Search in sources :

Example 21 with LayoutPreference

use of com.android.settingslib.widget.LayoutPreference in project android_packages_apps_Settings by omnirom.

the class ImportanceResetPreferenceControllerTest method setup.

@Before
public void setup() {
    MockitoAnnotations.initMocks(this);
    mContext = RuntimeEnvironment.application;
    mPreference = new LayoutPreference(mContext, R.layout.reset_importance_button);
    when(mScreen.findPreference(anyString())).thenReturn(mPreference);
    mController = new ImportanceResetPreferenceController(mContext, KEY);
    mController.displayPreference(mScreen);
    ReflectionHelpers.setField(mController, "mBackend", mBackend);
}
Also used : LayoutPreference(com.android.settingslib.widget.LayoutPreference) Before(org.junit.Before)

Example 22 with LayoutPreference

use of com.android.settingslib.widget.LayoutPreference in project android_packages_apps_Settings by omnirom.

the class RecentConversationsPreferenceController method getClearAll.

LayoutPreference getClearAll(PreferenceGroup parent) {
    LayoutPreference pref = new LayoutPreference(mContext, R.layout.conversations_clear_recents);
    pref.setOrder(1);
    Button button = pref.findViewById(R.id.conversation_settings_clear_recents);
    button.setOnClickListener(v -> {
        try {
            mPs.removeAllRecentConversations();
            for (int i = parent.getPreferenceCount() - 1; i >= 0; i--) {
                Preference p = parent.getPreference(i);
                if (p instanceof RecentConversationPreference) {
                    if (((RecentConversationPreference) p).hasClearListener()) {
                        parent.removePreference(p);
                    }
                }
            }
            button.announceForAccessibility(mContext.getString(R.string.recent_convos_removed));
        } catch (RemoteException e) {
            Slog.w(TAG, "Could not clear recents", e);
        }
    });
    return pref;
}
Also used : LayoutPreference(com.android.settingslib.widget.LayoutPreference) Button(android.widget.Button) LayoutPreference(com.android.settingslib.widget.LayoutPreference) Preference(androidx.preference.Preference) RemoteException(android.os.RemoteException)

Example 23 with LayoutPreference

use of com.android.settingslib.widget.LayoutPreference in project android_packages_apps_Settings by omnirom.

the class HeaderPreferenceController method updateState.

@Override
public void updateState(Preference preference) {
    if (mAppRow != null && mFragment != null) {
        Activity activity = null;
        if (mStarted) {
            // don't call done on an activity if it hasn't started yet
            activity = mFragment.getActivity();
        }
        if (activity == null) {
            return;
        }
        LayoutPreference pref = (LayoutPreference) preference;
        mHeaderController = EntityHeaderController.newInstance(activity, mFragment, pref.findViewById(R.id.entity_header));
        pref = mHeaderController.setIcon(mAppRow.icon).setLabel(getLabel()).setSummary(getSummary()).setSecondSummary(getSecondSummary()).setPackageName(mAppRow.pkg).setUid(mAppRow.uid).setButtonActions(EntityHeaderController.ActionType.ACTION_NOTIF_PREFERENCE, EntityHeaderController.ActionType.ACTION_NONE).setHasAppInfoLink(true).setRecyclerView(mFragment.getListView(), mFragment.getSettingsLifecycle()).done(activity, mContext);
        pref.findViewById(R.id.entity_header).setVisibility(View.VISIBLE);
        pref.findViewById(R.id.entity_header).setBackground(null);
    }
}
Also used : LayoutPreference(com.android.settingslib.widget.LayoutPreference) Activity(android.app.Activity)

Example 24 with LayoutPreference

use of com.android.settingslib.widget.LayoutPreference in project android_packages_apps_Settings by omnirom.

the class BluetoothDetailsHeaderController method init.

@Override
protected void init(PreferenceScreen screen) {
    final LayoutPreference headerPreference = screen.findPreference(KEY_DEVICE_HEADER);
    mHeaderController = EntityHeaderController.newInstance(mFragment.getActivity(), mFragment, headerPreference.findViewById(R.id.entity_header));
    screen.addPreference(headerPreference);
}
Also used : LayoutPreference(com.android.settingslib.widget.LayoutPreference)

Example 25 with LayoutPreference

use of com.android.settingslib.widget.LayoutPreference in project android_packages_apps_Settings by omnirom.

the class ColorModePreferenceFragment method addStaticPreferences.

@Override
protected void addStaticPreferences(PreferenceScreen screen) {
    final LayoutPreference preview = new LayoutPreference(screen.getContext(), R.layout.color_mode_preview);
    configureAndInstallPreview(preview, screen);
    addViewPager(preview);
}
Also used : LayoutPreference(com.android.settingslib.widget.LayoutPreference)

Aggregations

LayoutPreference (com.android.settingslib.widget.LayoutPreference)61 Before (org.junit.Before)10 Preference (androidx.preference.Preference)8 Activity (android.app.Activity)5 View (android.view.View)5 Button (android.widget.Button)5 Lifecycle (com.android.settingslib.core.lifecycle.Lifecycle)5 Test (org.junit.Test)5 ImageView (android.widget.ImageView)3 PreferenceManager (androidx.preference.PreferenceManager)3 PreferenceScreen (androidx.preference.PreferenceScreen)3 Intent (android.content.Intent)2 UserInfo (android.content.pm.UserInfo)2 Resources (android.content.res.Resources)2 Bundle (android.os.Bundle)2 RemoteException (android.os.RemoteException)2 UserManager (android.os.UserManager)2 TextView (android.widget.TextView)2 PreferenceFragmentCompat (androidx.preference.PreferenceFragmentCompat)2 WifiDataUsageSummaryPreferenceController (com.android.settings.datausage.WifiDataUsageSummaryPreferenceController)2