Skip to content

Commit

Permalink
# This is a combination of 4 commits.
Browse files Browse the repository at this point in the history
# This is the 1st commit message:
添加 E-Ink 模式

# This is the commit message gedoor#2:

去除页面跳转动画

# This is the commit message gedoor#3:

开启E-Ink模式后自动设置阅读文字为白底黑字

# This is the commit message gedoor#4:

去除退出页面动画
  • Loading branch information
Modificator committed Apr 16, 2019
1 parent d8b349a commit 6d2c036
Show file tree
Hide file tree
Showing 9 changed files with 95 additions and 4 deletions.
2 changes: 2 additions & 0 deletions app/src/main/java/com/kunfei/bookshelf/MApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.kunfei.bookshelf.help.CrashHandler;
import com.kunfei.bookshelf.help.FileHelp;
import com.kunfei.bookshelf.model.UpLastChapterModel;
import com.kunfei.bookshelf.utils.Prefs;
import com.kunfei.bookshelf.utils.theme.ThemeStore;

import java.io.File;
Expand Down Expand Up @@ -96,6 +97,7 @@ public void onBack() {
}
}
});
Prefs.init(this);

}

Expand Down
24 changes: 24 additions & 0 deletions app/src/main/java/com/kunfei/bookshelf/base/MBaseActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
package com.kunfei.bookshelf.base;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
Expand All @@ -22,6 +23,7 @@
import com.kunfei.bookshelf.R;
import com.kunfei.bookshelf.constant.RxBusTag;
import com.kunfei.bookshelf.utils.ColorUtil;
import com.kunfei.bookshelf.utils.Prefs;
import com.kunfei.bookshelf.utils.bar.ImmersionBar;
import com.kunfei.bookshelf.utils.theme.MaterialValueHelper;
import com.kunfei.bookshelf.utils.theme.ThemeStore;
Expand Down Expand Up @@ -241,5 +243,27 @@ public void hideSnackBar() {
}
}

@Override
public void startActivity(Intent intent) {
super.startActivity(intent);
if (Prefs.isEInkMode){
overridePendingTransition(R.anim.anim_none,R.anim.anim_none);
}
}

@Override
public void startActivityForResult(Intent intent, int requestCode, @Nullable Bundle options) {
super.startActivityForResult(intent, requestCode, options);
if (Prefs.isEInkMode){
overridePendingTransition(R.anim.anim_none,R.anim.anim_none);
}
}

@Override
public void finish() {
super.finish();
if (Prefs.isEInkMode){
overridePendingTransition(R.anim.anim_none, R.anim.anim_none);
}
}
}
35 changes: 35 additions & 0 deletions app/src/main/java/com/kunfei/bookshelf/utils/Prefs.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.kunfei.bookshelf.utils;

import android.content.Context;
import android.content.SharedPreferences;
import android.util.Log;

import com.kunfei.bookshelf.help.ReadBookControl;

