Closed Bug 770101 Opened 13 years ago Closed 12 years ago

about:config should label integer fields correctly so keyboard uses numerical mode

Categories

(Firefox for Android Graveyard :: General, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
Firefox 27

People

(Reporter: gerv, Assigned: capella)

Details

Attachments

(2 files, 11 obsolete files)

Fennec has its own implementation of about:config. Entries in about:config can be boolean, integer or string. Booleans have a "toggle" rather than a "modify" button, which is good, but for integers, the field should be labelled as an integer field such that the keyboard enters numerical mode. Gerv
We're creating this prompt with the prompt service: http://mxr.mozilla.org/mozilla-central/source/mobile/android/chrome/content/config.xhtml#150 I don't think the prompt service API has a way to indicate that a field is a number, so it would be hard to let our Java implementation know that we want to show the numerical keyboard.
Is there a way we can cheat? My thoughts here are: * We control the caller (config.xhtml) and the callee (PromptService.java) * We could switch to use the message ("Prompt:Show") and add a hint for the type * The Java code would use the hint, if found, to adjust the UI
Assignee: nobody → markcapella
Status: NEW → ASSIGNED
Attached patch Patch (v1) (obsolete) — Splinter Review
Cool stuff ... just cheating a little >)
Attachment #704376 - Flags: review?(mark.finkle)
Attached image Screen Shot (obsolete) —
Comment on attachment 704376 [details] [diff] [review] Patch (v1) Wes is a better reviewer for PromptService
Attachment #704376 - Flags: review?(mark.finkle) → review?(wjohnston)
Comment on attachment 704376 [details] [diff] [review] Patch (v1) Review of attachment 704376 [details] [diff] [review]: ----------------------------------------------------------------- Great stuff :) I hate that we're not just doing this editing inline (i.e. we support input[type="number"] in HTML, if you want to work on fixing up aboout:config, I would love you), but this seems like a nice feature to have in prompts anyway. Just want a slightly different API. ::: mobile/android/base/PromptService.java @@ +106,5 @@ > mType = getSafeString(aJSONInput, "type"); > String id = getSafeString(aJSONInput, "id"); > mId = TextUtils.isEmpty(id) ? mType : id; > mHint = getSafeString(aJSONInput, "hint"); > + mKbdType = getSafeString(aJSONInput, "keyboard"); This may make the patch more complex, but I don't want to add more parameters here (its already too much I think, but I haven't been clever enough to pair it down). I'd rather we just have type="number" than specify a keyboard type. Hopefully we can still share most of the code with the textbox input type. On Android version 11+, we can actually use a NumberPicker instead: https://developer.android.com/reference/android/widget/NumberPicker.html ::: mobile/android/chrome/content/config.xhtml @@ +147,5 @@ > } else { > + let message = { type: "Prompt:Show" }; > + message.title = title; > + message.text = gStringBundle.formatStringFromName("modifyPref.promptText", [aPref.name], 1); > + message.buttons = [ "OK", "Cancel" ]; Localization. These strings are in chrome://global/locale/commonDialogs.properties
Attachment #704376 - Flags: review?(wjohnston) → review-
Ok, localizing the strings and creating a new PromptService type of "number" is easy enough. Even implementing the NumberPicker is fairly simple (and cool!) but the class doesn't seem to allow for negative numeric values ...
Attached patch Patch (v2) (obsolete) — Splinter Review
Maybe I'm getting too creative here with the NumberPicker :P ... See new screen shot. I added a togglebutton to handle negative integers ... then ran into two issues. Setting the pickers' MIN value to 0 and MAX value to |Integer.MAX_VALUE| causes what appears to be an android bug (image left). Setting MAX to |Integer.MAX_VALUE - 1| works ok (image center) with the following behaviour that I haven't fixed yet. If you click the pickers' middle / selected number, it opens the keyboard for you to make a manual entry (image right). Cool so far. If you click DONE on the keyboard all proceeds normally. However, if you enter a number and press the OK button in the dialog, it ends without grabbing the new data in the picker editbox. (Plus sign changes are preserved). Still playing ...
Attachment #704376 - Attachment is obsolete: true
Attached image Screenshot NumberPicker (obsolete) —
Attached patch Patch (v3) (obsolete) — Splinter Review
This seems to solve all issues I wasn't happy with. The user can now select all positive / negative INT values including Integer.MAX_VALUE... I fixed the scrolling issue but setting the wheel to not continuously wrap around then ends. Also, keying a numeric value and clicking the OK button now accepts the current fields data without first having to click DONE in the soft keyboard. Have a look?
Attachment #704789 - Attachment is obsolete: true
Attachment #705276 - Flags: review?(wjohnston)
Attached image Screen Shot Landscape (obsolete) —
Bug 729056 may also be corrected by this change.
Comment on attachment 705276 [details] [diff] [review] Patch (v3) Review of attachment 705276 [details] [diff] [review]: ----------------------------------------------------------------- I think we should get ibarlow's feedback on the +- button, and I want to play with it a bit myself, but this will crash on 2.3 so wanted to get back to you now rather than later. ::: mobile/android/base/PromptService.java @@ +204,5 @@ > + signButton.setTextOff("-"); > + signButton.setChecked(value >= 0); > + pickerView.addView(signButton); > + > + NumberPicker numberPicker = new NumberPicker(GeckoApp.mAppContext); This will crash on Android version < 11. We'll need to provide a textbox fallback there.
Attachment #705276 - Flags: review?(wjohnston)
Attached patch Patch (v4) (obsolete) — Splinter Review
Crashes are bad, 'mmkay ?
Attachment #705276 - Attachment is obsolete: true
Comment on attachment 706407 [details] [diff] [review] Patch (v4) Forgot to flag ibarlow for plus / minus sign feedback ...
Attachment #706407 - Flags: feedback?(ibarlow)
Attached image mockup (obsolete) —
It seems like a number picker with arrows on top and bottom might be a more appropriate UI for this? See attached.
The basic NumberPicker widget allows for one of two styles based on theme ... one with numbers above/ below, and one with arrows above / below ... (it doesn't allow for negative numbers either hence my plus/minus toggle modification ...) So I'm confused by the mockup ... Was this something you coded / the widget allows for and I haven't noticed yet? Or do you suggest a new custom widget employing both options?
No, it's a mockup i did, but I didn't realize there were those limitations to the picker widget. I suppose at that point I would just use the numbers above/below widget, with no + or - added, since if you can easily scroll up and down using the picker. Unless I am missing something, I can't see any additional value to the + and - signs in your previous mockups.
Ok thanks. I think that's why wesj wanted your input re: plus / minus ... I liked the convenience ... but yes you can scroll for selection, and tapping the edittext field allows quick entry
Moving back to wesj queue for review ... after re-reviewing, maybe I've confused things. I think we do need the plus/minus sign. Scrolling and edit text only allows for input of numbers from 0 to Integer.MAX_VALUE (or 2,147,483,647). The NumberPicker won't allow for values less than zero, so we can't scroll the whole range of Integer.MIN_VALUE -> 0 -> Integer.MAX_VALUE ... Since we have fields such as |javascript.options.mem.max| that default to -1, we need a way to specify that.
Attachment #706407 - Flags: feedback?(ibarlow) → review?(wjohnston)
Comment on attachment 706407 [details] [diff] [review] Patch (v4) Review of attachment 706407 [details] [diff] [review]: ----------------------------------------------------------------- Playing with this, I think we can use NumberPicker.setFormatter to set a formatter that shows negative values for us: numberPicker.setFormatter(new NumberPicker.Formatter() { public String format(int value) { return Integer.toString(Integer.MAX_VALUE/2 - value); } }); but there seem to be issues with the "initial" value in that case (https://code.google.com/p/android/issues/detail?id=35482). Android is also really vague about what picker.setValue() and picker.getValue() do in those cases. I'm debating in my head what's the right answer, but I think I'd rather do this and deal with the initial value problem on its own (since this isn't primary ui yet anyway). I've been trying to figure out what we can do by looking at the NumberPicker source, but no luck yet. Any ideas Capella?
Attachment #706407 - Flags: review?(wjohnston)
Well I didn't go down that road (quick switch under the cover kinda thing) ... won't it still mask the issue of not being able to input the full range of integer values -2,147,483,648 -> 0 -> 2,147,483,647 ? Won't it just allow a scroll range of (2,147,483,647 / 2) +/- centered on the current selected |value| ? Or do you think this allows the NumberPicker range to dynamically float centered on that value and still allow a full range of input? Too bad NumberPicker doesn't use longs internally ...
This bug is being closed / merged with the larger overall revamp being done in bug 840144.
Depends on: 840144
Assignee: markcapella → nobody
Status: ASSIGNED → NEW
capella: sad to see this bug get so close and then get tied up in a larger patch which is not checked in 5 months later... Any news? Gerv
Flags: needinfo?(markcapella)
Oh, yes, I agree, but I'll have to check with wesj as he was reviewing this original patch, as well as offering the WIP for the complete revamp (bug 840144). I think the revamp patch that I finished from wesj while functional, was too big a change to get review / approval. We might be able to move this along, I really liked the Java number picker.
Flags: needinfo?(markcapella) → needinfo?(wjohnston)
I think landing this would be useful. I think we got a bit sidetracked trying to make it perfect, when maybe we'd be better to just settle for "good".
Flags: needinfo?(wjohnston)
Assignee: nobody → markcapella
Status: NEW → ASSIGNED
Attached patch bug770101 v(v5) (obsolete) — Splinter Review
Well, someone moved my cheese, but a little refactoring after 5 months s/have been expected :-) Same solution as before, new NumberInput method different version based on Android OS (NumberPicker class is available from Honeycomb (v11) on forward ... before that we
Attachment #704377 - Attachment is obsolete: true
Attachment #704790 - Attachment is obsolete: true
Attachment #705730 - Attachment is obsolete: true
Attachment #706407 - Attachment is obsolete: true
Attachment #711361 - Attachment is obsolete: true
Attachment #804463 - Flags: review?(wjohnston)
Attached patch bug770101 (v5) (obsolete) — Splinter Review
Well, someone moved my cheese, but a little refactoring after 5 months s/have been expected ;-) Same solution as before, new NumberInput method w/different implementation based on Android OS. NumberPicker class is available from Honeycomb (v11) on forward ... before that we use a simpler numeric input ... both versions default to numeric keyboard only. Screenshots to follow ...
Attachment #804463 - Attachment is obsolete: true
Attachment #804463 - Flags: review?(wjohnston)
Attachment #804465 - Flags: review?(wjohnston)
No longer depends on: 840144
Comment on attachment 804465 [details] [diff] [review] bug770101 (v5) Review of attachment 804465 [details] [diff] [review]: ----------------------------------------------------------------- :( I feel bad, but this needs to use the new Prompt.jsm stuff. ::: mobile/android/base/PromptInput.java @@ +154,5 @@ > + > + ToggleButton signButton = new ToggleButton(context); > + signButton.setTextOn("+"); > + signButton.setTextOff("-"); > + signButton.setChecked(value >= 0); I still kinda hate this. It looks a bit ugly, but this is fairly hidden... I think we should toss this and just use the number input mode. i.e. the Honeycomb stuff. For anyone entering a number that has a large range anyway, it will make life bearable. i.e. Sorry for the goose chase :( Lets keep this even simpler and go back to your original v1 patch ::: mobile/android/chrome/content/config.xhtml @@ +144,5 @@ > return; > } > > Services.prefs.setBoolPref(aPref.name, result.value); > } else { We should use Prompt.jsm... but it will need to be updated to handle number. https://developer.mozilla.org/en-US/docs/Extensions/Mobile/API/Prompt.jsm http://mxr.mozilla.org/mozilla-central/source/mobile/android/modules/Prompt.jsm I say that because it does prompts asynchronously, and we're basically deprecating the old style (I should add a warning when it happens).
Attachment #804465 - Flags: review?(wjohnston) → review-
Attached patch bug770101v6Splinter Review
Git 'er done !!! ;-) fyi as an aside re: |For anyone entering a number that has a large range anyway, it will make life bearable| ... using the number picker, you wouldn't only have to roll the wheel to select the field value ... you can tap the editText in the center line and it opens for direct numeric input :-)
Attachment #804465 - Attachment is obsolete: true
Attachment #804468 - Attachment is obsolete: true
Attachment #804828 - Flags: review?(wjohnston)
Comment on attachment 804828 [details] [diff] [review] bug770101v6 Review of attachment 804828 [details] [diff] [review]: ----------------------------------------------------------------- ::: mobile/android/base/PromptInput.java @@ +13,5 @@ > import org.json.JSONObject; > > import android.content.Context; > +import android.content.res.Configuration; > +// Why aren't these sorted? ---v You didn't sort them? @@ +106,5 @@ > + InputType.TYPE_NUMBER_FLAG_SIGNED); > + return input; > + } > + > + public String getValue() { I think this is the same as EditInput. r.e. we don't need it?
Attachment #804828 - Flags: review?(wjohnston) → review+
1) Sorted, 2) removed nice catch (could take out of |PasswordInput| in future) 3) push to try ...
Status: ASSIGNED → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 27
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: