Search in sources :

Example 6 with Preference

use of android.preference.Preference in project MWM-for-Android-Gen1 by MetaWatchOpenProjects.

the class Settings method onStart.

@Override
protected void onStart() {
    Log.d(MetaWatch.TAG, "set onstart");
    editTextMac = (EditTextPreference) preferenceScreen.findPreference("MAC");
    editTextMac.setText(MetaWatchService.Preferences.watchMacAddress);
    discovery = preferenceScreen.findPreference("Discovery");
    discovery.setOnPreferenceClickListener(new OnPreferenceClickListener() {

        public boolean onPreferenceClick(Preference arg0) {
            Log.d(MetaWatch.TAG, "discovery click");
            startActivity(new Intent(context, DeviceSelection.class));
            return false;
        }
    });
    super.onStart();
}
Also used : OnPreferenceClickListener(android.preference.Preference.OnPreferenceClickListener) EditTextPreference(android.preference.EditTextPreference) Preference(android.preference.Preference) Intent(android.content.Intent)

Example 7 with Preference

use of android.preference.Preference in project Xposed-Tinted-Status-Bar by MohammadAG.

the class SettingsActivity method onPostCreate.

@SuppressWarnings({ "deprecation" })
@Override
protected void onPostCreate(Bundle savedInstanceState) {
    super.onPostCreate(savedInstanceState);
    getPreferenceManager().setSharedPreferencesMode(MODE_WORLD_READABLE);
    addPreferencesFromResource(R.xml.pref_general);
    Preference copyrightPreference = findPreference("copyright_key");
    copyrightPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {

        @Override
        public boolean onPreferenceClick(Preference preference) {
            AlertDialog.Builder builder = new AlertDialog.Builder(SettingsActivity.this);
            builder.setTitle("").setItems(R.array.my_apps, new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog, int which) {
                    Uri uri = null;
                    Intent intent = new Intent(Intent.ACTION_VIEW);
                    switch(which) {
                        case 0:
                            uri = Uri.parse(URL_MY_APPS);
                            intent.setPackage("com.android.vending");
                            break;
                        case 1:
                            uri = Uri.parse(URL_MY_MODULES);
                            break;
                        case 2:
                            uri = Uri.parse("https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=KGGZ5C3AVC8ZU");
                            break;
                    }
                    startActivity(intent.setData(uri));
                }
            });
            builder.create().show();
            return false;
        }
    });
    Preference donatePreference = findPreference("donate_key");
    donatePreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {

        @Override
        public boolean onPreferenceClick(Preference arg0) {
            Intent intent = new Intent(Intent.ACTION_VIEW).setData(Uri.parse(URL_DONATION_PACKAGE));
            intent.setPackage("com.android.vending");
            startActivity(intent);
            return false;
        }
    });
    if (Utils.isDonateVersionInstalled(getApplicationContext())) {
        copyrightPreference.setTitle(R.string.app_name_donate_version);
        donatePreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {

            @Override
            public boolean onPreferenceClick(Preference preference) {
                Toast.makeText(SettingsActivity.this, R.string.thank_you, Toast.LENGTH_SHORT).show();
                return false;
            }
        });
        donatePreference.setTitle(R.string.thank_you);
        donatePreference.setSummary(R.string.thank_you_summary);
    }
    String[] colorKeys = { SettingsKeys.DEFAULT_STATUS_BAR_TINT, SettingsKeys.DEFAULT_STATUS_BAR_ICON_TINT, SettingsKeys.DEFAULT_STATUS_BAR_INVERTED_ICON_TINT, SettingsKeys.DEFAULT_NAV_BAR_TINT, SettingsKeys.DEFAULT_NAV_BAR_ICON_TINT, SettingsKeys.DEFAULT_NAV_BAR_IM_TINT, SettingsKeys.DEFAULT_NAV_BAR_ICON_IM_TINT };
    intializeColorPreferences(colorKeys);
    findPreference(SettingsKeys.LINK_PANEL_VIEW_COLORS).setOnPreferenceChangeListener(new OnPreferenceChangeListener() {

        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            sendBroadcast(new Intent(Common.INTENT_SETTINGS_UPDATED));
            return true;
        }
    });
    ListPreference overlayTypePreference = (ListPreference) findPreference("pref_overlay_type");
    final Preference overlayTransparencyPreference = findPreference("pref_semi_transparent_overlay_opacity");
    if (overlayTypePreference.getValue().equals("semi_transparent"))
        overlayTransparencyPreference.setEnabled(true);
    overlayTypePreference.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {

        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            if (newValue.equals("semi_transparent"))
                overlayTransparencyPreference.setEnabled(true);
            else
                overlayTransparencyPreference.setEnabled(false);
            return true;
        }
    });
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) Intent(android.content.Intent) OnPreferenceChangeListener(android.preference.Preference.OnPreferenceChangeListener) ListPreference(android.preference.ListPreference) Uri(android.net.Uri) OnPreferenceClickListener(android.preference.Preference.OnPreferenceClickListener) ListPreference(android.preference.ListPreference) ColorPreference(com.mohammadag.colouredstatusbar.preferences.ColorPreference) Preference(android.preference.Preference)

