am 0a730c24: Merge "Exposing the API to support widgets in Recents."

* commit '0a730c24b0af03bea4afa5b6da5ae576b0ef2f99':
  Exposing the API to support widgets in Recents.
This commit is contained in:
Winson Chung
2014-05-06 00:03:21 +00:00
committed by Android Git Automerger
8 changed files with 28 additions and 27 deletions

View File

@@ -5312,6 +5312,7 @@ package android.appwidget {
field public static final int RESIZE_VERTICAL = 2; // 0x2
field public static final int WIDGET_CATEGORY_HOME_SCREEN = 1; // 0x1
field public static final int WIDGET_CATEGORY_KEYGUARD = 2; // 0x2
field public static final int WIDGET_CATEGORY_RECENTS = 4; // 0x4
field public int autoAdvanceViewId;
field public android.content.ComponentName configure;
field public int icon;

View File

@@ -181,7 +181,8 @@ public class AppWidgetManager {
* A bundle extra that hints to the AppWidgetProvider the category of host that owns this
* this widget. Can have the value {@link
* AppWidgetProviderInfo#WIDGET_CATEGORY_HOME_SCREEN} or {@link
* AppWidgetProviderInfo#WIDGET_CATEGORY_KEYGUARD}.
* AppWidgetProviderInfo#WIDGET_CATEGORY_KEYGUARD} or {@link
* AppWidgetProviderInfo#WIDGET_CATEGORY_RECENTS}.
*/
public static final String OPTION_APPWIDGET_HOST_CATEGORY = "appWidgetCategory";

View File

@@ -55,7 +55,6 @@ public class AppWidgetProviderInfo implements Parcelable {
/**
* Indicates that the widget can be displayed within recents.
* @hide
*/
public static final int WIDGET_CATEGORY_RECENTS = 4;

View File

@@ -5956,11 +5956,12 @@
<flag name="vertical" value="0x2" />
</attr>
<!-- Optional parameter which indicates where this widget can be shown,
ie. home screen, keyguard or both.
resized. Supports combined values using | operator. -->
ie. home screen, keyguard, recents or any combination thereof.
Supports combined values using | operator. -->
<attr name="widgetCategory" format="integer">
<flag name="home_screen" value="0x1" />
<flag name="keyguard" value="0x2" />
<flag name="recents" value="0x4" />
</attr>
</declare-styleable>

View File

@@ -32,5 +32,8 @@
<!-- Min alpha % that recent items will fade to while being dismissed -->
<integer name="config_recent_item_min_alpha">0</integer>
<!-- Transposes the search bar layout in landscape -->
<bool name="recents_transpose_search_layout_with_orientation">false</bool>
</resources>

View File

@@ -123,6 +123,8 @@
<integer name="recents_animate_task_view_info_pane_duration">150</integer>
<!-- The minimum alpha for the dim applied to cards that go deeper into the stack. -->
<integer name="recents_max_task_stack_view_dim">96</integer>
<!-- Transposes the search bar layout in landscape -->
<bool name="recents_transpose_search_layout_with_orientation">true</bool>
<!-- Whether to enable KeyguardService or not -->
<bool name="config_enableKeyguardService">true</bool>

View File

@@ -37,6 +37,7 @@ public class RecentsConfiguration {
public Rect displayRect = new Rect();
boolean isLandscape;
boolean transposeSearchLayoutWithOrientation;
int searchBarAppWidgetId = -1;
public float animationPxMovementPerSecond;
@@ -83,6 +84,8 @@ public class RecentsConfiguration {
isLandscape = res.getConfiguration().orientation ==
Configuration.ORIENTATION_LANDSCAPE;
transposeSearchLayoutWithOrientation =
res.getBoolean(R.bool.recents_transpose_search_layout_with_orientation);
Console.log(Constants.DebugFlags.UI.MeasureAndLayout,
"[RecentsConfiguration|orientation]", isLandscape ? "Landscape" : "Portrait",
Console.AnsiGreen);
@@ -148,7 +151,7 @@ public class RecentsConfiguration {
if (hasSearchBarAppWidget()) {
Rect searchBarBounds = new Rect();
getSearchBarBounds(width, height, searchBarBounds);
if (isLandscape) {
if (isLandscape && transposeSearchLayoutWithOrientation) {
// In landscape, the search bar appears on the left, so shift the task rect right
taskStackBounds.set(searchBarBounds.width(), 0, width, height);
} else {
@@ -171,7 +174,7 @@ public class RecentsConfiguration {
return;
}
if (isLandscape) {
if (isLandscape && transposeSearchLayoutWithOrientation) {
// In landscape, the search bar appears on the left
searchBarSpaceBounds.set(0, 0, searchBarSpaceHeightPx, height);
} else {

View File

@@ -55,6 +55,7 @@ public class SystemServicesProxy {
UserManager mUm;
SearchManager mSm;
String mPackage;
ComponentName mAssistComponent;
Bitmap mDummyIcon;
@@ -68,6 +69,12 @@ public class SystemServicesProxy {
mSm = (SearchManager) context.getSystemService(Context.SEARCH_SERVICE);
mPackage = context.getPackageName();
// Resolve the assist intent
Intent assist = mSm.getAssistIntent(context, false);
if (assist != null) {
mAssistComponent = assist.getComponent();
}
if (Constants.DebugFlags.App.EnableSystemServicesProxy) {
// Create a dummy icon
mDummyIcon = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888);
@@ -236,30 +243,14 @@ public class SystemServicesProxy {
*/
public Pair<Integer, AppWidgetProviderInfo> bindSearchAppWidget(AppWidgetHost host) {
if (mAwm == null) return null;
if (mAssistComponent == null) return null;
// Ensure we have a global search activity
ComponentName globalSearchActivity = mSm.getGlobalSearchActivity();
if (globalSearchActivity == null) return null;
// Resolve the search widget provider from the search activity
ActivityInfo searchActivityInfo = getActivityInfo(globalSearchActivity);
if (searchActivityInfo == null) return null;
String key = "com.android.recents.search_widget_provider";
ComponentName searchWidgetCn = null;
Bundle searchMetaData = searchActivityInfo.metaData;
String searchWidgetProvider = searchMetaData.getString(key, "");
if (searchWidgetProvider.length() != 0) {
searchWidgetCn = ComponentName.unflattenFromString(searchWidgetProvider);
} else {
return null;
}
// Find the first Recents widget from the same package as the global search activity
List<AppWidgetProviderInfo> widgets = mAwm.getInstalledProviders();
// Find the first Recents widget from the same package as the global assist activity
List<AppWidgetProviderInfo> widgets = mAwm.getInstalledProviders(
AppWidgetProviderInfo.WIDGET_CATEGORY_RECENTS);
AppWidgetProviderInfo searchWidgetInfo = null;
for (AppWidgetProviderInfo info : widgets) {
if (info.provider.equals(searchWidgetCn)) {
if (info.provider.getPackageName().equals(mAssistComponent.getPackageName())) {
searchWidgetInfo = info;
break;
}