Search in sources :

Example 31 with LayoutPreference

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

the class CredentialManagementAppHeaderController method displayHeader.

private void displayHeader(PreferenceScreen screen) {
    LayoutPreference headerPref = screen.findPreference(getPreferenceKey());
    ImageView appIconView = headerPref.findViewById(R.id.entity_header_icon);
    TextView titleView = headerPref.findViewById(R.id.entity_header_title);
    TextView summary1 = headerPref.findViewById(R.id.entity_header_summary);
    TextView summary2 = headerPref.findViewById(R.id.entity_header_second_summary);
    summary2.setVisibility(View.GONE);
    try {
        ApplicationInfo applicationInfo = mPackageManager.getApplicationInfo(mCredentialManagerPackageName, 0);
        appIconView.setImageDrawable(mPackageManager.getApplicationIcon(applicationInfo));
        titleView.setText(applicationInfo.loadLabel(mPackageManager));
        summary1.setText(R.string.certificate_management_app_description);
    } catch (PackageManager.NameNotFoundException e) {
        appIconView.setImageDrawable(null);
        titleView.setText(mCredentialManagerPackageName);
    }
}
Also used : LayoutPreference(com.android.settingslib.widget.LayoutPreference) PackageManager(android.content.pm.PackageManager) ApplicationInfo(android.content.pm.ApplicationInfo) TextView(android.widget.TextView) ImageView(android.widget.ImageView)

Example 32 with LayoutPreference

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

the class WifiDetailPreferenceController2 method setupEntityHeader.

private void setupEntityHeader(PreferenceScreen screen) {
    LayoutPreference headerPref = screen.findPreference(KEY_HEADER);
    if (usingDataUsageHeader(mContext)) {
        headerPref.setVisible(false);
        mDataUsageSummaryPref = screen.findPreference(KEY_DATA_USAGE_HEADER);
        mDataUsageSummaryPref.setVisible(true);
        mSummaryHeaderController = new WifiDataUsageSummaryPreferenceController(mFragment.getActivity(), mLifecycle, (PreferenceFragmentCompat) mFragment, mWifiEntry.getTitle());
        return;
    }
    mEntityHeaderController = EntityHeaderController.newInstance(mFragment.getActivity(), mFragment, headerPref.findViewById(R.id.entity_header));
    ImageView iconView = headerPref.findViewById(R.id.entity_header_icon);
    iconView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
    mEntityHeaderController.setLabel(mWifiEntry.getTitle());
}
Also used : LayoutPreference(com.android.settingslib.widget.LayoutPreference) WifiDataUsageSummaryPreferenceController(com.android.settings.datausage.WifiDataUsageSummaryPreferenceController) PreferenceFragmentCompat(androidx.preference.PreferenceFragmentCompat) ImageView(android.widget.ImageView)

Example 33 with LayoutPreference

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

the class AdbDeviceDetailsHeaderController method setupEntityHeader.

private void setupEntityHeader(PreferenceScreen screen) {
    LayoutPreference headerPref = (LayoutPreference) screen.findPreference(KEY_HEADER);
    mEntityHeaderController = EntityHeaderController.newInstance(mFragment.getActivity(), mFragment, headerPref.findViewById(R.id.entity_header));
    mEntityHeaderController.setIcon(mContext.getDrawable(com.android.internal.R.drawable.ic_bt_laptop)).setLabel(mPairedDevice.getDeviceName()).done(mFragment.getActivity(), true);
}
Also used : LayoutPreference(com.android.settingslib.widget.LayoutPreference)

Example 34 with LayoutPreference

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

the class UsbDetailsHeaderControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = RuntimeEnvironment.application;
    mLifecycleOwner = () -> mLifecycle;
    mLifecycle = new Lifecycle(mLifecycleOwner);
    mPreferenceManager = new PreferenceManager(mContext);
    mScreen = mPreferenceManager.createPreferenceScreen(mContext);
    when(mFragment.getActivity()).thenReturn(mActivity);
    when(mActivity.getApplicationContext()).thenReturn(mContext);
    when(mFragment.getContext()).thenReturn(mContext);
    when(mFragment.getPreferenceManager()).thenReturn(mPreferenceManager);
    when(mFragment.getPreferenceScreen()).thenReturn(mScreen);
    ShadowEntityHeaderController.setUseMock(mHeaderController);
    mDetailsHeaderController = new UsbDetailsHeaderController(mContext, mFragment, mUsbBackend);
    mPreference = new LayoutPreference(mContext, R.layout.settings_entity_header);
    mPreference.setKey(mDetailsHeaderController.getPreferenceKey());
    mScreen.addPreference(mPreference);
}
Also used : LayoutPreference(com.android.settingslib.widget.LayoutPreference) Lifecycle(com.android.settingslib.core.lifecycle.Lifecycle) PreferenceManager(androidx.preference.PreferenceManager) Before(org.junit.Before)

Example 35 with LayoutPreference

use of com.android.settingslib.widget.LayoutPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class PreventRingingSwitchPreferenceControllerTest method testPreferenceClickListenerAttached.

@Test
public void testPreferenceClickListenerAttached() {
    PreferenceScreen preferenceScreen = mock(PreferenceScreen.class);
    LayoutPreference mLayoutPreference = mock(LayoutPreference.class);
    when(preferenceScreen.findPreference(mController.getPreferenceKey())).thenReturn(mLayoutPreference);
    mController.displayPreference(preferenceScreen);
    verify(mLayoutPreference, times(1)).setOnPreferenceClickListener(any());
}
Also used : LayoutPreference(com.android.settingslib.widget.LayoutPreference) PreferenceScreen(androidx.preference.PreferenceScreen) Test(org.junit.Test)

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