Skip to content
This repository has been archived by the owner on Feb 4, 2023. It is now read-only.

Commit

Permalink
Feature/android splash screen (#257)
Browse files Browse the repository at this point in the history
* Scope snippets

* Add xml formatting option

* Add splash screen icon

* Cleanup android manifest

* Add changelog entry
  • Loading branch information
shilangyu authored Sep 24, 2021
1 parent 9f9cc52 commit 95e5da7
Show file tree
Hide file tree
Showing 15 changed files with 60 additions and 93 deletions.
6 changes: 6 additions & 0 deletions .vscode/lemmur.code-snippets
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,34 @@
"body": ["\"$1\": \"$2\",", "\"@$1\": {}$0"]
},
"Assert not null": {
"scope": "dart",
"prefix": "assnotnull",
"body": ["assert($1 != null)$0"]
},
"sizedbox": {
"scope": "dart",
"prefix": "sizedbox",
"body": ["const SizedBox($1)$0"]
},
"theme": {
"scope": "dart",
"prefix": "theme",
"body": ["final theme = Theme.of(context);"]
},
"sleep": {
"scope": "dart",
"prefix": "sleep",
"body": [
"await Future<dynamic>.delayed(const Duration(milliseconds: ${1:1000}));$0"
]
},
"repeat widget": {
"scope": "dart",
"prefix": "repeat",
"body": ["for(int i = 0; i < $1; i++)$0"]
},
"L10n string": {
"scope": "dart",
"prefix": "l10n",
"body": ["L10n.of(context)!.$0"]
},
Expand Down
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"files.associations": {
"*.arb": "json"
},
"dart.showTodos": false
"dart.showTodos": false,
"xml.format.preserveAttributeLineBreaks": true
}
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
### Added

- Logging: local logs about some actions/errors. Can be accessed from **settings > about lemmur > logs**
- Android theme-aware splash screen (thanks to [@mimi89999](https://github.com/mimi89999))

## v0.6.0 - 2021-09-06

Expand Down
85 changes: 36 additions & 49 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,51 +1,38 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.krawieck.lemmur">
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
calls FlutterMain.startInitialization(this); in its onCreate method.
In most cases you can leave this as-is, but you if you want to provide
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<uses-permission android:name="android.permission.INTERNET" />
<!-- Needed for url_launcher to work on android 11 -->
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"/>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.krawieck.lemmur">

<application
android:name="io.flutter.app.FlutterApplication"
android:label="${appName}"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
<!-- Displays an Android View that continues showing the launch screen
Drawable until Flutter paints its first frame, then this splash
screen fades out. A splash screen is useful to avoid any visual
gap between the end of Android's launch screen and the painting of
Flutter's first frame. -->
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="@drawable/launch_background"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
<uses-permission android:name="android.permission.INTERNET" />
<!-- Needed for url_launcher to work on android 11 -->
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />

<application
android:name="io.flutter.app.FlutterApplication"
android:label="${appName}"
android:icon="@mipmap/ic_launcher">

<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">

<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>

<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<meta-data
android:name="flutterEmbedding"
android:value="2" />

</application>
</manifest>
Binary file added android/app/src/main/res/drawable-hdpi/splash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added android/app/src/main/res/drawable-mdpi/splash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 0 additions & 12 deletions android/app/src/main/res/drawable/launch_background.xml

This file was deleted.

10 changes: 10 additions & 0 deletions android/app/src/main/res/drawable/splash_screen.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/splash_screen_background_color" />

<item>
<bitmap
android:gravity="center"
android:src="@drawable/splash" />
</item>
</layer-list>
2 changes: 1 addition & 1 deletion android/app/src/main/res/values-night/colors.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="launch_background_color">#303030</color>
<color name="splash_screen_background_color">#303030</color>
</resources>
18 changes: 0 additions & 18 deletions android/app/src/main/res/values-night/styles.xml

This file was deleted.

2 changes: 1 addition & 1 deletion android/app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ic_launcher_background">#ffffff</color>
<color name="launch_background_color">#fafafa</color>
<color name="splash_screen_background_color">#fafafa</color>
</resources>
14 changes: 3 additions & 11 deletions android/app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Theme applied to the Android Window while the process is starting -->
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
<!-- Show a splash screen on the activity. Automatically removed when
Flutter draws its first frame -->
<item name="android:windowBackground">@drawable/launch_background</item>
<item name="android:windowBackground">@drawable/splash_screen</item>
</style>
<!-- Theme applied to the Android Window as soon as the process has started.
This theme determines the color of the Android Window while your
Flutter UI initializes, as well as behind your Flutter UI while its
running.
This Theme is only used starting with V2 of Flutter's Android embedding. -->

<style name="NormalTheme" parent="@android:style/Theme.Black.NoTitleBar">
<item name="android:windowBackground">@android:color/white</item>
<item name="android:windowBackground">@color/splash_screen_background_color</item>
</style>
</resources>

0 comments on commit 95e5da7

Please sign in to comment.