Skip to content
This repository has been archived by the owner on Mar 29, 2022. It is now read-only.

Commit

Permalink
Quick fix for #1
Browse files Browse the repository at this point in the history
  • Loading branch information
GioPan04 committed Jan 28, 2021
1 parent 2415d8d commit d19f8fd
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 34 deletions.
22 changes: 9 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Change your app icon at runtime!

## Known issues
* You can use only one alternative icon. Later on I'll (re)make the process more dynamic. More info [here](https://github.com/GioPan04/flutter_icon_switcher/issues/1)
* The plugin only works on Android, on iOS will work, but i'm working on it.
* On Android if you try to run the app via cli, for example `flutter run` (or from the ide plugin), the app will not launch if the current enabled icon is not the default.

Expand All @@ -19,16 +20,8 @@ Change your app icon at runtime!
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
</activity>

<!-- The activity-alias are your alternatives icons and name of your app, the default one must be enabled (and the others disabled) and the name must be ".DEFAULT". All the names of your activity-alias' name must begin with a dot. -->
<activity-alias
android:label="Default"
android:icon="@mipmap/ic_launcher_2"
android:name=".DEFAULT"
android:enabled="true"
android:targetActivity=".MainActivity">
android:windowSoftInputMode="adjustResize"
android:enabled="true">

<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
Expand All @@ -44,13 +37,16 @@ Change your app icon at runtime!
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

</activity-alias>
<!-- The activity-alias are your alternatives icons and name of your app, the default one must be enabled (and the others disabled) and the name must be ".DEFAULT". All the names of your activity-alias' name must begin with a dot. -->

<!-- FOR NOW USE "ALT" AS ALTERNATIVE ICON NAME, FOLLOW https://github.com/GioPan04/flutter_icon_switcher/issues/1 FOR MORE INFO -->

<activity-alias
android:label="Blue"
android:icon="@mipmap/ic_launcher_3"
android:name=".BLUE"
android:name=".ALT"
android:enabled="false"
android:targetActivity=".MainActivity">

Expand All @@ -75,7 +71,7 @@ Change your app icon at runtime!
4. In your app you can now use:
(The name you pass in the method must be in the `AndroidManifest.xml`)
```dart
FlutterIconSwitcher.updateIcon('BLUE');
FlutterIconSwitcher.updateIcon('ALT');
```
5. Enjoy!
---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,13 @@ public void resetIcon() {
String packageName = context.getPackageName();

// Get the default class name of the activity-alias
String defaultClassName = String.format("%s.%s", packageName, "DEFAULT");
String defaultClassName = String.format("%s.%s", packageName, "MainActivity");

// Update the icon
PackageManager pm = context.getPackageManager();

//ActivityInfo oldActivity = getEnabledComponent();
String oldClassName = String.format("%s.%s", packageName, "BLUE");
// ActivityInfo oldActivity = getEnabledComponent();
String oldClassName = String.format("%s.%s", packageName, "ALT");

/*if (oldActivity.name.contains("DEFAULT")) {
return;
Expand All @@ -145,7 +145,7 @@ public void resetIcon() {
}


/*public ActivityInfo getEnabledComponent() {
public ActivityInfo getEnabledComponent() {
PackageManager pm = context.getPackageManager();
String packageName = context.getPackageName();
ActivityInfo[] activityInfos = getActivities();
Expand All @@ -163,7 +163,7 @@ public void resetIcon() {
}

return enabledComponent;
}*/
}

public ActivityInfo[] getActivities() {
ActivityInfo[] activityInfos;
Expand Down
17 changes: 5 additions & 12 deletions example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,8 @@
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">

</activity>

<activity-alias
android:label="Default"
android:icon="@mipmap/ic_launcher_2"
android:name=".DEFAULT"
android:enabled="true"
android:targetActivity=".MainActivity">
android:windowSoftInputMode="adjustResize"
android:enabled="true">

<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
Expand All @@ -37,12 +29,13 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

</activity-alias>
</activity>

<!-- FOR NOW USE "ALT" AS ALTERNATIVE ICON NAME, FOLLOW https://github.com/GioPan04/flutter_icon_switcher/issues/1 FOR MORE INFO -->
<activity-alias
android:label="Blue"
android:icon="@mipmap/ic_launcher_3"
android:name=".BLUE"
android:name=".ALT"
android:enabled="false"
android:targetActivity=".MainActivity">

Expand Down
2 changes: 1 addition & 1 deletion example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class _MyAppState extends State<MyApp> {


void _updateIcon() async {
await FlutterIconSwitcher.updateIcon('BLUE');
await FlutterIconSwitcher.updateIcon('ALT');
}

void _resetIcon() async {
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ packages:
path: ".."
relative: true
source: path
version: "0.0.1"
version: "0.0.2"
flutter_test:
dependency: "direct dev"
description: flutter
Expand Down
2 changes: 1 addition & 1 deletion flutter_icon_switcher.iml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
<excludeFolder url="file://$MODULE_DIR$/.idea" />
<excludeFolder url="file://$MODULE_DIR$/.pub" />
<excludeFolder url="file://$MODULE_DIR$/build" />
<excludeFolder url="file://$MODULE_DIR$/example/.dart_tool" />
<excludeFolder url="file://$MODULE_DIR$/example/.pub" />
<excludeFolder url="file://$MODULE_DIR$/example/build" />
</content>
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Dart Packages" level="project" />
<orderEntry type="library" name="Dart SDK" level="project" />
<orderEntry type="library" name="Flutter Plugins" level="project" />
</component>
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: flutter_icon_switcher
description: Change your app icon at runtime!
version: 0.0.1
version: 0.0.2
author: Gioele Pannetto
homepage: https://github.com/GioPan04/flutter_icon_switcher

Expand Down

0 comments on commit d19f8fd

Please sign in to comment.