From: Tobias Brunner Date: Tue, 19 Jun 2018 10:32:55 +0000 (+0200) Subject: android: Use modern shortcuts on Android 8+ X-Git-Tag: 5.7.0dr5~20^2~39 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e145a5e66de671bc9f66cb11f28ba2b0d86032c0;p=thirdparty%2Fstrongswan.git android: Use modern shortcuts on Android 8+ --- diff --git a/src/frontends/android/app/src/main/AndroidManifest.xml b/src/frontends/android/app/src/main/AndroidManifest.xml index ab3725b56e..2a75d05aba 100644 --- a/src/frontends/android/app/src/main/AndroidManifest.xml +++ b/src/frontends/android/app/src/main/AndroidManifest.xml @@ -80,7 +80,8 @@ + android:label="@string/strongswan_shortcut" + android:icon="@mipmap/ic_shortcut" > diff --git a/src/frontends/android/app/src/main/java/org/strongswan/android/ui/VpnProfileSelectActivity.java b/src/frontends/android/app/src/main/java/org/strongswan/android/ui/VpnProfileSelectActivity.java index 27cecc7e99..fe3d01322a 100644 --- a/src/frontends/android/app/src/main/java/org/strongswan/android/ui/VpnProfileSelectActivity.java +++ b/src/frontends/android/app/src/main/java/org/strongswan/android/ui/VpnProfileSelectActivity.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012 Tobias Brunner + * Copyright (C) 2012-2018 Tobias Brunner * HSR Hochschule fuer Technik Rapperswil * * This program is free software; you can redistribute it and/or modify it @@ -17,6 +17,9 @@ package org.strongswan.android.ui; import android.content.Intent; import android.os.Bundle; +import android.support.v4.content.pm.ShortcutInfoCompat; +import android.support.v4.content.pm.ShortcutManagerCompat; +import android.support.v4.graphics.drawable.IconCompat; import android.support.v7.app.AppCompatActivity; import org.strongswan.android.R; @@ -42,11 +45,11 @@ public class VpnProfileSelectActivity extends AppCompatActivity implements OnVpn Intent shortcut = new Intent(VpnProfileControlActivity.START_PROFILE); shortcut.putExtra(VpnProfileControlActivity.EXTRA_VPN_PROFILE_ID, profile.getUUID().toString()); - Intent intent = new Intent(); - intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcut); - intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, profile.getName()); - intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(this, R.drawable.ic_launcher)); - setResult(RESULT_OK, intent); + ShortcutInfoCompat.Builder builder = new ShortcutInfoCompat.Builder(this, profile.getUUID().toString()); + builder.setIntent(shortcut); + builder.setShortLabel(profile.getName()); + builder.setIcon(IconCompat.createWithResource(this, R.mipmap.ic_shortcut)); + setResult(RESULT_OK, ShortcutManagerCompat.createShortcutResultIntent(this, builder.build())); finish(); } } diff --git a/src/frontends/android/app/src/main/res/mipmap-anydpi-v26/ic_shortcut.xml b/src/frontends/android/app/src/main/res/mipmap-anydpi-v26/ic_shortcut.xml new file mode 100644 index 0000000000..6aea2ffbfb --- /dev/null +++ b/src/frontends/android/app/src/main/res/mipmap-anydpi-v26/ic_shortcut.xml @@ -0,0 +1,19 @@ + + + + + + diff --git a/src/frontends/android/app/src/main/res/mipmap-anydpi/ic_shortcut.xml b/src/frontends/android/app/src/main/res/mipmap-anydpi/ic_shortcut.xml new file mode 100644 index 0000000000..653d080060 --- /dev/null +++ b/src/frontends/android/app/src/main/res/mipmap-anydpi/ic_shortcut.xml @@ -0,0 +1,17 @@ + + + \ No newline at end of file diff --git a/src/frontends/android/app/src/main/res/mipmap-xxxhdpi-v26/ic_shortcut_bg.png b/src/frontends/android/app/src/main/res/mipmap-xxxhdpi-v26/ic_shortcut_bg.png new file mode 100644 index 0000000000..76532253cf Binary files /dev/null and b/src/frontends/android/app/src/main/res/mipmap-xxxhdpi-v26/ic_shortcut_bg.png differ diff --git a/src/frontends/android/app/src/main/res/mipmap-xxxhdpi-v26/ic_shortcut_fg.png b/src/frontends/android/app/src/main/res/mipmap-xxxhdpi-v26/ic_shortcut_fg.png new file mode 100644 index 0000000000..6e62e6d698 Binary files /dev/null and b/src/frontends/android/app/src/main/res/mipmap-xxxhdpi-v26/ic_shortcut_fg.png differ