bug 614355 - provide pref to not always use fullscreen landscape keyboards on android r=dougt

This commit is contained in:
Brad Lassey 2011-04-11 16:41:03 -04:00
parent 14e0485431
commit 3713a43a89
4 changed files with 45 additions and 4 deletions

View File

@ -522,7 +522,8 @@ public class GeckoAppShell
}
public static void notifyIMEEnabled(int state, String typeHint,
String actionHint) {
String actionHint, boolean landscapeFS)
{
if (GeckoApp.surfaceView == null)
return;
@ -531,6 +532,7 @@ public class GeckoAppShell
GeckoApp.surfaceView.mIMEState = state;
GeckoApp.surfaceView.mIMETypeHint = typeHint;
GeckoApp.surfaceView.mIMEActionHint = actionHint;
GeckoApp.surfaceView.mIMELandscapeFS = landscapeFS;
IMEStateUpdater.enableIME();
}

View File

@ -383,7 +383,10 @@ class GeckoSurfaceView
outAttrs.imeOptions = EditorInfo.IME_ACTION_SEND;
else if (mIMEActionHint != null && mIMEActionHint.length() != 0)
outAttrs.actionLabel = mIMEActionHint;
if (mIMELandscapeFS == false)
outAttrs.imeOptions |= EditorInfo.IME_FLAG_NO_EXTRACT_UI;
inputConnection.reset();
return inputConnection;
}
@ -624,6 +627,7 @@ class GeckoSurfaceView
int mIMEState;
String mIMETypeHint;
String mIMEActionHint;
boolean mIMELandscapeFS;
// Software rendering
ByteBuffer mSoftwareBuffer;

View File

@ -585,6 +585,12 @@ pref("indexedDB.feature.enabled", false);
pref("media.preload.default", 1); // default to preload none
pref("media.preload.auto", 2); // preload metadata if preload=auto
// 0: don't show fullscreen keyboard
// 1: always show fullscreen keyboard
// -1: show fullscreen keyboard based on threshold pref
pref("widget.ime.android.landscape_fullscreen", 0);
pref("widget.ime.android.fullscreen_threshold", 300); // in hundreths of inches
// optimize images memory usage
pref("image.mem.decodeondraw", true);
pref("content.image.allow_locking", false);

View File

@ -45,6 +45,8 @@
#include "AndroidBridge.h"
#include "nsAppShell.h"
#include "nsOSHelperAppService.h"
#include "nsIPrefService.h"
#include "nsWindow.h"
#ifdef DEBUG
#define ALOG_BRIDGE(args...) ALOG(args)
@ -52,6 +54,9 @@
#define ALOG_BRIDGE(args...)
#endif
#define IME_FULLSCREEN_PREF "widget.ime.android.landscape_fullscreen"
#define IME_FULLSCREEN_THRESHOLD_PREF "widget.ime.android.fullscreen_threshold"
using namespace mozilla;
static PRUintn sJavaEnvThreadIndex = 0;
@ -103,7 +108,7 @@ AndroidBridge::Init(JNIEnv *jEnv,
mGeckoAppShellClass = (jclass) jEnv->NewGlobalRef(jGeckoAppShellClass);
jNotifyIME = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "notifyIME", "(II)V");
jNotifyIMEEnabled = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "notifyIMEEnabled", "(ILjava/lang/String;Ljava/lang/String;)V");
jNotifyIMEEnabled = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "notifyIMEEnabled", "(ILjava/lang/String;Ljava/lang/String;Z)V");
jNotifyIMEChange = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "notifyIMEChange", "(Ljava/lang/String;III)V");
jAcknowledgeEventSync = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "acknowledgeEventSync", "()V");
@ -237,11 +242,35 @@ AndroidBridge::NotifyIMEEnabled(int aState, const nsAString& aTypeHint,
nsPromiseFlatString typeHint(aTypeHint);
nsPromiseFlatString actionHint(aActionHint);
jvalue args[3];
jvalue args[4];
AutoLocalJNIFrame jniFrame(1);
args[0].i = aState;
args[1].l = JNI()->NewString(typeHint.get(), typeHint.Length());
args[2].l = JNI()->NewString(actionHint.get(), actionHint.Length());
args[3].z = false;
nsCOMPtr<nsIPrefBranch> prefs =
do_GetService(NS_PREFSERVICE_CONTRACTID);
if (prefs) {
PRInt32 landscapeFS;
nsresult rv = prefs->GetIntPref(IME_FULLSCREEN_PREF, &landscapeFS);
if (NS_SUCCEEDED(rv)) {
if (landscapeFS == 1) {
args[3].z = true;
} else if (landscapeFS == -1){
rv = prefs->GetIntPref(IME_FULLSCREEN_THRESHOLD_PREF,
&landscapeFS);
if (NS_SUCCEEDED(rv)) {
// the threshold is hundreths of inches, so convert the
// threshold to pixels and multiply the height by 100
if (nsWindow::GetAndroidScreenBounds().height * 100 <
landscapeFS * Bridge()->GetDPI())
args[3].z = true;
}
}
}
}
JNI()->CallStaticVoidMethodA(sBridge->mGeckoAppShellClass,
sBridge->jNotifyIMEEnabled, args);
}