Search in sources :

Example 6 with EditTextPreference

use of com.takisoft.fix.support.v7.preference.EditTextPreference in project i2p.i2p-bote by i2p.

the class AdvancedPreferenceFragment method createPortField.

private static EditTextPreference createPortField(Context context) {
    EditTextPreference p = new SummaryEditTextPreference(context);
    p.setKey("i2pbote.i2cp.tcp.port");
    p.setTitle(R.string.pref_title_i2cp_port);
    p.setSummary("%s");
    p.setDefaultValue("internal");
    p.setEnabled(false);
    return p;
}
Also used : SummaryEditTextPreference(i2p.bote.android.config.util.SummaryEditTextPreference) EditTextPreference(android.support.v7.preference.EditTextPreference) SummaryEditTextPreference(i2p.bote.android.config.util.SummaryEditTextPreference)

Example 7 with EditTextPreference

use of com.takisoft.fix.support.v7.preference.EditTextPreference in project Rashr by DsLNeXuS.

the class SettingsFragment method onCreatePreferences.

@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
    addPreferencesFromResource(R.xml.preferences);
    EditTextPreference recovery_path = (EditTextPreference) findPreference(App.PREF_KEY_RECOVERY_PATH);
    recovery_path.setText(App.Preferences.getString(App.PREF_KEY_RECOVERY_PATH, null));
    EditTextPreference kernel_path = (EditTextPreference) findPreference(App.PREF_KEY_KERNEL_PATH);
    kernel_path.setText(App.Preferences.getString(App.PREF_KEY_KERNEL_PATH, null));
    EditTextPreference device_name = (EditTextPreference) findPreference(App.PREF_KEY_DEVICE_NAME);
    device_name.setText(App.Device.getName());
    device_name.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {

        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            View v = getView();
            if (v == null)
                return true;
            if (!newValue.toString().equals("")) {
                Snackbar.make(v, R.string.please_restart, Snackbar.LENGTH_INDEFINITE).show();
            }
            return true;
        }
    });
    Preference changelog = findPreference(App.PREF_KEY_CHANGELOG);
    changelog.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {

        @Override
        public boolean onPreferenceClick(Preference preference) {
            showChangelog(getContext());
            return false;
        }
    });
    Preference showlogs = findPreference(App.PREF_KEY_SHOW_LOGS);
    showlogs.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {

        @Override
        public boolean onPreferenceClick(Preference preference) {
            showLogs();
            return false;
        }
    });
    Preference report = findPreference(App.PREF_KEY_REPORT);
    report.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {

        @Override
        public boolean onPreferenceClick(Preference preference) {
            new ReportDialog(getActivity(), "").show();
            return false;
        }
    });
    Preference licenses = findPreference(App.PREF_KEY_LICENSES);
    licenses.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {

        @Override
        public boolean onPreferenceClick(Preference preference) {
            new LicensesDialog.Builder(getContext()).setNotices(R.raw.licenses_notice).setIncludeOwnLicense(true).build().show();
            return false;
        }
    });
    Preference reset = findPreference(App.PREF_KEY_RESET_APP);
    reset.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {

        @Override
        public boolean onPreferenceClick(Preference preference) {
            PreferenceManager.setDefaultValues(getActivity(), R.xml.preferences, true);
            return true;
        }
    });
    Preference clearCache = findPreference(App.PREF_KEY_CLEAR_CACHE);
    clearCache.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {

        @Override
        public boolean onPreferenceClick(Preference preference) {
            final AlertDialog.Builder ConfirmationDialog = new AlertDialog.Builder(getContext());
            ConfirmationDialog.setTitle(R.string.warning);
            ConfirmationDialog.setMessage(R.string.delete_confirmation);
            ConfirmationDialog.setPositiveButton(R.string.positive, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    if (!Common.deleteFolder(App.PathToCWM, false) || !Common.deleteFolder(App.PathToTWRP, false) || !Common.deleteFolder(App.PathToPhilz, false) || !Common.deleteFolder(App.PathToCM, false) || !Common.deleteFolder(App.PathToPhilz, false) || !Common.deleteFolder(App.PathToStockRecovery, false) || !Common.deleteFolder(App.PathToStockKernel, false)) {
                        Toast.makeText(getActivity(), R.string.delete_failed, Toast.LENGTH_SHORT).show();
                    } else {
                        Toast.makeText(getActivity(), R.string.files_deleted, Toast.LENGTH_SHORT).show();
                    }
                }
            });
            ConfirmationDialog.setNegativeButton(R.string.negative, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                }
            });
            ConfirmationDialog.show();
            return false;
        }
    });
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) EditTextPreference(android.support.v7.preference.EditTextPreference) LicensesDialog(de.psdev.licensesdialog.LicensesDialog) View(android.view.View) WebView(android.webkit.WebView) Preference(android.support.v7.preference.Preference) EditTextPreference(android.support.v7.preference.EditTextPreference) ReportDialog(de.mkrtchyan.recoverytools.ReportDialog)

