Search in sources :

Example 71 with LayoutPreference

use of com.android.settings.applications.LayoutPreference in project android_packages_apps_Settings by crdroidandroid.

the class BatteryHeaderPreferenceControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mLifecycle = new Lifecycle();
    mContext = spy(RuntimeEnvironment.application);
    mBatteryMeterView = new BatteryMeterView(mContext);
    mBatteryPercentText = new TextView(mContext);
    mSummary = new TextView(mContext);
    ShadowEntityHeaderController.setUseMock(mEntityHeaderController);
    mSummary2 = new TextView(mContext);
    mBatteryIntent = new Intent();
    mBatteryIntent.putExtra(BatteryManager.EXTRA_LEVEL, BATTERY_LEVEL);
    mBatteryIntent.putExtra(BatteryManager.EXTRA_SCALE, 100);
    mBatteryIntent.putExtra(BatteryManager.EXTRA_PLUGGED, 1);
    doReturn(mBatteryIntent).when(mContext).registerReceiver(any(), any());
    mBatteryLayoutPref = new LayoutPreference(mContext, R.layout.battery_header);
    doReturn(mBatteryLayoutPref).when(mPreferenceScreen).findPreference(BatteryHeaderPreferenceController.KEY_BATTERY_HEADER);
    mBatteryInfo.batteryLevel = BATTERY_LEVEL;
    mController = new BatteryHeaderPreferenceController(mContext, mActivity, mPreferenceFragment, mLifecycle);
    mController.mBatteryMeterView = mBatteryMeterView;
    mController.mBatteryPercentText = mBatteryPercentText;
    mController.mSummary1 = mSummary;
    mController.mSummary2 = mSummary2;
}
Also used : LayoutPreference(com.android.settings.applications.LayoutPreference) Lifecycle(com.android.settingslib.core.lifecycle.Lifecycle) TextView(android.widget.TextView) Intent(android.content.Intent) Before(org.junit.Before)

Example 72 with LayoutPreference

use of com.android.settings.applications.LayoutPreference in project android_packages_apps_Settings by crdroidandroid.

the class AppNotificationSettings method setupBlock.

protected void setupBlock() {
    View switchBarContainer = LayoutInflater.from(getPrefContext()).inflate(R.layout.styled_switch_bar, null);
    mSwitchBar = switchBarContainer.findViewById(R.id.switch_bar);
    mSwitchBar.show();
    mSwitchBar.setDisabledByAdmin(mSuspendedAppsAdmin);
    mSwitchBar.setChecked(!mAppRow.banned);
    mSwitchBar.addOnSwitchChangeListener(new SwitchBar.OnSwitchChangeListener() {

        @Override
        public void onSwitchChanged(Switch switchView, boolean isChecked) {
            if (mShowLegacyChannelConfig && mChannel != null) {
                final int importance = isChecked ? IMPORTANCE_UNSPECIFIED : IMPORTANCE_NONE;
                mImportanceToggle.setChecked(importance == IMPORTANCE_UNSPECIFIED);
                mChannel.setImportance(importance);
                mChannel.lockFields(NotificationChannel.USER_LOCKED_IMPORTANCE);
                mBackend.updateChannel(mPkg, mUid, mChannel);
            }
            mBackend.setNotificationsEnabledForPackage(mPkgInfo.packageName, mUid, isChecked);
            mAppRow.banned = true;
            updateDependents(!isChecked);
        }
    });
    mBlockBar = new LayoutPreference(getPrefContext(), switchBarContainer);
    mBlockBar.setOrder(ORDER_FIRST);
    mBlockBar.setKey(KEY_BLOCK);
    getPreferenceScreen().addPreference(mBlockBar);
    if (mAppRow.systemApp && !mAppRow.banned) {
        setVisible(mBlockBar, false);
    }
    setupBlockDesc(R.string.app_notifications_off_desc);
}
Also used : SwitchBar(com.android.settings.widget.SwitchBar) LayoutPreference(com.android.settings.applications.LayoutPreference) Switch(android.widget.Switch) View(android.view.View)

Example 73 with LayoutPreference

use of com.android.settings.applications.LayoutPreference in project android_packages_apps_Settings by crdroidandroid.

