mirror of
https://github.com/gsantner/dandelion
synced 2024-09-28 02:39:35 +02:00
implement create launcher shortcut
This commit is contained in:
parent
ac8b8469b0
commit
a558a463ef
|
@ -7,6 +7,8 @@
|
|||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
// Permission to install shortcut icon
|
||||
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
|
||||
|
||||
<application
|
||||
android:name="com.github.dfa.diaspora_android.App"
|
||||
|
|
|
@ -1158,6 +1158,22 @@ public class MainActivity extends ThemedActivity
|
|||
startActivity(new Intent(MainActivity.this, AboutActivity.class));
|
||||
}
|
||||
break;
|
||||
|
||||
case R.id.nav_shortcut: {
|
||||
Intent shortcutIntent = new Intent(MainActivity.this, MainActivity.class);
|
||||
shortcutIntent.setAction(Intent.ACTION_MAIN);
|
||||
// The intent responsible for creating the shortcut
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
|
||||
intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.app_name));
|
||||
intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(MainActivity.this, R.drawable.ic_launcher));
|
||||
// To install shortcut
|
||||
intent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
|
||||
sendBroadcast(intent);
|
||||
// Notify user of the shortcut created
|
||||
Snackbar.make(fragmentContainer, R.string.shortcut_created, Snackbar.LENGTH_LONG).show();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
navDrawer.closeDrawer(GravityCompat.START);
|
||||
|
|
|
@ -90,6 +90,10 @@
|
|||
android:id="@+id/nav_about"
|
||||
android:icon="@drawable/ic_info_black_48px"
|
||||
android:title="@string/nav_help_license" />
|
||||
|
||||
<item
|
||||
android:id="@+id/nav_shortcut"
|
||||
android:title="@string/nav_add_shortcut" />
|
||||
</group>
|
||||
|
||||
</menu>
|
||||
|
|
|
@ -96,4 +96,6 @@
|
|||
<string name="jump_to_last_visited_timestamp_in_stream">Jump to last visited page in stream?</string>
|
||||
<string name="pref_summary__is_statusbar_hidden">Hide statusbar at main view</string>
|
||||
<string name="pref_title__is_statusbar_hidden">Hide statusbar</string>
|
||||
<string name="nav_add_shortcut">Add Launcher Shortcut</string>
|
||||
<string name="shortcut_created">Shortcut Created</string>
|
||||
</resources>
|
||||
|
|
Loading…
Reference in a new issue