Browse Source

升级安卓v2

tags/0.1.0^0
Weller 2 years ago
parent
commit
e54ad9c9c0
8 changed files with 53 additions and 36 deletions
  1. +1
    -1
      android/build.gradle
  2. +16
    -15
      android/src/main/java/com/wxwx/flutter_alibc/FlutterAlibcHandle.java
  3. +26
    -10
      android/src/main/java/com/wxwx/flutter_alibc/FlutterAlibcPlugin.java
  4. +1
    -1
      example/.flutter-plugins-dependencies
  5. +2
    -1
      example/android/app/src/main/AndroidManifest.xml
  6. +2
    -8
      example/android/app/src/main/java/wxwx/com/flutter_alibc_example/MainActivity.java
  7. +4
    -0
      example/android/app/src/main/res/values/styles.xml
  8. +1
    -0
      example/android/build.gradle

+ 1
- 1
android/build.gradle View File

@@ -5,7 +5,7 @@ buildscript {
repositories { repositories {
google() google()
jcenter() jcenter()
maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}
// maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}
flatDir { flatDir {
dirs 'libs' dirs 'libs'
} }


+ 16
- 15
android/src/main/java/com/wxwx/flutter_alibc/FlutterAlibcHandle.java View File

@@ -1,15 +1,12 @@
package com.wxwx.flutter_alibc; package com.wxwx.flutter_alibc;


import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import android.webkit.WebChromeClient;
import android.webkit.WebViewClient;
import android.widget.Toast;
import android.content.Intent; import android.content.Intent;


import com.ali.auth.third.core.model.Session; import com.ali.auth.third.core.model.Session;




import io.flutter.plugin.common.MethodChannel;
import io.flutter.plugin.common.PluginRegistry; import io.flutter.plugin.common.PluginRegistry;
import io.flutter.plugin.common.PluginRegistry.Registrar; import io.flutter.plugin.common.PluginRegistry.Registrar;
import io.flutter.plugin.common.MethodChannel.Result; import io.flutter.plugin.common.MethodChannel.Result;
@@ -17,8 +14,6 @@ import io.flutter.plugin.common.MethodCall;


import java.util.HashMap; import java.util.HashMap;


import android.app.AlertDialog;

import static com.ali.auth.third.core.context.KernelContext.getApplicationContext; import static com.ali.auth.third.core.context.KernelContext.getApplicationContext;
import static com.wxwx.flutter_alibc.PluginConstants.*; import static com.wxwx.flutter_alibc.PluginConstants.*;
import static com.wxwx.flutter_alibc.PluginUtil.*; import static com.wxwx.flutter_alibc.PluginUtil.*;
@@ -48,21 +43,27 @@ import java.util.Map;
**/ **/
public class FlutterAlibcHandle { public class FlutterAlibcHandle {


private static FlutterAlibcHandle handle;
private MethodChannel channel;

// private static FlutterAlibcHandle handle;
private static Registrar register; private static Registrar register;
private static boolean isFirst = true; private static boolean isFirst = true;
private static Result result; private static Result result;


//第一次调用getInstance register不能为空
public static FlutterAlibcHandle getInstance(Registrar register) {

synchronized (FlutterAlibcHandle.class) {
handle = new FlutterAlibcHandle();
FlutterAlibcHandle.register = register;
}
return handle;
public FlutterAlibcHandle(MethodChannel channel) {
this.channel = channel;
} }


//第一次调用getInstance register不能为空
// public static FlutterAlibcHandle getInstance(Registrar register) {
//
// synchronized (FlutterAlibcHandle.class) {
// handle = new FlutterAlibcHandle();
// FlutterAlibcHandle.register = register;
// }
// return handle;
// }

/** /**
* 初始化阿里百川 * 初始化阿里百川
* *


+ 26
- 10
android/src/main/java/com/wxwx/flutter_alibc/FlutterAlibcPlugin.java View File

@@ -1,24 +1,40 @@
package com.wxwx.flutter_alibc; package com.wxwx.flutter_alibc;



import androidx.annotation.NonNull;

import io.flutter.embedding.engine.plugins.FlutterPlugin;
import io.flutter.plugin.common.MethodCall; import io.flutter.plugin.common.MethodCall;
import io.flutter.plugin.common.MethodChannel; import io.flutter.plugin.common.MethodChannel;
import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
import io.flutter.plugin.common.MethodChannel.Result;
import io.flutter.plugin.common.PluginRegistry.Registrar;


/** FlutterAlibcPlugin */ /** FlutterAlibcPlugin */
public class FlutterAlibcPlugin implements MethodCallHandler {
public class FlutterAlibcPlugin implements FlutterPlugin, MethodChannel.MethodCallHandler {


private static com.wxwx.flutter_alibc.FlutterAlibcHandle handle;
// private static com.wxwx.flutter_alibc.FlutterAlibcHandle handle;
/** Plugin registration. */ /** Plugin registration. */
public static void registerWith(Registrar registrar) {
handle = com.wxwx.flutter_alibc.FlutterAlibcHandle.getInstance(registrar);
final MethodChannel channel = new MethodChannel(registrar.messenger(), "flutter_alibc");
channel.setMethodCallHandler(new FlutterAlibcPlugin());
// public static void registerWith(Registrar registrar) {
// handle = com.wxwx.flutter_alibc.FlutterAlibcHandle.getInstance(registrar);
// final MethodChannel channel = new MethodChannel(registrar.messenger(), "flutter_alibc");
// channel.setMethodCallHandler(new FlutterAlibcPlugin());
// }
private MethodChannel channel;
private com.wxwx.flutter_alibc.FlutterAlibcHandle handle;

@Override
public void onAttachedToEngine(@NonNull FlutterPluginBinding flutterPluginBinding) {
channel = new MethodChannel(flutterPluginBinding.getBinaryMessenger(), "zhiying_live_ali");
channel.setMethodCallHandler(this);
handle = new FlutterAlibcHandle(channel);
}


@Override
public void onDetachedFromEngine(@NonNull FlutterPluginBinding binding) {
channel.setMethodCallHandler(null);
} }


@Override @Override
public void onMethodCall(MethodCall call, Result result) {
public void onMethodCall(@NonNull MethodCall call, @NonNull MethodChannel.Result result) {
if (call.method.equals("getPlatformVersion")) { if (call.method.equals("getPlatformVersion")) {
result.success("Android " + android.os.Build.VERSION.RELEASE); result.success("Android " + android.os.Build.VERSION.RELEASE);
} else if (call.method.equals("initAlibc")){ } else if (call.method.equals("initAlibc")){


+ 1
- 1
example/.flutter-plugins-dependencies View File

@@ -1 +1 @@
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"flutter_alibc","path":"/Users/fnuouser/Documents/code/zhiying/zhiying_flutter_alibc/","dependencies":[]}],"android":[{"name":"flutter_alibc","path":"/Users/fnuouser/Documents/code/zhiying/zhiying_flutter_alibc/","dependencies":[]}],"macos":[],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"flutter_alibc","dependencies":[]}],"date_created":"2022-03-30 14:23:23.445986","version":"2.10.3"}
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"flutter_alibc","path":"/Users/fnuouser/Documents/code/zhiying/zhiying_flutter_alibc/","dependencies":[]}],"android":[{"name":"flutter_alibc","path":"/Users/fnuouser/Documents/code/zhiying/zhiying_flutter_alibc/","dependencies":[]}],"macos":[],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"flutter_alibc","dependencies":[]}],"date_created":"2022-03-31 17:14:41.211674","version":"2.10.3"}

