Skip to content

Commit

Permalink
Long press to APK name copy to clipboard
Browse files Browse the repository at this point in the history
  • Loading branch information
javiersantos committed Jul 23, 2015
1 parent 77f8837 commit b51ff8e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.javiersantos.mlmanager.activities;

import android.app.Activity;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
Expand Down Expand Up @@ -49,6 +51,7 @@ public class AppActivity extends AppCompatActivity {
// Configuration variables
private int UNINSTALL_REQUEST_CODE = 1;
private Context context;
private Activity activity;
private MenuItem item_favorite;

// UI variables
Expand All @@ -59,6 +62,7 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_app);
this.context = this;
this.activity = (Activity) context;
this.appPreferences = MLManagerApplication.getAppPreferences();

getInitialConfiguration();
Expand Down Expand Up @@ -128,9 +132,6 @@ private void setScreenElements() {
if (appInfo.isSystem()) {
icon_googleplay.setVisibility(View.GONE);
start.setVisibility(View.GONE);

googleplay.setForeground(null);
start.setForeground(null);
} else {
googleplay.setOnClickListener(new View.OnClickListener() {
@Override
Expand All @@ -139,6 +140,20 @@ public void onClick(View view) {
}
});

googleplay.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View view) {
ClipData clipData;

ClipboardManager clipboardManager = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
clipData = ClipData.newPlainText("text", appInfo.getAPK());
clipboardManager.setPrimaryClip(clipData);
UtilsDialog.showSnackbar(activity, context.getResources().getString(R.string.copied_clipboard), null, null, 2).show();

return false;
}
});

start.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Expand All @@ -147,7 +162,7 @@ public void onClick(View view) {
startActivity(intent);
} catch (NullPointerException e) {
e.printStackTrace();
UtilsDialog.showSnackbar((Activity) context, String.format(getResources().getString(R.string.dialog_cannot_open), appInfo.getName()), null, null, 2).show();
UtilsDialog.showSnackbar(activity, String.format(getResources().getString(R.string.dialog_cannot_open), appInfo.getName()), null, null, 2).show();
}
}
});
Expand Down Expand Up @@ -244,7 +259,7 @@ public void onClick(View view) {
UtilsApp.removeIconFromCache(context, appInfo);
appsHidden.remove(appInfo.toString());
appPreferences.setHiddenApps(appsHidden);
UtilsDialog.showSnackbar((Activity) context, getResources().getString(R.string.dialog_reboot), getResources().getString(R.string.button_reboot), null, 3).show();
UtilsDialog.showSnackbar(activity, getResources().getString(R.string.dialog_reboot), getResources().getString(R.string.button_reboot), null, 3).show();
}
} else {
UtilsApp.saveIconToCache(context, appInfo);
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<string name="search">Search</string>
<string name="search_hint">Search by name&#8230;</string>
<string name="search_noresults">No results were found for your search</string>
<string name="copied_clipboard">Copied to clipboard</string>

<!-- Dialogs -->
<string name="dialog_saved">\"%s\" APK saved</string>
Expand Down

0 comments on commit b51ff8e

Please sign in to comment.