Skip to content

Commit 3218d00

Browse files
authored
Merge pull request alibaba#215 from DeckeDeng/develop
Develop
2 parents 5c5a601 + 49f7c70 commit 3218d00

File tree

15 files changed

+285
-121
lines changed

15 files changed

+285
-121
lines changed

android/app/release/output.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":1,"versionName":"0.0.5","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]
1+
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":1,"versionName":"1.0.6","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]

android/app/src/main/AndroidManifest.xml

+29-1
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@
1010
<uses-permission android:name="android.permission.INTERNET"/>
1111
<uses-permission android:name="android.permission.MODE_WORLD_READABLE"/>
1212
<uses-permission android:name="android.permission.MODE_WORLD_WRITEABLE"/>
13+
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
1314

1415
<application
1516
android:name="io.flutter.app.FlutterApplication"
16-
android:label="fluttergo"
17+
android:label="FlutterGo"
1718
android:icon="@mipmap/ic_launcher_logo">
1819
<activity
1920
android:name=".MainActivity"
@@ -34,5 +35,32 @@
3435
<category android:name="android.intent.category.LAUNCHER"/>
3536
</intent-filter>
3637
</activity>
38+
39+
40+
<provider
41+
android:name="vn.hunghd.flutterdownloader.DownloadedFileProvider"
42+
android:authorities="${applicationId}.flutter_downloader.provider"
43+
android:exported="false"
44+
android:grantUriPermissions="true">
45+
<meta-data
46+
android:name="android.support.FILE_PROVIDER_PATHS"
47+
android:resource="@xml/provider_paths"/>
48+
</provider>
49+
50+
<provider
51+
android:name="androidx.work.impl.WorkManagerInitializer"
52+
android:authorities="${applicationId}.workmanager-init"
53+
android:enabled="false"
54+
android:exported="false" />
55+
56+
<provider
57+
android:name="vn.hunghd.flutterdownloader.FlutterDownloaderInitializer"
58+
android:authorities="${applicationId}.flutter-downloader-init"
59+
android:exported="false">
60+
<meta-data
61+
android:name="vn.hunghd.flutterdownloader.MAX_CONCURRENT_TASKS"
62+
android:value="5" />
63+
</provider>
64+
3765
</application>
3866
</manifest>

app-release.apk

15.6 MB
Binary file not shown.

ios/Runner.xcodeproj/project.pbxproj

+19
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@
222222
9705A1C41CF9048500538489 /* Embed Frameworks */,
223223
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
224224
C38E5EAE601417DA9DF11753 /* [CP] Embed Pods Frameworks */,
225+
2432F011A7D713E4BFB3DC88 /* [CP] Copy Pods Resources */,
225226
);
226227
buildRules = (
227228
);
@@ -300,6 +301,24 @@
300301
/* End PBXResourcesBuildPhase section */
301302

302303
/* Begin PBXShellScriptBuildPhase section */
304+
2432F011A7D713E4BFB3DC88 /* [CP] Copy Pods Resources */ = {
305+
isa = PBXShellScriptBuildPhase;
306+
buildActionMask = 2147483647;
307+
files = (
308+
);
309+
inputPaths = (
310+
"${SRCROOT}/Pods/Target Support Files/Pods-Runner/Pods-Runner-resources.sh",
311+
"${PODS_CONFIGURATION_BUILD_DIR}/flutter_downloader/FlutterDownloaderDatabase.bundle",
312+
);
313+
name = "[CP] Copy Pods Resources";
314+
outputPaths = (
315+
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/FlutterDownloaderDatabase.bundle",
316+
);
317+
runOnlyForDeploymentPostprocessing = 0;
318+
shellPath = /bin/sh;
319+
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Runner/Pods-Runner-resources.sh\"\n";
320+
showEnvVarsInLog = 0;
321+
};
303322
3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
304323
isa = PBXShellScriptBuildPhase;
305324
buildActionMask = 2147483647;

ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
</AdditionalOptions>
4343
</TestAction>
4444
<LaunchAction
45-
buildConfiguration = "Release"
45+
buildConfiguration = "Debug"
4646
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
4747
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
4848
launchStyle = "0"

lib/api/api.dart

+2
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,6 @@ class Api{
77
static const String CHECK_LOGIN = BASE_URL+'checkLogin';//验证登陆
88

99
static const String LOGOUT = BASE_URL+'logout';//退出登陆
10+
11+
static const String VERSION = BASE_URL+'getAppVersion';//检查版本
1012
}

lib/main.dart

