Removing static access to Context through LauncherAppState

Bug: 33032833
Change-Id: I09baaa6d79187b3096a2ab3a89d7dcaeaf9eee68
This commit is contained in:
Sunny Goyal
2016-12-29 13:31:43 -08:00
parent c6b833dcbb
commit 8ad02b8f3f
8 changed files with 42 additions and 36 deletions

View File

@@ -18,7 +18,6 @@ package com.android.launcher3;
import android.content.ActivityNotFoundException;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Context;
import android.provider.Settings;
import android.util.AttributeSet;
@@ -90,13 +89,12 @@ public class InfoDropTarget extends UninstallDropTarget {
@Override
protected boolean supportsDrop(DragSource source, ItemInfo info) {
return source.supportsAppInfoDropTarget() && supportsDrop(info);
return source.supportsAppInfoDropTarget() && supportsDrop(getContext(), info);
}
public static boolean supportsDrop(ItemInfo info) {
public static boolean supportsDrop(Context context, ItemInfo info) {
// Only show the App Info drop target if developer settings are enabled.
ContentResolver resolver = LauncherAppState.getInstance().getContext().getContentResolver();
boolean developmentSettingsEnabled = Settings.Global.getInt(resolver,
boolean developmentSettingsEnabled = Settings.Global.getInt(context.getContentResolver(),
Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0) == 1;
return developmentSettingsEnabled
&& (info instanceof AppInfo || info instanceof ShortcutInfo