public class Prefs {

public static final String PREFS_KEY_E_INK_MODE = "prefs_key_e_ink_mode";
public static boolean isEInkMode = false;

public static void init(Context context) {
isEInkMode = getConfigStorage(context).getBoolean(PREFS_KEY_E_INK_MODE, false);
}

public static void setEInkModeStatus(Context context, boolean enable) {
isEInkMode = enable;
getConfigStorage(context).edit().putBoolean(PREFS_KEY_E_INK_MODE, enable).apply();
ReadBookControl.getInstance().setPageMode(4);
ReadBookControl.getInstance().setTextColor(1,0xFF000000);
ReadBookControl.getInstance().setBgColor(1,0xFFFFFFFF);
ReadBookControl.getInstance().setTextDrawableIndex(0);
ReadBookControl.getInstance().initTextDrawableIndex();
}

public static SharedPreferences getConfigStorage(Context context) {
return getStorage(context, "CONFIG");
}

public static SharedPreferences getStorage(Context context, String storage) {
return context.getSharedPreferences(storage, Context.MODE_PRIVATE);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.Menu;
Expand Down Expand Up @@ -36,6 +38,7 @@
import com.kunfei.bookshelf.presenter.MainPresenter;
import com.kunfei.bookshelf.presenter.contract.MainContract;
import com.kunfei.bookshelf.utils.PermissionUtils;
import com.kunfei.bookshelf.utils.Prefs;
import com.kunfei.bookshelf.utils.StringUtils;
import com.kunfei.bookshelf.utils.theme.ATH;
import com.kunfei.bookshelf.utils.theme.NavigationViewUtil;
Expand Down Expand Up @@ -422,7 +425,7 @@ public void onAlreadyTurnedDownAndNoAsk(String... permission) {
) {
drawer.closeDrawers();
} else {
drawer.openDrawer(GravityCompat.START);
drawer.openDrawer(GravityCompat.START, !Prefs.isEInkMode);
}
break;
}
Expand Down Expand Up @@ -481,7 +484,11 @@ private void setUpNavigationView() {
upThemeVw();
vwNightTheme.setOnClickListener(view -> setNightTheme(!isNightTheme()));
navigationView.setNavigationItemSelectedListener(menuItem -> {
drawer.closeDrawers();
if (Prefs.isEInkMode){
drawer.closeDrawer(Gravity.LEFT,false);
}else {
drawer.closeDrawers();
}
switch (menuItem.getItemId()) {
case R.id.action_book_source_manage:
handler.postDelayed(() -> BookSourceActivity.startThis(this), 200);
Expand Down Expand Up @@ -696,7 +703,7 @@ public boolean onKeyDown(int keyCode, KeyEvent event) {
} else {
if (keyCode == KeyEvent.KEYCODE_BACK) {
if (drawer.isDrawerOpen(GravityCompat.START)) {
drawer.closeDrawers();
drawer.closeDrawer(Gravity.LEFT, !Prefs.isEInkMode);
return true;
}
exit();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.kunfei.bookshelf.R;
import com.kunfei.bookshelf.constant.RxBusTag;
import com.kunfei.bookshelf.utils.ColorUtil;
import com.kunfei.bookshelf.utils.Prefs;
import com.kunfei.bookshelf.utils.theme.ATH;
import com.kunfei.bookshelf.view.activity.ThemeSettingActivity;

Expand Down Expand Up @@ -74,6 +75,9 @@ public void onPause() {
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
AlertDialog alertDialog;
switch (key) {
case "E-InkMode":
Prefs.setEInkModeStatus(getActivity(), sharedPreferences.getBoolean(key, false));
break;
case "immersionStatusBar":
case "navigationBarColorChange":
settingActivity.initImmersionBar();
Expand Down Expand Up @@ -147,7 +151,8 @@ public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preferen
MApplication.getInstance().upThemeStore();
RxBus.get().post(RxBusTag.RECREATE, true);
})
.setNegativeButton(R.string.cancel, (dialogInterface, i) -> {})
.setNegativeButton(R.string.cancel, (dialogInterface, i) -> {
})
.show();
ATH.setAlertDialogTint(alertDialog);
}
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/anim/anim_none.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">

</set>
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -405,4 +405,6 @@
<string name="tip_padding">Tip边距</string>
<string name="text_letter_spacing">字距</string>

<string name="e_ink_mode">E-Ink 模式</string>
<string name="e_ink_mode_detail">去除动画,优化电纸书使用体验</string>
</resources>
12 changes: 12 additions & 0 deletions app/src/main/res/xml/pref_settings_theme.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

<com.kunfei.bookshelf.widget.prefs.ATESwitchPreference
android:defaultValue="false"
android:key="E-InkMode"
android:summary="@string/e_ink_mode_detail"
android:title="@string/e_ink_mode" />

<com.kunfei.bookshelf.widget.prefs.ATESwitchPreference
android:defaultValue="false"
android:key="immersionStatusBar"
android:summary="@string/status_bar_immersion"
android:title="@string/immersion_status_bar" />

<com.kunfei.bookshelf.widget.prefs.ATESwitchPreference
android:defaultValue="false"
android:key="immersionStatusBar"
Expand Down
Empty file modified gradlew
100644 → 100755
Empty file.

0 comments on commit 6d2c036

Please sign in to comment.