Merge "Import translations. DO NOT MERGE" into ub-now-queens
diff --git a/res/layout/overview_panel.xml b/res/layout/overview_panel.xml
index 558900c..4b7423e 100644
--- a/res/layout/overview_panel.xml
+++ b/res/layout/overview_panel.xml
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2013 The Android Open Source Project
+<!--
+ Copyright (C) 2013 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.
@@ -13,47 +14,50 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<FrameLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="wrap_content"
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|bottom"
- android:orientation="horizontal">
+ android:gravity="top"
+ android:orientation="horizontal" >
<TextView
android:id="@+id/wallpaper_button"
- android:layout_width="wrap_content"
+ android:layout_width="0dp"
android:layout_height="wrap_content"
- android:layout_gravity="start|top"
- android:text="@string/wallpaper_button_text"
+ android:layout_weight="1"
android:drawablePadding="4dp"
android:drawableTop="@drawable/wallpaper_button"
- android:gravity="center_horizontal"
android:fontFamily="sans-serif-condensed"
+ android:gravity="center_horizontal"
+ android:text="@string/wallpaper_button_text"
android:textAllCaps="true"
android:textSize="12sp" />
+
<TextView
android:id="@+id/widget_button"
- android:layout_width="wrap_content"
+ android:layout_width="0dp"
android:layout_height="wrap_content"
- android:layout_gravity="center_horizontal|top"
- android:text="@string/widget_button_text"
+ android:layout_weight="1"
android:drawablePadding="4dp"
- android:gravity="center_horizontal"
android:drawableTop="@drawable/widget_button"
android:fontFamily="sans-serif-condensed"
- android:textAllCaps="true"
- android:textSize="12sp"/>
- <TextView
- android:id="@+id/settings_button"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="end|top"
- android:text="@string/settings_button_text"
- android:drawablePadding="4dp"
android:gravity="center_horizontal"
- android:drawableTop="@drawable/setting_button"
- android:fontFamily="sans-serif-condensed"
+ android:text="@string/widget_button_text"
android:textAllCaps="true"
android:textSize="12sp" />
-</FrameLayout>
+
+ <TextView
+ android:id="@+id/settings_button"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:drawablePadding="4dp"
+ android:drawableTop="@drawable/setting_button"
+ android:fontFamily="sans-serif-condensed"
+ android:gravity="center_horizontal"
+ android:text="@string/settings_button_text"
+ android:textAllCaps="true"
+ android:textSize="12sp" />
+
+</LinearLayout>
\ No newline at end of file
diff --git a/res/values/strings.xml b/res/values/strings.xml
index efc5d5b..a6397e3 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -44,6 +44,8 @@
<string name="activity_not_available">App isn\'t available</string>
<!-- SafeMode shortcut error string -->
<string name="safemode_shortcut_error">Downloaded app disabled in Safe mode</string>
+ <!-- SafeMode widget error string -->
+ <string name="safemode_widget_error">Widgets disabled in Safe mode</string>
<!-- Labels for the tabs in the customize drawer -->
<string name="widgets_tab_label">Widgets</string>
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index d5cb55b..be84540 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -1369,9 +1369,6 @@
settingsButton.setOnTouchListener(getHapticFeedbackTouchListener());
} else {
settingsButton.setVisibility(View.GONE);
- FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) widgetButton.getLayoutParams();
- lp.gravity = Gravity.END | Gravity.TOP;
- widgetButton.requestLayout();
}
mOverviewPanel.setAlpha(0f);
@@ -2538,6 +2535,11 @@
* Event handler for the app widget view which has not fully restored.
*/
public void onClickPendingWidget(final PendingAppWidgetHostView v) {
+ if (mIsSafeModeEnabled) {
+ Toast.makeText(this, R.string.safemode_widget_error, Toast.LENGTH_SHORT).show();
+ return;
+ }
+
final LauncherAppWidgetInfo info = (LauncherAppWidgetInfo) v.getTag();
if (v.isReadyForClickSetup()) {
int widgetId = info.appWidgetId;
@@ -2790,10 +2792,13 @@
*/
protected void onClickAddWidgetButton(View view) {
if (LOGD) Log.d(TAG, "onClickAddWidgetButton");
- showAllApps(true, AppsCustomizePagedView.ContentType.Widgets, true);
-
- if (mLauncherCallbacks != null) {
- mLauncherCallbacks.onClickAddWidgetButton(view);
+ if (mIsSafeModeEnabled) {
+ Toast.makeText(this, R.string.safemode_widget_error, Toast.LENGTH_SHORT).show();
+ } else {
+ showAllApps(true, AppsCustomizePagedView.ContentType.Widgets, true);
+ if (mLauncherCallbacks != null) {
+ mLauncherCallbacks.onClickAddWidgetButton(view);
+ }
}
}
@@ -4591,8 +4596,9 @@
final Workspace workspace = mWorkspace;
AppWidgetProviderInfo appWidgetInfo;
- if (((item.restoreStatus & LauncherAppWidgetInfo.FLAG_PROVIDER_NOT_READY) == 0) &&
- ((item.restoreStatus & LauncherAppWidgetInfo.FLAG_ID_NOT_VALID) != 0)) {
+ if (!mIsSafeModeEnabled
+ && ((item.restoreStatus & LauncherAppWidgetInfo.FLAG_PROVIDER_NOT_READY) == 0)
+ && ((item.restoreStatus & LauncherAppWidgetInfo.FLAG_ID_NOT_VALID) != 0)) {
appWidgetInfo = mModel.findAppWidgetProviderInfoWithComponent(this, item.providerName);
if (appWidgetInfo == null) {
@@ -4642,7 +4648,7 @@
LauncherModel.updateItemInDatabase(this, item);
}
- if (item.restoreStatus == LauncherAppWidgetInfo.RESTORE_COMPLETED) {
+ if (!mIsSafeModeEnabled && item.restoreStatus == LauncherAppWidgetInfo.RESTORE_COMPLETED) {
final int appWidgetId = item.appWidgetId;
appWidgetInfo = mAppWidgetManager.getAppWidgetInfo(appWidgetId);
if (DEBUG_WIDGETS) {
@@ -4652,7 +4658,8 @@
item.hostView = mAppWidgetHost.createView(this, appWidgetId, appWidgetInfo);
} else {
appWidgetInfo = null;
- PendingAppWidgetHostView view = new PendingAppWidgetHostView(this, item);
+ PendingAppWidgetHostView view = new PendingAppWidgetHostView(this, item,
+ mIsSafeModeEnabled);
view.updateIcon(mIconCache);
item.hostView = view;
item.hostView.updateAppWidget(null);
diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java
index f747423..f0899a8 100644
--- a/src/com/android/launcher3/LauncherModel.java
+++ b/src/com/android/launcher3/LauncherModel.java
@@ -2278,7 +2278,7 @@
// App restore has started. Update the flag
appWidgetInfo.restoreStatus |=
LauncherAppWidgetInfo.FLAG_RESTORE_STARTED;
- } else if (REMOVE_UNRESTORED_ICONS) {
+ } else if (REMOVE_UNRESTORED_ICONS && !isSafeMode) {
Launcher.addDumpLog(TAG,
"Unrestored widget removed: " + component, true);
itemsToRemove.add(id);
diff --git a/src/com/android/launcher3/PendingAppWidgetHostView.java b/src/com/android/launcher3/PendingAppWidgetHostView.java
index d23a330..179c60a 100644
--- a/src/com/android/launcher3/PendingAppWidgetHostView.java
+++ b/src/com/android/launcher3/PendingAppWidgetHostView.java
@@ -41,9 +41,9 @@
private final LauncherAppWidgetInfo mInfo;
private final int mStartState;
private final Intent mIconLookupIntent;
+ private final boolean mDisabledForSafeMode;
private Bitmap mIcon;
- private PreloadIconDrawable mDrawable;
private Drawable mCenterDrawable;
private Drawable mTopCornerDrawable;
@@ -53,11 +53,13 @@
private final TextPaint mPaint;
private Layout mSetupTextLayout;
- public PendingAppWidgetHostView(Context context, LauncherAppWidgetInfo info) {
+ public PendingAppWidgetHostView(Context context, LauncherAppWidgetInfo info,
+ boolean disabledForSafeMode) {
super(context);
mInfo = info;
mStartState = info.restoreStatus;
mIconLookupIntent = new Intent().setComponent(info.providerName);
+ mDisabledForSafeMode = disabledForSafeMode;
mPaint = new TextPaint();
mPaint.setColor(0xFFFFFFFF);
@@ -106,14 +108,21 @@
return;
}
mIcon = icon;
- if (mDrawable != null) {
- mDrawable.setCallback(null);
- mDrawable = null;
+ if (mCenterDrawable != null) {
+ mCenterDrawable.setCallback(null);
+ mCenterDrawable = null;
}
if (mIcon != null) {
- // The view displays two modes, one with a setup icon and another with a preload icon
- // in the center.
- if (isReadyForClickSetup()) {
+ // The view displays three modes,
+ // 1) App icon in the center
+ // 2) Preload icon in the center
+ // 3) Setup icon in the center and app icon in the top right corner.
+ if (mDisabledForSafeMode) {
+ FastBitmapDrawable disabledIcon = Utilities.createIconDrawable(mIcon);
+ disabledIcon.setGhostModeEnabled(true);
+ mCenterDrawable = disabledIcon;
+ mTopCornerDrawable = null;
+ } else if (isReadyForClickSetup()) {
mCenterDrawable = getResources().getDrawable(R.drawable.ic_setting);
mTopCornerDrawable = new FastBitmapDrawable(mIcon);
} else {
@@ -123,8 +132,9 @@
}
FastBitmapDrawable drawable = Utilities.createIconDrawable(mIcon);
- mDrawable = new PreloadIconDrawable(drawable, sPreloaderTheme);
- mDrawable.setCallback(this);
+ mCenterDrawable = new PreloadIconDrawable(drawable, sPreloaderTheme);
+ mCenterDrawable.setCallback(this);
+ mTopCornerDrawable = null;
applyState();
}
mDrawableSizeChanged = true;
@@ -133,12 +143,12 @@
@Override
protected boolean verifyDrawable(Drawable who) {
- return (who == mDrawable) || super.verifyDrawable(who);
+ return (who == mCenterDrawable) || super.verifyDrawable(who);
}
public void applyState() {
- if (mDrawable != null) {
- mDrawable.setLevel(Math.max(mInfo.installProgress, 0));
+ if (mCenterDrawable != null) {
+ mCenterDrawable.setLevel(Math.max(mInfo.installProgress, 0));
}
}
@@ -158,23 +168,30 @@
@Override
protected void onDraw(Canvas canvas) {
- if (mDrawable != null) {
+ if (mCenterDrawable == null) {
+ // Nothing to draw
+ return;
+ }
+
+ if (mTopCornerDrawable == null) {
if (mDrawableSizeChanged) {
+ int outset = (mCenterDrawable instanceof PreloadIconDrawable) ?
+ ((PreloadIconDrawable) mCenterDrawable).getOutset() : 0;
int maxSize = LauncherAppState.getInstance().getDynamicGrid()
- .getDeviceProfile().iconSizePx + 2 * mDrawable.getOutset();
+ .getDeviceProfile().iconSizePx + 2 * outset;
int size = Math.min(maxSize, Math.min(
getWidth() - getPaddingLeft() - getPaddingRight(),
getHeight() - getPaddingTop() - getPaddingBottom()));
mRect.set(0, 0, size, size);
- mRect.inset(mDrawable.getOutset(), mDrawable.getOutset());
+ mRect.inset(outset, outset);
mRect.offsetTo((getWidth() - mRect.width()) / 2, (getHeight() - mRect.height()) / 2);
- mDrawable.setBounds(mRect);
+ mCenterDrawable.setBounds(mRect);
mDrawableSizeChanged = false;
}
-
- mDrawable.draw(canvas);
- } else if ((mCenterDrawable != null) && (mTopCornerDrawable != null)) {
+ mCenterDrawable.draw(canvas);
+ } else {
+ // Draw the top corner icon and "Setup" text is possible
if (mDrawableSizeChanged) {
DeviceProfile grid = getDeviceProfile();
int iconSize = grid.iconSizePx;