|
1 | | -# live_icon |
| 1 | +# Live Icon |
2 | 2 |
|
3 | | -A new Flutter plugin. |
| 3 | +<!-- <img src="https://i.imgur.com/462Y6wf.gif" title="Flutter_Shortcuts" /> --> |
4 | 4 |
|
5 | | -## Getting Started |
| 5 | +      |
6 | 6 |
|
7 | | -This project is a starting point for a Flutter |
8 | | -[plug-in package](https://flutter.dev/developing-packages/), |
9 | | -a specialized package that includes platform-specific implementation code for |
10 | | -Android and/or iOS. |
| 7 | +  |
11 | 8 |
|
12 | | -For help getting started with Flutter, view our |
13 | | -[online documentation](https://flutter.dev/docs), which offers tutorials, |
14 | | -samples, guidance on mobile development, and a full API reference. |
15 | 9 |
|
| 10 | +## Features |
| 11 | + |
| 12 | +All the features listed below can be performed at the runtime. |
| 13 | + |
| 14 | +✅ Change App Icons </br> |
| 15 | +✅ Change App Label </br> |
| 16 | + |
| 17 | +<!-- ## Demo --> |
| 18 | + |
| 19 | +<!-- |<img height=500 src="https://i.imgur.com/UPcyPEl.gif"/>| |
| 20 | +|---| --> |
| 21 | + |
| 22 | +## Quick Start |
| 23 | + |
| 24 | +### Step 1: Include plugin to your project |
| 25 | + |
| 26 | +```yml |
| 27 | +dependencies: |
| 28 | + live_icon: <latest version> |
| 29 | +``` |
| 30 | +
|
| 31 | +### Step 2: Add activity-alias in AndroidManifest.xml |
| 32 | +
|
| 33 | +```xml |
| 34 | +... |
| 35 | +... |
| 36 | +<application |
| 37 | + android:label="live_icon_example" |
| 38 | + android:icon="@mipmap/ic_launcher"> |
| 39 | + <activity |
| 40 | + android:name=".MainActivity" |
| 41 | + android:launchMode="singleTop" |
| 42 | + android:theme="@style/LaunchTheme" |
| 43 | + android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" |
| 44 | + android:hardwareAccelerated="true" |
| 45 | + android:windowSoftInputMode="adjustResize"> |
| 46 | + <meta-data |
| 47 | + android:name="io.flutter.embedding.android.NormalTheme" |
| 48 | + android:resource="@style/NormalTheme" |
| 49 | + /> |
| 50 | + <meta-data |
| 51 | + android:name="io.flutter.embedding.android.SplashScreenDrawable" |
| 52 | + android:resource="@drawable/launch_background" |
| 53 | + /> |
| 54 | + <intent-filter> |
| 55 | + <action android:name="android.intent.action.MAIN"/> |
| 56 | + <category android:name="android.intent.category.LAUNCHER"/> |
| 57 | + </intent-filter> |
| 58 | + </activity> |
| 59 | + |
| 60 | + <!-- Live Icon Addition --> |
| 61 | + <activity-alias |
| 62 | + android:name=".DarkTheme" |
| 63 | + android:enabled="false" |
| 64 | + android:icon="@mipmap/dark_theme" |
| 65 | + android:label="DarkThemeLabel" |
| 66 | + android:targetActivity=".MainActivity"> |
| 67 | + <intent-filter> |
| 68 | + <action android:name="android.intent.action.MAIN"/> |
| 69 | + <category android:name="android.intent.category.LAUNCHER"/> |
| 70 | + </intent-filter> |
| 71 | + </activity-alias> |
| 72 | + |
| 73 | + <activity-alias |
| 74 | + android:name=".LightTheme" |
| 75 | + android:enabled="false" |
| 76 | + android:icon="@mipmap/light_theme" |
| 77 | + android:label="LightThemeLabel" |
| 78 | + android:targetActivity=".MainActivity"> |
| 79 | + <intent-filter> |
| 80 | + <action android:name="android.intent.action.MAIN"/> |
| 81 | + <category android:name="android.intent.category.LAUNCHER"/> |
| 82 | + </intent-filter> |
| 83 | + </activity-alias> |
| 84 | + <!-- Live Icon Addition --> |
| 85 | + |
| 86 | + <meta-data |
| 87 | + android:name="flutterEmbedding" |
| 88 | + android:value="2" /> |
| 89 | + |
| 90 | +</application> |
| 91 | +... |
| 92 | +... |
| 93 | +``` |
| 94 | + |
| 95 | +### Step 3: Create classes |
| 96 | + |
| 97 | +Create java/kotlin files with the same name as provided in activity-alias. |
| 98 | + |
| 99 | +In the above AndroidManifest.xml example, 2 activity-alias are provided, so the number of java/kotlin files will be 2. |
| 100 | +Example: |
| 101 | + |
| 102 | +#### 1. `DarkTheme.java` |
| 103 | + |
| 104 | +```java |
| 105 | +package com.hackthedeveloper.live_icon_example; |
| 106 | + |
| 107 | +public class DarkTheme { |
| 108 | +} |
| 109 | +``` |
| 110 | + |
| 111 | +#### 2. `LightTheme.java` |
| 112 | + |
| 113 | +```java |
| 114 | +package com.hackthedeveloper.live_icon_example; |
| 115 | + |
| 116 | +public class LightTheme { |
| 117 | +} |
| 118 | +``` |
| 119 | + |
| 120 | +One thing to note here is that, we have added two extra activity as activity-alias, and we now have 3 activity in total. |
| 121 | + |
| 122 | +### Step 4: Initialise plugin |
| 123 | + |
| 124 | +List all the activity-alias class names. |
| 125 | +**NOTE:** `MainActivity` will also be added here as it containes the launch intent. |
| 126 | + |
| 127 | +```dart |
| 128 | +LiveIcon.initialize( |
| 129 | + classNames: ['MainActivity', 'DarkTheme', 'LightTheme'], |
| 130 | +); |
| 131 | +``` |
| 132 | + |
| 133 | +### Step 5: Switch App icon |
| 134 | + |
| 135 | +Use `switchIconTo` to switch app icons. It takes in the className that must match the desired activity-alias `android:name`. |
| 136 | + |
| 137 | +```dart |
| 138 | +await liveIcon.switchIconTo( |
| 139 | + className: 'DarkTheme', |
| 140 | +); |
| 141 | +``` |
| 142 | + |
| 143 | + |
| 144 | + |
| 145 | +## Project Created & Maintained By |
| 146 | + |
| 147 | +### Subham Praharaj |
| 148 | + |
| 149 | +<a href="https://twitter.com/SubhamPraharaj6"><img src="https://github.com/aritraroy/social-icons/blob/master/twitter-icon.png?raw=true" width="60"></a> <a href="https://www.linkedin.com/in/subham-praharaj-66b172179/"><img src="https://github.com/aritraroy/social-icons/blob/master/linkedin-icon.png?raw=true" width="60"></a> <a href="https://instagram.com/the_champ_subham_865"><img src="https://github.com/aritraroy/social-icons/blob/master/instagram-icon.png?raw=true" width="60"></a> |
| 150 | + |
| 151 | +[](https://github.com/skpraharaj/) |
| 152 | + |
| 153 | +### Divyanshu Shekhar |
| 154 | + |
| 155 | +<a href="https://twitter.com/dshekhar17"><img src="https://github.com/aritraroy/social-icons/blob/master/twitter-icon.png?raw=true" width="60"></a> <a href="https://in.linkedin.com/in/divyanshu-shekhar-a8a04a162"><img src="https://github.com/aritraroy/social-icons/blob/master/linkedin-icon.png?raw=true" width="60"></a> <a href="https://instagram.com/dshekhar17"><img src="https://github.com/aritraroy/social-icons/blob/master/instagram-icon.png?raw=true" width="60"></a> |
| 156 | + |
| 157 | +[](https://github.com/divshekhar/) |
| 158 | + |
| 159 | + |
| 160 | + |
| 161 | +## Contributions |
| 162 | + |
| 163 | +Contributions are welcomed! |
| 164 | + |
| 165 | +If you feel that a hook is missing, feel free to open a pull-request. |
| 166 | + |
| 167 | +For a custom-hook to be merged, you will need to do the following: |
| 168 | + |
| 169 | +Describe the use-case. |
| 170 | + |
| 171 | +* Open an issue explaining why we need this hook, how to use it, ... |
| 172 | + This is important as a hook will not get merged if the hook doens't appeal to |
| 173 | + a large number of people. |
| 174 | + |
| 175 | +* If your hook is rejected, don't worry! A rejection doesn't mean that it won't |
| 176 | + be merged later in the future if more people shows an interest in it. |
| 177 | + In the mean-time, feel free to publish your hook as a package on https://pub.dev. |
| 178 | + |
| 179 | +* A hook will not be merged unles fully tested, to avoid breaking it inadvertendly |
| 180 | + in the future. |
| 181 | + |
| 182 | +## Copyright & License |
| 183 | + |
| 184 | +Code and documentation Copyright (c) 2021 [Devs On Flutter](https://github.com/DevsOnFlutter). Code released under the [BSD 3-Clause License](./LICENSE). |
0 commit comments