зеркало из https://github.com/mozilla/gecko-dev.git
Bug 741693 - Move the Axis prefs from GeckoLayerClient into PanZoomController. r=Cwiiis
This commit is contained in:
Родитель
9dbef8e3e9
Коммит
d03f265dc4
|
@ -43,7 +43,6 @@ import org.mozilla.gecko.GeckoApp;
|
|||
import org.mozilla.gecko.GeckoAppShell;
|
||||
import org.mozilla.gecko.GeckoEvent;
|
||||
import org.mozilla.gecko.GeckoEventResponder;
|
||||
import org.mozilla.gecko.ui.Axis;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
@ -124,7 +123,6 @@ public class GeckoLayerClient implements GeckoEventResponder,
|
|||
|
||||
JSONArray prefs = new JSONArray();
|
||||
DisplayPortCalculator.addPrefNames(prefs);
|
||||
Axis.addPrefNames(prefs);
|
||||
GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("Preferences:Get", prefs.toString()));
|
||||
}
|
||||
|
||||
|
@ -273,7 +271,6 @@ public class GeckoLayerClient implements GeckoEventResponder,
|
|||
// right batch of prefs, since other java code may also have sent requests
|
||||
// for prefs.
|
||||
if (DisplayPortCalculator.setStrategy(prefValues)) {
|
||||
Axis.setPrefs(prefValues);
|
||||
GeckoAppShell.unregisterGeckoEventListener("Preferences:Data", this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ import org.mozilla.gecko.FloatUtils;
|
|||
* like displacement, velocity, viewport dimensions, etc. pertaining to
|
||||
* a particular axis.
|
||||
*/
|
||||
public abstract class Axis {
|
||||
abstract class Axis {
|
||||
private static final String LOGTAG = "GeckoAxis";
|
||||
|
||||
private static final String PREF_SCROLLING_FRICTION_SLOW = "ui.scrolling.friction_slow";
|
||||
|
@ -90,7 +90,7 @@ public abstract class Axis {
|
|||
return (value == null || value < 0 ? defaultValue : value);
|
||||
}
|
||||
|
||||
public static void addPrefNames(JSONArray prefs) {
|
||||
static void addPrefNames(JSONArray prefs) {
|
||||
prefs.put(PREF_SCROLLING_FRICTION_FAST);
|
||||
prefs.put(PREF_SCROLLING_FRICTION_SLOW);
|
||||
prefs.put(PREF_SCROLLING_VELOCITY_THRESHOLD);
|
||||
|
@ -100,7 +100,7 @@ public abstract class Axis {
|
|||
prefs.put(PREF_SCROLLING_MIN_SCROLLABLE_DISTANCE);
|
||||
}
|
||||
|
||||
public static void setPrefs(Map<String, Integer> prefs) {
|
||||
static void setPrefs(Map<String, Integer> prefs) {
|
||||
FRICTION_SLOW = getFloatPref(prefs, PREF_SCROLLING_FRICTION_SLOW, 850);
|
||||
FRICTION_FAST = getFloatPref(prefs, PREF_SCROLLING_FRICTION_FAST, 970);
|
||||
VELOCITY_THRESHOLD = getIntPref(prefs, PREF_SCROLLING_VELOCITY_THRESHOLD, 10);
|
||||
|
|
|
@ -57,6 +57,8 @@ import android.util.Log;
|
|||
import android.view.GestureDetector;
|
||||
import android.view.MotionEvent;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
@ -165,6 +167,7 @@ public class PanZoomController
|
|||
|
||||
JSONArray prefs = new JSONArray();
|
||||
prefs.put(PREF_ZOOM_ANIMATION_FRAMES);
|
||||
Axis.addPrefNames(prefs);
|
||||
GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent(MESSAGE_PREFS_GET, prefs.toString()));
|
||||
}
|
||||
|
||||
|
@ -209,16 +212,31 @@ public class PanZoomController
|
|||
});
|
||||
} else if (MESSAGE_PREFS_DATA.equals(event)) {
|
||||
JSONArray jsonPrefs = message.getJSONArray("preferences");
|
||||
Map<String, Integer> axisPrefs = new HashMap<String, Integer>();
|
||||
String zoomAnimationFrames = null;
|
||||
for (int i = jsonPrefs.length() - 1; i >= 0; i--) {
|
||||
JSONObject pref = jsonPrefs.getJSONObject(i);
|
||||
String name = pref.getString("name");
|
||||
if (PREF_ZOOM_ANIMATION_FRAMES.equals(name)) {
|
||||
setZoomAnimationFrames(pref.getString("value"));
|
||||
GeckoAppShell.unregisterGeckoEventListener(MESSAGE_PREFS_DATA, this);
|
||||
break;
|
||||
zoomAnimationFrames = pref.getString("value");
|
||||
} else {
|
||||
try {
|
||||
axisPrefs.put(name, pref.getInt("value"));
|
||||
} catch (JSONException je) {
|
||||
// the value could not be parsed as an int. ignore this
|
||||
// pref and continue
|
||||
}
|
||||
}
|
||||
}
|
||||
// check for null to make sure the batch of preferences we got notified
|
||||
// of are in the fact the ones we requested and not those requested by
|
||||
// other java code
|
||||
if (zoomAnimationFrames != null) {
|
||||
setZoomAnimationFrames(zoomAnimationFrames);
|
||||
Axis.setPrefs(axisPrefs);
|
||||
GeckoAppShell.unregisterGeckoEventListener(MESSAGE_PREFS_DATA, this);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e(LOGTAG, "Exception handling message \"" + event + "\":", e);
|
||||
}
|
||||
|
@ -226,7 +244,7 @@ public class PanZoomController
|
|||
|
||||
private void setZoomAnimationFrames(String frames) {
|
||||
try {
|
||||
if (frames != null && frames.length() > 0) {
|
||||
if (frames.length() > 0) {
|
||||
StringTokenizer st = new StringTokenizer(frames, ",");
|
||||
float[] values = new float[st.countTokens()];
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче