Skip to content

Commit

Permalink
Merge branch 'MIUI-Fix' of https://github.com/lx200916/Cimoc-1 into r…
Browse files Browse the repository at this point in the history
…elease-tci
  • Loading branch information
Haleydu committed Feb 5, 2021
2 parents 2fba1c4 + ec1e81d commit 4ce67b9
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 2 deletions.
2 changes: 2 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@
android:configChanges="orientation|keyboardHidden|screenSize" />
<activity
android:name=".ui.activity.PageReaderActivity"
android:forceDarkAllowed="false"
android:theme="@style/AppThemeNoDark"
android:configChanges="orientation|keyboardHidden|screenSize" />
<activity
android:name=".ui.activity.StreamReaderActivity"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.hiroshi.cimoc.ui.activity;

import android.os.Build;

import androidx.recyclerview.widget.RecyclerView;

import com.hiroshi.cimoc.R;
Expand Down Expand Up @@ -32,6 +34,9 @@ protected void initView() {
((RecyclerViewPager) mRecyclerView).setScrollSpeed(0.12f);
}
((RecyclerViewPager) mRecyclerView).setTriggerOffset(0.01f * offset);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
mRecyclerView.setForceDarkAllowed(false);
}
((RecyclerViewPager) mRecyclerView).setOnPageChangedListener(this);
mRecyclerView.setItemAnimator(null);
mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ protected void initTheme() {
protected BasePresenter initPresenter() {
mPresenter = new ReaderPresenter();
mPresenter.attachView(this);

return mPresenter;
}

Expand All @@ -168,18 +169,23 @@ protected void initView() {
mHideInfo = mPreference.getBoolean(PreferenceManager.PREF_READER_HIDE_INFO, false);
mControllerTrigThreshold = mPreference.getInt(PreferenceManager.PREF_READER_CONTROLLER_TRIG_THRESHOLD, 30) * 0.01f;
mInfoLayout.setVisibility(mHideInfo ? View.INVISIBLE : View.VISIBLE);
// 防止miui及其他魔改ROM启用反色
setTheme(R.style.AppThemeNoDark);
String key = mode == PreferenceManager.READER_MODE_PAGE ?
PreferenceManager.PREF_READER_PAGE_TURN : PreferenceManager.PREF_READER_STREAM_TURN;
turn = mPreference.getInt(key, PreferenceManager.READER_TURN_LTR);
if (mPreference.getBoolean(PreferenceManager.PREF_READER_WHITE_BACKGROUND, false)) {
mReaderBox.setBackgroundResource(R.color.white);
}
initSeekBar();

initLayoutManager();
initReaderAdapter();
mRecyclerView.setItemAnimator(null);
mRecyclerView.setLayoutManager(mLayoutManager);
mRecyclerView.setAdapter(mReaderAdapter);


mRecyclerView.setItemViewCacheSize(2);
mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
Expand Down Expand Up @@ -239,6 +245,7 @@ private void initLayoutManager() {
mLayoutManager.setOrientation(turn == PreferenceManager.READER_TURN_ATB ? LinearLayoutManager.VERTICAL : LinearLayoutManager.HORIZONTAL);
mLayoutManager.setReverseLayout(turn == PreferenceManager.READER_TURN_RTL);
mLayoutManager.setExtraSpace(2);

}

@Override
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/res/values-v29/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<style name="AppThemeNoDark" parent="AppTheme">
<item name="android:forceDarkAllowed">false</item>

</style>
</resources>
12 changes: 10 additions & 2 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<resources xmlns:tools="http://schemas.android.com/tools">

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"></style>
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">

</style>

<style name="AppThemeNoDark" parent="Theme.AppCompat.Light.NoActionBar">
<!-- // 防止miui及其他魔改ROM启用反色-->
<item name="android:forceDarkAllowed" tools:targetApi="q">false</item>

</style>

<style name="AppThemeBlue" parent="AppTheme">
<item name="colorPrimary">@color/colorPrimaryBlue</item>
Expand Down

0 comments on commit 4ce67b9

Please sign in to comment.