Parcourir la source

升级安卓v2

tags/0.1.0^0
Weller il y a 2 ans
Parent
révision
e54ad9c9c0
8 fichiers modifiés avec 53 ajouts et 36 suppressions
  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 Voir le fichier

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


+ 16
- 15
android/src/main/java/com/wxwx/flutter_alibc/FlutterAlibcHandle.java Voir le fichier

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

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

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.Registrar;
import io.flutter.plugin.common.MethodChannel.Result;
@@ -17,8 +14,6 @@ import io.flutter.plugin.common.MethodCall;

import java.util.HashMap;

import android.app.AlertDialog;

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

private static FlutterAlibcHandle handle;
private MethodChannel channel;

// private static FlutterAlibcHandle handle;
private static Registrar register;
private static boolean isFirst = true;
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 Voir le fichier

@@ -1,24 +1,40 @@
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.MethodChannel;
import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
import io.flutter.plugin.common.MethodChannel.Result;
import io.flutter.plugin.common.PluginRegistry.Registrar;

/** 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. */
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
public void onMethodCall(MethodCall call, Result result) {
public void onMethodCall(@NonNull MethodCall call, @NonNull MethodChannel.Result result) {
if (call.method.equals("getPlatformVersion")) {
result.success("Android " + android.os.Build.VERSION.RELEASE);
} else if (call.method.equals("initAlibc")){


+ 1
- 1
example/.flutter-plugins-dependencies Voir le fichier

@@ -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 Voir le fichier

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


+ 2
- 8
example/android/app/src/main/java/wxwx/com/flutter_alibc_example/MainActivity.java Voir le fichier

@@ -1,13 +1,7 @@
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 {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
GeneratedPluginRegistrant.registerWith(this);
}

}

+ 4
- 0
example/android/app/src/main/res/values/styles.xml Voir le fichier

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

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

+ 1
- 0
example/android/build.gradle Voir le fichier

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

dependencies {


Chargement…
Annuler
Enregistrer