Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Pull Request] 设置界面日志相关更新; 更新版本规则 #28

Merged
merged 8 commits into from
Mar 12, 2023
9 changes: 5 additions & 4 deletions kitx_mobile/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ if (flutterVersionName == null) {
flutterVersionName = '1.0'
}

def majorVersion = "1.0.0"
def majorVersion = "3.23.04"
def majorVersionCode = 100000
def buildVersionCode = ((new Date().getTime() - new Date("6/6/2005").getTime()) / 86400000 - 9 as int)

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
Expand All @@ -46,14 +47,14 @@ android {
}

defaultConfig {
applicationId "com.crequency.kitx.kitx_mobile"
applicationId "com.crequency.kitx.mobile"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
minSdkVersion 21
compileSdkVersion 33
targetSdkVersion 33
versionCode majorVersionCode + (new Date (new Date().getTime() - new Date("1/1/2022").getTime()).getTime() / 86400000 as int)
versionName "v" + majorVersion + ".dev." + (new Date (new Date().getTime() - new Date("1/1/2022").getTime()).getTime() / 86400000 as int)
versionCode majorVersionCode + buildVersionCode
versionName "v" + majorVersion + "." + buildVersionCode
}

buildTypes {
Expand Down
6 changes: 3 additions & 3 deletions kitx_mobile/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ allprojects {
// mavenCentral()
}
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
}
}
}
}

rootProject.buildDir = '../build'
subprojects {
Expand Down
61 changes: 48 additions & 13 deletions kitx_mobile/lib/pages/settings_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,21 @@ class SettingsPage extends StatefulWidget {

class _SettingsPageState extends State<SettingsPage> {
var selectedModes = <ThemeMode>{Global.themeModeNotifier.value};
var logFilePath = '/data/data/com.crequency.kitx.kitx_mobile/app_flutter/flog.db';
var logFilePath = '/data/data/com.crequency.kitx.mobile/app_flutter/flog.db';

var useMaterial3 = lightThemeData.value.useMaterial3.obs;
var logFileSizeString = 'getting ...'.obs;
var logFileExists = false.obs;

void updateLogFileSizeString() {
var file = File(logFilePath);
logFileSizeString.value = convert2string(file.lengthSync());
if (file.existsSync()) {
logFileSizeString.value = convert2string(file.lengthSync());
logFileExists.value = true;
} else {
logFileSizeString.value = 'File $logFilePath don\'t exists';
logFileExists.value = false;
}
}

void showSnackBar(Widget content, {Duration? duration}) {
Expand Down Expand Up @@ -191,7 +198,14 @@ class _SettingsPageState extends State<SettingsPage> {
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Obx(() => Text(logFileSizeString.value)),
Obx(
() => AnimatedContainer(
duration: Duration(milliseconds: 700),
curve: Curves.easeInOutCubic,
width: logFileExists.value ? null : MediaQuery.of(context).size.width / 3 * 2,
child: Text(logFileSizeString.value),
),
),
SizedBox(width: 10),
IconButton(
onPressed: updateLogFileSizeString,
Expand All @@ -203,21 +217,42 @@ class _SettingsPageState extends State<SettingsPage> {
Container(
alignment: Alignment.center,
child: ElevatedButton(
onPressed: () async {
Global.delay(() async {
var file = File(logFilePath);
var beforeSize = file.lengthSync();
var beforeSizeString = convert2string(beforeSize);
onPressed: () => Global.delay(() async {
var beforeSize = 0;
var beforeSizeString = convert2string(beforeSize);
var nowSize = 0;
var nowSizeString = convert2string(nowSize);

var file = File(logFilePath);

if (file.existsSync()) {
logFileExists.value = true;

beforeSize = file.lengthSync();
beforeSizeString = convert2string(beforeSize);
}

if (logFileExists.value) {
await FLog.clearLogs();
} else {
FLog.clearLogs();
}

file = File(logFilePath);

file = File(logFilePath);
var nowSize = file.lengthSync();
var nowSizeString = convert2string(nowSize);
if (logFileExists.value) {
nowSize = file.lengthSync();
nowSizeString = convert2string(nowSize);
}

updateLogFileSizeString();

if (logFileExists.value) {
showSnackBar(Text('$beforeSizeString -> $nowSizeString'));
}, 200);
},
} else {
showSnackBar(Text('Log file clean action requested.'));
}
}, 200),
child: Text('SettingsPage_CleanLog'.tr),
),
),
Expand Down