mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-03 10:33:33 +00:00
Bug 1476106 - Part 5 - Subscribe PromptService to OrientationChangeListener, too. r=snorp
Now that GeckoScreenOrientation generally offers notifications of screen orientation changes, the PromptService no longer needs to do its own orientation tracking and require to be fed orientation changes from each activity using it. MozReview-Commit-ID: K7KbDsQip7b --HG-- extra : rebase_source : 8b447d9db079794c9ad231a31a52f2787ab742ce
This commit is contained in:
parent
619de3dc05
commit
e93ad5ad8e
@ -2175,10 +2175,6 @@ public abstract class GeckoApp extends GeckoActivity
|
||||
onLocaleChanged(Locales.getLanguageTag(changed));
|
||||
}
|
||||
|
||||
if (mPromptService != null) {
|
||||
mPromptService.changePromptOrientation(newConfig.orientation);
|
||||
}
|
||||
|
||||
super.onConfigurationChanged(newConfig);
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,6 @@ import android.app.PendingIntent;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
@ -187,15 +186,6 @@ public class CustomTabsActivity extends AppCompatActivity
|
||||
Permissions.onRequestPermissionsResult(this, permissions, grantResults);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfigurationChanged(Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
|
||||
if (mPromptService != null) {
|
||||
mPromptService.changePromptOrientation(newConfig.orientation);
|
||||
}
|
||||
}
|
||||
|
||||
private void sendTelemetry() {
|
||||
final SafeIntent startIntent = new SafeIntent(getIntent());
|
||||
|
||||
|
@ -6,23 +6,25 @@
|
||||
package org.mozilla.gecko.prompts;
|
||||
|
||||
import org.mozilla.gecko.EventDispatcher;
|
||||
import org.mozilla.gecko.GeckoScreenOrientation;
|
||||
import org.mozilla.gecko.GeckoScreenOrientation.ScreenOrientation;
|
||||
import org.mozilla.gecko.util.BundleEventListener;
|
||||
import org.mozilla.gecko.util.EventCallback;
|
||||
import org.mozilla.gecko.util.GeckoBundle;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
public class PromptService implements BundleEventListener {
|
||||
public class PromptService implements BundleEventListener,
|
||||
GeckoScreenOrientation.OrientationChangeListener {
|
||||
private static final String LOGTAG = "GeckoPromptService";
|
||||
|
||||
private final Context context;
|
||||
private final EventDispatcher dispatcher;
|
||||
private Prompt currentPrompt;
|
||||
private int currentOrientation;
|
||||
|
||||
public PromptService(final Context context, final EventDispatcher dispatcher) {
|
||||
this.context = context;
|
||||
this.currentOrientation = context.getResources().getConfiguration().orientation;
|
||||
GeckoScreenOrientation.getInstance().addListener(this);
|
||||
this.dispatcher = dispatcher;
|
||||
this.dispatcher.registerUiThreadListener(this,
|
||||
"Prompt:Show",
|
||||
@ -33,6 +35,7 @@ public class PromptService implements BundleEventListener {
|
||||
dispatcher.unregisterUiThreadListener(this,
|
||||
"Prompt:Show",
|
||||
"Prompt:ShowTop");
|
||||
GeckoScreenOrientation.getInstance().removeListener(this);
|
||||
}
|
||||
|
||||
// BundleEventListener implementation
|
||||
@ -49,10 +52,11 @@ public class PromptService implements BundleEventListener {
|
||||
currentPrompt.show(message);
|
||||
}
|
||||
|
||||
public void changePromptOrientation(int newOrientation) {
|
||||
if (currentPrompt != null && currentOrientation != newOrientation) {
|
||||
// OrientationChangeListener implementation
|
||||
@Override
|
||||
public void onScreenOrientationChanged(ScreenOrientation newOrientation) {
|
||||
if (currentPrompt != null) {
|
||||
currentPrompt.resetLayout();
|
||||
}
|
||||
currentOrientation = newOrientation;
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ import android.annotation.TargetApi;
|
||||
import android.app.ActivityManager;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Bitmap;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
@ -174,15 +173,6 @@ public class WebAppActivity extends AppCompatActivity
|
||||
mGeckoSession.loadUri(mManifest.getStartUri().toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfigurationChanged(Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
|
||||
if (mPromptService != null) {
|
||||
mPromptService.changePromptOrientation(newConfig.orientation);
|
||||
}
|
||||
}
|
||||
|
||||
private void fallbackToFennec(String message) {
|
||||
if (message != null) {
|
||||
Toast.makeText(this, message, Toast.LENGTH_LONG).show();
|
||||
|
Loading…
Reference in New Issue
Block a user