mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Merge again
This commit is contained in:
commit
ce788fe121
@ -13,7 +13,7 @@ import android.content.ComponentName;
|
||||
|
||||
public class GeckoActivity extends Activity {
|
||||
private boolean hasStarted = false;
|
||||
private boolean isGeckoActivityOpened = false;
|
||||
private boolean mGeckoActivityOpened = false;
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
@ -31,7 +31,7 @@ public class GeckoActivity extends Activity {
|
||||
// Avoid resume notifications in startup path.
|
||||
if (hasStarted && (getApplication() instanceof GeckoApplication)) {
|
||||
((GeckoApplication) getApplication()).onActivityResume(this);
|
||||
isGeckoActivityOpened = false;
|
||||
mGeckoActivityOpened = false;
|
||||
} else {
|
||||
hasStarted = true;
|
||||
}
|
||||
@ -54,15 +54,19 @@ public class GeckoActivity extends Activity {
|
||||
// If we call an activity from another package, or an open intent (leaving android to resolve)
|
||||
// component has a different package name or it is null.
|
||||
ComponentName component = intent.getComponent();
|
||||
isGeckoActivityOpened = false;
|
||||
mGeckoActivityOpened = false;
|
||||
if (component != null &&
|
||||
component.getPackageName() != null &&
|
||||
component.getPackageName().equals("@ANDROID_PACKAGE_NAME@")) {
|
||||
isGeckoActivityOpened = true;
|
||||
mGeckoActivityOpened = true;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isGeckoActivityOpened() {
|
||||
return mGeckoActivityOpened;
|
||||
}
|
||||
|
||||
public boolean isApplicationInBackground() {
|
||||
return !isGeckoActivityOpened;
|
||||
return ((GeckoApplication) getApplication()).isApplicationInBackground();
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import android.app.Application;
|
||||
|
||||
public class GeckoApplication extends Application {
|
||||
|
||||
private boolean mInBackground = false;
|
||||
private ArrayList<ApplicationLifecycleCallbacks> mListeners;
|
||||
|
||||
public interface ApplicationLifecycleCallbacks {
|
||||
@ -33,19 +34,21 @@ public class GeckoApplication extends Application {
|
||||
}
|
||||
|
||||
public void onActivityPause(GeckoActivity activity) {
|
||||
if (!activity.isApplicationInBackground())
|
||||
if (activity.isGeckoActivityOpened())
|
||||
return;
|
||||
|
||||
if (mListeners == null)
|
||||
return;
|
||||
|
||||
mInBackground = true;
|
||||
|
||||
for (ApplicationLifecycleCallbacks listener: mListeners)
|
||||
listener.onApplicationPause();
|
||||
}
|
||||
|
||||
public void onActivityResume(GeckoActivity activity) {
|
||||
// This is a misnomer. Should have been "wasApplicationInBackground".
|
||||
if (!activity.isApplicationInBackground())
|
||||
// This is a misnomer. Should have been "wasGeckoActivityOpened".
|
||||
if (activity.isGeckoActivityOpened())
|
||||
return;
|
||||
|
||||
if (mListeners == null)
|
||||
@ -53,5 +56,11 @@ public class GeckoApplication extends Application {
|
||||
|
||||
for (ApplicationLifecycleCallbacks listener: mListeners)
|
||||
listener.onApplicationResume();
|
||||
|
||||
mInBackground = false;
|
||||
}
|
||||
|
||||
public boolean isApplicationInBackground() {
|
||||
return mInBackground;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user