Search in sources :

Example 6 with FooterPreference

use of com.android.settingslib.widget.FooterPreference in project android_packages_apps_Settings by SudaMod.

the class ChannelNotificationSettings method addFooterPref.

private void addFooterPref() {
    if (!TextUtils.isEmpty(mChannel.getDescription())) {
        FooterPreference descPref = new FooterPreference(getPrefContext());
        descPref.setOrder(ORDER_LAST);
        descPref.setSelectable(false);
        descPref.setTitle(mChannel.getDescription());
        getPreferenceScreen().addPreference(descPref);
    }
}
Also used : FooterPreference(com.android.settingslib.widget.FooterPreference)

Example 7 with FooterPreference

use of com.android.settingslib.widget.FooterPreference in project android_packages_apps_Settings by SudaMod.

the class BluetoothDetailsMacAddressControllerTest method macAddress.

@Test
public void macAddress() {
    showScreen(mController);
    FooterPreference footer = (FooterPreference) mScreen.findPreference(mController.getPreferenceKey());
    assertThat(footer.getTitle().toString()).endsWith(mDeviceConfig.getAddress());
}
Also used : FooterPreference(com.android.settingslib.widget.FooterPreference) Test(org.junit.Test)

Example 8 with FooterPreference

use of com.android.settingslib.widget.FooterPreference in project android_packages_apps_Settings by DirtyUnicorns.

the class BluetoothDetailsMacAddressControllerTest method macAddress.

@Test
public void macAddress() {
    showScreen(mController);
    FooterPreference footer = (FooterPreference) mScreen.findPreference(mController.getPreferenceKey());
    assertThat(footer.getTitle().toString()).endsWith(mDeviceConfig.getAddress());
}
Also used : FooterPreference(com.android.settingslib.widget.FooterPreference) Test(org.junit.Test)

Example 9 with FooterPreference

use of com.android.settingslib.widget.FooterPreference in project android_packages_apps_Settings by DirtyUnicorns.

the class BluetoothSettingsTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = spy(RuntimeEnvironment.application);
    FakeFeatureFactory.setupForTest(mContext);
    mFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
    mFragment = spy(new BluetoothSettings());
    doReturn(mContext).when(mFragment).getContext();
    doReturn(mResource).when(mFragment).getResources();
    doReturn(mActivity).when(mFragment).getActivity();
    mContainer = new View(mContext);
    mEmptyMessage = new TextView(mContext);
    doReturn(mContainer).when(mActivity).findViewById(android.R.id.list_container);
    doReturn(mEmptyMessage).when(mActivity).findViewById(android.R.id.empty);
    mFooterPreference = new FooterPreference(RuntimeEnvironment.application);
    mFragment.setLocalBluetoothAdapter(mLocalAdapter);
    mFragment.mPairingPrefController = mPairingPreferenceController;
}
Also used : TextView(android.widget.TextView) View(android.view.View) TextView(android.widget.TextView) FooterPreference(com.android.settingslib.widget.FooterPreference) Before(org.junit.Before)

Example 10 with FooterPreference

use of com.android.settingslib.widget.FooterPreference in project android_packages_apps_Settings by DirtyUnicorns.

the class AppNotificationSettings method populateChannelList.

private void populateChannelList() {
    if (!mChannelGroups.isEmpty()) {
        // If there's anything in mChannelGroups, we've called populateChannelList twice.
        // Clear out existing channels and log.
        Log.w(TAG, "Notification channel group posted twice to settings - old size " + mChannelGroups.size() + ", new size " + mChannelGroupList.size());
        for (Preference p : mChannelGroups) {
            getPreferenceScreen().removePreference(p);
        }
    }
    if (mChannelGroupList.isEmpty()) {
        PreferenceCategory groupCategory = new PreferenceCategory(getPrefContext());
        groupCategory.setTitle(R.string.notification_channels);
        groupCategory.setKey(KEY_GENERAL_CATEGORY);
        getPreferenceScreen().addPreference(groupCategory);
        mChannelGroups.add(groupCategory);
        Preference empty = new Preference(getPrefContext());
        empty.setTitle(R.string.no_channels);
        empty.setEnabled(false);
        groupCategory.addPreference(empty);
    } else {
        for (NotificationChannelGroup group : mChannelGroupList) {
            PreferenceCategory groupCategory = new PreferenceCategory(getPrefContext());
            if (group.getId() == null) {
                groupCategory.setTitle(mChannelGroupList.size() > 1 ? R.string.notification_channels_other : R.string.notification_channels);
                groupCategory.setKey(KEY_GENERAL_CATEGORY);
            } else {
                groupCategory.setTitle(group.getName());
                groupCategory.setKey(group.getId());
            }
            groupCategory.setOrderingAsAdded(true);
            getPreferenceScreen().addPreference(groupCategory);
            mChannelGroups.add(groupCategory);
            final List<NotificationChannel> channels = group.getChannels();
            Collections.sort(channels, mChannelComparator);
            int N = channels.size();
            for (int i = 0; i < N; i++) {
                final NotificationChannel channel = channels.get(i);
                populateSingleChannelPrefs(groupCategory, channel);
            }
        }
        int deletedChannelCount = mBackend.getDeletedChannelCount(mAppRow.pkg, mAppRow.uid);
        if (deletedChannelCount > 0 && getPreferenceScreen().findPreference(KEY_DELETED) == null) {
            mDeletedChannels = new FooterPreference(getPrefContext());
            mDeletedChannels.setSelectable(false);
            mDeletedChannels.setTitle(getResources().getQuantityString(R.plurals.deleted_channels, deletedChannelCount, deletedChannelCount));
            mDeletedChannels.setEnabled(false);
            mDeletedChannels.setKey(KEY_DELETED);
            mDeletedChannels.setOrder(ORDER_LAST);
            getPreferenceScreen().addPreference(mDeletedChannels);
        }
    }
    updateDependents(mAppRow.banned);
}
Also used : NotificationChannel(android.app.NotificationChannel) NotificationChannelGroup(android.app.NotificationChannelGroup) LayoutPreference(com.android.settings.applications.LayoutPreference) RestrictedSwitchPreference(com.android.settingslib.RestrictedSwitchPreference) MasterSwitchPreference(com.android.settings.widget.MasterSwitchPreference) FooterPreference(com.android.settingslib.widget.FooterPreference) Preference(android.support.v7.preference.Preference) PreferenceCategory(android.support.v7.preference.PreferenceCategory) FooterPreference(com.android.settingslib.widget.FooterPreference)

Aggregations

FooterPreference (com.android.settingslib.widget.FooterPreference)56 Before (org.junit.Before)14 Test (org.junit.Test)12 NotificationChannel (android.app.NotificationChannel)6 NotificationChannelGroup (android.app.NotificationChannelGroup)6 Preference (android.support.v7.preference.Preference)6 PreferenceCategory (android.support.v7.preference.PreferenceCategory)6 View (android.view.View)6 TextView (android.widget.TextView)6 LayoutPreference (com.android.settings.applications.LayoutPreference)6 MasterSwitchPreference (com.android.settings.widget.MasterSwitchPreference)6 RestrictedSwitchPreference (com.android.settingslib.RestrictedSwitchPreference)6 Intent (android.content.Intent)5 Preference (androidx.preference.Preference)5 PreferenceScreen (androidx.preference.PreferenceScreen)3 Context (android.content.Context)1 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)1 Handler (android.os.Handler)1 PowerManager (android.os.PowerManager)1 SwitchPreference (android.support.v14.preference.SwitchPreference)1