Fix dark theme issue when selecting playback speed. Minor bugs fixed.

This commit is contained in:
Alex Ning 2021-11-21 20:59:01 +08:00
parent fd1b6fa6fe
commit 725921dac1
7 changed files with 68 additions and 11 deletions

View File

@ -25,7 +25,7 @@
<uses-permission android:name="android.permission.WAKE_LOCK" /> <uses-permission android:name="android.permission.WAKE_LOCK" />
<application <application
android:name=".Infinity" android:name="ml.docilealligator.infinityforreddit.Infinity"
android:allowBackup="true" android:allowBackup="true"
android:icon="@mipmap/ic_launcher" android:icon="@mipmap/ic_launcher"
android:label="@string/application_name" android:label="@string/application_name"

View File

@ -129,10 +129,10 @@ public abstract class BaseActivity extends AppCompatActivity {
} }
} }
boolean userDefinedChangeSatusBarIconColorInImmersiveInterface = boolean userDefinedChangeStatusBarIconColorInImmersiveInterface =
customThemeWrapper.isChangeStatusBarIconColorAfterToolbarCollapsedInImmersiveInterface(); customThemeWrapper.isChangeStatusBarIconColorAfterToolbarCollapsedInImmersiveInterface();
if (immersiveInterface && isImmersiveInterfaceApplicable) { if (immersiveInterface && isImmersiveInterfaceApplicable) {
changeStatusBarIconColor = userDefinedChangeSatusBarIconColorInImmersiveInterface; changeStatusBarIconColor = userDefinedChangeStatusBarIconColorInImmersiveInterface;
} else { } else {
changeStatusBarIconColor = false; changeStatusBarIconColor = false;
} }

View File

@ -270,9 +270,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
drawer.setFitsSystemWindows(false); drawer.setFitsSystemWindows(false);
getWindow().setDecorFitsSystemWindows(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 { } else {
window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
} }

View File

@ -22,6 +22,7 @@ import androidx.recyclerview.widget.RecyclerView;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import com.bumptech.glide.Glide; import com.bumptech.glide.Glide;
import com.bumptech.glide.RequestManager;
import com.google.android.material.appbar.AppBarLayout; import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.appbar.CollapsingToolbarLayout; import com.google.android.material.appbar.CollapsingToolbarLayout;
import com.r0adkll.slidr.Slidr; import com.r0adkll.slidr.Slidr;
@ -100,10 +101,10 @@ public class TrendingActivity extends BaseActivity {
@Inject @Inject
Executor mExecutor; Executor mExecutor;
private String mAccessToken; private String mAccessToken;
private String mAccountName;
private boolean isRefreshing = false; private boolean isRefreshing = false;
private ArrayList<TrendingSearch> trendingSearches; private ArrayList<TrendingSearch> trendingSearches;
private TrendingSearchRecyclerViewAdapter adapter; private TrendingSearchRecyclerViewAdapter adapter;
private RequestManager mGlide;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -151,7 +152,8 @@ public class TrendingActivity extends BaseActivity {
setToolbarGoToTop(toolbar); setToolbarGoToTop(toolbar);
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null); mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, null);
mGlide = Glide.with(this);
DisplayMetrics displayMetrics = new DisplayMetrics(); DisplayMetrics displayMetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displayMetrics); getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
@ -277,7 +279,7 @@ public class TrendingActivity extends BaseActivity {
private void showErrorView(int stringId) { private void showErrorView(int stringId) {
errorLinearLayout.setVisibility(View.VISIBLE); 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); errorTextView.setText(stringId);
} }

View File

@ -1,5 +1,10 @@
package ml.docilealligator.infinityforreddit.activities; 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.Manifest;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
@ -32,6 +37,7 @@ import android.widget.Toast;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.coordinatorlayout.widget.CoordinatorLayout; import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.core.app.ActivityCompat; import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
@ -150,6 +156,8 @@ public class ViewVideoActivity extends AppCompatActivity {
TextView titleTextView; TextView titleTextView;
@BindView(R.id.download_image_view_exo_playback_control_view) @BindView(R.id.download_image_view_exo_playback_control_view)
ImageView downloadImageView; 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) @BindView(R.id.lockable_nested_scroll_view_view_video_activity)
LockableNestedScrollView nestedScrollView; LockableNestedScrollView nestedScrollView;
@ -206,7 +214,37 @@ public class ViewVideoActivity extends AppCompatActivity {
((Infinity) getApplication()).getAppComponent().inject(this); ((Infinity) getApplication()).getAppComponent().inject(this);
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); 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 getTheme().applyStyle(FontStyle.valueOf(mSharedPreferences
.getString(SharedPreferencesUtils.FONT_SIZE_KEY, FontStyle.Normal.name())).getResId(), true); .getString(SharedPreferencesUtils.FONT_SIZE_KEY, FontStyle.Normal.name())).getResId(), true);
@ -250,6 +288,14 @@ public class ViewVideoActivity extends AppCompatActivity {
isDownloading = true; isDownloading = true;
requestPermissionAndDownload(); 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 { } else {
ActionBar actionBar = getSupportActionBar(); ActionBar actionBar = getSupportActionBar();
Drawable upArrow = resources.getDrawable(R.drawable.ic_arrow_back_white_24dp); Drawable upArrow = resources.getDrawable(R.drawable.ic_arrow_back_white_24dp);

View File

@ -26,6 +26,7 @@ import androidx.recyclerview.widget.RecyclerView;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import com.bumptech.glide.Glide; import com.bumptech.glide.Glide;
import com.bumptech.glide.RequestManager;
import com.google.android.material.appbar.AppBarLayout; import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.appbar.CollapsingToolbarLayout; import com.google.android.material.appbar.CollapsingToolbarLayout;
import com.r0adkll.slidr.Slidr; import com.r0adkll.slidr.Slidr;
@ -113,6 +114,7 @@ public class WikiActivity extends BaseActivity {
private Markwon markwon; private Markwon markwon;
private MarkwonAdapter markwonAdapter; private MarkwonAdapter markwonAdapter;
private boolean isRefreshing = false; private boolean isRefreshing = false;
private RequestManager mGlide;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { 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.setEnabled(mSharedPreferences.getBoolean(SharedPreferencesUtils.PULL_TO_REFRESH, true));
swipeRefreshLayout.setOnRefreshListener(this::loadWiki); swipeRefreshLayout.setOnRefreshListener(this::loadWiki);
@ -328,7 +332,7 @@ public class WikiActivity extends BaseActivity {
swipeRefreshLayout.setRefreshing(false); swipeRefreshLayout.setRefreshing(false);
mFetchWikiInfoLinearLayout.setVisibility(View.VISIBLE); mFetchWikiInfoLinearLayout.setVisibility(View.VISIBLE);
mFetchWikiInfoTextView.setText(stringResId); mFetchWikiInfoTextView.setText(stringResId);
Glide.with(this).load(R.drawable.error_image).into(mFetchWikiInfoImageView); mGlide.load(R.drawable.error_image).into(mFetchWikiInfoImageView);
} }
@Override @Override

View File

@ -119,6 +119,14 @@
android:src="@drawable/ic_file_download_toolbar_white_24dp" android:src="@drawable/ic_file_download_toolbar_white_24dp"
android:background="?attr/selectableItemBackgroundBorderless" /> 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> </LinearLayout>
</com.google.android.material.bottomappbar.BottomAppBar> </com.google.android.material.bottomappbar.BottomAppBar>