+43-16
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
import 'dart:async';
2+
import 'dart:core';
3+
14
import 'package:flutter/material.dart';
25
import 'package:fluro/fluro.dart';
36
import 'package:flutter/rendering.dart';
7+
import 'package:url_launcher/url_launcher.dart';
48
import 'routers/routers.dart';
59
import 'routers/application.dart';
610
import 'package:flutter_spinkit/flutter_spinkit.dart';
@@ -36,14 +40,26 @@ class _MyAppState extends State<MyApp> {
3640
bool _isLoading = true;
3741

3842
@override
39-
void initState() {
43+
Future initState() {
4044
super.initState();
45+
var platformAandroid =
46+
(Theme.of(context).platform == TargetPlatform.android);
47+
DataUtils.checkVersion({'name': 'FlutterGo'}).then((bool) {
48+
print("返回值back ${bool}");
49+
if (platformAandroid && bool) {
50+
setState(() {});
51+
_UpdateURL();
52+
}
53+
}).catchError((onError) {
54+
print('获取失败:$onError');
55+
});
56+
4157
DataUtils.checkLogin().then((hasLogin) {
4258
setState(() {
4359
_hasLogin = hasLogin;
4460
_isLoading = false;
4561
});
46-
}).catchError((onError){
62+
}).catchError((onError) {
4763
setState(() {
4864
_hasLogin = true;
4965
_isLoading = false;
@@ -52,24 +68,34 @@ class _MyAppState extends State<MyApp> {
5268
});
5369
}
5470

55-
showWelcomePage() {
56-
if (_isLoading) {
57-
return Container(
58-
color: const Color(ThemeColor),
59-
child: Center(
60-
child: SpinKitPouringHourglass(color: Colors.white),
61-
),
62-
);
71+
_UpdateURL() async {
72+
const currUrl =
73+
'https://github.com/alibaba/flutter-go/raw/master/FlutterGo.apk';
74+
if (await canLaunch(currUrl)) {
75+
await launch(currUrl);
6376
} else {
64-
// 判断是否已经登录
65-
if (_hasLogin) {
66-
return AppPage();
67-
} else {
68-
return LoginPage();
69-
}
77+
throw 'Could not launch $currUrl';
7078
}
7179
}
7280

81+
showWelcomePage() {
82+
// if (_isLoading) {
83+
// return Container(
84+
// color: const Color(ThemeColor),
85+
// child: Center(
86+
// child: SpinKitPouringHourglass(color: Colors.white),
87+
// ),
88+
// );
89+
// } else {
90+
// // 判断是否已经登录
91+
// if (_hasLogin) {
92+
return AppPage();
93+
// } else {
94+
// return LoginPage();
95+
// }
96+
// }
97+
}
98+
7399
@override
74100
Widget build(BuildContext context) {
75101
return new MaterialApp(
@@ -88,6 +114,7 @@ class _MyAppState extends State<MyApp> {
88114
),
89115
),
90116
home: new Scaffold(body: showWelcomePage()),
117+
//去掉debug logo
91118
debugShowCheckedModeBanner: false,
92119
onGenerateRoute: Application.router.generator,
93120
navigatorObservers: <NavigatorObserver>[Analytics.observer],

lib/model/user_info_cache.dart

+2
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,6 @@ class UserInfoControlModel {
5959
Future deleteAll() async{
6060
return await sql.deleteAll();
6161
}
62+
63+
6264
}

lib/model/version.dart

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
class Data {
2+
String version;
3+
String name;
4+
5+
Data.fromJson(Map<String, dynamic> json)
6+
: version = json['version'],
7+
name = json['name'];
8+
9+
@override
10+
String toString() {
11+
return 'name: $name ,version: $version';
12+
}
13+
}
14+
15+
class Version {
16+
Data data;
17+
int status;
18+
bool success;
19+
20+
Version.formJson(Map<String, dynamic> json)
21+
: status = json['status'],
22+
success = json['success'],
23+
data = Data.fromJson(json['data']);
24+
25+
@override
26+
String toString() {
27+
return 'status: $status ,success: $success,date: ${data.toString()}';
28+
}
29+
}

lib/utils/data_utils.dart

+29-6
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,53 @@
11
import 'dart:async' show Future;
22

3+
import 'package:flutter_go/model/version.dart';
4+
import 'package:package_info/package_info.dart';
5+
import 'package:url_launcher/url_launcher.dart';
6+
37
import './net_utils.dart';
48
import '../model/user_info.dart';
59
import 'package:flutter_go/api/api.dart';
610

7-
8-
class DataUtils{
11+
class DataUtils {
912
// 登陆获取用户信息
10-
static Future<UserInfo> doLogin(Map<String,String> params) async{
13+
static Future<UserInfo> doLogin(Map<String, String> params) async {
1114
var response = await NetUtils.post(Api.DO_LOGIN, params);
1215
UserInfo userInfo = UserInfo.fromJson(response['data']);
1316
return userInfo;
1417
}
1518

1619
// 验证登陆
1720

18-
static Future<bool> checkLogin() async{
21+
static Future<bool> checkLogin() async {
1922
var response = await NetUtils.get(Api.CHECK_LOGIN);
2023
print('验证登陆:$response');
2124
return response['success'];
2225
}
2326

2427
// 退出登陆
25-
static Future<bool> logout() async{
28+
static Future<bool> logout() async {
2629
var response = await NetUtils.get(Api.LOGOUT);
2730
print('退出登陆 $response');
2831
return response['success'];
2932
}
30-
}
33+
34+
/**
35+
* {"status":200,"data":{"version":"0.0.2","name":"FlutterGo"},"success":true}
36+
*/
37+
// 检查版本
38+
static Future<bool> checkVersion(Map<String, String> params) async {
39+
var response = await NetUtils.get(Api.VERSION, params);
40+
Version version = Version.formJson(response);
41+
var currVersion = version.data.version;
42+
PackageInfo packageInfo = await PackageInfo.fromPlatform();
43+
var localVersion = packageInfo.version;
44+
//相同=0、大于=1、小于=-1
45+
// localVersion = '0.0.2';
46+
// currVersion = '1.0.6';
47+
if (currVersion.compareTo(localVersion) == 1) {
48+
return true;
49+
} else {
50+
return false;
51+
}
52+
}
53+
}

lib/views/first_page/first_page.dart

+21-21
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,24 @@ class FirstPageState extends State<FirstPage> with AutomaticKeepAliveClientMixin
2626
bool get wantKeepAlive => true;
2727

2828

29-
@override
29+
@override
3030
void initState() {
3131
super.initState();
3232
if (key == null) {
33-
key = GlobalKey<DisclaimerMsgState>();
34-
// key = const Key('__RIKEY1__');
33+
key = GlobalKey<DisclaimerMsgState>();
34+
// key = const Key('__RIKEY1__');
3535
//获取sharePre
36-
_unKnow = _prefs.then((SharedPreferences prefs) {
37-
return (prefs.getBool('disclaimer::Boolean') ?? false);
38-
});
36+
_unKnow = _prefs.then((SharedPreferences prefs) {
37+
return (prefs.getBool('disclaimer::Boolean') ?? false);
38+
});
3939

4040
/// 判断是否需要弹出免责声明,已经勾选过不在显示,就不会主动弹
4141
_unKnow.then((bool value) {
42-
new Future.delayed(const Duration(seconds: 1),(){
43-
if (!value && key.currentState is DisclaimerMsgState && key.currentState.showAlertDialog is Function) {
44-
key.currentState.showAlertDialog(context);
45-
}
46-
});
42+
new Future.delayed(const Duration(seconds: 1),(){
43+
if (!value && key.currentState is DisclaimerMsgState && key.currentState.showAlertDialog is Function) {
44+
key.currentState.showAlertDialog(context);
45+
}
46+
});
4747
});
4848
}
4949
}
@@ -93,15 +93,15 @@ class FirstPageState extends State<FirstPage> with AutomaticKeepAliveClientMixin
9393
Column(
9494
children: <Widget>[
9595
Stack(
96-
//alignment: const FractionalOffset(0.9, 0.1),//方法一
97-
children: <Widget>[
98-
Pagination(),
99-
Positioned(//方法二
100-
top: 10.0,
101-
left: 0.0,
102-
child: DisclaimerMsg(key:key,pWidget:this)
103-
),
104-
]),
96+
//alignment: const FractionalOffset(0.9, 0.1),//方法一
97+
children: <Widget>[
98+
Pagination(),
99+
Positioned(//方法二
100+
top: 10.0,
101+
left: 0.0,
102+
child: DisclaimerMsg(key:key,pWidget:this)
103+
),
104+
]),
105105
SizedBox(height: 1, child:Container(color: Theme.of(context).primaryColor)),
106106
SizedBox(height: 10),
107107
],
@@ -127,7 +127,7 @@ class FirstPageState extends State<FirstPage> with AutomaticKeepAliveClientMixin
127127
// SizedBox(height: 2, child:Container(color: Theme.of(context).primaryColor)),
128128
new Expanded(
129129
//child: new List(),
130-
child: listComp.ListRefresh(getIndexListData,makeCard,headerView)
130+
child: listComp.ListRefresh(getIndexListData,makeCard,headerView)
131131
)
132132
]
133133

0 commit comments

Comments
 (0)