Example 8 with EditTextPreference

use of com.takisoft.fix.support.v7.preference.EditTextPreference in project ring-client-android by savoirfairelinux.

the class SecurityAccountFragment method setDetails.

@Override
public void setDetails(AccountConfig config, String[] tlsMethods) {
    for (int i = 0; i < tlsCategory.getPreferenceCount(); ++i) {
        final Preference current = tlsCategory.getPreference(i);
        final ConfigKey key = ConfigKey.fromString(current.getKey());
        if (current instanceof TwoStatePreference) {
            ((TwoStatePreference) current).setChecked(config.getBool(key));
        } else {
            if (key == ConfigKey.TLS_CA_LIST_FILE) {
                File crt = new File(config.get(ConfigKey.TLS_CA_LIST_FILE));
                current.setSummary(crt.getName());
                setFeedbackIcon(current);
                current.setOnPreferenceClickListener(filePickerListener);
            } else if (key == ConfigKey.TLS_PRIVATE_KEY_FILE) {
                current.setSummary(new File(config.get(ConfigKey.TLS_PRIVATE_KEY_FILE)).getName());
                current.setOnPreferenceClickListener(filePickerListener);
            } else if (key == ConfigKey.TLS_CERTIFICATE_FILE) {
                File pem = new File(config.get(ConfigKey.TLS_CERTIFICATE_FILE));
                current.setSummary(pem.getName());
                setFeedbackIcon(current);
                checkForRSAKey();
                current.setOnPreferenceClickListener(filePickerListener);
            } else if (key == ConfigKey.TLS_METHOD) {
                ListPreference listPref = (ListPreference) current;
                String curVal = config.get(key);
                listPref.setEntries(tlsMethods);
                listPref.setEntryValues(tlsMethods);
                listPref.setValue(curVal);
                current.setSummary(curVal);
            } else if (current instanceof EditTextPreference) {
                String val = config.get(key);
                ((EditTextPreference) current).setText(val);
                current.setSummary(val);
            } else {
                current.setSummary(config.get(key));
            }
        }
        current.setOnPreferenceChangeListener(tlsListener);
    }
}
Also used : ConfigKey(cx.ring.model.ConfigKey) TwoStatePreference(android.support.v7.preference.TwoStatePreference) CredentialsPreference(cx.ring.views.CredentialsPreference) ListPreference(android.support.v7.preference.ListPreference) TwoStatePreference(android.support.v7.preference.TwoStatePreference) Preference(android.support.v7.preference.Preference) EditTextPreference(android.support.v7.preference.EditTextPreference) ListPreference(android.support.v7.preference.ListPreference) EditTextPreference(android.support.v7.preference.EditTextPreference) File(java.io.File)

Example 9 with EditTextPreference

use of com.takisoft.fix.support.v7.preference.EditTextPreference in project ring-client-android by savoirfairelinux.

the class AdvancedAccountFragment method initView.

