Search in sources :

Example 6 with LayoutPreference

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

the class RecentAppsPreferenceControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    final Context context = spy(RuntimeEnvironment.application);
    when(context.getApplicationContext()).thenReturn(context);
    ReflectionHelpers.setStaticField(ApplicationsState.class, "sInstance", mAppState);
    doReturn(mUserManager).when(context).getSystemService(Context.USER_SERVICE);
    doReturn(mPackageManager).when(context).getPackageManager();
    when(mUserManager.getProfileIdsWithDisabled(anyInt())).thenReturn(new int[] {});
    final View appEntitiesHeaderView = LayoutInflater.from(context).inflate(R.layout.app_entities_header, null);
    final Preference dividerPreference = new Preference(context);
    final LayoutPreference recentAppsPreference = spy(new LayoutPreference(context, appEntitiesHeaderView));
    mController = spy(new RecentAppsPreferenceController(context, "test_key"));
    mController.setFragment(mFragment);
    mController.mAppEntitiesController = mock(AppEntitiesHeaderController.class);
    mController.mRecentAppsPreference = recentAppsPreference;
    mController.mDivider = dividerPreference;
    when(mScreen.findPreference(RecentAppsPreferenceController.KEY_DIVIDER)).thenReturn(dividerPreference);
    when(mScreen.findPreference("test_key")).thenReturn(recentAppsPreference);
    when(recentAppsPreference.findViewById(R.id.app_entities_header)).thenReturn(appEntitiesHeaderView);
}
Also used : Context(android.content.Context) LayoutPreference(com.android.settingslib.widget.LayoutPreference) LayoutPreference(com.android.settingslib.widget.LayoutPreference) Preference(androidx.preference.Preference) AppEntitiesHeaderController(com.android.settingslib.widget.AppEntitiesHeaderController) View(android.view.View) Before(org.junit.Before)

Example 7 with LayoutPreference

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

the class CaptionPropertiesFragment method initializeAllPreferences.

private void initializeAllPreferences() {
    final LayoutPreference captionPreview = findPreference(PREF_CAPTION_PREVIEW);
    mPreviewText = captionPreview.findViewById(R.id.preview_text);
    mPreviewWindow = captionPreview.findViewById(R.id.preview_window);
    mPreviewViewport = captionPreview.findViewById(R.id.preview_viewport);
    mPreviewViewport.addOnLayoutChangeListener((v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> refreshPreviewText());
    final Resources res = getResources();
    final int[] presetValues = res.getIntArray(R.array.captioning_preset_selector_values);
    final String[] presetTitles = res.getStringArray(R.array.captioning_preset_selector_titles);
    mPreset = (PresetPreference) findPreference(PREF_PRESET);
    mPreset.setValues(presetValues);
    mPreset.setTitles(presetTitles);
    mSwitch = (SwitchPreference) findPreference(PREF_SWITCH);
    mLocale = (LocalePreference) findPreference(PREF_LOCALE);
    mFontSize = (ListPreference) findPreference(PREF_FONT_SIZE);
    // Initialize the preference list
    mPreferenceList.add(mLocale);
    mPreferenceList.add(mFontSize);
    mPreferenceList.add(mPreset);
    refreshPreferenceViewEnabled(mCaptioningManager.isEnabled());
    mCustom = (PreferenceCategory) findPreference(PREF_CUSTOM);
    mShowingCustom = true;
    final int[] colorValues = res.getIntArray(R.array.captioning_color_selector_values);
    final String[] colorTitles = res.getStringArray(R.array.captioning_color_selector_titles);
    mForegroundColor = (ColorPreference) mCustom.findPreference(PREF_FOREGROUND_COLOR);
    mForegroundColor.setTitles(colorTitles);
    mForegroundColor.setValues(colorValues);
    final int[] opacityValues = res.getIntArray(R.array.captioning_opacity_selector_values);
    final String[] opacityTitles = res.getStringArray(R.array.captioning_opacity_selector_titles);
    mForegroundOpacity = (ColorPreference) mCustom.findPreference(PREF_FOREGROUND_OPACITY);
    mForegroundOpacity.setTitles(opacityTitles);
    mForegroundOpacity.setValues(opacityValues);
    mEdgeColor = (ColorPreference) mCustom.findPreference(PREF_EDGE_COLOR);
    mEdgeColor.setTitles(colorTitles);
    mEdgeColor.setValues(colorValues);
    // Add "none" as an additional option for backgrounds.
    final int[] bgColorValues = new int[colorValues.length + 1];
    final String[] bgColorTitles = new String[colorTitles.length + 1];
    System.arraycopy(colorValues, 0, bgColorValues, 1, colorValues.length);
    System.arraycopy(colorTitles, 0, bgColorTitles, 1, colorTitles.length);
    bgColorValues[0] = Color.TRANSPARENT;
    bgColorTitles[0] = getString(R.string.color_none);
    mBackgroundColor = (ColorPreference) mCustom.findPreference(PREF_BACKGROUND_COLOR);
    mBackgroundColor.setTitles(bgColorTitles);
    mBackgroundColor.setValues(bgColorValues);
    mBackgroundOpacity = (ColorPreference) mCustom.findPreference(PREF_BACKGROUND_OPACITY);
    mBackgroundOpacity.setTitles(opacityTitles);
    mBackgroundOpacity.setValues(opacityValues);
    mWindowColor = (ColorPreference) mCustom.findPreference(PREF_WINDOW_COLOR);
    mWindowColor.setTitles(bgColorTitles);
    mWindowColor.setValues(bgColorValues);
    mWindowOpacity = (ColorPreference) mCustom.findPreference(PREF_WINDOW_OPACITY);
    mWindowOpacity.setTitles(opacityTitles);
    mWindowOpacity.setValues(opacityValues);
    mEdgeType = (EdgeTypePreference) mCustom.findPreference(PREF_EDGE_TYPE);
    mTypeface = (ListPreference) mCustom.findPreference(PREF_TYPEFACE);
}
Also used : LayoutPreference(com.android.settingslib.widget.LayoutPreference) Resources(android.content.res.Resources)

Example 8 with LayoutPreference

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

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);
}
Also used : LayoutPreference(com.android.settingslib.widget.LayoutPreference)

