aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2019-08-12 02:08:49 +0000
committerAlex Ning <chineseperson5@gmail.com>2019-08-12 02:08:49 +0000
commit1ce96509356c98f04377ac6aa94f54c8d51aa0d0 (patch)
treebf064dc3ae3a780711e725f2b83e694ae14caa75
parent4ca9b065516a6f6799aab6842d419e9f22f8dfa0 (diff)
downloadinfinity-for-reddit-1ce96509356c98f04377ac6aa94f54c8d51aa0d0.tar
infinity-for-reddit-1ce96509356c98f04377ac6aa94f54c8d51aa0d0.tar.gz
infinity-for-reddit-1ce96509356c98f04377ac6aa94f54c8d51aa0d0.tar.bz2
infinity-for-reddit-1ce96509356c98f04377ac6aa94f54c8d51aa0d0.tar.lz
infinity-for-reddit-1ce96509356c98f04377ac6aa94f54c8d51aa0d0.tar.xz
infinity-for-reddit-1ce96509356c98f04377ac6aa94f54c8d51aa0d0.tar.zst
infinity-for-reddit-1ce96509356c98f04377ac6aa94f54c8d51aa0d0.zip
Transparent nav bar in FilteredPostsActivity.
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/FilteredPostsActivity.java51
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedSubredditsListingFragment.java1
-rw-r--r--app/src/main/res/layout/activity_filtered_posts.xml20
3 files changed, 67 insertions, 5 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/FilteredPostsActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/FilteredPostsActivity.java
index 18d57300..0ee3a216 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/FilteredPostsActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/FilteredPostsActivity.java
@@ -1,14 +1,23 @@
package ml.docilealligator.infinityforreddit;
+import android.content.res.Configuration;
+import android.content.res.Resources;
+import android.os.Build;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.Window;
+import android.view.WindowManager;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.fragment.app.Fragment;
+import com.google.android.material.appbar.AppBarLayout;
+
import javax.inject.Inject;
import butterknife.BindView;
@@ -27,6 +36,7 @@ public class FilteredPostsActivity extends AppCompatActivity implements SortType
private static final String ACCESS_TOKEN_STATE = "ATS";
private static final String FRAGMENT_OUT_STATE = "FOS";
+ @BindView(R.id.appbar_layout_filtered_posts_activity) AppBarLayout appBarLayout;
@BindView(R.id.toolbar_filtered_posts_activity) Toolbar toolbar;
private boolean mNullAccessToken = false;
@@ -53,6 +63,47 @@ public class FilteredPostsActivity extends AppCompatActivity implements SortType
((Infinity) getApplication()).getAppComponent().inject(this);
+ Resources resources = getResources();
+
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1
+ && (resources.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT
+ || resources.getBoolean(R.bool.isTablet))) {
+ Window window = getWindow();
+ window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
+
+ boolean lightNavBar = false;
+ if((resources.getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) != Configuration.UI_MODE_NIGHT_YES) {
+ lightNavBar = true;
+ }
+ boolean finalLightNavBar = lightNavBar;
+
+ View decorView = window.getDecorView();
+ if(finalLightNavBar) {
+ decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR);
+ }
+ appBarLayout.addOnOffsetChangedListener(new AppBarStateChangeListener() {
+ @Override
+ void onStateChanged(AppBarLayout appBarLayout, State state) {
+ if (state == State.COLLAPSED) {
+ if(finalLightNavBar) {
+ decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR | View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR);
+ }
+ } else if (state == State.EXPANDED) {
+ if(finalLightNavBar) {
+ decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR);
+ }
+ }
+ }
+ });
+
+ int statusBarResourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
+ if (statusBarResourceId > 0) {
+ ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) toolbar.getLayoutParams();
+ params.topMargin = getResources().getDimensionPixelSize(statusBarResourceId);
+ toolbar.setLayoutParams(params);
+ }
+ }
+
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedSubredditsListingFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedSubredditsListingFragment.java
index 15da8748..d43eb602 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedSubredditsListingFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedSubredditsListingFragment.java
@@ -104,6 +104,7 @@ public class SubscribedSubredditsListingFragment extends Fragment {
} else {
mLinearLayout.setVisibility(View.GONE);
mRecyclerView.setVisibility(View.VISIBLE);
+ mGlide.clear(mImageView);
}
adapter.addUser(accountName, getArguments().getString(EXTRA_ACCOUNT_PROFILE_IMAGE_URL));
diff --git a/app/src/main/res/layout/activity_filtered_posts.xml b/app/src/main/res/layout/activity_filtered_posts.xml
index a7b605a7..b4065444 100644
--- a/app/src/main/res/layout/activity_filtered_posts.xml
+++ b/app/src/main/res/layout/activity_filtered_posts.xml
@@ -7,16 +7,26 @@
tools:application=".FilteredPostsActivity">
<com.google.android.material.appbar.AppBarLayout
+ android:id="@+id/appbar_layout_filtered_posts_activity"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
- <androidx.appcompat.widget.Toolbar
- android:id="@+id/toolbar_filtered_posts_activity"
+ <com.google.android.material.appbar.CollapsingToolbarLayout
android:layout_width="match_parent"
- android:layout_height="?attr/actionBarSize"
- app:popupTheme="@style/AppTheme.PopupOverlay"
- app:navigationIcon="?attr/homeAsUpIndicator" />
+ android:layout_height="match_parent"
+ app:layout_scrollFlags="scroll|enterAlways"
+ app:titleEnabled="false"
+ app:toolbarId="@+id/toolbar_filtered_posts_activity">
+
+ <androidx.appcompat.widget.Toolbar
+ android:id="@+id/toolbar_filtered_posts_activity"
+ android:layout_width="match_parent"
+ android:layout_height="?attr/actionBarSize"
+ app:popupTheme="@style/AppTheme.PopupOverlay"
+ app:navigationIcon="?attr/homeAsUpIndicator" />
+
+ </com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>