Search in sources :

Example 11 with Preference

use of android.support.v7.preference.Preference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class SimSettings method updateSubscriptions.

private void updateSubscriptions() {
    mSubInfoList = mSubscriptionManager.getActiveSubscriptionInfoList();
    for (int i = 0; i < mNumSlots; ++i) {
        Preference pref = mSimCards.findPreference("sim" + i);
        if (pref instanceof SimPreference) {
            mSimCards.removePreference(pref);
        }
    }
    mMobileNetwork.removeAll();
    mAvailableSubInfos.clear();
    mSelectableSubInfos.clear();
    for (int i = 0; i < mNumSlots; ++i) {
        final SubscriptionInfo sir = mSubscriptionManager.getActiveSubscriptionInfoForSimSlotIndex(i);
        final int subscriptionId = sir != null ? sir.getSubscriptionId() : SubscriptionManager.INVALID_SUBSCRIPTION_ID;
        SimPreference simPreference = new SimEnablerPreference(getPrefContext(), sir, i);
        simPreference.setOrder(i - mNumSlots);
        mSimCards.addPreference(simPreference);
        mAvailableSubInfos.add(sir);
        if (sir != null && mUiccProvisionStatus[i] == PROVISIONED) {
            mSelectableSubInfos.add(sir);
        }
        Intent mobileNetworkIntent = new Intent();
        mobileNetworkIntent.setComponent(new ComponentName("com.android.phone", "com.android.phone.MobileNetworkSettings"));
        SubscriptionManager.putPhoneIdAndSubIdExtra(mobileNetworkIntent, i, subscriptionId);
        Preference mobileNetworkPref = new Preference(getActivity());
        mobileNetworkPref.setTitle(getString(R.string.sim_mobile_network_settings_title, (i + 1)));
        mobileNetworkPref.setIntent(mobileNetworkIntent);
        mobileNetworkPref.setEnabled(subscriptionId != SubscriptionManager.INVALID_SUBSCRIPTION_ID);
        mMobileNetwork.addPreference(mobileNetworkPref);
    }
    updateAllOptions();
}
Also used : Preference(android.support.v7.preference.Preference) SwitchPreference(android.support.v14.preference.SwitchPreference) SubscriptionInfo(android.telephony.SubscriptionInfo) Intent(android.content.Intent) ComponentName(android.content.ComponentName)

Example 12 with Preference

use of android.support.v7.preference.Preference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class SimSettings method updateCallValues.

private void updateCallValues() {
    final Preference simPref = findPreference(KEY_CALLS);
    final TelecomManager telecomManager = TelecomManager.from(mContext);
    final PhoneAccountHandle phoneAccountHandle = telecomManager.getUserSelectedOutgoingPhoneAccount();
    final List<PhoneAccountHandle> allPhoneAccounts = telecomManager.getCallCapablePhoneAccounts();
    simPref.setTitle(R.string.calls_title);
    PhoneAccount phoneAccount = null;
    if (phoneAccountHandle != null) {
        phoneAccount = telecomManager.getPhoneAccount(phoneAccountHandle);
    }
    simPref.setSummary(phoneAccount == null ? mContext.getResources().getString(R.string.sim_calls_ask_first_prefs_title) : (String) phoneAccount.getLabel());
    simPref.setEnabled(allPhoneAccounts.size() > 1);
}
Also used : PhoneAccount(android.telecom.PhoneAccount) PhoneAccountHandle(android.telecom.PhoneAccountHandle) Preference(android.support.v7.preference.Preference) SwitchPreference(android.support.v14.preference.SwitchPreference) TelecomManager(android.telecom.TelecomManager)

Example 13 with Preference

use of android.support.v7.preference.Preference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class SimSettings method updateSmsValues.