Example 9 with LayoutPreference

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

the class DcDimmingSettings method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mContext = getContext();
    mDcDimmingManager = (DcDimmingManager) getSystemService(Context.DC_DIM_SERVICE);
    if (mDcDimmingManager == null || !mDcDimmingManager.isAvailable()) {
        return;
    }
    PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
    mMinimumBacklight = pm.getMinimumScreenBrightnessSetting();
    mMaximumBacklight = pm.getMaximumScreenBrightnessSetting();
    SettingsObserver settingsObserver = new SettingsObserver(new Handler());
    settingsObserver.observe();
    LayoutPreference brightnessPreference = findPreference(KEY_BRIGHTNESS);
    mSeekBar = brightnessPreference.findViewById(R.id.seekbar);
    mBrightnessValue = brightnessPreference.findViewById(R.id.value);
    mBrightnessTitle = brightnessPreference.findViewById(R.id.title);
    mBrightnessSumm = brightnessPreference.findViewById(R.id.summary);
    mSeekBar.setOnSeekBarChangeListener(this);
    mSeekBar.setMax(GAMMA_SPACE_MAX / 2);
    LayoutPreference preference = findPreference(KEY_FORCE_BUTTON);
    mTurnOnButton = preference.findViewById(R.id.dc_dimming_on_button);
    mTurnOnButton.setOnClickListener(mForceListener);
    mTurnOffButton = preference.findViewById(R.id.dc_dimming_off_button);
    mTurnOffButton.setOnClickListener(mForceListener);
    mRestoreAuto = findPreference(KEY_RESTORE_BUTTON);
    Button restoreActiveButton = mRestoreAuto.findViewById(R.id.dc_dimming_restore_active);
    restoreActiveButton.setOnClickListener(mRestoreListener);
    mDropPreference = findPreference(KEY_AUTO_MODE);
    mDropPreference.setEntries(new CharSequence[] { mContext.getString(R.string.dark_ui_auto_mode_never), mContext.getString(R.string.dark_ui_auto_mode_auto), mContext.getString(R.string.dc_dimming_mode_brightness), mContext.getString(R.string.dc_dimming_mode_full) });
    mDropPreference.setEntryValues(new CharSequence[] { String.valueOf(MODE_AUTO_OFF), String.valueOf(MODE_AUTO_TIME), String.valueOf(MODE_AUTO_BRIGHTNESS), String.valueOf(MODE_AUTO_FULL) });
    mDropPreference.setValue(String.valueOf(mDcDimmingManager.getAutoMode()));
    mDropPreference.setOnPreferenceChangeListener(this);
    Preference footerPreference = findPreference(FooterPreference.KEY_FOOTER);
    footerPreference.setTitle(mContext.getResources().getString(R.string.dc_dimming_info));
    final int gamma = convertLinearToGamma(mDcDimmingManager.getBrightnessThreshold(), mMinimumBacklight, mMaximumBacklight);
    mSeekBar.setProgress(gamma);
    updateStateInternal();
}
Also used : PowerManager(android.os.PowerManager) LayoutPreference(com.android.settingslib.widget.LayoutPreference) Button(android.widget.Button) LayoutPreference(com.android.settingslib.widget.LayoutPreference) DropDownPreference(androidx.preference.DropDownPreference) Preference(androidx.preference.Preference) FooterPreference(com.android.settingslib.widget.FooterPreference) Handler(android.os.Handler)

Example 10 with LayoutPreference

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

the class RecentLocationAccessPreferenceController method displayPreference.

@Override
public void displayPreference(PreferenceScreen screen) {
    super.displayPreference(screen);
    final LayoutPreference preference = screen.findPreference(KEY_APPS_DASHBOARD);
    final View view = preference.findViewById(R.id.app_entities_header);
    mController = AppEntitiesHeaderController.newInstance(mContext, view).setHeaderTitleRes(R.string.location_category_recent_location_access).setHeaderDetailsRes(R.string.location_recent_location_access_view_details).setHeaderEmptyRes(R.string.location_no_recent_accesses).setHeaderDetailsClickListener((View v) -> {
        final Intent intent = new Intent(Intent.ACTION_REVIEW_PERMISSION_USAGE);
        intent.putExtra(Intent.EXTRA_PERMISSION_NAME, Manifest.permission.ACCESS_FINE_LOCATION);
        intent.putExtra(Intent.EXTRA_DURATION_MILLIS, DAYS.toMillis(1));
        mContext.startActivity(intent);
    });
}
Also used : LayoutPreference(com.android.settingslib.widget.LayoutPreference) Intent(android.content.Intent) View(android.view.View)

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