mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-05 10:49:24 +02:00
options have been moved from ZLAndroidApplication to ZLAndroidLibrary
This commit is contained in:
parent
93c3e335dd
commit
858197ede0
8 changed files with 56 additions and 61 deletions
|
@ -36,7 +36,7 @@ import org.geometerplus.zlibrary.core.xml.ZLStringMap;
|
|||
import org.geometerplus.zlibrary.text.view.ZLTextRegion;
|
||||
import org.geometerplus.zlibrary.text.view.ZLTextWord;
|
||||
|
||||
import org.geometerplus.zlibrary.ui.android.library.ZLAndroidApplication;
|
||||
import org.geometerplus.zlibrary.ui.android.library.ZLAndroidLibrary;
|
||||
|
||||
import org.geometerplus.android.util.UIUtil;
|
||||
import org.geometerplus.android.util.PackageUtil;
|
||||
|
@ -191,8 +191,8 @@ public abstract class DictionaryUtil {
|
|||
final int minHeight = Math.min(200, screenHeight * 2 / 3);
|
||||
intent.putExtra(ColorDict3.HEIGHT, Math.max(minHeight, Math.min(maxHeight, space)));
|
||||
intent.putExtra(ColorDict3.GRAVITY, showAtBottom ? Gravity.BOTTOM : Gravity.TOP);
|
||||
final ZLAndroidApplication application = (ZLAndroidApplication)activity.getApplication();
|
||||
intent.putExtra(ColorDict3.FULLSCREEN, !application.ShowStatusBarOption.getValue());
|
||||
final ZLAndroidLibrary zlibrary = (ZLAndroidLibrary)ZLAndroidLibrary.Instance();
|
||||
intent.putExtra(ColorDict3.FULLSCREEN, !zlibrary.ShowStatusBarOption.getValue());
|
||||
}
|
||||
activity.startActivity(intent);
|
||||
} catch (ActivityNotFoundException e) {
|
||||
|
|
|
@ -37,6 +37,7 @@ import org.geometerplus.zlibrary.text.hyphenation.ZLTextHyphenator;
|
|||
import org.geometerplus.zlibrary.ui.android.R;
|
||||
import org.geometerplus.zlibrary.ui.android.library.ZLAndroidActivity;
|
||||
import org.geometerplus.zlibrary.ui.android.library.ZLAndroidApplication;
|
||||
import org.geometerplus.zlibrary.ui.android.library.ZLAndroidLibrary;
|
||||
|
||||
import org.geometerplus.fbreader.fbreader.ActionCode;
|
||||
import org.geometerplus.fbreader.fbreader.FBReaderApp;
|
||||
|
@ -101,9 +102,9 @@ public final class FBReader extends ZLAndroidActivity {
|
|||
@Override
|
||||
public void onCreate(Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
final ZLAndroidApplication application = (ZLAndroidApplication)getApplication();
|
||||
final ZLAndroidLibrary zlibrary = (ZLAndroidLibrary)ZLAndroidLibrary.Instance();
|
||||
myFullScreenFlag =
|
||||
application.ShowStatusBarOption.getValue() ? 0 : WindowManager.LayoutParams.FLAG_FULLSCREEN;
|
||||
zlibrary.ShowStatusBarOption.getValue() ? 0 : WindowManager.LayoutParams.FLAG_FULLSCREEN;
|
||||
getWindow().setFlags(
|
||||
WindowManager.LayoutParams.FLAG_FULLSCREEN, myFullScreenFlag
|
||||
);
|
||||
|
@ -144,9 +145,9 @@ public final class FBReader extends ZLAndroidActivity {
|
|||
|
||||
@Override
|
||||
public boolean onPrepareOptionsMenu(Menu menu) {
|
||||
final ZLAndroidApplication application = (ZLAndroidApplication)getApplication();
|
||||
if (!application.ShowStatusBarOption.getValue() &&
|
||||
application.ShowStatusBarWhenMenuIsActiveOption.getValue()) {
|
||||
final ZLAndroidLibrary zlibrary = (ZLAndroidLibrary)ZLAndroidLibrary.Instance();
|
||||
if (!zlibrary.ShowStatusBarOption.getValue() &&
|
||||
zlibrary.ShowStatusBarWhenMenuIsActiveOption.getValue()) {
|
||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
|
||||
}
|
||||
return super.onPrepareOptionsMenu(menu);
|
||||
|
@ -155,9 +156,9 @@ public final class FBReader extends ZLAndroidActivity {
|
|||
@Override
|
||||
public void onOptionsMenuClosed(Menu menu) {
|
||||
super.onOptionsMenuClosed(menu);
|
||||
final ZLAndroidApplication application = (ZLAndroidApplication)getApplication();
|
||||
if (!application.ShowStatusBarOption.getValue() &&
|
||||
application.ShowStatusBarWhenMenuIsActiveOption.getValue()) {
|
||||
final ZLAndroidLibrary zlibrary = (ZLAndroidLibrary)ZLAndroidLibrary.Instance();
|
||||
if (!zlibrary.ShowStatusBarOption.getValue() &&
|
||||
zlibrary.ShowStatusBarWhenMenuIsActiveOption.getValue()) {
|
||||
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
|
||||
}
|
||||
}
|
||||
|
@ -203,10 +204,10 @@ public final class FBReader extends ZLAndroidActivity {
|
|||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
final ZLAndroidApplication application = (ZLAndroidApplication)getApplication();
|
||||
final ZLAndroidLibrary zlibrary = (ZLAndroidLibrary)ZLAndroidLibrary.Instance();
|
||||
|
||||
final int fullScreenFlag =
|
||||
application.ShowStatusBarOption.getValue() ? 0 : WindowManager.LayoutParams.FLAG_FULLSCREEN;
|
||||
zlibrary.ShowStatusBarOption.getValue() ? 0 : WindowManager.LayoutParams.FLAG_FULLSCREEN;
|
||||
if (fullScreenFlag != myFullScreenFlag) {
|
||||
finish();
|
||||
startActivity(new Intent(this, getClass()));
|
||||
|
|
|
@ -31,7 +31,7 @@ import org.geometerplus.zlibrary.core.image.*;
|
|||
import org.geometerplus.zlibrary.core.util.MimeType;
|
||||
import org.geometerplus.zlibrary.core.util.ZLColor;
|
||||
|
||||
import org.geometerplus.zlibrary.ui.android.library.ZLAndroidApplication;
|
||||
import org.geometerplus.zlibrary.ui.android.library.ZLAndroidLibrary;
|
||||
import org.geometerplus.zlibrary.ui.android.image.ZLAndroidImageData;
|
||||
import org.geometerplus.zlibrary.ui.android.util.ZLAndroidColorUtil;
|
||||
|
||||
|
@ -46,8 +46,8 @@ public class ImageViewActivity extends Activity {
|
|||
super.onCreate(icicle);
|
||||
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
final ZLAndroidApplication application = (ZLAndroidApplication)getApplication();
|
||||
final boolean showStatusBar = application.ShowStatusBarOption.getValue();
|
||||
final ZLAndroidLibrary library = (ZLAndroidLibrary)ZLAndroidLibrary.Instance();
|
||||
final boolean showStatusBar = library.ShowStatusBarOption.getValue();
|
||||
getWindow().setFlags(
|
||||
WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
||||
showStatusBar ? 0 : WindowManager.LayoutParams.FLAG_FULLSCREEN
|
||||
|
|
|
@ -28,7 +28,7 @@ import org.geometerplus.zlibrary.core.options.ZLIntegerRangeOption;
|
|||
|
||||
import org.geometerplus.zlibrary.text.view.style.*;
|
||||
|
||||
import org.geometerplus.zlibrary.ui.android.library.ZLAndroidApplication;
|
||||
import org.geometerplus.zlibrary.ui.android.library.ZLAndroidLibrary;
|
||||
import org.geometerplus.zlibrary.ui.android.view.AndroidFontUtil;
|
||||
|
||||
import org.geometerplus.fbreader.fbreader.*;
|
||||
|
@ -46,7 +46,7 @@ public class PreferenceActivity extends ZLPreferenceActivity {
|
|||
@Override
|
||||
protected void init(Intent intent) {
|
||||
final FBReaderApp fbReader = (FBReaderApp)FBReaderApp.Instance();
|
||||
final ZLAndroidApplication androidApp = (ZLAndroidApplication)getApplication();
|
||||
final ZLAndroidLibrary androidLibrary = (ZLAndroidLibrary)ZLAndroidLibrary.Instance();
|
||||
final ColorProfile profile = fbReader.getColorProfile();
|
||||
|
||||
final Screen directoriesScreen = createPreferenceScreen("directories");
|
||||
|
@ -58,10 +58,10 @@ public class PreferenceActivity extends ZLPreferenceActivity {
|
|||
|
||||
final ZLPreferenceSet statusBarPreferences = new ZLPreferenceSet();
|
||||
final Screen appearanceScreen = createPreferenceScreen("appearance");
|
||||
appearanceScreen.addOption(androidApp.AutoOrientationOption, "autoOrientation");
|
||||
appearanceScreen.addOption(androidLibrary.AutoOrientationOption, "autoOrientation");
|
||||
appearanceScreen.addPreference(
|
||||
new ZLBooleanPreference(
|
||||
this, androidApp.ShowStatusBarOption, appearanceScreen.Resource, "showStatusBar"
|
||||
this, androidLibrary.ShowStatusBarOption, appearanceScreen.Resource, "showStatusBar"
|
||||
) {
|
||||
@Override
|
||||
public void onClick() {
|
||||
|
@ -72,12 +72,12 @@ public class PreferenceActivity extends ZLPreferenceActivity {
|
|||
);
|
||||
statusBarPreferences.add(
|
||||
appearanceScreen.addOption(
|
||||
androidApp.ShowStatusBarWhenMenuIsActiveOption,
|
||||
androidLibrary.ShowStatusBarWhenMenuIsActiveOption,
|
||||
"showStatusBarWhenMenuIsActive"
|
||||
)
|
||||
);
|
||||
statusBarPreferences.setEnabled(!androidApp.ShowStatusBarOption.getValue());
|
||||
appearanceScreen.addOption(androidApp.DisableButtonLightsOption, "disableButtonLights");
|
||||
statusBarPreferences.setEnabled(!androidLibrary.ShowStatusBarOption.getValue());
|
||||
appearanceScreen.addOption(androidLibrary.DisableButtonLightsOption, "disableButtonLights");
|
||||
|
||||
final Screen textScreen = createPreferenceScreen("text");
|
||||
final ZLTextStyleCollection collection = ZLTextStyleCollection.Instance();
|
||||
|
@ -311,20 +311,20 @@ public class PreferenceActivity extends ZLPreferenceActivity {
|
|||
public void onAccept() {
|
||||
super.onAccept();
|
||||
if (!isChecked()) {
|
||||
androidApp.ScreenBrightnessLevelOption.setValue(0);
|
||||
androidLibrary.ScreenBrightnessLevelOption.setValue(0);
|
||||
}
|
||||
}
|
||||
});
|
||||
displayScreen.addPreference(new BatteryLevelToTurnScreenOffPreference(
|
||||
this,
|
||||
androidApp.BatteryLevelToTurnScreenOffOption,
|
||||
androidLibrary.BatteryLevelToTurnScreenOffOption,
|
||||
displayScreen.Resource,
|
||||
"dontTurnScreenOff"
|
||||
));
|
||||
/*
|
||||
displayScreen.addPreference(new ZLBooleanPreference(
|
||||
this,
|
||||
androidApp.DontTurnScreenOffDuringChargingOption,
|
||||
androidLibrary.DontTurnScreenOffDuringChargingOption,
|
||||
displayScreen.Resource,
|
||||
"dontTurnScreenOffDuringCharging"
|
||||
));
|
||||
|
|
|
@ -32,7 +32,6 @@ import org.geometerplus.zlibrary.core.resources.ZLResource;
|
|||
import org.geometerplus.zlibrary.core.view.ZLViewWidget;
|
||||
|
||||
import org.geometerplus.zlibrary.ui.android.library.ZLAndroidLibrary;
|
||||
import org.geometerplus.zlibrary.ui.android.library.ZLAndroidApplication;
|
||||
|
||||
import org.geometerplus.android.util.UIUtil;
|
||||
|
||||
|
@ -106,11 +105,8 @@ public final class ZLAndroidApplicationWindow extends ZLApplicationWindow {
|
|||
}
|
||||
|
||||
public boolean canRotate() {
|
||||
final Activity activity =
|
||||
((ZLAndroidLibrary)ZLAndroidLibrary.Instance()).getActivity();
|
||||
return
|
||||
activity != null &&
|
||||
!((ZLAndroidApplication)activity.getApplication()).AutoOrientationOption.getValue();
|
||||
final ZLAndroidLibrary zlibrary = (ZLAndroidLibrary)ZLAndroidLibrary.Instance();
|
||||
return zlibrary.AutoOrientationOption.getValue();
|
||||
}
|
||||
|
||||
public void close() {
|
||||
|
|
|
@ -63,7 +63,7 @@ public abstract class ZLAndroidActivity extends Activity {
|
|||
final WindowManager.LayoutParams attrs = getWindow().getAttributes();
|
||||
attrs.screenBrightness = percent / 100.0f;
|
||||
getWindow().setAttributes(attrs);
|
||||
((ZLAndroidApplication)getApplication()).ScreenBrightnessLevelOption.setValue(percent);
|
||||
getLibrary().ScreenBrightnessLevelOption.setValue(percent);
|
||||
}
|
||||
|
||||
final int getScreenBrightness() {
|
||||
|
@ -97,8 +97,7 @@ public abstract class ZLAndroidActivity extends Activity {
|
|||
}
|
||||
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
final ZLAndroidApplication androidApplication = (ZLAndroidApplication)getApplication();
|
||||
if (androidApplication.DisableButtonLightsOption.getValue()) {
|
||||
if (getLibrary().DisableButtonLightsOption.getValue()) {
|
||||
disableButtonLight();
|
||||
}
|
||||
setContentView(R.layout.main);
|
||||
|
@ -107,6 +106,7 @@ public abstract class ZLAndroidActivity extends Activity {
|
|||
getLibrary().setActivity(this);
|
||||
|
||||
final ZLFile fileToOpen = fileFromIntent(getIntent());
|
||||
final ZLAndroidApplication androidApplication = (ZLAndroidApplication)getApplication();
|
||||
if (androidApplication.myMainWindow == null) {
|
||||
final ZLApplication application = createApplication(fileToOpen);
|
||||
androidApplication.myMainWindow = new ZLAndroidApplicationWindow(application);
|
||||
|
@ -121,7 +121,7 @@ public abstract class ZLAndroidActivity extends Activity {
|
|||
public void onStart() {
|
||||
super.onStart();
|
||||
|
||||
if (((ZLAndroidApplication)getApplication()).AutoOrientationOption.getValue()) {
|
||||
if (getLibrary().AutoOrientationOption.getValue()) {
|
||||
setAutoRotationMode();
|
||||
} else {
|
||||
switch (myOrientation) {
|
||||
|
@ -181,14 +181,13 @@ public abstract class ZLAndroidActivity extends Activity {
|
|||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
final ZLAndroidApplication application = (ZLAndroidApplication)getApplication();
|
||||
switchWakeLock(
|
||||
application.BatteryLevelToTurnScreenOffOption.getValue() <
|
||||
getLibrary().BatteryLevelToTurnScreenOffOption.getValue() <
|
||||
ZLApplication.Instance().getBatteryLevel()
|
||||
);
|
||||
myStartTimer = true;
|
||||
final int brightnessLevel =
|
||||
application.ScreenBrightnessLevelOption.getValue();
|
||||
getLibrary().ScreenBrightnessLevelOption.getValue();
|
||||
if (brightnessLevel != 0) {
|
||||
setScreenBrightness(brightnessLevel);
|
||||
} else {
|
||||
|
@ -238,8 +237,7 @@ public abstract class ZLAndroidActivity extends Activity {
|
|||
private int myChangeCounter;
|
||||
private int myOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
|
||||
private void setAutoRotationMode() {
|
||||
final ZLAndroidApplication application = (ZLAndroidApplication)getApplication();
|
||||
myOrientation = application.AutoOrientationOption.getValue() ?
|
||||
myOrientation = getLibrary().AutoOrientationOption.getValue() ?
|
||||
ActivityInfo.SCREEN_ORIENTATION_SENSOR : ActivityInfo.SCREEN_ORIENTATION_NOSENSOR;
|
||||
setRequestedOrientation(myOrientation);
|
||||
myChangeCounter = 0;
|
||||
|
@ -297,7 +295,7 @@ public abstract class ZLAndroidActivity extends Activity {
|
|||
final ZLAndroidApplication application = (ZLAndroidApplication)getApplication();
|
||||
application.myMainWindow.setBatteryLevel(level);
|
||||
switchWakeLock(
|
||||
application.BatteryLevelToTurnScreenOffOption.getValue() < level
|
||||
getLibrary().BatteryLevelToTurnScreenOffOption.getValue() < level
|
||||
);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -20,32 +20,13 @@
|
|||
package org.geometerplus.zlibrary.ui.android.library;
|
||||
|
||||
import android.app.Application;
|
||||
import android.os.Build;
|
||||
|
||||
import org.geometerplus.zlibrary.core.options.ZLBooleanOption;
|
||||
import org.geometerplus.zlibrary.core.options.ZLIntegerRangeOption;
|
||||
import org.geometerplus.zlibrary.core.sqliteconfig.ZLSQLiteConfig;
|
||||
|
||||
import org.geometerplus.zlibrary.ui.android.application.ZLAndroidApplicationWindow;
|
||||
import org.geometerplus.zlibrary.ui.android.image.ZLAndroidImageManager;
|
||||
|
||||
public class ZLAndroidApplication extends Application {
|
||||
public final ZLBooleanOption AutoOrientationOption = new ZLBooleanOption("LookNFeel", "AutoOrientation", false);
|
||||
public final ZLBooleanOption ShowStatusBarOption = new ZLBooleanOption("LookNFeel", "ShowStatusBar", hasNoHardwareMenuButton());
|
||||
public final ZLBooleanOption ShowStatusBarWhenMenuIsActiveOption = new ZLBooleanOption("LookNFeel", "ShowStatusBarWithMenu", true);
|
||||
public final ZLIntegerRangeOption BatteryLevelToTurnScreenOffOption = new ZLIntegerRangeOption("LookNFeel", "BatteryLevelToTurnScreenOff", 0, 100, 50);
|
||||
public final ZLBooleanOption DontTurnScreenOffDuringChargingOption = new ZLBooleanOption("LookNFeel", "DontTurnScreenOffDuringCharging", true);
|
||||
public final ZLIntegerRangeOption ScreenBrightnessLevelOption = new ZLIntegerRangeOption("LookNFeel", "ScreenBrightnessLevel", 0, 100, 0);
|
||||
public final ZLBooleanOption DisableButtonLightsOption = new ZLBooleanOption("LookNFeel", "DisableButtonLights", true);
|
||||
|
||||
private boolean hasNoHardwareMenuButton() {
|
||||
return
|
||||
// Eken M001
|
||||
(Build.DISPLAY != null && Build.DISPLAY.contains("simenxie")) ||
|
||||
// PanDigital
|
||||
"PD_Novel".equals(Build.MODEL);
|
||||
}
|
||||
|
||||
public ZLAndroidApplicationWindow myMainWindow;
|
||||
|
||||
@Override
|
||||
|
|
|
@ -25,6 +25,7 @@ import java.util.*;
|
|||
import android.app.Application;
|
||||
import android.content.res.AssetFileDescriptor;
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.text.format.DateFormat;
|
||||
import android.util.DisplayMetrics;
|
||||
|
@ -32,11 +33,29 @@ import android.util.DisplayMetrics;
|
|||
import org.geometerplus.zlibrary.core.library.ZLibrary;
|
||||
import org.geometerplus.zlibrary.core.filesystem.ZLFile;
|
||||
import org.geometerplus.zlibrary.core.filesystem.ZLResourceFile;
|
||||
import org.geometerplus.zlibrary.core.options.ZLBooleanOption;
|
||||
import org.geometerplus.zlibrary.core.options.ZLIntegerRangeOption;
|
||||
|
||||
import org.geometerplus.zlibrary.ui.android.R;
|
||||
import org.geometerplus.zlibrary.ui.android.view.ZLAndroidWidget;
|
||||
|
||||
public final class ZLAndroidLibrary extends ZLibrary {
|
||||
public final ZLBooleanOption AutoOrientationOption = new ZLBooleanOption("LookNFeel", "AutoOrientation", false);
|
||||
public final ZLBooleanOption ShowStatusBarOption = new ZLBooleanOption("LookNFeel", "ShowStatusBar", hasNoHardwareMenuButton());
|
||||
public final ZLBooleanOption ShowStatusBarWhenMenuIsActiveOption = new ZLBooleanOption("LookNFeel", "ShowStatusBarWithMenu", true);
|
||||
public final ZLIntegerRangeOption BatteryLevelToTurnScreenOffOption = new ZLIntegerRangeOption("LookNFeel", "BatteryLevelToTurnScreenOff", 0, 100, 50);
|
||||
public final ZLBooleanOption DontTurnScreenOffDuringChargingOption = new ZLBooleanOption("LookNFeel", "DontTurnScreenOffDuringCharging", true);
|
||||
public final ZLIntegerRangeOption ScreenBrightnessLevelOption = new ZLIntegerRangeOption("LookNFeel", "ScreenBrightnessLevel", 0, 100, 0);
|
||||
public final ZLBooleanOption DisableButtonLightsOption = new ZLBooleanOption("LookNFeel", "DisableButtonLights", true);
|
||||
|
||||
private static boolean hasNoHardwareMenuButton() {
|
||||
return
|
||||
// Eken M001
|
||||
(Build.DISPLAY != null && Build.DISPLAY.contains("simenxie")) ||
|
||||
// PanDigital
|
||||
"PD_Novel".equals(Build.MODEL);
|
||||
}
|
||||
|
||||
private ZLAndroidActivity myActivity;
|
||||
private final Application myApplication;
|
||||
private ZLAndroidWidget myWidget;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue