diff options
author | Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> | 2022-07-28 13:42:46 +0000 |
---|---|---|
committer | Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> | 2022-07-28 13:42:46 +0000 |
commit | 9614f4a67afc10b9a003dc345f1176d92c5b64fd (patch) | |
tree | e14cb70f70048e23f87fd8b82e7b2c4b9aa03729 /app/src/main/java/ml | |
parent | 318240e271ee9be0c4ec119aa72d25cb777287df (diff) | |
download | infinity-for-reddit-9614f4a67afc10b9a003dc345f1176d92c5b64fd.tar infinity-for-reddit-9614f4a67afc10b9a003dc345f1176d92c5b64fd.tar.gz infinity-for-reddit-9614f4a67afc10b9a003dc345f1176d92c5b64fd.tar.bz2 infinity-for-reddit-9614f4a67afc10b9a003dc345f1176d92c5b64fd.tar.lz infinity-for-reddit-9614f4a67afc10b9a003dc345f1176d92c5b64fd.tar.xz infinity-for-reddit-9614f4a67afc10b9a003dc345f1176d92c5b64fd.tar.zst infinity-for-reddit-9614f4a67afc10b9a003dc345f1176d92c5b64fd.zip |
Minor UI tweaks in ViewSubredditDetailActivity, ViewUserDetailActivity and CustomThemePreviewActivity.
Diffstat (limited to 'app/src/main/java/ml')
3 files changed, 23 insertions, 6 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomThemePreviewActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomThemePreviewActivity.java index db63b198..18da2dce 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomThemePreviewActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomThemePreviewActivity.java @@ -16,6 +16,7 @@ import android.util.TypedValue; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; +import android.view.ViewTreeObserver; import android.view.Window; import android.view.WindowManager; import android.widget.ImageView; @@ -80,6 +81,8 @@ public class CustomThemePreviewActivity extends AppCompatActivity implements Cus CollapsingToolbarLayout collapsingToolbarLayout; @BindView(R.id.toolbar_linear_layout_theme_preview_activity) LinearLayout linearLayout; + @BindView(R.id.extra_padding_view_theme_preview_activity) + View extraPaddingView; @BindView(R.id.subreddit_name_text_view_theme_preview_activity) TextView subredditNameTextView; @BindView(R.id.user_name_text_view_theme_preview_activity) @@ -239,6 +242,7 @@ public class CustomThemePreviewActivity extends AppCompatActivity implements Cus } else { window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); } + adjustToolbar(toolbar); Resources resources = getResources(); int navBarResourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android"); @@ -304,7 +308,6 @@ public class CustomThemePreviewActivity extends AppCompatActivity implements Cus }); } - adjustToolbar(toolbar); setSupportActionBar(toolbar); subscribeSubredditChip.setOnClickListener(view -> { @@ -335,6 +338,13 @@ public class CustomThemePreviewActivity extends AppCompatActivity implements Cus private void applyCustomTheme() { coordinatorLayout.setBackgroundColor(customTheme.backgroundColor); + appBarLayout.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { + @Override + public void onGlobalLayout() { + appBarLayout.getViewTreeObserver().removeOnGlobalLayoutListener(this); + collapsingToolbarLayout.setScrimVisibleHeightTrigger(toolbar.getHeight() + tabLayout.getHeight() + getStatusBarHeight() * 2); + } + }); collapsingToolbarLayout.setContentScrimColor(customTheme.colorPrimary); subscribeSubredditChip.setTextColor(customTheme.chipTextColor); subscribeSubredditChip.setChipBackgroundColor(ColorStateList.valueOf(customTheme.unsubscribed)); @@ -346,6 +356,7 @@ public class CustomThemePreviewActivity extends AppCompatActivity implements Cus collapsedTabIndicatorColor = customTheme.tabLayoutWithCollapsedCollapsingToolbarTabIndicator; collapsedTabBackgroundColor = customTheme.tabLayoutWithCollapsedCollapsingToolbarTabBackground; linearLayout.setBackgroundColor(customTheme.tabLayoutWithExpandedCollapsingToolbarTabBackground); + extraPaddingView.setBackgroundColor(customTheme.colorPrimary); subredditNameTextView.setTextColor(customTheme.subreddit); usernameTextView.setTextColor(customTheme.username); subscribeSubredditChip.setTextColor(customTheme.chipTextColor); @@ -370,6 +381,15 @@ public class CustomThemePreviewActivity extends AppCompatActivity implements Cus } } + private 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 applyAppBarLayoutAndToolbarTheme(AppBarLayout appBarLayout, Toolbar toolbar) { appBarLayout.setBackgroundColor(customTheme.colorPrimary); toolbar.setTitleTextColor(customTheme.toolbarPrimaryTextAndIconColor); 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 ad200202..48054ceb 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java @@ -236,7 +236,6 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp @Override protected void onCreate(Bundle savedInstanceState) { ((Infinity) getApplication()).getAppComponent().inject(this); - setTransparentStatusBarAfterToolbarCollapsed(); super.onCreate(savedInstanceState); @@ -268,6 +267,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp } else { window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); } + adjustToolbar(toolbar); int navBarHeight = getNavBarHeight(); if (navBarHeight > 0) { @@ -364,7 +364,6 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp subredditNameTextView.setText(title); toolbar.setTitle(title); - adjustToolbar(toolbar); setSupportActionBar(toolbar); setToolbarGoToTop(toolbar); @@ -537,7 +536,6 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp creationTimeTextView.setTextColor(primaryTextColor); descriptionTextView.setTextColor(primaryTextColor); navigationWrapper.applyCustomTheme(mCustomThemeWrapper.getBottomAppBarIconColor(), mCustomThemeWrapper.getBottomAppBarBackgroundColor()); - int bottomAppBarIconColor = mCustomThemeWrapper.getBottomAppBarIconColor(); applyTabLayoutTheme(tabLayout); applyFABTheme(navigationWrapper.floatingActionButton); if (typeface != null) { 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 ddf997c9..15b55477 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java @@ -286,8 +286,6 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele Resources resources = getResources(); - adjustToolbar(toolbar); - String title = "u/" + username; userNameTextView.setText(title); toolbar.setTitle(title); @@ -304,6 +302,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele } else { window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); } + adjustToolbar(toolbar); int navBarHeight = getNavBarHeight(); if (navBarHeight > 0) { |