Skip to content

Commit 4c70dca

Browse files
committed
适配 1.12.13+hotfix.6
1 parent 8ddd6b0 commit 4c70dca

File tree

19 files changed

+399
-247
lines changed

19 files changed

+399
-247
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
build/
88

99
.flutter-plugins
10+
.flutter-plugins-dependencies
1011

1112
*.iml
1213

.metadata

+4-2
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,7 @@
44
# This file should be version controlled and should not be manually edited.
55

66
version:
7-
revision: c7ea3ca377e909469c68f2ab878a5bc53d3cf66b
8-
channel: beta
7+
revision: 18cd7a3601bcffb36fdf2f679f763b5e827c2e8e
8+
channel: unknown
9+
10+
project_type: app

android/app/build.gradle

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ android {
3333
targetSdkVersion 28
3434
versionCode 30
3535
versionName "1.6.8"
36-
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
36+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
3737
}
3838

3939

@@ -72,6 +72,6 @@ flutter {
7272
dependencies {
7373
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
7474
testImplementation 'junit:junit:4.12'
75-
androidTestImplementation 'com.android.support.test:runner:1.0.1'
76-
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
75+
androidTestImplementation 'androidx.test:runner:1.1.1'
76+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
7777
}

android/app/src/main/AndroidManifest.xml

+11-6
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,22 @@
2424
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density"
2525
android:hardwareAccelerated="true"
2626
android:windowSoftInputMode="adjustResize">
27-
<!-- This keeps the window background of the activity showing
28-
until Flutter renders its first frame. It can be removed if
29-
there is no splash screen (such as the default splash screen
30-
defined in @style/LaunchTheme). -->
3127
<meta-data
32-
android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
33-
android:value="true" />
28+
android:name="io.flutter.embedding.android.SplashScreenDrawable"
29+
android:resource="@drawable/launch_background" />
30+
<meta-data
31+
android:name="io.flutter.embedding.android.NormalTheme"
32+
android:resource="@style/NormalTheme"
33+
/>
3434
<intent-filter>
3535
<action android:name="android.intent.action.MAIN"/>
3636
<category android:name="android.intent.category.LAUNCHER"/>
3737
</intent-filter>
3838
</activity>
39+
<!-- Don't delete the meta-data below.
40+
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
41+
<meta-data
42+
android:name="flutterEmbedding"
43+
android:value="2" />
3944
</application>
4045
</manifest>
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
package com.shuyu.gsygithub.gsygithubappflutter
22

3-
import android.os.Bundle
4-
5-
import io.flutter.app.FlutterActivity
3+
import UpdateAlbumPlugin
4+
import androidx.annotation.NonNull;
5+
import io.flutter.embedding.android.FlutterActivity
6+
import io.flutter.embedding.engine.FlutterEngine
67
import io.flutter.plugins.GeneratedPluginRegistrant
78

8-
class MainActivity(): FlutterActivity() {
9-
override fun onCreate(savedInstanceState: Bundle?) {
10-
super.onCreate(savedInstanceState)
11-
GeneratedPluginRegistrant.registerWith(this)
12-
UpdateAlbumPlugin.register(this, flutterView)
9+
class MainActivity: FlutterActivity() {
10+
override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
11+
GeneratedPluginRegistrant.registerWith(flutterEngine)
12+
flutterEngine.plugins.add(UpdateAlbumPlugin())
1313
}
1414
}

android/app/src/main/kotlin/com/shuyu/gsygithub/gsygithubappflutter/UpdateAlbumPlugin.kt

+36-15
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,56 @@ import android.content.Context
22
import android.content.Intent
33
import android.net.Uri
44
import android.provider.MediaStore
5-
import io.flutter.plugin.common.BinaryMessenger
5+
import io.flutter.embedding.engine.plugins.FlutterPlugin
6+
import io.flutter.plugin.common.MethodCall
67
import io.flutter.plugin.common.MethodChannel
8+
import io.flutter.plugin.common.PluginRegistry.Registrar
79

8-
object UpdateAlbumPlugin {
10+
class UpdateAlbumPlugin : FlutterPlugin, MethodChannel.MethodCallHandler {
911

1012
/** Channel名称 **/
11-
private const val ChannelName = "com.shuyu.gsygithub.gsygithubflutter/UpdateAlbumPlugin"
12-
13-
/**
14-
* 注册Toast插件
15-
* @param context 上下文对象
16-
* @param messenger 数据信息交流对象
17-
*/
18-
@JvmStatic
19-
fun register(context: Context, messenger: BinaryMessenger) = MethodChannel(messenger, ChannelName).setMethodCallHandler { methodCall, result ->
13+
14+
private var channel: MethodChannel? = null
15+
private var context: Context? = null
16+
17+
companion object {
18+
19+
private val sChannelName = "com.shuyu.gsygithub.gsygithubflutter/UpdateAlbumPlugin"
20+
21+
fun registerWith(registrar: Registrar) {
22+
val instance = UpdateAlbumPlugin()
23+
instance.channel = MethodChannel(registrar.messenger(), sChannelName)
24+
instance.context = registrar.context()
25+
instance.channel?.setMethodCallHandler(instance)
26+
}
27+
}
28+
29+
override fun onAttachedToEngine(binding: FlutterPlugin.FlutterPluginBinding) {
30+
channel = MethodChannel(
31+
binding.flutterEngine.dartExecutor, sChannelName)
32+
context = binding.applicationContext
33+
channel!!.setMethodCallHandler(this)
34+
}
35+
36+
override fun onDetachedFromEngine(binding: FlutterPlugin.FlutterPluginBinding) {
37+
channel?.setMethodCallHandler(null)
38+
channel = null
39+
}
40+
41+
override fun onMethodCall(methodCall: MethodCall, result: MethodChannel.Result) {
2042
when (methodCall.method) {
2143
"updateAlbum" -> {
2244
val path: String? = methodCall.argument("path")
2345
val name: String? = methodCall.argument("name")
2446
try {
25-
MediaStore.Images.Media.insertImage(context.contentResolver, path, name, null)
47+
MediaStore.Images.Media.insertImage(context?.contentResolver, path, name, null)
2648
} catch (e: Exception) {
2749
e.printStackTrace()
2850
}
2951
// 最后通知图库更新
30-
context.sendBroadcast(Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.parse("file://$path")))
52+
context?.sendBroadcast(Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.parse("file://$path")))
3153
}
3254
}
33-
result.success(null) //没有返回值,所以直接返回为null
55+
result.success(null)
3456
}
35-
3657
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- Modify this file to customize your launch splash screen -->
3+
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
4+
<item android:drawable="@android:color/white" />
5+
</layer-list>

android/app/src/main/res/values/styles.xml

+3
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,7 @@
55
Flutter draws its first frame -->
66
<item name="android:windowBackground">@drawable/launch_background</item>
77
</style>
8+
<style name="NormalTheme" parent="@android:style/Theme.Black.NoTitleBar">
9+
<item name="android:windowBackground">@drawable/normal_background</item>
10+
</style>
811
</resources>

android/build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
buildscript {
2-
ext.kotlin_version = '1.2.71'
2+
ext.kotlin_version = '1.3.50'
33
repositories {
44
google()
55
jcenter()
66
}
77

88
dependencies {
9-
classpath 'com.android.tools.build:gradle:3.2.0'
9+
classpath 'com.android.tools.build:gradle:3.5.0'
1010
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1111
}
1212
}

android/gradle.properties

+3
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
org.gradle.jvmargs=-Xmx1536M
2+
android.enableR8=true
3+
android.useAndroidX=true
4+
android.enableJetifier=true

android/gradle/wrapper/gradle-wrapper.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip

ios/Podfile

+59-34
Original file line numberDiff line numberDiff line change
@@ -4,58 +4,83 @@
44
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
55
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
66

7+
project 'Runner', {
8+
'Debug' => :debug,
9+
'Profile' => :release,
10+
'Release' => :release,
11+
}
12+
713
def parse_KV_file(file, separator='=')
814
file_abs_path = File.expand_path(file)
915
if !File.exists? file_abs_path
1016
return [];
1117
end
12-
pods_ary = []
18+
generated_key_values = {}
1319
skip_line_start_symbols = ["#", "/"]
14-
File.foreach(file_abs_path) { |line|
15-
next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ }
16-
plugin = line.split(pattern=separator)
17-
if plugin.length == 2
18-
podname = plugin[0].strip()
19-
path = plugin[1].strip()
20-
podpath = File.expand_path("#{path}", file_abs_path)
21-
pods_ary.push({:name => podname, :path => podpath});
22-
else
23-
puts "Invalid plugin specification: #{line}"
24-
end
25-
}
26-
return pods_ary
20+
File.foreach(file_abs_path) do |line|
21+
next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ }
22+
plugin = line.split(pattern=separator)
23+
if plugin.length == 2
24+
podname = plugin[0].strip()
25+
path = plugin[1].strip()
26+
podpath = File.expand_path("#{path}", file_abs_path)
27+
generated_key_values[podname] = podpath
28+
else
29+
puts "Invalid plugin specification: #{line}"
30+
end
31+
end
32+
generated_key_values
2733
end
2834

2935
target 'Runner' do
3036
use_frameworks!
37+
use_modular_headers!
3138

32-
# Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
33-
# referring to absolute paths on developers' machines.
34-
system('rm -rf .symlinks')
35-
system('mkdir -p .symlinks/plugins')
39+
# Flutter Pod
3640

37-
# Flutter Pods
38-
generated_xcode_build_settings = parse_KV_file('./Flutter/Generated.xcconfig')
39-
if generated_xcode_build_settings.empty?
40-
puts "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter packages get is executed first."
41-
end
42-
generated_xcode_build_settings.map { |p|
43-
if p[:name] == 'FLUTTER_FRAMEWORK_DIR'
44-
symlink = File.join('.symlinks', 'flutter')
45-
File.symlink(File.dirname(p[:path]), symlink)
46-
pod 'Flutter', :path => File.join(symlink, File.basename(p[:path]))
41+
copied_flutter_dir = File.join(__dir__, 'Flutter')
42+
copied_framework_path = File.join(copied_flutter_dir, 'Flutter.framework')
43+
copied_podspec_path = File.join(copied_flutter_dir, 'Flutter.podspec')
44+
unless File.exist?(copied_framework_path) && File.exist?(copied_podspec_path)
45+
# Copy Flutter.framework and Flutter.podspec to Flutter/ to have something to link against if the xcode backend script has not run yet.
46+
# That script will copy the correct debug/profile/release version of the framework based on the currently selected Xcode configuration.
47+
# CocoaPods will not embed the framework on pod install (before any build phases can generate) if the dylib does not exist.
48+
49+
generated_xcode_build_settings_path = File.join(copied_flutter_dir, 'Generated.xcconfig')
50+
unless File.exist?(generated_xcode_build_settings_path)
51+
raise "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter pub get is executed first"
4752
end
48-
}
53+
generated_xcode_build_settings = parse_KV_file(generated_xcode_build_settings_path)
54+
cached_framework_dir = generated_xcode_build_settings['FLUTTER_FRAMEWORK_DIR'];
55+
56+
unless File.exist?(copied_framework_path)
57+
FileUtils.cp_r(File.join(cached_framework_dir, 'Flutter.framework'), copied_flutter_dir)
58+
end
59+
unless File.exist?(copied_podspec_path)
60+
FileUtils.cp(File.join(cached_framework_dir, 'Flutter.podspec'), copied_flutter_dir)
61+
end
62+
end
63+
64+
# Keep pod path relative so it can be checked into Podfile.lock.
65+
pod 'Flutter', :path => 'Flutter'
4966

5067
# Plugin Pods
68+
69+
# Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
70+
# referring to absolute paths on developers' machines.
71+
system('rm -rf .symlinks')
72+
system('mkdir -p .symlinks/plugins')
5173
plugin_pods = parse_KV_file('../.flutter-plugins')
52-
plugin_pods.map { |p|
53-
symlink = File.join('.symlinks', 'plugins', p[:name])
54-
File.symlink(p[:path], symlink)
55-
pod p[:name], :path => File.join(symlink, 'ios')
56-
}
74+
plugin_pods.each do |name, path|
75+
symlink = File.join('.symlinks', 'plugins', name)
76+
File.symlink(path, symlink)
77+
pod name, :path => File.join(symlink, 'ios')
78+
end
5779
end
5880

81+
# Prevent Cocoapods from embedding a second Flutter framework and causing an error with the new Xcode build system.
82+
install! 'cocoapods', :disable_input_output_paths => true
83+
5984
post_install do |installer|
6085
installer.pods_project.targets.each do |target|
6186
target.build_configurations.each do |config|

0 commit comments

Comments
 (0)