aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2021-11-21 12:59:01 +0000
committerAlex Ning <chineseperson5@gmail.com>2021-11-21 12:59:01 +0000
commit725921dac16541a1eb4724130bf87ee509c0591b (patch)
treea84298df1392fab043e11420815884a953409538 /app/src/main/java
parentfd1b6fa6fef6aecb7e945546c1f14f3aa6923881 (diff)
downloadinfinity-for-reddit-725921dac16541a1eb4724130bf87ee509c0591b.tar
infinity-for-reddit-725921dac16541a1eb4724130bf87ee509c0591b.tar.gz
infinity-for-reddit-725921dac16541a1eb4724130bf87ee509c0591b.tar.bz2
infinity-for-reddit-725921dac16541a1eb4724130bf87ee509c0591b.tar.lz
infinity-for-reddit-725921dac16541a1eb4724130bf87ee509c0591b.tar.xz
infinity-for-reddit-725921dac16541a1eb4724130bf87ee509c0591b.tar.zst
infinity-for-reddit-725921dac16541a1eb4724130bf87ee509c0591b.zip
Fix dark theme issue when selecting playback speed. Minor bugs fixed.
Diffstat (limited to '')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/BaseActivity.java4
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java3
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/TrendingActivity.java8
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java48
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/WikiActivity.java6
5 files changed, 59 insertions, 10 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/BaseActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/BaseActivity.java
index 13f40f63..ad840efa 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/BaseActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/BaseActivity.java
@@ -129,10 +129,10 @@ public abstract class BaseActivity extends AppCompatActivity {
}
}
- boolean userDefinedChangeSatusBarIconColorInImmersiveInterface =
+ boolean userDefinedChangeStatusBarIconColorInImmersiveInterface =
customThemeWrapper.isChangeStatusBarIconColorAfterToolbarCollapsedInImmersiveInterface();
if (immersiveInterface && isImmersiveInterfaceApplicable) {
- changeStatusBarIconColor = userDefinedChangeSatusBarIconColorInImmersiveInterface;
+ changeStatusBarIconColor = userDefinedChangeStatusBarIconColorInImmersiveInterface;
} else {
changeStatusBarIconColor = false;
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java
index 30d134fe..1b509410 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java
@@ -270,9 +270,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
drawer.setFitsSystemWindows(false);
getWindow().setDecorFitsSystemWindows(false);
- /*drawer.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
- View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
- View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);*/
} else {
window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/TrendingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/TrendingActivity.java
index 7057b1ad..039688fb 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/TrendingActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/TrendingActivity.java
@@ -22,6 +22,7 @@ import androidx.recyclerview.widget.RecyclerView;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import com.bumptech.glide.Glide;
+import com.bumptech.glide.RequestManager;
import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.appbar.CollapsingToolbarLayout;
import com.r0adkll.slidr.Slidr;
@@ -100,10 +101,10 @@ public class TrendingActivity extends BaseActivity {
@Inject
Executor mExecutor;
private String mAccessToken;
- private String mAccountName;
private boolean isRefreshing = false;
private ArrayList<TrendingSearch> trendingSearches;
private TrendingSearchRecyclerViewAdapter adapter;
+ private RequestManager mGlide;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -151,7 +152,8 @@ public class TrendingActivity extends BaseActivity {
setToolbarGoToTop(toolbar);
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
- mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, null);
+
+ mGlide = Glide.with(this);
DisplayMetrics displayMetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
@@ -277,7 +279,7 @@ public class TrendingActivity extends BaseActivity {
private void showErrorView(int stringId) {
errorLinearLayout.setVisibility(View.VISIBLE);
- Glide.with(this).load(R.drawable.error_image).into(errorImageView);
+ mGlide.load(R.drawable.error_image).into(errorImageView);
errorTextView.setText(stringId);
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java
index 548e7c53..50e756ed 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java
@@ -1,5 +1,10 @@
package ml.docilealligator.infinityforreddit.activities;
+import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY;
+import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM;
+import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_NO;
+import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_YES;
+
import android.Manifest;
import android.content.Intent;
import android.content.SharedPreferences;
@@ -32,6 +37,7 @@ import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
+import androidx.appcompat.app.AppCompatDelegate;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
@@ -150,6 +156,8 @@ public class ViewVideoActivity extends AppCompatActivity {
TextView titleTextView;
@BindView(R.id.download_image_view_exo_playback_control_view)
ImageView downloadImageView;
+ @BindView(R.id.playback_speed_image_view_exo_playback_control_view)
+ ImageView playbackSpeedImageView;
@BindView(R.id.lockable_nested_scroll_view_view_video_activity)
LockableNestedScrollView nestedScrollView;
@@ -206,7 +214,37 @@ public class ViewVideoActivity extends AppCompatActivity {
((Infinity) getApplication()).getAppComponent().inject(this);
- getTheme().applyStyle(R.style.Theme_Normal, true);
+ boolean systemDefault = Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q;
+ int systemThemeType = Integer.parseInt(mSharedPreferences.getString(SharedPreferencesUtils.THEME_KEY, "2"));
+ switch (systemThemeType) {
+ case 0:
+ AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_NO);
+ getTheme().applyStyle(R.style.Theme_Normal, true);
+ break;
+ case 1:
+ AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_YES);
+ if(mSharedPreferences.getBoolean(SharedPreferencesUtils.AMOLED_DARK_KEY, false)) {
+ getTheme().applyStyle(R.style.Theme_Normal_AmoledDark, true);
+ } else {
+ getTheme().applyStyle(R.style.Theme_Normal_NormalDark, true);
+ }
+ break;
+ case 2:
+ if (systemDefault) {
+ AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_FOLLOW_SYSTEM);
+ } else {
+ AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_AUTO_BATTERY);
+ }
+ if((getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_NO) {
+ getTheme().applyStyle(R.style.Theme_Normal, true);
+ } else {
+ if(mSharedPreferences.getBoolean(SharedPreferencesUtils.AMOLED_DARK_KEY, false)) {
+ getTheme().applyStyle(R.style.Theme_Normal_AmoledDark, true);
+ } else {
+ getTheme().applyStyle(R.style.Theme_Normal_NormalDark, true);
+ }
+ }
+ }
getTheme().applyStyle(FontStyle.valueOf(mSharedPreferences
.getString(SharedPreferencesUtils.FONT_SIZE_KEY, FontStyle.Normal.name())).getResId(), true);
@@ -250,6 +288,14 @@ public class ViewVideoActivity extends AppCompatActivity {
isDownloading = true;
requestPermissionAndDownload();
});
+
+ playbackSpeedImageView.setOnClickListener(view -> {
+ PlaybackSpeedBottomSheetFragment playbackSpeedBottomSheetFragment = new PlaybackSpeedBottomSheetFragment();
+ Bundle bundle = new Bundle();
+ bundle.putInt(PlaybackSpeedBottomSheetFragment.EXTRA_PLAYBACK_SPEED, playbackSpeed);
+ playbackSpeedBottomSheetFragment.setArguments(bundle);
+ playbackSpeedBottomSheetFragment.show(getSupportFragmentManager(), playbackSpeedBottomSheetFragment.getTag());
+ });
} else {
ActionBar actionBar = getSupportActionBar();
Drawable upArrow = resources.getDrawable(R.drawable.ic_arrow_back_white_24dp);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/WikiActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/WikiActivity.java
index 1a353a7f..09fcffe6 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/WikiActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/WikiActivity.java
@@ -26,6 +26,7 @@ import androidx.recyclerview.widget.RecyclerView;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import com.bumptech.glide.Glide;
+import com.bumptech.glide.RequestManager;
import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.appbar.CollapsingToolbarLayout;
import com.r0adkll.slidr.Slidr;
@@ -113,6 +114,7 @@ public class WikiActivity extends BaseActivity {
private Markwon markwon;
private MarkwonAdapter markwonAdapter;
private boolean isRefreshing = false;
+ private RequestManager mGlide;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -154,6 +156,8 @@ public class WikiActivity extends BaseActivity {
}
}
+ mGlide = Glide.with(this);
+
swipeRefreshLayout.setEnabled(mSharedPreferences.getBoolean(SharedPreferencesUtils.PULL_TO_REFRESH, true));
swipeRefreshLayout.setOnRefreshListener(this::loadWiki);
@@ -328,7 +332,7 @@ public class WikiActivity extends BaseActivity {
swipeRefreshLayout.setRefreshing(false);
mFetchWikiInfoLinearLayout.setVisibility(View.VISIBLE);
mFetchWikiInfoTextView.setText(stringResId);
- Glide.with(this).load(R.drawable.error_image).into(mFetchWikiInfoImageView);
+ mGlide.load(R.drawable.error_image).into(mFetchWikiInfoImageView);
}
@Override