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

Commit b05a72e

Browse files
authored
Merge pull request #532 from OkunaOrg/feature/update-android-plugin-system
🚧 apply tutorial from flutter github to migrate
2 parents cdb8b6c + e03bfec commit b05a72e

File tree

14 files changed

+400
-337
lines changed

14 files changed

+400
-337
lines changed

android/app/src/main/AndroidManifest.xml

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,26 +25,31 @@
2525
FlutterApplication and put your custom class here. -->
2626
<application
2727
android:requestLegacyExternalStorage="true"
28-
android:name="io.flutter.app.FlutterApplication"
2928
android:label="Okuna"
3029
android:icon="@mipmap/ic_launcher"
3130
android:usesCleartextTraffic="true"
3231
>
32+
<meta-data
33+
android:name="flutterEmbedding"
34+
android:value="2" />
3335
<activity
3436
android:name=".MainActivity"
3537
android:launchMode="singleTop"
3638
android:theme="@style/LaunchTheme"
3739
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density"
3840
android:hardwareAccelerated="true"
3941
android:windowSoftInputMode="adjustResize">
40-
<!-- This keeps the window background of the activity showing
41-
until Flutter renders its first frame. It can be removed if
42-
there is no splash screen (such as the default splash screen
43-
defined in @style/LaunchTheme). -->
42+
<!-- Specify that the launch screen should continue being displayed -->
43+
<!-- until Flutter renders its first frame. -->
4444
<meta-data
45-
android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
46-
android:value="true"/>
47-
<!-- App Links -->
45+
android:name="io.flutter.embedding.android.SplashScreenDrawable"
46+
android:resource="@drawable/launch_background" />
47+
48+
<!-- Theme to apply as soon as Flutter begins rendering frames -->
49+
<meta-data
50+
android:name="io.flutter.embedding.android.NormalTheme"
51+
android:resource="@style/NormalTheme"
52+
/>
4853
<intent-filter android:autoVerify="true">
4954
<action android:name="android.intent.action.VIEW"/>
5055
<category android:name="android.intent.category.DEFAULT"/>

android/app/src/main/java/com/example/openbook/MainActivity.java

Lines changed: 0 additions & 277 deletions
This file was deleted.

android/app/src/main/java/com/example/openbook/ImageConverter.java renamed to android/app/src/main/java/social/openbook/app/ImageConverter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.example.openbook;
1+
package social.openbook.app;
22

33
import android.graphics.Bitmap;
44
import android.graphics.BitmapFactory;
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package social.openbook.app;
2+
3+
import android.content.Intent;
4+
import android.os.Bundle;
5+
import social.openbook.app.plugins.ImageConverterPlugin;
6+
import social.openbook.app.plugins.SharePlugin;
7+
import io.flutter.embedding.android.FlutterActivity;
8+
import io.flutter.embedding.engine.plugins.PluginRegistry;
9+
10+
public class MainActivity extends FlutterActivity {
11+
private SharePlugin sharePlugin;
12+
13+
@Override
14+
protected void onCreate(Bundle savedInstanceState) {
15+
super.onCreate(savedInstanceState);
16+
17+
// Register the ImageConverterPlugin manually. It won't register automatically since it isn't added as a plugin via
18+
// our pubspec.yaml.
19+
// Note: getFlutterEngine() should not be null here since it is created in super.onCreate().
20+
PluginRegistry pluginRegistry = getFlutterEngine().getPlugins();
21+
pluginRegistry.add(new ImageConverterPlugin());
22+
sharePlugin = new SharePlugin();
23+
pluginRegistry.add(sharePlugin);
24+
25+
// Pass the intent that created this activity to the share plugin,
26+
// just in case it is an ACTION_SEND intent with share data.
27+
sharePlugin.handleIntent(getIntent());
28+
}
29+
30+
@Override
31+
protected void onNewIntent(Intent intent) {
32+
super.onNewIntent(intent);
33+
sharePlugin.handleIntent(intent);
34+
}
35+
}

0 commit comments

Comments
 (0)