mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-05 02:39:23 +02:00
no ZLAndroidApplication.Instance() method
This commit is contained in:
parent
f4b0861ce2
commit
93c3e335dd
10 changed files with 28 additions and 32 deletions
|
@ -191,7 +191,7 @@ public abstract class DictionaryUtil {
|
||||||
final int minHeight = Math.min(200, screenHeight * 2 / 3);
|
final int minHeight = Math.min(200, screenHeight * 2 / 3);
|
||||||
intent.putExtra(ColorDict3.HEIGHT, Math.max(minHeight, Math.min(maxHeight, space)));
|
intent.putExtra(ColorDict3.HEIGHT, Math.max(minHeight, Math.min(maxHeight, space)));
|
||||||
intent.putExtra(ColorDict3.GRAVITY, showAtBottom ? Gravity.BOTTOM : Gravity.TOP);
|
intent.putExtra(ColorDict3.GRAVITY, showAtBottom ? Gravity.BOTTOM : Gravity.TOP);
|
||||||
final ZLAndroidApplication application = ZLAndroidApplication.Instance();
|
final ZLAndroidApplication application = (ZLAndroidApplication)activity.getApplication();
|
||||||
intent.putExtra(ColorDict3.FULLSCREEN, !application.ShowStatusBarOption.getValue());
|
intent.putExtra(ColorDict3.FULLSCREEN, !application.ShowStatusBarOption.getValue());
|
||||||
}
|
}
|
||||||
activity.startActivity(intent);
|
activity.startActivity(intent);
|
||||||
|
|
|
@ -24,8 +24,6 @@ import android.text.ClipboardManager;
|
||||||
|
|
||||||
import org.geometerplus.zlibrary.core.resources.ZLResource;
|
import org.geometerplus.zlibrary.core.resources.ZLResource;
|
||||||
|
|
||||||
import org.geometerplus.zlibrary.ui.android.library.ZLAndroidApplication;
|
|
||||||
|
|
||||||
import org.geometerplus.fbreader.fbreader.FBReaderApp;
|
import org.geometerplus.fbreader.fbreader.FBReaderApp;
|
||||||
|
|
||||||
import org.geometerplus.android.util.UIUtil;
|
import org.geometerplus.android.util.UIUtil;
|
||||||
|
@ -41,7 +39,7 @@ public class SelectionCopyAction extends FBAndroidAction {
|
||||||
Reader.getTextView().clearSelection();
|
Reader.getTextView().clearSelection();
|
||||||
|
|
||||||
final ClipboardManager clipboard =
|
final ClipboardManager clipboard =
|
||||||
(ClipboardManager)ZLAndroidApplication.Instance().getSystemService(Application.CLIPBOARD_SERVICE);
|
(ClipboardManager)BaseActivity.getApplication().getSystemService(Application.CLIPBOARD_SERVICE);
|
||||||
clipboard.setText(text);
|
clipboard.setText(text);
|
||||||
UIUtil.showMessageText(
|
UIUtil.showMessageText(
|
||||||
BaseActivity,
|
BaseActivity,
|
||||||
|
|
|
@ -46,7 +46,7 @@ public class ImageViewActivity extends Activity {
|
||||||
super.onCreate(icicle);
|
super.onCreate(icicle);
|
||||||
|
|
||||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||||
final ZLAndroidApplication application = ZLAndroidApplication.Instance();
|
final ZLAndroidApplication application = (ZLAndroidApplication)getApplication();
|
||||||
final boolean showStatusBar = application.ShowStatusBarOption.getValue();
|
final boolean showStatusBar = application.ShowStatusBarOption.getValue();
|
||||||
getWindow().setFlags(
|
getWindow().setFlags(
|
||||||
WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
||||||
|
|
|
@ -97,7 +97,7 @@ public class NetworkBookInfoActivity extends Activity implements NetworkLibrary.
|
||||||
final NetworkLibrary library = NetworkLibrary.Instance();
|
final NetworkLibrary library = NetworkLibrary.Instance();
|
||||||
if (!library.isInitialized()) {
|
if (!library.isInitialized()) {
|
||||||
if (SQLiteNetworkDatabase.Instance() == null) {
|
if (SQLiteNetworkDatabase.Instance() == null) {
|
||||||
new SQLiteNetworkDatabase();
|
new SQLiteNetworkDatabase(getApplication());
|
||||||
}
|
}
|
||||||
library.initialize();
|
library.initialize();
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ package org.geometerplus.android.fbreader.network;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
import android.app.Application;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.database.sqlite.SQLiteDatabase;
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
|
@ -36,8 +37,8 @@ import org.geometerplus.android.util.SQLiteUtil;
|
||||||
class SQLiteNetworkDatabase extends NetworkDatabase {
|
class SQLiteNetworkDatabase extends NetworkDatabase {
|
||||||
private final SQLiteDatabase myDatabase;
|
private final SQLiteDatabase myDatabase;
|
||||||
|
|
||||||
SQLiteNetworkDatabase() {
|
SQLiteNetworkDatabase(Application application) {
|
||||||
myDatabase = ZLAndroidApplication.Instance().openOrCreateDatabase("network.db", Context.MODE_PRIVATE, null);
|
myDatabase = application.openOrCreateDatabase("network.db", Context.MODE_PRIVATE, null);
|
||||||
migrate();
|
migrate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ public abstract class Util implements UserRegistrationConstants {
|
||||||
return intent;
|
return intent;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void initLibrary(Activity activity) {
|
static void initLibrary(final Activity activity) {
|
||||||
final NetworkLibrary library = NetworkLibrary.Instance();
|
final NetworkLibrary library = NetworkLibrary.Instance();
|
||||||
if (library.isInitialized()) {
|
if (library.isInitialized()) {
|
||||||
return;
|
return;
|
||||||
|
@ -59,7 +59,7 @@ public abstract class Util implements UserRegistrationConstants {
|
||||||
UIUtil.wait("loadingNetworkLibrary", new Runnable() {
|
UIUtil.wait("loadingNetworkLibrary", new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
if (SQLiteNetworkDatabase.Instance() == null) {
|
if (SQLiteNetworkDatabase.Instance() == null) {
|
||||||
new SQLiteNetworkDatabase();
|
new SQLiteNetworkDatabase(activity.getApplication());
|
||||||
}
|
}
|
||||||
|
|
||||||
library.initialize();
|
library.initialize();
|
||||||
|
|
|
@ -46,7 +46,7 @@ public class PreferenceActivity extends ZLPreferenceActivity {
|
||||||
@Override
|
@Override
|
||||||
protected void init(Intent intent) {
|
protected void init(Intent intent) {
|
||||||
final FBReaderApp fbReader = (FBReaderApp)FBReaderApp.Instance();
|
final FBReaderApp fbReader = (FBReaderApp)FBReaderApp.Instance();
|
||||||
final ZLAndroidApplication androidApp = ZLAndroidApplication.Instance();
|
final ZLAndroidApplication androidApp = (ZLAndroidApplication)getApplication();
|
||||||
final ColorProfile profile = fbReader.getColorProfile();
|
final ColorProfile profile = fbReader.getColorProfile();
|
||||||
|
|
||||||
final Screen directoriesScreen = createPreferenceScreen("directories");
|
final Screen directoriesScreen = createPreferenceScreen("directories");
|
||||||
|
|
|
@ -106,7 +106,11 @@ public final class ZLAndroidApplicationWindow extends ZLApplicationWindow {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canRotate() {
|
public boolean canRotate() {
|
||||||
return !ZLAndroidApplication.Instance().AutoOrientationOption.getValue();
|
final Activity activity =
|
||||||
|
((ZLAndroidLibrary)ZLAndroidLibrary.Instance()).getActivity();
|
||||||
|
return
|
||||||
|
activity != null &&
|
||||||
|
!((ZLAndroidApplication)activity.getApplication()).AutoOrientationOption.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void close() {
|
public void close() {
|
||||||
|
|
|
@ -97,7 +97,8 @@ public abstract class ZLAndroidActivity extends Activity {
|
||||||
}
|
}
|
||||||
|
|
||||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||||
if (ZLAndroidApplication.Instance().DisableButtonLightsOption.getValue()) {
|
final ZLAndroidApplication androidApplication = (ZLAndroidApplication)getApplication();
|
||||||
|
if (androidApplication.DisableButtonLightsOption.getValue()) {
|
||||||
disableButtonLight();
|
disableButtonLight();
|
||||||
}
|
}
|
||||||
setContentView(R.layout.main);
|
setContentView(R.layout.main);
|
||||||
|
@ -106,9 +107,9 @@ public abstract class ZLAndroidActivity extends Activity {
|
||||||
getLibrary().setActivity(this);
|
getLibrary().setActivity(this);
|
||||||
|
|
||||||
final ZLFile fileToOpen = fileFromIntent(getIntent());
|
final ZLFile fileToOpen = fileFromIntent(getIntent());
|
||||||
if (((ZLAndroidApplication)getApplication()).myMainWindow == null) {
|
if (androidApplication.myMainWindow == null) {
|
||||||
ZLApplication application = createApplication(fileToOpen);
|
final ZLApplication application = createApplication(fileToOpen);
|
||||||
((ZLAndroidApplication)getApplication()).myMainWindow = new ZLAndroidApplicationWindow(application);
|
androidApplication.myMainWindow = new ZLAndroidApplicationWindow(application);
|
||||||
application.initWindow();
|
application.initWindow();
|
||||||
} else {
|
} else {
|
||||||
ZLApplication.Instance().openFile(fileToOpen);
|
ZLApplication.Instance().openFile(fileToOpen);
|
||||||
|
@ -120,7 +121,7 @@ public abstract class ZLAndroidActivity extends Activity {
|
||||||
public void onStart() {
|
public void onStart() {
|
||||||
super.onStart();
|
super.onStart();
|
||||||
|
|
||||||
if (ZLAndroidApplication.Instance().AutoOrientationOption.getValue()) {
|
if (((ZLAndroidApplication)getApplication()).AutoOrientationOption.getValue()) {
|
||||||
setAutoRotationMode();
|
setAutoRotationMode();
|
||||||
} else {
|
} else {
|
||||||
switch (myOrientation) {
|
switch (myOrientation) {
|
||||||
|
@ -180,13 +181,14 @@ public abstract class ZLAndroidActivity extends Activity {
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
final ZLAndroidApplication application = (ZLAndroidApplication)getApplication();
|
||||||
switchWakeLock(
|
switchWakeLock(
|
||||||
ZLAndroidApplication.Instance().BatteryLevelToTurnScreenOffOption.getValue() <
|
application.BatteryLevelToTurnScreenOffOption.getValue() <
|
||||||
ZLApplication.Instance().getBatteryLevel()
|
ZLApplication.Instance().getBatteryLevel()
|
||||||
);
|
);
|
||||||
myStartTimer = true;
|
myStartTimer = true;
|
||||||
final int brightnessLevel =
|
final int brightnessLevel =
|
||||||
((ZLAndroidApplication)getApplication()).ScreenBrightnessLevelOption.getValue();
|
application.ScreenBrightnessLevelOption.getValue();
|
||||||
if (brightnessLevel != 0) {
|
if (brightnessLevel != 0) {
|
||||||
setScreenBrightness(brightnessLevel);
|
setScreenBrightness(brightnessLevel);
|
||||||
} else {
|
} else {
|
||||||
|
@ -236,7 +238,7 @@ public abstract class ZLAndroidActivity extends Activity {
|
||||||
private int myChangeCounter;
|
private int myChangeCounter;
|
||||||
private int myOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
|
private int myOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
|
||||||
private void setAutoRotationMode() {
|
private void setAutoRotationMode() {
|
||||||
final ZLAndroidApplication application = ZLAndroidApplication.Instance();
|
final ZLAndroidApplication application = (ZLAndroidApplication)getApplication();
|
||||||
myOrientation = application.AutoOrientationOption.getValue() ?
|
myOrientation = application.AutoOrientationOption.getValue() ?
|
||||||
ActivityInfo.SCREEN_ORIENTATION_SENSOR : ActivityInfo.SCREEN_ORIENTATION_NOSENSOR;
|
ActivityInfo.SCREEN_ORIENTATION_SENSOR : ActivityInfo.SCREEN_ORIENTATION_NOSENSOR;
|
||||||
setRequestedOrientation(myOrientation);
|
setRequestedOrientation(myOrientation);
|
||||||
|
@ -292,9 +294,10 @@ public abstract class ZLAndroidActivity extends Activity {
|
||||||
BroadcastReceiver myBatteryInfoReceiver = new BroadcastReceiver() {
|
BroadcastReceiver myBatteryInfoReceiver = new BroadcastReceiver() {
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
final int level = intent.getIntExtra("level", 100);
|
final int level = intent.getIntExtra("level", 100);
|
||||||
((ZLAndroidApplication)getApplication()).myMainWindow.setBatteryLevel(level);
|
final ZLAndroidApplication application = (ZLAndroidApplication)getApplication();
|
||||||
|
application.myMainWindow.setBatteryLevel(level);
|
||||||
switchWakeLock(
|
switchWakeLock(
|
||||||
ZLAndroidApplication.Instance().BatteryLevelToTurnScreenOffOption.getValue() < level
|
application.BatteryLevelToTurnScreenOffOption.getValue() < level
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -30,8 +30,6 @@ import org.geometerplus.zlibrary.ui.android.application.ZLAndroidApplicationWind
|
||||||
import org.geometerplus.zlibrary.ui.android.image.ZLAndroidImageManager;
|
import org.geometerplus.zlibrary.ui.android.image.ZLAndroidImageManager;
|
||||||
|
|
||||||
public class ZLAndroidApplication extends Application {
|
public class ZLAndroidApplication extends Application {
|
||||||
private static ZLAndroidApplication ourApplication;
|
|
||||||
|
|
||||||
public final ZLBooleanOption AutoOrientationOption = new ZLBooleanOption("LookNFeel", "AutoOrientation", false);
|
public final ZLBooleanOption AutoOrientationOption = new ZLBooleanOption("LookNFeel", "AutoOrientation", false);
|
||||||
public final ZLBooleanOption ShowStatusBarOption = new ZLBooleanOption("LookNFeel", "ShowStatusBar", hasNoHardwareMenuButton());
|
public final ZLBooleanOption ShowStatusBarOption = new ZLBooleanOption("LookNFeel", "ShowStatusBar", hasNoHardwareMenuButton());
|
||||||
public final ZLBooleanOption ShowStatusBarWhenMenuIsActiveOption = new ZLBooleanOption("LookNFeel", "ShowStatusBarWithMenu", true);
|
public final ZLBooleanOption ShowStatusBarWhenMenuIsActiveOption = new ZLBooleanOption("LookNFeel", "ShowStatusBarWithMenu", true);
|
||||||
|
@ -40,14 +38,6 @@ public class ZLAndroidApplication extends Application {
|
||||||
public final ZLIntegerRangeOption ScreenBrightnessLevelOption = new ZLIntegerRangeOption("LookNFeel", "ScreenBrightnessLevel", 0, 100, 0);
|
public final ZLIntegerRangeOption ScreenBrightnessLevelOption = new ZLIntegerRangeOption("LookNFeel", "ScreenBrightnessLevel", 0, 100, 0);
|
||||||
public final ZLBooleanOption DisableButtonLightsOption = new ZLBooleanOption("LookNFeel", "DisableButtonLights", true);
|
public final ZLBooleanOption DisableButtonLightsOption = new ZLBooleanOption("LookNFeel", "DisableButtonLights", true);
|
||||||
|
|
||||||
public static ZLAndroidApplication Instance() {
|
|
||||||
return ourApplication;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ZLAndroidApplication() {
|
|
||||||
ourApplication = this;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean hasNoHardwareMenuButton() {
|
private boolean hasNoHardwareMenuButton() {
|
||||||
return
|
return
|
||||||
// Eken M001
|
// Eken M001
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue