parent
dfc6524fc1
commit
404796a9fa
@ -24,6 +24,7 @@ dependencies {
|
||||
compile "com.android.support:support-vector-drawable:27.1.1"
|
||||
compile 'com.android.support.constraint:constraint-layout:1.1.0'
|
||||
compile "com.android.support:palette-v7:27.1.1"
|
||||
compile "com.android.support:preference-v7:27.1.1"
|
||||
|
||||
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
|
||||
compile 'com.google.zxing:core:3.3.2'
|
||||
@ -65,10 +66,6 @@ if (!hasProperty('sourceDeps')) {
|
||||
compile 'com.madgag.spongycastle:prov:1.54.0.0'
|
||||
compile 'com.madgag.spongycastle:core:1.54.0.0'
|
||||
|
||||
// Upstream doesn't have a binary on mavenCentral/jcenter yet:
|
||||
// https://github.com/kolavar/android-support-v4-preferencefragment/issues/13
|
||||
compile files('libs/binaryDeps/support-v4-preferencefragment-release.aar')
|
||||
|
||||
// Fork for F-Droid, including support for https. Not merged into upstream
|
||||
// yet (seems to be a little unsupported as of late), so not using mavenCentral/jcenter.
|
||||
compile files('libs/binaryDeps/nanohttpd-2.1.0.jar')
|
||||
@ -138,9 +135,6 @@ if (!hasProperty('sourceDeps')) {
|
||||
logger.info "Setting up *source* dependencies for F-Droid (because you passed in the -PsourceDeps argument to gradle while building)."
|
||||
|
||||
dependencies {
|
||||
compile(project(':extern:support-v4-preferencefragment')) {
|
||||
exclude module: 'support-v4'
|
||||
}
|
||||
compile project(':extern:nanohttpd:core')
|
||||
compile project(':extern:zipsigner')
|
||||
}
|
||||
@ -151,7 +145,6 @@ if (!hasProperty('sourceDeps')) {
|
||||
description = "Copies .jar and .aar files from subproject dependencies in extern/ to app/libs. Requires the sourceDeps property to be set (\"gradle -PsourceDeps binaryDeps\")"
|
||||
|
||||
from('../extern/') {
|
||||
include 'support-v4-preferencefragment/build/outputs/aar/support-v4-preferencefragment-release.aar'
|
||||
include 'nanohttpd/core/build/libs/nanohttpd-2.1.0.jar'
|
||||
include 'zipsigner/build/libs/zipsigner.jar'
|
||||
}
|
||||
|
Binary file not shown.
@ -1,100 +0,0 @@
|
||||
/*
|
||||
* *
|
||||
* * This file is part of QuickLyric
|
||||
* * Created by geecko
|
||||
* *
|
||||
* * QuickLyric is free software: you can redistribute it and/or modify
|
||||
* * it under the terms of the GNU General Public License as published by
|
||||
* * the Free Software Foundation, either version 3 of the License, or
|
||||
* * (at your option) any later version.
|
||||
* *
|
||||
* * QuickLyric is distributed in the hope that it will be useful,
|
||||
* * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* * GNU General Public License for more details.
|
||||
* * You should have received a copy of the GNU General Public License
|
||||
* * along with QuickLyric. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.geecko.QuickLyric.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.preference.ListPreference;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.app.AppCompatDialog;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public class AppCompatListPreference extends ListPreference {
|
||||
|
||||
private AppCompatDialog appCompatDialog;
|
||||
|
||||
public AppCompatListPreference(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public AppCompatListPreference(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AppCompatDialog getDialog() {
|
||||
return appCompatDialog;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void showDialog(Bundle state) {
|
||||
if (getEntries() == null || getEntryValues() == null) {
|
||||
throw new IllegalStateException(
|
||||
"ListPreference requires an entries array and an entryValues array.");
|
||||
}
|
||||
|
||||
int preselect = findIndexOfValue(getValue());
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getContext())
|
||||
.setTitle(getDialogTitle())
|
||||
.setIcon(getDialogIcon())
|
||||
.setSingleChoiceItems(getEntries(), preselect, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
if (which >= 0 && getEntryValues() != null) {
|
||||
String value = getEntryValues()[which].toString();
|
||||
if (callChangeListener(value) && isPersistent()) {
|
||||
setValue(value);
|
||||
}
|
||||
}
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
PreferenceManager pm = getPreferenceManager();
|
||||
try {
|
||||
Method method = pm.getClass().getDeclaredMethod(
|
||||
"registerOnActivityDestroyListener",
|
||||
PreferenceManager.OnActivityDestroyListener.class);
|
||||
method.setAccessible(true);
|
||||
method.invoke(pm, this);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
appCompatDialog = builder.create();
|
||||
if (state != null) {
|
||||
appCompatDialog.onRestoreInstanceState(state);
|
||||
}
|
||||
appCompatDialog.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityDestroy() {
|
||||
super.onActivityDestroy();
|
||||
if (appCompatDialog != null && appCompatDialog.isShowing() &&
|
||||
appCompatDialog.getWindow() != null && appCompatDialog.getWindow().getWindowManager() != null) {
|
||||
appCompatDialog.dismiss();
|
||||
}
|
||||
}
|
||||
}
|
@ -5,16 +5,15 @@ import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.preference.CheckBoxPreference;
|
||||
import android.preference.EditTextPreference;
|
||||
import android.preference.ListPreference;
|
||||
import android.preference.Preference;
|
||||
import android.preference.PreferenceCategory;
|
||||
import android.support.v4.preference.PreferenceFragment;
|
||||
import android.support.v14.preference.PreferenceFragment;
|
||||
import android.support.v7.preference.CheckBoxPreference;
|
||||
import android.support.v7.preference.EditTextPreference;
|
||||
import android.support.v7.preference.ListPreference;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.PreferenceCategory;
|
||||
import android.text.TextUtils;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import com.geecko.QuickLyric.view.AppCompatListPreference;
|
||||
import info.guardianproject.netcipher.NetCipher;
|
||||
import info.guardianproject.netcipher.proxy.OrbotHelper;
|
||||
import org.fdroid.fdroid.AppDetails2;
|
||||
@ -59,15 +58,14 @@ public class PreferencesFragment extends PreferenceFragment
|
||||
private FDroidApp fdroidApp;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
public void onCreatePreferences(Bundle bundle, String s) {
|
||||
addPreferencesFromResource(R.xml.preferences);
|
||||
useTorCheckPref = (CheckBoxPreference) findPreference(Preferences.PREF_USE_TOR);
|
||||
enableProxyCheckPref = (CheckBoxPreference) findPreference(Preferences.PREF_ENABLE_PROXY);
|
||||
updateAutoDownloadPref = findPreference(Preferences.PREF_AUTO_DOWNLOAD_INSTALL_UPDATES);
|
||||
updatePrivilegedExtensionPref = findPreference(Preferences.PREF_UNINSTALL_PRIVILEGED_APP);
|
||||
|
||||
AppCompatListPreference languagePref = (AppCompatListPreference) findPreference(Preferences.PREF_LANGUAGE);
|
||||
ListPreference languagePref = (ListPreference) findPreference(Preferences.PREF_LANGUAGE);
|
||||
if (Build.VERSION.SDK_INT >= 24) {
|
||||
PreferenceCategory category = (PreferenceCategory) findPreference("pref_category_display");
|
||||
category.removePreference(languagePref);
|
||||
@ -162,8 +160,8 @@ public class PreferencesFragment extends PreferenceFragment
|
||||
Activity activity = getActivity();
|
||||
Languages.setLanguage(activity);
|
||||
|
||||
RepoProvider.Helper.clearEtags(getContext());
|
||||
UpdateService.updateNow(getContext());
|
||||
RepoProvider.Helper.clearEtags(getActivity());
|
||||
UpdateService.updateNow(getActivity());
|
||||
|
||||
Languages.forceChangeLanguage(activity);
|
||||
}
|
||||
@ -173,7 +171,7 @@ public class PreferencesFragment extends PreferenceFragment
|
||||
entrySummary(key);
|
||||
if (changing
|
||||
&& currentKeepCacheTime != Preferences.get().getKeepCacheTime()) {
|
||||
CleanCacheService.schedule(getContext());
|
||||
CleanCacheService.schedule(getActivity());
|
||||
}
|
||||
break;
|
||||
|
||||
@ -219,9 +217,9 @@ public class PreferencesFragment extends PreferenceFragment
|
||||
case Preferences.PREF_KEEP_INSTALL_HISTORY:
|
||||
CheckBoxPreference p = (CheckBoxPreference) findPreference(key);
|
||||
if (p.isChecked()) {
|
||||
InstallHistoryService.register(getContext());
|
||||
InstallHistoryService.register(getActivity());
|
||||
} else {
|
||||
InstallHistoryService.unregister(getContext());
|
||||
InstallHistoryService.unregister(getActivity());
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -310,13 +308,13 @@ public class PreferencesFragment extends PreferenceFragment
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
if (newValue instanceof Boolean && (boolean) newValue) {
|
||||
UpdateService.autoDownloadUpdates(getContext());
|
||||
UpdateService.autoDownloadUpdates(getActivity());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
if (PrivilegedInstaller.isDefault(getContext())) {
|
||||
if (PrivilegedInstaller.isDefault(getActivity())) {
|
||||
updateAutoDownloadPref.setTitle(R.string.update_auto_install);
|
||||
updateAutoDownloadPref.setSummary(R.string.update_auto_install_summary);
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
package org.fdroid.fdroid.views.main;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Fragment;
|
||||
import android.app.FragmentTransaction;
|
||||
import android.content.Context;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.FrameLayout;
|
||||
@ -55,7 +55,7 @@ public class SettingsView extends FrameLayout {
|
||||
}
|
||||
|
||||
if (currentTransaction == null) {
|
||||
currentTransaction = activity.getSupportFragmentManager().beginTransaction();
|
||||
currentTransaction = activity.getFragmentManager().beginTransaction();
|
||||
}
|
||||
|
||||
currentTransaction.replace(getId(), new PreferencesFragment(), "preferences-fragment");
|
||||
@ -73,18 +73,18 @@ public class SettingsView extends FrameLayout {
|
||||
throw new IllegalArgumentException("Cannot add a SettingsView to activities which are not an AppCompatActivity");
|
||||
}
|
||||
|
||||
Fragment existingFragment = activity.getSupportFragmentManager().findFragmentByTag("preferences-fragment");
|
||||
Fragment existingFragment = activity.getFragmentManager().findFragmentByTag("preferences-fragment");
|
||||
if (existingFragment == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentTransaction == null) {
|
||||
currentTransaction = activity.getSupportFragmentManager().beginTransaction();
|
||||
currentTransaction = activity.getFragmentManager().beginTransaction();
|
||||
}
|
||||
currentTransaction.remove(existingFragment);
|
||||
currentTransaction.commitAllowingStateLoss();
|
||||
currentTransaction = null;
|
||||
activity.getSupportFragmentManager().executePendingTransactions();
|
||||
activity.getFragmentManager().executePendingTransactions();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -12,14 +12,14 @@ import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.preference.CheckBoxPreference;
|
||||
import android.preference.ListPreference;
|
||||
import android.preference.Preference;
|
||||
import android.support.annotation.ColorInt;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v14.preference.PreferenceFragment;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v4.preference.PreferenceFragment;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.preference.CheckBoxPreference;
|
||||
import android.support.v7.preference.ListPreference;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.text.TextUtils;
|
||||
import android.util.TypedValue;
|
||||
import info.guardianproject.panic.Panic;
|
||||
@ -30,8 +30,8 @@ import org.fdroid.fdroid.views.hiding.HidingManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class PanicPreferencesFragment extends PreferenceFragment implements SharedPreferences
|
||||
.OnSharedPreferenceChangeListener {
|
||||
public class PanicPreferencesFragment extends PreferenceFragment
|
||||
implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
|
||||
private static final String PREF_EXIT = Preferences.PREF_PANIC_EXIT;
|
||||
private static final String PREF_APP = "pref_panic_app";
|
||||
@ -43,8 +43,7 @@ public class PanicPreferencesFragment extends PreferenceFragment implements Shar
|
||||
private CheckBoxPreference prefHide;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
public void onCreatePreferences(Bundle bundle, String s) {
|
||||
addPreferencesFromResource(R.xml.preferences_panic);
|
||||
|
||||
pm = getActivity().getPackageManager();
|
||||
@ -147,9 +146,9 @@ public class PanicPreferencesFragment extends PreferenceFragment implements Shar
|
||||
prefApp.setSummary(getString(R.string.panic_app_setting_summary));
|
||||
|
||||
prefApp.setIcon(null); // otherwise re-setting view resource doesn't work
|
||||
Drawable icon = ContextCompat.getDrawable(getContext(), R.drawable.ic_cancel);
|
||||
Drawable icon = ContextCompat.getDrawable(getActivity(), R.drawable.ic_cancel);
|
||||
TypedValue typedValue = new TypedValue();
|
||||
Resources.Theme theme = getContext().getTheme();
|
||||
Resources.Theme theme = getActivity().getTheme();
|
||||
theme.resolveAttribute(R.attr.appListItem, typedValue, true);
|
||||
@ColorInt int color = typedValue.data;
|
||||
icon.setColorFilter(color, PorterDuff.Mode.SRC_IN);
|
||||
@ -189,7 +188,7 @@ public class PanicPreferencesFragment extends PreferenceFragment implements Shar
|
||||
}
|
||||
};
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||
builder.setTitle(getString(R.string.panic_app_dialog_title));
|
||||
|
||||
CharSequence app = getString(R.string.panic_app_unknown_app);
|
||||
@ -221,10 +220,10 @@ public class PanicPreferencesFragment extends PreferenceFragment implements Shar
|
||||
|
||||
private void showHideConfirmationDialog() {
|
||||
String appName = getString(R.string.app_name);
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||
builder.setTitle(R.string.panic_hide_warning_title);
|
||||
builder.setMessage(getString(R.string.panic_hide_warning_message, appName,
|
||||
HidingManager.getUnhidePin(getContext()), getString(R.string.hiding_calculator)));
|
||||
HidingManager.getUnhidePin(getActivity()), getString(R.string.hiding_calculator)));
|
||||
builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
|
@ -23,6 +23,7 @@
|
||||
<item name="appListItem">#ffffff</item>
|
||||
<item name="lightGrayTextColor">#a6a6a6</item>
|
||||
<item name="antiFeaturesWarning">@drawable/ic_warning_white_24dp</item>
|
||||
<item name="preferenceTheme">@style/PreferenceThemeOverlay</item>
|
||||
</style>
|
||||
|
||||
<style name="AppBaseThemeLight" parent="Theme.AppCompat.Light.NoActionBar">
|
||||
@ -47,6 +48,7 @@
|
||||
<item name="appListItem">#424242</item>
|
||||
<item name="lightGrayTextColor">#4a4a4a</item>
|
||||
<item name="antiFeaturesWarning">@drawable/ic_warning_black_24dp</item>
|
||||
<item name="preferenceTheme">@style/PreferenceThemeOverlay</item>
|
||||
</style>
|
||||
|
||||
<style name="AppBaseThemeNight" parent="AppThemeDark">
|
||||
|
@ -23,7 +23,7 @@
|
||||
</PreferenceScreen>
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory android:title="@string/updates">
|
||||
<com.geecko.QuickLyric.view.AppCompatListPreference android:title="@string/update_interval"
|
||||
<ListPreference android:title="@string/update_interval"
|
||||
android:key="updateInterval"
|
||||
android:defaultValue="24"
|
||||
android:entries="@array/updateIntervalNames"
|
||||
@ -41,9 +41,9 @@
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory android:title="@string/display"
|
||||
android:key="pref_category_display">
|
||||
<com.geecko.QuickLyric.view.AppCompatListPreference android:title="@string/pref_language"
|
||||
<ListPreference android:title="@string/pref_language"
|
||||
android:key="language"/>
|
||||
<com.geecko.QuickLyric.view.AppCompatListPreference android:title="@string/theme"
|
||||
<ListPreference android:title="@string/theme"
|
||||
android:key="theme"
|
||||
android:defaultValue="light"
|
||||
android:entries="@array/themeNames"
|
||||
@ -119,7 +119,7 @@
|
||||
|
||||
<PreferenceCategory android:title="@string/other"
|
||||
android:key="pref_category_other">
|
||||
<com.geecko.QuickLyric.view.AppCompatListPreference android:title="@string/cache_downloaded"
|
||||
<ListPreference android:title="@string/cache_downloaded"
|
||||
android:key="keepCacheFor"
|
||||
android:defaultValue="86400000"
|
||||
android:entries="@array/keepCacheNames"
|
||||
|
@ -1,20 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2013 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="android.support.v4.preferencefragment">
|
||||
<uses-sdk android:minSdkVersion="7"/>
|
||||
<application></application>
|
||||
</manifest>
|
191
extern/support-v4-preferencefragment/LICENSE
vendored
191
extern/support-v4-preferencefragment/LICENSE
vendored
@ -1,191 +0,0 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction, and
|
||||
distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by the copyright
|
||||
owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all other entities
|
||||
that control, are controlled by, or are under common control with that entity.
|
||||
For the purposes of this definition, "control" means (i) the power, direct or
|
||||
indirect, to cause the direction or management of such entity, whether by
|
||||
contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity exercising
|
||||
permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications, including
|
||||
but not limited to software source code, documentation source, and configuration
|
||||
files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical transformation or
|
||||
translation of a Source form, including but not limited to compiled object code,
|
||||
generated documentation, and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or Object form, made
|
||||
available under the License, as indicated by a copyright notice that is included
|
||||
in or attached to the work (an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object form, that
|
||||
is based on (or derived from) the Work and for which the editorial revisions,
|
||||
annotations, elaborations, or other modifications represent, as a whole, an
|
||||
original work of authorship. For the purposes of this License, Derivative Works
|
||||
shall not include works that remain separable from, or merely link (or bind by
|
||||
name) to the interfaces of, the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including the original version
|
||||
of the Work and any modifications or additions to that Work or Derivative Works
|
||||
thereof, that is intentionally submitted to Licensor for inclusion in the Work
|
||||
by the copyright owner or by an individual or Legal Entity authorized to submit
|
||||
on behalf of the copyright owner. For the purposes of this definition,
|
||||
"submitted" means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems, and
|
||||
issue tracking systems that are managed by, or on behalf of, the Licensor for
|
||||
the purpose of discussing and improving the Work, but excluding communication
|
||||
that is conspicuously marked or otherwise designated in writing by the copyright
|
||||
owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf
|
||||
of whom a Contribution has been received by Licensor and subsequently
|
||||
incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License.
|
||||
|
||||
Subject to the terms and conditions of this License, each Contributor hereby
|
||||
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
|
||||
irrevocable copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the Work and such
|
||||
Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License.
|
||||
|
||||
Subject to the terms and conditions of this License, each Contributor hereby
|
||||
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
|
||||
irrevocable (except as stated in this section) patent license to make, have
|
||||
made, use, offer to sell, sell, import, and otherwise transfer the Work, where
|
||||
such license applies only to those patent claims licensable by such Contributor
|
||||
that are necessarily infringed by their Contribution(s) alone or by combination
|
||||
of their Contribution(s) with the Work to which such Contribution(s) was
|
||||
submitted. If You institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work or a
|
||||
Contribution incorporated within the Work constitutes direct or contributory
|
||||
patent infringement, then any patent licenses granted to You under this License
|
||||
for that Work shall terminate as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution.
|
||||
|
||||
You may reproduce and distribute copies of the Work or Derivative Works thereof
|
||||
in any medium, with or without modifications, and in Source or Object form,
|
||||
provided that You meet the following conditions:
|
||||
|
||||
You must give any other recipients of the Work or Derivative Works a copy of
|
||||
this License; and
|
||||
You must cause any modified files to carry prominent notices stating that You
|
||||
changed the files; and
|
||||
You must retain, in the Source form of any Derivative Works that You distribute,
|
||||
all copyright, patent, trademark, and attribution notices from the Source form
|
||||
of the Work, excluding those notices that do not pertain to any part of the
|
||||
Derivative Works; and
|
||||
If the Work includes a "NOTICE" text file as part of its distribution, then any
|
||||
Derivative Works that You distribute must include a readable copy of the
|
||||
attribution notices contained within such NOTICE file, excluding those notices
|
||||
that do not pertain to any part of the Derivative Works, in at least one of the
|
||||
following places: within a NOTICE text file distributed as part of the
|
||||
Derivative Works; within the Source form or documentation, if provided along
|
||||
with the Derivative Works; or, within a display generated by the Derivative
|
||||
Works, if and wherever such third-party notices normally appear. The contents of
|
||||
the NOTICE file are for informational purposes only and do not modify the
|
||||
License. You may add Your own attribution notices within Derivative Works that
|
||||
You distribute, alongside or as an addendum to the NOTICE text from the Work,
|
||||
provided that such additional attribution notices cannot be construed as
|
||||
modifying the License.
|
||||
You may add Your own copyright statement to Your modifications and may provide
|
||||
additional or different license terms and conditions for use, reproduction, or
|
||||
distribution of Your modifications, or for any such Derivative Works as a whole,
|
||||
provided Your use, reproduction, and distribution of the Work otherwise complies
|
||||
with the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions.
|
||||
|
||||
Unless You explicitly state otherwise, any Contribution intentionally submitted
|
||||
for inclusion in the Work by You to the Licensor shall be under the terms and
|
||||
conditions of this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify the terms of
|
||||
any separate license agreement you may have executed with Licensor regarding
|
||||
such Contributions.
|
||||
|
||||
6. Trademarks.
|
||||
|
||||
This License does not grant permission to use the trade names, trademarks,
|
||||
service marks, or product names of the Licensor, except as required for
|
||||
reasonable and customary use in describing the origin of the Work and
|
||||
reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty.
|
||||
|
||||
Unless required by applicable law or agreed to in writing, Licensor provides the
|
||||
Work (and each Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
|
||||
including, without limitation, any warranties or conditions of TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are
|
||||
solely responsible for determining the appropriateness of using or
|
||||
redistributing the Work and assume any risks associated with Your exercise of
|
||||
permissions under this License.
|
||||
|
||||
8. Limitation of Liability.
|
||||
|
||||
In no event and under no legal theory, whether in tort (including negligence),
|
||||
contract, or otherwise, unless required by applicable law (such as deliberate
|
||||
and grossly negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special, incidental,
|
||||
or consequential damages of any character arising as a result of this License or
|
||||
out of the use or inability to use the Work (including but not limited to
|
||||
damages for loss of goodwill, work stoppage, computer failure or malfunction, or
|
||||
any and all other commercial damages or losses), even if such Contributor has
|
||||
been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability.
|
||||
|
||||
While redistributing the Work or Derivative Works thereof, You may choose to
|
||||
offer, and charge a fee for, acceptance of support, warranty, indemnity, or
|
||||
other liability obligations and/or rights consistent with this License. However,
|
||||
in accepting such obligations, You may act only on Your own behalf and on Your
|
||||
sole responsibility, not on behalf of any other Contributor, and only if You
|
||||
agree to indemnify, defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason of your
|
||||
accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work
|
||||
|
||||
To apply the Apache License to your work, attach the following boilerplate
|
||||
notice, with the fields enclosed by brackets "[]" replaced with your own
|
||||
identifying information. (Don't include the brackets!) The text should be
|
||||
enclosed in the appropriate comment syntax for the file format. We also
|
||||
recommend that a file or class name and description of purpose be included on
|
||||
the same "printed page" as the copyright notice for easier identification within
|
||||
third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
@ -1,41 +0,0 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
jcenter()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// 2.2.2 is the version that is included in Debian/stretch
|
||||
classpath 'com.android.tools.build:gradle:2.2.2'
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: 'android-library'
|
||||
|
||||
version = VERSION
|
||||
group = GROUP
|
||||
|
||||
dependencies {
|
||||
compile 'com.android.support:support-v4:19.0.+'
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdkVersion 19
|
||||
buildToolsVersion '25.0.2'
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion 7
|
||||
targetSdkVersion 19
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
manifest.srcFile 'AndroidManifest.xml'
|
||||
java.srcDirs = ['src']
|
||||
resources.srcDirs = ['src']
|
||||
aidl.srcDirs = ['src']
|
||||
renderscript.srcDirs = ['src']
|
||||
res.srcDirs = ['res']
|
||||
assets.srcDirs = ['assets']
|
||||
}
|
||||
}
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
# Project-wide Gradle settings.
|
||||
|
||||
# IDE (e.g. Android Studio) users:
|
||||
# Settings specified in this file will override any Gradle settings
|
||||
# configured through the IDE.
|
||||
|
||||
# For more details on how to configure your build environment visit
|
||||
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
||||
|
||||
# Specifies the JVM arguments used for the daemon process.
|
||||
# The setting is particularly useful for tweaking memory settings.
|
||||
# Default value: -Xmx10248m -XX:MaxPermSize=256m
|
||||
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
|
||||
|
||||
# When configured, Gradle will run in incubating parallel mode.
|
||||
# This option should only be used with decoupled projects. More details, visit
|
||||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
||||
# org.gradle.parallel=true
|
||||
|
||||
GROUP=com.android.support
|
||||
VERSION=1.0.0
|
||||
ARTIFACT_ID=support-v4-preferencefragment
|
@ -1,15 +0,0 @@
|
||||
# This file is automatically generated by Android Tools.
|
||||
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
|
||||
#
|
||||
# This file must be checked in Version Control Systems.
|
||||
#
|
||||
# To customize properties used by the Ant build system edit
|
||||
# "ant.properties", and override values to adapt the script to your
|
||||
# project structure.
|
||||
#
|
||||
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
|
||||
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
|
||||
|
||||
# Project target.
|
||||
target=android-15
|
||||
android.library=true
|
@ -1,82 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
/*
|
||||
** Copyright 2010, The Android Open Source Project
|
||||
**
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
** you may not use this file except in compliance with the License.
|
||||
** You may obtain a copy of the License at
|
||||
**
|
||||
** http://www.apache.org/licenses/LICENSE-2.0
|
||||
**
|
||||
** Unless required by applicable law or agreed to in writing, software
|
||||
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
** See the License for the specific language governing permissions and
|
||||
** limitations under the License.
|
||||
*/
|
||||
-->
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_width="fill_parent"
|
||||
android:background="@android:color/transparent">
|
||||
|
||||
<ListView android:id="@android:id/list"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="0px"
|
||||
android:layout_weight="1"
|
||||
android:paddingTop="0dip"
|
||||
android:paddingBottom="@dimen/preference_fragment_padding_bottom"
|
||||
android:paddingLeft="@dimen/preference_fragment_padding_side"
|
||||
android:paddingRight="@dimen/preference_fragment_padding_side"
|
||||
android:scrollbarStyle="@integer/preference_fragment_scrollbarStyle"
|
||||
android:clipToPadding="false"
|
||||
android:drawSelectorOnTop="false"
|
||||
android:cacheColorHint="@android:color/transparent"
|
||||
android:scrollbarAlwaysDrawVerticalTrack="true" />
|
||||
|
||||
<TextView android:id="@android:id/empty"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:padding="@dimen/preference_fragment_padding_side"
|
||||
android:gravity="center"
|
||||
android:visibility="gone" />
|
||||
|
||||
<RelativeLayout android:id="@+id/button_bar"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_weight="0"
|
||||
android:visibility="gone">
|
||||
|
||||
<Button android:id="@+id/back_button"
|
||||
android:layout_width="150dip"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="5dip"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:text="@string/back_button_label"
|
||||
/>
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true">
|
||||
|
||||
<Button android:id="@+id/skip_button"
|
||||
android:layout_width="150dip"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="5dip"
|
||||
android:text="@string/skip_button_label"
|
||||
android:visibility="gone"
|
||||
/>
|
||||
|
||||
<Button android:id="@+id/next_button"
|
||||
android:layout_width="150dip"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="5dip"
|
||||
android:text="@string/next_button_label"
|
||||
/>
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
@ -1,9 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<!-- Preference fragment padding, bottom -->
|
||||
<dimen name="preference_fragment_padding_bottom">0dp</dimen>
|
||||
<!-- Preference fragment padding, sides -->
|
||||
<dimen name="preference_fragment_padding_side">16dp</dimen>
|
||||
|
||||
</resources>
|
@ -1,7 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<!-- Preference fragment padding, sides -->
|
||||
<dimen name="preference_fragment_padding_side">8dp</dimen>
|
||||
|
||||
</resources>
|
@ -1,7 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<!-- Preference fragment padding, sides -->
|
||||
<dimen name="preference_fragment_padding_side">32dp</dimen>
|
||||
|
||||
</resources>
|
@ -1,29 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
/* //device/apps/common/assets/res/any/dimens.xml
|
||||
**
|
||||
** Copyright 2006, The Android Open Source Project
|
||||
**
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
** you may not use this file except in compliance with the License.
|
||||
** You may obtain a copy of the License at
|
||||
**
|
||||
** http://www.apache.org/licenses/LICENSE-2.0
|
||||
**
|
||||
** Unless required by applicable law or agreed to in writing, software
|
||||
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
** See the License for the specific language governing permissions and
|
||||
** limitations under the License.
|
||||
*/
|
||||
-->
|
||||
<resources>
|
||||
|
||||
<!-- Preference fragment padding, bottom -->
|
||||
<dimen name="preference_fragment_padding_bottom">0dp</dimen>
|
||||
<!-- Preference fragment padding, sides -->
|
||||
<dimen name="preference_fragment_padding_side">16dp</dimen>
|
||||
|
||||
<integer name="preference_fragment_scrollbarStyle">0x02000000</integer> <!-- outsideOverlay -->
|
||||
|
||||
</resources>
|
@ -1,29 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
/* //device/apps/common/assets/res/any/strings.xml
|
||||
**
|
||||
** Copyright 2006, The Android Open Source Project
|
||||
**
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
** you may not use this file except in compliance with the License.
|
||||
** You may obtain a copy of the License at
|
||||
**
|
||||
** http://www.apache.org/licenses/LICENSE-2.0
|
||||
**
|
||||
** Unless required by applicable law or agreed to in writing, software
|
||||
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
** See the License for the specific language governing permissions and
|
||||
** limitations under the License.
|
||||
*/
|
||||
-->
|
||||
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
|
||||
|
||||
<!-- Strings for possible PreferenceActivity Back/Next buttons -->
|
||||
<string name="back_button_label">Back</string>
|
||||
<string name="next_button_label">Next</string>
|
||||
|
||||
<!-- Optional button to Skip a PreferenceActivity [CHAR LIMIT=20] -->
|
||||
<string name="skip_button_label">Skip</string>
|
||||
|
||||
</resources>
|
@ -1,2 +0,0 @@
|
||||
This hidden file is there to ensure there is an src folder.
|
||||
Once we support binary library this will go away.
|
@ -1,349 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2013 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.support.v4.preference;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.preference.Preference;
|
||||
import android.preference.PreferenceGroup;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.preference.PreferenceScreen;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.preferencefragment.R;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.View.OnKeyListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ListView;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public abstract class PreferenceFragment extends Fragment implements
|
||||
PreferenceManagerCompat.OnPreferenceTreeClickListener {
|
||||
|
||||
private static final String PREFERENCES_TAG = "android:preferences";
|
||||
|
||||
private PreferenceManager mPreferenceManager;
|
||||
private ListView mList;
|
||||
private boolean mHavePrefs;
|
||||
private boolean mInitDone;
|
||||
|
||||
/**
|
||||
* The starting request code given out to preference framework.
|
||||
*/
|
||||
private static final int FIRST_REQUEST_CODE = 100;
|
||||
|
||||
private static final int MSG_BIND_PREFERENCES = 1;
|
||||
private Handler mHandler = new Handler() {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
switch (msg.what) {
|
||||
|
||||
case MSG_BIND_PREFERENCES:
|
||||
bindPreferences();
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
final private Runnable mRequestFocus = new Runnable() {
|
||||
public void run() {
|
||||
mList.focusableViewAvailable(mList);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Interface that PreferenceFragment's containing activity should
|
||||
* implement to be able to process preference items that wish to
|
||||
* switch to a new fragment.
|
||||
*/
|
||||
public interface OnPreferenceStartFragmentCallback {
|
||||
/**
|
||||
* Called when the user has clicked on a Preference that has
|
||||
* a fragment class name associated with it. The implementation
|
||||
* to should instantiate and switch to an instance of the given
|
||||
* fragment.
|
||||
*/
|
||||
boolean onPreferenceStartFragment(PreferenceFragment caller, Preference pref);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle paramBundle) {
|
||||
super.onCreate(paramBundle);
|
||||
mPreferenceManager = PreferenceManagerCompat.newInstance(getActivity(), FIRST_REQUEST_CODE);
|
||||
PreferenceManagerCompat.setFragment(mPreferenceManager, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater paramLayoutInflater, ViewGroup paramViewGroup,
|
||||
Bundle paramBundle) {
|
||||
return paramLayoutInflater.inflate(R.layout.preference_list_fragment, paramViewGroup,
|
||||
false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
|
||||
if (mHavePrefs) {
|
||||
bindPreferences();
|
||||
}
|
||||
|
||||
mInitDone = true;
|
||||
|
||||
if (savedInstanceState != null) {
|
||||
Bundle container = savedInstanceState.getBundle(PREFERENCES_TAG);
|
||||
if (container != null) {
|
||||
final PreferenceScreen preferenceScreen = getPreferenceScreen();
|
||||
if (preferenceScreen != null) {
|
||||
preferenceScreen.restoreHierarchyState(container);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
PreferenceManagerCompat.setOnPreferenceTreeClickListener(mPreferenceManager, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
super.onStop();
|
||||
PreferenceManagerCompat.dispatchActivityStop(mPreferenceManager);
|
||||
PreferenceManagerCompat.setOnPreferenceTreeClickListener(mPreferenceManager, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
mList = null;
|
||||
mHandler.removeCallbacks(mRequestFocus);
|
||||
mHandler.removeMessages(MSG_BIND_PREFERENCES);
|
||||
super.onDestroyView();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
PreferenceManagerCompat.dispatchActivityDestroy(mPreferenceManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
|
||||
final PreferenceScreen preferenceScreen = getPreferenceScreen();
|
||||
if (preferenceScreen != null) {
|
||||
Bundle container = new Bundle();
|
||||
preferenceScreen.saveHierarchyState(container);
|
||||
outState.putBundle(PREFERENCES_TAG, container);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
|
||||
PreferenceManagerCompat.dispatchActivityResult(mPreferenceManager, requestCode, resultCode, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link PreferenceManager} used by this fragment.
|
||||
* @return The {@link PreferenceManager}.
|
||||
*/
|
||||
public PreferenceManager getPreferenceManager() {
|
||||
return mPreferenceManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the root of the preference hierarchy that this fragment is showing.
|
||||
*
|
||||
* @param preferenceScreen The root {@link PreferenceScreen} of the preference hierarchy.
|
||||
*/
|
||||
public void setPreferenceScreen(PreferenceScreen preferenceScreen) {
|
||||
if (PreferenceManagerCompat.setPreferences(mPreferenceManager, preferenceScreen) && preferenceScreen != null) {
|
||||
mHavePrefs = true;
|
||||
if (mInitDone) {
|
||||
postBindPreferences();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the root of the preference hierarchy that this fragment is showing.
|
||||
*
|
||||
* @return The {@link PreferenceScreen} that is the root of the preference
|
||||
* hierarchy.
|
||||
*/
|
||||
public PreferenceScreen getPreferenceScreen() {
|
||||
return PreferenceManagerCompat.getPreferenceScreen(mPreferenceManager);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds preferences from activities that match the given {@link Intent}.
|
||||
*
|
||||
* @param intent The {@link Intent} to query activities.
|
||||
*/
|
||||
public void addPreferencesFromIntent(Intent intent) {
|
||||
requirePreferenceManager();
|
||||
|
||||
setPreferenceScreen(PreferenceManagerCompat.inflateFromIntent(mPreferenceManager, intent, getPreferenceScreen()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Inflates the given XML resource and adds the preference hierarchy to the current
|
||||
* preference hierarchy.
|
||||
*
|
||||
* @param preferencesResId The XML resource ID to inflate.
|
||||
*/
|
||||
public void addPreferencesFromResource(int preferencesResId) {
|
||||
requirePreferenceManager();
|
||||
|
||||
setPreferenceScreen(PreferenceManagerCompat.inflateFromResource(mPreferenceManager, getActivity(),
|
||||
preferencesResId, getPreferenceScreen()));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen,
|
||||
Preference preference) {
|
||||
//if (preference.getFragment() != null &&
|
||||
if (
|
||||
getActivity() instanceof OnPreferenceStartFragmentCallback) {
|
||||
return ((OnPreferenceStartFragmentCallback)getActivity()).onPreferenceStartFragment(
|
||||
this, preference);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds a {@link Preference} based on its key.
|
||||
*
|
||||
* @param key The key of the preference to retrieve.
|
||||
* @return The {@link Preference} with the key, or null.
|
||||
* @see PreferenceGroup#findPreference(CharSequence)
|
||||
*/
|
||||
public Preference findPreference(CharSequence key) {
|
||||
if (mPreferenceManager == null) {
|
||||
return null;
|
||||
}
|
||||
return mPreferenceManager.findPreference(key);
|
||||
}
|
||||
|
||||
private void requirePreferenceManager() {
|
||||
if (mPreferenceManager == null) {
|
||||
throw new RuntimeException("This should be called after super.onCreate.");
|
||||
}
|
||||
}
|
||||
|
||||
private void postBindPreferences() {
|
||||
if (mHandler.hasMessages(MSG_BIND_PREFERENCES)) return;
|
||||
mHandler.obtainMessage(MSG_BIND_PREFERENCES).sendToTarget();
|
||||
}
|
||||
|
||||
private void bindPreferences() {
|
||||
final PreferenceScreen preferenceScreen = getPreferenceScreen();
|
||||
if (preferenceScreen != null) {
|
||||
preferenceScreen.bind(getListView());
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD_MR1) {
|
||||
// Workaround android bug for SDK 10 and below - see
|
||||
// https://github.com/android/platform_frameworks_base/commit/2d43d283fc0f22b08f43c6db4da71031168e7f59
|
||||
getListView().setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
// If the list has headers, subtract them from the index.
|
||||
if (parent instanceof ListView) {
|
||||
position -= ((ListView)parent).getHeaderViewsCount();
|
||||
}
|
||||
|
||||
Object item = preferenceScreen.getRootAdapter().getItem(position);
|
||||
if (!(item instanceof Preference))
|
||||
return;
|
||||
|
||||
final Preference preference = (Preference)item;
|
||||
try {
|
||||
Method performClick = Preference.class.getDeclaredMethod(
|
||||
"performClick", PreferenceScreen.class);
|
||||
performClick.setAccessible(true);
|
||||
performClick.invoke(preference, preferenceScreen);
|
||||
} catch (InvocationTargetException e) {
|
||||
} catch (IllegalAccessException e) {
|
||||
} catch (NoSuchMethodException e) {
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public ListView getListView() {
|
||||
ensureList();
|
||||
return mList;
|
||||
}
|
||||
|
||||
private void ensureList() {
|
||||
if (mList != null) {
|
||||
return;
|
||||
}
|
||||
View root = getView();
|
||||
if (root == null) {
|
||||
throw new IllegalStateException("Content view not yet created");
|
||||
}
|
||||
View rawListView = root.findViewById(android.R.id.list);
|
||||
if (!(rawListView instanceof ListView)) {
|
||||
throw new RuntimeException(
|
||||
"Content has view with id attribute 'android.R.id.list' "
|
||||
+ "that is not a ListView class");
|
||||
}
|
||||
mList = (ListView)rawListView;
|
||||
if (mList == null) {
|
||||
throw new RuntimeException(
|
||||
"Your content must have a ListView whose id attribute is " +
|
||||
"'android.R.id.list'");
|
||||
}
|
||||
mList.setOnKeyListener(mListOnKeyListener);
|
||||
mHandler.post(mRequestFocus);
|
||||
}
|
||||
|
||||
private OnKeyListener mListOnKeyListener = new OnKeyListener() {
|
||||
|
||||
@Override
|
||||
public boolean onKey(View v, int keyCode, KeyEvent event) {
|
||||
Object selectedItem = mList.getSelectedItem();
|
||||
if (selectedItem instanceof Preference) {
|
||||
@SuppressWarnings("unused")
|
||||
View selectedView = mList.getSelectedView();
|
||||
//return ((Preference)selectedItem).onKey(
|
||||
// selectedView, keyCode, event);
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
}
|
@ -1,230 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2013 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.support.v4.preference;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationHandler;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Proxy;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.preference.Preference;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.preference.PreferenceScreen;
|
||||
import android.util.Log;
|
||||
|
||||
public class PreferenceManagerCompat {
|
||||
|
||||
private static final String TAG = PreferenceManagerCompat.class.getSimpleName();
|
||||
|
||||
/**
|
||||
* Interface definition for a callback to be invoked when a
|
||||
* {@link Preference} in the hierarchy rooted at this {@link PreferenceScreen} is
|
||||
* clicked.
|
||||
*/
|
||||
interface OnPreferenceTreeClickListener {
|
||||
/**
|
||||
* Called when a preference in the tree rooted at this
|
||||
* {@link PreferenceScreen} has been clicked.
|
||||
*
|
||||
* @param preferenceScreen The {@link PreferenceScreen} that the
|
||||
* preference is located in.
|
||||
* @param preference The preference that was clicked.
|
||||
* @return Whether the click was handled.
|
||||
*/
|
||||
boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference);
|
||||
}
|
||||
|
||||
static PreferenceManager newInstance(Activity activity, int firstRequestCode) {
|
||||
try {
|
||||
Constructor<PreferenceManager> c = PreferenceManager.class.getDeclaredConstructor(Activity.class, int.class);
|
||||
c.setAccessible(true);
|
||||
return c.newInstance(activity, firstRequestCode);
|
||||
} catch (Exception e) {
|
||||
Log.w(TAG, "Couldn't call constructor PreferenceManager by reflection", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the owning preference fragment
|
||||
*/
|
||||
static void setFragment(PreferenceManager manager, PreferenceFragment fragment) {
|
||||
// stub
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the callback to be invoked when a {@link Preference} in the
|
||||
* hierarchy rooted at this {@link PreferenceManager} is clicked.
|
||||
*
|
||||
* @param listener The callback to be invoked.
|
||||
*/
|
||||
static void setOnPreferenceTreeClickListener(PreferenceManager manager, final OnPreferenceTreeClickListener listener) {
|
||||
try {
|
||||
Field onPreferenceTreeClickListener = PreferenceManager.class.getDeclaredField("mOnPreferenceTreeClickListener");
|
||||
onPreferenceTreeClickListener.setAccessible(true);
|
||||
if (listener != null) {
|
||||
Object proxy = Proxy.newProxyInstance(
|
||||
onPreferenceTreeClickListener.getType().getClassLoader(),
|
||||
new Class[] { onPreferenceTreeClickListener.getType() },
|
||||
new InvocationHandler() {
|
||||
public Object invoke(Object proxy, Method method, Object[] args) {
|
||||
if (method.getName().equals("onPreferenceTreeClick")) {
|
||||
return Boolean.valueOf(listener.onPreferenceTreeClick((PreferenceScreen) args[0], (Preference) args[1]));
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
});
|
||||
onPreferenceTreeClickListener.set(manager, proxy);
|
||||
} else {
|
||||
onPreferenceTreeClickListener.set(manager, null);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.w(TAG, "Couldn't set PreferenceManager.mOnPreferenceTreeClickListener by reflection", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Inflates a preference hierarchy from the preference hierarchies of
|
||||
* {@link Activity Activities} that match the given {@link Intent}. An
|
||||
* {@link Activity} defines its preference hierarchy with meta-data using
|
||||
* the {@link #METADATA_KEY_PREFERENCES} key.
|
||||
* <p>
|
||||
* If a preference hierarchy is given, the new preference hierarchies will
|
||||
* be merged in.
|
||||
*
|
||||
* @param queryIntent The intent to match activities.
|
||||
* @param rootPreferences Optional existing hierarchy to merge the new
|
||||
* hierarchies into.
|
||||
* @return The root hierarchy (if one was not provided, the new hierarchy's
|
||||
* root).
|
||||
*/
|
||||
static PreferenceScreen inflateFromIntent(PreferenceManager manager, Intent intent, PreferenceScreen screen) {
|
||||
try {
|
||||
Method m = PreferenceManager.class.getDeclaredMethod("inflateFromIntent", Intent.class, PreferenceScreen.class);
|
||||
m.setAccessible(true);
|
||||
PreferenceScreen prefScreen = (PreferenceScreen) m.invoke(manager, intent, screen);
|
||||
return prefScreen;
|
||||
} catch (Exception e) {
|
||||
Log.w(TAG, "Couldn't call PreferenceManager.inflateFromIntent by reflection", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inflates a preference hierarchy from XML. If a preference hierarchy is
|
||||
* given, the new preference hierarchies will be merged in.
|
||||
*
|
||||
* @param context The context of the resource.
|
||||
* @param resId The resource ID of the XML to inflate.
|
||||
* @param rootPreferences Optional existing hierarchy to merge the new
|
||||
* hierarchies into.
|
||||
* @return The root hierarchy (if one was not provided, the new hierarchy's
|
||||
* root).
|
||||
* @hide
|
||||
*/
|
||||
static PreferenceScreen inflateFromResource(PreferenceManager manager, Activity activity, int resId, PreferenceScreen screen) {
|
||||
try {
|
||||
Method m = PreferenceManager.class.getDeclaredMethod("inflateFromResource", Context.class, int.class, PreferenceScreen.class);
|
||||
m.setAccessible(true);
|
||||
PreferenceScreen prefScreen = (PreferenceScreen) m.invoke(manager, activity, resId, screen);
|
||||
return prefScreen;
|
||||
} catch (Exception e) {
|
||||
Log.w(TAG, "Couldn't call PreferenceManager.inflateFromResource by reflection", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the root of the preference hierarchy managed by this class.
|
||||
*
|
||||
* @return The {@link PreferenceScreen} object that is at the root of the hierarchy.
|
||||
*/
|
||||
static PreferenceScreen getPreferenceScreen(PreferenceManager manager) {
|
||||
try {
|
||||
Method m = PreferenceManager.class.getDeclaredMethod("getPreferenceScreen");
|
||||
m.setAccessible(true);
|
||||
return (PreferenceScreen) m.invoke(manager);
|
||||
} catch (Exception e) {
|
||||
Log.w(TAG, "Couldn't call PreferenceManager.getPreferenceScreen by reflection", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by the {@link PreferenceManager} to dispatch a subactivity result.
|
||||
*/
|
||||
static void dispatchActivityResult(PreferenceManager manager, int requestCode, int resultCode, Intent data) {
|
||||
try {
|
||||
Method m = PreferenceManager.class.getDeclaredMethod("dispatchActivityResult", int.class, int.class, Intent.class);
|
||||
m.setAccessible(true);
|
||||
m.invoke(manager, requestCode, resultCode, data);
|
||||
} catch (Exception e) {
|
||||
Log.w(TAG, "Couldn't call PreferenceManager.dispatchActivityResult by reflection", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by the {@link PreferenceManager} to dispatch the activity stop
|
||||
* event.
|
||||
*/
|
||||
static void dispatchActivityStop(PreferenceManager manager) {
|
||||
try {
|
||||
Method m = PreferenceManager.class.getDeclaredMethod("dispatchActivityStop");
|
||||
m.setAccessible(true);
|
||||
m.invoke(manager);
|
||||
} catch (Exception e) {
|
||||
Log.w(TAG, "Couldn't call PreferenceManager.dispatchActivityStop by reflection", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by the {@link PreferenceManager} to dispatch the activity destroy
|
||||
* event.
|
||||
*/
|
||||
static void dispatchActivityDestroy(PreferenceManager manager) {
|
||||
try {
|
||||
Method m = PreferenceManager.class.getDeclaredMethod("dispatchActivityDestroy");
|
||||
m.setAccessible(true);
|
||||
m.invoke(manager);
|
||||
} catch (Exception e) {
|
||||
Log.w(TAG, "Couldn't call PreferenceManager.dispatchActivityDestroy by reflection", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the root of the preference hierarchy.
|
||||
*
|
||||
* @param preferenceScreen The root {@link PreferenceScreen} of the preference hierarchy.
|
||||
* @return Whether the {@link PreferenceScreen} given is different than the previous.
|
||||
*/
|
||||
static boolean setPreferences(PreferenceManager manager, PreferenceScreen screen) {
|
||||
try {
|
||||
Method m = PreferenceManager.class.getDeclaredMethod("setPreferences", PreferenceScreen.class);
|
||||
m.setAccessible(true);
|
||||
return ((Boolean) m.invoke(manager, screen));
|
||||
} catch (Exception e) {
|
||||
Log.w(TAG, "Couldn't call PreferenceManager.setPreferences by reflection", e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user