mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-11-10 12:47:26 +01:00
Transparent nav bar in FilteredPostsActivity.
This commit is contained in:
parent
4ca9b06551
commit
1ce9650935
@ -1,14 +1,23 @@
|
|||||||
package ml.docilealligator.infinityforreddit;
|
package ml.docilealligator.infinityforreddit;
|
||||||
|
|
||||||
|
import android.content.res.Configuration;
|
||||||
|
import android.content.res.Resources;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
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.annotation.NonNull;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import androidx.appcompat.widget.Toolbar;
|
import androidx.appcompat.widget.Toolbar;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
|
import com.google.android.material.appbar.AppBarLayout;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import butterknife.BindView;
|
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 ACCESS_TOKEN_STATE = "ATS";
|
||||||
private static final String FRAGMENT_OUT_STATE = "FOS";
|
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;
|
@BindView(R.id.toolbar_filtered_posts_activity) Toolbar toolbar;
|
||||||
|
|
||||||
private boolean mNullAccessToken = false;
|
private boolean mNullAccessToken = false;
|
||||||
@ -53,6 +63,47 @@ public class FilteredPostsActivity extends AppCompatActivity implements SortType
|
|||||||
|
|
||||||
((Infinity) getApplication()).getAppComponent().inject(this);
|
((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);
|
setSupportActionBar(toolbar);
|
||||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
|
|
||||||
|
@ -104,6 +104,7 @@ public class SubscribedSubredditsListingFragment extends Fragment {
|
|||||||
} else {
|
} else {
|
||||||
mLinearLayout.setVisibility(View.GONE);
|
mLinearLayout.setVisibility(View.GONE);
|
||||||
mRecyclerView.setVisibility(View.VISIBLE);
|
mRecyclerView.setVisibility(View.VISIBLE);
|
||||||
|
mGlide.clear(mImageView);
|
||||||
}
|
}
|
||||||
|
|
||||||
adapter.addUser(accountName, getArguments().getString(EXTRA_ACCOUNT_PROFILE_IMAGE_URL));
|
adapter.addUser(accountName, getArguments().getString(EXTRA_ACCOUNT_PROFILE_IMAGE_URL));
|
||||||
|
@ -7,16 +7,26 @@
|
|||||||
tools:application=".FilteredPostsActivity">
|
tools:application=".FilteredPostsActivity">
|
||||||
|
|
||||||
<com.google.android.material.appbar.AppBarLayout
|
<com.google.android.material.appbar.AppBarLayout
|
||||||
|
android:id="@+id/appbar_layout_filtered_posts_activity"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:theme="@style/AppTheme.AppBarOverlay">
|
android:theme="@style/AppTheme.AppBarOverlay">
|
||||||
|
|
||||||
<androidx.appcompat.widget.Toolbar
|
<com.google.android.material.appbar.CollapsingToolbarLayout
|
||||||
android:id="@+id/toolbar_filtered_posts_activity"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="?attr/actionBarSize"
|
android:layout_height="match_parent"
|
||||||
app:popupTheme="@style/AppTheme.PopupOverlay"
|
app:layout_scrollFlags="scroll|enterAlways"
|
||||||
app:navigationIcon="?attr/homeAsUpIndicator" />
|
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>
|
</com.google.android.material.appbar.AppBarLayout>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user