Added app shortcuts (#278)
* Added app shortcuts Signed-off-by: Hussein Mohammed <zidhussein@gmail.com> * Added sdk25 to travis
This commit is contained in:
parent
46be418c38
commit
d888e5e2f2
4 changed files with 26 additions and 5 deletions
|
@ -6,8 +6,10 @@ android:
|
||||||
- tools
|
- tools
|
||||||
- build-tools-23.0.3
|
- build-tools-23.0.3
|
||||||
- build-tools-24.0.2
|
- build-tools-24.0.2
|
||||||
|
- build-tools-25.0.2
|
||||||
- android-23
|
- android-23
|
||||||
- android-24
|
- android-24
|
||||||
|
- android-25
|
||||||
- extra-google-m2repository
|
- extra-google-m2repository
|
||||||
- extra-android-m2repository
|
- extra-android-m2repository
|
||||||
|
|
||||||
|
|
|
@ -3,12 +3,12 @@ apply from: 'copyLibs.gradle' // enable 'copyLibs.gradle' script plugin
|
||||||
apply plugin: 'eclipse'
|
apply plugin: 'eclipse'
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 24
|
compileSdkVersion 25
|
||||||
buildToolsVersion '24.0.2'
|
buildToolsVersion '25.0.2'
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "com.zeapo.pwdstore"
|
applicationId "com.zeapo.pwdstore"
|
||||||
minSdkVersion 15
|
minSdkVersion 15
|
||||||
targetSdkVersion 24
|
targetSdkVersion 25
|
||||||
versionCode 77
|
versionCode 77
|
||||||
versionName "1.2.0.57"
|
versionName "1.2.0.57"
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,11 @@ import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
|
import android.content.pm.ShortcutInfo;
|
||||||
|
import android.content.pm.ShortcutManager;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
|
import android.graphics.drawable.Icon;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.support.design.widget.Snackbar;
|
import android.support.design.widget.Snackbar;
|
||||||
|
@ -40,6 +44,7 @@ import org.eclipse.jgit.lib.Repository;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -51,6 +56,7 @@ public class PasswordStore extends AppCompatActivity {
|
||||||
private Activity activity;
|
private Activity activity;
|
||||||
private PasswordFragment plist;
|
private PasswordFragment plist;
|
||||||
private AlertDialog selectDestinationDialog;
|
private AlertDialog selectDestinationDialog;
|
||||||
|
private ShortcutManager shortcutManager;
|
||||||
|
|
||||||
private final static int CLONE_REPO_BUTTON = 401;
|
private final static int CLONE_REPO_BUTTON = 401;
|
||||||
private final static int NEW_REPO_BUTTON = 402;
|
private final static int NEW_REPO_BUTTON = 402;
|
||||||
|
@ -61,6 +67,8 @@ public class PasswordStore extends AppCompatActivity {
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
settings = PreferenceManager.getDefaultSharedPreferences(this.getApplicationContext());
|
settings = PreferenceManager.getDefaultSharedPreferences(this.getApplicationContext());
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1)
|
||||||
|
shortcutManager = getSystemService(ShortcutManager.class);
|
||||||
activity = this;
|
activity = this;
|
||||||
PRNGFixes.apply();
|
PRNGFixes.apply();
|
||||||
|
|
||||||
|
@ -392,6 +400,17 @@ public class PasswordStore extends AppCompatActivity {
|
||||||
intent.putExtra("NAME", item.toString());
|
intent.putExtra("NAME", item.toString());
|
||||||
intent.putExtra("FILE_PATH", item.getFile().getAbsolutePath());
|
intent.putExtra("FILE_PATH", item.getFile().getAbsolutePath());
|
||||||
intent.putExtra("Operation", "DECRYPT");
|
intent.putExtra("Operation", "DECRYPT");
|
||||||
|
|
||||||
|
// Adds shortcut
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
|
||||||
|
ShortcutInfo shortcut = new ShortcutInfo.Builder(this, item.getFullPathName())
|
||||||
|
.setShortLabel(item.toString())
|
||||||
|
.setLongLabel(item.getFullPathName() + item.toString())
|
||||||
|
.setIcon(Icon.createWithResource(this, R.drawable.ic_launcher))
|
||||||
|
.setIntent(intent.setAction("DECRYPT_PASS")) // Needs action
|
||||||
|
.build();
|
||||||
|
shortcutManager.addDynamicShortcuts(Arrays.asList(shortcut));
|
||||||
|
}
|
||||||
startActivityForResult(intent, PgpHandler.REQUEST_CODE_DECRYPT_AND_VERIFY);
|
startActivityForResult(intent, PgpHandler.REQUEST_CODE_DECRYPT_AND_VERIFY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,8 +21,8 @@ allprojects {
|
||||||
}
|
}
|
||||||
|
|
||||||
ext {
|
ext {
|
||||||
compileSdkVersion = 23
|
compileSdkVersion = 25
|
||||||
buildToolsVersion = "23.0.3"
|
buildToolsVersion = "25.0.2"
|
||||||
}
|
}
|
||||||
subprojects { subproject ->
|
subprojects { subproject ->
|
||||||
afterEvaluate{
|
afterEvaluate{
|
||||||
|
|
Loading…
Reference in a new issue