Explorar el Código

1、Android的启动优化

2、Android的状态栏的优化
tags/0.0.1
PH2 hace 4 años
padre
commit
41fa258191
Se han modificado 3 ficheros con 78 adiciones y 32 borrados
  1. +6
    -6
      example/android/app/build.gradle
  2. +16
    -9
      example/android/app/src/main/AndroidManifest.xml
  3. +56
    -17
      example/android/app/src/main/java/cn/zhios/zhiying_base_widget_example/MainActivity.java

+ 6
- 6
example/android/app/build.gradle Ver fichero

@@ -34,7 +34,7 @@ apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"


android {
compileSdkVersion 29
compileSdkVersion 28

lintOptions {
disable 'InvalidPackage'
@@ -44,7 +44,7 @@ android {
defaultConfig {
applicationId "cn.zhios.zhiying"
minSdkVersion 21
targetSdkVersion 29
targetSdkVersion 28
versionCode 1
versionName "1.0"
aaptOptions.cruncherEnabled = false
@@ -90,7 +90,7 @@ android {



//
// // 签名配置
// signingConfigs {
// // 智夜生活
@@ -113,14 +113,14 @@ android {
// // 智夜生活
// zhiying {
// applicationId "cn.zhios.zhiying"
// versionCode 1
// versionCode 3
// dimension "app"
// versionName '1.0.0'
// versionName '1.0.3'
// // 签名信息
// signingConfig signingConfigs.zhiying
// }
// }
//
// // 打包脚本
// android.applicationVariants.all { variant ->
// if (variant.buildType.name != "debug") {


+ 16
- 9
example/android/app/src/main/AndroidManifest.xml Ver fichero

@@ -13,15 +13,15 @@
android:label="@string/app_name"
android:usesCleartextTraffic="true"
tools:replace="android:name">
<activity android:name=".WebActivity"></activity>
<activity android:name=".WebActivity" />
<activity
android:name=".TestActivity"
android:theme="@style/Theme.AppCompat.NoActionBar">
<!-- <intent-filter>-->
<!-- <action android:name="android.intent.action.MAIN" />-->
<!-- <intent-filter>-->
<!-- <action android:name="android.intent.action.MAIN" />-->

<!-- <category android:name="android.intent.category.LAUNCHER" />-->
<!-- </intent-filter>-->
<!-- <category android:name="android.intent.category.LAUNCHER" />-->
<!-- </intent-filter>-->
</activity>
<activity
android:name=".MainActivity"
@@ -32,12 +32,19 @@
android:usesCleartextTraffic="true"
android:windowSoftInputMode="adjustResize">

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


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

<meta-data
android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
android:value="true" />
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="@drawable/launch_background" />
</activity>
<!--
Don't delete the meta-data below.


+ 56
- 17
example/android/app/src/main/java/cn/zhios/zhiying_base_widget_example/MainActivity.java Ver fichero

@@ -1,6 +1,14 @@
package cn.zhios.zhiying_base_widget_example;

import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Build;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import java.util.HashMap;
import java.util.Map;
@@ -9,16 +17,47 @@ import cn.zhios.zhiying_comm.ZhiyingFlutterCommHandler;
import cn.zhios.zhiying_comm.ZhiyingFlutterCommNativable;
import cn.zhios.zhiying_comm.ZhiyingFlutterCommNative;
import io.flutter.embedding.android.FlutterActivity;
import io.flutter.embedding.android.FlutterActivityLaunchConfigs;
import io.flutter.embedding.engine.FlutterEngine;
import io.flutter.plugin.platform.PlatformPlugin;
import io.flutter.plugins.GeneratedPluginRegistrant;

public class MainActivity extends FlutterActivity implements ZhiyingFlutterCommNativable {

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {

super.onCreate(savedInstanceState);
configureWindowForTransparency();
configureStatusBarForFullscreenFlutterExperience();
}

@Override
public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) {
GeneratedPluginRegistrant.registerWith(flutterEngine);
ZhiyingFlutterCommNative.getInstance().regist(this);
}

private void configureWindowForTransparency() {
FlutterActivityLaunchConfigs.BackgroundMode backgroundMode = getBackgroundMode();
if (backgroundMode == FlutterActivityLaunchConfigs.BackgroundMode.transparent) {
getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
getWindow().setFlags(
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
);
}
}

private void configureStatusBarForFullscreenFlutterExperience() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Window window = getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(Color.TRANSPARENT);
window.getDecorView().setSystemUiVisibility(PlatformPlugin.DEFAULT_SYSTEM_UI);
}
}


boolean localDebug = false;

@@ -32,25 +71,25 @@ public class MainActivity extends FlutterActivity implements ZhiyingFlutterCommN

}

@Override
public Map getSetting() {
Map map = new HashMap();
map.put("domain", "http://inapi.izhyin.cn"); //"http://120.76.175.204:8989");
@Override
public Map getSetting() {
Map map = new HashMap();
map.put("domain", "http://inapi.izhyin.cn"); //"http://120.76.175.204:8989");
// map.put("domain", "http://192.168.0.113:5000");
map.put("master_id", "123456");
map.put("secret_key", "123456");
map.put("master_id", "123456");
map.put("secret_key", "123456");
// map.put("token", "123465");
return map;
}
return map;
}

@Override
public void invokeMethod(String method, Map<String, Object> params, ZhiyingFlutterCommHandler handler) {
return;
}
@Override
public void invokeMethod(String method, Map<String, Object> params, ZhiyingFlutterCommHandler handler) {
return;
}

@Override
protected void onDestroy() {
super.onDestroy();
ZhiyingFlutterCommNative.getInstance().unregist();
}
@Override
protected void onDestroy() {
super.onDestroy();
ZhiyingFlutterCommNative.getInstance().unregist();
}
}

Cargando…
Cancelar
Guardar