aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/build.gradle2
-rw-r--r--app/src/main/AndroidManifest.xml18
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java6
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/RedditDataRoomDatabase.java11
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountPostsActivity.java6
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountSavedThingActivity.java6
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/AnonymousSubscriptionsActivity.java5
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/BaseActivity.java32
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/CreateMultiRedditActivity.java5
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomThemeListingActivity.java5
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizePostFilterActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizeThemeActivity.java5
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditCommentActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditMultiRedditActivity.java5
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditPostActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditProfileActivity.java356
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredPostsActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/FullMarkdownActivity.java5
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/GiveAwardActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/InboxActivity.java6
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/LoginActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java11
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/MultiredditSelectionActivity.java5
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostFilterPreferenceActivity.java5
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostFilterUsageListingActivity.java5
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostGalleryActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostImageActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostLinkActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostTextActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostVideoActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/ReportActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/RulesActivity.java5
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchResultActivity.java5
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchSubredditsResultActivity.java4
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchUsersResultActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/SelectUserFlairActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/SelectedSubredditsAndUsersActivity.java5
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/SendPrivateMessageActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/SettingsActivity.java5
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubmitCrosspostActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubredditMultiselectionActivity.java5
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubredditSelectionActivity.java5
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubscribedThingListingActivity.java5
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/TrendingActivity.java6
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewMultiRedditDetailActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPostDetailActivity.java5
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPrivateMessagesActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java21
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java26
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/WebViewActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/WikiActivity.java5
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java6
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java326
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/apis/RedditAPI.java20
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/events/SubmitChangeAvatarEvent.java11
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/events/SubmitChangeBannerEvent.java11
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/events/SubmitSaveProfileEvent.java11
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/post/Post.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/services/EditProfileService.java260
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/subreddit/SubredditSettingData.java634
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/user/FetchUserData.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/user/ParseUserData.java3
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/user/UserData.java9
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/utils/EditProfileUtils.java276
-rw-r--r--app/src/main/res/drawable/ic_dot_outline.xml9
-rw-r--r--app/src/main/res/layout/activity_anonymous_subscriptions.xml1
-rw-r--r--app/src/main/res/layout/activity_comment_full_markdown.xml1
-rw-r--r--app/src/main/res/layout/activity_create_multi_reddit.xml1
-rw-r--r--app/src/main/res/layout/activity_edit_multi_reddit.xml1
-rw-r--r--app/src/main/res/layout/activity_edit_profile.xml176
-rw-r--r--app/src/main/res/layout/activity_multireddit_selection.xml1
-rw-r--r--app/src/main/res/layout/activity_rules.xml1
-rw-r--r--app/src/main/res/layout/activity_search_result.xml1
-rw-r--r--app/src/main/res/layout/activity_selected_subreddits.xml1
-rw-r--r--app/src/main/res/layout/activity_settings.xml1
-rw-r--r--app/src/main/res/layout/activity_subreddit_selection.xml1
-rw-r--r--app/src/main/res/layout/activity_subscribed_subreddits_multiselection.xml1
-rw-r--r--app/src/main/res/layout/activity_subscribed_thing_listing.xml1
-rw-r--r--app/src/main/res/layout/activity_view_post_detail.xml4
-rw-r--r--app/src/main/res/layout/activity_view_subreddit_detail.xml2
-rw-r--r--app/src/main/res/layout/activity_view_user_detail.xml8
-rw-r--r--app/src/main/res/layout/activity_view_video.xml1
-rw-r--r--app/src/main/res/layout/activity_wiki.xml1
-rw-r--r--app/src/main/res/layout/app_bar_main.xml2
-rw-r--r--app/src/main/res/layout/fragment_theme_preview_posts.xml3
-rw-r--r--app/src/main/res/layout/item_post_card_2_video_autoplay.xml3
-rw-r--r--app/src/main/res/layout/item_post_card_2_video_autoplay_legacy_controller.xml3
-rw-r--r--app/src/main/res/layout/item_post_card_2_with_preview.xml32
-rw-r--r--app/src/main/res/layout/item_post_gallery.xml34
-rw-r--r--app/src/main/res/layout/item_post_text.xml3
-rw-r--r--app/src/main/res/layout/item_post_video_type_autoplay.xml3
-rw-r--r--app/src/main/res/layout/item_post_video_type_autoplay_legacy_controller.xml3
-rw-r--r--app/src/main/res/layout/item_post_with_preview.xml51
-rw-r--r--app/src/main/res/layout/item_trending_search.xml3
-rw-r--r--app/src/main/res/menu/edit_profile_activity.xml11
-rw-r--r--app/src/main/res/menu/view_user_detail_activity.xml5
-rw-r--r--app/src/main/res/values-land-v28/styles.xml2
-rw-r--r--app/src/main/res/values-v28/styles.xml2
-rw-r--r--app/src/main/res/values/strings.xml25
-rw-r--r--app/src/main/res/values/styles.xml10
102 files changed, 2298 insertions, 324 deletions
diff --git a/app/build.gradle b/app/build.gradle
index 6086d8eb..6b68777f 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -68,7 +68,7 @@ dependencies {
annotationProcessor "androidx.room:room-compiler:$roomVersion"
implementation 'androidx.viewpager2:viewpager2:1.1.0-beta01'
implementation 'androidx.work:work-runtime:2.5.0'
- implementation 'com.google.android.material:material:1.3.0'
+ implementation 'com.google.android.material:material:1.5.0-alpha05'
/** ExoPlayer **/
def exoplayerVersion = "2.10.8"
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index edad7ed5..826dc004 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -205,7 +205,8 @@
android:label="@string/account_saved_thing_activity_label"
android:parentActivityName=".activities.MainActivity"
android:theme="@style/AppTheme.Slidable" />
- <activity android:name=".activities.ShareDataResolverActivity">
+ <activity android:name=".activities.ShareDataResolverActivity"
+ android:exported="false">
<intent-filter>
<action android:name="android.intent.action.SEND" />
@@ -263,7 +264,8 @@
android:label="@string/search_subreddits_activity_label"
android:parentActivityName=".activities.MainActivity"
android:theme="@style/AppTheme.Slidable" />
- <activity android:name=".activities.LinkResolverActivity">
+ <activity android:name=".activities.LinkResolverActivity"
+ android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
@@ -356,7 +358,8 @@
android:name=".activities.MainActivity"
android:label="@string/application_name"
android:theme="@style/AppTheme.Launcher"
- android:windowSoftInputMode="adjustPan">
+ android:windowSoftInputMode="adjustPan"
+ android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
@@ -391,6 +394,11 @@
android:parentActivityName=".activities.MainActivity"
android:theme="@style/AppTheme.SlidableWithTranslucentWindow" />
+ <activity android:name=".activities.EditProfileActivity"
+ android:parentActivityName=".activities.MainActivity"
+ android:theme="@style/AppTheme.SlidableWithTranslucentWindow"
+ android:windowSoftInputMode="adjustPan" />
+
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="ml.docilealligator.infinityforreddit.provider"
@@ -417,6 +425,10 @@
<service
android:name=".services.MaterialYouService"
android:exported="false" />
+ <service
+ android:name=".services.EditProfileService"
+ android:enabled="true"
+ android:exported="false" />
</application>
</manifest> \ No newline at end of file
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java b/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java
index 2fc08bd9..c33a6deb 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java
@@ -14,6 +14,7 @@ import ml.docilealligator.infinityforreddit.activities.CustomizePostFilterActivi
import ml.docilealligator.infinityforreddit.activities.CustomizeThemeActivity;
import ml.docilealligator.infinityforreddit.activities.EditCommentActivity;
import ml.docilealligator.infinityforreddit.activities.EditMultiRedditActivity;
+import ml.docilealligator.infinityforreddit.activities.EditProfileActivity;
import ml.docilealligator.infinityforreddit.activities.EditPostActivity;
import ml.docilealligator.infinityforreddit.activities.FetchRandomSubredditOrPostActivity;
import ml.docilealligator.infinityforreddit.activities.FilteredPostsActivity;
@@ -78,6 +79,7 @@ import ml.docilealligator.infinityforreddit.fragments.ViewRedditGalleryImageOrGi
import ml.docilealligator.infinityforreddit.fragments.ViewRedditGalleryVideoFragment;
import ml.docilealligator.infinityforreddit.services.DownloadMediaService;
import ml.docilealligator.infinityforreddit.services.DownloadRedditVideoService;
+import ml.docilealligator.infinityforreddit.services.EditProfileService;
import ml.docilealligator.infinityforreddit.services.MaterialYouService;
import ml.docilealligator.infinityforreddit.services.SubmitPostService;
import ml.docilealligator.infinityforreddit.settings.AdvancedPreferenceFragment;
@@ -286,4 +288,8 @@ public interface AppComponent {
void inject(WikiActivity wikiActivity);
void inject(Infinity infinity);
+
+ void inject(EditProfileService editProfileService);
+
+ void inject(EditProfileActivity editProfileActivity);
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/RedditDataRoomDatabase.java b/app/src/main/java/ml/docilealligator/infinityforreddit/RedditDataRoomDatabase.java
index eda22c35..229e047c 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/RedditDataRoomDatabase.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/RedditDataRoomDatabase.java
@@ -37,7 +37,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, AnonymousMultiredditSubreddit.class}, version = 21)
+ ReadPost.class, PostFilter.class, PostFilterUsage.class, AnonymousMultiredditSubreddit.class}, version = 22)
public abstract class RedditDataRoomDatabase extends RoomDatabase {
private static RedditDataRoomDatabase INSTANCE;
@@ -51,7 +51,8 @@ public abstract class RedditDataRoomDatabase extends RoomDatabase {
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_16_17,
- MIGRATION_17_18, MIGRATION_18_19, MIGRATION_19_20, MIGRATION_20_21)
+ MIGRATION_17_18, MIGRATION_18_19, MIGRATION_19_20, MIGRATION_20_21,
+ MIGRATION_21_22)
.build();
}
}
@@ -358,4 +359,10 @@ public abstract class RedditDataRoomDatabase extends RoomDatabase {
database.execSQL("ALTER TABLE post_filter ADD COLUMN contain_domains TEXT");
}
};
+ private static final Migration MIGRATION_21_22 = new Migration(21, 22) {
+ @Override
+ public void migrate(@NonNull SupportSQLiteDatabase database) {
+ database.execSQL("ALTER TABLE users ADD COLUMN title TEXT");
+ }
+ };
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountPostsActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountPostsActivity.java
index 2bd6a247..69c20f34 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountPostsActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountPostsActivity.java
@@ -50,10 +50,10 @@ public class AccountPostsActivity extends BaseActivity implements SortTypeSelect
@BindView(R.id.coordinator_layout_account_posts_activity)
CoordinatorLayout coordinatorLayout;
- @BindView(R.id.collapsing_toolbar_layout_account_posts_activity)
- CollapsingToolbarLayout collapsingToolbarLayout;
@BindView(R.id.appbar_layout_account_posts_activity)
AppBarLayout appBarLayout;
+ @BindView(R.id.collapsing_toolbar_layout_account_posts_activity)
+ CollapsingToolbarLayout collapsingToolbarLayout;
@BindView(R.id.toolbar_account_posts_activity)
Toolbar toolbar;
@Inject
@@ -160,7 +160,7 @@ public class AccountPostsActivity extends BaseActivity implements SortTypeSelect
@Override
protected void applyCustomTheme() {
coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
- applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar);
+ applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar);
}
private void initializeFragment() {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountSavedThingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountSavedThingActivity.java
index bbdb74f0..6254f97d 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountSavedThingActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountSavedThingActivity.java
@@ -59,10 +59,10 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT
@BindView(R.id.coordinator_layout_account_saved_thing_activity)
CoordinatorLayout coordinatorLayout;
- @BindView(R.id.collapsing_toolbar_layout_account_saved_thing_activity)
- CollapsingToolbarLayout collapsingToolbarLayout;
@BindView(R.id.appbar_layout_account_saved_thing_activity)
AppBarLayout appBarLayout;
+ @BindView(R.id.collapsing_toolbar_layout_account_saved_thing_activity)
+ CollapsingToolbarLayout collapsingToolbarLayout;
@BindView(R.id.toolbar_account_saved_thing_activity)
Toolbar toolbar;
@BindView(R.id.tab_layout_tab_layout_account_saved_thing_activity_activity)
@@ -167,7 +167,7 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT
@Override
protected void applyCustomTheme() {
coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
- applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar);
+ applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar);
applyTabLayoutTheme(tabLayout);
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AnonymousSubscriptionsActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AnonymousSubscriptionsActivity.java
index f0e753b7..403f3567 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AnonymousSubscriptionsActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AnonymousSubscriptionsActivity.java
@@ -13,6 +13,7 @@ import androidx.appcompat.widget.Toolbar;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import com.google.android.material.appbar.AppBarLayout;
+import com.google.android.material.appbar.CollapsingToolbarLayout;
import com.r0adkll.slidr.Slidr;
import javax.inject.Inject;
@@ -32,6 +33,8 @@ public class AnonymousSubscriptionsActivity extends BaseActivity {
CoordinatorLayout coordinatorLayout;
@BindView(R.id.appbar_layout_anonymous_subscriptions_activity)
AppBarLayout appBarLayout;
+ @BindView(R.id.collapsing_toolbar_layout_anonymous_subscriptions_activity)
+ CollapsingToolbarLayout collapsingToolbarLayout;
@BindView(R.id.toolbar_anonymous_subscriptions_activity)
Toolbar toolbar;
@Inject
@@ -99,7 +102,7 @@ public class AnonymousSubscriptionsActivity extends BaseActivity {
@Override
protected void applyCustomTheme() {
coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
- applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar);
+ applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar);
}
@Override
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/BaseActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/BaseActivity.java
index 12e565c4..13f40f63 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/BaseActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/BaseActivity.java
@@ -1,5 +1,10 @@
package ml.docilealligator.infinityforreddit.activities;
+import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY;
+import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM;
+import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_NO;
+import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_YES;
+
import android.annotation.SuppressLint;
import android.content.SharedPreferences;
import android.content.res.ColorStateList;
@@ -25,6 +30,7 @@ import androidx.recyclerview.widget.RecyclerView;
import androidx.viewpager2.widget.ViewPager2;
import com.google.android.material.appbar.AppBarLayout;
+import com.google.android.material.appbar.CollapsingToolbarLayout;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.tabs.TabLayout;
@@ -44,11 +50,6 @@ import ml.docilealligator.infinityforreddit.font.TitleFontStyle;
import ml.docilealligator.infinityforreddit.utils.CustomThemeSharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
-import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY;
-import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM;
-import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_NO;
-import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_YES;
-
public abstract class BaseActivity extends AppCompatActivity {
private boolean immersiveInterface;
private boolean changeStatusBarIconColor;
@@ -275,6 +276,15 @@ public abstract class BaseActivity extends AppCompatActivity {
return 0;
}
+ public int getStatusBarHeight() {
+ int result = 0;
+ int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
+ if (resourceId > 0) {
+ result = getResources().getDimensionPixelSize(resourceId);
+ }
+ return result;
+ }
+
protected void setTransparentStatusBarAfterToolbarCollapsed() {
this.transparentStatusBarAfterToolbarCollapsed = true;
}
@@ -287,8 +297,18 @@ public abstract class BaseActivity extends AppCompatActivity {
isImmersiveInterfaceApplicable = false;
}
- protected void applyAppBarLayoutAndToolbarTheme(AppBarLayout appBarLayout, Toolbar toolbar) {
+ protected void applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(AppBarLayout appBarLayout, @Nullable CollapsingToolbarLayout collapsingToolbarLayout, Toolbar toolbar) {
+ applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar, true);
+ }
+
+ protected void applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(AppBarLayout appBarLayout, @Nullable CollapsingToolbarLayout collapsingToolbarLayout, Toolbar toolbar, boolean setToolbarBackgroundColor) {
appBarLayout.setBackgroundColor(customThemeWrapper.getColorPrimary());
+ if (collapsingToolbarLayout != null) {
+ collapsingToolbarLayout.setContentScrimColor(customThemeWrapper.getColorPrimary());
+ }
+ if (setToolbarBackgroundColor) {
+ toolbar.setBackgroundColor(customThemeWrapper.getColorPrimary());
+ }
toolbar.setTitleTextColor(customThemeWrapper.getToolbarPrimaryTextAndIconColor());
toolbar.setSubtitleTextColor(customThemeWrapper.getToolbarSecondaryTextColor());
if (toolbar.getNavigationIcon() != null) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentActivity.java
index a244fafe..1f85f362 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentActivity.java
@@ -310,7 +310,7 @@ public class CommentActivity extends BaseActivity implements UploadImageEnabledA
@Override
protected void applyCustomTheme() {
coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
- applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar);
+ applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, null, toolbar);
commentParentMarkwonView.setTextColor(mCustomThemeWrapper.getCommentColor());
divider.setBackgroundColor(mCustomThemeWrapper.getDividerColor());
commentEditText.setTextColor(mCustomThemeWrapper.getCommentColor());
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CreateMultiRedditActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CreateMultiRedditActivity.java
index c586c1da..9ae956f9 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CreateMultiRedditActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CreateMultiRedditActivity.java
@@ -19,6 +19,7 @@ import androidx.appcompat.widget.Toolbar;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import com.google.android.material.appbar.AppBarLayout;
+import com.google.android.material.appbar.CollapsingToolbarLayout;
import com.google.android.material.snackbar.Snackbar;
import com.r0adkll.slidr.Slidr;
@@ -47,6 +48,8 @@ public class CreateMultiRedditActivity extends BaseActivity {
CoordinatorLayout coordinatorLayout;
@BindView(R.id.appbar_layout_create_multi_reddit_activity)
AppBarLayout appBarLayout;
+ @BindView(R.id.collapsing_toolbar_layout_create_multi_reddit_activity)
+ CollapsingToolbarLayout collapsingToolbarLayout;
@BindView(R.id.toolbar_create_multi_reddit_activity)
Toolbar toolbar;
@BindView(R.id.multi_reddit_name_edit_text_create_multi_reddit_activity)
@@ -220,7 +223,7 @@ public class CreateMultiRedditActivity extends BaseActivity {
@Override
protected void applyCustomTheme() {
coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
- applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar);
+ applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar);
int primaryTextColor = mCustomThemeWrapper.getPrimaryTextColor();
int secondaryTextColor = mCustomThemeWrapper.getSecondaryTextColor();
nameEditText.setTextColor(primaryTextColor);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomThemeListingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomThemeListingActivity.java
index 144898bb..8ab69a4d 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomThemeListingActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomThemeListingActivity.java
@@ -22,6 +22,7 @@ import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.appbar.AppBarLayout;
+import com.google.android.material.appbar.CollapsingToolbarLayout;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.snackbar.Snackbar;
@@ -62,6 +63,8 @@ public class CustomThemeListingActivity extends BaseActivity implements
CoordinatorLayout coordinatorLayout;
@BindView(R.id.appbar_layout_customize_theme_listing_activity)
AppBarLayout appBarLayout;
+ @BindView(R.id.collapsing_toolbar_layout_customize_theme_listing_activity)
+ CollapsingToolbarLayout collapsingToolbarLayout;
@BindView(R.id.toolbar_customize_theme_listing_activity)
Toolbar toolbar;
@BindView(R.id.recycler_view_customize_theme_listing_activity)
@@ -152,7 +155,7 @@ public class CustomThemeListingActivity extends BaseActivity implements
@Override
protected void applyCustomTheme() {
- applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar);
+ applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar);
}
@Override
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizePostFilterActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizePostFilterActivity.java
index 37194312..8603c808 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizePostFilterActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizePostFilterActivity.java
@@ -395,7 +395,7 @@ public class CustomizePostFilterActivity extends BaseActivity {
@Override
protected void applyCustomTheme() {
coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
- applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar);
+ applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar);
int primaryTextColor = mCustomThemeWrapper.getPrimaryTextColor();
int primaryIconColor = mCustomThemeWrapper.getPrimaryIconColor();
Drawable cursorDrawable = Utils.getTintedDrawable(this, R.drawable.edit_text_cursor, primaryTextColor);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizeThemeActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizeThemeActivity.java
index cadaa8d5..58dd009b 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizeThemeActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizeThemeActivity.java
@@ -15,6 +15,7 @@ import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.appbar.AppBarLayout;
+import com.google.android.material.appbar.CollapsingToolbarLayout;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.snackbar.Snackbar;
@@ -56,6 +57,8 @@ public class CustomizeThemeActivity extends BaseActivity {
CoordinatorLayout coordinatorLayout;
@BindView(R.id.appbar_layout_customize_theme_activity)
AppBarLayout appBarLayout;
+ @BindView(R.id.collapsing_toolbar_layout_customize_theme_activity)
+ CollapsingToolbarLayout collapsingToolbarLayout;
@BindView(R.id.toolbar_customize_theme_activity)
Toolbar toolbar;
@BindView(R.id.recycler_view_customize_theme_activity)
@@ -253,6 +256,6 @@ public class CustomizeThemeActivity extends BaseActivity {
@Override
protected void applyCustomTheme() {
- applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar);
+ applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar);
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditCommentActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditCommentActivity.java
index e46f581b..4f4b81ec 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditCommentActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditCommentActivity.java
@@ -183,7 +183,7 @@ public class EditCommentActivity extends BaseActivity implements UploadImageEnab
@Override
protected void applyCustomTheme() {
coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
- applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar);
+ applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, null, toolbar);
contentEditText.setTextColor(mCustomThemeWrapper.getCommentColor());
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditMultiRedditActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditMultiRedditActivity.java
index eb559f1c..1ff1b157 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditMultiRedditActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditMultiRedditActivity.java
@@ -21,6 +21,7 @@ import androidx.appcompat.widget.Toolbar;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import com.google.android.material.appbar.AppBarLayout;
+import com.google.android.material.appbar.CollapsingToolbarLayout;
import com.google.android.material.snackbar.Snackbar;
import com.r0adkll.slidr.Slidr;
@@ -51,6 +52,8 @@ public class EditMultiRedditActivity extends BaseActivity {
CoordinatorLayout coordinatorLayout;
@BindView(R.id.appbar_layout_edit_multi_reddit_activity)
AppBarLayout appBarLayout;
+ @BindView(R.id.collapsing_toolbar_layout_edit_multi_reddit_activity)
+ CollapsingToolbarLayout collapsingToolbarLayout;
@BindView(R.id.toolbar_edit_multi_reddit_activity)
Toolbar toolbar;
@BindView(R.id.progress_bar_edit_multi_reddit_activity)
@@ -272,7 +275,7 @@ public class EditMultiRedditActivity extends BaseActivity {
@Override
protected void applyCustomTheme() {
coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
- applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar);
+ applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar);
progressBar.setIndeterminateTintList(ColorStateList.valueOf(mCustomThemeWrapper.getColorAccent()));
int primaryTextColor = mCustomThemeWrapper.getPrimaryTextColor();
int secondaryTextColor = mCustomThemeWrapper.getSecondaryTextColor();
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditPostActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditPostActivity.java
index 21e1418d..0d22d9b3 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditPostActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditPostActivity.java
@@ -192,7 +192,7 @@ public class EditPostActivity extends BaseActivity implements UploadImageEnabled
@Override
protected void applyCustomTheme() {
coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
- applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar);
+ applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, null, toolbar);
titleTextView.setTextColor(mCustomThemeWrapper.getPostTitleColor());
divider.setBackgroundColor(mCustomThemeWrapper.getPostTitleColor());
contentEditText.setTextColor(mCustomThemeWrapper.getPostContentColor());
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditProfileActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditProfileActivity.java
new file mode 100644
index 00000000..f267e9f4
--- /dev/null
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditProfileActivity.java
@@ -0,0 +1,356 @@
+package ml.docilealligator.infinityforreddit.activities;
+
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.os.Bundle;
+import android.view.Gravity;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.EditText;
+import android.widget.FrameLayout.LayoutParams;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.appcompat.widget.Toolbar;
+import androidx.coordinatorlayout.widget.CoordinatorLayout;
+import androidx.core.content.ContextCompat;
+import androidx.lifecycle.ViewModelProvider;
+
+import com.bumptech.glide.Glide;
+import com.bumptech.glide.RequestManager;
+import com.bumptech.glide.request.RequestOptions;
+import com.google.android.material.appbar.AppBarLayout;
+import com.google.android.material.dialog.MaterialAlertDialogBuilder;
+import com.r0adkll.slidr.Slidr;
+import com.r0adkll.slidr.model.SlidrInterface;
+
+import org.greenrobot.eventbus.EventBus;
+import org.greenrobot.eventbus.Subscribe;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import butterknife.BindView;
+import butterknife.ButterKnife;
+import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
+import ml.docilealligator.infinityforreddit.Infinity;
+import ml.docilealligator.infinityforreddit.R;
+import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
+import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
+import ml.docilealligator.infinityforreddit.events.SubmitChangeAvatarEvent;
+import ml.docilealligator.infinityforreddit.events.SubmitChangeBannerEvent;
+import ml.docilealligator.infinityforreddit.events.SubmitSaveProfileEvent;
+import ml.docilealligator.infinityforreddit.services.EditProfileService;
+import ml.docilealligator.infinityforreddit.user.UserViewModel;
+import ml.docilealligator.infinityforreddit.utils.EditProfileUtils;
+import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
+import retrofit2.Retrofit;
+
+public class EditProfileActivity extends BaseActivity {
+
+ private static final int PICK_IMAGE_BANNER_REQUEST_CODE = 0x401;
+ private static final int PICK_IMAGE_AVATAR_REQUEST_CODE = 0x402;
+
+ @BindView(R.id.root_layout_view_edit_profile_activity)
+ CoordinatorLayout root;
+ @BindView(R.id.content_view_edit_profile_activity)
+ LinearLayout content;
+ @BindView(R.id.appbar_layout_view_edit_profile_activity)
+ AppBarLayout appBarLayout;
+ @BindView(R.id.toolbar_view_edit_profile_activity)
+ Toolbar toolbar;
+ @BindView(R.id.image_view_banner_edit_profile_activity)
+ ImageView bannerImageView;
+ @BindView(R.id.image_view_avatar_edit_profile_activity)
+ ImageView avatarImageView;
+ @BindView(R.id.image_view_change_banner_edit_profile_activity)
+ ImageView changeBanner;
+ @BindView(R.id.image_view_change_avatar_edit_profile_activity)
+ ImageView changeAvatar;
+ @BindView(R.id.edit_text_display_name_edit_profile_activity)
+ EditText editTextDisplayName;
+ @BindView(R.id.edit_text_about_you_edit_profile_activity)
+ EditText editTextAboutYou;
+
+ @Inject
+ @Named("current_account")
+ SharedPreferences mCurrentAccountSharedPreferences;
+ @Inject
+ @Named("default")
+ SharedPreferences mSharedPreferences;
+ @Inject
+ @Named("oauth")
+ Retrofit mOauthRetrofit;
+ @Inject
+ RedditDataRoomDatabase mRedditDataRoomDatabase;
+ @Inject
+ CustomThemeWrapper mCustomThemeWrapper;
+
+ //
+ private String mAccountName;
+ private String mAccessToken;
+
+ @Override
+ protected void onCreate(@Nullable Bundle savedInstanceState) {
+ ((Infinity) getApplication()).getAppComponent().inject(this);
+ setTransparentStatusBarAfterToolbarCollapsed();
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_edit_profile);
+ ButterKnife.bind(this);
+ EventBus.getDefault().register(this);
+ applyCustomTheme();
+ adjustToolbar(toolbar);
+ setSupportActionBar(toolbar);
+
+ if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK, true)) {
+ SlidrInterface slidrInterface = Slidr.attach(this);
+ slidrInterface.unlock();
+ }
+
+ mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
+ mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, null);
+
+ changeBanner.setOnClickListener(view -> {
+ startPickImage(PICK_IMAGE_BANNER_REQUEST_CODE);
+ });
+ changeAvatar.setOnClickListener(view -> {
+ startPickImage(PICK_IMAGE_AVATAR_REQUEST_CODE);
+ });
+
+ final RequestManager glide = Glide.with(this);
+ final UserViewModel.Factory userViewModelFactory =
+ new UserViewModel.Factory(getApplication(), mRedditDataRoomDatabase, mAccountName);
+ final UserViewModel userViewModel =
+ new ViewModelProvider(this, userViewModelFactory).get(UserViewModel.class);
+
+ userViewModel.getUserLiveData().observe(this, userData -> {
+ if (userData == null) return;//
+ // BANNER
+ final String userBanner = userData.getBanner();
+ LayoutParams cBannerLp = (LayoutParams) changeBanner.getLayoutParams();
+ if (userBanner == null || userBanner.isEmpty()) {
+ changeBanner.setLongClickable(false);
+ changeBanner.setImageResource(R.drawable.ic_add_day_night_24dp);
+ changeBanner.setLayoutParams(new LayoutParams(cBannerLp.width, cBannerLp.height, Gravity.CENTER));
+ changeBanner.setOnLongClickListener(v -> false);
+ } else {
+ changeBanner.setLongClickable(true);
+ changeBanner.setImageResource(R.drawable.ic_outline_add_a_photo_day_night_24dp);
+ changeBanner.setLayoutParams(new LayoutParams(cBannerLp.width, cBannerLp.height, Gravity.END | Gravity.BOTTOM));
+ glide.load(userBanner).into(bannerImageView);
+ changeBanner.setOnLongClickListener(view -> {
+ if (mAccessToken == null) return false;
+ new MaterialAlertDialogBuilder(this, R.style.MaterialAlertDialogTheme)
+ .setTitle(R.string.remove_banner)
+ .setMessage(R.string.are_you_sure)
+ .setPositiveButton(R.string.yes, (dialogInterface, i)
+ -> EditProfileUtils.deleteBanner(mOauthRetrofit,
+ mAccessToken,
+ mAccountName,
+ new EditProfileUtils.EditProfileUtilsListener() {
+ @Override
+ public void success() {
+ Toast.makeText(EditProfileActivity.this,
+ R.string.message_remove_banner_success,
+ Toast.LENGTH_SHORT).show();
+ bannerImageView.setImageDrawable(null);//
+ }
+
+ @Override
+ public void failed(String message) {
+ Toast.makeText(EditProfileActivity.this,
+ getString(R.string.message_remove_banner_failed_fmt, message),
+ Toast.LENGTH_SHORT).show();
+ }
+ }))
+ .setNegativeButton(R.string.no, null)
+ .show();
+ return true;
+ });
+ }
+ // AVATAR
+ final String userAvatar = userData.getIconUrl();
+ glide.load(userAvatar)
+ .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(216, 0)))
+ .into(avatarImageView);
+ LayoutParams cAvatarLp = (LayoutParams) changeAvatar.getLayoutParams();
+ if (userAvatar.contains("avatar_default_")) {
+ changeAvatar.setLongClickable(false);
+ changeAvatar.setImageResource(R.drawable.ic_add_day_night_24dp);
+ changeAvatar.setLayoutParams(new LayoutParams(cAvatarLp.width, cAvatarLp.height, Gravity.CENTER));
+ changeAvatar.setOnLongClickListener(v -> false);
+ } else {
+ changeAvatar.setLongClickable(true);
+ changeAvatar.setImageResource(R.drawable.ic_outline_add_a_photo_day_night_24dp);
+ changeAvatar.setLayoutParams(new LayoutParams(cAvatarLp.width, cAvatarLp.height, Gravity.END | Gravity.BOTTOM));
+ changeAvatar.setOnLongClickListener(view -> {
+ if (mAccessToken == null) return false;
+ new MaterialAlertDialogBuilder(this, R.style.MaterialAlertDialogTheme)
+ .setTitle(R.string.remove_avatar)
+ .setMessage(R.string.are_you_sure)
+ .setPositiveButton(R.string.yes, (dialogInterface, i)
+ -> EditProfileUtils.deleteAvatar(mOauthRetrofit,
+ mAccessToken,
+ mAccountName,
+ new EditProfileUtils.EditProfileUtilsListener() {
+ @Override
+ public void success() {
+ Toast.makeText(EditProfileActivity.this,
+ R.string.message_remove_avatar_success,
+ Toast.LENGTH_SHORT).show();//
+ }
+
+ @Override
+ public void failed(String message) {
+ Toast.makeText(EditProfileActivity.this,
+ getString(R.string.message_remove_avatar_failed_fmt, message),
+ Toast.LENGTH_SHORT).show();
+ }
+ }))
+ .setNegativeButton(R.string.no, null)
+ .show();
+ return true;
+ });
+ }
+
+ editTextAboutYou.setText(userData.getDescription());
+ editTextDisplayName.setText(userData.getTitle());
+ });
+ }
+
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
+ super.onActivityResult(requestCode, resultCode, data);
+ if (resultCode != RESULT_OK || data == null) return; //
+ if (mAccessToken == null || mAccountName == null) return; //
+ Intent intent = new Intent(this, EditProfileService.class);
+ intent.setData(data.getData());
+ intent.putExtra(EditProfileService.EXTRA_ACCOUNT_NAME, mAccountName);
+ intent.putExtra(EditProfileService.EXTRA_ACCESS_TOKEN, mAccessToken);
+ intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
+ switch (requestCode) {
+ case PICK_IMAGE_BANNER_REQUEST_CODE:
+ intent.putExtra(EditProfileService.EXTRA_POST_TYPE, EditProfileService.EXTRA_POST_TYPE_CHANGE_BANNER);
+ ContextCompat.startForegroundService(this, intent);
+ break;
+ case PICK_IMAGE_AVATAR_REQUEST_CODE:
+ intent.putExtra(EditProfileService.EXTRA_POST_TYPE, EditProfileService.EXTRA_POST_TYPE_CHANGE_AVATAR);
+ ContextCompat.startForegroundService(this, intent);
+ break;
+ default:
+ break;
+ }
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.edit_profile_activity, menu);
+ applyMenuItemTheme(menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(@NonNull MenuItem item) {
+ final int itemId = item.getItemId();
+ if (itemId == android.R.id.home) {
+ finish();
+ return true;
+ } else if (itemId == R.id.action_save_edit_profile_activity) {
+ String displayName = null;
+ if (editTextDisplayName.getText() != null) {
+ displayName = editTextDisplayName.getText().toString();
+ }
+ String aboutYou = null;
+ if (editTextAboutYou.getText() != null) {
+ aboutYou = editTextAboutYou.getText().toString();
+ }
+ if (aboutYou == null || displayName == null) return false; //
+
+ Intent intent = new Intent(this, EditProfileService.class);
+ intent.putExtra(EditProfileService.EXTRA_ACCOUNT_NAME, mAccountName);
+ intent.putExtra(EditProfileService.EXTRA_ACCESS_TOKEN, mAccessToken);
+ intent.putExtra(EditProfileService.EXTRA_DISPLAY_NAME, displayName); //
+ intent.putExtra(EditProfileService.EXTRA_ABOUT_YOU, aboutYou); //
+ intent.putExtra(EditProfileService.EXTRA_POST_TYPE, EditProfileService.EXTRA_POST_TYPE_SAVE_EDIT_PROFILE);
+
+ ContextCompat.startForegroundService(this, intent);
+ return true;
+ }
+ return false;
+ }
+
+ @Subscribe
+ public void onSubmitChangeAvatar(SubmitChangeAvatarEvent event) {
+ if (event.isSuccess) {
+ Toast.makeText(this, R.string.message_change_avatar_success, Toast.LENGTH_SHORT).show();
+ } else {
+ String message = getString(R.string.message_change_avatar_failed_fmt, event.errorMessage);
+ Toast.makeText(this, message, Toast.LENGTH_SHORT).show();
+ }
+ }
+
+ @Subscribe
+ public void onSubmitChangeBanner(SubmitChangeBannerEvent event) {
+ if (event.isSuccess) {
+ Toast.makeText(this, R.string.message_change_banner_success, Toast.LENGTH_SHORT).show();
+ } else {
+ String message = getString(R.string.message_change_banner_failed_fmt, event.errorMessage);
+ Toast.makeText(this, message, Toast.LENGTH_SHORT).show();
+ }
+ }
+
+ @Subscribe
+ public void onSubmitSaveProfile(SubmitSaveProfileEvent event) {
+ if (event.isSuccess) {
+ Toast.makeText(this, R.string.message_save_profile_success, Toast.LENGTH_SHORT).show();
+ } else {
+ String message = getString(R.string.message_save_profile_failed_fmt, event.errorMessage);
+ Toast.makeText(this, message, Toast.LENGTH_SHORT).show();
+ }
+ }
+
+
+ @Override
+ protected SharedPreferences getDefaultSharedPreferences() {
+ return mSharedPreferences;
+ }
+
+ @Override
+ protected CustomThemeWrapper getCustomThemeWrapper() {
+ return mCustomThemeWrapper;
+ }
+
+ @Override
+ protected void applyCustomTheme() {
+ applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, null, toolbar);
+ root.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
+ changeColorTextView(content, mCustomThemeWrapper.getPrimaryTextColor());
+ }
+
+ private void changeColorTextView(ViewGroup viewGroup, int color) {
+ final int childCount = viewGroup.getChildCount();
+ for (int i = 0; i < childCount; i++) {
+ View child = viewGroup.getChildAt(i);
+ if (child instanceof ViewGroup) {
+ changeColorTextView((ViewGroup) child, color);
+ } else if (child instanceof TextView) {
+ ((TextView) child).setTextColor(color);
+ }
+ }
+ }
+
+ private void startPickImage(int requestId) {
+ Intent intent = new Intent();
+ intent.setType("image/*");
+ intent.setAction(Intent.ACTION_GET_CONTENT);
+ startActivityForResult(
+ Intent.createChooser(intent, getString(R.string.select_from_gallery)),
+ requestId);
+ }
+}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredPostsActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredPostsActivity.java
index 175ff228..3c0dd8e3 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredPostsActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredPostsActivity.java
@@ -256,7 +256,7 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec
@Override
protected void applyCustomTheme() {
coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
- applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar);
+ applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar);
applyFABTheme(fab);
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FullMarkdownActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FullMarkdownActivity.java
index 9eb9fb86..dca5b75b 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FullMarkdownActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FullMarkdownActivity.java
@@ -25,6 +25,7 @@ import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.appbar.AppBarLayout;
+import com.google.android.material.appbar.CollapsingToolbarLayout;
import com.r0adkll.slidr.Slidr;
import com.r0adkll.slidr.model.SlidrInterface;
@@ -68,6 +69,8 @@ public class FullMarkdownActivity extends BaseActivity {
CoordinatorLayout coordinatorLayout;
@BindView(R.id.appbar_layout_comment_full_markdown_activity)
AppBarLayout appBarLayout;
+ @BindView(R.id.collapsing_toolbar_layout_comment_full_markdown_activity)
+ CollapsingToolbarLayout collapsingToolbarLayout;
@BindView(R.id.toolbar_comment_full_markdown_activity)
Toolbar toolbar;
@BindView(R.id.content_markdown_view_comment_full_markdown_activity)
@@ -277,7 +280,7 @@ public class FullMarkdownActivity extends BaseActivity {
@Override
protected void applyCustomTheme() {
coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
- applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar);
+ applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar);
}
@Override
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/GiveAwardActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/GiveAwardActivity.java
index 98e1b604..50db35d1 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/GiveAwardActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/GiveAwardActivity.java
@@ -189,6 +189,6 @@ public class GiveAwardActivity extends BaseActivity {
@Override
protected void applyCustomTheme() {
coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
- applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar);
+ applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, null, toolbar);
}
} \ No newline at end of file
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/InboxActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/InboxActivity.java
index 2437103f..203ded9e 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/InboxActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/InboxActivity.java
@@ -73,10 +73,10 @@ public class InboxActivity extends BaseActivity implements ActivityToolbarInterf
@BindView(R.id.coordinator_layout_inbox_activity)
CoordinatorLayout mCoordinatorLayout;
- @BindView(R.id.collapsing_toolbar_layout_inbox_activity)
- CollapsingToolbarLayout collapsingToolbarLayout;
@BindView(R.id.appbar_layout_inbox_activity)
AppBarLayout mAppBarLayout;
+ @BindView(R.id.collapsing_toolbar_layout_inbox_activity)
+ CollapsingToolbarLayout mCollapsingToolbarLayout;
@BindView(R.id.toolbar_inbox_activity)
Toolbar mToolbar;
@BindView(R.id.tab_layout_inbox_activity)
@@ -238,7 +238,7 @@ public class InboxActivity extends BaseActivity implements ActivityToolbarInterf
@Override
protected void applyCustomTheme() {
mCoordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
- applyAppBarLayoutAndToolbarTheme(mAppBarLayout, mToolbar);
+ applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(mAppBarLayout, mCollapsingToolbarLayout, mToolbar);
applyTabLayoutTheme(tabLayout);
applyFABTheme(fab);
}
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 8bdc0528..cef2a207 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LoginActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LoginActivity.java
@@ -281,7 +281,7 @@ public class LoginActivity extends BaseActivity {
@Override
protected void applyCustomTheme() {
coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
- applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar);
+ applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, null, toolbar);
twoFAInfoTextView.setTextColor(mCustomThemeWrapper.getPrimaryTextColor());
Drawable infoDrawable = Utils.getTintedDrawable(this, R.drawable.ic_info_preference_24dp, mCustomThemeWrapper.getPrimaryIconColor());
twoFAInfoTextView.setCompoundDrawablesWithIntrinsicBounds(infoDrawable, null, null, null);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java
index 0697ec04..30d134fe 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java
@@ -31,7 +31,6 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.ActionBarDrawerToggle;
import androidx.appcompat.app.AppCompatDelegate;
-import androidx.appcompat.widget.Toolbar;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.core.app.ActivityCompat;
import androidx.core.view.GravityCompat;
@@ -52,6 +51,7 @@ import androidx.work.WorkManager;
import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.appbar.CollapsingToolbarLayout;
+import com.google.android.material.appbar.MaterialToolbar;
import com.google.android.material.bottomappbar.BottomAppBar;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
@@ -160,7 +160,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
@BindView(R.id.collapsing_toolbar_layout_main_activity)
CollapsingToolbarLayout collapsingToolbarLayout;
@BindView(R.id.toolbar)
- Toolbar toolbar;
+ MaterialToolbar toolbar;
@BindView(R.id.nav_drawer_recycler_view_main_activity)
RecyclerView navDrawerRecyclerView;
@BindView(R.id.tab_layout_main_activity)
@@ -269,9 +269,10 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
drawer.setStatusBarBackgroundColor(Color.TRANSPARENT);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
drawer.setFitsSystemWindows(false);
- drawer.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
+ getWindow().setDecorFitsSystemWindows(false);
+ /*drawer.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
- View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
+ View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);*/
} else {
window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
}
@@ -355,7 +356,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
option3BottomAppBar.setColorFilter(bottomAppBarIconColor, android.graphics.PorterDuff.Mode.SRC_IN);
option4BottomAppBar.setColorFilter(bottomAppBarIconColor, android.graphics.PorterDuff.Mode.SRC_IN);
navigationView.setBackgroundColor(backgroundColor);
- applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar);
+ applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar);
applyTabLayoutTheme(tabLayout);
bottomAppBar.setBackgroundTint(ColorStateList.valueOf(mCustomThemeWrapper.getBottomAppBarBackgroundColor()));
applyFABTheme(fab);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MultiredditSelectionActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MultiredditSelectionActivity.java
index 7b1596f8..d4f7dd07 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MultiredditSelectionActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MultiredditSelectionActivity.java
@@ -18,6 +18,7 @@ import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.fragment.app.Fragment;
import com.google.android.material.appbar.AppBarLayout;
+import com.google.android.material.appbar.CollapsingToolbarLayout;
import com.r0adkll.slidr.Slidr;
import org.greenrobot.eventbus.EventBus;
@@ -55,6 +56,8 @@ public class MultiredditSelectionActivity extends BaseActivity implements Activi
CoordinatorLayout coordinatorLayout;
@BindView(R.id.appbar_layout_multireddit_selection_activity)
AppBarLayout appBarLayout;
+ @BindView(R.id.collapsing_toolbar_layout_multireddit_selection_activity)
+ CollapsingToolbarLayout collapsingToolbarLayout;
@BindView(R.id.toolbar_multireddit_selection_activity)
Toolbar toolbar;
@Inject
@@ -142,7 +145,7 @@ public class MultiredditSelectionActivity extends BaseActivity implements Activi
@Override
protected void applyCustomTheme() {
coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
- applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar);
+ applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar);
}
private void bindView(boolean initializeFragment) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostFilterPreferenceActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostFilterPreferenceActivity.java
index d8c89639..44a6f62d 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostFilterPreferenceActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostFilterPreferenceActivity.java
@@ -12,6 +12,7 @@ import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.appbar.AppBarLayout;
+import com.google.android.material.appbar.CollapsingToolbarLayout;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
@@ -43,6 +44,8 @@ public class PostFilterPreferenceActivity extends BaseActivity {
CoordinatorLayout coordinatorLayout;
@BindView(R.id.appbar_layout_post_filter_preference_activity)
AppBarLayout appBarLayout;
+ @BindView(R.id.collapsing_toolbar_layout_post_filter_preference_activity)
+ CollapsingToolbarLayout collapsingToolbarLayout;
@BindView(R.id.toolbar_post_filter_preference_activity)
Toolbar toolbar;
@BindView(R.id.recycler_view_post_filter_preference_activity)
@@ -207,7 +210,7 @@ public class PostFilterPreferenceActivity extends BaseActivity {
@Override
protected void applyCustomTheme() {
- applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar);
+ applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar);
}
@Override
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostFilterUsageListingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostFilterUsageListingActivity.java
index 350584db..e24a47b9 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostFilterUsageListingActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostFilterUsageListingActivity.java
@@ -15,6 +15,7 @@ import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.appbar.AppBarLayout;
+import com.google.android.material.appbar.CollapsingToolbarLayout;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.textfield.TextInputEditText;
@@ -47,6 +48,8 @@ public class PostFilterUsageListingActivity extends BaseActivity {
CoordinatorLayout coordinatorLayout;
@BindView(R.id.appbar_layout_post_filter_application_activity)
AppBarLayout appBarLayout;
+ @BindView(R.id.collapsing_toolbar_layout_post_filter_application_activity)
+ CollapsingToolbarLayout collapsingToolbarLayout;
@BindView(R.id.toolbar_post_filter_application_activity)
Toolbar toolbar;
@BindView(R.id.recycler_view_post_filter_application_activity)
@@ -209,6 +212,6 @@ public class PostFilterUsageListingActivity extends BaseActivity {
@Override
protected void applyCustomTheme() {
- applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar);
+ applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar);
}
} \ No newline at end of file
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostGalleryActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostGalleryActivity.java
index 8edb4516..3dcb726e 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostGalleryActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostGalleryActivity.java
@@ -407,7 +407,7 @@ public class PostGalleryActivity extends BaseActivity implements FlairBottomShee
@Override
protected void applyCustomTheme() {
coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
- applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar);
+ applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, null, toolbar);
int secondaryTextColor = mCustomThemeWrapper.getSecondaryTextColor();
subredditNameTextView.setTextColor(secondaryTextColor);
rulesButton.setTextColor(mCustomThemeWrapper.getButtonTextColor());
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostImageActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostImageActivity.java
index acf5034d..cf6c7664 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostImageActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostImageActivity.java
@@ -388,7 +388,7 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
@Override
protected void applyCustomTheme() {
coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
- applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar);
+ applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, null, toolbar);
int secondaryTextColor = mCustomThemeWrapper.getSecondaryTextColor();
subredditNameTextView.setTextColor(secondaryTextColor);
rulesButton.setTextColor(mCustomThemeWrapper.getButtonTextColor());
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostLinkActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostLinkActivity.java
index 8ce97d55..eecefa75 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostLinkActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostLinkActivity.java
@@ -362,7 +362,7 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
@Override
protected void applyCustomTheme() {
coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
- applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar);
+ applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, null, toolbar);
int secondaryTextColor = mCustomThemeWrapper.getSecondaryTextColor();
subredditNameTextView.setTextColor(secondaryTextColor);
rulesButton.setTextColor(mCustomThemeWrapper.getButtonTextColor());
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostTextActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostTextActivity.java
index a03f7355..5336051c 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostTextActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostTextActivity.java
@@ -386,7 +386,7 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
@Override
protected void applyCustomTheme() {
coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
- applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar);
+ applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, null, toolbar);
int secondaryTextColor = mCustomThemeWrapper.getSecondaryTextColor();
subredditNameTextView.setTextColor(secondaryTextColor);
rulesButton.setTextColor(mCustomThemeWrapper.getButtonTextColor());
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostVideoActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostVideoActivity.java
index a7fb97d8..f80b5e94 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostVideoActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostVideoActivity.java
@@ -399,7 +399,7 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
@Override
protected void applyCustomTheme() {
coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
- applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar);
+ applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, null, toolbar);
int secondaryTextColor = mCustomThemeWrapper.getSecondaryTextColor();
subredditNameTextView.setTextColor(secondaryTextColor);
rulesButton.setTextColor(mCustomThemeWrapper.getButtonTextColor());
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ReportActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ReportActivity.java
index 4b8f9b38..f00c9eb3 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ReportActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ReportActivity.java
@@ -196,6 +196,6 @@ public class ReportActivity extends BaseActivity {
@Override
protected void applyCustomTheme() {
coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
- applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar);
+ applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, null, toolbar);
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/RulesActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/RulesActivity.java
index ca687cf1..75e01121 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/RulesActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/RulesActivity.java
@@ -18,6 +18,7 @@ import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.appbar.AppBarLayout;
+import com.google.android.material.appbar.CollapsingToolbarLayout;
import com.r0adkll.slidr.Slidr;
import org.greenrobot.eventbus.EventBus;
@@ -49,6 +50,8 @@ public class RulesActivity extends BaseActivity {
CoordinatorLayout coordinatorLayout;
@BindView(R.id.appbar_layout_rules_activity)
AppBarLayout appBarLayout;
+ @BindView(R.id.collapsing_toolbar_layout_rules_activity)
+ CollapsingToolbarLayout collapsingToolbarLayout;
@BindView(R.id.toolbar_rules_activity)
Toolbar toolbar;
@BindView(R.id.progress_bar_rules_activity)
@@ -154,7 +157,7 @@ public class RulesActivity extends BaseActivity {
@Override
protected void applyCustomTheme() {
coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
- applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar);
+ applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar);
progressBar.setIndeterminateTintList(ColorStateList.valueOf(mCustomThemeWrapper.getColorAccent()));
errorTextView.setTextColor(mCustomThemeWrapper.getSecondaryTextColor());
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java
index 6daffcce..b98fb205 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java
@@ -349,7 +349,7 @@ public class SearchActivity extends BaseActivity {
@Override
protected void applyCustomTheme() {
coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
- applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar);
+ applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, null, toolbar);
simpleSearchView.setSearchBackground(new ColorDrawable(mCustomThemeWrapper.getColorPrimary()));
int toolbarPrimaryTextAndIconColorColor = mCustomThemeWrapper.getToolbarPrimaryTextAndIconColor();
simpleSearchView.setIconsColor(toolbarPrimaryTextAndIconColorColor);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchResultActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchResultActivity.java
index 4dca5fc6..95a98aa9 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchResultActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchResultActivity.java
@@ -28,6 +28,7 @@ import androidx.viewpager2.adapter.FragmentStateAdapter;
import androidx.viewpager2.widget.ViewPager2;
import com.google.android.material.appbar.AppBarLayout;
+import com.google.android.material.appbar.CollapsingToolbarLayout;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.tabs.TabLayout;
@@ -95,6 +96,8 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
CoordinatorLayout coordinatorLayout;
@BindView(R.id.appbar_layout_search_result_activity)
AppBarLayout appBarLayout;
+ @BindView(R.id.collapsing_toolbar_layout_search_result_activity)
+ CollapsingToolbarLayout collapsingToolbarLayout;
@BindView(R.id.toolbar_search_result_activity)
Toolbar toolbar;
@BindView(R.id.tab_layout_search_result_activity)
@@ -230,7 +233,7 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
@Override
protected void applyCustomTheme() {
coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
- applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar);
+ applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar);
applyTabLayoutTheme(tabLayout);
applyFABTheme(fab);
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchSubredditsResultActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchSubredditsResultActivity.java
index ae115534..4cd3390e 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchSubredditsResultActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchSubredditsResultActivity.java
@@ -23,7 +23,6 @@ import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import java.util.ArrayList;
-import java.util.List;
import javax.inject.Inject;
import javax.inject.Named;
@@ -36,7 +35,6 @@ import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent;
import ml.docilealligator.infinityforreddit.fragments.SubredditListingFragment;
-import ml.docilealligator.infinityforreddit.subreddit.SubredditData;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
public class SearchSubredditsResultActivity extends BaseActivity implements ActivityToolbarInterface {
@@ -143,7 +141,7 @@ public class SearchSubredditsResultActivity extends BaseActivity implements Acti
@Override
protected void applyCustomTheme() {
coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
- applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar);
+ applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, null, toolbar);
}
public void getSelectedSubreddit(String name, String iconUrl) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchUsersResultActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchUsersResultActivity.java
index 58db6bc7..c0cab347 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchUsersResultActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchUsersResultActivity.java
@@ -140,7 +140,7 @@ public class SearchUsersResultActivity extends BaseActivity implements ActivityT
@Override
protected void applyCustomTheme() {
coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
- applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar);
+ applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, null, toolbar);
}
public void getSelectedUser(String name, String iconUrl) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SelectUserFlairActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SelectUserFlairActivity.java
index f9a7460e..3b4252dd 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SelectUserFlairActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SelectUserFlairActivity.java
@@ -223,7 +223,7 @@ public class SelectUserFlairActivity extends BaseActivity implements ActivityToo
@Override
protected void applyCustomTheme() {
coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
- applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar);
+ applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, null, toolbar);
}
@Override
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SelectedSubredditsAndUsersActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SelectedSubredditsAndUsersActivity.java
index 38502fd4..9df207b0 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SelectedSubredditsAndUsersActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SelectedSubredditsAndUsersActivity.java
@@ -14,6 +14,7 @@ import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.appbar.AppBarLayout;
+import com.google.android.material.appbar.CollapsingToolbarLayout;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.r0adkll.slidr.Slidr;
@@ -45,6 +46,8 @@ public class SelectedSubredditsAndUsersActivity extends BaseActivity implements
CoordinatorLayout coordinatorLayout;
@BindView(R.id.appbar_layout_selected_subreddits_and_users_activity)
AppBarLayout appBarLayout;
+ @BindView(R.id.collapsing_toolbar_layout_selected_subreddits_and_users_activity)
+ CollapsingToolbarLayout collapsingToolbarLayout;
@BindView(R.id.toolbar_selected_subreddits_and_users_activity)
Toolbar toolbar;
@BindView(R.id.recycler_view_selected_subreddits_and_users_activity)
@@ -187,7 +190,7 @@ public class SelectedSubredditsAndUsersActivity extends BaseActivity implements
@Override
protected void applyCustomTheme() {
coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
- applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar);
+ applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar);
applyFABTheme(fab);
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SendPrivateMessageActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SendPrivateMessageActivity.java
index 216dd2ae..abfe7810 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SendPrivateMessageActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SendPrivateMessageActivity.java
@@ -174,7 +174,7 @@ public class SendPrivateMessageActivity extends BaseActivity {
@Override
protected void applyCustomTheme() {
coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
- applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar);
+ applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, null, toolbar);
int primaryTextColor = mCustomThemeWrapper.getPrimaryTextColor();
usernameEditText.setTextColor(primaryTextColor);
subjectEditText.setTextColor(primaryTextColor);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SettingsActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SettingsActivity.java
index b4a70c30..067e44a1 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SettingsActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SettingsActivity.java
@@ -13,6 +13,7 @@ import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
import com.google.android.material.appbar.AppBarLayout;
+import com.google.android.material.appbar.CollapsingToolbarLayout;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
@@ -46,6 +47,8 @@ public class SettingsActivity extends BaseActivity implements
@BindView(R.id.appbar_layout_settings_activity)
AppBarLayout appBarLayout;
+ @BindView(R.id.collapsing_toolbar_layout_settings_activity)
+ CollapsingToolbarLayout collapsingToolbarLayout;
@BindView(R.id.toolbar_settings_activity)
Toolbar toolbar;
private String mAccountName;
@@ -126,7 +129,7 @@ public class SettingsActivity extends BaseActivity implements
@Override
protected void applyCustomTheme() {
- applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar);
+ applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar);
}
@Override
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubmitCrosspostActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubmitCrosspostActivity.java
index b5ac9689..dd3b0d89 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubmitCrosspostActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubmitCrosspostActivity.java
@@ -391,7 +391,7 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom
@Override
protected void applyCustomTheme() {
coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
- applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar);
+ applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, null, toolbar);
int secondaryTextColor = mCustomThemeWrapper.getSecondaryTextColor();
subredditNameTextView.setTextColor(secondaryTextColor);
rulesButton.setTextColor(mCustomThemeWrapper.getButtonTextColor());
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubredditMultiselectionActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubredditMultiselectionActivity.java
index 344f00dd..91da0e06 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubredditMultiselectionActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubredditMultiselectionActivity.java
@@ -24,6 +24,7 @@ import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import com.bumptech.glide.Glide;
import com.bumptech.glide.RequestManager;
import com.google.android.material.appbar.AppBarLayout;
+import com.google.android.material.appbar.CollapsingToolbarLayout;
import com.r0adkll.slidr.Slidr;
import java.util.ArrayList;
@@ -54,6 +55,8 @@ public class SubredditMultiselectionActivity extends BaseActivity implements Act
CoordinatorLayout mCoordinatorLayout;
@BindView(R.id.appbar_layout_subreddits_multiselection_activity)
AppBarLayout mAppBarLayout;
+ @BindView(R.id.collapsing_toolbar_layout_subscribed_subreddits_multiselection_activity)
+ CollapsingToolbarLayout mCollapsingToolbarLayout;
@BindView(R.id.toolbar_subscribed_subreddits_multiselection_activity)
Toolbar mToolbar;
@BindView(R.id.swipe_refresh_layout_subscribed_subscribed_subreddits_multiselection_activity)
@@ -226,7 +229,7 @@ public class SubredditMultiselectionActivity extends BaseActivity implements Act
@Override
protected void applyCustomTheme() {
mCoordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
- applyAppBarLayoutAndToolbarTheme(mAppBarLayout, mToolbar);
+ applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(mAppBarLayout, mCollapsingToolbarLayout, mToolbar);
mErrorTextView.setTextColor(mCustomThemeWrapper.getSecondaryTextColor());
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubredditSelectionActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubredditSelectionActivity.java
index 3db45c00..3578a32b 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubredditSelectionActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubredditSelectionActivity.java
@@ -19,6 +19,7 @@ import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.fragment.app.Fragment;
import com.google.android.material.appbar.AppBarLayout;
+import com.google.android.material.appbar.CollapsingToolbarLayout;
import com.r0adkll.slidr.Slidr;
import org.greenrobot.eventbus.EventBus;
@@ -62,6 +63,8 @@ public class SubredditSelectionActivity extends BaseActivity implements Activity
CoordinatorLayout coordinatorLayout;
@BindView(R.id.appbar_layout_subreddit_selection_activity)
AppBarLayout appBarLayout;
+ @BindView(R.id.collapsing_toolbar_layout_subreddit_selection_activity)
+ CollapsingToolbarLayout collapsingToolbarLayout;
@BindView(R.id.toolbar_subreddit_selection_activity)
Toolbar toolbar;
@Inject
@@ -153,7 +156,7 @@ public class SubredditSelectionActivity extends BaseActivity implements Activity
@Override
protected void applyCustomTheme() {
coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
- applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar);
+ applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar);
}
private void bindView(boolean initializeFragment) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubscribedThingListingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubscribedThingListingActivity.java
index de5438e1..dde51105 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubscribedThingListingActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubscribedThingListingActivity.java
@@ -21,6 +21,7 @@ import androidx.fragment.app.FragmentPagerAdapter;
import androidx.viewpager.widget.ViewPager;
import com.google.android.material.appbar.AppBarLayout;
+import com.google.android.material.appbar.CollapsingToolbarLayout;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.tabs.TabLayout;
@@ -74,6 +75,8 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
CoordinatorLayout coordinatorLayout;
@BindView(R.id.appbar_layout_subscribed_thing_listing_activity)
AppBarLayout appBarLayout;
+ @BindView(R.id.collapsing_toolbar_layout_subscribed_thing_listing_activity)
+ CollapsingToolbarLayout collapsingToolbarLayout;
@BindView(R.id.toolbar_subscribed_thing_listing_activity)
Toolbar toolbar;
@BindView(R.id.tab_layout_subscribed_thing_listing_activity)
@@ -178,7 +181,7 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
@Override
protected void applyCustomTheme() {
coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
- applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar);
+ applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar);
applyTabLayoutTheme(tabLayout);
applyFABTheme(fab);
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/TrendingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/TrendingActivity.java
index 7f0282f3..7057b1ad 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/TrendingActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/TrendingActivity.java
@@ -64,10 +64,10 @@ public class TrendingActivity extends BaseActivity {
@BindView(R.id.coordinator_layout_trending_activity)
CoordinatorLayout coordinatorLayout;
- @BindView(R.id.collapsing_toolbar_layout_trending_activity)
- CollapsingToolbarLayout collapsingToolbarLayout;
@BindView(R.id.appbar_layout_trending_activity)
AppBarLayout appBarLayout;
+ @BindView(R.id.collapsing_toolbar_layout_trending_activity)
+ CollapsingToolbarLayout collapsingToolbarLayout;
@BindView(R.id.toolbar_trending_activity)
Toolbar toolbar;
@BindView(R.id.swipe_refresh_layout_trending_activity)
@@ -326,7 +326,7 @@ public class TrendingActivity extends BaseActivity {
@Override
protected void applyCustomTheme() {
coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
- applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar);
+ applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar);
swipeRefreshLayout.setProgressBackgroundColorSchemeColor(mCustomThemeWrapper.getCircularProgressBarBackground());
swipeRefreshLayout.setColorSchemeColors(mCustomThemeWrapper.getColorAccent());
errorTextView.setTextColor(mCustomThemeWrapper.getSecondaryTextColor());
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewMultiRedditDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewMultiRedditDetailActivity.java
index 012742d4..33561073 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewMultiRedditDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewMultiRedditDetailActivity.java
@@ -298,7 +298,7 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
@Override
protected void applyCustomTheme() {
coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
- applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar);
+ applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar);
}
@Override
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPostDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPostDetailActivity.java
index ae3538b1..494d062c 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPostDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPostDetailActivity.java
@@ -31,6 +31,7 @@ import com.evernote.android.state.State;
import com.github.piasy.biv.BigImageViewer;
import com.github.piasy.biv.loader.glide.GlideImageLoader;
import com.google.android.material.appbar.AppBarLayout;
+import com.google.android.material.appbar.CollapsingToolbarLayout;
import com.google.android.material.card.MaterialCardView;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.snackbar.Snackbar;
@@ -88,6 +89,8 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
CoordinatorLayout mCoordinatorLayout;
@BindView(R.id.appbar_layout_view_post_detail_activity)
AppBarLayout mAppBarLayout;
+ @BindView(R.id.collapsing_toolbar_layout_view_post_detail_activity)
+ CollapsingToolbarLayout mCollapsingToolbarLayout;
@BindView(R.id.toolbar_view_post_detail_activity)
Toolbar mToolbar;
@BindView(R.id.view_pager_2_view_post_detail_activity)
@@ -276,7 +279,7 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
@Override
protected void applyCustomTheme() {
mCoordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
- applyAppBarLayoutAndToolbarTheme(mAppBarLayout, mToolbar);
+ applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(mAppBarLayout, mCollapsingToolbarLayout, mToolbar);
applyFABTheme(fab);
searchPanelMaterialCardView.setBackgroundTintList(ColorStateList.valueOf(mCustomThemeWrapper.getColorPrimary()));
int searchPanelTextAndIconColor = mCustomThemeWrapper.getToolbarPrimaryTextAndIconColor();
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPrivateMessagesActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPrivateMessagesActivity.java
index ad09e76e..f56bf406 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPrivateMessagesActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPrivateMessagesActivity.java
@@ -290,7 +290,7 @@ public class ViewPrivateMessagesActivity extends BaseActivity implements Activit
@Override
protected void applyCustomTheme() {
mLinearLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
- applyAppBarLayoutAndToolbarTheme(mAppBarLayout, mToolbar);
+ applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(mAppBarLayout, null, mToolbar);
mDivider.setBackgroundColor(mCustomThemeWrapper.getDividerColor());
mEditText.setTextColor(mCustomThemeWrapper.getPrimaryTextColor());
mSecondaryTextColor = mCustomThemeWrapper.getSecondaryTextColor();
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java
index 41fd582d..9ea9f5de 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java
@@ -16,6 +16,7 @@ import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
+import android.view.ViewTreeObserver;
import android.view.Window;
import android.view.WindowManager;
import android.view.inputmethod.EditorInfo;
@@ -27,7 +28,6 @@ import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
-import androidx.appcompat.widget.Toolbar;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
@@ -42,6 +42,7 @@ import com.bumptech.glide.RequestManager;
import com.bumptech.glide.request.RequestOptions;
import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.appbar.CollapsingToolbarLayout;
+import com.google.android.material.appbar.MaterialToolbar;
import com.google.android.material.bottomappbar.BottomAppBar;
import com.google.android.material.chip.Chip;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
@@ -149,7 +150,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
@BindView(R.id.toolbar_linear_layout_view_subreddit_detail_activity)
LinearLayout linearLayout;
@BindView(R.id.toolbar)
- Toolbar toolbar;
+ MaterialToolbar toolbar;
@BindView(R.id.tab_layout_view_subreddit_detail_activity)
TabLayout tabLayout;
@BindView(R.id.banner_image_view_view_subreddit_detail_activity)
@@ -268,9 +269,10 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
if (isImmersiveInterface()) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
- coordinatorLayout.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
+ /*coordinatorLayout.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
- View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
+ View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);*/
+ getWindow().setDecorFitsSystemWindows(false);
} else {
window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
}
@@ -514,8 +516,14 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
@Override
protected void applyCustomTheme() {
coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
- collapsingToolbarLayout.setContentScrimColor(mCustomThemeWrapper.getColorPrimary());
- applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar);
+ appBarLayout.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
+ @Override
+ public void onGlobalLayout() {
+ collapsingToolbarLayout.setScrimVisibleHeightTrigger(toolbar.getHeight() + tabLayout.getHeight() + getStatusBarHeight() * 2);
+ appBarLayout.getViewTreeObserver().removeOnGlobalLayoutListener(this);
+ }
+ });
+ applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar, false);
expandedTabTextColor = mCustomThemeWrapper.getTabLayoutWithExpandedCollapsingToolbarTextColor();
expandedTabIndicatorColor = mCustomThemeWrapper.getTabLayoutWithExpandedCollapsingToolbarTabIndicator();
expandedTabBackgroundColor = mCustomThemeWrapper.getTabLayoutWithExpandedCollapsingToolbarTabBackground();
@@ -793,6 +801,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
option1BottomAppBar.setOnClickListener(view -> {
bottomAppBarOptionAction(option1);
+ //Toast.makeText(this, "s " + collapsingToolbarLayout.getScrimVisibleHeightTrigger(), Toast.LENGTH_SHORT).show();
});
option2BottomAppBar.setOnClickListener(view -> {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java
index 4884ca40..dfc40140 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java
@@ -6,7 +6,6 @@ import android.content.SharedPreferences;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.net.Uri;
-import android.opengl.Visibility;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
@@ -18,6 +17,7 @@ import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
+import android.view.ViewTreeObserver;
import android.view.Window;
import android.view.WindowManager;
import android.view.inputmethod.EditorInfo;
@@ -29,7 +29,6 @@ import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
-import androidx.appcompat.widget.Toolbar;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
@@ -44,6 +43,7 @@ import com.bumptech.glide.RequestManager;
import com.bumptech.glide.request.RequestOptions;
import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.appbar.CollapsingToolbarLayout;
+import com.google.android.material.appbar.MaterialToolbar;
import com.google.android.material.bottomappbar.BottomAppBar;
import com.google.android.material.chip.Chip;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
@@ -141,7 +141,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
@BindView(R.id.appbar_layout_view_user_detail)
AppBarLayout appBarLayout;
@BindView(R.id.toolbar_view_user_detail_activity)
- Toolbar toolbar;
+ MaterialToolbar toolbar;
@BindView(R.id.toolbar_linear_layout_view_user_detail_activity)
LinearLayout linearLayout;
@BindView(R.id.tab_layout_view_user_detail_activity)
@@ -563,8 +563,14 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
@Override
protected void applyCustomTheme() {
coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
- collapsingToolbarLayout.setContentScrimColor(mCustomThemeWrapper.getColorPrimary());
- applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar);
+ appBarLayout.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
+ @Override
+ public void onGlobalLayout() {
+ collapsingToolbarLayout.setScrimVisibleHeightTrigger(toolbar.getHeight() + tabLayout.getHeight() + getStatusBarHeight() * 2);
+ appBarLayout.getViewTreeObserver().removeOnGlobalLayoutListener(this);
+ }
+ });
+ applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar, false);
expandedTabTextColor = mCustomThemeWrapper.getTabLayoutWithExpandedCollapsingToolbarTextColor();
expandedTabIndicatorColor = mCustomThemeWrapper.getTabLayoutWithExpandedCollapsingToolbarTabIndicator();
expandedTabBackgroundColor = mCustomThemeWrapper.getTabLayoutWithExpandedCollapsingToolbarTabBackground();
@@ -1016,6 +1022,13 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.view_user_detail_activity, menu);
+ if(mAccountName.equals(username)){ // Hide some menus
+ menu.findItem(R.id.action_send_private_message_view_user_detail_activity).setVisible(false);
+ menu.findItem(R.id.action_report_view_user_detail_activity).setVisible(false);
+ menu.findItem(R.id.action_block_user_view_user_detail_activity).setVisible(false);
+ }else { // Hide Edit Profile menu
+ menu.findItem(R.id.action_edit_profile_view_user_detail_activity).setVisible(false);
+ }
applyMenuItemTheme(menu);
return true;
}
@@ -1104,6 +1117,9 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
.setNegativeButton(R.string.no, null)
.show();
return true;
+ } else if(itemId == R.id.action_edit_profile_view_user_detail_activity){
+ startActivity(new Intent(this, EditProfileActivity.class));
+ return true;
}
return false;
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/WebViewActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/WebViewActivity.java
index 8945e758..8c18718c 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/WebViewActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/WebViewActivity.java
@@ -109,7 +109,7 @@ public class WebViewActivity extends BaseActivity {
@Override
protected void applyCustomTheme() {
coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
- applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar);
+ applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, null, toolbar);
Drawable closeIcon = Utils.getTintedDrawable(this, R.drawable.ic_close_black_24dp, mCustomThemeWrapper.getToolbarPrimaryTextAndIconColor());
toolbar.setNavigationIcon(closeIcon);
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/WikiActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/WikiActivity.java
index 372d3c6f..c5e9d35c 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/WikiActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/WikiActivity.java
@@ -27,6 +27,7 @@ import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import com.bumptech.glide.Glide;
import com.google.android.material.appbar.AppBarLayout;
+import com.google.android.material.appbar.CollapsingToolbarLayout;
import com.r0adkll.slidr.Slidr;
import com.r0adkll.slidr.model.SlidrInterface;
@@ -78,6 +79,8 @@ public class WikiActivity extends BaseActivity {
CoordinatorLayout coordinatorLayout;
@BindView(R.id.appbar_layout_comment_wiki_activity)
AppBarLayout appBarLayout;
+ @BindView(R.id.collapsing_toolbar_layout_wiki_activity)
+ CollapsingToolbarLayout collapsingToolbarLayout;
@BindView(R.id.toolbar_comment_wiki_activity)
Toolbar toolbar;
@BindView(R.id.swipe_refresh_layout_wiki_activity)
@@ -356,7 +359,7 @@ public class WikiActivity extends BaseActivity {
@Override
protected void applyCustomTheme() {
coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
- applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar);
+ applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar);
swipeRefreshLayout.setProgressBackgroundColorSchemeColor(mCustomThemeWrapper.getCircularProgressBarBackground());
swipeRefreshLayout.setColorSchemeColors(mCustomThemeWrapper.getColorAccent());
mFetchWikiInfoTextView.setTextColor(mCustomThemeWrapper.getSecondaryTextColor());
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java
index d083a0bc..789ce798 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java
@@ -680,7 +680,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
}
((PostDetailVideoAutoplayViewHolder) holder).setVolume(mMuteAutoplayingVideos || (mPost.isNSFW() && mMuteNSFWVideo) ? 0f : 1f);
- if (mPost.isGfycat() || mPost.isRedgifs() && !mPost.isLoadGfyOrRedgifsVideoSuccess()) {
+ if (mPost.isGfycat() || mPost.isRedgifs() && !mPost.isLoadGfycatOrRedgifsVideoSuccess()) {
((PostDetailVideoAutoplayViewHolder) holder).fetchGfycatOrRedgifsVideoLinks = new FetchGfycatOrRedgifsVideoLinks(new FetchGfycatOrRedgifsVideoLinks.FetchGfycatOrRedgifsVideoLinksListener() {
@Override
public void success(String webm, String mp4) {
@@ -1670,14 +1670,14 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
if (mPost.isGfycat()) {
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_GFYCAT);
intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, mPost.getGfycatId());
- if (mPost.isLoadGfyOrRedgifsVideoSuccess()) {
+ if (mPost.isLoadGfycatOrRedgifsVideoSuccess()) {
intent.setData(Uri.parse(mPost.getVideoUrl()));
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, mPost.getVideoDownloadUrl());
}
} else if (mPost.isRedgifs()) {
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_REDGIFS);
intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, mPost.getGfycatId());
- if (mPost.isLoadGfyOrRedgifsVideoSuccess()) {
+ if (mPost.isLoadGfycatOrRedgifsVideoSuccess()) {
intent.setData(Uri.parse(mPost.getVideoUrl()));
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, mPost.getVideoDownloadUrl());
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java
index 7556cba0..464a4ab1 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java
@@ -39,6 +39,7 @@ import com.bumptech.glide.Glide;
import com.bumptech.glide.RequestBuilder;
import com.bumptech.glide.RequestManager;
import com.bumptech.glide.load.DataSource;
+import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.load.engine.GlideException;
import com.bumptech.glide.request.RequestListener;
import com.bumptech.glide.request.RequestOptions;
@@ -455,6 +456,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
if (holder instanceof PostBaseViewHolder) {
Post post = getItem(position);
if (post != null) {
+ ((PostBaseViewHolder) holder).post = post;
((PostBaseViewHolder) holder).currentPosition = position;
if (post.isRead()) {
if (((PostBaseViewHolder) holder).itemViewIsNotCardView) {
@@ -689,7 +691,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
((PostVideoAutoplayViewHolder) holder).setVolume(mFragment.getMasterMutingOption() ? 0f : 1f);
}
- if (post.isGfycat() || post.isRedgifs() && !post.isLoadGfyOrRedgifsVideoSuccess()) {
+ if ((post.isGfycat() || post.isRedgifs()) && !post.isLoadGfycatOrRedgifsVideoSuccess()) {
((PostVideoAutoplayViewHolder) holder).fetchGfycatOrRedgifsVideoLinks = new FetchGfycatOrRedgifsVideoLinks(new FetchGfycatOrRedgifsVideoLinks.FetchGfycatOrRedgifsVideoLinksListener() {
@Override
public void success(String webm, String mp4) {
@@ -766,6 +768,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
((PostWithPreviewTypeViewHolder) holder).videoOrGifIndicatorImageView.setVisibility(View.GONE);
} else {
Post.Preview preview = getSuitablePreview(post.getPreviews());
+ ((PostWithPreviewTypeViewHolder) holder).preview = preview;
if (preview != null) {
((PostWithPreviewTypeViewHolder) holder).imageWrapperRelativeLayout.setVisibility(View.VISIBLE);
if (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0) {
@@ -778,7 +781,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
((PostWithPreviewTypeViewHolder) holder).imageView
.setRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth());
}
- loadImage(holder, post, preview);
+ loadImage(holder);
} else {
((PostWithPreviewTypeViewHolder) holder).noPreviewLinkImageView.setVisibility(View.VISIBLE);
if (post.getPostType() == Post.VIDEO_TYPE) {
@@ -821,7 +824,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
((PostCard2VideoAutoplayViewHolder) holder).setVolume(mFragment.getMasterMutingOption() ? 0f : 1f);
}
- if (post.isGfycat() || post.isRedgifs() && !post.isLoadGfyOrRedgifsVideoSuccess()) {
+ if ((post.isGfycat() || post.isRedgifs()) && !post.isLoadGfycatOrRedgifsVideoSuccess()) {
((PostCard2VideoAutoplayViewHolder) holder).fetchGfycatOrRedgifsVideoLinks = new FetchGfycatOrRedgifsVideoLinks(new FetchGfycatOrRedgifsVideoLinks.FetchGfycatOrRedgifsVideoLinksListener() {
@Override
public void success(String webm, String mp4) {
@@ -900,6 +903,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
((PostCard2WithPreviewViewHolder) holder).videoOrGifIndicatorImageView.setVisibility(View.GONE);
} else {
Post.Preview preview = getSuitablePreview(post.getPreviews());
+ ((PostCard2WithPreviewViewHolder) holder).preview = preview;
if (preview != null) {
((PostCard2WithPreviewViewHolder) holder).imageView.setVisibility(View.VISIBLE);
if (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0) {
@@ -912,7 +916,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
((PostCard2WithPreviewViewHolder) holder).imageView
.setRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth());
}
- loadImage(holder, post, preview);
+ loadImage(holder);
} else {
((PostCard2WithPreviewViewHolder) holder).progressBar.setVisibility(View.GONE);
((PostCard2WithPreviewViewHolder) holder).noPreviewImageView.setVisibility(View.VISIBLE);
@@ -943,6 +947,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
} else if (holder instanceof PostCompactBaseViewHolder) {
Post post = getItem(position);
if (post != null) {
+ ((PostCompactBaseViewHolder) holder).post = post;
((PostCompactBaseViewHolder) holder).currentPosition = position;
if (post.isRead()) {
holder.itemView.setBackgroundColor(mReadPostCardViewBackgroundColor);
@@ -1153,13 +1158,12 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
((PostCompactBaseViewHolder) holder).noPreviewPostImageFrameLayout.setVisibility(View.VISIBLE);
((PostCompactBaseViewHolder) holder).noPreviewPostImageView.setImageResource(R.drawable.ic_gallery_24dp);
}
- ArrayList<Post.Preview> previews = post.getPreviews();
- if (previews != null && !previews.isEmpty()) {
+ if (post.getPreviews() != null && !post.getPreviews().isEmpty()) {
if (post.getPostType() != Post.GIF_TYPE && post.getPostType() != Post.VIDEO_TYPE) {
((PostCompactBaseViewHolder) holder).imageView.setVisibility(View.VISIBLE);
((PostCompactBaseViewHolder) holder).progressBar.setVisibility(View.VISIBLE);
}
- loadImage(holder, post, previews.get(0));
+ loadImage(holder);
}
}
@@ -1269,6 +1273,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
} else if (holder instanceof PostGalleryViewHolder) {
Post post = getItem(position);
if (post != null) {
+ ((PostGalleryViewHolder) holder).post = post;
((PostGalleryViewHolder) holder).currentPosition = position;
if (post.isRead()) {
holder.itemView.setBackgroundTintList(ColorStateList.valueOf(mReadPostCardViewBackgroundColor));
@@ -1281,6 +1286,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
((PostGalleryViewHolder) holder).progressBar.setVisibility(View.VISIBLE);
Post.Preview preview = getSuitablePreview(post.getPreviews());
+ ((PostGalleryViewHolder) holder).preview = preview;
if (preview != null) {
if (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0) {
int height = (int) (400 * mScale);
@@ -1292,7 +1298,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
((PostGalleryViewHolder) holder).imageView
.setRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth());
}
- loadImage(holder, post, preview);
+ loadImage(holder);
} else {
((PostGalleryViewHolder) holder).noPreviewImageView.setVisibility(View.VISIBLE);
if (post.getPostType() == Post.VIDEO_TYPE) {
@@ -1316,6 +1322,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
((PostGalleryViewHolder) holder).videoOrGifIndicatorImageView.setImageDrawable(ContextCompat.getDrawable(mActivity, R.drawable.ic_play_circle_36dp));
Post.Preview preview = getSuitablePreview(post.getPreviews());
+ ((PostGalleryViewHolder) holder).preview = preview;
if (preview != null) {
if (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0) {
int height = (int) (400 * mScale);
@@ -1327,7 +1334,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
((PostGalleryViewHolder) holder).imageView
.setRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth());
}
- loadImage(holder, post, preview);
+ loadImage(holder);
} else {
((PostGalleryViewHolder) holder).noPreviewImageView.setVisibility(View.VISIBLE);
((PostGalleryViewHolder) holder).noPreviewImageView.setImageResource(R.drawable.ic_image_24dp);
@@ -1341,6 +1348,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
((PostGalleryViewHolder) holder).videoOrGifIndicatorImageView.setImageDrawable(ContextCompat.getDrawable(mActivity, R.drawable.ic_play_circle_36dp));
Post.Preview preview = getSuitablePreview(post.getPreviews());
+ ((PostGalleryViewHolder) holder).preview = preview;
if (preview != null) {
if (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0) {
int height = (int) (400 * mScale);
@@ -1352,7 +1360,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
((PostGalleryViewHolder) holder).imageView
.setRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth());
}
- loadImage(holder, post, preview);
+ loadImage(holder);
} else {
((PostGalleryViewHolder) holder).noPreviewImageView.setVisibility(View.VISIBLE);
((PostGalleryViewHolder) holder).noPreviewImageView.setImageResource(R.drawable.ic_outline_video_24dp);
@@ -1366,6 +1374,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
((PostGalleryViewHolder) holder).videoOrGifIndicatorImageView.setImageDrawable(ContextCompat.getDrawable(mActivity, R.drawable.ic_link_post_type_indicator));
Post.Preview preview = getSuitablePreview(post.getPreviews());
+ ((PostGalleryViewHolder) holder).preview = preview;
if (preview != null) {
if (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0) {
int height = (int) (400 * mScale);
@@ -1377,7 +1386,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
((PostGalleryViewHolder) holder).imageView
.setRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth());
}
- loadImage(holder, post, preview);
+ loadImage(holder);
} else {
((PostGalleryViewHolder) holder).noPreviewImageView.setVisibility(View.VISIBLE);
((PostGalleryViewHolder) holder).noPreviewImageView.setImageResource(R.drawable.ic_link);
@@ -1401,6 +1410,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
((PostGalleryViewHolder) holder).videoOrGifIndicatorImageView.setImageDrawable(ContextCompat.getDrawable(mActivity, R.drawable.ic_gallery_24dp));
Post.Preview preview = getSuitablePreview(post.getPreviews());
+ ((PostGalleryViewHolder) holder).preview = preview;
if (preview != null) {
if (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0) {
int height = (int) (400 * mScale);
@@ -1412,7 +1422,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
((PostGalleryViewHolder) holder).imageView
.setRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth());
}
- loadImage(holder, post, preview);
+ loadImage(holder);
} else {
((PostGalleryViewHolder) holder).noPreviewImageView.setVisibility(View.VISIBLE);
((PostGalleryViewHolder) holder).noPreviewImageView.setImageResource(R.drawable.ic_gallery_24dp);
@@ -1435,29 +1445,31 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
previewIndex = 0;
}
preview = previews.get(previewIndex);
- if (preview.getPreviewWidth() * preview.getPreviewHeight() > 10_000_000) {
+ if (preview.getPreviewWidth() * preview.getPreviewHeight() > 5_000_000) {
for (int i = previews.size() - 1; i >= 1; i--) {
preview = previews.get(i);
if (mImageViewWidth >= preview.getPreviewWidth()) {
- if (preview.getPreviewWidth() * preview.getPreviewHeight() <= 10_000_000) {
+ if (preview.getPreviewWidth() * preview.getPreviewHeight() <= 5_000_000) {
return preview;
}
} else {
int height = mImageViewWidth / preview.getPreviewWidth() * preview.getPreviewHeight();
- if (mImageViewWidth * height <= 10_000_000) {
+ if (mImageViewWidth * height <= 5_000_000) {
+ preview.setPreviewWidth(mImageViewWidth);
+ preview.setPreviewHeight(height);
return preview;
}
}
}
}
- if (preview.getPreviewWidth() * preview.getPreviewHeight() > 10_000_000) {
+ if (preview.getPreviewWidth() * preview.getPreviewHeight() > 5_000_000) {
int divisor = 2;
do {
preview.setPreviewWidth(preview.getPreviewWidth() / divisor);
preview.setPreviewHeight(preview.getPreviewHeight() / divisor);
divisor *= 2;
- } while (preview.getPreviewWidth() * preview.getPreviewHeight() > 10_000_000);
+ } while (preview.getPreviewWidth() * preview.getPreviewHeight() > 5_000_000);
}
return preview;
}
@@ -1465,70 +1477,40 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
return null;
}
- private void loadImage(final RecyclerView.ViewHolder holder, final Post post, @NonNull Post.Preview preview) {
+ private void loadImage(final RecyclerView.ViewHolder holder) {
if (holder instanceof PostWithPreviewTypeViewHolder) {
- String url;
- boolean blurImage = (post.isNSFW() && mNeedBlurNsfw && !(mDoNotBlurNsfwInNsfwSubreddits && mFragment != null && mFragment.getIsNsfwSubreddit()) && !(post.getPostType() == Post.GIF_TYPE && mAutoplayNsfwVideos)) || post.isSpoiler() && mNeedBlurSpoiler;
- if (post.getPostType() == Post.GIF_TYPE && mAutoplay && !blurImage) {
- url = post.getUrl();
- } else {
- url = preview.getPreviewUrl();
- }
- RequestBuilder<Drawable> imageRequestBuilder = mGlide.load(url).listener(new RequestListener<Drawable>() {
- @Override
- public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
- ((PostWithPreviewTypeViewHolder) holder).progressBar.setVisibility(View.GONE);
- ((PostWithPreviewTypeViewHolder) holder).errorRelativeLayout.setVisibility(View.VISIBLE);
- ((PostWithPreviewTypeViewHolder) holder).errorRelativeLayout.setOnClickListener(view -> {
- ((PostWithPreviewTypeViewHolder) holder).progressBar.setVisibility(View.VISIBLE);
- ((PostWithPreviewTypeViewHolder) holder).errorRelativeLayout.setVisibility(View.GONE);
- loadImage(holder, post, preview);
- });
- return false;
- }
-
- @Override
- public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
- ((PostWithPreviewTypeViewHolder) holder).errorRelativeLayout.setVisibility(View.GONE);
- ((PostWithPreviewTypeViewHolder) holder).progressBar.setVisibility(View.GONE);
- return false;
+ Post post = ((PostWithPreviewTypeViewHolder) holder).post;
+ Post.Preview preview = ((PostWithPreviewTypeViewHolder) holder).preview;
+ if (preview != null) {
+ String url;
+ boolean blurImage = (post.isNSFW() && mNeedBlurNsfw && !(mDoNotBlurNsfwInNsfwSubreddits && mFragment != null && mFragment.getIsNsfwSubreddit()) && !(post.getPostType() == Post.GIF_TYPE && mAutoplayNsfwVideos)) || post.isSpoiler() && mNeedBlurSpoiler;
+ if (post.getPostType() == Post.GIF_TYPE && mAutoplay && !blurImage) {
+ url = post.getUrl();
+ } else {
+ url = preview.getPreviewUrl();
}
- });
+ RequestBuilder<Drawable> imageRequestBuilder = mGlide.load(url).listener(((PostWithPreviewTypeViewHolder) holder).glideRequestListener);
- if (blurImage) {
- imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10)))
- .into(((PostWithPreviewTypeViewHolder) holder).imageView);
- } else {
- if (mImageViewWidth > preview.getPreviewWidth()) {
- imageRequestBuilder.override(preview.getPreviewWidth(), preview.getPreviewHeight()).into(((PostWithPreviewTypeViewHolder) holder).imageView);
+ if (blurImage) {
+ imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10)))
+ .into(((PostWithPreviewTypeViewHolder) holder).imageView);
} else {
- imageRequestBuilder.into(((PostWithPreviewTypeViewHolder) holder).imageView);
+ imageRequestBuilder.diskCacheStrategy(DiskCacheStrategy.NONE).override(preview.getPreviewWidth(), preview.getPreviewHeight()).into(((PostWithPreviewTypeViewHolder) holder).imageView);
}
}
} else if (holder instanceof PostCompactBaseViewHolder) {
+ Post post = ((PostCompactBaseViewHolder) holder).post;
String postCompactThumbnailPreviewUrl;
ArrayList<Post.Preview> previews = post.getPreviews();
if (previews != null && !previews.isEmpty()) {
if (previews.size() >= 2) {
postCompactThumbnailPreviewUrl = previews.get(1).getPreviewUrl();
} else {
- postCompactThumbnailPreviewUrl = preview.getPreviewUrl();
+ postCompactThumbnailPreviewUrl = previews.get(0).getPreviewUrl();
}
RequestBuilder<Drawable> imageRequestBuilder = mGlide.load(postCompactThumbnailPreviewUrl)
- .error(R.drawable.ic_error_outline_black_24dp).listener(new RequestListener<Drawable>() {
- @Override
- public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
- ((PostCompactBaseViewHolder) holder).progressBar.setVisibility(View.GONE);
- return false;
- }
-
- @Override
- public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
- ((PostCompactBaseViewHolder) holder).progressBar.setVisibility(View.GONE);
- return false;
- }
- });
+ .error(R.drawable.ic_error_outline_black_24dp).listener(((PostCompactBaseViewHolder) holder).requestListener);
if ((post.isNSFW() && mNeedBlurNsfw && !(mDoNotBlurNsfwInNsfwSubreddits && mFragment != null && mFragment.getIsNsfwSubreddit())) || post.isSpoiler() && mNeedBlurSpoiler) {
imageRequestBuilder
.transform(new BlurTransformation(50, 2)).into(((PostCompactBaseViewHolder) holder).imageView);
@@ -1537,81 +1519,51 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
}
}
} else if (holder instanceof PostGalleryViewHolder) {
- String url;
- boolean blurImage = (post.isNSFW() && mNeedBlurNsfw && !(mDoNotBlurNsfwInNsfwSubreddits && mFragment != null && mFragment.getIsNsfwSubreddit()) && !(post.getPostType() == Post.GIF_TYPE && mAutoplayNsfwVideos)) || post.isSpoiler() && mNeedBlurSpoiler;
- if (post.getPostType() == Post.GIF_TYPE && mAutoplay && !blurImage) {
- url = post.getUrl();
- } else {
- url = preview.getPreviewUrl();
- }
- RequestBuilder<Drawable> imageRequestBuilder = mGlide.load(url).listener(new RequestListener<Drawable>() {
- @Override
- public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
- ((PostGalleryViewHolder) holder).progressBar.setVisibility(View.GONE);
- ((PostGalleryViewHolder) holder).errorRelativeLayout.setVisibility(View.VISIBLE);
- ((PostGalleryViewHolder) holder).errorRelativeLayout.setOnClickListener(view -> {
- ((PostGalleryViewHolder) holder).progressBar.setVisibility(View.VISIBLE);
- ((PostGalleryViewHolder) holder).errorRelativeLayout.setVisibility(View.GONE);
- loadImage(holder, post, preview);
- });
- return false;
- }
-
- @Override
- public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
- ((PostGalleryViewHolder) holder).errorRelativeLayout.setVisibility(View.GONE);
- ((PostGalleryViewHolder) holder).progressBar.setVisibility(View.GONE);
- return false;
+ Post post = ((PostGalleryViewHolder) holder).post;
+ Post.Preview preview = ((PostGalleryViewHolder) holder).preview;
+ if (preview != null) {
+ String url;
+ boolean blurImage = (post.isNSFW() && mNeedBlurNsfw && !(mDoNotBlurNsfwInNsfwSubreddits && mFragment != null && mFragment.getIsNsfwSubreddit()) && !(post.getPostType() == Post.GIF_TYPE && mAutoplayNsfwVideos)) || post.isSpoiler() && mNeedBlurSpoiler;
+ if (post.getPostType() == Post.GIF_TYPE && mAutoplay && !blurImage) {
+ url = post.getUrl();
+ } else {
+ url = preview.getPreviewUrl();
}
- });
+ RequestBuilder<Drawable> imageRequestBuilder = mGlide.load(url).listener(((PostGalleryViewHolder) holder).requestListener);
- if (blurImage) {
- imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10)))
- .into(((PostGalleryViewHolder) holder).imageView);
- } else {
- if (mImageViewWidth > preview.getPreviewWidth()) {
- imageRequestBuilder.override(preview.getPreviewWidth(), preview.getPreviewHeight()).into(((PostGalleryViewHolder) holder).imageView);
+ if (blurImage) {
+ imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10)))
+ .into(((PostGalleryViewHolder) holder).imageView);
} else {
- imageRequestBuilder.into(((PostGalleryViewHolder) holder).imageView);
+ if (mImageViewWidth > preview.getPreviewWidth()) {
+ imageRequestBuilder.override(preview.getPreviewWidth(), preview.getPreviewHeight()).into(((PostGalleryViewHolder) holder).imageView);
+ } else {
+ imageRequestBuilder.into(((PostGalleryViewHolder) holder).imageView);
+ }
}
}
} else if (holder instanceof PostCard2WithPreviewViewHolder) {
- String url;
- boolean blurImage = (post.isNSFW() && mNeedBlurNsfw && !(mDoNotBlurNsfwInNsfwSubreddits && mFragment != null && mFragment.getIsNsfwSubreddit()) && !(post.getPostType() == Post.GIF_TYPE && mAutoplayNsfwVideos)) || post.isSpoiler() && mNeedBlurSpoiler;
- if (post.getPostType() == Post.GIF_TYPE && mAutoplay && !blurImage) {
- url = post.getUrl();
- } else {
- url = preview.getPreviewUrl();
- }
- RequestBuilder<Drawable> imageRequestBuilder = mGlide.load(url).listener(new RequestListener<Drawable>() {
- @Override
- public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
- ((PostCard2WithPreviewViewHolder) holder).progressBar.setVisibility(View.GONE);
- ((PostCard2WithPreviewViewHolder) holder).errorRelativeLayout.setVisibility(View.VISIBLE);
- ((PostCard2WithPreviewViewHolder) holder).errorRelativeLayout.setOnClickListener(view -> {
- ((PostCard2WithPreviewViewHolder) holder).progressBar.setVisibility(View.VISIBLE);
- ((PostCard2WithPreviewViewHolder) holder).errorRelativeLayout.setVisibility(View.GONE);
- loadImage(holder, post, preview);
- });
- return false;
- }
-
- @Override
- public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
- ((PostCard2WithPreviewViewHolder) holder).errorRelativeLayout.setVisibility(View.GONE);
- ((PostCard2WithPreviewViewHolder) holder).progressBar.setVisibility(View.GONE);
- return false;
+ Post post = ((PostCard2WithPreviewViewHolder) holder).post;
+ Post.Preview preview = ((PostCard2WithPreviewViewHolder) holder).preview;
+ if (preview != null) {
+ String url;
+ boolean blurImage = (post.isNSFW() && mNeedBlurNsfw && !(mDoNotBlurNsfwInNsfwSubreddits && mFragment != null && mFragment.getIsNsfwSubreddit()) && !(post.getPostType() == Post.GIF_TYPE && mAutoplayNsfwVideos)) || post.isSpoiler() && mNeedBlurSpoiler;
+ if (post.getPostType() == Post.GIF_TYPE && mAutoplay && !blurImage) {
+ url = post.getUrl();
+ } else {
+ url = preview.getPreviewUrl();
}
- });
+ RequestBuilder<Drawable> imageRequestBuilder = mGlide.load(url).listener(((PostCard2WithPreviewViewHolder) holder).requestListener);
- if (blurImage) {
- imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10)))
- .into(((PostCard2WithPreviewViewHolder) holder).imageView);
- } else {
- if (mImageViewWidth > preview.getPreviewWidth()) {
- imageRequestBuilder.override(preview.getPreviewWidth(), preview.getPreviewHeight()).into(((PostCard2WithPreviewViewHolder) holder).imageView);
+ if (blurImage) {
+ imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10)))
+ .into(((PostCard2WithPreviewViewHolder) holder).imageView);
} else {
- imageRequestBuilder.into(((PostCard2WithPreviewViewHolder) holder).imageView);
+ if (mImageViewWidth > preview.getPreviewWidth()) {
+ imageRequestBuilder.override(preview.getPreviewWidth(), preview.getPreviewHeight()).into(((PostCard2WithPreviewViewHolder) holder).imageView);
+ } else {
+ imageRequestBuilder.into(((PostCard2WithPreviewViewHolder) holder).imageView);
+ }
}
}
}
@@ -1787,6 +1739,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
} else {
holder.itemView.setBackgroundTintList(ColorStateList.valueOf(mCardViewBackgroundColor));
}
+ mGlide.clear(((PostBaseViewHolder) holder).iconGifImageView);
((PostBaseViewHolder) holder).titleTextView.setTextColor(mPostTitleColor);
if (holder instanceof PostVideoAutoplayViewHolder) {
((PostVideoAutoplayViewHolder) holder).mediaUri = null;
@@ -1801,7 +1754,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
} else if (holder instanceof PostWithPreviewTypeViewHolder) {
mGlide.clear(((PostWithPreviewTypeViewHolder) holder).imageView);
((PostWithPreviewTypeViewHolder) holder).imageWrapperRelativeLayout.setVisibility(View.GONE);
- ((PostWithPreviewTypeViewHolder) holder).errorRelativeLayout.setVisibility(View.GONE);
+ ((PostWithPreviewTypeViewHolder) holder).errorTextView.setVisibility(View.GONE);
((PostWithPreviewTypeViewHolder) holder).noPreviewLinkImageView.setVisibility(View.GONE);
((PostWithPreviewTypeViewHolder) holder).progressBar.setVisibility(View.GONE);
((PostWithPreviewTypeViewHolder) holder).videoOrGifIndicatorImageView.setVisibility(View.GONE);
@@ -1823,7 +1776,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
} else if (holder instanceof PostCard2WithPreviewViewHolder) {
mGlide.clear(((PostCard2WithPreviewViewHolder) holder).imageView);
((PostCard2WithPreviewViewHolder) holder).imageView.setVisibility(View.GONE);
- ((PostCard2WithPreviewViewHolder) holder).errorRelativeLayout.setVisibility(View.GONE);
+ ((PostCard2WithPreviewViewHolder) holder).errorTextView.setVisibility(View.GONE);
((PostCard2WithPreviewViewHolder) holder).noPreviewImageView.setVisibility(View.GONE);
((PostCard2WithPreviewViewHolder) holder).progressBar.setVisibility(View.GONE);
((PostCard2WithPreviewViewHolder) holder).videoOrGifIndicatorImageView.setVisibility(View.GONE);
@@ -1894,7 +1847,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
mGlide.clear(((PostGalleryViewHolder) holder).imageView);
((PostGalleryViewHolder) holder).imageView.setVisibility(View.GONE);
((PostGalleryViewHolder) holder).progressBar.setVisibility(View.GONE);
- ((PostGalleryViewHolder) holder).errorRelativeLayout.setVisibility(View.GONE);
+ ((PostGalleryViewHolder) holder).errorTextView.setVisibility(View.GONE);
((PostGalleryViewHolder) holder).videoOrGifIndicatorImageView.setVisibility(View.GONE);
((PostGalleryViewHolder) holder).noPreviewImageView.setVisibility(View.GONE);
}
@@ -2045,6 +1998,8 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
TextView commentsCountTextView;
ImageView saveButton;
ImageView shareButton;
+ Post post;
+ Post.Preview preview;
boolean itemViewIsNotCardView = false;
int currentPosition;
@@ -2706,14 +2661,14 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
if (post.isGfycat()) {
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_GFYCAT);
intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, post.getGfycatId());
- if (post.isLoadGfyOrRedgifsVideoSuccess()) {
+ if (post.isLoadGfycatOrRedgifsVideoSuccess()) {
intent.setData(Uri.parse(post.getVideoUrl()));
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, post.getVideoDownloadUrl());
}
} else if (post.isRedgifs()) {
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_REDGIFS);
intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, post.getGfycatId());
- if (post.isLoadGfyOrRedgifsVideoSuccess()) {
+ if (post.isLoadGfycatOrRedgifsVideoSuccess()) {
intent.setData(Uri.parse(post.getVideoUrl()));
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, post.getVideoDownloadUrl());
}
@@ -2871,13 +2826,11 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
@BindView(R.id.video_or_gif_indicator_image_view_item_post_with_preview)
ImageView videoOrGifIndicatorImageView;
@BindView(R.id.image_wrapper_relative_layout_item_post_with_preview)
- RelativeLayout imageWrapperRelativeLayout;
+ FrameLayout imageWrapperRelativeLayout;
@BindView(R.id.progress_bar_item_post_with_preview)
ProgressBar progressBar;
@BindView(R.id.image_view_item_post_with_preview)
AspectRatioGifImageView imageView;
- @BindView(R.id.load_image_error_relative_layout_item_post_with_preview)
- RelativeLayout errorRelativeLayout;
@BindView(R.id.load_image_error_text_view_item_post_with_preview)
TextView errorTextView;
@BindView(R.id.image_view_no_preview_gallery_item_post_with_preview)
@@ -2896,6 +2849,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
ImageView saveButton;
@BindView(R.id.share_button_item_post_with_preview)
ImageView shareButton;
+ RequestListener<Drawable> glideRequestListener;
PostWithPreviewTypeViewHolder(View itemView) {
super(itemView);
@@ -2943,9 +2897,31 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
}
});
+ errorTextView.setOnClickListener(view -> {
+ progressBar.setVisibility(View.VISIBLE);
+ errorTextView.setVisibility(View.GONE);
+ loadImage(this);
+ });
+
noPreviewLinkImageView.setOnClickListener(view -> {
imageView.performClick();
});
+
+ glideRequestListener = new RequestListener<>() {
+ @Override
+ public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
+ progressBar.setVisibility(View.GONE);
+ errorTextView.setVisibility(View.VISIBLE);
+ return false;
+ }
+
+ @Override
+ public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
+ errorTextView.setVisibility(View.GONE);
+ progressBar.setVisibility(View.GONE);
+ return false;
+ }
+ };
}
}
@@ -3056,6 +3032,8 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
ImageView saveButton;
ImageView shareButton;
View divider;
+ RequestListener<Drawable> requestListener;
+ Post post;
int currentPosition;
@@ -3552,6 +3530,20 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
shareLink(post);
}
});
+
+ requestListener = new RequestListener<>() {
+ @Override
+ public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
+ progressBar.setVisibility(View.GONE);
+ return false;
+ }
+
+ @Override
+ public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
+ progressBar.setVisibility(View.GONE);
+ return false;
+ }
+ };
}
void markPostRead(Post post, boolean changePostItemColor) {
@@ -3728,14 +3720,15 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
ImageView videoOrGifIndicatorImageView;
@BindView(R.id.image_view_item_post_gallery)
AspectRatioGifImageView imageView;
- @BindView(R.id.load_image_error_relative_layout_item_post_gallery)
- RelativeLayout errorRelativeLayout;
@BindView(R.id.load_image_error_text_view_item_gallery)
TextView errorTextView;
@BindView(R.id.image_view_no_preview_item_post_gallery)
ImageView noPreviewImageView;
@BindView(R.id.title_text_view_item_post_gallery)
TextView titleTextView;
+ RequestListener<Drawable> requestListener;
+ Post post;
+ Post.Preview preview;
int currentPosition;
@@ -3788,9 +3781,31 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
return true;
});
+ errorTextView.setOnClickListener(view -> {
+ progressBar.setVisibility(View.VISIBLE);
+ errorTextView.setVisibility(View.GONE);
+ loadImage(this);
+ });
+
noPreviewImageView.setOnClickListener(view -> {
itemView.performClick();
});
+
+ requestListener = new RequestListener<>() {
+ @Override
+ public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
+ progressBar.setVisibility(View.GONE);
+ errorTextView.setVisibility(View.VISIBLE);
+ return false;
+ }
+
+ @Override
+ public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
+ errorTextView.setVisibility(View.GONE);
+ progressBar.setVisibility(View.GONE);
+ return false;
+ }
+ };
}
void markPostRead(Post post, boolean changePostItemColor) {
@@ -3931,14 +3946,14 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
if (post.isGfycat()) {
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_GFYCAT);
intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, post.getGfycatId());
- if (post.isLoadGfyOrRedgifsVideoSuccess()) {
+ if (post.isLoadGfycatOrRedgifsVideoSuccess()) {
intent.setData(Uri.parse(post.getVideoUrl()));
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, post.getVideoDownloadUrl());
}
} else if (post.isRedgifs()) {
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_REDGIFS);
intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, post.getGfycatId());
- if (post.isLoadGfyOrRedgifsVideoSuccess()) {
+ if (post.isLoadGfycatOrRedgifsVideoSuccess()) {
intent.setData(Uri.parse(post.getVideoUrl()));
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, post.getVideoDownloadUrl());
}
@@ -4099,8 +4114,6 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
ProgressBar progressBar;
@BindView(R.id.image_view_item_post_card_2_with_preview)
AspectRatioGifImageView imageView;
- @BindView(R.id.load_image_error_relative_layout_item_post_card_2_with_preview)
- RelativeLayout errorRelativeLayout;
@BindView(R.id.load_image_error_text_view_item_post_card_2_with_preview)
TextView errorTextView;
@BindView(R.id.image_view_no_preview_gallery_item_post_card_2_with_preview)
@@ -4121,6 +4134,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
ImageView shareButton;
@BindView(R.id.divider_item_post_card_2_with_preview)
View divider;
+ RequestListener<Drawable> requestListener;
PostCard2WithPreviewViewHolder(@NonNull View itemView) {
super(itemView);
@@ -4170,9 +4184,31 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
}
});
+ errorTextView.setOnClickListener(view -> {
+ progressBar.setVisibility(View.VISIBLE);
+ errorTextView.setVisibility(View.GONE);
+ loadImage(this);
+ });
+
noPreviewImageView.setOnClickListener(view -> {
imageView.performClick();
});
+
+ requestListener = new RequestListener<>() {
+ @Override
+ public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
+ progressBar.setVisibility(View.GONE);
+ errorTextView.setVisibility(View.VISIBLE);
+ return false;
+ }
+
+ @Override
+ public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
+ errorTextView.setVisibility(View.GONE);
+ progressBar.setVisibility(View.GONE);
+ return false;
+ }
+ };
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/apis/RedditAPI.java b/app/src/main/java/ml/docilealligator/infinityforreddit/apis/RedditAPI.java
index dd9efb33..4b00f4be 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/apis/RedditAPI.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/apis/RedditAPI.java
@@ -403,4 +403,24 @@ public interface RedditAPI {
@GET("{multipath}.json?raw_json=1")
ListenableFuture<Response<String>> getMultiRedditPostsOauthListenableFuture(@Path(value = "multipath", encoded = true) String multiPath,
@Query("after") String after, @HeaderMap Map<String, String> headers);
+
+ @POST("r/{subredditName}/api/delete_sr_icon")
+ Call<String> deleteSrIcon(@HeaderMap Map<String, String> headers, @Path("subredditName") String subredditName);
+
+ @POST("r/{subredditName}/api/delete_sr_banner")
+ Call<String> deleteSrBanner(@HeaderMap Map<String, String> headers, @Path("subredditName") String subredditName);
+
+ @Multipart
+ @POST("r/{subredditName}/api/upload_sr_img")
+ Call<String> uploadSrImg(@HeaderMap Map<String, String> headers,
+ @Path("subredditName") String subredditName,
+ @PartMap Map<String, RequestBody> params,
+ @Part MultipartBody.Part file);
+
+ @GET("r/{subredditName}/about/edit?raw_json=1")
+ Call<String> getSubredditSetting(@HeaderMap Map<String, String> headers, @Path("subredditName") String subredditName);
+
+ @FormUrlEncoded
+ @POST("/api/site_admin")
+ Call<String> postSiteAdmin(@HeaderMap Map<String, String> headers, @FieldMap Map<String, String> params);
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/events/SubmitChangeAvatarEvent.java b/app/src/main/java/ml/docilealligator/infinityforreddit/events/SubmitChangeAvatarEvent.java
new file mode 100644
index 00000000..3e806034
--- /dev/null
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/events/SubmitChangeAvatarEvent.java
@@ -0,0 +1,11 @@
+package ml.docilealligator.infinityforreddit.events;
+
+public class SubmitChangeAvatarEvent {
+ public final boolean isSuccess;
+ public final String errorMessage;
+
+ public SubmitChangeAvatarEvent(boolean isSuccess, String errorMessage) {
+ this.isSuccess = isSuccess;
+ this.errorMessage = errorMessage;
+ }
+}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/events/SubmitChangeBannerEvent.java b/app/src/main/java/ml/docilealligator/infinityforreddit/events/SubmitChangeBannerEvent.java
new file mode 100644
index 00000000..290445e3
--- /dev/null
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/events/SubmitChangeBannerEvent.java
@@ -0,0 +1,11 @@
+package ml.docilealligator.infinityforreddit.events;
+
+public class SubmitChangeBannerEvent {
+ public final boolean isSuccess;
+ public final String errorMessage;
+
+ public SubmitChangeBannerEvent(boolean isSuccess, String errorMessage) {
+ this.isSuccess = isSuccess;
+ this.errorMessage = errorMessage;
+ }
+}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/events/SubmitSaveProfileEvent.java b/app/src/main/java/ml/docilealligator/infinityforreddit/events/SubmitSaveProfileEvent.java
new file mode 100644
index 00000000..d2ca5516
--- /dev/null
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/events/SubmitSaveProfileEvent.java
@@ -0,0 +1,11 @@
+package ml.docilealligator.infinityforreddit.events;
+
+public class SubmitSaveProfileEvent {
+ public final boolean isSuccess;
+ public final String errorMessage;
+
+ public SubmitSaveProfileEvent(boolean isSuccess, String errorMessage) {
+ this.isSuccess = isSuccess;
+ this.errorMessage = errorMessage;
+ }
+}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/post/Post.java b/app/src/main/java/ml/docilealligator/infinityforreddit/post/Post.java
index d814fb86..6a0173c1 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/post/Post.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/post/Post.java
@@ -337,7 +337,7 @@ public class Post implements Parcelable {
this.isRedgifs = isRedgifs;
}
- public boolean isLoadGfyOrRedgifsVideoSuccess() {
+ public boolean isLoadGfycatOrRedgifsVideoSuccess() {
return loadGfyOrRedgifsVideoSuccess;
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/services/EditProfileService.java b/app/src/main/java/ml/docilealligator/infinityforreddit/services/EditProfileService.java
new file mode 100644
index 00000000..e93d16d2
--- /dev/null
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/services/EditProfileService.java
@@ -0,0 +1,260 @@
+package ml.docilealligator.infinityforreddit.services;
+
+import android.app.Notification;
+import android.app.Service;
+import android.content.Intent;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.net.Uri;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.HandlerThread;
+import android.os.IBinder;
+import android.os.Looper;
+import android.os.Message;
+import android.os.Process;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.core.app.NotificationChannelCompat;
+import androidx.core.app.NotificationCompat;
+import androidx.core.app.NotificationManagerCompat;
+import com.bumptech.glide.Glide;
+import jp.wasabeef.glide.transformations.CropTransformation;
+import ml.docilealligator.infinityforreddit.Infinity;
+import ml.docilealligator.infinityforreddit.R;
+import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
+import ml.docilealligator.infinityforreddit.events.SubmitChangeAvatarEvent;
+import ml.docilealligator.infinityforreddit.events.SubmitChangeBannerEvent;
+import ml.docilealligator.infinityforreddit.events.SubmitSaveProfileEvent;
+import ml.docilealligator.infinityforreddit.utils.EditProfileUtils;
+import ml.docilealligator.infinityforreddit.utils.NotificationUtils;
+import org.greenrobot.eventbus.EventBus;
+import retrofit2.Retrofit;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import java.io.FileNotFoundException;
+import java.util.Random;
+import java.util.concurrent.ExecutionException;
+
+public class EditProfileService extends Service {
+ public static final String EXTRA_ACCESS_TOKEN = "EAT";
+ public static final String EXTRA_ACCOUNT_NAME = "EAN";
+ public static final String EXTRA_DISPLAY_NAME = "EDN";
+ public static final String EXTRA_ABOUT_YOU = "EAY";
+ public static final String EXTRA_POST_TYPE = "EPT";
+
+ public static final int EXTRA_POST_TYPE_UNKNOWN = 0x500;
+ public static final int EXTRA_POST_TYPE_CHANGE_BANNER = 0x501;
+ public static final int EXTRA_POST_TYPE_CHANGE_AVATAR = 0x502;
+ public static final int EXTRA_POST_TYPE_SAVE_EDIT_PROFILE = 0x503;
+
+ private static final String EXTRA_MEDIA_URI = "EU";
+
+ private static final int MAX_BANNER_WIDTH = 1280;
+ private static final int MIN_BANNER_WIDTH = 640;
+ private static final int AVATAR_SIZE = 256;
+ @Inject
+ @Named("oauth")
+ Retrofit mOauthRetrofit;
+ @Inject
+ CustomThemeWrapper mCustomThemeWrapper;
+ private Handler handler;
+ private ServiceHandler serviceHandler;
+
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ ((Infinity) getApplication()).getAppComponent().inject(this);
+ handler = new Handler();
+ HandlerThread thread = new HandlerThread("ServiceStartArguments",
+ Process.THREAD_PRIORITY_BACKGROUND);
+ thread.start();
+ serviceHandler = new ServiceHandler(thread.getLooper());
+ }
+
+ @Override
+ public int onStartCommand(Intent intent, int flags, int startId) {
+ ((Infinity) getApplication()).getAppComponent().inject(this);
+
+ NotificationChannelCompat serviceChannel =
+ new NotificationChannelCompat.Builder(
+ NotificationUtils.CHANNEL_SUBMIT_POST,
+ NotificationManagerCompat.IMPORTANCE_LOW)
+ .setName(NotificationUtils.CHANNEL_SUBMIT_POST)
+ .build();
+
+ NotificationManagerCompat manager = NotificationManagerCompat.from(this);
+ manager.createNotificationChannel(serviceChannel);
+
+ int randomNotificationIdOffset = new Random().nextInt(10000);
+ Bundle bundle = intent.getExtras();
+ final int postType = intent.getIntExtra(EXTRA_POST_TYPE, EXTRA_POST_TYPE_UNKNOWN);
+ switch (postType) {
+ case EXTRA_POST_TYPE_CHANGE_BANNER:
+ bundle.putString(EXTRA_MEDIA_URI, intent.getData().toString());
+ startForeground(NotificationUtils.SUBMIT_POST_SERVICE_NOTIFICATION_ID + randomNotificationIdOffset,
+ createNotification(R.string.submit_change_banner));
+ break;
+ case EXTRA_POST_TYPE_CHANGE_AVATAR:
+ bundle.putString(EXTRA_MEDIA_URI, intent.getData().toString());
+ startForeground(NotificationUtils.SUBMIT_POST_SERVICE_NOTIFICATION_ID + randomNotificationIdOffset,
+ createNotification(R.string.submit_change_avatar));
+ break;
+ case EXTRA_POST_TYPE_SAVE_EDIT_PROFILE:
+ startForeground(NotificationUtils.SUBMIT_POST_SERVICE_NOTIFICATION_ID + randomNotificationIdOffset,
+ createNotification(R.string.submit_save_profile));
+ break;
+ default:
+ case EXTRA_POST_TYPE_UNKNOWN:
+ break;
+ }
+
+ Message msg = serviceHandler.obtainMessage();
+ msg.setData(bundle);
+ serviceHandler.sendMessage(msg);
+ return START_NOT_STICKY;
+ }
+
+ @Nullable
+ @Override
+ public IBinder onBind(Intent intent) {
+ return null;
+ }
+
+ private void submitChangeBanner(String accessToken, Uri mediaUri, String accountName) {
+ try {
+ final int width = getWidthBanner(mediaUri);
+ final int height = Math.round(width * 3 / 10f); // ratio 10:3
+ CropTransformation bannerCrop = new CropTransformation(width, height, CropTransformation.CropType.CENTER);
+ Bitmap resource = Glide.with(this).asBitmap().skipMemoryCache(true)
+ .load(mediaUri).transform(bannerCrop).submit().get();
+ EditProfileUtils.uploadBanner(mOauthRetrofit, accessToken, accountName, resource, new EditProfileUtils.EditProfileUtilsListener() {
+ @Override
+ public void success() {
+ handler.post(() -> EventBus.getDefault().post(new SubmitChangeBannerEvent(true, "")));
+ stopService();
+ }
+
+ @Override
+ public void failed(String message) {
+ handler.post(() -> EventBus.getDefault().post(new SubmitChangeBannerEvent(false, message)));
+ stopService();
+ }
+ });
+ } catch (InterruptedException | ExecutionException | FileNotFoundException e) {
+ e.printStackTrace();
+ stopService();
+ }
+ }
+
+ private void submitChangeAvatar(String accessToken, Uri mediaUri, String accountName) {
+ try {
+ final CropTransformation avatarCrop = new CropTransformation(AVATAR_SIZE, AVATAR_SIZE, CropTransformation.CropType.CENTER);
+ final Bitmap resource = Glide.with(this).asBitmap().skipMemoryCache(true)
+ .load(mediaUri).transform(avatarCrop).submit().get();
+ EditProfileUtils.uploadAvatar(mOauthRetrofit, accessToken, accountName, resource, new EditProfileUtils.EditProfileUtilsListener() {
+ @Override
+ public void success() {
+ handler.post(() -> EventBus.getDefault().post(new SubmitChangeAvatarEvent(true, "")));
+ stopService();
+ }
+
+ @Override
+ public void failed(String message) {
+ handler.post(() -> EventBus.getDefault().post(new SubmitChangeAvatarEvent(false, message)));
+ stopService();
+ }
+ });
+ } catch (InterruptedException | ExecutionException e) {
+ e.printStackTrace();
+ stopService();
+ }
+ }
+
+ private void submitSaveEditProfile(String accessToken,
+ String accountName,
+ String displayName,
+ String publicDesc
+ ) {
+ EditProfileUtils.updateProfile(mOauthRetrofit,
+ accessToken,
+ accountName,
+ displayName,
+ publicDesc,
+ new EditProfileUtils.EditProfileUtilsListener() {
+ @Override
+ public void success() {
+ handler.post(() -> EventBus.getDefault().post(new SubmitSaveProfileEvent(true, "")));
+ stopService();
+ }
+
+ @Override
+ public void failed(String message) {
+ handler.post(() -> EventBus.getDefault().post(new SubmitSaveProfileEvent(false, message)));
+ stopService();
+ }
+ });
+
+ }
+
+ private Notification createNotification(int stringResId) {
+ return new NotificationCompat.Builder(this, NotificationUtils.CHANNEL_SUBMIT_POST)
+ .setContentTitle(getString(stringResId))
+ .setContentText(getString(R.string.please_wait))
+ .setSmallIcon(R.drawable.ic_notification)
+ .setColor(mCustomThemeWrapper.getColorPrimaryLightTheme())
+ .build();
+ }
+
+ private void stopService() {
+ stopForeground(true);
+ stopSelf();
+ }
+
+
+ private int getWidthBanner(Uri mediaUri) throws FileNotFoundException {
+ BitmapFactory.Options options = new BitmapFactory.Options();
+ options.inJustDecodeBounds = true;
+ BitmapFactory.decodeStream(getContentResolver().openInputStream(mediaUri), null, options);
+ return Math.max(Math.min(options.outWidth, MAX_BANNER_WIDTH), MIN_BANNER_WIDTH);
+ }
+
+ private class ServiceHandler extends Handler {
+ public ServiceHandler(Looper looper) {
+ super(looper);
+ }
+
+ @Override
+ public void handleMessage(@NonNull Message msg) {
+ super.handleMessage(msg);
+ Bundle bundle = msg.getData();
+ String accessToken = bundle.getString(EXTRA_ACCESS_TOKEN);
+ String accountName = bundle.getString(EXTRA_ACCOUNT_NAME);
+ final int postType = bundle.getInt(EXTRA_POST_TYPE, EXTRA_POST_TYPE_UNKNOWN);
+ switch (postType) {
+ case EXTRA_POST_TYPE_CHANGE_BANNER:
+ submitChangeBanner(accessToken,
+ Uri.parse(bundle.getString(EXTRA_MEDIA_URI)),
+ accountName);
+ break;
+ case EXTRA_POST_TYPE_CHANGE_AVATAR:
+ submitChangeAvatar(accessToken,
+ Uri.parse(bundle.getString(EXTRA_MEDIA_URI)),
+ accountName);
+ break;
+ case EXTRA_POST_TYPE_SAVE_EDIT_PROFILE:
+ submitSaveEditProfile(
+ accessToken,
+ accountName,
+ bundle.getString(EXTRA_DISPLAY_NAME),
+ bundle.getString(EXTRA_ABOUT_YOU)
+ );
+ break;
+ default:
+ case EXTRA_POST_TYPE_UNKNOWN:
+ break;
+ }
+ }
+ }
+}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/subreddit/SubredditSettingData.java b/app/src/main/java/ml/docilealligator/infinityforreddit/subreddit/SubredditSettingData.java
new file mode 100644
index 00000000..4759d102
--- /dev/null
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/subreddit/SubredditSettingData.java
@@ -0,0 +1,634 @@
+package ml.docilealligator.infinityforreddit.subreddit;
+
+import androidx.annotation.Nullable;
+import com.google.gson.annotations.SerializedName;
+
+import java.util.Objects;
+
+public class SubredditSettingData {
+ // Content visibility || Posts to this profile can appear in r/all and your profile can be discovered in /users
+ @SerializedName("default_set")
+ private boolean defaultSet;
+ @SerializedName("toxicity_threshold_chat_level")
+ private int toxicityThresholdChatLevel;
+ @SerializedName("crowd_control_chat_level")
+ private int crowdControlChatLevel;
+ @SerializedName("restrict_posting")
+ private boolean restrictPosting;
+ @SerializedName("public_description")
+ private String publicDescription;
+ @SerializedName("subreddit_id")
+ private String subredditId;
+ @SerializedName("allow_images")
+ private boolean allowImages;
+ @SerializedName("free_form_reports")
+ private boolean freeFormReports;
+ @SerializedName("domain")
+ @Nullable
+ private String domain;
+ @SerializedName("show_media")
+ private boolean showMedia;
+ @SerializedName("wiki_edit_age")
+ private int wikiEditAge;
+ @SerializedName("submit_text")
+ private String submitText;
+ @SerializedName("allow_polls")
+ private boolean allowPolls;
+ @SerializedName("title")
+ private String title;
+ @SerializedName("collapse_deleted_comments")
+ private boolean collapseDeletedComments;
+ @SerializedName("wikimode")
+ private String wikiMode;
+ @SerializedName("should_archive_posts")
+ private boolean shouldArchivePosts;
+ @SerializedName("allow_videos")
+ private boolean allowVideos;
+ @SerializedName("allow_galleries")
+ private boolean allowGalleries;
+ @SerializedName("crowd_control_level")
+ private int crowdControlLevel;
+ @SerializedName("crowd_control_mode")
+ private boolean crowdControlMode;
+ @SerializedName("welcome_message_enabled")
+ private boolean welcomeMessageEnabled;
+ @SerializedName("welcome_message_text")
+ @Nullable
+ private String welcomeMessageText;
+ @SerializedName("over_18")
+ private boolean over18;
+ @SerializedName("suggested_comment_sort")
+ private String suggestedCommentSort;
+ @SerializedName("disable_contributor_requests")
+ private boolean disableContributorRequests;
+ @SerializedName("original_content_tag_enabled")
+ private boolean originalContentTagEnabled;
+ @SerializedName("description")
+ private String description;
+ @SerializedName("submit_link_label")
+ private String submitLinkLabel;
+ @SerializedName("spoilers_enabled")
+ private boolean spoilersEnabled;
+ @SerializedName("allow_post_crossposts")
+ private boolean allowPostCrossPosts;
+ @SerializedName("spam_comments")
+ private String spamComments;
+ @SerializedName("public_traffic")
+ private boolean publicTraffic;
+ @SerializedName("restrict_commenting")
+ private boolean restrictCommenting;
+ @SerializedName("new_pinned_post_pns_enabled")
+ private boolean newPinnedPostPnsEnabled;
+ @SerializedName("submit_text_label")
+ private String submitTextLabel;
+ @SerializedName("all_original_content")
+ private boolean allOriginalContent;
+ @SerializedName("spam_selfposts")
+ private String spamSelfPosts;
+ @SerializedName("key_color")
+ private String keyColor;
+ @SerializedName("language")
+ private String language;
+ @SerializedName("wiki_edit_karma")
+ private int wikiEditKarma;
+ @SerializedName("hide_ads")
+ private boolean hideAds;
+ @SerializedName("prediction_leaderboard_entry_type")
+ private int predictionLeaderboardEntryType;
+ @SerializedName("header_hover_text")
+ private String headerHoverText;
+ @SerializedName("allow_chat_post_creation")
+ private boolean allowChatPostCreation;
+ @SerializedName("allow_prediction_contributors")
+ private boolean allowPredictionContributors;
+ @SerializedName("allow_discovery")
+ private boolean allowDiscovery;
+ @SerializedName("accept_followers")
+ private boolean acceptFollowers;
+ @SerializedName("exclude_banned_modqueue")
+ private boolean excludeBannedModQueue;
+ @SerializedName("allow_predictions_tournament")
+ private boolean allowPredictionsTournament;
+ @SerializedName("show_media_preview")
+ private boolean showMediaPreview;
+ @SerializedName("comment_score_hide_mins")
+ private int commentScoreHideMins;
+ @SerializedName("subreddit_type")
+ private String subredditType;
+ @SerializedName("spam_links")
+ private String spamLinks;
+ @SerializedName("allow_predictions")
+ private boolean allowPredictions;
+ @SerializedName("user_flair_pns_enabled")
+ private boolean userFlairPnsEnabled;
+ @SerializedName("content_options")
+ private String contentOptions;
+
+ public boolean isDefaultSet() {
+ return defaultSet;
+ }
+
+ public void setDefaultSet(boolean defaultSet) {
+ this.defaultSet = defaultSet;
+ }
+
+ public int getToxicityThresholdChatLevel() {
+ return toxicityThresholdChatLevel;
+ }
+
+ public void setToxicityThresholdChatLevel(int toxicityThresholdChatLevel) {
+ this.toxicityThresholdChatLevel = toxicityThresholdChatLevel;
+ }
+
+ public int getCrowdControlChatLevel() {
+ return crowdControlChatLevel;
+ }
+
+ public void setCrowdControlChatLevel(int crowdControlChatLevel) {
+ this.crowdControlChatLevel = crowdControlChatLevel;
+ }
+
+ public boolean isRestrictPosting() {
+ return restrictPosting;
+ }
+
+ public void setRestrictPosting(boolean restrictPosting) {
+ this.restrictPosting = restrictPosting;
+ }
+
+ public String getPublicDescription() {
+ return publicDescription;
+ }
+
+ public void setPublicDescription(String publicDescription) {
+ this.publicDescription = publicDescription;
+ }
+
+ public String getSubredditId() {
+ return subredditId;
+ }
+
+ public void setSubredditId(String subredditId) {
+ this.subredditId = subredditId;
+ }
+
+ public boolean isAllowImages() {
+ return allowImages;
+ }
+
+ public void setAllowImages(boolean allowImages) {
+ this.allowImages = allowImages;
+ }
+
+ public boolean isFreeFormReports() {
+ return freeFormReports;
+ }
+
+ public void setFreeFormReports(boolean freeFormReports) {
+ this.freeFormReports = freeFormReports;
+ }
+
+ @Nullable
+ public String getDomain() {
+ return domain;
+ }
+
+ public void setDomain(@Nullable String domain) {
+ this.domain = domain;
+ }
+
+ public boolean isShowMedia() {
+ return showMedia;
+ }
+
+ public void setShowMedia(boolean showMedia) {
+ this.showMedia = showMedia;
+ }
+
+ public int getWikiEditAge() {
+ return wikiEditAge;
+ }
+
+ public void setWikiEditAge(int wikiEditAge) {
+ this.wikiEditAge = wikiEditAge;
+ }
+
+ public String getSubmitText() {
+ return submitText;
+ }
+
+ public void setSubmitText(String submitText) {
+ this.submitText = submitText;
+ }
+
+ public boolean isAllowPolls() {
+ return allowPolls;
+ }
+
+ public void setAllowPolls(boolean allowPolls) {
+ this.allowPolls = allowPolls;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public boolean isCollapseDeletedComments() {
+ return collapseDeletedComments;
+ }
+
+ public void setCollapseDeletedComments(boolean collapseDeletedComments) {
+ this.collapseDeletedComments = collapseDeletedComments;
+ }
+
+ public String getWikiMode() {
+ return wikiMode;
+ }
+
+ public void setWikiMode(String wikiMode) {
+ this.wikiMode = wikiMode;
+ }
+
+ public boolean isShouldArchivePosts() {
+ return shouldArchivePosts;
+ }
+
+ public void setShouldArchivePosts(boolean shouldArchivePosts) {
+ this.shouldArchivePosts = shouldArchivePosts;
+ }
+
+ public boolean isAllowVideos() {
+ return allowVideos;
+ }
+
+ public void setAllowVideos(boolean allowVideos) {
+ this.allowVideos = allowVideos;
+ }
+
+ public boolean isAllowGalleries() {
+ return allowGalleries;
+ }
+
+ public void setAllowGalleries(boolean allowGalleries) {
+ this.allowGalleries = allowGalleries;
+ }
+
+ public int getCrowdControlLevel() {
+ return crowdControlLevel;
+ }
+
+ public void setCrowdControlLevel(int crowdControlLevel) {
+ this.crowdControlLevel = crowdControlLevel;
+ }
+
+ public boolean isCrowdControlMode() {
+ return crowdControlMode;
+ }
+
+ public void setCrowdControlMode(boolean crowdControlMode) {
+ this.crowdControlMode = crowdControlMode;
+ }
+
+ public boolean isWelcomeMessageEnabled() {
+ return welcomeMessageEnabled;
+ }
+
+ public void setWelcomeMessageEnabled(boolean welcomeMessageEnabled) {
+ this.welcomeMessageEnabled = welcomeMessageEnabled;
+ }
+
+ @Nullable
+ public String getWelcomeMessageText() {
+ return welcomeMessageText;
+ }
+
+ public void setWelcomeMessageText(@Nullable String welcomeMessageText) {
+ this.welcomeMessageText = welcomeMessageText;
+ }
+
+ public boolean isOver18() {
+ return over18;
+ }
+
+ public void setOver18(boolean over18) {
+ this.over18 = over18;
+ }
+
+ public String getSuggestedCommentSort() {
+ return suggestedCommentSort;
+ }
+
+ public void setSuggestedCommentSort(String suggestedCommentSort) {
+ this.suggestedCommentSort = suggestedCommentSort;
+ }
+
+ public boolean isDisableContributorRequests() {
+ return disableContributorRequests;
+ }
+
+ public void setDisableContributorRequests(boolean disableContributorRequests) {
+ this.disableContributorRequests = disableContributorRequests;
+ }
+
+ public boolean isOriginalContentTagEnabled() {
+ return originalContentTagEnabled;
+ }
+
+ public void setOriginalContentTagEnabled(boolean originalContentTagEnabled) {
+ this.originalContentTagEnabled = originalContentTagEnabled;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getSubmitLinkLabel() {
+ return submitLinkLabel;
+ }
+
+ public void setSubmitLinkLabel(String submitLinkLabel) {
+ this.submitLinkLabel = submitLinkLabel;
+ }
+
+ public boolean isSpoilersEnabled() {
+ return spoilersEnabled;
+ }
+
+ public void setSpoilersEnabled(boolean spoilersEnabled) {
+ this.spoilersEnabled = spoilersEnabled;
+ }
+
+ public boolean isAllowPostCrossPosts() {
+ return allowPostCrossPosts;
+ }
+
+ public void setAllowPostCrossPosts(boolean allowPostCrossPosts) {
+ this.allowPostCrossPosts = allowPostCrossPosts;
+ }
+
+ public String getSpamComments() {
+ return spamComments;
+ }
+
+ public void setSpamComments(String spamComments) {
+ this.spamComments = spamComments;
+ }
+
+ public boolean isPublicTraffic() {
+ return publicTraffic;
+ }
+
+ public void setPublicTraffic(boolean publicTraffic) {
+ this.publicTraffic = publicTraffic;
+ }
+
+ public boolean isRestrictCommenting() {
+ return restrictCommenting;
+ }
+
+ public void setRestrictCommenting(boolean restrictCommenting) {
+ this.restrictCommenting = restrictCommenting;
+ }
+
+ public boolean isNewPinnedPostPnsEnabled() {
+ return newPinnedPostPnsEnabled;
+ }
+
+ public void setNewPinnedPostPnsEnabled(boolean newPinnedPostPnsEnabled) {
+ this.newPinnedPostPnsEnabled = newPinnedPostPnsEnabled;
+ }
+
+ public String getSubmitTextLabel() {
+ return submitTextLabel;
+ }
+
+ public void setSubmitTextLabel(String submitTextLabel) {
+ this.submitTextLabel = submitTextLabel;
+ }
+
+ public boolean isAllOriginalContent() {
+ return allOriginalContent;
+ }
+
+ public void setAllOriginalContent(boolean allOriginalContent) {
+ this.allOriginalContent = allOriginalContent;
+ }
+
+ public String getSpamSelfPosts() {
+ return spamSelfPosts;
+ }
+
+ public void setSpamSelfPosts(String spamSelfPosts) {
+ this.spamSelfPosts = spamSelfPosts;
+ }
+
+ public String getKeyColor() {
+ return keyColor;
+ }
+
+ public void setKeyColor(String keyColor) {
+ this.keyColor = keyColor;
+ }
+
+ public String getLanguage() {
+ return language;
+ }
+
+ public void setLanguage(String language) {
+ this.language = language;
+ }
+
+ public int getWikiEditKarma() {
+ return wikiEditKarma;
+ }
+
+ public void setWikiEditKarma(int wikiEditKarma) {
+ this.wikiEditKarma = wikiEditKarma;
+ }
+
+ public boolean isHideAds() {
+ return hideAds;
+ }
+
+ public void setHideAds(boolean hideAds) {
+ this.hideAds = hideAds;
+ }
+
+ public int getPredictionLeaderboardEntryType() {
+ return predictionLeaderboardEntryType;
+ }
+
+ public void setPredictionLeaderboardEntryType(int predictionLeaderboardEntryType) {
+ this.predictionLeaderboardEntryType = predictionLeaderboardEntryType;
+ }
+
+ public String getHeaderHoverText() {
+ return headerHoverText;
+ }
+
+ public void setHeaderHoverText(String headerHoverText) {
+ this.headerHoverText = headerHoverText;
+ }
+
+ public boolean isAllowChatPostCreation() {
+ return allowChatPostCreation;
+ }
+
+ public void setAllowChatPostCreation(boolean allowChatPostCreation) {
+ this.allowChatPostCreation = allowChatPostCreation;
+ }
+
+ public boolean isAllowPredictionContributors() {
+ return allowPredictionContributors;
+ }
+
+ public void setAllowPredictionContributors(boolean allowPredictionContributors) {
+ this.allowPredictionContributors = allowPredictionContributors;
+ }
+
+ public boolean isAllowDiscovery() {
+ return allowDiscovery;
+ }
+
+ public void setAllowDiscovery(boolean allowDiscovery) {
+ this.allowDiscovery = allowDiscovery;
+ }
+
+ public boolean isAcceptFollowers() {
+ return acceptFollowers;
+ }
+
+ public void setAcceptFollowers(boolean acceptFollowers) {
+ this.acceptFollowers = acceptFollowers;
+ }
+
+ public boolean isExcludeBannedModQueue() {
+ return excludeBannedModQueue;
+ }
+
+ public void setExcludeBannedModQueue(boolean excludeBannedModQueue) {
+ this.excludeBannedModQueue = excludeBannedModQueue;
+ }
+
+ public boolean isAllowPredictionsTournament() {
+ return allowPredictionsTournament;
+ }
+
+ public void setAllowPredictionsTournament(boolean allowPredictionsTournament) {
+ this.allowPredictionsTournament = allowPredictionsTournament;
+ }
+
+ public boolean isShowMediaPreview() {
+ return showMediaPreview;
+ }
+
+ public void setShowMediaPreview(boolean showMediaPreview) {
+ this.showMediaPreview = showMediaPreview;
+ }
+
+ public int getCommentScoreHideMins() {
+ return commentScoreHideMins;
+ }
+
+ public void setCommentScoreHideMins(int commentScoreHideMins) {
+ this.commentScoreHideMins = commentScoreHideMins;
+ }
+
+ public String getSubredditType() {
+ return subredditType;
+ }
+
+ public void setSubredditType(String subredditType) {
+ this.subredditType = subredditType;
+ }
+
+ public String getSpamLinks() {
+ return spamLinks;
+ }
+
+ public void setSpamLinks(String spamLinks) {
+ this.spamLinks = spamLinks;
+ }
+
+ public boolean isAllowPredictions() {
+ return allowPredictions;
+ }
+
+ public void setAllowPredictions(boolean allowPredictions) {
+ this.allowPredictions = allowPredictions;
+ }
+
+ public boolean isUserFlairPnsEnabled() {
+ return userFlairPnsEnabled;
+ }
+
+ public void setUserFlairPnsEnabled(boolean userFlairPnsEnabled) {
+ this.userFlairPnsEnabled = userFlairPnsEnabled;
+ }
+
+ public String getContentOptions() {
+ return contentOptions;
+ }
+
+ public void setContentOptions(String contentOptions) {
+ this.contentOptions = contentOptions;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ SubredditSettingData that = (SubredditSettingData) o;
+ return defaultSet == that.defaultSet && toxicityThresholdChatLevel == that.toxicityThresholdChatLevel
+ && crowdControlChatLevel == that.crowdControlChatLevel && restrictPosting == that.restrictPosting
+ && allowImages == that.allowImages && freeFormReports == that.freeFormReports && showMedia == that.showMedia
+ && wikiEditAge == that.wikiEditAge && allowPolls == that.allowPolls && collapseDeletedComments == that.collapseDeletedComments
+ && shouldArchivePosts == that.shouldArchivePosts && allowVideos == that.allowVideos
+ && allowGalleries == that.allowGalleries && crowdControlLevel == that.crowdControlLevel
+ && crowdControlMode == that.crowdControlMode && welcomeMessageEnabled == that.welcomeMessageEnabled
+ && over18 == that.over18 && disableContributorRequests == that.disableContributorRequests
+ && originalContentTagEnabled == that.originalContentTagEnabled && spoilersEnabled == that.spoilersEnabled
+ && allowPostCrossPosts == that.allowPostCrossPosts && publicTraffic == that.publicTraffic
+ && restrictCommenting == that.restrictCommenting && newPinnedPostPnsEnabled == that.newPinnedPostPnsEnabled
+ && allOriginalContent == that.allOriginalContent && wikiEditKarma == that.wikiEditKarma
+ && hideAds == that.hideAds && predictionLeaderboardEntryType == that.predictionLeaderboardEntryType
+ && allowChatPostCreation == that.allowChatPostCreation && allowPredictionContributors == that.allowPredictionContributors
+ && allowDiscovery == that.allowDiscovery && acceptFollowers == that.acceptFollowers
+ && excludeBannedModQueue == that.excludeBannedModQueue && allowPredictionsTournament == that.allowPredictionsTournament
+ && showMediaPreview == that.showMediaPreview && commentScoreHideMins == that.commentScoreHideMins
+ && allowPredictions == that.allowPredictions && userFlairPnsEnabled == that.userFlairPnsEnabled
+ && Objects.equals(publicDescription, that.publicDescription) && Objects.equals(subredditId, that.subredditId)
+ && Objects.equals(domain, that.domain) && Objects.equals(submitText, that.submitText)
+ && Objects.equals(title, that.title) && Objects.equals(wikiMode, that.wikiMode) &&
+ Objects.equals(welcomeMessageText, that.welcomeMessageText) && Objects.equals(suggestedCommentSort, that.suggestedCommentSort)
+ && Objects.equals(description, that.description) && Objects.equals(submitLinkLabel, that.submitLinkLabel)
+ && Objects.equals(spamComments, that.spamComments) && Objects.equals(submitTextLabel, that.submitTextLabel)
+ && Objects.equals(spamSelfPosts, that.spamSelfPosts) && Objects.equals(keyColor, that.keyColor)
+ && Objects.equals(language, that.language) && Objects.equals(headerHoverText, that.headerHoverText)
+ && Objects.equals(subredditType, that.subredditType) && Objects.equals(spamLinks, that.spamLinks)
+ && Objects.equals(contentOptions, that.contentOptions);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(defaultSet, toxicityThresholdChatLevel, crowdControlChatLevel, restrictPosting,
+ publicDescription, subredditId, allowImages, freeFormReports, domain, showMedia, wikiEditAge,
+ submitText, allowPolls, title, collapseDeletedComments, wikiMode, shouldArchivePosts,
+ allowVideos, allowGalleries, crowdControlLevel, crowdControlMode, welcomeMessageEnabled,
+ welcomeMessageText, over18, suggestedCommentSort, disableContributorRequests, originalContentTagEnabled,
+ description, submitLinkLabel, spoilersEnabled, allowPostCrossPosts, spamComments, publicTraffic,
+ restrictCommenting, newPinnedPostPnsEnabled, submitTextLabel, allOriginalContent, spamSelfPosts,
+ keyColor, language, wikiEditKarma, hideAds, predictionLeaderboardEntryType, headerHoverText,
+ allowChatPostCreation, allowPredictionContributors, allowDiscovery, acceptFollowers,
+ excludeBannedModQueue, allowPredictionsTournament, showMediaPreview, commentScoreHideMins,
+ subredditType, spamLinks, allowPredictions, userFlairPnsEnabled, contentOptions);
+ }
+}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/user/FetchUserData.java b/app/src/main/java/ml/docilealligator/infinityforreddit/user/FetchUserData.java
index 3c5280a7..fc3da19d 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/user/FetchUserData.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/user/FetchUserData.java
@@ -26,7 +26,7 @@ public class FetchUserData {
} else {
userInfo = api.getUserDataOauth(APIUtils.getOAuthHeader(accessToken), userName);
}
- userInfo.enqueue(new Callback<String>() {
+ userInfo.enqueue(new Callback<>() {
@Override
public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) {
if (response.isSuccessful()) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/user/ParseUserData.java b/app/src/main/java/ml/docilealligator/infinityforreddit/user/ParseUserData.java
index 608f78a4..a57a98ed 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/user/ParseUserData.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/user/ParseUserData.java
@@ -52,9 +52,10 @@ public class ParseUserData {
boolean isFriend = userDataJson.getBoolean(JSONUtils.IS_FRIEND_KEY);
boolean isNsfw = userDataJson.getJSONObject(JSONUtils.SUBREDDIT_KEY).getBoolean(JSONUtils.OVER_18_KEY);
String description = userDataJson.getJSONObject(JSONUtils.SUBREDDIT_KEY).getString(JSONUtils.PUBLIC_DESCRIPTION_KEY);
+ String title = userDataJson.getJSONObject(JSONUtils.SUBREDDIT_KEY).getString(JSONUtils.TITLE_KEY);
return new UserData(userName, iconImageUrl, bannerImageUrl, linkKarma, commentKarma, awarderKarma,
- awardeeKarma, totalKarma, cakeday, isGold, isFriend, canBeFollowed, isNsfw, description);
+ awardeeKarma, totalKarma, cakeday, isGold, isFriend, canBeFollowed, isNsfw, description, title);
}
interface ParseUserDataListener {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/user/UserData.java b/app/src/main/java/ml/docilealligator/infinityforreddit/user/UserData.java
index 06be82f1..4512ca86 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/user/UserData.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/user/UserData.java
@@ -38,12 +38,14 @@ public class UserData {
private boolean isNSFW;
@ColumnInfo(name = "description")
private String description;
+ @ColumnInfo(name = "title")
+ private String title;
@Ignore
private boolean isSelected;
public UserData(@NonNull String name, String iconUrl, String banner, int linkKarma, int commentKarma,
int awarderKarma, int awardeeKarma, int totalKarma, long cakeday, boolean isGold,
- boolean isFriend, boolean canBeFollowed, boolean isNSFW, String description) {
+ boolean isFriend, boolean canBeFollowed, boolean isNSFW, String description, String title) {
this.name = name;
this.iconUrl = iconUrl;
this.banner = banner;
@@ -58,6 +60,7 @@ public class UserData {
this.canBeFollowed = canBeFollowed;
this.isNSFW = isNSFW;
this.description = description;
+ this.title = title;
this.isSelected = false;
}
@@ -118,6 +121,10 @@ public class UserData {
return description;
}
+ public String getTitle() {
+ return title;
+ }
+
public boolean isSelected() {
return isSelected;
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/EditProfileUtils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/EditProfileUtils.java
new file mode 100644
index 00000000..5293bc71
--- /dev/null
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/EditProfileUtils.java
@@ -0,0 +1,276 @@
+package ml.docilealligator.infinityforreddit.utils;
+
+import android.graphics.Bitmap;
+import androidx.annotation.NonNull;
+import com.google.gson.Gson;
+import ml.docilealligator.infinityforreddit.apis.RedditAPI;
+import ml.docilealligator.infinityforreddit.subreddit.SubredditSettingData;
+import okhttp3.MediaType;
+import okhttp3.MultipartBody;
+import okhttp3.RequestBody;
+import org.json.JSONException;
+import org.json.JSONObject;
+import retrofit2.Call;
+import retrofit2.Callback;
+import retrofit2.Response;
+import retrofit2.Retrofit;
+
+import java.io.ByteArrayOutputStream;
+import java.util.HashMap;
+import java.util.Map;
+
+public final class EditProfileUtils {
+
+
+
+ public static void updateProfile(Retrofit oauthRetrofit,
+ String accessToken,
+ String accountName,
+ String displayName,
+ String publicDesc,
+ EditProfileUtilsListener listener) {
+ final Map<String, String> oauthHeader = APIUtils.getOAuthHeader(accessToken);
+ final RedditAPI api = oauthRetrofit.create(RedditAPI.class);
+ final String name = "u_" + accountName;
+ api.getSubredditSetting(oauthHeader, name).enqueue(new Callback<>() {
+ @Override
+ public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
+ if (response.isSuccessful()) {
+ try {
+ final String json = response.body();
+ if (json == null) {
+ listener.failed("Something happen.");
+ return;
+ }
+
+ final JSONObject resBody = new JSONObject(json);
+ final SubredditSettingData data = new Gson().fromJson(resBody.getString("data"), SubredditSettingData.class);
+
+ if (data.getPublicDescription().equals(publicDesc)
+ && data.getTitle().equals(displayName)) {
+ // no-op
+ listener.success();
+ return;
+ }
+
+ final Map<String, String> params = new HashMap<>();
+
+ params.put("api_type", "json");
+ params.put("sr", data.getSubredditId());
+ params.put("name", name);
+ params.put("type", data.getSubredditType());
+ // Only this 2 param
+ params.put("public_description", publicDesc);
+ params.put("title", displayName);
+ // Official Reddit app have this 2 params
+ // 1 = disable; 0 = enable || Active in communities visibility || Show which communities I am active in on my profile.
+ params.put("toxicity_threshold_chat_level", String.valueOf(data.getToxicityThresholdChatLevel()));
+ // Content visibility || Posts to this profile can appear in r/all and your profile can be discovered in /users
+ params.put("default_set", String.valueOf(data.isDefaultSet()));
+
+ // Allow people to follow you || Followers will be notified about posts you make to your profile and see them in their home feed.
+ params.put("accept_followers", String.valueOf(data.isAcceptFollowers()));
+
+ params.put("allow_top", String.valueOf(data.isPublicTraffic())); //
+ params.put("link_type", String.valueOf(data.getContentOptions())); //
+ //
+ params.put("original_content_tag_enabled", String.valueOf(data.isOriginalContentTagEnabled()));
+ params.put("new_pinned_post_pns_enabled", String.valueOf(data.isNewPinnedPostPnsEnabled()));
+ params.put("prediction_leaderboard_entry_type", String.valueOf(data.getPredictionLeaderboardEntryType()));
+ params.put("restrict_commenting", String.valueOf(data.isRestrictCommenting()));
+ params.put("restrict_posting", String.valueOf(data.isRestrictPosting()));
+ params.put("should_archive_posts", String.valueOf(data.isShouldArchivePosts()));
+ params.put("show_media", String.valueOf(data.isShowMedia()));
+ params.put("show_media_preview", String.valueOf(data.isShowMediaPreview()));
+ params.put("spam_comments", data.getSpamComments());
+ params.put("spam_links", data.getSpamLinks());
+ params.put("spam_selfposts", data.getSpamSelfPosts());
+ params.put("spoilers_enabled", String.valueOf(data.isSpoilersEnabled()));
+ params.put("submit_link_label", data.getSubmitLinkLabel());
+ params.put("submit_text", data.getSubmitText());
+ params.put("submit_text_label", data.getSubmitTextLabel());
+ params.put("user_flair_pns_enabled", String.valueOf(data.isUserFlairPnsEnabled()));
+ params.put("all_original_content", String.valueOf(data.isAllOriginalContent()));
+ params.put("allow_chat_post_creation", String.valueOf(data.isAllowChatPostCreation()));
+ params.put("allow_discovery", String.valueOf(data.isAllowDiscovery()));
+ params.put("allow_galleries", String.valueOf(data.isAllowGalleries()));
+ params.put("allow_images", String.valueOf(data.isAllowImages()));
+ params.put("allow_polls", String.valueOf(data.isAllowPolls()));
+ params.put("allow_post_crossposts", String.valueOf(data.isAllowPostCrossPosts()));
+ params.put("allow_prediction_contributors", String.valueOf(data.isAllowPredictionContributors()));
+ params.put("allow_predictions", String.valueOf(data.isAllowPredictions()));
+ params.put("allow_predictions_tournament", String.valueOf(data.isAllowPredictionsTournament()));
+ params.put("allow_videos", String.valueOf(data.isAllowVideos()));
+ params.put("collapse_deleted_comments", String.valueOf(data.isCollapseDeletedComments()));
+ params.put("comment_score_hide_mins", String.valueOf(data.getCommentScoreHideMins()));
+ params.put("crowd_control_chat_level", String.valueOf(data.getCrowdControlChatLevel()));
+ params.put("crowd_control_filter", String.valueOf(data.getCrowdControlChatLevel()));
+ params.put("crowd_control_level", String.valueOf(data.getCrowdControlLevel()));
+ params.put("crowd_control_mode", String.valueOf(data.isCrowdControlMode()));
+ params.put("description", data.getDescription());
+ params.put("disable_contributor_requests", String.valueOf(data.isDisableContributorRequests()));
+ params.put("exclude_banned_modqueue", String.valueOf(data.isExcludeBannedModQueue()));
+ params.put("free_form_reports", String.valueOf(data.isFreeFormReports()));
+ params.put("header-title", data.getHeaderHoverText());
+ params.put("hide_ads", String.valueOf(data.isHideAds()));
+ params.put("key_color", data.getKeyColor());
+ params.put("lang", data.getLanguage());
+ params.put("over_18", String.valueOf(data.isOver18()));
+ params.put("suggested_comment_sort", data.getSuggestedCommentSort());
+ params.put("welcome_message_enabled", String.valueOf(data.isWelcomeMessageEnabled()));
+ params.put("welcome_message_text", String.valueOf(data.getWelcomeMessageText()));
+ params.put("wiki_edit_age", String.valueOf(data.getWikiEditAge()));
+ params.put("wiki_edit_karma", String.valueOf(data.getWikiEditKarma()));
+ params.put("wikimode", data.getWikiMode());
+
+ api.postSiteAdmin(oauthHeader, params)
+ .enqueue(new Callback<>() {
+ @Override
+ public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
+ if (response.isSuccessful()) listener.success();
+ else listener.failed(response.message());
+ }
+
+ @Override
+ public void onFailure(@NonNull Call<String> call, @NonNull Throwable t) {
+ t.printStackTrace();
+ listener.failed(t.getLocalizedMessage());
+ }
+ });
+ } catch (JSONException e) {
+ listener.failed(e.getLocalizedMessage());
+ }
+ } else {
+ listener.failed(response.message());
+ }
+ }
+
+ @Override
+ public void onFailure(@NonNull Call<String> call, @NonNull Throwable t) {
+ t.printStackTrace();
+ listener.failed(t.getLocalizedMessage());
+ }
+ });
+
+ }
+
+ public static void uploadAvatar(Retrofit oauthRetrofit,
+ String accessToken,
+ String accountName,
+ Bitmap image,
+ EditProfileUtilsListener listener) {
+ oauthRetrofit.create(RedditAPI.class)
+ .uploadSrImg(
+ APIUtils.getOAuthHeader(accessToken),
+ "u_" + accountName,
+ requestBodyUploadSr("icon"),
+ fileToUpload(image, accountName + "-icon"))
+ .enqueue(new Callback<>() {
+ @Override
+ public void onResponse(@NonNull Call<String> call,
+ @NonNull Response<String> response) {
+ if (response.isSuccessful()) listener.success();
+ else listener.failed(response.message());
+ }
+
+ @Override
+ public void onFailure(@NonNull Call<String> call, @NonNull Throwable t) {
+ t.printStackTrace();
+ listener.failed(t.getLocalizedMessage());
+ }
+ });
+ }
+
+ public static void uploadBanner(Retrofit oauthRetrofit,
+ String accessToken,
+ String accountName,
+ Bitmap image,
+ EditProfileUtilsListener listener) {
+ oauthRetrofit.create(RedditAPI.class)
+ .uploadSrImg(
+ APIUtils.getOAuthHeader(accessToken),
+ "u_" + accountName,
+ requestBodyUploadSr("banner"),
+ fileToUpload(image, accountName + "-banner"))
+ .enqueue(new Callback<>() {
+ @Override
+ public void onResponse(@NonNull Call<String> call,
+ @NonNull Response<String> response) {
+ if (response.isSuccessful()) listener.success();
+ else listener.failed(response.message());
+ }
+
+ @Override
+ public void onFailure(@NonNull Call<String> call, @NonNull Throwable t) {
+ t.printStackTrace();
+ listener.failed(t.getLocalizedMessage());
+ }
+ });
+ }
+
+ public static void deleteAvatar(Retrofit oauthRetrofit,
+ String accessToken,
+ String accountName,
+ EditProfileUtilsListener listener) {
+ oauthRetrofit.create(RedditAPI.class)
+ .deleteSrIcon(APIUtils.getOAuthHeader(accessToken), "u_" + accountName)
+ .enqueue(new Callback<>() {
+ @Override
+ public void onResponse(@NonNull Call<String> call,
+ @NonNull Response<String> response) {
+ if (response.isSuccessful()) listener.success();
+ else listener.failed(response.message());
+ }
+
+ @Override
+ public void onFailure(@NonNull Call<String> call, @NonNull Throwable t) {
+ t.printStackTrace();
+ listener.failed(t.getLocalizedMessage());
+ }
+ });
+ }
+
+ public static void deleteBanner(Retrofit oauthRetrofit,
+ String accessToken,
+ String accountName,
+ EditProfileUtilsListener listener) {
+ oauthRetrofit.create(RedditAPI.class)
+ .deleteSrBanner(APIUtils.getOAuthHeader(accessToken), "u_" + accountName)
+ .enqueue(new Callback<>() {
+ @Override
+ public void onResponse(@NonNull Call<String> call,
+ @NonNull Response<String> response) {
+ if (response.isSuccessful()) listener.success();
+ else listener.failed(response.message());
+ }
+
+ @Override
+ public void onFailure(@NonNull Call<String> call, @NonNull Throwable t) {
+ t.printStackTrace();
+ listener.failed(t.getLocalizedMessage());
+ }
+ });
+ }
+
+ private static Map<String, RequestBody> requestBodyUploadSr(String type) {
+ Map<String, RequestBody> param = new HashMap<>();
+ param.put("upload_type", APIUtils.getRequestBody(type));
+ param.put("img_type", APIUtils.getRequestBody("jpg"));
+ return param;
+ }
+
+ private static MultipartBody.Part fileToUpload(Bitmap image, String fileName) {
+ ByteArrayOutputStream stream = new ByteArrayOutputStream();
+ image.compress(Bitmap.CompressFormat.JPEG, 100, stream);
+ byte[] byteArray = stream.toByteArray();
+ RequestBody fileBody = RequestBody.create(byteArray,
+ MediaType.parse("image/*"));
+ return MultipartBody.Part.createFormData("file", fileName + ".jpg", fileBody);
+ }
+
+ public interface EditProfileUtilsListener {
+ void success();
+
+ void failed(String message);
+ }
+}
diff --git a/app/src/main/res/drawable/ic_dot_outline.xml b/app/src/main/res/drawable/ic_dot_outline.xml
new file mode 100644
index 00000000..dd9c5588
--- /dev/null
+++ b/app/src/main/res/drawable/ic_dot_outline.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+ android:shape="oval"
+ android:tint="?attr/colorOnPrimary">
+ <size
+ android:width="24dp"
+ android:height="24dp" />
+ <solid android:color="#7F000000" />
+</shape>
diff --git a/app/src/main/res/layout/activity_anonymous_subscriptions.xml b/app/src/main/res/layout/activity_anonymous_subscriptions.xml
index eb030fd8..66efc9bb 100644
--- a/app/src/main/res/layout/activity_anonymous_subscriptions.xml
+++ b/app/src/main/res/layout/activity_anonymous_subscriptions.xml
@@ -14,6 +14,7 @@
android:theme="@style/AppTheme.AppBarOverlay">
<com.google.android.material.appbar.CollapsingToolbarLayout
+ android:id="@+id/collapsing_toolbar_layout_anonymous_subscriptions_activity"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|enterAlways"
diff --git a/app/src/main/res/layout/activity_comment_full_markdown.xml b/app/src/main/res/layout/activity_comment_full_markdown.xml
index e1f89252..df690767 100644
--- a/app/src/main/res/layout/activity_comment_full_markdown.xml
+++ b/app/src/main/res/layout/activity_comment_full_markdown.xml
@@ -14,6 +14,7 @@
android:theme="@style/AppTheme.AppBarOverlay">
<com.google.android.material.appbar.CollapsingToolbarLayout
+ android:id="@+id/collapsing_toolbar_layout_comment_full_markdown_activity"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|enterAlways"
diff --git a/app/src/main/res/layout/activity_create_multi_reddit.xml b/app/src/main/res/layout/activity_create_multi_reddit.xml
index 5b088546..e1b3a3e1 100644
--- a/app/src/main/res/layout/activity_create_multi_reddit.xml
+++ b/app/src/main/res/layout/activity_create_multi_reddit.xml
@@ -14,6 +14,7 @@
android:theme="@style/AppTheme.AppBarOverlay">
<com.google.android.material.appbar.CollapsingToolbarLayout
+ android:id="@+id/collapsing_toolbar_layout_create_multi_reddit_activity"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|enterAlways"
diff --git a/app/src/main/res/layout/activity_edit_multi_reddit.xml b/app/src/main/res/layout/activity_edit_multi_reddit.xml
index 2e2442eb..71b98553 100644
--- a/app/src/main/res/layout/activity_edit_multi_reddit.xml
+++ b/app/src/main/res/layout/activity_edit_multi_reddit.xml
@@ -14,6 +14,7 @@
android:theme="@style/AppTheme.AppBarOverlay">
<com.google.android.material.appbar.CollapsingToolbarLayout
+ android:id="@+id/collapsing_toolbar_layout_edit_multi_reddit_activity"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|enterAlways"
diff --git a/app/src/main/res/layout/activity_edit_profile.xml b/app/src/main/res/layout/activity_edit_profile.xml
new file mode 100644
index 00000000..453ad5c4
--- /dev/null
+++ b/app/src/main/res/layout/activity_edit_profile.xml
@@ -0,0 +1,176 @@
+<?xml version="1.0" encoding="utf-8"?>
+<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:id="@+id/root_layout_view_edit_profile_activity"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ tools:context=".activities.EditProfileActivity">
+
+ <com.google.android.material.appbar.AppBarLayout
+ android:id="@+id/appbar_layout_view_edit_profile_activity"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:theme="@style/AppTheme.AppBarOverlay">
+
+ <androidx.appcompat.widget.Toolbar
+ android:id="@+id/toolbar_view_edit_profile_activity"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:minHeight="?attr/actionBarSize"
+ app:navigationIcon="?attr/homeAsUpIndicator"
+ app:popupTheme="@style/AppTheme.PopupOverlay"
+ app:title="@string/action_edit_profile" />
+
+ </com.google.android.material.appbar.AppBarLayout>
+
+ <androidx.core.widget.NestedScrollView
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ app:layout_behavior="@string/appbar_scrolling_view_behavior">
+
+ <LinearLayout
+ android:id="@+id/content_view_edit_profile_activity"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical">
+
+ <FrameLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+
+ <FrameLayout
+ android:id="@+id/frame_layout_view_banner_edit_profile_activity"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_margin="8dp">
+
+ <ImageView
+ android:id="@+id/image_view_banner_edit_profile_activity"
+ android:layout_width="match_parent"
+ android:layout_height="180dp"
+ android:contentDescription="@null"
+ android:scaleType="centerCrop"
+ tools:src="@tools:sample/backgrounds/scenic" />
+
+ <ImageView
+ android:id="@+id/image_view_change_banner_edit_profile_activity"
+ android:layout_width="32dp"
+ android:layout_height="32dp"
+ android:layout_gravity="end|bottom"
+ android:layout_margin="4dp"
+ android:background="@drawable/ic_dot_outline"
+ android:contentDescription="@null"
+ android:padding="4dp"
+ app:srcCompat="@drawable/ic_outline_add_a_photo_day_night_24dp" />
+
+ </FrameLayout>
+
+ <FrameLayout
+ android:id="@+id/frame_layout_view_avatar_edit_profile_activity"
+ android:layout_width="74dp"
+ android:layout_height="74dp"
+ android:layout_marginStart="24dp"
+ android:layout_marginTop="143dp"
+ android:elevation="4dp">
+
+ <ImageView
+ android:id="@+id/image_view_avatar_edit_profile_activity"
+ android:layout_width="74dp"
+ android:layout_height="74dp"
+ android:contentDescription="@null"
+ tools:src="@tools:sample/avatars" />
+
+ <ImageView
+ android:id="@+id/image_view_change_avatar_edit_profile_activity"
+ android:layout_width="32dp"
+ android:layout_height="32dp"
+ android:layout_gravity="end|bottom"
+ android:layout_margin="4dp"
+ android:background="@drawable/ic_dot_outline"
+ android:contentDescription="@null"
+ android:padding="4dp"
+ app:srcCompat="@drawable/ic_outline_add_a_photo_day_night_24dp" />
+
+ </FrameLayout>
+
+ </FrameLayout>
+
+ <View
+ android:layout_width="match_parent"
+ android:layout_height="1dp"
+ android:layout_margin="8dp"
+ android:background="?dividerVertical" />
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_margin="8dp"
+ android:orientation="vertical"
+ android:padding="8dp">
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:fontFamily="?attr/font_family"
+ android:text="@string/display_name_text"
+ android:textSize="?attr/font_18" />
+
+ <EditText
+ android:id="@+id/edit_text_display_name_edit_profile_activity"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:gravity="top"
+ android:hint="@string/display_name_hint"
+ android:importantForAutofill="no"
+ android:inputType="textCapSentences"
+ android:lines="1"
+ android:maxLength="30"
+ android:maxLines="1"
+ android:paddingStart="16dp"
+ android:paddingEnd="16dp"
+ android:paddingBottom="16dp" />
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/display_name_description" />
+
+ </LinearLayout>
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_margin="8dp"
+ android:orientation="vertical"
+ android:padding="8dp">
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:fontFamily="?attr/font_family"
+ android:text="@string/about_you_text"
+ android:textSize="?attr/font_18" />
+
+ <EditText
+ android:id="@+id/edit_text_about_you_edit_profile_activity"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:gravity="top"
+ android:hint="@string/about_you_hint"
+ android:importantForAutofill="no"
+ android:inputType="textCapSentences|textMultiLine"
+ android:lines="4"
+ android:maxLength="200"
+ android:maxLines="4"
+ android:paddingStart="16dp"
+ android:paddingEnd="16dp"
+ android:paddingBottom="16dp" />
+
+ </LinearLayout>
+
+ </LinearLayout>
+
+ </androidx.core.widget.NestedScrollView>
+
+</androidx.coordinatorlayout.widget.CoordinatorLayout> \ No newline at end of file
diff --git a/app/src/main/res/layout/activity_multireddit_selection.xml b/app/src/main/res/layout/activity_multireddit_selection.xml
index aec94a4f..0cfe6e8d 100644
--- a/app/src/main/res/layout/activity_multireddit_selection.xml
+++ b/app/src/main/res/layout/activity_multireddit_selection.xml
@@ -14,6 +14,7 @@
android:theme="@style/AppTheme.AppBarOverlay">
<com.google.android.material.appbar.CollapsingToolbarLayout
+ android:id="@+id/collapsing_toolbar_layout_multireddit_selection_activity"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|enterAlways"
diff --git a/app/src/main/res/layout/activity_rules.xml b/app/src/main/res/layout/activity_rules.xml
index 0cb088b2..38256a63 100644
--- a/app/src/main/res/layout/activity_rules.xml
+++ b/app/src/main/res/layout/activity_rules.xml
@@ -14,6 +14,7 @@
android:theme="@style/AppTheme.AppBarOverlay">
<com.google.android.material.appbar.CollapsingToolbarLayout
+ android:id="@+id/collapsing_toolbar_layout_rules_activity"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|enterAlways"
diff --git a/app/src/main/res/layout/activity_search_result.xml b/app/src/main/res/layout/activity_search_result.xml
index 58100f8d..6e293e2c 100644
--- a/app/src/main/res/layout/activity_search_result.xml
+++ b/app/src/main/res/layout/activity_search_result.xml
@@ -12,6 +12,7 @@
android:theme="@style/AppTheme.AppBarOverlay">
<com.google.android.material.appbar.CollapsingToolbarLayout
+ android:id="@+id/collapsing_toolbar_layout_search_result_activity"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|enterAlways"
diff --git a/app/src/main/res/layout/activity_selected_subreddits.xml b/app/src/main/res/layout/activity_selected_subreddits.xml
index 9482cba4..66dfa6f8 100644
--- a/app/src/main/res/layout/activity_selected_subreddits.xml
+++ b/app/src/main/res/layout/activity_selected_subreddits.xml
@@ -14,6 +14,7 @@
android:theme="@style/AppTheme.AppBarOverlay">
<com.google.android.material.appbar.CollapsingToolbarLayout
+ android:id="@+id/collapsing_toolbar_layout_selected_subreddits_and_users_activity"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|enterAlways"
diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml
index 339d4685..4ede004f 100644
--- a/app/src/main/res/layout/activity_settings.xml
+++ b/app/src/main/res/layout/activity_settings.xml
@@ -10,6 +10,7 @@
android:theme="@style/AppTheme.AppBarOverlay">
<com.google.android.material.appbar.CollapsingToolbarLayout
+ android:id="@+id/collapsing_toolbar_layout_settings_activity"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|enterAlways"
diff --git a/app/src/main/res/layout/activity_subreddit_selection.xml b/app/src/main/res/layout/activity_subreddit_selection.xml
index 8d027137..78bac0d3 100644
--- a/app/src/main/res/layout/activity_subreddit_selection.xml
+++ b/app/src/main/res/layout/activity_subreddit_selection.xml
@@ -14,6 +14,7 @@
android:theme="@style/AppTheme.AppBarOverlay">
<com.google.android.material.appbar.CollapsingToolbarLayout
+ android:id="@+id/collapsing_toolbar_layout_subreddit_selection_activity"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|enterAlways"
diff --git a/app/src/main/res/layout/activity_subscribed_subreddits_multiselection.xml b/app/src/main/res/layout/activity_subscribed_subreddits_multiselection.xml
index 506375e7..428047f4 100644
--- a/app/src/main/res/layout/activity_subscribed_subreddits_multiselection.xml
+++ b/app/src/main/res/layout/activity_subscribed_subreddits_multiselection.xml
@@ -14,6 +14,7 @@
android:theme="@style/AppTheme.AppBarOverlay">
<com.google.android.material.appbar.CollapsingToolbarLayout
+ android:id="@+id/collapsing_toolbar_layout_subscribed_subreddits_multiselection_activity"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|enterAlways"
diff --git a/app/src/main/res/layout/activity_subscribed_thing_listing.xml b/app/src/main/res/layout/activity_subscribed_thing_listing.xml
index 109d3f74..10037a07 100644
--- a/app/src/main/res/layout/activity_subscribed_thing_listing.xml
+++ b/app/src/main/res/layout/activity_subscribed_thing_listing.xml
@@ -14,6 +14,7 @@
android:theme="@style/AppTheme.AppBarOverlay">
<com.google.android.material.appbar.CollapsingToolbarLayout
+ android:id="@+id/collapsing_toolbar_layout_subscribed_thing_listing_activity"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|enterAlways"
diff --git a/app/src/main/res/layout/activity_view_post_detail.xml b/app/src/main/res/layout/activity_view_post_detail.xml
index da98158d..3746f5c6 100644
--- a/app/src/main/res/layout/activity_view_post_detail.xml
+++ b/app/src/main/res/layout/activity_view_post_detail.xml
@@ -14,6 +14,7 @@
android:theme="@style/AppTheme.AppBarOverlay">
<com.google.android.material.appbar.CollapsingToolbarLayout
+ android:id="@+id/collapsing_toolbar_layout_view_post_detail_activity"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|enterAlways"
@@ -53,7 +54,8 @@
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:visibility="gone"
- app:cardElevation="16dp">
+ app:cardElevation="16dp"
+ style="?attr/materialCardViewElevatedStyle">
<LinearLayout
android:layout_width="match_parent"
diff --git a/app/src/main/res/layout/activity_view_subreddit_detail.xml b/app/src/main/res/layout/activity_view_subreddit_detail.xml
index bdb46784..6709af9f 100644
--- a/app/src/main/res/layout/activity_view_subreddit_detail.xml
+++ b/app/src/main/res/layout/activity_view_subreddit_detail.xml
@@ -140,7 +140,7 @@
</RelativeLayout>
- <androidx.appcompat.widget.Toolbar
+ <com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
diff --git a/app/src/main/res/layout/activity_view_user_detail.xml b/app/src/main/res/layout/activity_view_user_detail.xml
index 3d5501da..c312e808 100644
--- a/app/src/main/res/layout/activity_view_user_detail.xml
+++ b/app/src/main/res/layout/activity_view_user_detail.xml
@@ -5,7 +5,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/coordinator_layout_view_user_detail_activity"
- tools:application=".ViewUserDetailActivity">
+ tools:application="ml.docilealligator.infinityforreddit.activities.ViewUserDetailActivity">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appbar_layout_view_user_detail"
@@ -107,15 +107,15 @@
</RelativeLayout>
- <androidx.appcompat.widget.Toolbar
+ <com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar_view_user_detail_activity"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
app:layout_collapseMode="pin"
- app:layout_scrollFlags="scroll|enterAlways|enterAlwaysCollapsed"
+ app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/AppTheme.PopupOverlay"
- app:navigationIcon="?attr/homeAsUpIndicator"/>
+ app:navigationIcon="?attr/homeAsUpIndicator" />
</com.google.android.material.appbar.CollapsingToolbarLayout>
diff --git a/app/src/main/res/layout/activity_view_video.xml b/app/src/main/res/layout/activity_view_video.xml
index bd314ccc..cd98291d 100644
--- a/app/src/main/res/layout/activity_view_video.xml
+++ b/app/src/main/res/layout/activity_view_video.xml
@@ -6,6 +6,7 @@
android:id="@+id/hauler_view_view_video_activity"
android:layout_width="match_parent"
android:layout_height="match_parent"
+ android:background="#000000"
android:keepScreenOn="true"
app:dragUpEnabled="true"
tools:application="ml.docilealligator.infinityforreddit.activities.ViewVideoActivity">
diff --git a/app/src/main/res/layout/activity_wiki.xml b/app/src/main/res/layout/activity_wiki.xml
index c8f49864..ead5eedd 100644
--- a/app/src/main/res/layout/activity_wiki.xml
+++ b/app/src/main/res/layout/activity_wiki.xml
@@ -14,6 +14,7 @@
android:theme="@style/AppTheme.AppBarOverlay">
<com.google.android.material.appbar.CollapsingToolbarLayout
+ android:id="@+id/collapsing_toolbar_layout_wiki_activity"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|enterAlways"
diff --git a/app/src/main/res/layout/app_bar_main.xml b/app/src/main/res/layout/app_bar_main.xml
index 9aef7ff3..fe3656be 100644
--- a/app/src/main/res/layout/app_bar_main.xml
+++ b/app/src/main/res/layout/app_bar_main.xml
@@ -21,7 +21,7 @@
app:titleEnabled="false"
app:toolbarId="@+id/toolbar">
- <androidx.appcompat.widget.Toolbar
+ <com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
diff --git a/app/src/main/res/layout/fragment_theme_preview_posts.xml b/app/src/main/res/layout/fragment_theme_preview_posts.xml
index aaf14a30..8c0169cf 100644
--- a/app/src/main/res/layout/fragment_theme_preview_posts.xml
+++ b/app/src/main/res/layout/fragment_theme_preview_posts.xml
@@ -11,7 +11,8 @@
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
app:cardCornerRadius="16dp"
- app:cardElevation="2dp">
+ app:cardElevation="2dp"
+ style="?attr/materialCardViewElevatedStyle">
<LinearLayout
android:layout_width="match_parent"
diff --git a/app/src/main/res/layout/item_post_card_2_video_autoplay.xml b/app/src/main/res/layout/item_post_card_2_video_autoplay.xml
index 1846c3df..ef8794ce 100644
--- a/app/src/main/res/layout/item_post_card_2_video_autoplay.xml
+++ b/app/src/main/res/layout/item_post_card_2_video_autoplay.xml
@@ -16,7 +16,8 @@
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
app:cardElevation="2dp"
- app:cardCornerRadius="8dp">
+ app:cardCornerRadius="8dp"
+ style="?attr/materialCardViewElevatedStyle">
<com.google.android.exoplayer2.ui.AspectRatioFrameLayout
android:id="@+id/aspect_ratio_frame_layout_item_post_card_2_video_autoplay"
diff --git a/app/src/main/res/layout/item_post_card_2_video_autoplay_legacy_controller.xml b/app/src/main/res/layout/item_post_card_2_video_autoplay_legacy_controller.xml
index 81030a91..4f5dc4f2 100644
--- a/app/src/main/res/layout/item_post_card_2_video_autoplay_legacy_controller.xml
+++ b/app/src/main/res/layout/item_post_card_2_video_autoplay_legacy_controller.xml
@@ -16,7 +16,8 @@
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
app:cardElevation="2dp"
- app:cardCornerRadius="8dp">
+ app:cardCornerRadius="8dp"
+ style="?attr/materialCardViewElevatedStyle">
<com.google.android.exoplayer2.ui.AspectRatioFrameLayout
android:id="@+id/aspect_ratio_frame_layout_item_post_card_2_video_autoplay"
diff --git a/app/src/main/res/layout/item_post_card_2_with_preview.xml b/app/src/main/res/layout/item_post_card_2_with_preview.xml
index 0accab55..298e77ce 100644
--- a/app/src/main/res/layout/item_post_card_2_with_preview.xml
+++ b/app/src/main/res/layout/item_post_card_2_with_preview.xml
@@ -16,7 +16,8 @@
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
app:cardElevation="2dp"
- app:cardCornerRadius="8dp">
+ app:cardCornerRadius="8dp"
+ style="?attr/materialCardViewElevatedStyle">
<ml.docilealligator.infinityforreddit.customviews.AspectRatioGifImageView
android:id="@+id/image_view_item_post_card_2_with_preview"
@@ -42,25 +43,18 @@
android:layout_height="wrap_content"
android:layout_gravity="center" />
- <RelativeLayout
- android:id="@+id/load_image_error_relative_layout_item_post_card_2_with_preview"
+ <TextView
+ android:id="@+id/load_image_error_text_view_item_post_card_2_with_preview"
android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:visibility="gone">
-
- <TextView
- android:id="@+id/load_image_error_text_view_item_post_card_2_with_preview"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:drawableTop="@drawable/ic_error_outline_black_24dp"
- android:layout_centerInParent="true"
- android:paddingStart="16dp"
- android:paddingEnd="16dp"
- android:text="@string/error_loading_image_tap_to_retry"
- android:textSize="?attr/font_default"
- android:fontFamily="?attr/font_family" />
-
- </RelativeLayout>
+ android:layout_height="wrap_content"
+ android:drawableTop="@drawable/ic_error_outline_black_24dp"
+ android:layout_gravity="center"
+ android:paddingStart="16dp"
+ android:paddingEnd="16dp"
+ android:text="@string/error_loading_image_tap_to_retry"
+ android:textSize="?attr/font_default"
+ android:fontFamily="?attr/font_family"
+ android:visibility="gone" />
<ImageView
android:id="@+id/image_view_no_preview_gallery_item_post_card_2_with_preview"
diff --git a/app/src/main/res/layout/item_post_gallery.xml b/app/src/main/res/layout/item_post_gallery.xml
index 19a2e418..128b65dc 100644
--- a/app/src/main/res/layout/item_post_gallery.xml
+++ b/app/src/main/res/layout/item_post_gallery.xml
@@ -7,7 +7,8 @@
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
app:cardElevation="2dp"
- app:cardCornerRadius="8dp">
+ app:cardCornerRadius="8dp"
+ style="?attr/materialCardViewElevatedStyle">
<ProgressBar
android:id="@+id/progress_bar_item_post_gallery"
@@ -40,26 +41,19 @@
android:background="@drawable/play_button_round_background"
android:visibility="gone" />
- <RelativeLayout
- android:id="@+id/load_image_error_relative_layout_item_post_gallery"
+ <TextView
+ android:id="@+id/load_image_error_text_view_item_gallery"
android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:visibility="gone"
- tools:visibility="visible">
-
- <TextView
- android:id="@+id/load_image_error_text_view_item_gallery"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:paddingStart="16dp"
- android:paddingEnd="16dp"
- app:drawableTopCompat="@drawable/ic_error_outline_black_24dp"
- android:layout_centerInParent="true"
- android:text="@string/error_loading_image_tap_to_retry"
- android:textSize="?attr/font_default"
- android:fontFamily="?attr/font_family" />
-
- </RelativeLayout>
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:paddingStart="16dp"
+ android:paddingEnd="16dp"
+ app:drawableTopCompat="@drawable/ic_error_outline_black_24dp"
+ android:layout_centerInParent="true"
+ android:text="@string/error_loading_image_tap_to_retry"
+ android:textSize="?attr/font_default"
+ android:fontFamily="?attr/font_family"
+ android:visibility="gone" />
<TextView
android:id="@+id/title_text_view_item_post_gallery"
diff --git a/app/src/main/res/layout/item_post_text.xml b/app/src/main/res/layout/item_post_text.xml
index cd9eb21b..b2b979b1 100644
--- a/app/src/main/res/layout/item_post_text.xml
+++ b/app/src/main/res/layout/item_post_text.xml
@@ -7,7 +7,8 @@
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
app:cardElevation="2dp"
- app:cardCornerRadius="16dp">
+ app:cardCornerRadius="16dp"
+ style="?attr/materialCardViewElevatedStyle">
<LinearLayout
android:layout_width="match_parent"
diff --git a/app/src/main/res/layout/item_post_video_type_autoplay.xml b/app/src/main/res/layout/item_post_video_type_autoplay.xml
index 33bdf97f..5afde9c1 100644
--- a/app/src/main/res/layout/item_post_video_type_autoplay.xml
+++ b/app/src/main/res/layout/item_post_video_type_autoplay.xml
@@ -7,7 +7,8 @@
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
app:cardElevation="2dp"
- app:cardCornerRadius="16dp">
+ app:cardCornerRadius="16dp"
+ style="?attr/materialCardViewElevatedStyle">
<LinearLayout
android:layout_width="match_parent"
diff --git a/app/src/main/res/layout/item_post_video_type_autoplay_legacy_controller.xml b/app/src/main/res/layout/item_post_video_type_autoplay_legacy_controller.xml
index bb3a07e2..b8f4a27c 100644
--- a/app/src/main/res/layout/item_post_video_type_autoplay_legacy_controller.xml
+++ b/app/src/main/res/layout/item_post_video_type_autoplay_legacy_controller.xml
@@ -7,7 +7,8 @@
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
app:cardElevation="2dp"
- app:cardCornerRadius="16dp">
+ app:cardCornerRadius="16dp"
+ style="?attr/materialCardViewElevatedStyle">
<LinearLayout
android:layout_width="match_parent"
diff --git a/app/src/main/res/layout/item_post_with_preview.xml b/app/src/main/res/layout/item_post_with_preview.xml
index b3ef0a9b..91014578 100644
--- a/app/src/main/res/layout/item_post_with_preview.xml
+++ b/app/src/main/res/layout/item_post_with_preview.xml
@@ -7,7 +7,8 @@
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
app:cardElevation="2dp"
- app:cardCornerRadius="16dp">
+ app:cardCornerRadius="16dp"
+ style="?attr/materialCardViewElevatedStyle">
<LinearLayout
android:layout_width="match_parent"
@@ -113,10 +114,9 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="4dp"
- android:text="@string/gallery"
android:textSize="?attr/font_12"
android:fontFamily="?attr/font_family"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -130,7 +130,7 @@
android:fontFamily="?attr/font_family"
android:padding="4dp"
android:visibility="gone"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -143,7 +143,7 @@
android:textSize="?attr/font_12"
android:fontFamily="?attr/font_family"
android:visibility="gone"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -156,7 +156,7 @@
android:fontFamily="?attr/font_family"
android:padding="4dp"
android:visibility="gone"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -168,7 +168,7 @@
android:textSize="?attr/font_12"
android:fontFamily="?attr/font_family"
android:visibility="gone"
- app:lib_setRadius="3dp"
+ app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
@@ -206,7 +206,7 @@
android:fontFamily="?attr/font_family"
android:visibility="gone" />
- <RelativeLayout
+ <FrameLayout
android:id="@+id/image_wrapper_relative_layout_item_post_with_preview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@@ -224,7 +224,6 @@
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_margin="16dp"
- android:layout_gravity="start"
android:scaleType="center"
android:background="@drawable/play_button_round_background"
android:visibility="gone" />
@@ -233,29 +232,21 @@
android:id="@+id/progress_bar_item_post_with_preview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_centerInParent="true" />
+ android:layout_gravity="center" />
- <RelativeLayout
- android:id="@+id/load_image_error_relative_layout_item_post_with_preview"
+ <TextView
+ android:id="@+id/load_image_error_text_view_item_post_with_preview"
android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_centerInParent="true"
- android:visibility="gone">
-
- <TextView
- android:id="@+id/load_image_error_text_view_item_post_with_preview"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:drawableTop="@drawable/ic_error_outline_black_24dp"
- android:layout_gravity="center"
- android:gravity="center"
- android:text="@string/error_loading_image_tap_to_retry"
- android:textSize="?attr/font_default"
- android:fontFamily="?attr/font_family" />
-
- </RelativeLayout>
-
- </RelativeLayout>
+ android:layout_height="wrap_content"
+ android:drawableTop="@drawable/ic_error_outline_black_24dp"
+ android:layout_gravity="center"
+ android:gravity="center"
+ android:text="@string/error_loading_image_tap_to_retry"
+ android:textSize="?attr/font_default"
+ android:fontFamily="?attr/font_family"
+ android:visibility="gone" />
+
+ </FrameLayout>
<ImageView
android:id="@+id/image_view_no_preview_gallery_item_post_with_preview"
diff --git a/app/src/main/res/layout/item_trending_search.xml b/app/src/main/res/layout/item_trending_search.xml
index d1cdbded..8a14922a 100644
--- a/app/src/main/res/layout/item_trending_search.xml
+++ b/app/src/main/res/layout/item_trending_search.xml
@@ -8,7 +8,8 @@
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
app:cardCornerRadius="16dp"
- app:cardElevation="2dp">
+ app:cardElevation="2dp"
+ style="?attr/materialCardViewElevatedStyle">
<RelativeLayout
android:id="@+id/image_wrapper_relative_layout_item_trending_search"
diff --git a/app/src/main/res/menu/edit_profile_activity.xml b/app/src/main/res/menu/edit_profile_activity.xml
new file mode 100644
index 00000000..fe96ba20
--- /dev/null
+++ b/app/src/main/res/menu/edit_profile_activity.xml
@@ -0,0 +1,11 @@
+<menu xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:tools="http://schemas.android.com/tools"
+ tools:application="ml.docilealligator.infinityforreddit.activities.EditProfileActivity">
+ <item
+ android:id="@+id/action_save_edit_profile_activity"
+ android:orderInCategory="1"
+ android:title="@string/action_save"
+ android:icon="@drawable/ic_save_to_database_24dp"
+ app:showAsAction="ifRoom" />
+</menu> \ No newline at end of file
diff --git a/app/src/main/res/menu/view_user_detail_activity.xml b/app/src/main/res/menu/view_user_detail_activity.xml
index 437c6e23..ec9128e4 100644
--- a/app/src/main/res/menu/view_user_detail_activity.xml
+++ b/app/src/main/res/menu/view_user_detail_activity.xml
@@ -59,4 +59,9 @@
android:id="@+id/action_block_user_view_user_detail_activity"
android:orderInCategory="10"
android:title="@string/action_block_user" />
+
+ <item
+ android:id="@+id/action_edit_profile_view_user_detail_activity"
+ android:orderInCategory="11"
+ android:title="@string/action_edit_profile" />
</menu>
diff --git a/app/src/main/res/values-land-v28/styles.xml b/app/src/main/res/values-land-v28/styles.xml
index 037bf7e3..c3e82635 100644
--- a/app/src/main/res/values-land-v28/styles.xml
+++ b/app/src/main/res/values-land-v28/styles.xml
@@ -1,6 +1,6 @@
<resources>
- <style name="AppTheme" parent="Theme.MaterialComponents.DayNight">
+ <style name="AppTheme" parent="Theme.Material3.DayNight">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
diff --git a/app/src/main/res/values-v28/styles.xml b/app/src/main/res/values-v28/styles.xml
index 80d2dd21..272e1ebf 100644
--- a/app/src/main/res/values-v28/styles.xml
+++ b/app/src/main/res/values-v28/styles.xml
@@ -1,7 +1,7 @@
<resources>
<!-- Base application theme. -->
- <style name="AppTheme" parent="Theme.MaterialComponents.DayNight">
+ <style name="AppTheme" parent="Theme.Material3.DayNight">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 6a5890c7..3b8753e8 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -1215,4 +1215,29 @@
<string name="app_lock_timeout_12_hours">12 hours</string>
<string name="app_lock_timeout_24_hours">24 hours</string>
+ <!--EditProfileService Notification-->
+ <string name="submit_change_avatar">Submit Change Avatar</string>
+ <string name="submit_change_banner">Submit Change Banner</string>
+ <string name="submit_save_profile">Submit Save Profile</string>
+
+ <!--EditProfileActivity-->
+ <string name="action_edit_profile">Edit Profile</string>
+ <string name="remove_avatar">Remove Avatar</string>
+ <string name="remove_banner">Remove Banner</string>
+ <string name="display_name_text">Display Name</string>
+ <string name="display_name_hint">Show on your profile page</string>
+ <string name="display_name_description">This will be displayed to viewer of your profile page and does not change your username</string>
+ <string name="about_you_text">About You</string>
+ <string name="about_you_hint">A little description of your self</string>
+ <string name="message_remove_avatar_success">Success remove Avatar</string>
+ <string name="message_remove_avatar_failed_fmt">Failed remove Avatar %s</string>
+ <string name="message_remove_banner_success">Success remove Banner</string>
+ <string name="message_remove_banner_failed_fmt">Failed remove Banner %s</string>
+ <string name="message_change_avatar_success">Success changing Avatar</string>
+ <string name="message_change_avatar_failed_fmt">Failed changing Avatar %s</string>
+ <string name="message_change_banner_success">Success changing Banner</string>
+ <string name="message_change_banner_failed_fmt">Failed changing Banner %s</string>
+ <string name="message_save_profile_success">Success save profile</string>
+ <string name="message_save_profile_failed_fmt">Failed save profile %s</string>
+
</resources>
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
index 350b0f29..9fdc6369 100644
--- a/app/src/main/res/values/styles.xml
+++ b/app/src/main/res/values/styles.xml
@@ -1,7 +1,7 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
- <style name="AppTheme" parent="Theme.MaterialComponents.DayNight">
+ <style name="AppTheme" parent="Theme.Material3.DayNight">
<item name="colorPrimary">?attr/colorPrimary</item>
<item name="colorPrimaryDark">?attr/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
@@ -58,7 +58,7 @@
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.DayNight" />
- <style name="MaterialAlertDialogTheme" parent="ThemeOverlay.MaterialComponents.MaterialAlertDialog">
+ <style name="MaterialAlertDialogTheme" parent="ThemeOverlay.Material3.MaterialAlertDialog">
<item name="android:textSize">?attr/font_default</item>
<item name="android:background">?attr/cardViewBackgroundColor</item>
<item name="materialAlertDialogTitleTextStyle">@style/MaterialAlertDialogTitleTextStyle
@@ -78,15 +78,15 @@
</item>
</style>
- <style name="MaterialAlertDialogPositiveButtonStyle" parent="Widget.MaterialComponents.Button.TextButton.Dialog">
+ <style name="MaterialAlertDialogPositiveButtonStyle" parent="Widget.Material3.Button.TextButton.Dialog">
<item name="android:textColor">@color/colorAccent</item>
</style>
- <style name="MaterialAlertDialogNegativeButtonStyle" parent="Widget.MaterialComponents.Button.TextButton.Dialog">
+ <style name="MaterialAlertDialogNegativeButtonStyle" parent="Widget.Material3.Button.TextButton.Dialog">
<item name="android:textColor">?attr/primaryTextColor</item>
</style>
- <style name="MaterialAlertDialogTitleTextStyle" parent="MaterialAlertDialog.MaterialComponents.Title.Text">
+ <style name="MaterialAlertDialogTitleTextStyle" parent="MaterialAlertDialog.Material3.Title.Text">
<item name="android:textSize">?attr/font_20</item>
</style>