Skip to content

Commit

Permalink
Merge pull request #28 from Crequency/dev=dynesshely
Browse files Browse the repository at this point in the history
[Pull Request] 设置界面日志相关更新; 更新版本规则

Close Crequency/KitX#236 .
  • Loading branch information
Dynesshely committed Mar 12, 2023
2 parents 36f0512 + 5c71499 commit 1787a2f
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 20 deletions.
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

0 comments on commit 1787a2f

Please sign in to comment.