the class ChannelNotificationSettings method setupBlock.

private void setupBlock() {
    View switchBarContainer = LayoutInflater.from(getPrefContext()).inflate(R.layout.styled_switch_bar, null);
    mSwitchBar = switchBarContainer.findViewById(R.id.switch_bar);
    mSwitchBar.show();
    mSwitchBar.setDisabledByAdmin(mSuspendedAppsAdmin);
    mSwitchBar.setChecked(mChannel.getImportance() != NotificationManager.IMPORTANCE_NONE);
    mSwitchBar.addOnSwitchChangeListener(new SwitchBar.OnSwitchChangeListener() {

        @Override
        public void onSwitchChanged(Switch switchView, boolean isChecked) {
            int importance = 0;
            if (mShowLegacyChannelConfig) {
                importance = isChecked ? IMPORTANCE_UNSPECIFIED : IMPORTANCE_NONE;
                mImportanceToggle.setChecked(importance == IMPORTANCE_UNSPECIFIED);
            } else {
                importance = isChecked ? IMPORTANCE_LOW : IMPORTANCE_NONE;
                mImportance.setSummary(getImportanceSummary(importance));
            }
            mChannel.setImportance(importance);
            mChannel.lockFields(NotificationChannel.USER_LOCKED_IMPORTANCE);
            mBackend.updateChannel(mPkg, mUid, mChannel);
            updateDependents(mChannel.getImportance() == IMPORTANCE_NONE);
        }
    });
    mBlockBar = new LayoutPreference(getPrefContext(), switchBarContainer);
    mBlockBar.setOrder(ORDER_FIRST);
    mBlockBar.setKey(KEY_BLOCK);
    getPreferenceScreen().addPreference(mBlockBar);
    if (!isChannelBlockable(mAppRow.systemApp, mChannel)) {
        setVisible(mBlockBar, false);
    }
    setupBlockDesc(R.string.channel_notifications_off_desc);
}
Also used : SwitchBar(com.android.settings.widget.SwitchBar) LayoutPreference(com.android.settings.applications.LayoutPreference) Switch(android.widget.Switch) View(android.view.View)

Example 74 with LayoutPreference

use of com.android.settings.applications.LayoutPreference in project android_packages_apps_Settings by crdroidandroid.

the class WifiDetailPreferenceController 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));
    ImageView iconView = headerPref.findViewById(R.id.entity_header_icon);
    iconView.setBackground(mContext.getDrawable(R.drawable.ic_settings_widget_background));
    iconView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
    mEntityHeaderController.setLabel(mAccessPoint.getSsidStr());
}
Also used : LayoutPreference(com.android.settings.applications.LayoutPreference) ImageView(android.widget.ImageView)

Example 75 with LayoutPreference

use of com.android.settings.applications.LayoutPreference in project android_packages_apps_Settings by crdroidandroid.

the class EntityHeaderControllerTest method testBuildView_withContext_shouldBuildPreference.

@Test
public void testBuildView_withContext_shouldBuildPreference() {
    mController = EntityHeaderController.newInstance(mActivity, mFragment, null);
    Preference preference = mController.done(mActivity, mShadowContext);
    assertThat(preference instanceof LayoutPreference).isTrue();
}
Also used : LayoutPreference(com.android.settings.applications.LayoutPreference) LayoutPreference(com.android.settings.applications.LayoutPreference) Preference(android.support.v7.preference.Preference) Test(org.junit.Test)

Aggregations

LayoutPreference (com.android.settings.applications.LayoutPreference)85 Button (android.widget.Button)18 View (android.view.View)12 Switch (android.widget.Switch)12 SwitchBar (com.android.settings.widget.SwitchBar)12 Before (org.junit.Before)12 Preference (android.support.v7.preference.Preference)7 Intent (android.content.Intent)6 ImageView (android.widget.ImageView)6 TextView (android.widget.TextView)6 Lifecycle (com.android.settingslib.core.lifecycle.Lifecycle)6 Test (org.junit.Test)6 Context (android.content.Context)1 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)1 Bundle (android.os.Bundle)1 OnPreferenceClickListener (android.support.v7.preference.Preference.OnPreferenceClickListener)1 BatterySipper (com.android.internal.os.BatterySipper)1