Merge "Use FooterPreference in xml explicitly"

This commit is contained in:
TreeHugger Robot
2019-06-14 03:50:37 +00:00
committed by Android (Google) Code Review
10 changed files with 84 additions and 109 deletions

View File

@@ -26,7 +26,6 @@ import android.os.Looper;
import android.provider.Settings;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
import com.android.settings.core.BasePreferenceController;
@@ -40,7 +39,7 @@ import com.android.settingslib.widget.FooterPreference;
*/
public class GameDriverFooterPreferenceController extends BasePreferenceController
implements GameDriverContentObserver.OnGameDriverContentChangedListener, LifecycleObserver,
OnStart, OnStop {
OnStart, OnStop {
private final ContentResolver mContentResolver;
@VisibleForTesting
@@ -48,8 +47,8 @@ public class GameDriverFooterPreferenceController extends BasePreferenceControll
private FooterPreference mPreference;
public GameDriverFooterPreferenceController(Context context) {
super(context, FooterPreference.KEY_FOOTER);
public GameDriverFooterPreferenceController(Context context, String key) {
super(context, key);
mContentResolver = context.getContentResolver();
mGameDriverContentObserver =
new GameDriverContentObserver(new Handler(Looper.getMainLooper()), this);
@@ -58,8 +57,8 @@ public class GameDriverFooterPreferenceController extends BasePreferenceControll
@Override
public int getAvailabilityStatus() {
return Settings.Global.getInt(
mContentResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT)
== GAME_DRIVER_OFF
mContentResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT)
== GAME_DRIVER_OFF
? AVAILABLE_UNSEARCHABLE
: CONDITIONALLY_UNAVAILABLE;
}
@@ -80,11 +79,6 @@ public class GameDriverFooterPreferenceController extends BasePreferenceControll
mGameDriverContentObserver.unregister(mContentResolver);
}
@Override
public void updateState(Preference preference) {
preference.setVisible(isAvailable());
}
@Override
public void onGameDriverContentChanged() {
updateState(mPreference);