+ 2
- 1
example/android/app/src/main/AndroidManifest.xml View File

@@ -8,7 +8,7 @@
additional functionality it is fine to subclass or reimplement additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. --> FlutterApplication and put your custom class here. -->
<application <application
android:name="io.flutter.app.FlutterApplication"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher" android:icon="@mipmap/ic_launcher"
android:label="flutter_alibc_example" android:label="flutter_alibc_example"
tools:replace="android:label"> tools:replace="android:label">
@@ -23,6 +23,7 @@
until Flutter renders its first frame. It can be removed if until Flutter renders its first frame. It can be removed if
there is no splash screen (such as the default splash screen there is no splash screen (such as the default splash screen
defined in @style/LaunchTheme). --> defined in @style/LaunchTheme). -->
<meta-data android:name="flutterEmbedding" android:value="2"/>
<meta-data <meta-data
android:name="io.flutter.app.android.SplashScreenUntilFirstFrame" android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
android:value="true" /> android:value="true" />


+ 2
- 8
example/android/app/src/main/java/wxwx/com/flutter_alibc_example/MainActivity.java View File

@@ -1,13 +1,7 @@
package wxwx.com.flutter_alibc_example; package wxwx.com.flutter_alibc_example;


import android.os.Bundle;
import io.flutter.app.FlutterActivity;
import io.flutter.plugins.GeneratedPluginRegistrant;
import io.flutter.embedding.android.FlutterActivity;


public class MainActivity extends FlutterActivity { public class MainActivity extends FlutterActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
GeneratedPluginRegistrant.registerWith(this);
}

} }

+ 4
- 0
example/android/app/src/main/res/values/styles.xml View File

@@ -5,4 +5,8 @@
Flutter draws its first frame --> Flutter draws its first frame -->
<item name="android:windowBackground">@drawable/launch_background</item> <item name="android:windowBackground">@drawable/launch_background</item>
</style> </style>

<style name="NormalTheme" parent="@android:style/Theme.Black.NoTitleBar">
<item name="android:windowBackground">@drawable/launch_background</item>
</style>
</resources> </resources>

+ 1
- 0
example/android/build.gradle View File

@@ -1,6 +1,7 @@
buildscript { buildscript {
repositories { repositories {
google() google()
jcenter()
} }


dependencies { dependencies {


Loading…
Cancel
Save