mirror of
https://github.com/beemdevelopment/Aegis.git
synced 2025-05-27 04:07:15 +00:00
Added new profile shortcut
This commit is contained in:
parent
dc7f8b5b7e
commit
a90e35eb97
2 changed files with 22 additions and 3 deletions
|
@ -6,7 +6,7 @@ android {
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "me.impy.aegis"
|
applicationId "me.impy.aegis"
|
||||||
minSdkVersion 15
|
minSdkVersion 19
|
||||||
targetSdkVersion 25
|
targetSdkVersion 25
|
||||||
versionCode 1
|
versionCode 1
|
||||||
versionName "1.0"
|
versionName "1.0"
|
||||||
|
|
|
@ -22,6 +22,7 @@ import android.support.v7.widget.LinearLayoutManager;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.support.v7.widget.Toolbar;
|
import android.support.v7.widget.Toolbar;
|
||||||
import android.support.v7.widget.helper.ItemTouchHelper;
|
import android.support.v7.widget.helper.ItemTouchHelper;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -33,6 +34,7 @@ import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
import me.impy.aegis.crypto.CryptoUtils;
|
import me.impy.aegis.crypto.CryptoUtils;
|
||||||
import me.impy.aegis.crypto.OTP;
|
import me.impy.aegis.crypto.OTP;
|
||||||
|
@ -274,19 +276,36 @@ public class MainActivity extends AppCompatActivity {
|
||||||
|
|
||||||
private void initializeAppShortcuts()
|
private void initializeAppShortcuts()
|
||||||
{
|
{
|
||||||
|
String mode = getIntent().getStringExtra("Action");
|
||||||
|
if(mode != null)
|
||||||
|
{
|
||||||
|
Log.println(Log.DEBUG, "MODE: ", mode);
|
||||||
|
if(Objects.equals(mode, "Scan"))
|
||||||
|
{
|
||||||
|
Log.println(Log.DEBUG, "OKK ", "OKKK");
|
||||||
|
Intent scannerActivity = new Intent(getApplicationContext(), ScannerActivity.class);
|
||||||
|
startActivityForResult(scannerActivity, GET_KEYINFO);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ShortcutManager shortcutManager = null;
|
ShortcutManager shortcutManager = null;
|
||||||
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
|
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
|
||||||
shortcutManager = getSystemService(ShortcutManager.class);
|
shortcutManager = getSystemService(ShortcutManager.class);
|
||||||
if(shortcutManager != null) {
|
if(shortcutManager != null) {
|
||||||
|
//TODO: Remove this line
|
||||||
|
shortcutManager.removeAllDynamicShortcuts();
|
||||||
if (shortcutManager.getDynamicShortcuts().size() == 0) {
|
if (shortcutManager.getDynamicShortcuts().size() == 0) {
|
||||||
// Application restored. Need to re-publish dynamic shortcuts.
|
// Application restored. Need to re-publish dynamic shortcuts.
|
||||||
|
|
||||||
|
Intent intent1 = new Intent(this.getBaseContext(), MainActivity.class);
|
||||||
|
intent1.putExtra("Action", "Scan");
|
||||||
|
intent1.setAction(Intent.ACTION_MAIN);
|
||||||
|
|
||||||
ShortcutInfo shortcut = new ShortcutInfo.Builder(this, "id1")
|
ShortcutInfo shortcut = new ShortcutInfo.Builder(this, "id1")
|
||||||
.setShortLabel("Web site")
|
.setShortLabel("New profile")
|
||||||
.setLongLabel("Add new profile")
|
.setLongLabel("Add new profile")
|
||||||
.setIcon(Icon.createWithResource(this.getApplicationContext(), R.drawable.intro_scanner))
|
.setIcon(Icon.createWithResource(this.getApplicationContext(), R.drawable.intro_scanner))
|
||||||
.setIntent(new Intent(Intent.ACTION_VIEW, Uri.EMPTY, this, ScannerActivity.class))
|
.setIntent(intent1)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
shortcutManager.setDynamicShortcuts(Arrays.asList(shortcut));
|
shortcutManager.setDynamicShortcuts(Arrays.asList(shortcut));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue