Add tuner params to change the initial stack state and navbar gesture.

Change-Id: I114b8342f5293589eb96a1fd3a14da1757e75a95
This commit is contained in:
Winson
2015-12-03 16:55:06 -08:00
parent 389a3069ff
commit e759cd58bd
5 changed files with 52 additions and 10 deletions

View File

@@ -1171,13 +1171,23 @@
<!-- Toggles fullscreen screenshots. DO NOT TRANSLATE -->
<string name="overview_fullscreen_thumbnails">Enable fullscreen screenshots</string>
<!-- Description for the toggle for fullscreen screenshots. DO NOT TRANSLATE -->
<string name="overview_fullscreen_thumbnails_desc">Enable fullscreen screenshots in Overview</string>
<string name="overview_fullscreen_thumbnails_desc">Enable fullscreen screenshots in Overview. Restart required.</string>
<!-- Toggle to enable the Overview nav bar gesture. DO NOT TRANSLATE -->
<string name="overview_nav_bar_gesture">Enable navigation bar gesture</string>
<!-- Description for the toggle to enable the Overview nav bar gesture. DO NOT TRANSLATE -->
<string name="overview_nav_bar_gesture_desc">Enables the gesture to enter Overview by swiping up on the Nav bar</string>
<!-- Toggle to show the history view in Overview. DO NOT TRANSLATE -->
<string name="overview_show_history">Show History</string>
<!-- Description for the toggle to show the history view in Overview. DO NOT TRANSLATE -->
<string name="overview_show_history_desc">Enables the history view to see more recent tasks</string>
<!-- Toggle to set the initial scroll state to be paging or stack. DO NOT TRANSLATE -->
<string name="overview_initial_state_paging">Initialize to paging</string>
<!-- Description for the toggle to set the initial scroll state to be paging or stack. DO NOT TRANSLATE -->
<string name="overview_initial_state_paging_desc">Determines whether Overview will initially be in a stacked or paged state</string>
<!-- Category in the System UI Tuner settings, where new/experimental
settings are -->
<string name="experimental">Experimental</string>

View File

@@ -92,11 +92,21 @@
android:title="@string/overview_page_on_toggle"
android:summary="@string/overview_page_on_toggle_desc" />
<com.android.systemui.tuner.TunerSwitch
android:key="overview_initial_state_paging"
android:title="@string/overview_initial_state_paging"
android:summary="@string/overview_initial_state_paging_desc" />
<com.android.systemui.tuner.TunerSwitch
android:key="overview_fast_toggle"
android:title="@string/overview_fast_toggle_via_button"
android:summary="@string/overview_fast_toggle_via_button_desc" />
<com.android.systemui.tuner.TunerSwitch
android:key="overview_nav_bar_gesture"
android:title="@string/overview_nav_bar_gesture"
android:summary="@string/overview_nav_bar_gesture_desc" />
<com.android.systemui.tuner.TunerSwitch
android:key="overview_fullscreen_thumbnails"
android:title="@string/overview_fullscreen_thumbnails"

View File