private void updateSmsValues() {
    final Preference simPref = findPreference(KEY_SMS);
    final SubscriptionInfo sir = mSubscriptionManager.getDefaultSmsSubscriptionInfo();
    simPref.setTitle(R.string.sms_messages_title);
    if (DBG)
        log("[updateSmsValues] mSubInfoList=" + mSubInfoList);
    if (sir != null) {
        simPref.setSummary(sir.getDisplayName());
        simPref.setEnabled(mSelectableSubInfos.size() > 1);
    } else if (sir == null) {
        simPref.setSummary(R.string.sim_selection_required_pref);
        simPref.setEnabled(mSelectableSubInfos.size() >= 1);
    }
}
Also used : Preference(android.support.v7.preference.Preference) SwitchPreference(android.support.v14.preference.SwitchPreference) SubscriptionInfo(android.telephony.SubscriptionInfo)

Example 14 with Preference

use of android.support.v7.preference.Preference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class TextToSpeechSettings method onVoiceDataIntegrityCheckDone.

/*
     * Step 5: The voice data check is complete.
     */
private void onVoiceDataIntegrityCheckDone(Intent data) {
    final String engine = mTts.getCurrentEngine();
    if (engine == null) {
        Log.e(TAG, "Voice data check complete, but no engine bound");
        return;
    }
    if (data == null) {
        Log.e(TAG, "Engine failed voice data integrity check (null return)" + mTts.getCurrentEngine());
        return;
    }
    android.provider.Settings.Secure.putString(getContentResolver(), TTS_DEFAULT_SYNTH, engine);
    mAvailableStrLocals = data.getStringArrayListExtra(TextToSpeech.Engine.EXTRA_AVAILABLE_VOICES);
    if (mAvailableStrLocals == null) {
        Log.e(TAG, "Voice data check complete, but no available voices found");
        // Set mAvailableStrLocals to empty list
        mAvailableStrLocals = new ArrayList<String>();
    }
    if (evaluateDefaultLocale()) {
        getSampleText();
    }
    final int engineCount = mEnginePreferenceCategory.getPreferenceCount();
    for (int i = 0; i < engineCount; ++i) {
        final Preference p = mEnginePreferenceCategory.getPreference(i);
        if (p instanceof TtsEnginePreference) {
            TtsEnginePreference enginePref = (TtsEnginePreference) p;
            if (enginePref.getKey().equals(engine)) {
                enginePref.setVoiceDataDetails(data);
                break;
            }
        }
    }
}
Also used : SeekBarPreference(com.android.settings.SeekBarPreference) Preference(android.support.v7.preference.Preference) SwitchPreference(android.support.v14.preference.SwitchPreference)

Example 15 with Preference

use of android.support.v7.preference.Preference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class WifiSettings method onAccessPointsChanged.

/**
     * Shows the latest access points available with supplemental information like
     * the strength of network and the security for it.
     */
