aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/ml
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2021-01-23 02:17:48 +0000
committerAlex Ning <chineseperson5@gmail.com>2021-01-23 02:17:48 +0000
commitef5ba34b8707b394e0f309e81f34e8c4fa9fd3c4 (patch)
treefe556616b9c4c98eb2c408df2c758fc84129fc01 /app/src/main/java/ml
parent54ef23c35760b1da140eac688cbb94bbcf213de1 (diff)
downloadinfinity-for-reddit-ef5ba34b8707b394e0f309e81f34e8c4fa9fd3c4.tar
infinity-for-reddit-ef5ba34b8707b394e0f309e81f34e8c4fa9fd3c4.tar.gz
infinity-for-reddit-ef5ba34b8707b394e0f309e81f34e8c4fa9fd3c4.tar.bz2
infinity-for-reddit-ef5ba34b8707b394e0f309e81f34e8c4fa9fd3c4.tar.lz
infinity-for-reddit-ef5ba34b8707b394e0f309e81f34e8c4fa9fd3c4.tar.xz
infinity-for-reddit-ef5ba34b8707b394e0f309e81f34e8c4fa9fd3c4.tar.zst
infinity-for-reddit-ef5ba34b8707b394e0f309e81f34e8c4fa9fd3c4.zip
Switch to anonymous mode when updating the app. Save profile image url to SharedPreferences when logging in an account.
Diffstat (limited to 'app/src/main/java/ml')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/RedditDataRoomDatabase.java11
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/LoginActivity.java3
2 files changed, 11 insertions, 3 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/RedditDataRoomDatabase.java b/app/src/main/java/ml/docilealligator/infinityforreddit/RedditDataRoomDatabase.java
index a385ff4a..6c975dec 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/RedditDataRoomDatabase.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/RedditDataRoomDatabase.java
@@ -35,7 +35,7 @@ import ml.docilealligator.infinityforreddit.user.UserData;
@Database(entities = {Account.class, SubredditData.class, SubscribedSubredditData.class, UserData.class,
SubscribedUserData.class, MultiReddit.class, CustomTheme.class, RecentSearchQuery.class,
- ReadPost.class, PostFilter.class, PostFilterUsage.class}, version = 16)
+ ReadPost.class, PostFilter.class, PostFilterUsage.class}, version = 17)
public abstract class RedditDataRoomDatabase extends RoomDatabase {
private static RedditDataRoomDatabase INSTANCE;
@@ -48,7 +48,7 @@ public abstract class RedditDataRoomDatabase extends RoomDatabase {
.addMigrations(MIGRATION_1_2, MIGRATION_2_3, MIGRATION_3_4, MIGRATION_4_5,
MIGRATION_5_6, MIGRATION_6_7, MIGRATION_7_8, MIGRATION_8_9,
MIGRATION_9_10, MIGRATION_10_11, MIGRATION_11_12, MIGRATION_12_13,
- MIGRATION_13_14, MIGRATION_14_15, MIGRATION_15_16)
+ MIGRATION_13_14, MIGRATION_14_15, MIGRATION_15_16, MIGRATION_16_17)
.build();
}
}
@@ -309,4 +309,11 @@ public abstract class RedditDataRoomDatabase extends RoomDatabase {
database.execSQL("DROP TABLE subreddit_filter");
}
};
+
+ private static final Migration MIGRATION_16_17 = new Migration(16, 17) {
+ @Override
+ public void migrate(@NonNull SupportSQLiteDatabase database) {
+ database.execSQL("UPDATE accounts SET is_current_user = 0");
+ }
+ };
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LoginActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LoginActivity.java
index a55567e8..210a81c7 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LoginActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LoginActivity.java
@@ -161,7 +161,8 @@ public class LoginActivity extends BaseActivity {
@Override
public void onFetchMyInfoSuccess(String name, String profileImageUrl, String bannerImageUrl, int karma) {
mCurrentAccountSharedPreferences.edit().putString(SharedPreferencesUtils.ACCESS_TOKEN, accessToken)
- .putString(SharedPreferencesUtils.ACCOUNT_NAME, name).apply();
+ .putString(SharedPreferencesUtils.ACCOUNT_NAME, name)
+ .putString(SharedPreferencesUtils.ACCOUNT_IMAGE_URL, profileImageUrl).apply();
new ParseAndInsertNewAccountAsyncTask(name, accessToken, refreshToken, profileImageUrl, bannerImageUrl,
karma, authCode, mRedditDataRoomDatabase.accountDao(),
() -> {