summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2019-03-14 15:12:38 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2019-03-14 15:12:38 +0000
commit95335a500e2b29e56bd9d9a18de61e5dcf47acef (patch)
tree34020f49f6c64f25c38a9ae1963b4a4b15fbad4f /core/java
parent7ff810676f4680024a84601d95ab94b67510de07 (diff)
parentdf634cc0997c6fe1762e09414ce3aceec6a94d1b (diff)
Merge "Sharesheet - Remove pin/unpin actions"
Diffstat (limited to 'core/java')
-rw-r--r--core/java/com/android/internal/app/ChooserActivity.java53
-rw-r--r--core/java/com/android/internal/app/ResolverActivity.java30
-rw-r--r--core/java/com/android/internal/app/ResolverComparator.java32
-rw-r--r--core/java/com/android/internal/app/ResolverListController.java10
-rw-r--r--core/java/com/android/internal/app/ResolverTargetActionsDialogFragment.java27
5 files changed, 18 insertions, 134 deletions
diff --git a/core/java/com/android/internal/app/ChooserActivity.java b/core/java/com/android/internal/app/ChooserActivity.java
index 8d8ec4df4433..9c50f9b967d6 100644
--- a/core/java/com/android/internal/app/ChooserActivity.java
+++ b/core/java/com/android/internal/app/ChooserActivity.java
@@ -42,7 +42,6 @@ import android.content.IntentFilter;
import android.content.IntentSender;
import android.content.IntentSender.SendIntentException;
import android.content.ServiceConnection;
-import android.content.SharedPreferences;
import android.content.pm.ActivityInfo;
import android.content.pm.LabeledIntent;
import android.content.pm.LauncherApps;
@@ -65,7 +64,6 @@ import android.metrics.LogMaker;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
-import android.os.Environment;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
@@ -75,7 +73,6 @@ import android.os.RemoteException;
import android.os.ResultReceiver;
import android.os.UserHandle;
import android.os.UserManager;
-import android.os.storage.StorageManager;
import android.provider.DocumentsContract;
import android.provider.Downloads;
import android.provider.OpenableColumns;
@@ -114,7 +111,6 @@ import com.android.internal.util.ImageUtils;
import com.google.android.collect.Lists;
-import java.io.File;
import java.io.IOException;
import java.lang.annotation.Retention;
import java.util.ArrayList;
@@ -188,10 +184,7 @@ public class ChooserActivity extends ResolverActivity {
private Drawable mChooserRowLayer;
private int mChooserRowServiceSpacing;
- private SharedPreferences mPinnedSharedPrefs;
- private static final float PINNED_TARGET_SCORE_BOOST = 1000.f;
private static final float CALLER_TARGET_SCORE_BOOST = 900.f;
- private static final String PINNED_SHARED_PREFS_NAME = "chooser_pin_settings";
private static final String TARGET_DETAILS_FRAGMENT_TAG = "targetDetailsFragment";
private final List<ChooserTargetServiceConnection> mServiceConnections = new ArrayList<>();
@@ -385,7 +378,6 @@ public class ChooserActivity extends ResolverActivity {
mCallerChooserTargets = targets;
}
- mPinnedSharedPrefs = getPinnedSharedPrefs(this);
setRetainInOnStop(intent.getBooleanExtra(EXTRA_PRIVATE_RETAIN_IN_ON_STOP, false));
super.onCreate(savedInstanceState, target, title, defaultTitleRes, initialIntents,
null, false);
@@ -817,22 +809,6 @@ public class ChooserActivity extends ResolverActivity {
return CONTENT_PREVIEW_TEXT;
}
- static SharedPreferences getPinnedSharedPrefs(Context context) {
- // The code below is because in the android:ui process, no one can hear you scream.
- // The package info in the context isn't initialized in the way it is for normal apps,
- // so the standard, name-based context.getSharedPreferences doesn't work. Instead, we
- // build the path manually below using the same policy that appears in ContextImpl.
- // This fails silently under the hood if there's a problem, so if we find ourselves in
- // the case where we don't have access to credential encrypted storage we just won't
- // have our pinned target info.
- final File prefsFile = new File(new File(
- Environment.getDataUserCePackageDirectory(StorageManager.UUID_PRIVATE_INTERNAL,
- context.getUserId(), context.getPackageName()),
- "shared_prefs"),
- PINNED_SHARED_PREFS_NAME + ".xml");
- return context.getSharedPreferences(prefsFile, MODE_PRIVATE);
- }
-
@Override
protected void onDestroy() {
super.onDestroy();
@@ -928,10 +904,9 @@ public class ChooserActivity extends ResolverActivity {
}
ComponentName name = ri.activityInfo.getComponentName();
- boolean pinned = mPinnedSharedPrefs.getBoolean(name.flattenToString(), false);
ResolverTargetActionsDialogFragment f =
new ResolverTargetActionsDialogFragment(ri.loadLabel(getPackageManager()),
- name, pinned);
+ name);
f.show(getFragmentManager(), TARGET_DETAILS_FRAGMENT_TAG);
}
@@ -1385,11 +1360,6 @@ public class ChooserActivity extends ResolverActivity {
}
@Override
- boolean isComponentPinned(ComponentName name) {
- return mPinnedSharedPrefs.getBoolean(name.flattenToString(), false);
- }
-
- @Override
boolean isComponentFiltered(ComponentName name) {
if (mFilteredComponentNames == null) {
return false;
@@ -1407,11 +1377,8 @@ public class ChooserActivity extends ResolverActivity {
if (target == null) {
return CALLER_TARGET_SCORE_BOOST;
}
- float score = super.getScore(target);
- if (target.isPinned()) {
- score += PINNED_TARGET_SCORE_BOOST;
- }
- return score;
+
+ return super.getScore(target);
}
}
@@ -1508,10 +1475,6 @@ public class ChooserActivity extends ResolverActivity {
return null;
}
- public boolean isPinned() {
- return false;
- }
-
public float getModifiedScore() {
return 0.1f;
}
@@ -1742,11 +1705,6 @@ public class ChooserActivity extends ResolverActivity {
}
return results;
}
-
- @Override
- public boolean isPinned() {
- return mSourceInfo != null ? mSourceInfo.isPinned() : false;
- }
}
private void handleScroll(View view, int x, int y, int oldx, int oldy) {
@@ -1855,11 +1813,6 @@ public class ChooserActivity extends ResolverActivity {
}
@Override
- public boolean isComponentPinned(ComponentName name) {
- return mPinnedSharedPrefs.getBoolean(name.flattenToString(), false);
- }
-
- @Override
public View onCreateView(ViewGroup parent) {
return mInflater.inflate(
com.android.internal.R.layout.resolve_grid_item, parent, false);
diff --git a/core/java/com/android/internal/app/ResolverActivity.java b/core/java/com/android/internal/app/ResolverActivity.java
index c60a96b3d437..b55700e5985d 100644
--- a/core/java/com/android/internal/app/ResolverActivity.java
+++ b/core/java/com/android/internal/app/ResolverActivity.java
@@ -1177,7 +1177,6 @@ public class ResolverActivity extends Activity {
private final CharSequence mExtendedInfo;
private final Intent mResolvedIntent;
private final List<Intent> mSourceIntents = new ArrayList<>();
- private boolean mPinned;
public DisplayResolveInfo(Intent originalIntent, ResolveInfo pri, CharSequence pLabel,
CharSequence pInfo, Intent pOrigIntent) {
@@ -1204,7 +1203,6 @@ public class ResolverActivity extends Activity {
mExtendedInfo = other.mExtendedInfo;
mResolvedIntent = new Intent(other.mResolvedIntent);
mResolvedIntent.fillIn(fillInIntent, flags);
- mPinned = other.mPinned;
}
public ResolveInfo getResolveInfo() {
@@ -1304,15 +1302,6 @@ public class ResolverActivity extends Activity {
activity.startActivityAsUser(mResolvedIntent, options, user);
return false;
}
-
- @Override
- public boolean isPinned() {
- return mPinned;
- }
-
- public void setPinned(boolean pinned) {
- mPinned = pinned;
- }
}
/**
@@ -1414,11 +1403,6 @@ public class ResolverActivity extends Activity {
* @return the list of supported source intents deduped against this single target
*/
List<Intent> getAllSourceIntents();
-
- /**
- * @return true if this target should be pinned to the front by the request of the user
- */
- boolean isPinned();
}
public class ResolveListAdapter extends BaseAdapter {
@@ -1776,7 +1760,6 @@ public class ResolverActivity extends Activity {
final Intent replaceIntent = getReplacementIntent(add.activityInfo, intent);
final DisplayResolveInfo dri = new DisplayResolveInfo(intent, add, roLabel,
extraInfo, replaceIntent);
- dri.setPinned(rci.isPinned());
addResolveInfo(dri);
if (replaceIntent == intent) {
// Only add alternates if we didn't get a specific replacement from
@@ -1921,10 +1904,6 @@ public class ResolverActivity extends Activity {
return !TextUtils.isEmpty(info.getExtendedInfo());
}
- public boolean isComponentPinned(ComponentName name) {
- return false;
- }
-
public final void bindView(int position, View view) {
onBindView(view, getItem(position));
}
@@ -1967,7 +1946,6 @@ public class ResolverActivity extends Activity {
@VisibleForTesting
public static final class ResolvedComponentInfo {
public final ComponentName name;
- private boolean mPinned;
private final List<Intent> mIntents = new ArrayList<>();
private final List<ResolveInfo> mResolveInfos = new ArrayList<>();
@@ -2010,14 +1988,6 @@ public class ResolverActivity extends Activity {
}
return -1;
}
-
- public boolean isPinned() {
- return mPinned;
- }
-
- public void setPinned(boolean pinned) {
- mPinned = pinned;
- }
}
static class ViewHolder {
diff --git a/core/java/com/android/internal/app/ResolverComparator.java b/core/java/com/android/internal/app/ResolverComparator.java
index f61a03bccb78..b9f67e6e0521 100644
--- a/core/java/com/android/internal/app/ResolverComparator.java
+++ b/core/java/com/android/internal/app/ResolverComparator.java
@@ -325,30 +325,18 @@ class ResolverComparator implements Comparator<ResolvedComponentInfo> {
}
}
- final boolean lPinned = lhsp.isPinned();
- final boolean rPinned = rhsp.isPinned();
-
- if (lPinned && !rPinned) {
- return -1;
- } else if (!lPinned && rPinned) {
- return 1;
- }
-
- // Pinned items stay stable within a normal lexical sort and ignore scoring.
- if (!lPinned && !rPinned) {
- if (mStats != null) {
- final ResolverTarget lhsTarget = mTargetsDict.get(new ComponentName(
- lhs.activityInfo.packageName, lhs.activityInfo.name));
- final ResolverTarget rhsTarget = mTargetsDict.get(new ComponentName(
- rhs.activityInfo.packageName, rhs.activityInfo.name));
-
- if (lhsTarget != null && rhsTarget != null) {
- final int selectProbabilityDiff = Float.compare(
+ if (mStats != null) {
+ final ResolverTarget lhsTarget = mTargetsDict.get(new ComponentName(
+ lhs.activityInfo.packageName, lhs.activityInfo.name));
+ final ResolverTarget rhsTarget = mTargetsDict.get(new ComponentName(
+ rhs.activityInfo.packageName, rhs.activityInfo.name));
+
+ if (lhsTarget != null && rhsTarget != null) {
+ final int selectProbabilityDiff = Float.compare(
rhsTarget.getSelectProbability(), lhsTarget.getSelectProbability());
- if (selectProbabilityDiff != 0) {
- return selectProbabilityDiff > 0 ? 1 : -1;
- }
+ if (selectProbabilityDiff != 0) {
+ return selectProbabilityDiff > 0 ? 1 : -1;
}
}
}
diff --git a/core/java/com/android/internal/app/ResolverListController.java b/core/java/com/android/internal/app/ResolverListController.java
index 61aeca679303..f48102a9fcd4 100644
--- a/core/java/com/android/internal/app/ResolverListController.java
+++ b/core/java/com/android/internal/app/ResolverListController.java
@@ -30,14 +30,13 @@ import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.RemoteException;
import android.util.Log;
-import com.android.internal.annotations.GuardedBy;
+
import com.android.internal.annotations.VisibleForTesting;
-import java.lang.InterruptedException;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.concurrent.CountDownLatch;
import java.util.List;
+import java.util.concurrent.CountDownLatch;
/**
* A helper for the ResolverActivity that exposes methods to retrieve, filter and sort its list of
@@ -147,7 +146,6 @@ public class ResolverListController {
newInfo.activityInfo.packageName, newInfo.activityInfo.name);
final ResolverActivity.ResolvedComponentInfo rci =
new ResolverActivity.ResolvedComponentInfo(name, intent, newInfo);
- rci.setPinned(isComponentPinned(name));
into.add(rci);
}
}
@@ -270,10 +268,6 @@ public class ResolverListController {
&& ai.name.equals(b.name.getClassName());
}
- boolean isComponentPinned(ComponentName name) {
- return false;
- }
-
boolean isComponentFiltered(ComponentName componentName) {
return false;
}
diff --git a/core/java/com/android/internal/app/ResolverTargetActionsDialogFragment.java b/core/java/com/android/internal/app/ResolverTargetActionsDialogFragment.java
index 8156f79f3be3..a49240cd0019 100644
--- a/core/java/com/android/internal/app/ResolverTargetActionsDialogFragment.java
+++ b/core/java/com/android/internal/app/ResolverTargetActionsDialogFragment.java
@@ -23,7 +23,6 @@ import android.app.DialogFragment;
import android.content.ComponentName;
import android.content.DialogInterface;
import android.content.Intent;
-import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Bundle;
import android.provider.Settings;
@@ -36,34 +35,27 @@ import com.android.internal.R;
public class ResolverTargetActionsDialogFragment extends DialogFragment
implements DialogInterface.OnClickListener {
private static final String NAME_KEY = "componentName";
- private static final String PINNED_KEY = "pinned";
private static final String TITLE_KEY = "title";
// Sync with R.array.resolver_target_actions_* resources
- private static final int TOGGLE_PIN_INDEX = 0;
- private static final int APP_INFO_INDEX = 1;
+ private static final int APP_INFO_INDEX = 0;
public ResolverTargetActionsDialogFragment() {
}
- public ResolverTargetActionsDialogFragment(CharSequence title, ComponentName name,
- boolean pinned) {
+ public ResolverTargetActionsDialogFragment(CharSequence title, ComponentName name) {
Bundle args = new Bundle();
args.putCharSequence(TITLE_KEY, title);
args.putParcelable(NAME_KEY, name);
- args.putBoolean(PINNED_KEY, pinned);
setArguments(args);
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final Bundle args = getArguments();
- final int itemRes = args.getBoolean(PINNED_KEY, false)
- ? R.array.resolver_target_actions_unpin
- : R.array.resolver_target_actions_pin;
return new Builder(getContext())
.setCancelable(true)
- .setItems(itemRes, this)
+ .setItems(R.array.resolver_target_actions, this)
.setTitle(args.getCharSequence(TITLE_KEY))
.create();
}
@@ -73,19 +65,6 @@ public class ResolverTargetActionsDialogFragment extends DialogFragment
final Bundle args = getArguments();
ComponentName name = args.getParcelable(NAME_KEY);
switch (which) {
- case TOGGLE_PIN_INDEX:
- SharedPreferences sp = ChooserActivity.getPinnedSharedPrefs(getContext());
- final String key = name.flattenToString();
- boolean currentVal = sp.getBoolean(name.flattenToString(), false);
- if (currentVal) {
- sp.edit().remove(key).apply();
- } else {
- sp.edit().putBoolean(key, true).apply();
- }
-
- // Force the chooser to requery and resort things
- getActivity().recreate();
- break;
case APP_INFO_INDEX:
Intent in = new Intent().setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
.setData(Uri.fromParts("package", name.getPackageName(), null))