зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1412872 - 8. Remove GeckoAppShell dependency in gecko-view; r=snorp
In the future, GeckoAppShell will only be part of the service process library, and will not be part of the app process library. Therefore, we should minimize GeckoAppShell usage in any GeckoView code that will likely end up in the app process library. In particular, AndroidGamepadManager and Clipboard are made to accept Context as arguments, instead of using GeckoAppShell.getApplicationContext() for getting the Context. MozReview-Commit-ID: G9SC815H5Ku
This commit is contained in:
Родитель
843d67f245
Коммит
db34ad5809
|
@ -75,12 +75,14 @@ public:
|
|||
void StartGamepadMonitoring()
|
||||
{
|
||||
AndroidGamepadManager::Init();
|
||||
java::AndroidGamepadManager::Start();
|
||||
java::AndroidGamepadManager::Start(
|
||||
java::GeckoAppShell::GetApplicationContext());
|
||||
}
|
||||
|
||||
void StopGamepadMonitoring()
|
||||
{
|
||||
java::AndroidGamepadManager::Stop();
|
||||
java::AndroidGamepadManager::Stop(
|
||||
java::GeckoAppShell::GetApplicationContext());
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
|
|
|
@ -155,7 +155,6 @@ import org.mozilla.gecko.trackingprotection.TrackingProtectionPrompt;
|
|||
import org.mozilla.gecko.updater.PostUpdateHandler;
|
||||
import org.mozilla.gecko.updater.UpdateServiceHelper;
|
||||
import org.mozilla.gecko.util.ActivityUtils;
|
||||
import org.mozilla.gecko.util.Clipboard;
|
||||
import org.mozilla.gecko.util.ContextUtils;
|
||||
import org.mozilla.gecko.util.DrawableUtil;
|
||||
import org.mozilla.gecko.util.EventCallback;
|
||||
|
@ -1408,7 +1407,7 @@ public class BrowserApp extends GeckoApp
|
|||
if (itemId == R.id.pasteandgo) {
|
||||
hideFirstrunPager(TelemetryContract.Method.CONTEXT_MENU);
|
||||
|
||||
String text = Clipboard.getText();
|
||||
String text = Clipboard.getText(this);
|
||||
if (!TextUtils.isEmpty(text)) {
|
||||
loadUrlOrKeywordSearch(text);
|
||||
Telemetry.sendUIEvent(TelemetryContract.Event.LOAD_URL, TelemetryContract.Method.CONTEXT_MENU);
|
||||
|
@ -1418,7 +1417,7 @@ public class BrowserApp extends GeckoApp
|
|||
}
|
||||
|
||||
if (itemId == R.id.paste) {
|
||||
String text = Clipboard.getText();
|
||||
String text = Clipboard.getText(this);
|
||||
if (!TextUtils.isEmpty(text)) {
|
||||
enterEditingMode(text);
|
||||
showBrowserSearch();
|
||||
|
@ -1455,7 +1454,7 @@ public class BrowserApp extends GeckoApp
|
|||
if (tab != null) {
|
||||
String url = ReaderModeUtils.stripAboutReaderUrl(tab.getURL());
|
||||
if (url != null) {
|
||||
Clipboard.setText(url);
|
||||
Clipboard.setText(this, url);
|
||||
Telemetry.sendUIEvent(TelemetryContract.Event.ACTION, TelemetryContract.Method.CONTEXT_MENU, "copyurl");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ import android.support.design.widget.Snackbar;
|
|||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
|
||||
import org.mozilla.gecko.Clipboard;
|
||||
import org.mozilla.gecko.GeckoApplication;
|
||||
import org.mozilla.gecko.IntentHelper;
|
||||
import org.mozilla.gecko.R;
|
||||
|
@ -27,7 +28,6 @@ import org.mozilla.gecko.db.BrowserDB;
|
|||
import org.mozilla.gecko.db.SuggestedSites;
|
||||
import org.mozilla.gecko.home.HomePager;
|
||||
import org.mozilla.gecko.reader.SavedReaderViewHelper;
|
||||
import org.mozilla.gecko.util.Clipboard;
|
||||
import org.mozilla.gecko.util.HardwareUtils;
|
||||
import org.mozilla.gecko.util.ThreadUtils;
|
||||
import org.mozilla.gecko.util.UIAsyncTask;
|
||||
|
@ -279,7 +279,7 @@ public abstract class ActivityStreamContextMenu
|
|||
break;
|
||||
|
||||
case R.id.copy_url:
|
||||
Clipboard.setText(item.getUrl());
|
||||
Clipboard.setText(context, item.getUrl());
|
||||
break;
|
||||
|
||||
case R.id.add_homescreen:
|
||||
|
|
|
@ -35,6 +35,7 @@ import android.widget.ProgressBar;
|
|||
|
||||
import org.mozilla.gecko.ActivityHandlerHelper;
|
||||
import org.mozilla.gecko.BrowserApp;
|
||||
import org.mozilla.gecko.Clipboard;
|
||||
import org.mozilla.gecko.DoorHangerPopup;
|
||||
import org.mozilla.gecko.EventDispatcher;
|
||||
import org.mozilla.gecko.FormAssistPopup;
|
||||
|
@ -56,7 +57,6 @@ import org.mozilla.gecko.prompts.PromptListItem;
|
|||
import org.mozilla.gecko.prompts.PromptService;
|
||||
import org.mozilla.gecko.text.TextSelection;
|
||||
import org.mozilla.gecko.util.ActivityUtils;
|
||||
import org.mozilla.gecko.util.Clipboard;
|
||||
import org.mozilla.gecko.util.ColorUtil;
|
||||
import org.mozilla.gecko.util.GeckoBundle;
|
||||
import org.mozilla.gecko.util.IntentUtils;
|
||||
|
@ -552,7 +552,7 @@ public class CustomTabsActivity extends AppCompatActivity
|
|||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
if (!TextUtils.isEmpty(mCurrentUrl)) {
|
||||
Clipboard.setText(mCurrentUrl);
|
||||
Clipboard.setText(CustomTabsActivity.this, mCurrentUrl);
|
||||
SnackbarBuilder.builder(CustomTabsActivity.this)
|
||||
.message(R.string.custom_tabs_hint_url_copy)
|
||||
.duration(Snackbar.LENGTH_SHORT)
|
||||
|
|
|
@ -8,6 +8,7 @@ package org.mozilla.gecko.home;
|
|||
import java.lang.ref.WeakReference;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import org.mozilla.gecko.Clipboard;
|
||||
import org.mozilla.gecko.GeckoApplication;
|
||||
import org.mozilla.gecko.GeckoProfile;
|
||||
import org.mozilla.gecko.GeckoSharedPrefs;
|
||||
|
@ -30,7 +31,6 @@ import org.mozilla.gecko.reader.SavedReaderViewHelper;
|
|||
import org.mozilla.gecko.reader.ReadingListHelper;
|
||||
import org.mozilla.gecko.restrictions.Restrictable;
|
||||
import org.mozilla.gecko.restrictions.Restrictions;
|
||||
import org.mozilla.gecko.util.Clipboard;
|
||||
import org.mozilla.gecko.util.MenuUtils;
|
||||
import org.mozilla.gecko.util.StringUtils;
|
||||
import org.mozilla.gecko.util.ThreadUtils;
|
||||
|
@ -280,7 +280,7 @@ public abstract class HomeFragment extends Fragment {
|
|||
return false;
|
||||
}
|
||||
|
||||
Clipboard.setText(info.url);
|
||||
Clipboard.setText(context, info.url);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ import android.graphics.Rect;
|
|||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import org.mozilla.gecko.BrowserApp;
|
||||
import org.mozilla.gecko.Clipboard;
|
||||
import org.mozilla.gecko.GeckoSharedPrefs;
|
||||
import org.mozilla.gecko.R;
|
||||
import org.mozilla.gecko.Tab;
|
||||
|
@ -32,7 +33,6 @@ import org.mozilla.gecko.tabs.TabHistoryController;
|
|||
import org.mozilla.gecko.toolbar.ToolbarDisplayLayout.OnStopListener;
|
||||
import org.mozilla.gecko.toolbar.ToolbarDisplayLayout.OnTitleChangeListener;
|
||||
import org.mozilla.gecko.toolbar.ToolbarDisplayLayout.UpdateFlags;
|
||||
import org.mozilla.gecko.util.Clipboard;
|
||||
import org.mozilla.gecko.util.HardwareUtils;
|
||||
import org.mozilla.gecko.util.MenuUtils;
|
||||
import org.mozilla.gecko.util.WindowUtil;
|
||||
|
@ -251,7 +251,7 @@ public abstract class BrowserToolbar extends ThemedRelativeLayout
|
|||
MenuInflater inflater = activity.getMenuInflater();
|
||||
inflater.inflate(R.menu.titlebar_contextmenu, menu);
|
||||
|
||||
String clipboard = Clipboard.getText();
|
||||
String clipboard = Clipboard.getText(context);
|
||||
if (TextUtils.isEmpty(clipboard)) {
|
||||
menu.findItem(R.id.pasteandgo).setVisible(false);
|
||||
menu.findItem(R.id.paste).setVisible(false);
|
||||
|
|
|
@ -146,38 +146,38 @@ public class AndroidGamepadManager {
|
|||
}
|
||||
|
||||
@WrapForJNI
|
||||
private static void start() {
|
||||
private static void start(final Context context) {
|
||||
ThreadUtils.postToUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
doStart();
|
||||
doStart(context);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* package */ static void doStart() {
|
||||
/* package */ static void doStart(final Context context) {
|
||||
ThreadUtils.assertOnUiThread();
|
||||
if (!sStarted) {
|
||||
scanForGamepads();
|
||||
addDeviceListener();
|
||||
addDeviceListener(context);
|
||||
sStarted = true;
|
||||
}
|
||||
}
|
||||
|
||||
@WrapForJNI
|
||||
private static void stop() {
|
||||
private static void stop(final Context context) {
|
||||
ThreadUtils.postToUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
doStop();
|
||||
doStop(context);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* package */ static void doStop() {
|
||||
/* package */ static void doStop(final Context context) {
|
||||
ThreadUtils.assertOnUiThread();
|
||||
if (sStarted) {
|
||||
removeDeviceListener();
|
||||
removeDeviceListener(context);
|
||||
sPendingGamepads.clear();
|
||||
sGamepads.clear();
|
||||
sStarted = false;
|
||||
|
@ -362,7 +362,7 @@ public class AndroidGamepadManager {
|
|||
sGamepads.remove(deviceId);
|
||||
}
|
||||
|
||||
private static void addDeviceListener() {
|
||||
private static void addDeviceListener(final Context context) {
|
||||
if (Build.VERSION.SDK_INT < 16) {
|
||||
// Poll known gamepads to see if they've disappeared.
|
||||
sPollTimer = new Timer();
|
||||
|
@ -408,13 +408,12 @@ public class AndroidGamepadManager {
|
|||
}
|
||||
};
|
||||
final InputManager im = (InputManager)
|
||||
GeckoAppShell.getApplicationContext()
|
||||
.getSystemService(Context.INPUT_SERVICE);
|
||||
context.getSystemService(Context.INPUT_SERVICE);
|
||||
im.registerInputDeviceListener(sListener, ThreadUtils.getUiHandler());
|
||||
}
|
||||
}
|
||||
|
||||
private static void removeDeviceListener() {
|
||||
private static void removeDeviceListener(final Context context) {
|
||||
if (Build.VERSION.SDK_INT < 16) {
|
||||
if (sPollTimer != null) {
|
||||
sPollTimer.cancel();
|
||||
|
@ -422,8 +421,7 @@ public class AndroidGamepadManager {
|
|||
}
|
||||
} else {
|
||||
final InputManager im = (InputManager)
|
||||
GeckoAppShell.getApplicationContext()
|
||||
.getSystemService(Context.INPUT_SERVICE);
|
||||
context.getSystemService(Context.INPUT_SERVICE);
|
||||
im.unregisterInputDeviceListener(sListener);
|
||||
sListener = null;
|
||||
}
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
* 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.util;
|
||||
package org.mozilla.gecko;
|
||||
|
||||
import java.util.concurrent.SynchronousQueue;
|
||||
|
||||
import org.mozilla.gecko.annotation.WrapForJNI;
|
||||
import org.mozilla.gecko.GeckoAppShell;
|
||||
import org.mozilla.gecko.util.ThreadUtils;
|
||||
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.ClipData;
|
||||
|
@ -22,19 +22,19 @@ public final class Clipboard {
|
|||
}
|
||||
|
||||
@WrapForJNI(calledFrom = "gecko")
|
||||
public static String getText() {
|
||||
public static String getText(final Context context) {
|
||||
// If we're on the UI thread or the background thread, we have a looper on the thread
|
||||
// and can just call this directly. For any other threads, post the call to the
|
||||
// background thread.
|
||||
|
||||
if (ThreadUtils.isOnUiThread() || ThreadUtils.isOnBackgroundThread()) {
|
||||
return getClipboardTextImpl();
|
||||
return getClipboardTextImpl(context);
|
||||
}
|
||||
|
||||
ThreadUtils.postToBackgroundThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
String text = getClipboardTextImpl();
|
||||
String text = getClipboardTextImpl(context);
|
||||
try {
|
||||
sClipboardQueue.put(text != null ? text : "");
|
||||
} catch (InterruptedException ie) { }
|
||||
|
@ -49,16 +49,12 @@ public final class Clipboard {
|
|||
}
|
||||
|
||||
@WrapForJNI(calledFrom = "gecko")
|
||||
public static void setText(final CharSequence text) {
|
||||
public static void setText(final Context context, final CharSequence text) {
|
||||
ThreadUtils.postToBackgroundThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// In API Level 11 and above, CLIPBOARD_SERVICE returns android.content.ClipboardManager,
|
||||
// which is a subclass of android.text.ClipboardManager.
|
||||
final Context context = GeckoAppShell.getApplicationContext();
|
||||
if (context == null) {
|
||||
return;
|
||||
}
|
||||
final ClipboardManager cm = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
final ClipData clip = ClipData.newPlainText("Text", text);
|
||||
try {
|
||||
|
@ -77,11 +73,7 @@ public final class Clipboard {
|
|||
* @return true if the clipboard is nonempty, false otherwise.
|
||||
*/
|
||||
@WrapForJNI(calledFrom = "gecko")
|
||||
public static boolean hasText() {
|
||||
final Context context = GeckoAppShell.getApplicationContext();
|
||||
if (context == null) {
|
||||
return false;
|
||||
}
|
||||
public static boolean hasText(final Context context) {
|
||||
final ClipboardManager cm = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
return cm.hasPrimaryClip();
|
||||
}
|
||||
|
@ -90,8 +82,8 @@ public final class Clipboard {
|
|||
* Deletes all text from the clipboard.
|
||||
*/
|
||||
@WrapForJNI(calledFrom = "gecko")
|
||||
public static void clearText() {
|
||||
setText(null);
|
||||
public static void clearText(final Context context) {
|
||||
setText(context, null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -100,12 +92,9 @@ public final class Clipboard {
|
|||
* present on the thread.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
static String getClipboardTextImpl() {
|
||||
final Context context = GeckoAppShell.getApplicationContext();
|
||||
if (context == null) {
|
||||
return null;
|
||||
}
|
||||
final ClipboardManager cm = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
static String getClipboardTextImpl(final Context context) {
|
||||
final ClipboardManager cm = (ClipboardManager)
|
||||
context.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
if (cm.hasPrimaryClip()) {
|
||||
ClipData clip = cm.getPrimaryClip();
|
||||
if (clip != null) {
|
||||
|
|
|
@ -9,7 +9,6 @@ package org.mozilla.gecko;
|
|||
import org.mozilla.gecko.annotation.ReflectionTarget;
|
||||
import org.mozilla.gecko.annotation.RobocopTarget;
|
||||
import org.mozilla.gecko.annotation.WrapForJNI;
|
||||
import org.mozilla.gecko.GeckoAppShell;
|
||||
import org.mozilla.gecko.mozglue.JNIObject;
|
||||
import org.mozilla.gecko.util.BundleEventListener;
|
||||
import org.mozilla.gecko.util.EventCallback;
|
||||
|
|
|
@ -11,7 +11,6 @@ import java.lang.reflect.Proxy;
|
|||
|
||||
import org.mozilla.gecko.gfx.DynamicToolbarAnimator;
|
||||
import org.mozilla.gecko.util.ActivityUtils;
|
||||
import org.mozilla.gecko.util.Clipboard;
|
||||
import org.mozilla.gecko.util.GamepadUtils;
|
||||
import org.mozilla.gecko.util.ThreadUtils;
|
||||
|
||||
|
@ -134,8 +133,9 @@ class GeckoInputConnection
|
|||
|
||||
@Override
|
||||
public boolean performContextMenuAction(int id) {
|
||||
Editable editable = getEditable();
|
||||
if (editable == null) {
|
||||
final View view = getView();
|
||||
final Editable editable = getEditable();
|
||||
if (view == null || editable == null) {
|
||||
return false;
|
||||
}
|
||||
int selStart = Selection.getSelectionStart(editable);
|
||||
|
@ -149,18 +149,17 @@ class GeckoInputConnection
|
|||
// If selection is empty, we'll select everything
|
||||
if (selStart == selEnd) {
|
||||
// Fill the clipboard
|
||||
Clipboard.setText(editable);
|
||||
Clipboard.setText(view.getContext(), editable);
|
||||
editable.clear();
|
||||
} else {
|
||||
Clipboard.setText(
|
||||
editable.toString().substring(
|
||||
Math.min(selStart, selEnd),
|
||||
Math.max(selStart, selEnd)));
|
||||
Clipboard.setText(view.getContext(),
|
||||
editable.subSequence(Math.min(selStart, selEnd),
|
||||
Math.max(selStart, selEnd)));
|
||||
editable.delete(selStart, selEnd);
|
||||
}
|
||||
break;
|
||||
case android.R.id.paste:
|
||||
commitText(Clipboard.getText(), 1);
|
||||
commitText(Clipboard.getText(view.getContext()), 1);
|
||||
break;
|
||||
case android.R.id.copy:
|
||||
// Copy the current selection or the empty string if nothing is selected.
|
||||
|
@ -168,7 +167,7 @@ class GeckoInputConnection
|
|||
editable.toString().substring(
|
||||
Math.min(selStart, selEnd),
|
||||
Math.max(selStart, selEnd));
|
||||
Clipboard.setText(copiedText);
|
||||
Clipboard.setText(view.getContext(), copiedText);
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -1029,24 +1029,23 @@ public class GeckoView extends LayerView {
|
|||
}
|
||||
|
||||
@Override // FileCallback
|
||||
public void confirm(final Uri uri) {
|
||||
public void confirm(final Context context, final Uri uri) {
|
||||
if ("file".equals(mType)) {
|
||||
confirm(uri == null ? null : new Uri[] { uri });
|
||||
confirm(context, uri == null ? null : new Uri[] { uri });
|
||||
return;
|
||||
} else {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
|
||||
private static String getFile(final Uri uri) {
|
||||
private static String getFile(final Context context, final Uri uri) {
|
||||
if (uri == null) {
|
||||
return null;
|
||||
}
|
||||
if ("file".equals(uri.getScheme())) {
|
||||
return uri.getPath();
|
||||
}
|
||||
final ContentResolver cr =
|
||||
GeckoAppShell.getApplicationContext().getContentResolver();
|
||||
final ContentResolver cr = context.getContentResolver();
|
||||
final Cursor cur = cr.query(uri, new String[] { "_data" }, /* selection */ null,
|
||||
/* args */ null, /* sort */ null);
|
||||
if (cur == null) {
|
||||
|
@ -1073,14 +1072,14 @@ public class GeckoView extends LayerView {
|
|||
}
|
||||
|
||||
@Override // FileCallback
|
||||
public void confirm(final Uri[] uris) {
|
||||
public void confirm(final Context context, final Uri[] uris) {
|
||||
if ("single".equals(mMode) && (uris == null || uris.length != 1)) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
if ("file".equals(mType)) {
|
||||
final String[] paths = new String[uris != null ? uris.length : 0];
|
||||
for (int i = 0; i < paths.length; i++) {
|
||||
paths[i] = getFile(uris[i]);
|
||||
paths[i] = getFile(context, uris[i]);
|
||||
if (paths[i] == null) {
|
||||
Log.e(LOGTAG, "Only file URI is supported: " + uris[i]);
|
||||
}
|
||||
|
@ -1767,17 +1766,19 @@ public class GeckoView extends LayerView {
|
|||
* Called by the prompt implementation when the user makes a file selection in
|
||||
* single-selection mode.
|
||||
*
|
||||
* @param context An application Context for parsing URIs.
|
||||
* @param uri The URI of the selected file.
|
||||
*/
|
||||
void confirm(Uri uri);
|
||||
void confirm(Context context, Uri uri);
|
||||
|
||||
/**
|
||||
* Called by the prompt implementation when the user makes file selections in
|
||||
* multiple-selection mode.
|
||||
*
|
||||
* @param context An application Context for parsing URIs.
|
||||
* @param uris Array of URI objects for the selected files.
|
||||
*/
|
||||
void confirm(Uri[] uris);
|
||||
void confirm(Context context, Uri[] uris);
|
||||
}
|
||||
|
||||
static final int FILE_TYPE_SINGLE = 1;
|
||||
|
|
|
@ -8,7 +8,6 @@ package org.mozilla.gecko.gfx;
|
|||
import org.mozilla.gecko.annotation.RobocopTarget;
|
||||
import org.mozilla.gecko.annotation.WrapForJNI;
|
||||
import org.mozilla.gecko.EventDispatcher;
|
||||
import org.mozilla.gecko.GeckoAppShell;
|
||||
import org.mozilla.gecko.util.GeckoBundle;
|
||||
|
||||
import android.content.Context;
|
||||
|
|
|
@ -11,7 +11,6 @@ import java.nio.IntBuffer;
|
|||
import org.mozilla.gecko.AndroidGamepadManager;
|
||||
import org.mozilla.gecko.annotation.RobocopTarget;
|
||||
import org.mozilla.gecko.annotation.WrapForJNI;
|
||||
import org.mozilla.gecko.GeckoAppShell;
|
||||
import org.mozilla.gecko.GeckoThread;
|
||||
import org.mozilla.gecko.mozglue.JNIObject;
|
||||
import org.mozilla.gecko.util.ThreadUtils;
|
||||
|
|
|
@ -5,8 +5,6 @@
|
|||
|
||||
package org.mozilla.gecko.gfx;
|
||||
|
||||
import org.mozilla.gecko.GeckoAppShell;
|
||||
import org.mozilla.gecko.GeckoThread;
|
||||
import org.mozilla.gecko.annotation.WrapForJNI;
|
||||
import org.mozilla.gecko.gfx.DynamicToolbarAnimator.PinReason;
|
||||
import org.mozilla.gecko.mozglue.JNIObject;
|
||||
|
@ -22,12 +20,14 @@ import android.view.View;
|
|||
import android.view.InputDevice;
|
||||
|
||||
class NativePanZoomController extends JNIObject implements PanZoomController {
|
||||
private final float MAX_SCROLL;
|
||||
|
||||
private final LayerView mView;
|
||||
|
||||
private boolean mDestroyed;
|
||||
private Overscroll mOverscroll;
|
||||
private float mPointerScrollFactor;
|
||||
private long mLastDownTime;
|
||||
private static final float MAX_SCROLL = 0.075f * GeckoAppShell.getDpi();
|
||||
|
||||
@WrapForJNI(calledFrom = "ui")
|
||||
private native boolean handleMotionEvent(
|
||||
|
@ -138,6 +138,8 @@ class NativePanZoomController extends JNIObject implements PanZoomController {
|
|||
|
||||
|
||||
NativePanZoomController(View view) {
|
||||
MAX_SCROLL = 0.075f * view.getContext().getResources().getDisplayMetrics().densityDpi;
|
||||
|
||||
mView = (LayerView) view;
|
||||
|
||||
TypedValue outValue = new TypedValue();
|
||||
|
|
|
@ -5,17 +5,12 @@
|
|||
|
||||
package org.mozilla.gecko.gfx;
|
||||
|
||||
import org.mozilla.gecko.GeckoAppShell;
|
||||
|
||||
import android.graphics.PointF;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
|
||||
public interface PanZoomController {
|
||||
// Threshold for sending touch move events to content
|
||||
public static final float CLICK_THRESHOLD = 1 / 50f * GeckoAppShell.getDpi();
|
||||
|
||||
static class Factory {
|
||||
static PanZoomController create(View view) {
|
||||
return new NativePanZoomController(view);
|
||||
|
|
|
@ -753,7 +753,8 @@ final class BasicGeckoViewPrompt implements GeckoView.PromptDelegate {
|
|||
}
|
||||
}
|
||||
|
||||
public void onFileCallbackResult(final int resultCode, final Intent data) {
|
||||
public void onFileCallbackResult(final Context context, final int resultCode,
|
||||
final Intent data) {
|
||||
if (mFileCallback == null) {
|
||||
return;
|
||||
}
|
||||
|
@ -771,7 +772,7 @@ final class BasicGeckoViewPrompt implements GeckoView.PromptDelegate {
|
|||
|
||||
if (mFileType == FILE_TYPE_SINGLE ||
|
||||
(mFileType == FILE_TYPE_MULTIPLE && clip == null)) {
|
||||
callback.confirm(uri);
|
||||
callback.confirm(context, uri);
|
||||
|
||||
} else if (mFileType == FILE_TYPE_MULTIPLE) {
|
||||
if (clip == null) {
|
||||
|
@ -784,7 +785,7 @@ final class BasicGeckoViewPrompt implements GeckoView.PromptDelegate {
|
|||
for (int i = 0; i < count; i++) {
|
||||
uris.add(clip.getItemAt(i).getUri());
|
||||
}
|
||||
callback.confirm(uris.toArray(new Uri[uris.size()]));
|
||||
callback.confirm(context, uris.toArray(new Uri[uris.size()]));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -108,7 +108,7 @@ public class GeckoViewActivity extends Activity {
|
|||
if (requestCode == REQUEST_FILE_PICKER) {
|
||||
final BasicGeckoViewPrompt prompt = (BasicGeckoViewPrompt)
|
||||
mGeckoView.getPromptDelegate();
|
||||
prompt.onFileCallbackResult(resultCode, data);
|
||||
prompt.onFileCallbackResult(this, resultCode, data);
|
||||
} else {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
package org.mozilla.gecko.tests;
|
||||
|
||||
import org.mozilla.gecko.Actions;
|
||||
import org.mozilla.gecko.util.Clipboard;
|
||||
import org.mozilla.gecko.Clipboard;
|
||||
import org.mozilla.gecko.Element;
|
||||
import org.mozilla.gecko.R;
|
||||
|
||||
|
@ -81,7 +81,8 @@ abstract class ContentContextMenuTest extends PixelTest {
|
|||
boolean correctText = waitForCondition(new Condition() {
|
||||
@Override
|
||||
public boolean isSatisfied() {
|
||||
final String clipboardText = Clipboard.getText();
|
||||
final String clipboardText =
|
||||
Clipboard.getText(getInstrumentation().getContext());
|
||||
mAsserter.dumpLog("Clipboard text = " + clipboardText + " , expected text = " + copiedText);
|
||||
return clipboardText.contains(copiedText);
|
||||
}
|
||||
|
|
|
@ -318,7 +318,7 @@ AndroidBridge::GetClipboardText(nsAString& aText)
|
|||
{
|
||||
ALOG_BRIDGE("AndroidBridge::GetClipboardText");
|
||||
|
||||
auto text = Clipboard::GetText();
|
||||
auto text = Clipboard::GetText(GeckoAppShell::GetApplicationContext());
|
||||
|
||||
if (text) {
|
||||
aText = text->ToString();
|
||||
|
|
|
@ -35,17 +35,52 @@ constexpr char AndroidGamepadManager::OnGamepadChange_t::signature[];
|
|||
constexpr char AndroidGamepadManager::Start_t::name[];
|
||||
constexpr char AndroidGamepadManager::Start_t::signature[];
|
||||
|
||||
auto AndroidGamepadManager::Start() -> void
|
||||
auto AndroidGamepadManager::Start(mozilla::jni::Object::Param a0) -> void
|
||||
{
|
||||
return mozilla::jni::Method<Start_t>::Call(AndroidGamepadManager::Context(), nullptr);
|
||||
return mozilla::jni::Method<Start_t>::Call(AndroidGamepadManager::Context(), nullptr, a0);
|
||||
}
|
||||
|
||||
constexpr char AndroidGamepadManager::Stop_t::name[];
|
||||
constexpr char AndroidGamepadManager::Stop_t::signature[];
|
||||
|
||||
auto AndroidGamepadManager::Stop() -> void
|
||||
auto AndroidGamepadManager::Stop(mozilla::jni::Object::Param a0) -> void
|
||||
{
|
||||
return mozilla::jni::Method<Stop_t>::Call(AndroidGamepadManager::Context(), nullptr);
|
||||
return mozilla::jni::Method<Stop_t>::Call(AndroidGamepadManager::Context(), nullptr, a0);
|
||||
}
|
||||
|
||||
const char Clipboard::name[] =
|
||||
"org/mozilla/gecko/Clipboard";
|
||||
|
||||
constexpr char Clipboard::ClearText_t::name[];
|
||||
constexpr char Clipboard::ClearText_t::signature[];
|
||||
|
||||
auto Clipboard::ClearText(mozilla::jni::Object::Param a0) -> void
|
||||
{
|
||||
return mozilla::jni::Method<ClearText_t>::Call(Clipboard::Context(), nullptr, a0);
|
||||
}
|
||||
|
||||
constexpr char Clipboard::GetText_t::name[];
|
||||
constexpr char Clipboard::GetText_t::signature[];
|
||||
|
||||
auto Clipboard::GetText(mozilla::jni::Object::Param a0) -> mozilla::jni::String::LocalRef
|
||||
{
|
||||
return mozilla::jni::Method<GetText_t>::Call(Clipboard::Context(), nullptr, a0);
|
||||
}
|
||||
|
||||
constexpr char Clipboard::HasText_t::name[];
|
||||
constexpr char Clipboard::HasText_t::signature[];
|
||||
|
||||
auto Clipboard::HasText(mozilla::jni::Object::Param a0) -> bool
|
||||
{
|
||||
return mozilla::jni::Method<HasText_t>::Call(Clipboard::Context(), nullptr, a0);
|
||||
}
|
||||
|
||||
constexpr char Clipboard::SetText_t::name[];
|
||||
constexpr char Clipboard::SetText_t::signature[];
|
||||
|
||||
auto Clipboard::SetText(mozilla::jni::Object::Param a0, mozilla::jni::String::Param a1) -> void
|
||||
{
|
||||
return mozilla::jni::Method<SetText_t>::Call(Clipboard::Context(), nullptr, a0, a1);
|
||||
}
|
||||
|
||||
const char EventDispatcher::name[] =
|
||||
|
@ -2520,41 +2555,6 @@ auto GeckoServiceChildProcess::GetEditableParent(int64_t a0, int64_t a1) -> mozi
|
|||
return mozilla::jni::Method<GetEditableParent_t>::Call(GeckoServiceChildProcess::Context(), nullptr, a0, a1);
|
||||
}
|
||||
|
||||
const char Clipboard::name[] =
|
||||
"org/mozilla/gecko/util/Clipboard";
|
||||
|
||||
constexpr char Clipboard::ClearText_t::name[];
|
||||
constexpr char Clipboard::ClearText_t::signature[];
|
||||
|
||||
auto Clipboard::ClearText() -> void
|
||||
{
|
||||
return mozilla::jni::Method<ClearText_t>::Call(Clipboard::Context(), nullptr);
|
||||
}
|
||||
|
||||
constexpr char Clipboard::GetText_t::name[];
|
||||
constexpr char Clipboard::GetText_t::signature[];
|
||||
|
||||
auto Clipboard::GetText() -> mozilla::jni::String::LocalRef
|
||||
{
|
||||
return mozilla::jni::Method<GetText_t>::Call(Clipboard::Context(), nullptr);
|
||||
}
|
||||
|
||||
constexpr char Clipboard::HasText_t::name[];
|
||||
constexpr char Clipboard::HasText_t::signature[];
|
||||
|
||||
auto Clipboard::HasText() -> bool
|
||||
{
|
||||
return mozilla::jni::Method<HasText_t>::Call(Clipboard::Context(), nullptr);
|
||||
}
|
||||
|
||||
constexpr char Clipboard::SetText_t::name[];
|
||||
constexpr char Clipboard::SetText_t::signature[];
|
||||
|
||||
auto Clipboard::SetText(mozilla::jni::String::Param a0) -> void
|
||||
{
|
||||
return mozilla::jni::Method<SetText_t>::Call(Clipboard::Context(), nullptr, a0);
|
||||
}
|
||||
|
||||
const char EventCallback::name[] =
|
||||
"org/mozilla/gecko/util/EventCallback";
|
||||
|
||||
|
|
|
@ -106,10 +106,11 @@ public:
|
|||
typedef AndroidGamepadManager Owner;
|
||||
typedef void ReturnType;
|
||||
typedef void SetterType;
|
||||
typedef mozilla::jni::Args<> Args;
|
||||
typedef mozilla::jni::Args<
|
||||
mozilla::jni::Object::Param> Args;
|
||||
static constexpr char name[] = "start";
|
||||
static constexpr char signature[] =
|
||||
"()V";
|
||||
"(Landroid/content/Context;)V";
|
||||
static const bool isStatic = true;
|
||||
static const mozilla::jni::ExceptionMode exceptionMode =
|
||||
mozilla::jni::ExceptionMode::ABORT;
|
||||
|
@ -119,16 +120,17 @@ public:
|
|||
mozilla::jni::DispatchTarget::CURRENT;
|
||||
};
|
||||
|
||||
static auto Start() -> void;
|
||||
static auto Start(mozilla::jni::Object::Param) -> void;
|
||||
|
||||
struct Stop_t {
|
||||
typedef AndroidGamepadManager Owner;
|
||||
typedef void ReturnType;
|
||||
typedef void SetterType;
|
||||
typedef mozilla::jni::Args<> Args;
|
||||
typedef mozilla::jni::Args<
|
||||
mozilla::jni::Object::Param> Args;
|
||||
static constexpr char name[] = "stop";
|
||||
static constexpr char signature[] =
|
||||
"()V";
|
||||
"(Landroid/content/Context;)V";
|
||||
static const bool isStatic = true;
|
||||
static const mozilla::jni::ExceptionMode exceptionMode =
|
||||
mozilla::jni::ExceptionMode::ABORT;
|
||||
|
@ -138,7 +140,7 @@ public:
|
|||
mozilla::jni::DispatchTarget::CURRENT;
|
||||
};
|
||||
|
||||
static auto Stop() -> void;
|
||||
static auto Stop(mozilla::jni::Object::Param) -> void;
|
||||
|
||||
static const mozilla::jni::CallingThread callingThread =
|
||||
mozilla::jni::CallingThread::ANY;
|
||||
|
@ -146,6 +148,99 @@ public:
|
|||
template<class Impl> class Natives;
|
||||
};
|
||||
|
||||
class Clipboard : public mozilla::jni::ObjectBase<Clipboard>
|
||||
{
|
||||
public:
|
||||
static const char name[];
|
||||
|
||||
explicit Clipboard(const Context& ctx) : ObjectBase<Clipboard>(ctx) {}
|
||||
|
||||
struct ClearText_t {
|
||||
typedef Clipboard Owner;
|
||||
typedef void ReturnType;
|
||||
typedef void SetterType;
|
||||
typedef mozilla::jni::Args<
|
||||
mozilla::jni::Object::Param> Args;
|
||||
static constexpr char name[] = "clearText";
|
||||
static constexpr char signature[] =
|
||||
"(Landroid/content/Context;)V";
|
||||
static const bool isStatic = true;
|
||||
static const mozilla::jni::ExceptionMode exceptionMode =
|
||||
mozilla::jni::ExceptionMode::ABORT;
|
||||
static const mozilla::jni::CallingThread callingThread =
|
||||
mozilla::jni::CallingThread::GECKO;
|
||||
static const mozilla::jni::DispatchTarget dispatchTarget =
|
||||
mozilla::jni::DispatchTarget::CURRENT;
|
||||
};
|
||||
|
||||
static auto ClearText(mozilla::jni::Object::Param) -> void;
|
||||
|
||||
struct GetText_t {
|
||||
typedef Clipboard Owner;
|
||||
typedef mozilla::jni::String::LocalRef ReturnType;
|
||||
typedef mozilla::jni::String::Param SetterType;
|
||||
typedef mozilla::jni::Args<
|
||||
mozilla::jni::Object::Param> Args;
|
||||
static constexpr char name[] = "getText";
|
||||
static constexpr char signature[] =
|
||||
"(Landroid/content/Context;)Ljava/lang/String;";
|
||||
static const bool isStatic = true;
|
||||
static const mozilla::jni::ExceptionMode exceptionMode =
|
||||
mozilla::jni::ExceptionMode::ABORT;
|
||||
static const mozilla::jni::CallingThread callingThread =
|
||||
mozilla::jni::CallingThread::GECKO;
|
||||
static const mozilla::jni::DispatchTarget dispatchTarget =
|
||||
mozilla::jni::DispatchTarget::CURRENT;
|
||||
};
|
||||
|
||||
static auto GetText(mozilla::jni::Object::Param) -> mozilla::jni::String::LocalRef;
|
||||
|
||||
struct HasText_t {
|
||||
typedef Clipboard Owner;
|
||||
typedef bool ReturnType;
|
||||
typedef bool SetterType;
|
||||
typedef mozilla::jni::Args<
|
||||
mozilla::jni::Object::Param> Args;
|
||||
static constexpr char name[] = "hasText";
|
||||
static constexpr char signature[] =
|
||||
"(Landroid/content/Context;)Z";
|
||||
static const bool isStatic = true;
|
||||
static const mozilla::jni::ExceptionMode exceptionMode =
|
||||
mozilla::jni::ExceptionMode::ABORT;
|
||||
static const mozilla::jni::CallingThread callingThread =
|
||||
mozilla::jni::CallingThread::GECKO;
|
||||
static const mozilla::jni::DispatchTarget dispatchTarget =
|
||||
mozilla::jni::DispatchTarget::CURRENT;
|
||||
};
|
||||
|
||||
static auto HasText(mozilla::jni::Object::Param) -> bool;
|
||||
|
||||
struct SetText_t {
|
||||
typedef Clipboard Owner;
|
||||
typedef void ReturnType;
|
||||
typedef void SetterType;
|
||||
typedef mozilla::jni::Args<
|
||||
mozilla::jni::Object::Param,
|
||||
mozilla::jni::String::Param> Args;
|
||||
static constexpr char name[] = "setText";
|
||||
static constexpr char signature[] =
|
||||
"(Landroid/content/Context;Ljava/lang/CharSequence;)V";
|
||||
static const bool isStatic = true;
|
||||
static const mozilla::jni::ExceptionMode exceptionMode =
|
||||
mozilla::jni::ExceptionMode::ABORT;
|
||||
static const mozilla::jni::CallingThread callingThread =
|
||||
mozilla::jni::CallingThread::GECKO;
|
||||
static const mozilla::jni::DispatchTarget dispatchTarget =
|
||||
mozilla::jni::DispatchTarget::CURRENT;
|
||||
};
|
||||
|
||||
static auto SetText(mozilla::jni::Object::Param, mozilla::jni::String::Param) -> void;
|
||||
|
||||
static const mozilla::jni::CallingThread callingThread =
|
||||
mozilla::jni::CallingThread::GECKO;
|
||||
|
||||
};
|
||||
|
||||
class EventDispatcher : public mozilla::jni::ObjectBase<EventDispatcher>
|
||||
{
|
||||
public:
|
||||
|
@ -7096,95 +7191,6 @@ public:
|
|||
|
||||
};
|
||||
|
||||
class Clipboard : public mozilla::jni::ObjectBase<Clipboard>
|
||||
{
|
||||
public:
|
||||
static const char name[];
|
||||
|
||||
explicit Clipboard(const Context& ctx) : ObjectBase<Clipboard>(ctx) {}
|
||||
|
||||
struct ClearText_t {
|
||||
typedef Clipboard Owner;
|
||||
typedef void ReturnType;
|
||||
typedef void SetterType;
|
||||
typedef mozilla::jni::Args<> Args;
|
||||
static constexpr char name[] = "clearText";
|
||||
static constexpr char signature[] =
|
||||
"()V";
|
||||
static const bool isStatic = true;
|
||||
static const mozilla::jni::ExceptionMode exceptionMode =
|
||||
mozilla::jni::ExceptionMode::ABORT;
|
||||
static const mozilla::jni::CallingThread callingThread =
|
||||
mozilla::jni::CallingThread::GECKO;
|
||||
static const mozilla::jni::DispatchTarget dispatchTarget =
|
||||
mozilla::jni::DispatchTarget::CURRENT;
|
||||
};
|
||||
|
||||
static auto ClearText() -> void;
|
||||
|
||||
struct GetText_t {
|
||||
typedef Clipboard Owner;
|
||||
typedef mozilla::jni::String::LocalRef ReturnType;
|
||||
typedef mozilla::jni::String::Param SetterType;
|
||||
typedef mozilla::jni::Args<> Args;
|
||||
static constexpr char name[] = "getText";
|
||||
static constexpr char signature[] =
|
||||
"()Ljava/lang/String;";
|
||||
static const bool isStatic = true;
|
||||
static const mozilla::jni::ExceptionMode exceptionMode =
|
||||
mozilla::jni::ExceptionMode::ABORT;
|
||||
static const mozilla::jni::CallingThread callingThread =
|
||||
mozilla::jni::CallingThread::GECKO;
|
||||
static const mozilla::jni::DispatchTarget dispatchTarget =
|
||||
mozilla::jni::DispatchTarget::CURRENT;
|
||||
};
|
||||
|
||||
static auto GetText() -> mozilla::jni::String::LocalRef;
|
||||
|
||||
struct HasText_t {
|
||||
typedef Clipboard Owner;
|
||||
typedef bool ReturnType;
|
||||
typedef bool SetterType;
|
||||
typedef mozilla::jni::Args<> Args;
|
||||
static constexpr char name[] = "hasText";
|
||||
static constexpr char signature[] =
|
||||
"()Z";
|
||||
static const bool isStatic = true;
|
||||
static const mozilla::jni::ExceptionMode exceptionMode =
|
||||
mozilla::jni::ExceptionMode::ABORT;
|
||||
static const mozilla::jni::CallingThread callingThread =
|
||||
mozilla::jni::CallingThread::GECKO;
|
||||
static const mozilla::jni::DispatchTarget dispatchTarget =
|
||||
mozilla::jni::DispatchTarget::CURRENT;
|
||||
};
|
||||
|
||||
static auto HasText() -> bool;
|
||||
|
||||
struct SetText_t {
|
||||
typedef Clipboard Owner;
|
||||
typedef void ReturnType;
|
||||
typedef void SetterType;
|
||||
typedef mozilla::jni::Args<
|
||||
mozilla::jni::String::Param> Args;
|
||||
static constexpr char name[] = "setText";
|
||||
static constexpr char signature[] =
|
||||
"(Ljava/lang/CharSequence;)V";
|
||||
static const bool isStatic = true;
|
||||
static const mozilla::jni::ExceptionMode exceptionMode =
|
||||
mozilla::jni::ExceptionMode::ABORT;
|
||||
static const mozilla::jni::CallingThread callingThread =
|
||||
mozilla::jni::CallingThread::GECKO;
|
||||
static const mozilla::jni::DispatchTarget dispatchTarget =
|
||||
mozilla::jni::DispatchTarget::CURRENT;
|
||||
};
|
||||
|
||||
static auto SetText(mozilla::jni::String::Param) -> void;
|
||||
|
||||
static const mozilla::jni::CallingThread callingThread =
|
||||
mozilla::jni::CallingThread::GECKO;
|
||||
|
||||
};
|
||||
|
||||
class EventCallback : public mozilla::jni::ObjectBase<EventCallback>
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -43,7 +43,8 @@ nsClipboard::SetData(nsITransferable *aTransferable,
|
|||
nsAutoString buffer;
|
||||
supportsString->GetData(buffer);
|
||||
|
||||
java::Clipboard::SetText(buffer);
|
||||
java::Clipboard::SetText(java::GeckoAppShell::GetApplicationContext(),
|
||||
buffer);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -84,7 +85,7 @@ nsClipboard::EmptyClipboard(int32_t aWhichClipboard)
|
|||
{
|
||||
if (aWhichClipboard != kGlobalClipboard)
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
java::Clipboard::ClearText();
|
||||
java::Clipboard::ClearText(java::GeckoAppShell::GetApplicationContext());
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -100,7 +101,8 @@ nsClipboard::HasDataMatchingFlavors(const char **aFlavorList,
|
|||
|
||||
for (uint32_t k = 0; k < aLength; k++) {
|
||||
if (strcmp(aFlavorList[k], kUnicodeMime) == 0) {
|
||||
*aHasText = java::Clipboard::HasText();
|
||||
*aHasText = java::Clipboard::HasText(
|
||||
java::GeckoAppShell::GetApplicationContext());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче