[automerger] Show progress dialog when uninstalling an app in Launcher3Go. am: c56e3ff2ee

Change-Id: I9c9b9d8c3159d9c49e20f277bc17b0608571f134
This commit is contained in:
Jonathan Miranda 2017-08-23 19:14:04 +00:00
commit 4ec0d61ee8
3 changed files with 44 additions and 11 deletions

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
* Copyright (C) 2017 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-->
<resources>
<!-- String representing the intent to delete a package. -->
<string name="delete_package_intent" translatable="false">#Intent;action=android.intent.action.DELETE;launchFlags=0x10800000;B.android.intent.extra.RETURN_RESULT=true;end</string>
</resources>

View File

@ -19,6 +19,9 @@
q=<query> to the data to the intent -->
<string name="market_search_intent" translatable="false">market://search?c=apps</string>
<!-- String representing the intent to delete a package.-->
<string name="delete_package_intent" translatable="false">#Intent;action=android.intent.action.DELETE;launchFlags=0x10800000;end</string>
<!-- Values for icon shape overrides. These should correspond to entries defined
in icon_shape_override_paths_names -->
<string-array translatable="false" name="icon_shape_override_paths_values">

View File

@ -11,12 +11,17 @@ import android.os.Bundle;
import android.os.UserHandle;
import android.os.UserManager;
import android.util.AttributeSet;
import android.util.Log;
import android.widget.Toast;
import com.android.launcher3.compat.LauncherAppsCompat;
import java.net.URISyntaxException;
public class UninstallDropTarget extends ButtonDropTarget {
private static final String TAG = "UninstallDropTarget";
public UninstallDropTarget(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
@ -99,25 +104,28 @@ public class UninstallDropTarget extends ButtonDropTarget {
final Launcher launcher, ItemInfo info, DropTargetResultCallback callback) {
final ComponentName cn = getUninstallTarget(launcher, info);
final boolean isUninstallable;
boolean canUninstall;
if (cn == null) {
// System applications cannot be installed. For now, show a toast explaining that.
// We may give them the option of disabling apps this way.
Toast.makeText(launcher, R.string.uninstall_system_app_text, Toast.LENGTH_SHORT).show();
isUninstallable = false;
canUninstall = false;
} else {
Intent intent = new Intent(Intent.ACTION_DELETE,
Uri.fromParts("package", cn.getPackageName(), cn.getClassName()))
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
| Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
intent.putExtra(Intent.EXTRA_USER, info.user);
launcher.startActivity(intent);
isUninstallable = true;
try {
Intent i = Intent.parseUri(launcher.getString(R.string.delete_package_intent), 0)
.setData(Uri.fromParts("package", cn.getPackageName(), cn.getClassName()))
.putExtra(Intent.EXTRA_USER, info.user);
launcher.startActivity(i);
canUninstall = true;
} catch (URISyntaxException e) {
Log.e(TAG, "Failed to parse intent to start uninstall activity for item=" + info);
canUninstall = false;
}
}
if (callback != null) {
sendUninstallResult(launcher, isUninstallable, cn, info.user, callback);
sendUninstallResult(launcher, canUninstall, cn, info.user, callback);
}
return isUninstallable;
return canUninstall;
}
/**