Example 8 with Preference

use of android.preference.Preference in project NimbusBase_Android_Tutorial by NimbusBase.

the class IndexFragment method initiatePreferenceScreen.

protected PreferenceScreen initiatePreferenceScreen(Base base, int preferencesResID) {
    addPreferencesFromResource(preferencesResID);
    final PreferenceScreen preferenceScreen = getPreferenceScreen();
    final PreferenceCategory serverCate = getServerCategory(preferenceScreen);
    serverCate.setOrderingAsAdded(true);
    final Server[] servers = base.getServers();
    for (int index = 0; index < servers.length; index++) {
        final Server server = servers[index];
        final ListItemServer item = new ListItemServer(getActivity(), server);
        item.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {

            @Override
            public boolean onPreferenceChange(Preference preference, Object newValue) {
                onServerItemStateChange((ListItemServer) preference, (Boolean) newValue);
                return false;
            }
        });
        item.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {

            @Override
            public boolean onPreferenceClick(Preference preference) {
                onServerItemClick((ListItemServer) preference);
                return true;
            }
        });
        serverCate.addPreference(item);
        onServerStateChange(server, index);
    }
    final PreferenceCategory databaseCate = getDatabaseCategory(preferenceScreen);
    final PreferenceScreen playgroundItem = (PreferenceScreen) databaseCate.findPreference(getString(R.string.item_playground));
    playgroundItem.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {

        @Override
        public boolean onPreferenceClick(Preference preference) {
            return onPlaygroundItemClick(preference);
        }
    });
    return preferenceScreen;
}
Also used : PreferenceScreen(android.preference.PreferenceScreen) Server(com.nimbusbase.nimbusbase.Server) PreferenceCategory(android.preference.PreferenceCategory) Preference(android.preference.Preference)

Example 9 with Preference

use of android.preference.Preference in project NimbusBase_Android_Tutorial by NimbusBase.

the class PGFragmentTable method reload.

protected void reload(List<? extends PGRecord> records) {
    final PreferenceScreen preferenceScreen = getPreferenceScreen();
    preferenceScreen.removeAll();
    for (final PGRecord user : records) {
        final PGListItemRecord item = new PGListItemRecord(getActivity(), user);
        item.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {

            @Override
            public boolean onPreferenceClick(Preference preference) {
                return onRecordPressed((PGListItemRecord) preference);
            }
        });
        preferenceScreen.addPreference(item);
    }
}
Also used : PreferenceScreen(android.preference.PreferenceScreen) Preference(android.preference.Preference)

Example 10 with Preference

use of android.preference.Preference in project NimbusBase_Android_Tutorial by NimbusBase.

the class PGFragmentTable method onViewCreated.

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    final ActionBar actionBar = getActivity().getActionBar();
    if (actionBar != null)
        actionBar.setTitle("Table " + mTableName);
    final SQLiteDatabase database = mSQLiteOpenHelper.getReadableDatabase();
    final List<MDLUser> records = MDLUser.fetchAll(database);
    database.close();
    if (!records.equals(mRecords)) {
        this.mRecords = records;
        reload(records);
        final PreferenceScreen preferenceScreen = getPreferenceScreen();
        preferenceScreen.removeAll();
        for (final MDLUser user : records) {
            final PGListItemRecord item = new PGListItemRecord(getActivity(), user);
            item.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {

                @Override
                public boolean onPreferenceClick(Preference preference) {
                    return onRecordPressed((PGListItemRecord) preference);
                }
            });
            preferenceScreen.addPreference(item);
        }
    }
}
Also used : PreferenceScreen(android.preference.PreferenceScreen) SQLiteDatabase(android.database.sqlite.SQLiteDatabase) Preference(android.preference.Preference) ActionBar(android.app.ActionBar)

Aggregations

Preference (android.preference.Preference)173 CheckBoxPreference (android.preference.CheckBoxPreference)50 ListPreference (android.preference.ListPreference)49 PreferenceScreen (android.preference.PreferenceScreen)36 Intent (android.content.Intent)32 EditTextPreference (android.preference.EditTextPreference)26 OnPreferenceChangeListener (android.preference.Preference.OnPreferenceChangeListener)23 PreferenceCategory (android.preference.PreferenceCategory)23 OnPreferenceClickListener (android.preference.Preference.OnPreferenceClickListener)21 SharedPreferences (android.content.SharedPreferences)19 ChromeSwitchPreference (org.chromium.chrome.browser.preferences.ChromeSwitchPreference)16 Test (org.junit.Test)15 PreferenceGroup (android.preference.PreferenceGroup)13 Uri (android.net.Uri)12 Bundle (android.os.Bundle)12 ArrayList (java.util.ArrayList)11 Resources (android.content.res.Resources)10 SwitchPreference (android.preference.SwitchPreference)10 View (android.view.View)10 ChromeBasePreference (org.chromium.chrome.browser.preferences.ChromeBasePreference)10