aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2020-03-01 09:15:05 +0000
committerAlex Ning <chineseperson5@gmail.com>2020-03-01 09:15:05 +0000
commitb1fe0510232a31cefe0aeb1c17e4d369571cf797 (patch)
tree300373b31d6110f8773d09a4baf275aba5f5f4f2
parent192d64f6bcd1d606c7474af43ebd5073f76fbb7f (diff)
downloadinfinity-for-reddit-b1fe0510232a31cefe0aeb1c17e4d369571cf797.tar
infinity-for-reddit-b1fe0510232a31cefe0aeb1c17e4d369571cf797.tar.gz
infinity-for-reddit-b1fe0510232a31cefe0aeb1c17e4d369571cf797.tar.bz2
infinity-for-reddit-b1fe0510232a31cefe0aeb1c17e4d369571cf797.tar.lz
infinity-for-reddit-b1fe0510232a31cefe0aeb1c17e4d369571cf797.tar.xz
infinity-for-reddit-b1fe0510232a31cefe0aeb1c17e4d369571cf797.tar.zst
infinity-for-reddit-b1fe0510232a31cefe0aeb1c17e4d369571cf797.zip
Still prepare to support multiple themes.
Diffstat (limited to '')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/BaseActivity.java7
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/CommentsListingFragment.java14
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/FollowedUsersListingFragment.java18
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java16
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SubredditListingFragment.java14
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SubscribedSubredditsListingFragment.java18
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/UserListingFragment.java14
7 files changed, 58 insertions, 43 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/BaseActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/BaseActivity.java
index 1565a42e..863322ce 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/BaseActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/BaseActivity.java
@@ -121,9 +121,6 @@ public abstract class BaseActivity extends AppCompatActivity {
public abstract SharedPreferences getSharedPreferences();
- protected boolean isLightStatusbar() {
- return lightStatusbar;
- }
protected boolean isChangeStatusBarIconColor() {
return changeStatusBarIconColor;
}
@@ -136,7 +133,7 @@ public abstract class BaseActivity extends AppCompatActivity {
return systemVisibilityToolbarCollapsed;
}
- protected boolean isImmersiveInterface() {
+ public boolean isImmersiveInterface() {
return immersiveInterface;
}
@@ -163,7 +160,7 @@ public abstract class BaseActivity extends AppCompatActivity {
});
}
- protected int getNavBarHeight() {
+ public int getNavBarHeight() {
Resources resources = getResources();
int navBarResourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
if (navBarResourceId > 0) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/CommentsListingFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/CommentsListingFragment.java
index cbef91ab..ee3cc947 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/CommentsListingFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/CommentsListingFragment.java
@@ -31,6 +31,7 @@ import javax.inject.Named;
import butterknife.BindView;
import butterknife.ButterKnife;
+import ml.docilealligator.infinityforreddit.Activity.BaseActivity;
import ml.docilealligator.infinityforreddit.Adapter.CommentsListingRecyclerViewAdapter;
import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask;
import ml.docilealligator.infinityforreddit.CommentViewModel;
@@ -108,12 +109,13 @@ public class CommentsListingFragment extends Fragment implements FragmentCommuni
Resources resources = getResources();
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
- if (resources.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT || resources.getBoolean(R.bool.isTablet)) {
- int navBarResourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
- if (navBarResourceId > 0) {
- mCommentRecyclerView.setPadding(0, 0, 0, resources.getDimensionPixelSize(navBarResourceId));
- }
+ if ((mActivity instanceof BaseActivity && ((BaseActivity) mActivity).isImmersiveInterface())) {
+ mCommentRecyclerView.setPadding(0, 0, 0, ((BaseActivity) mActivity).getNavBarHeight());
+ } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
+ && mSharedPreferences.getBoolean(SharedPreferencesUtils.IMMERSIVE_INTERFACE_KEY, true)) {
+ int navBarResourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
+ if (navBarResourceId > 0) {
+ mCommentRecyclerView.setPadding(0, 0, 0, resources.getDimensionPixelSize(navBarResourceId));
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/FollowedUsersListingFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/FollowedUsersListingFragment.java
index e3ec8f91..2bd84344 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/FollowedUsersListingFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/FollowedUsersListingFragment.java
@@ -2,6 +2,7 @@ package ml.docilealligator.infinityforreddit.Fragment;
import android.app.Activity;
+import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Build;
@@ -26,6 +27,7 @@ import javax.inject.Named;
import butterknife.BindView;
import butterknife.ButterKnife;
+import ml.docilealligator.infinityforreddit.Activity.BaseActivity;
import ml.docilealligator.infinityforreddit.Activity.SubscribedThingListingActivity;
import ml.docilealligator.infinityforreddit.Adapter.FollowedUsersRecyclerViewAdapter;
import ml.docilealligator.infinityforreddit.FragmentCommunicator;
@@ -33,6 +35,7 @@ import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.SubscribedUserDatabase.SubscribedUserViewModel;
+import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.Utils.Utils;
import retrofit2.Retrofit;
@@ -57,6 +60,8 @@ public class FollowedUsersListingFragment extends Fragment implements FragmentCo
@Named("oauth")
Retrofit mOauthRetrofit;
@Inject
+ SharedPreferences mSharedPreferences;
+ @Inject
RedditDataRoomDatabase mRedditDataRoomDatabase;
SubscribedUserViewModel mSubscribedUserViewModel;
private Activity mActivity;
@@ -79,12 +84,13 @@ public class FollowedUsersListingFragment extends Fragment implements FragmentCo
Resources resources = getResources();
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
- if (resources.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT || resources.getBoolean(R.bool.isTablet)) {
- int navBarResourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
- if (navBarResourceId > 0) {
- mRecyclerView.setPadding(0, 0, 0, resources.getDimensionPixelSize(navBarResourceId));
- }
+ if ((mActivity instanceof BaseActivity && ((BaseActivity) mActivity).isImmersiveInterface())) {
+ mRecyclerView.setPadding(0, 0, 0, ((BaseActivity) mActivity).getNavBarHeight());
+ } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
+ && mSharedPreferences.getBoolean(SharedPreferencesUtils.IMMERSIVE_INTERFACE_KEY, true)) {
+ int navBarResourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
+ if (navBarResourceId > 0) {
+ mRecyclerView.setPadding(0, 0, 0, resources.getDimensionPixelSize(navBarResourceId));
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java
index 66a70c74..2605ffa0 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java
@@ -11,6 +11,7 @@ import android.os.Build;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.os.Handler;
+import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
@@ -46,6 +47,7 @@ import javax.inject.Named;
import butterknife.BindView;
import butterknife.ButterKnife;
+import ml.docilealligator.infinityforreddit.Activity.BaseActivity;
import ml.docilealligator.infinityforreddit.Activity.FilteredThingActivity;
import ml.docilealligator.infinityforreddit.Activity.MainActivity;
import ml.docilealligator.infinityforreddit.Activity.ViewSubredditDetailActivity;
@@ -195,15 +197,13 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
Resources resources = getResources();
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1
- && (resources.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT
- || resources.getBoolean(R.bool.isTablet))
+ if ((activity instanceof BaseActivity && ((BaseActivity) activity).isImmersiveInterface())) {
+ mPostRecyclerView.setPadding(0, 0, 0, ((BaseActivity) activity).getNavBarHeight());
+ } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
&& mSharedPreferences.getBoolean(SharedPreferencesUtils.IMMERSIVE_INTERFACE_KEY, true)) {
- if (resources.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT || resources.getBoolean(R.bool.isTablet)) {
- int navBarResourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
- if (navBarResourceId > 0) {
- mPostRecyclerView.setPadding(0, 0, 0, resources.getDimensionPixelSize(navBarResourceId));
- }
+ int navBarResourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
+ if (navBarResourceId > 0) {
+ mPostRecyclerView.setPadding(0, 0, 0, resources.getDimensionPixelSize(navBarResourceId));
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SubredditListingFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SubredditListingFragment.java
index 91698cb6..9e16db19 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SubredditListingFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SubredditListingFragment.java
@@ -31,6 +31,7 @@ import javax.inject.Named;
import butterknife.BindView;
import butterknife.ButterKnife;
+import ml.docilealligator.infinityforreddit.Activity.BaseActivity;
import ml.docilealligator.infinityforreddit.Activity.SearchSubredditsResultActivity;
import ml.docilealligator.infinityforreddit.Activity.ViewSubredditDetailActivity;
import ml.docilealligator.infinityforreddit.Adapter.SubredditListingRecyclerViewAdapter;
@@ -100,12 +101,13 @@ public class SubredditListingFragment extends Fragment implements FragmentCommun
Resources resources = getResources();
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
- if (resources.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT || resources.getBoolean(R.bool.isTablet)) {
- int navBarResourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
- if (navBarResourceId > 0) {
- mSubredditListingRecyclerView.setPadding(0, 0, 0, resources.getDimensionPixelSize(navBarResourceId));
- }
+ if ((mActivity instanceof BaseActivity && ((BaseActivity) mActivity).isImmersiveInterface())) {
+ mSubredditListingRecyclerView.setPadding(0, 0, 0, ((BaseActivity) mActivity).getNavBarHeight());
+ } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
+ && mSharedPreferences.getBoolean(SharedPreferencesUtils.IMMERSIVE_INTERFACE_KEY, true)) {
+ int navBarResourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
+ if (navBarResourceId > 0) {
+ mSubredditListingRecyclerView.setPadding(0, 0, 0, resources.getDimensionPixelSize(navBarResourceId));
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SubscribedSubredditsListingFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SubscribedSubredditsListingFragment.java
index 076ac28c..a0d2af6c 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SubscribedSubredditsListingFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SubscribedSubredditsListingFragment.java
@@ -3,6 +3,7 @@ package ml.docilealligator.infinityforreddit.Fragment;
import android.app.Activity;
import android.content.Context;
+import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Build;
@@ -28,6 +29,7 @@ import javax.inject.Named;
import butterknife.BindView;
import butterknife.ButterKnife;
+import ml.docilealligator.infinityforreddit.Activity.BaseActivity;
import ml.docilealligator.infinityforreddit.Activity.SubredditSelectionActivity;
import ml.docilealligator.infinityforreddit.Activity.SubscribedThingListingActivity;
import ml.docilealligator.infinityforreddit.Adapter.SubscribedSubredditsRecyclerViewAdapter;
@@ -36,6 +38,7 @@ import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.SubscribedSubredditDatabase.SubscribedSubredditViewModel;
+import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.Utils.Utils;
import retrofit2.Retrofit;
@@ -63,6 +66,8 @@ public class SubscribedSubredditsListingFragment extends Fragment implements Fra
@Named("oauth")
Retrofit mOauthRetrofit;
@Inject
+ SharedPreferences mSharedPreferences;
+ @Inject
RedditDataRoomDatabase mRedditDataRoomDatabase;
private Activity mActivity;
private RequestManager mGlide;
@@ -81,13 +86,14 @@ public class SubscribedSubredditsListingFragment extends Fragment implements Fra
((Infinity) mActivity.getApplication()).getAppComponent().inject(this);
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
+ if ((mActivity instanceof BaseActivity && ((BaseActivity) mActivity).isImmersiveInterface())) {
+ mRecyclerView.setPadding(0, 0, 0, ((BaseActivity) mActivity).getNavBarHeight());
+ } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
+ && mSharedPreferences.getBoolean(SharedPreferencesUtils.IMMERSIVE_INTERFACE_KEY, true)) {
Resources resources = getResources();
- if (resources.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT || resources.getBoolean(R.bool.isTablet)) {
- int navBarResourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
- if (navBarResourceId > 0) {
- mRecyclerView.setPadding(0, 0, 0, resources.getDimensionPixelSize(navBarResourceId));
- }
+ int navBarResourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
+ if (navBarResourceId > 0) {
+ mRecyclerView.setPadding(0, 0, 0, resources.getDimensionPixelSize(navBarResourceId));
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/UserListingFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/UserListingFragment.java
index 3baf7f8d..726e8c14 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/UserListingFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/UserListingFragment.java
@@ -30,6 +30,7 @@ import javax.inject.Named;
import butterknife.BindView;
import butterknife.ButterKnife;
+import ml.docilealligator.infinityforreddit.Activity.BaseActivity;
import ml.docilealligator.infinityforreddit.Adapter.UserListingRecyclerViewAdapter;
import ml.docilealligator.infinityforreddit.FragmentCommunicator;
import ml.docilealligator.infinityforreddit.Infinity;
@@ -97,12 +98,13 @@ public class UserListingFragment extends Fragment implements FragmentCommunicato
Resources resources = getResources();
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
- if (resources.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT || resources.getBoolean(R.bool.isTablet)) {
- int navBarResourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
- if (navBarResourceId > 0) {
- mUserListingRecyclerView.setPadding(0, 0, 0, resources.getDimensionPixelSize(navBarResourceId));
- }
+ if ((mActivity instanceof BaseActivity && ((BaseActivity) mActivity).isImmersiveInterface())) {
+ mUserListingRecyclerView.setPadding(0, 0, 0, ((BaseActivity) mActivity).getNavBarHeight());
+ } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
+ && mSharedPreferences.getBoolean(SharedPreferencesUtils.IMMERSIVE_INTERFACE_KEY, true)) {
+ int navBarResourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
+ if (navBarResourceId > 0) {
+ mUserListingRecyclerView.setPadding(0, 0, 0, resources.getDimensionPixelSize(navBarResourceId));
}
}