mirror of
https://github.com/HeyPuter/firefox.git
synced 2026-11-25 15:43:10 -10:00
#!/bin/bash set -x pushd mobile/android/base # Can't be present in glob below. rm -rf java/org/mozilla/gecko for i in */ ; do # But is necessary to copy into. mkdir -p java/org/mozilla/gecko hg mv $i java/org/mozilla/gecko ; done hg mv *.java java/org/mozilla/gecko # Move back stuff we didn't want to move. hg mv java/org/mozilla/gecko/crashreporter crashreporter hg mv java/org/mozilla/gecko/docs docs hg mv java/org/mozilla/gecko/locales locales hg mv java/org/mozilla/gecko/resources resources popd
62 lines
2.4 KiB
Java
62 lines
2.4 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.util.ActivityResultHandler;
|
|
import org.mozilla.gecko.util.ActivityResultHandlerMap;
|
|
|
|
import android.app.Activity;
|
|
import android.content.ActivityNotFoundException;
|
|
import android.content.Context;
|
|
import android.content.Intent;
|
|
import android.util.Log;
|
|
|
|
public class ActivityHandlerHelper {
|
|
private static final String LOGTAG = "GeckoActivityHandlerHelper";
|
|
private static final ActivityResultHandlerMap mActivityResultHandlerMap = new ActivityResultHandlerMap();
|
|
|
|
private static int makeRequestCode(ActivityResultHandler aHandler) {
|
|
return mActivityResultHandlerMap.put(aHandler);
|
|
}
|
|
|
|
public static void startIntent(Intent intent, ActivityResultHandler activityResultHandler) {
|
|
startIntentForActivity(GeckoAppShell.getGeckoInterface().getActivity(), intent, activityResultHandler);
|
|
}
|
|
|
|
/**
|
|
* Starts the Activity, catching & logging if the Activity fails to start.
|
|
*
|
|
* We catch to prevent callers from passing in invalid Intents and crashing the browser.
|
|
*
|
|
* @return true if the Activity is successfully started, false otherwise.
|
|
*/
|
|
public static boolean startIntentAndCatch(final String logtag, final Context context, final Intent intent) {
|
|
try {
|
|
context.startActivity(intent);
|
|
return true;
|
|
} catch (final ActivityNotFoundException e) {
|
|
Log.w(logtag, "Activity not found.", e);
|
|
return false;
|
|
} catch (final SecurityException e) {
|
|
Log.w(logtag, "Forbidden to launch activity.", e);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public static void startIntentForActivity(Activity activity, Intent intent, ActivityResultHandler activityResultHandler) {
|
|
activity.startActivityForResult(intent, mActivityResultHandlerMap.put(activityResultHandler));
|
|
}
|
|
|
|
|
|
public static boolean handleActivityResult(int requestCode, int resultCode, Intent data) {
|
|
ActivityResultHandler handler = mActivityResultHandlerMap.getAndRemove(requestCode);
|
|
if (handler != null) {
|
|
handler.onActivityResult(resultCode, data);
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
}
|