@Override
public void initView(AccountConfig config, ArrayList<CharSequence> networkInterfaces) {
    for (ConfigKey confKey : config.getKeys()) {
        Preference pref = findPreference(confKey.key());
        if (pref != null) {
            pref.setOnPreferenceChangeListener(this);
            if (confKey == ConfigKey.LOCAL_INTERFACE) {
                String val = config.get(confKey);
                CharSequence[] display = networkInterfaces.toArray(new CharSequence[networkInterfaces.size()]);
                ListPreference listPref = (ListPreference) pref;
                listPref.setEntries(display);
                listPref.setEntryValues(display);
                listPref.setSummary(val);
                listPref.setValue(val);
            } else if (!confKey.isTwoState()) {
                String val = config.get(confKey);
                pref.setSummary(val);
                if (pref instanceof EditTextPreference) {
                    ((EditTextPreference) pref).setText(val);
                }
            } else {
                ((TwoStatePreference) pref).setChecked(config.getBool(confKey));
            }
        }
    }
}
Also used : ConfigKey(cx.ring.model.ConfigKey) ListPreference(android.support.v7.preference.ListPreference) TwoStatePreference(android.support.v7.preference.TwoStatePreference) Preference(android.support.v7.preference.Preference) EditTextPreference(android.support.v7.preference.EditTextPreference) EditTextIntegerPreference(cx.ring.views.EditTextIntegerPreference) PasswordPreference(cx.ring.views.PasswordPreference) ListPreference(android.support.v7.preference.ListPreference) EditTextPreference(android.support.v7.preference.EditTextPreference)

Example 10 with EditTextPreference

use of com.takisoft.fix.support.v7.preference.EditTextPreference in project haven by guardianproject.

the class SettingsFragment method onCreatePreferencesFix.

@Override
public void onCreatePreferencesFix(Bundle bundle, String s) {
    addPreferencesFromResource(R.xml.settings);
    mActivity = getActivity();
    preferences = new PreferenceManager(mActivity);
    setHasOptionsMenu(true);
    app = (HavenApp) mActivity.getApplication();
    /*
         * We create an application directory to store images and audio
         */
    File directory = new File(Environment.getExternalStorageDirectory() + preferences.getDirPath());
    directory.mkdirs();
    if (preferences.getCameraActivation()) {
        String camera = preferences.getCamera();
        switch(camera) {
            case PreferenceManager.FRONT:
                ((ListPreference) findPreference(PreferenceManager.CAMERA)).setValueIndex(0);
                break;
            case PreferenceManager.BACK:
                ((ListPreference) findPreference(PreferenceManager.CAMERA)).setValueIndex(1);
                break;
            case PreferenceManager.OFF:
                ((ListPreference) findPreference(PreferenceManager.CAMERA)).setValueIndex(2);
                break;
        }
    }
    if (preferences.getSmsActivation()) {
        ((SwitchPreferenceCompat) findPreference(PreferenceManager.SMS_ACTIVE)).setChecked(true);
    }
    if (checkValidString(preferences.getSmsNumber())) {
        ((EditTextPreference) findPreference(PreferenceManager.SMS_NUMBER)).setText(preferences.getSmsNumber().trim());
        findPreference(PreferenceManager.SMS_NUMBER).setSummary(preferences.getSmsNumber().trim());
    } else {
        findPreference(PreferenceManager.SMS_NUMBER).setSummary(R.string.sms_dialog_summary);
    }
    if (preferences.getRemoteAccessActive()) {
        ((SwitchPreferenceCompat) findPreference(PreferenceManager.REMOTE_ACCESS_ACTIVE)).setChecked(true);
    }
    if (checkValidString(preferences.getRemoteAccessOnion())) {
        ((EditTextPreference) findPreference(PreferenceManager.REMOTE_ACCESS_ONION)).setText(preferences.getRemoteAccessOnion().trim() + ":" + WebServer.LOCAL_PORT);
        findPreference(PreferenceManager.REMOTE_ACCESS_ONION).setSummary(preferences.getRemoteAccessOnion().trim() + ":" + WebServer.LOCAL_PORT);
    } else {
        findPreference(PreferenceManager.REMOTE_ACCESS_ONION).setSummary(R.string.remote_access_hint);
    }
    if (checkValidString(preferences.getRemoteAccessCredential())) {
        ((EditTextPreference) findPreference(PreferenceManager.REMOTE_ACCESS_CRED)).setText(preferences.getRemoteAccessCredential().trim());
        findPreference(PreferenceManager.REMOTE_ACCESS_CRED).setSummary(R.string.bullets);
    } else {
        findPreference(PreferenceManager.REMOTE_ACCESS_CRED).setSummary(R.string.remote_access_credential_hint);
    }
    if (checkValidString(preferences.getSignalUsername())) {
        String signalNum = "+" + preferences.getSignalUsername().trim().replaceAll("[^0-9]", "");
        findPreference(PreferenceManager.REGISTER_SIGNAL).setSummary(signalNum);
    } else {
        findPreference(PreferenceManager.REGISTER_SIGNAL).setSummary(R.string.register_signal_desc);
    }
    if (preferences.getNotificationTimeMs() > 0) {
        findPreference(PreferenceManager.NOTIFICATION_TIME).setSummary(preferences.getNotificationTimeMs() / 60000 + " " + getString(R.string.minutes));
    }
    Preference prefCameraSensitivity = findPreference(PreferenceManager.CAMERA_SENSITIVITY);
    prefCameraSensitivity.setOnPreferenceClickListener(preference -> {
        startActivity(new Intent(mActivity, CameraConfigureActivity.class));
        return true;
    });
    Preference prefConfigMovement = findPreference(PreferenceManager.CONFIG_MOVEMENT);
    prefConfigMovement.setOnPreferenceClickListener(preference -> {
        startActivity(new Intent(mActivity, AccelConfigureActivity.class));
        return true;
    });
    Preference prefConfigSound = findPreference(PreferenceManager.CONFIG_SOUND);
    prefConfigSound.setOnPreferenceClickListener(preference -> {
        startActivity(new Intent(mActivity, MicrophoneConfigureActivity.class));
        return true;
    });
    Preference prefConfigTimeDelay = findPreference(PreferenceManager.CONFIG_TIME_DELAY);
    prefConfigTimeDelay.setOnPreferenceClickListener(preference -> {
        showTimeDelayDialog(PreferenceManager.CONFIG_TIME_DELAY);
        return true;
    });
    Preference prefConfigVideoLength = findPreference(PreferenceManager.CONFIG_VIDEO_LENGTH);
    prefConfigVideoLength.setOnPreferenceClickListener(preference -> {
        showTimeDelayDialog(PreferenceManager.CONFIG_VIDEO_LENGTH);
        return true;
    });
    Preference prefDisableBatteryOpt = findPreference(PreferenceManager.DISABLE_BATTERY_OPT);
    prefDisableBatteryOpt.setOnPreferenceClickListener(preference -> {
        requestChangeBatteryOptimizations();
        return true;
    });
    checkSignalUsername();
    ((EditTextPreference) findPreference(PreferenceManager.VERIFY_SIGNAL)).setText("");
    askForPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE, 1);
}
Also used : SwitchPreferenceCompat(android.support.v7.preference.SwitchPreferenceCompat) ListPreference(android.support.v7.preference.ListPreference) Preference(android.support.v7.preference.Preference) EditTextPreference(android.support.v7.preference.EditTextPreference) SwitchPreference(android.support.v14.preference.SwitchPreference) MicrophoneConfigureActivity(org.havenapp.main.ui.MicrophoneConfigureActivity) CameraConfigureActivity(org.havenapp.main.ui.CameraConfigureActivity) Intent(android.content.Intent) ListPreference(android.support.v7.preference.ListPreference) EditTextPreference(android.support.v7.preference.EditTextPreference) AccelConfigureActivity(org.havenapp.main.ui.AccelConfigureActivity) File(java.io.File)

