Skip to content

Commit

Permalink
base: Screen Stabilization [1/2]
Browse files Browse the repository at this point in the history
* New Settings menu integrated into QS itself(long click)
* Thanks to SuperDroidBond for keeping this alive till Pie

Change-Id: Ibccb8d78d79938f42241ea3690ea66c3aace89ea
  • Loading branch information
ritujb authored and neobuddy89 committed May 11, 2020
1 parent c33f56f commit 11fb9f4
Show file tree
Hide file tree
Showing 11 changed files with 889 additions and 4 deletions.
14 changes: 14 additions & 0 deletions core/java/android/provider/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -5196,6 +5196,20 @@ public boolean validate(@Nullable String value) {
* @hide
*/
public static final String QS_BACKGROUND_BLUR = "qs_background_blur";

/**
* Screen stabilization parameters
* @hide
*/
public static final String STABILIZATION_ENABLE = "stabilization_enable";

public static final String STABILIZATION_VELOCITY_FRICTION = "stabilization_velocity_friction";

public static final String STABILIZATION_POSITION_FRICTION = "stabilization_position_friction";

public static final String STABILIZATION_LOWPASS_ALPHA = "stabilization_lowpass_alpha";

public static final String STABILIZATION_VELOCITY_AMPLITUDE = "stabilization_velocity_amplitude";

/**
* Switch between different dark styles
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<!--
Copyright (C) 2014 The Android Open Source Project
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.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:height="24dp"
android:width="24dp"
android:viewportWidth="380"
android:viewportHeight="360">
<group
android:translateY="360.000000"
android:scaleX="0.100000"
android:scaleY="-0.100000">
<path
android:fillColor="#4DFFFFFF"
android:strokeWidth="1"
android:pathData="M1219 3109 c-105 -9 -175 -65 -205 -165 -21 -72 -21 -2217 1 -2290 19 -63 63 -116
120 -144 44 -21 48 -21 764 -22 l719 -1 46 23 c58 27 102 81 121 144 22 74 22 2218
0 2292 -19 63 -63 116 -120 144 -45 22 -49 22 -712 23 -368 1 -698 -1 -734 -4z
m1331 -1254 l0 -925 -647 2 -648 3 -3 923 -2 922 650 0 650 0 0 -925z m-483 -1035
c54 -33 58 -139 6 -180 -23 -18 -40 -20 -174 -20 -139 0 -149 1 -174 23 -32 27 -44
92 -25 137 21 51 49 59 200 60 117 0 139 -3 167 -20z" />
<path
android:fillColor="#4DFFFFFF"
android:strokeWidth="1"
android:pathData="M465 2905 c-159 -67 -307 -134 -327 -148 -53 -37 -82 -98 -82 -172 0 -55 15 -96
200 -530 110 -259 268 -629 350 -823 l149 -352 3 284 2 284 -220 522 c-122 287
-219 527 -217 534 3 6 102 52 221 101 l216 90 0 168 c0 92 -1 167 -2 166 -2 0 -133
-56 -293 -124z" />
<path
android:fillColor="#4DFFFFFF"
android:strokeWidth="1"
android:pathData="M3040 2863 l0 -168 216 -90 c119 -49 218 -95 221 -101 2 -7 -95 -246 -216 -533
l-221 -521 2 -285 3 -285 349 822 c327 769 349 827 350 883 0 71 -27 131 -76 168
-18 14 -163 80 -323 147 -159 67 -293 124 -297 127 -5 2 -8 -71 -8 -164z" />
</group>
</vector>
46 changes: 46 additions & 0 deletions packages/SystemUI/res/drawable/ic_screen_stabilization_enabled.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<!--
Copyright (C) 2014 The Android Open Source Project
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.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:height="24dp"
android:width="24dp"
android:viewportWidth="380"
android:viewportHeight="360">
<group
android:translateY="360.000000"
android:scaleX="0.100000"
android:scaleY="-0.100000">
<path
android:fillColor="#FFFFFF"
android:strokeWidth="1"
android:pathData="M1219 3109 c-105 -9 -175 -65 -205 -165 -21 -72 -21 -2217 1 -2290 19 -63 63 -116
120 -144 44 -21 48 -21 764 -22 l719 -1 46 23 c58 27 102 81 121 144 22 74 22 2218
0 2292 -19 63 -63 116 -120 144 -45 22 -49 22 -712 23 -368 1 -698 -1 -734 -4z
m1331 -1254 l0 -925 -647 2 -648 3 -3 923 -2 922 650 0 650 0 0 -925z m-483 -1035
c54 -33 58 -139 6 -180 -23 -18 -40 -20 -174 -20 -139 0 -149 1 -174 23 -32 27 -44
92 -25 137 21 51 49 59 200 60 117 0 139 -3 167 -20z" />
<path
android:fillColor="#FFFFFF"
android:strokeWidth="1"
android:pathData="M465 2905 c-159 -67 -307 -134 -327 -148 -53 -37 -82 -98 -82 -172 0 -55 15 -96
200 -530 110 -259 268 -629 350 -823 l149 -352 3 284 2 284 -220 522 c-122 287
-219 527 -217 534 3 6 102 52 221 101 l216 90 0 168 c0 92 -1 167 -2 166 -2 0 -133
-56 -293 -124z" />
<path
android:fillColor="#FFFFFF"
android:strokeWidth="1"
android:pathData="M3040 2863 l0 -168 216 -90 c119 -49 218 -95 221 -101 2 -7 -95 -246 -216 -533
l-221 -521 2 -285 3 -285 349 822 c327 769 349 827 350 883 0 71 -27 131 -76 168
-18 14 -163 80 -323 147 -159 67 -293 124 -297 127 -5 2 -8 -71 -8 -164z" />
</group>
</vector>
4 changes: 2 additions & 2 deletions packages/SystemUI/res/layout/qs_detail.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
android:layout_height="match_parent"
android:clickable="true"
android:orientation="vertical"
android:paddingBottom="8dp"
android:paddingBottom="0.01dp"
android:visibility="invisible"
android:elevation="4dp"
android:importantForAccessibility="no" >
Expand Down Expand Up @@ -72,4 +72,4 @@
<include layout="@layout/qs_detail_buttons" />
</com.android.keyguard.AlphaOptimizedLinearLayout>

</com.android.systemui.qs.QSDetail>
</com.android.systemui.qs.QSDetail>
179 changes: 179 additions & 0 deletions packages/SystemUI/res/layout/screen_stabilization_panel.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2020 The AOSPA Project
~
~ 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
-->

<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/screen_stabilization_panel"
android:orientation="vertical"
android:clipChildren="false">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:textAppearance="?android:attr/textAppearanceMedium"
android:singleLine="true"
android:layout_marginTop="12dp"
android:text="@string/stabilization_velocity_friction"
android:ellipsize="marquee" />

<SeekBar
android:id="@+id/stabilization_velocity_friction_seekbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:min="1"
android:max="5"
android:layout_marginTop="6dp"
style="@android:style/Widget.Material.SeekBar.Discrete"
android:theme="@*android:style/ThemeOverlay.DeviceDefault.Accent" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="4dp">

<TextView android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginBottom="2dp"
android:layout_marginStart="12dp"
android:gravity="start"
android:text="@string/low_label"
android:textAppearance="?android:attr/textAppearance"
android:singleLine="true"
android:ellipsize="marquee" />

<TextView android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginBottom="2dp"
android:layout_marginEnd="12dp"
android:gravity="end"
android:text="@string/high_label"
android:textAppearance="?android:attr/textAppearance"
android:singleLine="true"
android:ellipsize="marquee" />
</LinearLayout>

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:textAppearance="?android:attr/textAppearanceMedium"
android:singleLine="true"
android:layout_marginTop="20dp"
android:text="@string/stabilization_velocity_amplitude"
android:ellipsize="marquee" />

<SeekBar
android:id="@+id/stabilization_velocity_amplitude_seekbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:min="1"
android:max="5"
android:layout_marginTop="6dp"
style="@android:style/Widget.Material.SeekBar.Discrete"
android:theme="@*android:style/ThemeOverlay.DeviceDefault.Accent" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="4dp">

<TextView android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginBottom="2dp"
android:layout_marginStart="12dp"
android:gravity="start"
android:text="@string/low_label"
android:textAppearance="?android:attr/textAppearance"
android:singleLine="true"
android:ellipsize="marquee" />

<TextView android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginBottom="2dp"
android:layout_marginEnd="12dp"
android:gravity="end"
android:text="@string/high_label"
android:textAppearance="?android:attr/textAppearance"
android:singleLine="true"
android:ellipsize="marquee" />
</LinearLayout>

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:textAppearance="?android:attr/textAppearanceMedium"
android:singleLine="true"
android:layout_marginTop="20dp"
android:text="@string/stabilization_position_friction"
android:ellipsize="marquee" />

<SeekBar
android:id="@+id/stabilization_position_friction_seekbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:min="1"
android:max="5"
android:layout_marginTop="6dp"
style="@android:style/Widget.Material.SeekBar.Discrete"
android:theme="@*android:style/ThemeOverlay.DeviceDefault.Accent" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="4dp">

<TextView android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginBottom="2dp"
android:layout_marginStart="12dp"
android:gravity="start"
android:text="@string/low_label"
android:textAppearance="?android:attr/textAppearance"
android:singleLine="true"
android:ellipsize="marquee" />

<TextView android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginBottom="2dp"
android:layout_marginEnd="12dp"
android:gravity="end"
android:text="@string/high_label"
android:textAppearance="?android:attr/textAppearance"
android:singleLine="true"
android:ellipsize="marquee" />
</LinearLayout>

</LinearLayout>
2 changes: 1 addition & 1 deletion packages/SystemUI/res/values/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@

<!-- Tiles native to System UI. Order should match "quick_settings_tiles_default" -->
<string name="quick_settings_tiles_stock" translatable="false">
wifi,cell,battery,dnd,flashlight,rotation,bt,airplane,nfc,location,hotspot,inversion,saver,dark,work,cast,night,adb_network,ambient_display,caffeine,heads_up,livedisplay,aod,reading_mode,sync,dataswitch,usb_tether,volume_panel,vpn,profiles,powershare,smartpixels,screenshot,cpuinfo,fpsinfo,hw_keys,compass,music,soundsearch,sound,reboot,gaming
wifi,cell,battery,dnd,flashlight,rotation,bt,airplane,nfc,location,hotspot,inversion,saver,dark,work,cast,night,adb_network,ambient_display,caffeine,heads_up,livedisplay,aod,reading_mode,sync,dataswitch,usb_tether,volume_panel,vpn,profiles,powershare,smartpixels,screenshot,screenstabilization,cpuinfo,fpsinfo,hw_keys,compass,music,soundsearch,sound,reboot,gaming
</string>

<!-- The tiles to display in QuickSettings -->
Expand Down
11 changes: 11 additions & 0 deletions packages/SystemUI/res/values/cr_strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -208,4 +208,15 @@
<string name="text_clock_m_fifty_seven">Fifty Seven</string>
<string name="text_clock_m_fifty_eight">Fifty Eight</string>
<string name="text_clock_m_fifty_nine">Fifty Nine</string>

<!-- Screen Stabilization -->
<string name="quick_settings_stabilization_label">Screen Stabilization</string>
<string name="quick_settings_stabilization_off">Stabilization is disabled</string>
<string name="quick_settings_stabilization_on">Stabilization is enabled</string>
<string name="low_label">Low</string>
<string name="high_label">High</string>
<string name="stabilization_velocity_friction">Velocity Friction</string>
<string name="stabilization_velocity_amplitude">Velocity Amplitude</string>
<string name="stabilization_position_friction">Position Friction</string>

</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
import com.android.systemui.qs.tiles.SoundSearchTile;
import com.android.systemui.qs.tiles.SyncTile;
import com.android.systemui.qs.tiles.UiModeNightTile;
import com.android.systemui.qs.tiles.ScreenStabilizationTile;
import com.android.systemui.qs.tiles.UsbTetherTile;
import com.android.systemui.qs.tiles.UserTile;
import com.android.systemui.qs.tiles.VolumeTile;
Expand Down Expand Up @@ -126,6 +127,7 @@ public class QSFactoryImpl implements QSFactory {
private final Provider<RebootTile> mRebootTileProvider;
private final Provider<GamingModeTile> mGamingModeTileProvider;
private final Provider<DataSwitchTile> mDataSwitchTileProvider;
private final Provider<ScreenStabilizationTile> mScreenStabilizationTileProvider;

private QSTileHost mHost;

Expand Down Expand Up @@ -173,7 +175,8 @@ public QSFactoryImpl(Provider<WifiTile> wifiTileProvider,
Provider<RebootTile> rebootTileProvider,
Provider<GamingModeTile> gamingModeTileProvider,
Provider<DataSwitchTile> dataSwitchTileProvider,
Provider<FPSInfoTile> fpsInfoTileProvider) {
Provider<FPSInfoTile> fpsInfoTileProvider,
Provider<ScreenStabilizationTile> screenStabilizationTileProvider) {
mWifiTileProvider = wifiTileProvider;
mBluetoothTileProvider = bluetoothTileProvider;
mCellularTileProvider = cellularTileProvider;
Expand Down Expand Up @@ -218,6 +221,7 @@ public QSFactoryImpl(Provider<WifiTile> wifiTileProvider,
mGamingModeTileProvider = gamingModeTileProvider;
mDataSwitchTileProvider = dataSwitchTileProvider;
mFPSInfoTileProvider = fpsInfoTileProvider;
mScreenStabilizationTileProvider = screenStabilizationTileProvider;
}

public void setHost(QSTileHost host) {
Expand Down Expand Up @@ -322,6 +326,8 @@ private QSTileImpl createTileInternal(String tileSpec) {
return mDataSwitchTileProvider.get();
case "fpsinfo":
return mFPSInfoTileProvider.get();
case "screenstabilization":
return mScreenStabilizationTileProvider.get();
}

// Intent tiles.
Expand Down
Loading

0 comments on commit 11fb9f4

Please sign in to comment.