mirror of
https://github.com/nuclearfog/Shitter.git
synced 2025-01-19 13:01:17 +01:00
database update, gradle dependency update, renamed table update constants
This commit is contained in:
parent
3a38db5055
commit
96f6aba71e
@ -65,7 +65,7 @@ dependencies {
|
||||
implementation 'com.squareup.okhttp3:okhttp:4.10.0'
|
||||
//noinspection GradleDependency
|
||||
implementation 'com.squareup.picasso:picasso:2.8'
|
||||
implementation 'com.github.open-android:Picasso-transformations:0.1.0'
|
||||
implementation 'jp.wasabeef:picasso-transformations:2.4.0'
|
||||
implementation 'com.github.QuadFlask:colorpicker:0.0.15'
|
||||
implementation 'com.github.nuclearfog:ZoomView:1.0.4'
|
||||
implementation 'com.github.nuclearfog:Tagger:2.3'
|
||||
|
@ -1220,6 +1220,7 @@ public class AppDatabase {
|
||||
private Status getStatus(Cursor cursor, SQLiteDatabase db) {
|
||||
Account login = settings.getLogin();
|
||||
DatabaseStatus result = new DatabaseStatus(cursor, login);
|
||||
DatabaseUser author = (DatabaseUser) result.getAuthor();
|
||||
// check if there is an embedded status
|
||||
if (result.getEmbeddedStatusId() != NO_ID) {
|
||||
result.setEmbeddedStatus(getStatus(result.getEmbeddedStatusId()));
|
||||
@ -1257,6 +1258,18 @@ public class AppDatabase {
|
||||
result.addLocation(location);
|
||||
}
|
||||
}
|
||||
if (author.getEmojiKeys().length > 0) {
|
||||
List<Emoji> emojiList = new LinkedList<>();
|
||||
for (String emojiKey : author.getEmojiKeys()) {
|
||||
Emoji item = getEmoji(db, emojiKey);
|
||||
if (item != null) {
|
||||
emojiList.add(item);
|
||||
}
|
||||
}
|
||||
if (!emojiList.isEmpty()) {
|
||||
author.addEmojis(emojiList.toArray(new Emoji[0]));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@ public class DatabaseAdapter {
|
||||
/**
|
||||
* database version
|
||||
*/
|
||||
private static final int DB_VERSION = 15;
|
||||
private static final int DB_VERSION = 16;
|
||||
|
||||
/**
|
||||
* database file name
|
||||
@ -44,7 +44,8 @@ public class DatabaseAdapter {
|
||||
+ UserTable.FRIENDS + " INTEGER,"
|
||||
+ UserTable.FOLLOWER + " INTEGER,"
|
||||
+ UserTable.STATUSES + " INTEGER,"
|
||||
+ UserTable.FAVORITS + " INTEGER);";
|
||||
+ UserTable.FAVORITS + " INTEGER,"
|
||||
+ UserTable.EMOJI + " TEXT);";
|
||||
|
||||
/**
|
||||
* SQL query to create a table for status information
|
||||
@ -232,54 +233,62 @@ public class DatabaseAdapter {
|
||||
/**
|
||||
* update account table to add social network hostname
|
||||
*/
|
||||
private static final String UPDATE_ADD_HOST = "ALTER TABLE " + AccountTable.NAME + " ADD " + AccountTable.HOSTNAME + " TEXT;";
|
||||
private static final String UPDATE_ACCOUNT_ADD_HOST = "ALTER TABLE " + AccountTable.NAME + " ADD " + AccountTable.HOSTNAME + " TEXT;";
|
||||
|
||||
/**
|
||||
* update account table to add API client ID
|
||||
*/
|
||||
private static final String UPDATE_ADD_CLIENT_ID = "ALTER TABLE " + AccountTable.NAME + " ADD " + AccountTable.CLIENT_ID + " TEXT;";
|
||||
private static final String UPDATE_ACCOUNT_ADD_CLIENT_ID = "ALTER TABLE " + AccountTable.NAME + " ADD " + AccountTable.CLIENT_ID + " TEXT;";
|
||||
|
||||
/**
|
||||
* update account table to add API client secret
|
||||
*/
|
||||
private static final String UPDATE_ADD_CLIENT_SEC = "ALTER TABLE " + AccountTable.NAME + " ADD " + AccountTable.CLIENT_SECRET + " TEXT;";
|
||||
private static final String UPDATE_ACCOUNT_ADD_CLIENT_SEC = "ALTER TABLE " + AccountTable.NAME + " ADD " + AccountTable.CLIENT_SECRET + " TEXT;";
|
||||
|
||||
/**
|
||||
* update account table to add API client secret
|
||||
*/
|
||||
private static final String UPDATE_ADD_API_ID = "ALTER TABLE " + AccountTable.NAME + " ADD " + AccountTable.API + " INTEGER;";
|
||||
private static final String UPDATE_ACCOUNT_ADD_API = "ALTER TABLE " + AccountTable.NAME + " ADD " + AccountTable.API + " INTEGER;";
|
||||
|
||||
/**
|
||||
* update account table to add API client secret
|
||||
*/
|
||||
private static final String UPDATE_ADD_REPLY_COUNT = "ALTER TABLE " + StatusTable.NAME + " ADD " + StatusTable.REPLY + " INTEGER;";
|
||||
private static final String UPDATE_STATUS_ADD_REPLY_COUNT = "ALTER TABLE " + StatusTable.NAME + " ADD " + StatusTable.REPLY + " INTEGER;";
|
||||
|
||||
/**
|
||||
* update account table to add API client secret
|
||||
*/
|
||||
private static final String UPDATE_ADD_BEARER = "ALTER TABLE " + AccountTable.NAME + " ADD " + AccountTable.BEARER + " TEXT;";
|
||||
private static final String UPDATE_ACCOUNT_ADD_BEARER = "ALTER TABLE " + AccountTable.NAME + " ADD " + AccountTable.BEARER + " TEXT;";
|
||||
|
||||
/**
|
||||
* update status table add location ID
|
||||
*/
|
||||
private static final String UPDATE_ADD_LOCATION_ID = "ALTER TABLE " + StatusTable.NAME + " ADD " + StatusTable.LOCATION + " INTEGER;";
|
||||
private static final String UPDATE_STATUS_ADD_LOCATION = "ALTER TABLE " + StatusTable.NAME + " ADD " + StatusTable.LOCATION + " INTEGER;";
|
||||
|
||||
/**
|
||||
* update status table add location ID
|
||||
*/
|
||||
private static final String UPDATE_ADD_STATUS_URL = "ALTER TABLE " + StatusTable.NAME + " ADD " + StatusTable.URL + " TEXT;";
|
||||
private static final String UPDATE_STATUS_ADD_URL = "ALTER TABLE " + StatusTable.NAME + " ADD " + StatusTable.URL + " TEXT;";
|
||||
|
||||
/**
|
||||
* update status table add emoji keys
|
||||
*/
|
||||
private static final String UPDATE_ADD_STATUS_EMOJI = "ALTER TABLE " + StatusTable.NAME + " ADD " + StatusTable.EMOJI + " TEXT;";
|
||||
private static final String UPDATE_STATUS_ADD_EMOJI = "ALTER TABLE " + StatusTable.NAME + " ADD " + StatusTable.EMOJI + " TEXT;";
|
||||
|
||||
/**
|
||||
* update status table add emoji keys
|
||||
*/
|
||||
private static final String UPDATE_ADD_STATUS_POLL = "ALTER TABLE " + StatusTable.NAME + " ADD " + StatusTable.POLL + " INTEGER;";
|
||||
private static final String UPDATE_STATUS_ADD_STATUS_POLL = "ALTER TABLE " + StatusTable.NAME + " ADD " + StatusTable.POLL + " INTEGER;";
|
||||
|
||||
private static final String UPDATE_ADD_LANGUAGE = "ALTER TABLE " + StatusTable.NAME + " ADD " + StatusTable.LANGUAGE + " TEXT;";
|
||||
/**
|
||||
* update status table add language string
|
||||
*/
|
||||
private static final String UPDATE_STATUS_ADD_LANGUAGE = "ALTER TABLE " + StatusTable.NAME + " ADD " + StatusTable.LANGUAGE + " TEXT;";
|
||||
|
||||
/**
|
||||
* updateuser table add emoji key string
|
||||
*/
|
||||
private static final String UPDATE_USER_ADD_EMOJI = "ALTER TABLE " + UserTable.NAME + " ADD " + UserTable.EMOJI + " TEXT;";
|
||||
|
||||
/**
|
||||
* singleton instance
|
||||
@ -328,41 +337,45 @@ public class DatabaseAdapter {
|
||||
db.setVersion(DB_VERSION);
|
||||
} else {
|
||||
if (db.getVersion() < 6) {
|
||||
db.execSQL(UPDATE_ADD_HOST);
|
||||
db.execSQL(UPDATE_ADD_CLIENT_ID);
|
||||
db.execSQL(UPDATE_ADD_CLIENT_SEC);
|
||||
db.execSQL(UPDATE_ACCOUNT_ADD_HOST);
|
||||
db.execSQL(UPDATE_ACCOUNT_ADD_CLIENT_ID);
|
||||
db.execSQL(UPDATE_ACCOUNT_ADD_CLIENT_SEC);
|
||||
db.setVersion(6);
|
||||
}
|
||||
if (db.getVersion() < 7) {
|
||||
db.execSQL(UPDATE_ADD_API_ID);
|
||||
db.execSQL(UPDATE_ACCOUNT_ADD_API);
|
||||
db.setVersion(7);
|
||||
}
|
||||
if (db.getVersion() < 8) {
|
||||
db.execSQL(UPDATE_ADD_REPLY_COUNT);
|
||||
db.execSQL(UPDATE_STATUS_ADD_REPLY_COUNT);
|
||||
db.setVersion(8);
|
||||
}
|
||||
if (db.getVersion() < 9) {
|
||||
db.execSQL(UPDATE_ADD_BEARER);
|
||||
db.execSQL(UPDATE_ACCOUNT_ADD_BEARER);
|
||||
db.setVersion(9);
|
||||
}
|
||||
if (db.getVersion() < 11) {
|
||||
db.execSQL(UPDATE_ADD_LOCATION_ID);
|
||||
db.execSQL(UPDATE_STATUS_ADD_LOCATION);
|
||||
db.setVersion(11);
|
||||
}
|
||||
if (db.getVersion() < 12) {
|
||||
db.execSQL(UPDATE_ADD_STATUS_URL);
|
||||
db.execSQL(UPDATE_STATUS_ADD_URL);
|
||||
db.setVersion(12);
|
||||
}
|
||||
if (db.getVersion() < 13) {
|
||||
db.execSQL(UPDATE_ADD_STATUS_EMOJI);
|
||||
db.execSQL(UPDATE_STATUS_ADD_EMOJI);
|
||||
db.setVersion(13);
|
||||
}
|
||||
if (db.getVersion() < 14) {
|
||||
db.execSQL(UPDATE_ADD_STATUS_POLL);
|
||||
db.execSQL(UPDATE_STATUS_ADD_STATUS_POLL);
|
||||
db.setVersion(14);
|
||||
}
|
||||
if (db.getVersion() < 15) {
|
||||
db.execSQL(UPDATE_STATUS_ADD_LANGUAGE);
|
||||
db.setVersion(15);
|
||||
}
|
||||
if (db.getVersion() < DB_VERSION) {
|
||||
db.execSQL(UPDATE_ADD_LANGUAGE);
|
||||
db.execSQL(UPDATE_USER_ADD_EMOJI);
|
||||
db.setVersion(DB_VERSION);
|
||||
}
|
||||
}
|
||||
@ -492,6 +505,11 @@ public class DatabaseAdapter {
|
||||
* count of the statuses favored by the user
|
||||
*/
|
||||
String FAVORITS = "favorCount";
|
||||
|
||||
/**
|
||||
* emoji keys
|
||||
*/
|
||||
String EMOJI = "userEmoji";
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -36,7 +36,7 @@ public class DatabaseStatus implements Status {
|
||||
|
||||
private static final long serialVersionUID = -5957556706939766801L;
|
||||
|
||||
private static final Pattern MEDIA_SEPARATOR = Pattern.compile(";");
|
||||
private static final Pattern KEY_SEPARATOR = Pattern.compile(";");
|
||||
|
||||
private long id;
|
||||
private long time;
|
||||
@ -105,9 +105,9 @@ public class DatabaseStatus implements Status {
|
||||
spoiler = (register & MASK_STATUS_SPOILER) != 0;
|
||||
|
||||
if (mediaKeys != null && !mediaKeys.isEmpty())
|
||||
this.mediaKeys = MEDIA_SEPARATOR.split(mediaKeys);
|
||||
this.mediaKeys = KEY_SEPARATOR.split(mediaKeys);
|
||||
if (emojiKeys != null && !emojiKeys.isEmpty())
|
||||
this.emojiKeys = MEDIA_SEPARATOR.split(emojiKeys);
|
||||
this.emojiKeys = KEY_SEPARATOR.split(emojiKeys);
|
||||
if (statusUrl != null)
|
||||
this.statusUrl = statusUrl;
|
||||
if (language != null)
|
||||
@ -375,9 +375,9 @@ public class DatabaseStatus implements Status {
|
||||
}
|
||||
|
||||
/**
|
||||
* add status media
|
||||
* add status emojis
|
||||
*
|
||||
* @param emojis media array
|
||||
* @param emojis emoji array
|
||||
*/
|
||||
public void addEmojis(@NonNull Emoji[] emojis) {
|
||||
this.emojis = emojis;
|
||||
|
@ -16,6 +16,8 @@ import org.nuclearfog.twidda.model.Account;
|
||||
import org.nuclearfog.twidda.model.Emoji;
|
||||
import org.nuclearfog.twidda.model.User;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* database implementation of an user
|
||||
*
|
||||
@ -25,6 +27,8 @@ public class DatabaseUser implements User {
|
||||
|
||||
private static final long serialVersionUID = 2367055336838212570L;
|
||||
|
||||
private static final Pattern KEY_SEPARATOR = Pattern.compile(";");
|
||||
|
||||
private long id;
|
||||
private long createdAt;
|
||||
private int following;
|
||||
@ -45,6 +49,8 @@ public class DatabaseUser implements User {
|
||||
private String profileImageOrig = "";
|
||||
private String profileBannerSmall = "";
|
||||
private String profileBannerOrig = "";
|
||||
private String[] emojiKeys = {};
|
||||
private Emoji[] emojis = {};
|
||||
|
||||
/**
|
||||
* @param cursor database cursor containing user column
|
||||
@ -59,6 +65,7 @@ public class DatabaseUser implements User {
|
||||
String link = cursor.getString(cursor.getColumnIndexOrThrow(UserTable.LINK));
|
||||
String location = cursor.getString(cursor.getColumnIndexOrThrow(UserTable.LOCATION));
|
||||
String profileBannerOrig = cursor.getString(cursor.getColumnIndexOrThrow(UserTable.BANNER));
|
||||
String emojiKeys = cursor.getString(cursor.getColumnIndexOrThrow(UserTable.EMOJI));
|
||||
createdAt = cursor.getLong(cursor.getColumnIndexOrThrow(UserTable.SINCE));
|
||||
following = cursor.getInt(cursor.getColumnIndexOrThrow(UserTable.FRIENDS));
|
||||
follower = cursor.getInt(cursor.getColumnIndexOrThrow(UserTable.FOLLOWER));
|
||||
@ -85,6 +92,10 @@ public class DatabaseUser implements User {
|
||||
this.profileImageOrig = profileImageOrig;
|
||||
if (profileBannerOrig != null)
|
||||
this.profileBannerOrig = profileBannerOrig;
|
||||
if (emojiKeys != null && !emojiKeys.isEmpty())
|
||||
this.emojiKeys = KEY_SEPARATOR.split(emojiKeys);
|
||||
if (emojiKeys != null && !emojiKeys.isEmpty())
|
||||
this.emojiKeys = KEY_SEPARATOR.split(emojiKeys);
|
||||
|
||||
switch (account.getConfiguration()) {
|
||||
case TWITTER1:
|
||||
@ -240,7 +251,7 @@ public class DatabaseUser implements User {
|
||||
|
||||
@Override
|
||||
public Emoji[] getEmojis() {
|
||||
return new Emoji[0];
|
||||
return emojis;
|
||||
}
|
||||
|
||||
|
||||
@ -264,6 +275,22 @@ public class DatabaseUser implements User {
|
||||
return "name=\"" + screen_name + "\"";
|
||||
}
|
||||
|
||||
/**
|
||||
* @return used emoji keys
|
||||
*/
|
||||
public String[] getEmojiKeys() {
|
||||
return emojiKeys;
|
||||
}
|
||||
|
||||
/**
|
||||
* add status emojis
|
||||
*
|
||||
* @param emojis emoji array
|
||||
*/
|
||||
public void addEmojis(@NonNull Emoji[] emojis) {
|
||||
this.emojis = emojis;
|
||||
}
|
||||
|
||||
/**
|
||||
* set this user as current user
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user