diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index f9c1e7a43..e80d163c3 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -56,6 +56,16 @@ android:label="" android:configChanges="orientation|screenSize" android:theme="@style/AppTheme.NoActionBar"/> + + + + + + parent, View view, int position, long id) + { + Cursor selected = (Cursor) parent.getItemAtPosition(position); + LoyaltyCard loyaltyCard = LoyaltyCard.toLoyaltyCard(selected); + + Log.d(TAG, "Creating shortcut for card " + loyaltyCard.store + "," + loyaltyCard.id); + + Intent shortcutIntent = new Intent(CardShortcutConfigure.this, LoyaltyCardViewActivity.class); + shortcutIntent.setAction(Intent.ACTION_MAIN); + // Prevent instances of the view activity from piling up; if one exists let this + // one replace it. + shortcutIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); + Bundle bundle = new Bundle(); + bundle.putInt("id", loyaltyCard.id); + bundle.putBoolean("view", true); + shortcutIntent.putExtras(bundle); + + Parcelable icon = Intent.ShortcutIconResource.fromContext(CardShortcutConfigure.this, R.mipmap.ic_launcher); + Intent intent = new Intent(); + intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); + intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, loyaltyCard.store); + intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, icon); + setResult(RESULT_OK, intent); + + finish(); + } + }); + } +} diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 62c7039c2..d89b6bbc3 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -33,6 +33,8 @@ Add Loyalty Card View Loyalty Card Scan Card\'s Barcode + Card Shortcut + There are no cards, add one first Image of card\'s barcode