Closed
Bug 694688
Opened 13 years ago
Closed 13 years ago
[birch] Implement Preferences activity
Categories
(Firefox for Android Graveyard :: General, defect, P1)
Tracking
(firefox11 fixed, fennec11+)
RESOLVED
FIXED
People
(Reporter: alexp, Assigned: bnicholson)
References
Details
(Keywords: feature, Whiteboard: [birch])
Attachments
(1 file, 5 obsolete files)
21.00 KB,
patch
|
mfinkle
:
review+
|
Details | Diff | Splinter Review |
Implement a native Preferences activity with preference values pulled from Gecko, and changes to be sent back to Gecko.
Reporter | ||
Comment 1•13 years ago
|
||
Asynchronous implementation without extra JNI calls.
- resources/xml/preferences.xml - the preferences screen
(this version only has one boolean CheckBox preference)
- GeckoPreferences.java - preferences activity
- nsPreferences.cpp - widget side handler
Attachment #567215 -
Flags: review?(blassey.bugs)
Reporter | ||
Updated•13 years ago
|
Status: NEW → ASSIGNED
Comment 2•13 years ago
|
||
Comment on attachment 567215 [details] [diff] [review]
Fix v4
Review of attachment 567215 [details] [diff] [review]:
-----------------------------------------------------------------
Since SET_PREF is only setting on preference, there's really no need to deal with JSON. If it is a string pref, you can use mCharacters, one of the int fields for in values and add a bool field for bool values.
Attachment #567215 -
Flags: review?(blassey.bugs) → review-
Updated•13 years ago
|
Assignee: alexp → nobody
Product: Fennec → Fennec Native
Version: Trunk → unspecified
Updated•13 years ago
|
Assignee: nobody → alexp
Reporter | ||
Comment 3•13 years ago
|
||
Using int and boolean class members to pass these types.
Attachment #567215 -
Attachment is obsolete: true
Attachment #567574 -
Flags: review?(blassey.bugs)
Comment 5•13 years ago
|
||
Comment on attachment 567574 [details] [diff] [review]
Fix v5
Review of attachment 567574 [details] [diff] [review]:
-----------------------------------------------------------------
So high level comments:
1) We should not save gecko prefs to the android system
2) We should not do the jscon parsing in nsPreferences.*.
3) We should reuse the broadcast message type
::: embedding/android/GeckoAppShell.java
@@ +1627,5 @@
> String uri = geckoObject.getString("uri");
> Tabs.getInstance().addTab(tabId, uri);
> + } else if (type.equals("preferences")) {
> + final JSONArray jsonPrefs = geckoObject.getJSONArray("preferences");
> + GeckoPreferences.savePreferences(jsonPrefs);
I don't understand savePreferences name. It should be LoadPreferences() because you should not save these preferences anywhere on the android.
::: embedding/android/GeckoEvent.java
@@ +75,5 @@
> public static final int ACTIVITY_START = 17;
> public static final int SAVE_STATE = 18;
> public static final int BROADCAST = 19;
> + public static final int GET_PREFS = 20;
> + public static final int SET_PREF = 21;
You should just use the BROADCAST type. It allows you to send arbitrary data. So, from java, you could just do:
GeckoEvent e = new GeckoEvent("preferences", <json>);
GeckoAppShell.sendEventToGecko(e);
@@ +112,5 @@
> public int mRangeType, mRangeStyles;
> public int mRangeForeColor, mRangeBackColor;
> public Location mLocation;
> public Address mAddress;
> + public int mIntValue;
can we reuse on of the other int's here?
@@ +113,5 @@
> public int mRangeForeColor, mRangeBackColor;
> public Location mLocation;
> public Address mAddress;
> + public int mIntValue;
> + public boolean mBoolValue;
would it be okay to use an int here and cast it to a boolean? Maybe Java is strict about that.
::: embedding/android/GeckoPreferences.java
@@ +40,5 @@
> +import android.content.SharedPreferences;
> +import android.os.Bundle;
> +import android.content.res.Resources;
> +import android.preference.*;
> +import android.preference.Preference.*;
android.preferences.* not needed. Maybe I am missing something. I do not think you want to save any of the gecko preferences to the android system.
@@ +45,5 @@
> +import android.util.Log;
> +import java.util.ArrayList;
> +import org.json.*;
> +
> +public class GeckoPreferences
I suspect alot of this class is going to change given that I do not think you want to save gecko preferences into the android system.
@@ +124,5 @@
> + if (prefsEditor == null)
> + return;
> +
> + try {
> + for (int i = 0; i < jsonPrefs.length(); i++) {
doesn't length() get evaluated every time through this loop. i can't remember if java optimized such loops, but i suspect not.
::: widget/src/android/AndroidJavaWrappers.cpp
@@ +69,5 @@
> jfieldID AndroidGeckoEvent::jRangeBackColorField = 0;
> jfieldID AndroidGeckoEvent::jLocationField = 0;
> jfieldID AndroidGeckoEvent::jAddressField = 0;
> +jfieldID AndroidGeckoEvent::jIntValueField = 0;
> +jfieldID AndroidGeckoEvent::jBoolValueField = 0;
I hope none of the changes in AndroidJavaWrapper.cpp are needed.
::: widget/src/android/AndroidJavaWrappers.h
@@ +426,5 @@
> int RangeBackColor() { return mRangeBackColor; }
> nsGeoPosition* GeoPosition() { return mGeoPosition; }
> nsGeoPositionAddress* GeoAddress() { return mGeoAddress; }
> + int IntValue() { return mIntValue; }
> + int BoolValue() { return mBoolValue; }
I hope none of the changes in AndroidJavaWrapper.h are needed.
::: widget/src/android/nsAppShell.cpp
@@ +53,5 @@
> #include "nsDeviceMotionSystem.h"
> #include <android/log.h>
> #include <pthread.h>
> #include <wchar.h>
> +#include "nsPreferences.h"
I am hoping that none of the changes to nsAppShell.cpp are needed.
::: widget/src/android/nsPreferences.cpp
@@ +1,1 @@
> +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
I do not want to do json parsing here. can you do either one of two things:
1) move this to javascript where it is easy, and most likely bug free.
2) extend nsIJSON to allow C++ code to easily deal with json data.
I would do (1).
Attachment #567574 -
Flags: review?(blassey.bugs) → review-
Updated•13 years ago
|
Priority: -- → P1
Reporter | ||
Comment 6•13 years ago
|
||
Moved the Gecko part to JavaScript.
Now using JSON to send preferences in both directions.
Attachment #567574 -
Attachment is obsolete: true
Attachment #567930 -
Flags: review?(doug.turner)
Comment 7•13 years ago
|
||
Comment on attachment 567930 [details] [diff] [review]
Fix v6
Just a drive by:
* "boolVal", "intVal" and "stringVal" could all be "value" in JSON. We don't need the specialized names.
* Why are we using:
let branch = Services.prefs.getBranch(null).QueryInterface(Ci.nsIPrefBranch2);
Why not just
Services.prefs ?
Reporter | ||
Comment 8•13 years ago
|
||
(In reply to Mark Finkle (:mfinkle) from comment #7)
> * "boolVal", "intVal" and "stringVal" could all be "value" in JSON. We don't
> need the specialized names.
I was thinking about this. Agree - with JSON all over the place it would make sense.
> * Why are we using:
> let branch =
> Services.prefs.getBranch(null).QueryInterface(Ci.nsIPrefBranch2);
>
> Why not just
> Services.prefs ?
I had the same question when was looking at config.js. Maybe because getPrefType is a method of nsIPrefBranch? I just left this to be clarified later.
Reporter | ||
Comment 9•13 years ago
|
||
Addressed Mark's comments.
Attachment #567930 -
Attachment is obsolete: true
Attachment #567930 -
Flags: review?(doug.turner)
Attachment #568036 -
Flags: review?(doug.turner)
Updated•13 years ago
|
Whiteboard: [birch] [ux needed]
Updated•13 years ago
|
Whiteboard: [birch] [ux needed] → [birch]
Updated•13 years ago
|
Assignee: alexp → bnicholson
Comment 10•13 years ago
|
||
Comment on attachment 568036 [details] [diff] [review]
Fix v6.1
Review of attachment 568036 [details] [diff] [review]:
-----------------------------------------------------------------
i handed this patch over to Brian.
Attachment #568036 -
Flags: review?(doug.turner) → review-
Assignee | ||
Comment 11•13 years ago
|
||
Attachment #568036 -
Attachment is obsolete: true
Comment 12•13 years ago
|
||
Comment on attachment 569220 [details] [diff] [review]
rebased alexp's patch
>diff --git a/embedding/android/GeckoAppShell.java b/embedding/android/GeckoAppShell.java
>+ } else if (type.equals("preferences")) {
>+ final JSONArray jsonPrefs = geckoObject.getJSONArray("preferences");
>+ GeckoPreferences.updatePreferenceScreen(jsonPrefs);
"preferences" -> "Preferences:Data"
>diff --git a/embedding/android/GeckoPreferences.java b/embedding/android/GeckoPreferences.java
>+ protected void onCreate(Bundle savedInstanceState) {
>+ initPreferenceGroup(mPreferenceScreen);
>+ initPreferenceValues();
initPreferenceGroup -> initGroups
initPreferenceValues -> initValues
>+ // Initialize preferences by sending the "preferences-get" command to Gecko
>+ private void initPreferenceValues() {
>+ JSONArray jsonPrefs = new JSONArray(mPreferencesList);
>+
>+ GeckoEvent event = new GeckoEvent("preferences-get", jsonPrefs.toString());
"preferences-get" -> "Preferences:Data"
>+ public static void updatePreferenceScreen(JSONArray jsonPrefs) {
updatePreferenceScreen -> refresh
>+ GeckoAppShell.getMainHandler().post(new Runnable() {
>+ public void run() {
>+ if (((CheckBoxPreference)pref).isChecked() != value)
>+ ((CheckBoxPreference)pref).setChecked(value);
>+ }
>+ });
Change this to | GeckoAppShell.getHandler().post(... |
(in all places)
un-indent the code bock 4 spaces
>+ }
>+
>+ } catch (JSONException e) {
Remove blank line
>+ // Send the "preferences-set" command with a preference value to Gecko
>+ public static void setPref(String pref, Object value) {
setPref -> setPreference
"preferences-set" -> "Preferences:Set"
>diff --git a/mobile/chrome/content/browser.js b/mobile/chrome/content/browser.js
>+ Services.obs.addObserver(this, "preferences-get", false);
>+ Services.obs.addObserver(this, "preferences-set", false);
"preferences-get" -> "Preferences:Get"
"preferences-set" -> "Preferences:Set"
>+ getPreferences: function getPreferences(aPrefNames) {
>+ for each (let prefName in json) {
>+ let pref = {
>+ name: prefName,
>+ };
let pref = {
name: prefName,
};
>+ sendMessageToJava({
>+ gecko: {
>+ type: "preferences",
"preferences" -> "Preferences:Data"
> observe: function(aSubject, aTopic, aData) {
>+ else if (aTopic == "preferences-get")
>+ this.getPreferences(aData);
>+ else if (aTopic == "preferences-set")
>+ this.setPreferences(aData);
Update the strings
r+, but update the patch and fix nits
Attachment #569220 -
Flags: review+
Assignee | ||
Comment 13•13 years ago
|
||
Attachment #569220 -
Attachment is obsolete: true
Attachment #569505 -
Flags: review?(mark.finkle)
Updated•13 years ago
|
Attachment #569505 -
Flags: review?(mark.finkle) → review+
Comment 14•13 years ago
|
||
Status: ASSIGNED → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Updated•13 years ago
|
tracking-fennec: --- → 11+
Updated•13 years ago
|
status-firefox11:
--- → fixed
Updated•4 years ago
|
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in
before you can comment on or make changes to this bug.
Description
•