@@ -30,6 +30,7 @@ public class RecentsDebugFlags implements TunerService.Tunable {
private static final String KEY_PAGE_ON_TOGGLE = "overview_page_on_toggle";
private static final String KEY_FULLSCREEN_THUMBNAILS = "overview_fullscreen_thumbnails";
private static final String KEY_SHOW_HISTORY = "overview_show_history";
private static final String KEY_INITIAL_STATE_PAGING = "overview_initial_state_paging";
public static class Static {
// Enables debug drawing for the transition thumbnail
@@ -54,6 +55,7 @@ public class RecentsDebugFlags implements TunerService.Tunable {
private boolean mPageOnToggle;
private boolean mUseFullscreenThumbnails;
private boolean mShowHistory;
private boolean mInitialStatePaging;
/**
* We read the prefs once when we start the activity, then update them as the tuner changes
@@ -63,7 +65,7 @@ public class RecentsDebugFlags implements TunerService.Tunable {
// Register all our flags, this will also call onTuningChanged() for each key, which will
// initialize the current state of each flag
TunerService.get(context).addTunable(this, KEY_FAST_TOGGLE, KEY_PAGE_ON_TOGGLE,
KEY_FULLSCREEN_THUMBNAILS, KEY_SHOW_HISTORY);
KEY_FULLSCREEN_THUMBNAILS, KEY_SHOW_HISTORY, KEY_INITIAL_STATE_PAGING);
}
/**
@@ -94,6 +96,13 @@ public class RecentsDebugFlags implements TunerService.Tunable {
return mShowHistory;
}
/**
* @return whether the initial stack state is paging.
*/
public boolean isInitialStatePaging() {
return mInitialStatePaging;
}
@Override
public void onTuningChanged(String key, String newValue) {
switch (key) {
@@ -113,6 +122,10 @@ public class RecentsDebugFlags implements TunerService.Tunable {
mShowHistory = (newValue != null) &&
(Integer.parseInt(newValue) != 0);
break;
case KEY_INITIAL_STATE_PAGING:
mInitialStatePaging = (newValue != null) &&
(Integer.parseInt(newValue) != 0);
break;
}
EventBus.getDefault().send(new DebugFlagsChangedEvent());
}

View File

@@ -498,7 +498,8 @@ public class TaskStackLayoutAlgorithm {
public float getDefaultFocusState() {
RecentsActivityLaunchState launchState = Recents.getConfiguration().getLaunchState();
RecentsDebugFlags debugFlags = Recents.getDebugFlags();
if (debugFlags.isPageOnToggleEnabled() || launchState.launchedWithAltTab) {
if (launchState.launchedWithAltTab ||
(debugFlags.isPageOnToggleEnabled() && debugFlags.isInitialStatePaging())) {
return 1f;
}
return 0f;

View File

@@ -18,29 +18,27 @@ package com.android.systemui.statusbar.phone;
import android.app.ActivityManager;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Rect;
import android.os.SystemProperties;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.VelocityTracker;
import android.view.ViewConfiguration;
import android.view.WindowManager;
import com.android.systemui.R;
import com.android.systemui.RecentsComponent;
import com.android.systemui.stackdivider.Divider;
import com.android.systemui.statusbar.BaseStatusBar;
import com.android.systemui.tuner.TunerService;
import static android.view.WindowManager.*;
/**
* Class to detect gestures on the navigation bar.
*/
public class NavigationBarGestureHelper extends GestureDetector.SimpleOnGestureListener {
public class NavigationBarGestureHelper extends GestureDetector.SimpleOnGestureListener
implements TunerService.Tunable {
private static final String DOCK_WINDOW_GESTURE_ENABLED_PROP = "persist.dock_gesture_enabled";
private static final String KEY_DOCK_WINDOW_GESTURE = "overview_nav_bar_gesture";
/**
* When dragging from the navigation bar, we drag in recents.
@@ -78,7 +76,7 @@ public class NavigationBarGestureHelper extends GestureDetector.SimpleOnGestureL
mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
mMinFlingVelocity = configuration.getScaledMinimumFlingVelocity();
mTaskSwitcherDetector = new GestureDetector(context, this);
mDockWindowEnabled = SystemProperties.getBoolean(DOCK_WINDOW_GESTURE_ENABLED_PROP, false);
TunerService.get(context).addTunable(this, KEY_DOCK_WINDOW_GESTURE);
}
public void setComponents(RecentsComponent recentsComponent, Divider divider) {
@@ -267,4 +265,14 @@ public class NavigationBarGestureHelper extends GestureDetector.SimpleOnGestureL
}
return true;
}
@Override
public void onTuningChanged(String key, String newValue) {
switch (key) {
case KEY_DOCK_WINDOW_GESTURE:
mDockWindowEnabled = (newValue != null) &&
(Integer.parseInt(newValue) != 0);
break;
}
}
}