mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 892094 - Create "Search" page in settings. r=liuche
--HG-- rename : mobile/android/base/resources/xml/preferences_customize.xml => mobile/android/base/resources/xml-v11/preferences_customize.xml rename : mobile/android/base/resources/xml/preferences_customize.xml => mobile/android/base/resources/xml/preferences_customize.xml.in
This commit is contained in:
parent
01616062a4
commit
c820daa64e
@ -234,6 +234,7 @@ FENNEC_JAVA_FILES = \
|
||||
menu/MenuItemDefault.java \
|
||||
menu/MenuPanel.java \
|
||||
menu/MenuPopup.java \
|
||||
preferences/SearchPreferenceCategory.java \
|
||||
widget/AboutHome.java \
|
||||
widget/AboutHomeView.java \
|
||||
widget/AboutHomeSection.java \
|
||||
@ -310,6 +311,7 @@ FENNEC_PP_JAVA_FILES = \
|
||||
|
||||
FENNEC_PP_XML_FILES = \
|
||||
res/xml/preferences.xml \
|
||||
res/xml/preferences_customize.xml \
|
||||
res/xml/searchable.xml \
|
||||
$(NULL)
|
||||
|
||||
@ -573,14 +575,15 @@ RES_VALUES_V14 = \
|
||||
$(NULL)
|
||||
|
||||
RES_XML = \
|
||||
res/xml/preferences_customize.xml \
|
||||
res/xml/preferences_display.xml \
|
||||
res/xml/preferences_search.xml \
|
||||
res/xml/preferences_privacy.xml \
|
||||
res/xml/preferences_vendor.xml \
|
||||
$(SYNC_RES_XML) \
|
||||
$(NULL)
|
||||
|
||||
RES_XML_V11 = \
|
||||
res/xml-v11/preferences_customize.xml \
|
||||
res/xml-v11/preference_headers.xml \
|
||||
res/xml-v11/preferences_customize_tablet.xml \
|
||||
res/xml-v11/preferences.xml \
|
||||
|
@ -68,10 +68,12 @@
|
||||
<!ENTITY settings "Settings">
|
||||
<!ENTITY settings_title "Settings">
|
||||
<!ENTITY pref_category_customize "Customize">
|
||||
<!ENTITY pref_category_search "Search">
|
||||
<!ENTITY pref_category_display "Display">
|
||||
<!ENTITY pref_category_privacy_short "Privacy">
|
||||
<!ENTITY pref_category_vendor "&vendorShortName;">
|
||||
<!ENTITY pref_category_datareporting "Data choices">
|
||||
<!ENTITY pref_category_installed_search_engines "Installed search engines">
|
||||
|
||||
<!-- collected old strings - remove after determining final strings
|
||||
as part of Bug 877791 -->
|
||||
|
@ -0,0 +1,89 @@
|
||||
package org.mozilla.gecko.preferences;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.os.Build;
|
||||
import android.preference.Preference;
|
||||
import android.preference.PreferenceCategory;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.mozilla.gecko.GeckoAppShell;
|
||||
import org.mozilla.gecko.GeckoEvent;
|
||||
import org.mozilla.gecko.R;
|
||||
import org.mozilla.gecko.gfx.BitmapUtils;
|
||||
import org.mozilla.gecko.util.GeckoEventListener;
|
||||
|
||||
public class SearchPreferenceCategory extends PreferenceCategory implements GeckoEventListener {
|
||||
public static final String LOGTAG = "SearchPrefCategory";
|
||||
|
||||
private static int sIconSize;
|
||||
|
||||
public SearchPreferenceCategory(Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
init();
|
||||
}
|
||||
public SearchPreferenceCategory(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init();
|
||||
}
|
||||
|
||||
public SearchPreferenceCategory(Context context) {
|
||||
super(context);
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
sIconSize = getContext().getResources().getDimensionPixelSize(R.dimen.searchpreferences_icon_size);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onAttachedToActivity() {
|
||||
super.onAttachedToActivity();
|
||||
|
||||
// Request list of search engines from Gecko
|
||||
GeckoAppShell.registerEventListener("SearchEngines:Data", this);
|
||||
GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("SearchEngines:Get", null));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMessage(String event, final JSONObject data) {
|
||||
if (event.equals("SearchEngines:Data")) {
|
||||
JSONArray engines;
|
||||
try {
|
||||
engines = data.getJSONArray("searchEngines");
|
||||
} catch (JSONException e) {
|
||||
Log.e(LOGTAG, "Unable to decode search engine data from Gecko.", e);
|
||||
return;
|
||||
}
|
||||
|
||||
// Create an element in this PreferenceCategory for each engine.
|
||||
for (int i = 0; i < engines.length(); i++) {
|
||||
try {
|
||||
JSONObject engineJSON = engines.getJSONObject(i);
|
||||
final String engineName = engineJSON.getString("name");
|
||||
|
||||
Preference engine = new Preference(getContext());
|
||||
engine.setTitle(engineName);
|
||||
engine.setKey(engineName);
|
||||
|
||||
// The setIcon feature is not available prior to API 11.
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
|
||||
String iconURI = engineJSON.getString("iconURI");
|
||||
Bitmap iconBitmap = BitmapUtils.getBitmapFromDataURI(iconURI);
|
||||
Bitmap scaledIconBitmap = Bitmap.createScaledBitmap(iconBitmap, sIconSize, sIconSize, false);
|
||||
BitmapDrawable drawable = new BitmapDrawable(scaledIconBitmap);
|
||||
engine.setIcon(drawable);
|
||||
}
|
||||
addPreference(engine);
|
||||
// TODO: Bug 892113 - Add event listener here for tapping on each element. Produce a dialog to provide options.
|
||||
} catch (JSONException e) {
|
||||
Log.e(LOGTAG, "JSONException parsing engine at index " + i, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -61,6 +61,7 @@
|
||||
<dimen name="prompt_service_min_list_item_height">48dp</dimen>
|
||||
<dimen name="remote_tab_child_row_height">64dp</dimen>
|
||||
<dimen name="remote_tab_group_row_height">26dp</dimen>
|
||||
<dimen name="searchpreferences_icon_size">32dp</dimen>
|
||||
<dimen name="tab_thumbnail_height">90dp</dimen>
|
||||
<dimen name="tab_thumbnail_width">160dp</dimen>
|
||||
<dimen name="tabs_counter_size">22sp</dimen>
|
||||
|
@ -7,6 +7,12 @@
|
||||
xmlns:gecko="http://schemas.android.com/apk/res-auto"
|
||||
android:enabled="false">
|
||||
|
||||
<PreferenceScreen android:title="@string/pref_category_search"
|
||||
android:fragment="org.mozilla.gecko.GeckoPreferenceFragment" >
|
||||
<extra android:name="resource"
|
||||
android:value="preferences_search"/>
|
||||
</PreferenceScreen>
|
||||
|
||||
<org.mozilla.gecko.AndroidImportPreference
|
||||
android:key="android.not_a_preference.import_android"
|
||||
gecko:entries="@array/pref_import_android_entries"
|
||||
@ -17,11 +23,6 @@
|
||||
android:negativeButtonText="@string/button_cancel"
|
||||
android:persistent="false" />
|
||||
|
||||
<CheckBoxPreference android:key="browser.search.suggest.enabled"
|
||||
android:title="@string/pref_search_suggestions"
|
||||
android:defaultValue="true"
|
||||
android:persistent="false" />
|
||||
|
||||
<CheckBoxPreference android:key="android.not_a_preference.restoreSession"
|
||||
android:title="@string/pref_restore_session"
|
||||
android:defaultValue="false"
|
@ -14,6 +14,12 @@
|
||||
<org.mozilla.gecko.SyncPreference android:title="@string/pref_sync"
|
||||
android:persistent="false" />
|
||||
|
||||
<PreferenceScreen android:title="@string/pref_category_search"
|
||||
android:fragment="org.mozilla.gecko.GeckoPreferenceFragment" >
|
||||
<extra android:name="resource"
|
||||
android:value="preferences_search"/>
|
||||
</PreferenceScreen>
|
||||
|
||||
<org.mozilla.gecko.AndroidImportPreference
|
||||
android:key="android.not_a_preference.import_android"
|
||||
gecko:entries="@array/pref_import_android_entries"
|
||||
@ -24,10 +30,10 @@
|
||||
android:negativeButtonText="@string/button_cancel"
|
||||
android:persistent="false" />
|
||||
|
||||
<CheckBoxPreference android:key="browser.search.suggest.enabled"
|
||||
android:title="@string/pref_search_suggestions"
|
||||
android:defaultValue="true"
|
||||
android:persistent="false" />
|
||||
<CheckBoxPreference android:key="android.not_a_preference.restoreSession"
|
||||
android:title="@string/pref_restore_session"
|
||||
android:defaultValue="false"
|
||||
android:persistent="true" />
|
||||
|
||||
<ListPreference android:key="app.update.autodownload"
|
||||
android:title="@string/pref_update_autodownload"
|
||||
|
@ -0,0 +1,42 @@
|
||||
#filter substitution
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
||||
- 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/. -->
|
||||
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:gecko="http://schemas.android.com/apk/res-auto"
|
||||
android:enabled="false">
|
||||
<PreferenceScreen android:title="@string/pref_category_search" >
|
||||
<intent android:action="android.intent.action.VIEW"
|
||||
android:targetPackage="@ANDROID_PACKAGE_NAME@"
|
||||
android:targetClass="org.mozilla.gecko.GeckoPreferences" >
|
||||
<extra
|
||||
android:name="resource"
|
||||
android:value="preferences_search" />
|
||||
</intent>
|
||||
</PreferenceScreen>
|
||||
|
||||
<org.mozilla.gecko.AndroidImportPreference
|
||||
android:key="android.not_a_preference.import_android"
|
||||
gecko:entries="@array/pref_import_android_entries"
|
||||
gecko:entryKeys="@array/pref_import_android_keys"
|
||||
gecko:initialValues="@array/pref_import_android_values"
|
||||
android:title="@string/pref_import_android"
|
||||
android:positiveButtonText="@string/bookmarkhistory_button_import"
|
||||
android:negativeButtonText="@string/button_cancel"
|
||||
android:persistent="false" />
|
||||
|
||||
<CheckBoxPreference android:key="android.not_a_preference.restoreSession"
|
||||
android:title="@string/pref_restore_session"
|
||||
android:defaultValue="false"
|
||||
android:persistent="true" />
|
||||
|
||||
<ListPreference android:key="app.update.autodownload"
|
||||
android:title="@string/pref_update_autodownload"
|
||||
android:entries="@array/pref_update_autodownload_entries"
|
||||
android:entryValues="@array/pref_update_autodownload_values"
|
||||
android:persistent="false" />
|
||||
|
||||
</PreferenceScreen>
|
||||
|
18
mobile/android/base/resources/xml/preferences_search.xml
Normal file
18
mobile/android/base/resources/xml/preferences_search.xml
Normal file
@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
||||
- 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/. -->
|
||||
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:gecko="http://schemas.android.com/apk/res-auto"
|
||||
android:title="@string/pref_category_search"
|
||||
android:enabled="false">
|
||||
|
||||
<CheckBoxPreference android:key="browser.search.suggest.enabled"
|
||||
android:title="@string/pref_search_suggestions"
|
||||
android:defaultValue="false"
|
||||
android:persistent="false" />
|
||||
|
||||
<org.mozilla.gecko.preferences.SearchPreferenceCategory
|
||||
android:title="@string/pref_category_installed_search_engines"/>
|
||||
</PreferenceScreen>
|
@ -80,10 +80,12 @@
|
||||
<string name="settings">&settings;</string>
|
||||
<string name="settings_title">&settings_title;</string>
|
||||
<string name="pref_category_customize">&pref_category_customize;</string>
|
||||
<string name="pref_category_search">&pref_category_search;</string>
|
||||
<string name="pref_category_display">&pref_category_display;</string>
|
||||
<string name="pref_category_privacy_short">&pref_category_privacy_short;</string>
|
||||
<string name="pref_category_vendor">&pref_category_vendor;</string>
|
||||
<string name="pref_category_datareporting">&pref_category_datareporting;</string>
|
||||
<string name="pref_category_installed_search_engines">&pref_category_installed_search_engines;</string>
|
||||
|
||||
<string name="pref_header_customize">&pref_header_customize;</string>
|
||||
<string name="pref_header_display">&pref_header_display;</string>
|
||||
|
Loading…
Reference in New Issue
Block a user