Merge "sysui: Observe weather enabled for lockscreen." into tm-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
823d92079d
@@ -11046,6 +11046,13 @@ public final class Settings {
|
||||
public static final String EXTRA_AUTOMATIC_POWER_SAVE_MODE =
|
||||
"extra_automatic_power_save_mode";
|
||||
|
||||
/**
|
||||
* Whether lockscreen weather is enabled.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public static final String LOCK_SCREEN_WEATHER_ENABLED = "lockscreen_weather_enabled";
|
||||
|
||||
/**
|
||||
* These entries are considered common between the personal and the managed profile,
|
||||
* since the managed profile doesn't get to change them.
|
||||
|
||||
@@ -6083,4 +6083,7 @@
|
||||
<!-- Whether the lock screen is allowed to run its own live wallpaper,
|
||||
different from the home screen wallpaper. -->
|
||||
<bool name="config_independentLockscreenLiveWallpaper">false</bool>
|
||||
|
||||
<!-- Whether to show weather on the lock screen by default. -->
|
||||
<bool name="config_lockscreenWeatherEnabledByDefault">false</bool>
|
||||
</resources>
|
||||
|
||||
@@ -4892,4 +4892,7 @@
|
||||
<java-symbol type="id" name="language_picker_header" />
|
||||
|
||||
<java-symbol type="dimen" name="status_bar_height_default" />
|
||||
|
||||
<!-- Whether to show weather on the lockscreen by default. -->
|
||||
<java-symbol type="bool" name="config_lockscreenWeatherEnabledByDefault" />
|
||||
</resources>
|
||||
|
||||
@@ -219,6 +219,7 @@ public class SecureSettings {
|
||||
Settings.Secure.ASSIST_LONG_PRESS_HOME_ENABLED,
|
||||
Settings.Secure.BLUETOOTH_LE_BROADCAST_PROGRAM_INFO,
|
||||
Settings.Secure.BLUETOOTH_LE_BROADCAST_CODE,
|
||||
Settings.Secure.BLUETOOTH_LE_BROADCAST_APP_SOURCE_NAME
|
||||
Settings.Secure.BLUETOOTH_LE_BROADCAST_APP_SOURCE_NAME,
|
||||
Settings.Secure.LOCK_SCREEN_WEATHER_ENABLED
|
||||
};
|
||||
}
|
||||
|
||||
@@ -352,5 +352,6 @@ public class SecureSettingsValidators {
|
||||
VALIDATORS.put(Secure.BLUETOOTH_LE_BROADCAST_PROGRAM_INFO, ANY_STRING_VALIDATOR);
|
||||
VALIDATORS.put(Secure.BLUETOOTH_LE_BROADCAST_CODE, ANY_STRING_VALIDATOR);
|
||||
VALIDATORS.put(Secure.BLUETOOTH_LE_BROADCAST_APP_SOURCE_NAME, ANY_STRING_VALIDATOR);
|
||||
VALIDATORS.put(Secure.LOCK_SCREEN_WEATHER_ENABLED, BOOLEAN_VALIDATOR);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,6 +106,12 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
|
||||
updateDoubleLineClock();
|
||||
}
|
||||
};
|
||||
private final ContentObserver mShowWeatherObserver = new ContentObserver(null) {
|
||||
@Override
|
||||
public void onChange(boolean change) {
|
||||
setWeatherVisibility();
|
||||
}
|
||||
};
|
||||
|
||||
private final KeyguardUnlockAnimationController.KeyguardUnlockAnimationListener
|
||||
mKeyguardUnlockAnimationListener =
|
||||
@@ -216,7 +222,15 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
|
||||
UserHandle.USER_ALL
|
||||
);
|
||||
|
||||
mSecureSettings.registerContentObserverForUser(
|
||||
Settings.Secure.LOCK_SCREEN_WEATHER_ENABLED,
|
||||
false, /* notifyForDescendants */
|
||||
mShowWeatherObserver,
|
||||
UserHandle.USER_ALL
|
||||
);
|
||||
|
||||
updateDoubleLineClock();
|
||||
setWeatherVisibility();
|
||||
|
||||
mKeyguardUnlockAnimationController.addKeyguardUnlockAnimationListener(
|
||||
mKeyguardUnlockAnimationListener);
|
||||
@@ -449,6 +463,14 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
|
||||
}
|
||||
}
|
||||
|
||||
private void setWeatherVisibility() {
|
||||
if (mWeatherView != null) {
|
||||
mUiExecutor.execute(
|
||||
() -> mWeatherView.setVisibility(
|
||||
mSmartspaceController.isWeatherEnabled() ? View.VISIBLE : View.GONE));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the clipChildren property on relevant views, to allow the smartspace to draw out of
|
||||
* bounds during the unlock transition.
|
||||
|
||||
@@ -31,6 +31,7 @@ import android.os.Handler
|
||||
import android.os.UserHandle
|
||||
import android.provider.Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS
|
||||
import android.provider.Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS
|
||||
import android.provider.Settings.Secure.LOCK_SCREEN_WEATHER_ENABLED
|
||||
import android.util.Log
|
||||
import android.view.ContextThemeWrapper
|
||||
import android.view.View
|
||||
@@ -244,6 +245,17 @@ constructor(
|
||||
datePlugin != null && weatherPlugin != null
|
||||
}
|
||||
|
||||
fun isWeatherEnabled(): Boolean {
|
||||
execution.assertIsMainThread()
|
||||
val defaultValue = context.getResources().getBoolean(
|
||||
com.android.internal.R.bool.config_lockscreenWeatherEnabledByDefault)
|
||||
val showWeather = secureSettings.getIntForUser(
|
||||
LOCK_SCREEN_WEATHER_ENABLED,
|
||||
if (defaultValue) 1 else 0,
|
||||
userTracker.userId) == 1
|
||||
return showWeather
|
||||
}
|
||||
|
||||
private fun updateBypassEnabled() {
|
||||
val bypassEnabled = bypassController.bypassEnabled
|
||||
smartspaceViews.forEach { it.setKeyguardBypassEnabled(bypassEnabled) }
|
||||
|
||||
@@ -300,8 +300,9 @@ public class KeyguardClockSwitchControllerTest extends SysuiTestCase {
|
||||
ArgumentCaptor<ContentObserver> observerCaptor =
|
||||
ArgumentCaptor.forClass(ContentObserver.class);
|
||||
mController.init();
|
||||
verify(mSecureSettings).registerContentObserverForUser(any(String.class),
|
||||
anyBoolean(), observerCaptor.capture(), eq(UserHandle.USER_ALL));
|
||||
verify(mSecureSettings).registerContentObserverForUser(
|
||||
eq(Settings.Secure.LOCKSCREEN_USE_DOUBLE_LINE_CLOCK),
|
||||
anyBoolean(), observerCaptor.capture(), eq(UserHandle.USER_ALL));
|
||||
ContentObserver observer = observerCaptor.getValue();
|
||||
mExecutor.runAllReady();
|
||||
|
||||
@@ -347,6 +348,22 @@ public class KeyguardClockSwitchControllerTest extends SysuiTestCase {
|
||||
assertEquals(0, mController.getClockBottom(10));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testChangeLockscreenWeatherEnabledSetsWeatherViewVisible() {
|
||||
when(mSmartspaceController.isWeatherEnabled()).thenReturn(true);
|
||||
ArgumentCaptor<ContentObserver> observerCaptor =
|
||||
ArgumentCaptor.forClass(ContentObserver.class);
|
||||
mController.init();
|
||||
verify(mSecureSettings).registerContentObserverForUser(
|
||||
eq(Settings.Secure.LOCK_SCREEN_WEATHER_ENABLED), anyBoolean(),
|
||||
observerCaptor.capture(), eq(UserHandle.USER_ALL));
|
||||
ContentObserver observer = observerCaptor.getValue();
|
||||
mExecutor.runAllReady();
|
||||
// When a settings change has occurred, check that view is visible.
|
||||
observer.onChange(true);
|
||||
mExecutor.runAllReady();
|
||||
assertEquals(View.VISIBLE, mFakeWeatherView.getVisibility());
|
||||
}
|
||||
|
||||
private void verifyAttachment(VerificationMode times) {
|
||||
verify(mClockRegistry, times).registerClockChangeListener(
|
||||
|
||||
Reference in New Issue
Block a user