From 2f15383718c72246581b1f70cb61ffb9bd12e6db Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Sat, 14 Sep 2019 11:11:39 +0800 Subject: Fix status bar and navbar icon color in MainActivity. --- .../infinityforreddit/MainActivity.java | 34 ++++++++++++++++++++++ .../ic_outline_check_circle_outline_white_24px.xml | 9 ++++++ app/src/main/res/menu/main_activity.xml | 20 +++++++++---- app/src/main/res/values/strings.xml | 1 + 4 files changed, 58 insertions(+), 6 deletions(-) create mode 100644 app/src/main/res/drawable/ic_outline_check_circle_outline_white_24px.xml (limited to 'app/src') 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()); diff --git a/app/src/main/res/drawable/ic_outline_check_circle_outline_white_24px.xml b/app/src/main/res/drawable/ic_outline_check_circle_outline_white_24px.xml new file mode 100644 index 00000000..191a8e4c --- /dev/null +++ b/app/src/main/res/drawable/ic_outline_check_circle_outline_white_24px.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/menu/main_activity.xml b/app/src/main/res/menu/main_activity.xml index 3ab9d924..e69f976b 100644 --- a/app/src/main/res/menu/main_activity.xml +++ b/app/src/main/res/menu/main_activity.xml @@ -4,11 +4,12 @@ xmlns:tools="http://schemas.android.com/tools" tools:application="ml.docilealligator.infinityforreddit.MainActivity"> + android:title="@string/action_subscriptions" + android:icon="@drawable/ic_outline_check_circle_outline_white_24px" + app:showAsAction="ifRoom" + android:visible="false"/> + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index afd0cc44..a029821d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -30,6 +30,7 @@ Stop Lazy Mode Send Sort + Subscriptions Hide Post Unhide Post Edit Post -- cgit v1.2.3