aboutsummaryrefslogtreecommitdiff
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
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.
-rw-r--r--app/src/main/AndroidManifest.xml2
-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
-rw-r--r--app/src/main/res/layout/exo_playback_control_view.xml8
7 files changed, 68 insertions, 11 deletions
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 1a7707e6..6852e8a5 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -25,7 +25,7 @@
<uses-permission android:name="android.permission.WAKE_LOCK" />
<application
- android:name=".Infinity"
+ android:name="ml.docilealligator.infinityforreddit.Infinity"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/application_name"
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
diff --git a/app/src/main/res/layout/exo_playback_control_view.xml b/app/src/main/res/layout/exo_playback_control_view.xml
index b81b5026..28ee2d9a 100644
--- a/app/src/main/res/layout/exo_playback_control_view.xml
+++ b/app/src/main/res/layout/exo_playback_control_view.xml
@@ -119,6 +119,14 @@
android:src="@drawable/ic_file_download_toolbar_white_24dp"
android:background="?attr/selectableItemBackgroundBorderless" />
+ <ImageView
+ android:id="@+id/playback_speed_image_view_exo_playback_control_view"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:padding="16dp"
+ android:src="@drawable/ic_playback_speed_toolbar_24dp"
+ android:background="?attr/selectableItemBackgroundBorderless" />
+
</LinearLayout>
</com.google.android.material.bottomappbar.BottomAppBar>