Showing a toast when changing wallaper is disabled

Bug: 27940102
Change-Id: I373093d9b85dca356aaa8798931d5315981fd74c
(cherry picked from commit 2afb636180)
This commit is contained in:
Sunny Goyal
2016-04-21 15:16:11 -07:00
parent cc8f9e0af7
commit 1ed6c4adde
3 changed files with 20 additions and 0 deletions
+2
View File
@@ -164,6 +164,8 @@
<string name="wallpaper_button_text">Wallpapers</string>
<!-- Text for settings button -->
<string name="settings_button_text">Settings</string>
<!-- Message shown when a feature is disabled by the administrator -->
<string name="msg_disabled_by_admin">Disabled by your admin</string>
<!-- Strings for settings -->
<!-- Title for Allow Rotation setting. [CHAR LIMIT=50] -->
+5
View File
@@ -2735,6 +2735,11 @@ public class Launcher extends Activity
* on the home screen.
*/
protected void onClickWallpaperPicker(View v) {
if (!Utilities.isWallapaperAllowed(this)) {
Toast.makeText(this, R.string.msg_disabled_by_admin, Toast.LENGTH_SHORT).show();
return;
}
if (LOGD) Log.d(TAG, "onClickWallpaperPicker");
int pageScroll = mWorkspace.getScrollForPage(mWorkspace.getPageNearestToCenterOfScreen());
float offset = mWorkspace.mWallpaperOffset.wallpaperOffsetForScroll(pageScroll);
+13
View File
@@ -19,6 +19,7 @@ package com.android.launcher3;
import android.annotation.TargetApi;
import android.app.Activity;
import android.app.SearchManager;
import android.app.WallpaperManager;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProviderInfo;
import android.content.ActivityNotFoundException;
@@ -45,6 +46,7 @@ import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.PaintDrawable;
import android.os.Build;
import android.os.Build.VERSION_CODES;
import android.os.Bundle;
import android.os.PowerManager;
import android.text.Spannable;
@@ -828,6 +830,17 @@ public final class Utilities {
return ATLEAST_LOLLIPOP && powerManager.isPowerSaveMode();
}
public static boolean isWallapaperAllowed(Context context) {
if (isNycOrAbove()) {
try {
WallpaperManager wm = context.getSystemService(WallpaperManager.class);
return (Boolean) wm.getClass().getDeclaredMethod("isWallpaperSettingAllowed")
.invoke(wm);
} catch (Exception e) { }
}
return true;
}
/**
* An extension of {@link BitmapDrawable} which returns the bitmap pixel size as intrinsic size.
* This allows the badging to be done based on the action bitmap size rather than