mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-17 15:25:52 +00:00
Bug 1277214 - Move remaining SafeIntentUtils functions to IntentUtils. r=grisha
I feel this better follows the util class pattern: IntentUtils acts on Intents as StringUtils would act on Strings. MozReview-Commit-ID: 7n2B9q1KlSy --HG-- rename : mobile/android/base/java/org/mozilla/gecko/util/SafeIntent.java => mobile/android/base/java/org/mozilla/gecko/mozglue/SafeIntent.java extra : rebase_source : ac953ac44f91f1d9b8fa4c0c2a21c539974e9df8
This commit is contained in:
parent
200e23d1c7
commit
dd4052c5e0
@ -51,8 +51,7 @@ import org.mozilla.gecko.javaaddons.JavaAddonManager;
|
||||
import org.mozilla.gecko.media.AudioFocusAgent;
|
||||
import org.mozilla.gecko.menu.GeckoMenu;
|
||||
import org.mozilla.gecko.menu.GeckoMenuItem;
|
||||
import org.mozilla.gecko.mozglue.SafeIntentUtils;
|
||||
import org.mozilla.gecko.util.SafeIntent;
|
||||
import org.mozilla.gecko.mozglue.SafeIntent;
|
||||
import org.mozilla.gecko.overlays.ui.ShareDialog;
|
||||
import org.mozilla.gecko.permissions.Permissions;
|
||||
import org.mozilla.gecko.preferences.ClearOnShutdownPref;
|
||||
@ -783,7 +782,7 @@ public class BrowserApp extends GeckoApp
|
||||
return;
|
||||
}
|
||||
|
||||
final String hostExtra = SafeIntentUtils.getStringExtra(intent, INTENT_KEY_SWITCHBOARD_HOST);
|
||||
final String hostExtra = IntentUtils.getStringExtraSafe(intent, INTENT_KEY_SWITCHBOARD_HOST);
|
||||
final String host = TextUtils.isEmpty(hostExtra) ? DEFAULT_SWITCHBOARD_HOST : hostExtra;
|
||||
|
||||
final String serverUrl;
|
||||
|
@ -8,7 +8,6 @@ package org.mozilla.gecko;
|
||||
import org.mozilla.gecko.AppConstants.Versions;
|
||||
import org.mozilla.gecko.GeckoProfileDirectories.NoMozillaDirectoryException;
|
||||
import org.mozilla.gecko.db.BrowserDB;
|
||||
import org.mozilla.gecko.db.URLMetadataTable;
|
||||
import org.mozilla.gecko.db.UrlAnnotations;
|
||||
import org.mozilla.gecko.favicons.Favicons;
|
||||
import org.mozilla.gecko.favicons.OnFaviconLoadedListener;
|
||||
@ -24,8 +23,8 @@ import org.mozilla.gecko.home.HomeConfig.PanelType;
|
||||
import org.mozilla.gecko.menu.GeckoMenu;
|
||||
import org.mozilla.gecko.menu.GeckoMenuInflater;
|
||||
import org.mozilla.gecko.menu.MenuPanel;
|
||||
import org.mozilla.gecko.mozglue.SafeIntentUtils;
|
||||
import org.mozilla.gecko.util.SafeIntent;
|
||||
import org.mozilla.gecko.util.IntentUtils;
|
||||
import org.mozilla.gecko.mozglue.SafeIntent;
|
||||
import org.mozilla.gecko.mozglue.GeckoLoader;
|
||||
import org.mozilla.gecko.permissions.Permissions;
|
||||
import org.mozilla.gecko.preferences.ClearOnShutdownPref;
|
||||
@ -52,7 +51,6 @@ import android.annotation.SuppressLint;
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
@ -91,7 +89,6 @@ import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.OrientationEventListener;
|
||||
import android.view.SurfaceHolder;
|
||||
import android.view.SurfaceView;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@ -117,7 +114,6 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
@ -1224,7 +1220,7 @@ public abstract class GeckoApp
|
||||
|
||||
GeckoThread.launch();
|
||||
|
||||
Bundle stateBundle = SafeIntentUtils.getBundleExtra(getIntent(), EXTRA_STATE_BUNDLE);
|
||||
Bundle stateBundle = IntentUtils.getBundleExtraSafe(getIntent(), EXTRA_STATE_BUNDLE);
|
||||
if (stateBundle != null) {
|
||||
// Use the state bundle if it was given as an intent extra. This is
|
||||
// only intended to be used internally via Robocop, so a boolean
|
||||
@ -1832,7 +1828,7 @@ public abstract class GeckoApp
|
||||
}
|
||||
|
||||
private boolean getRestartFromIntent() {
|
||||
return SafeIntentUtils.getBooleanExtra(getIntent(), "didRestart", false);
|
||||
return IntentUtils.getBooleanExtraSafe(getIntent(), "didRestart", false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -24,11 +24,11 @@ import org.mozilla.gecko.db.LocalBrowserDB;
|
||||
import org.mozilla.gecko.db.StubBrowserDB;
|
||||
import org.mozilla.gecko.distribution.Distribution;
|
||||
import org.mozilla.gecko.firstrun.FirstrunAnimationContainer;
|
||||
import org.mozilla.gecko.mozglue.SafeIntentUtils;
|
||||
import org.mozilla.gecko.preferences.DistroSharedPrefsImport;
|
||||
import org.mozilla.gecko.util.FileUtils;
|
||||
import org.mozilla.gecko.util.INIParser;
|
||||
import org.mozilla.gecko.util.INISection;
|
||||
import org.mozilla.gecko.util.IntentUtils;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
@ -227,7 +227,7 @@ public final class GeckoProfile {
|
||||
|
||||
final String args;
|
||||
if (context instanceof Activity) {
|
||||
args = SafeIntentUtils.getStringExtra(((Activity) context).getIntent(), "args");
|
||||
args = IntentUtils.getStringExtraSafe(((Activity) context).getIntent(), "args");
|
||||
} else {
|
||||
args = null;
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.mozilla.gecko.gfx.BitmapUtils;
|
||||
import org.mozilla.gecko.util.SafeIntent;
|
||||
import org.mozilla.gecko.mozglue.SafeIntent;
|
||||
import org.mozilla.gecko.util.GeckoEventListener;
|
||||
|
||||
import android.app.PendingIntent;
|
||||
|
@ -20,7 +20,7 @@ import org.mozilla.gecko.annotation.RobocopTarget;
|
||||
import org.mozilla.gecko.AppConstants.Versions;
|
||||
import org.mozilla.gecko.db.BrowserDB;
|
||||
import org.mozilla.gecko.favicons.Favicons;
|
||||
import org.mozilla.gecko.util.SafeIntent;
|
||||
import org.mozilla.gecko.mozglue.SafeIntent;
|
||||
import org.mozilla.gecko.notifications.WhatsNewReceiver;
|
||||
import org.mozilla.gecko.reader.ReaderModeUtils;
|
||||
import org.mozilla.gecko.util.GeckoEventListener;
|
||||
|
@ -16,7 +16,6 @@ import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.os.Environment;
|
||||
import android.util.Log;
|
||||
@ -24,7 +23,6 @@ import android.util.Log;
|
||||
import org.mozilla.gecko.annotation.JNITarget;
|
||||
import org.mozilla.gecko.annotation.RobocopTarget;
|
||||
import org.mozilla.gecko.AppConstants;
|
||||
import org.mozilla.gecko.util.SafeIntent;
|
||||
|
||||
public final class GeckoLoader {
|
||||
private static final String LOGTAG = "GeckoLoader";
|
||||
|
@ -4,7 +4,8 @@
|
||||
* file, you can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package org.mozilla.gecko.util;
|
||||
// This should be in util/, but is here because of build dependency issues.
|
||||
package org.mozilla.gecko.mozglue;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
@ -1,25 +0,0 @@
|
||||
/* 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.mozglue;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import org.mozilla.gecko.util.SafeIntent;
|
||||
|
||||
public class SafeIntentUtils {
|
||||
|
||||
public static Bundle getBundleExtra(final Intent intent, final String name) {
|
||||
return new SafeIntent(intent).getBundleExtra(name);
|
||||
}
|
||||
|
||||
public static String getStringExtra(final Intent intent, final String name) {
|
||||
return new SafeIntent(intent).getStringExtra(name);
|
||||
}
|
||||
|
||||
public static boolean getBooleanExtra(Intent intent, String name, boolean defaultValue) {
|
||||
return new SafeIntent(intent).getBooleanExtra(name, defaultValue);
|
||||
}
|
||||
|
||||
}
|
@ -20,7 +20,7 @@ import org.mozilla.gecko.overlays.service.OverlayActionService;
|
||||
import org.mozilla.gecko.overlays.service.sharemethods.SendTab;
|
||||
import org.mozilla.gecko.overlays.service.sharemethods.ShareMethod;
|
||||
import org.mozilla.gecko.sync.setup.activities.WebURLFinder;
|
||||
import org.mozilla.gecko.mozglue.SafeIntentUtils;
|
||||
import org.mozilla.gecko.util.IntentUtils;
|
||||
import org.mozilla.gecko.util.ThreadUtils;
|
||||
import org.mozilla.gecko.util.UIAsyncTask;
|
||||
|
||||
@ -208,7 +208,7 @@ public class ShareDialog extends Locales.LocaleAwareActivity implements SendTabT
|
||||
bookmarkButton.setBackgroundDrawable(bookmarkButtonDrawable);
|
||||
|
||||
// The URL is usually hiding somewhere in the extra text. Extract it.
|
||||
final String extraText = SafeIntentUtils.getStringExtra(intent, Intent.EXTRA_TEXT);
|
||||
final String extraText = IntentUtils.getStringExtraSafe(intent, Intent.EXTRA_TEXT);
|
||||
if (TextUtils.isEmpty(extraText)) {
|
||||
abortDueToNoURL();
|
||||
return;
|
||||
|
@ -16,7 +16,7 @@ import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import org.mozilla.gecko.util.SafeIntent;
|
||||
import org.mozilla.gecko.mozglue.SafeIntent;
|
||||
|
||||
/**
|
||||
* This class takes over external url loads (Intent.VIEW) from the BrowserApp class. It determines if
|
||||
|
@ -39,7 +39,7 @@ import android.view.WindowManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import org.mozilla.gecko.util.SafeIntent;
|
||||
import org.mozilla.gecko.mozglue.SafeIntent;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
|
@ -7,7 +7,9 @@
|
||||
package org.mozilla.gecko.util;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import org.mozilla.gecko.mozglue.SafeIntent;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.regex.Matcher;
|
||||
@ -56,4 +58,16 @@ public class IntentUtils {
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
public static Bundle getBundleExtraSafe(final Intent intent, final String name) {
|
||||
return new SafeIntent(intent).getBundleExtra(name);
|
||||
}
|
||||
|
||||
public static String getStringExtraSafe(final Intent intent, final String name) {
|
||||
return new SafeIntent(intent).getStringExtra(name);
|
||||
}
|
||||
|
||||
public static boolean getBooleanExtraSafe(final Intent intent, final String name, final boolean defaultValue) {
|
||||
return new SafeIntent(intent).getBooleanExtra(name, defaultValue);
|
||||
}
|
||||
}
|
||||
|
@ -16,10 +16,10 @@ import org.mozilla.gecko.R;
|
||||
import org.mozilla.gecko.SnackbarHelper;
|
||||
import org.mozilla.gecko.Telemetry;
|
||||
import org.mozilla.gecko.TelemetryContract;
|
||||
import org.mozilla.gecko.mozglue.SafeIntentUtils;
|
||||
import org.mozilla.gecko.overlays.ui.ShareDialog;
|
||||
import org.mozilla.gecko.menu.MenuItemSwitcherLayout;
|
||||
import org.mozilla.gecko.util.IOUtils;
|
||||
import org.mozilla.gecko.util.IntentUtils;
|
||||
import org.mozilla.gecko.util.ThreadUtils;
|
||||
|
||||
import android.content.Context;
|
||||
@ -289,7 +289,7 @@ public class GeckoActionProvider {
|
||||
* @param intent share intent to alter in place.
|
||||
*/
|
||||
public void downloadImageForIntent(final Intent intent) {
|
||||
final String src = SafeIntentUtils.getStringExtra(intent, Intent.EXTRA_TEXT);
|
||||
final String src = IntentUtils.getStringExtraSafe(intent, Intent.EXTRA_TEXT);
|
||||
final File dir = GeckoApp.getTempDirectory();
|
||||
|
||||
if (src == null || dir == null) {
|
||||
|
@ -85,7 +85,7 @@ mgjar.sources += ['java/org/mozilla/gecko/' + x for x in [
|
||||
'mozglue/JNIObject.java',
|
||||
'mozglue/NativeReference.java',
|
||||
'mozglue/NativeZip.java',
|
||||
'mozglue/SafeIntentUtils.java',
|
||||
'mozglue/SafeIntent.java',
|
||||
]]
|
||||
mgjar.generated_sources = [] # Keep it this way.
|
||||
mgjar.extra_jars += [
|
||||
@ -128,7 +128,6 @@ gujar.sources += ['java/org/mozilla/gecko/' + x for x in [
|
||||
'util/PrefUtils.java',
|
||||
'util/ProxySelector.java',
|
||||
'util/RawResource.java',
|
||||
'util/SafeIntent.java',
|
||||
'util/StringUtils.java',
|
||||
'util/ThreadUtils.java',
|
||||
'util/UIAsyncTask.java',
|
||||
|
Loading…
Reference in New Issue
Block a user