Skip to content

Commit

Permalink
!fixup Settings: Notch-city: Add 3 mode display cutout handler [3/3]
Browse files Browse the repository at this point in the history
*nuke unnecessary preference controller
*Also hide cutout settings for devices with no notch

Signed-off-by: Himanshu Kharkar <[email protected]>
  • Loading branch information
himanshukharkar committed Jun 22, 2021
1 parent 542b15b commit d8ff2ff
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 54 deletions.
7 changes: 1 addition & 6 deletions res/xml/display_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,11 @@
android:summary="@string/summary_placeholder"
settings:controller="com.android.settings.display.PeakRefreshRatePreferenceController" />

<!--ListPreference
android:icon="@drawable/ic_settings_notch_display"
android:key="display_cutout_emulation"
android:title="@string/display_cutout_emulation"
settings:keywords="@string/display_cutout_emulation_keywords" /-->

<Preference
android:key="cutout_settings"
android:fragment="com.android.settings.display.CutoutFragment"
android:icon="@drawable/ic_settings_notch_display"
settings:controller="com.android.settings.display.CutoutPreferenceController"
android:title="@string/cutout_main" />

<SwitchPreference
Expand Down
2 changes: 0 additions & 2 deletions src/com/android/settings/DisplaySettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import com.android.settings.display.ThemePreferenceController;
import com.android.settings.display.TimeoutPreferenceController;
import com.android.settings.display.VrDisplayPreferenceController;
import com.android.settings.display.EmulateDisplayCutoutPreferenceController;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.core.lifecycle.Lifecycle;
Expand Down Expand Up @@ -94,7 +93,6 @@ private static List<AbstractPreferenceController> buildPreferenceControllers(
controllers.add(new VrDisplayPreferenceController(context));
controllers.add(new ShowOperatorNamePreferenceController(context));
controllers.add(new ThemePreferenceController(context));
controllers.add(new EmulateDisplayCutoutPreferenceController(context));
controllers.add(new BrightnessLevelPreferenceController(context, lifecycle));
return controllers;
}
Expand Down
54 changes: 54 additions & 0 deletions src/com/android/settings/display/CutoutPreferenceController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Copyright (C) 2021 Wave-OS
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.android.settings.display;

import android.content.Context;

import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;

import com.android.settings.core.BasePreferenceController;
import com.android.settingslib.core.lifecycle.LifecycleObserver;
import com.android.settingslib.core.lifecycle.events.OnResume;

public class CutoutPreferenceController extends BasePreferenceController implements
LifecycleObserver, OnResume {

private Preference mPreference;

public CutoutPreferenceController(Context context, String key) {
super(context, key);
}

@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = screen.findPreference(getPreferenceKey());
}

@Override
public int getAvailabilityStatus() {
return mContext.getResources().getString(
com.android.internal.R.string.config_mainBuiltInDisplayCutout
) != "" ? UNSUPPORTED_ON_DEVICE : AVAILABLE;
}

@Override
public void onResume() {
mPreference.setVisible(isAvailable());
}
}

This file was deleted.

0 comments on commit d8ff2ff

Please sign in to comment.