@Override
public synchronized void onAccessPointsChanged() {
    // Safeguard from some delayed event handling
    if (getActivity() == null)
        return;
    if (isUiRestricted()) {
        if (!isUiRestrictedByOnlyAdmin()) {
            addMessagePreference(R.string.wifi_empty_list_user_restricted);
        }
        getPreferenceScreen().removeAll();
        return;
    }
    final int wifiState = mWifiManager.getWifiState();
    switch(wifiState) {
        case WifiManager.WIFI_STATE_ENABLED:
            // AccessPoints are automatically sorted with TreeSet.
            final Collection<AccessPoint> accessPoints = mWifiTracker.getAccessPoints();
            boolean hasAvailableAccessPoints = false;
            int index = 0;
            cacheRemoveAllPrefs(getPreferenceScreen());
            for (AccessPoint accessPoint : accessPoints) {
                // Ignore access points that are out of range.
                if (accessPoint.getLevel() != -1) {
                    String key = accessPoint.getBssid();
                    if (TextUtils.isEmpty(key)) {
                        key = accessPoint.getSsidStr();
                    }
                    hasAvailableAccessPoints = true;
                    LongPressAccessPointPreference pref = (LongPressAccessPointPreference) getCachedPreference(key);
                    if (pref != null) {
                        pref.setOrder(index++);
                        continue;
                    }
                    LongPressAccessPointPreference preference = new LongPressAccessPointPreference(accessPoint, getPrefContext(), mUserBadgeCache, false, R.drawable.ic_wifi_signal_0, this);
                    preference.setKey(key);
                    preference.setOrder(index++);
                    if (mOpenSsid != null && mOpenSsid.equals(accessPoint.getSsidStr()) && !accessPoint.isSaved() && accessPoint.getSecurity() != AccessPoint.SECURITY_NONE) {
                        onPreferenceTreeClick(preference);
                        mOpenSsid = null;
                    }
                    getPreferenceScreen().addPreference(preference);
                    accessPoint.setListener(this);
                    preference.refresh();
                }
            }
            removeCachedPrefs(getPreferenceScreen());
            if (!hasAvailableAccessPoints) {
                setProgressBarVisible(true);
                Preference pref = new Preference(getContext()) {

                    @Override
                    public void onBindViewHolder(PreferenceViewHolder holder) {
                        super.onBindViewHolder(holder);
                        // Show a line on each side of add network.
                        holder.setDividerAllowedBelow(true);
                    }
                };
                pref.setSelectable(false);
                pref.setSummary(R.string.wifi_empty_list_wifi_on);
                pref.setOrder(0);
                pref.setKey(PREF_KEY_EMPTY_WIFI_LIST);
                getPreferenceScreen().addPreference(pref);
                mAddPreference.setOrder(1);
                getPreferenceScreen().addPreference(mAddPreference);
            } else {
                mAddPreference.setOrder(index++);
                getPreferenceScreen().addPreference(mAddPreference);
                setProgressBarVisible(false);
            }
            if (mScanMenuItem != null) {
                mScanMenuItem.setEnabled(true);
            }
            break;
        case WifiManager.WIFI_STATE_ENABLING:
            getPreferenceScreen().removeAll();
            setProgressBarVisible(true);
            break;
        case WifiManager.WIFI_STATE_DISABLING:
            addMessagePreference(R.string.wifi_stopping);
            setProgressBarVisible(true);
            break;
        case WifiManager.WIFI_STATE_DISABLED:
            setOffMessage();
            setProgressBarVisible(false);
            if (mScanMenuItem != null) {
                mScanMenuItem.setEnabled(false);
            }
            break;
    }
}
Also used : AccessPointPreference(com.android.settingslib.wifi.AccessPointPreference) Preference(android.support.v7.preference.Preference) AccessPoint(com.android.settingslib.wifi.AccessPoint) PreferenceViewHolder(android.support.v7.preference.PreferenceViewHolder) AccessPoint(com.android.settingslib.wifi.AccessPoint)

Aggregations

Preference (android.support.v7.preference.Preference)122 PreferenceScreen (android.support.v7.preference.PreferenceScreen)44 SwitchPreference (android.support.v14.preference.SwitchPreference)33 Intent (android.content.Intent)27 ListPreference (android.support.v7.preference.ListPreference)27 Context (android.content.Context)17 PreferenceCategory (android.support.v7.preference.PreferenceCategory)17 OnPreferenceChangeListener (android.support.v7.preference.Preference.OnPreferenceChangeListener)15 ArrayList (java.util.ArrayList)14 PackageManager (android.content.pm.PackageManager)11 OnPreferenceClickListener (android.support.v7.preference.Preference.OnPreferenceClickListener)11 PreferenceGroup (android.support.v7.preference.PreferenceGroup)11 TwoStatePreference (android.support.v7.preference.TwoStatePreference)11 Activity (android.app.Activity)10 View (android.view.View)10 Bundle (android.os.Bundle)9 TextView (android.widget.TextView)8 AlertDialog (android.support.v7.app.AlertDialog)7 CheckBoxPreference (android.support.v7.preference.CheckBoxPreference)7 DimmableIconPreference (com.android.settings.DimmableIconPreference)7