Aggregations

EditTextPreference (android.support.v7.preference.EditTextPreference)11 Preference (android.support.v7.preference.Preference)10 ListPreference (android.support.v7.preference.ListPreference)8 CheckBoxPreference (android.support.v7.preference.CheckBoxPreference)3 SwitchPreferenceCompat (android.support.v7.preference.SwitchPreferenceCompat)3 TwoStatePreference (android.support.v7.preference.TwoStatePreference)3 EditTextPreference (com.takisoft.fix.support.v7.preference.EditTextPreference)3 ConfigKey (cx.ring.model.ConfigKey)3 SummaryEditTextPreference (i2p.bote.android.config.util.SummaryEditTextPreference)3 EditTextIntegerPreference (cx.ring.views.EditTextIntegerPreference)2 PasswordPreference (cx.ring.views.PasswordPreference)2 File (java.io.File)2 DialogInterface (android.content.DialogInterface)1 Intent (android.content.Intent)1 SharedPreferences (android.content.SharedPreferences)1 Bundle (android.os.Bundle)1 MultiSelectListPreference (android.support.v14.preference.MultiSelectListPreference)1 SwitchPreference (android.support.v14.preference.SwitchPreference)1 AlertDialog (android.support.v7.app.AlertDialog)1 View (android.view.View)1