diff options
author | Alex Ning <chineseperson5@gmail.com> | 2019-09-14 03:11:39 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2019-09-14 03:11:39 +0000 |
commit | 2f15383718c72246581b1f70cb61ffb9bd12e6db (patch) | |
tree | 69b272463d62cb6c1a767574e13da3e0940a9154 /app/src/main/java | |
parent | 6f24ac8cf5731e6e13ad767e6639ca2d67611985 (diff) | |
download | infinity-for-reddit-2f15383718c72246581b1f70cb61ffb9bd12e6db.tar infinity-for-reddit-2f15383718c72246581b1f70cb61ffb9bd12e6db.tar.gz infinity-for-reddit-2f15383718c72246581b1f70cb61ffb9bd12e6db.tar.bz2 infinity-for-reddit-2f15383718c72246581b1f70cb61ffb9bd12e6db.tar.lz infinity-for-reddit-2f15383718c72246581b1f70cb61ffb9bd12e6db.tar.xz infinity-for-reddit-2f15383718c72246581b1f70cb61ffb9bd12e6db.tar.zst infinity-for-reddit-2f15383718c72246581b1f70cb61ffb9bd12e6db.zip |
Fix status bar and navbar icon color in MainActivity.
Diffstat (limited to 'app/src/main/java')
-rw-r--r-- | app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java index dc1bbb99..e62b164d 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java @@ -168,6 +168,8 @@ public class MainActivity extends AppCompatActivity implements SortTypeBottomShe EventBus.getDefault().register(this); + getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) { Resources resources = getResources(); @@ -299,12 +301,20 @@ public class MainActivity extends AppCompatActivity implements SortTypeBottomShe mNewAccountName = null; if(newAccount == null) { mNullAccessToken = true; + + if(mMenu != null) { + mMenu.findItem(R.id.action_subscriptions_main_activity).setVisible(false); + } } else { mAccessToken = newAccount.getAccessToken(); mAccountName = newAccount.getUsername(); mProfileImageUrl = newAccount.getProfileImageUrl(); mBannerImageUrl = newAccount.getBannerImageUrl(); mKarma = newAccount.getKarma(); + + if(mMenu != null) { + mMenu.findItem(R.id.action_subscriptions_main_activity).setVisible(true); + } } if(enableNotification) { @@ -333,6 +343,10 @@ public class MainActivity extends AppCompatActivity implements SortTypeBottomShe mBannerImageUrl = account.getBannerImageUrl(); mKarma = account.getKarma(); + if(mMenu != null) { + mMenu.findItem(R.id.action_subscriptions_main_activity).setVisible(true); + } + if(enableNotification) { Constraints constraints = new Constraints.Builder() .setRequiredNetworkType(NetworkType.CONNECTED) @@ -355,12 +369,20 @@ public class MainActivity extends AppCompatActivity implements SortTypeBottomShe } else { if(account == null) { mNullAccessToken = true; + + if(mMenu != null) { + mMenu.findItem(R.id.action_subscriptions_main_activity).setVisible(false); + } } else { mAccessToken = account.getAccessToken(); mAccountName = account.getUsername(); mProfileImageUrl = account.getProfileImageUrl(); mBannerImageUrl = account.getBannerImageUrl(); mKarma = account.getKarma(); + + if(mMenu != null) { + mMenu.findItem(R.id.action_subscriptions_main_activity).setVisible(true); + } } if(enableNotification) { @@ -679,6 +701,14 @@ public class MainActivity extends AppCompatActivity implements SortTypeBottomShe getMenuInflater().inflate(R.menu.main_activity, menu); mMenu = menu; MenuItem lazyModeItem = mMenu.findItem(R.id.action_lazy_mode_main_activity); + MenuItem subscriptionsItem = mMenu.findItem(R.id.action_subscriptions_main_activity); + + if(mAccessToken != null) { + subscriptionsItem.setVisible(true); + } else { + subscriptionsItem.setVisible(false); + } + if(isInLazyMode) { lazyModeItem.setTitle(R.string.action_stop_lazy_mode); params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_NO_SCROLL); @@ -695,6 +725,10 @@ public class MainActivity extends AppCompatActivity implements SortTypeBottomShe @Override public boolean onOptionsItemSelected(@NonNull MenuItem item) { switch (item.getItemId()) { + case R.id.action_subscriptions_main_activity: + Intent subscriptionsIntent = new Intent(this, SubscribedThingListingActivity.class); + startActivity(subscriptionsIntent); + return true; case R.id.action_sort_main_activity: if(viewPager.getCurrentItem() == 1 ||viewPager.getCurrentItem() == 2) { popularAndAllSortTypeBottomSheetFragment.show(getSupportFragmentManager(), popularAndAllSortTypeBottomSheetFragment.getTag()); |