mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
69f3833cf8
--HG-- rename : mobile/android/base/resources/drawable-hdpi/ic_menu_close_all_tabs.png => mobile/android/base/resources/drawable-hdpi/close.png rename : mobile/android/base/resources/drawable-mdpi/ic_menu_close_all_tabs.png => mobile/android/base/resources/drawable-mdpi/close.png rename : mobile/android/base/resources/drawable-xhdpi/ic_menu_close_all_tabs.png => mobile/android/base/resources/drawable-xhdpi/close.png
114 lines
3.8 KiB
Java
114 lines
3.8 KiB
Java
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
package org.mozilla.gecko;
|
|
|
|
import org.mozilla.gecko.db.BrowserContract;
|
|
import org.mozilla.gecko.db.BrowserDB;
|
|
import org.mozilla.gecko.mozglue.GeckoLoader;
|
|
import org.mozilla.gecko.util.Clipboard;
|
|
import org.mozilla.gecko.util.HardwareUtils;
|
|
import org.mozilla.gecko.util.ThreadUtils;
|
|
|
|
import android.app.Application;
|
|
import android.content.BroadcastReceiver;
|
|
import android.content.Context;
|
|
import android.content.Intent;
|
|
import android.content.IntentFilter;
|
|
|
|
public class GeckoApplication extends Application {
|
|
|
|
private boolean mInited;
|
|
private boolean mInBackground;
|
|
private boolean mPausedGecko;
|
|
private boolean mNeedsRestart;
|
|
|
|
private LightweightTheme mLightweightTheme;
|
|
|
|
protected void initialize() {
|
|
if (mInited)
|
|
return;
|
|
|
|
// workaround for http://code.google.com/p/android/issues/detail?id=20915
|
|
try {
|
|
Class.forName("android.os.AsyncTask");
|
|
} catch (ClassNotFoundException e) {}
|
|
|
|
mLightweightTheme = new LightweightTheme(this);
|
|
|
|
GeckoConnectivityReceiver.getInstance().init(getApplicationContext());
|
|
GeckoBatteryManager.getInstance().init(getApplicationContext());
|
|
GeckoBatteryManager.getInstance().start();
|
|
GeckoNetworkManager.getInstance().init(getApplicationContext());
|
|
MemoryMonitor.getInstance().init(getApplicationContext());
|
|
|
|
BroadcastReceiver receiver = new BroadcastReceiver() {
|
|
@Override
|
|
public void onReceive(Context context, Intent intent) {
|
|
mNeedsRestart = true;
|
|
}
|
|
};
|
|
registerReceiver(receiver, new IntentFilter(Intent.ACTION_LOCALE_CHANGED));
|
|
|
|
mInited = true;
|
|
}
|
|
|
|
protected void onActivityPause(GeckoActivityStatus activity) {
|
|
mInBackground = true;
|
|
|
|
if ((activity.isFinishing() == false) &&
|
|
(activity.isGeckoActivityOpened() == false)) {
|
|
// Notify Gecko that we are pausing; the cache service will be
|
|
// shutdown, closing the disk cache cleanly. If the android
|
|
// low memory killer subsequently kills us, the disk cache will
|
|
// be left in a consistent state, avoiding costly cleanup and
|
|
// re-creation.
|
|
GeckoAppShell.sendEventToGecko(GeckoEvent.createAppBackgroundingEvent());
|
|
mPausedGecko = true;
|
|
|
|
ThreadUtils.postToBackgroundThread(new Runnable() {
|
|
@Override
|
|
public void run() {
|
|
BrowserDB.expireHistory(getContentResolver(),
|
|
BrowserContract.ExpirePriority.NORMAL);
|
|
}
|
|
});
|
|
}
|
|
GeckoConnectivityReceiver.getInstance().stop();
|
|
GeckoNetworkManager.getInstance().stop();
|
|
}
|
|
|
|
protected void onActivityResume(GeckoActivityStatus activity) {
|
|
if (mPausedGecko) {
|
|
GeckoAppShell.sendEventToGecko(GeckoEvent.createAppForegroundingEvent());
|
|
mPausedGecko = false;
|
|
}
|
|
GeckoConnectivityReceiver.getInstance().start();
|
|
GeckoNetworkManager.getInstance().start();
|
|
|
|
mInBackground = false;
|
|
}
|
|
|
|
protected boolean needsRestart() {
|
|
return mNeedsRestart;
|
|
}
|
|
|
|
@Override
|
|
public void onCreate() {
|
|
HardwareUtils.init(getApplicationContext());
|
|
Clipboard.init(getApplicationContext());
|
|
NotificationHelper.init(getApplicationContext());
|
|
GeckoLoader.loadMozGlue();
|
|
super.onCreate();
|
|
}
|
|
|
|
public boolean isApplicationInBackground() {
|
|
return mInBackground;
|
|
}
|
|
|
|
public LightweightTheme getLightweightTheme() {
|
|
return mLightweightTheme;
|
|
}
|
|
}
|