diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..603b140 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..603b140 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..88ea3aa --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,122 @@ + + + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+ + +
+
\ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..603b140 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..88ea3aa --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,122 @@ + + + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+ + +
+
\ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..603b140 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..88ea3aa --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,122 @@ + + + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+ + +
+
\ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..5cd135a --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..603b140 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..88ea3aa --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,122 @@ + + + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+ + +
+
\ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..5cd135a --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..7bfef59 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..603b140 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..88ea3aa --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,122 @@ + + + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+ + +
+
\ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..5cd135a --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..7bfef59 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..603b140 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..88ea3aa --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,122 @@ + + + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+ + +
+
\ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..5cd135a --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..7bfef59 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..603b140 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..88ea3aa --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,122 @@ + + + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+ + +
+
\ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..5cd135a --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..7bfef59 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..4ca4a9f --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,67 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' + +android { + compileSdkVersion 30 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.birmm.inspect" + minSdkVersion 21 + targetSdkVersion 30 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'androidx.core:core-ktx:1.3.2' + implementation 'androidx.constraintlayout:constraintlayout:2.0.4' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test.ext:junit:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:1.3.0' + //腾讯Android UI框架 + implementation 'com.qmuiteam:qmui:2.0.0-alpha10' + implementation 'com.qmuiteam:arch:0.3.1' + //沉浸式状态栏。基础依赖包,必须要依赖 + implementation 'com.gyf.immersionbar:immersionbar:3.0.0' + //fragment快速实现 + implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + + //MVP网络请求框架retrofit2+rxjava + implementation 'io.reactivex:rxjava:1.3.8' + implementation 'io.reactivex:rxandroid:1.2.1' + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.6.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + implementation 'com.squareup.retrofit2:adapter-rxjava:2.8.1' + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.8.6' + //Toast提示 + implementation 'com.sdsmdg.tastytoast:tastytoast:0.1.1' + //图片选择框架 + implementation 'com.github.LuckSiege.PictureSelector:picture_library:v2.6.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' +} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..603b140 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..88ea3aa --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,122 @@ + + + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+ + +
+
\ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..5cd135a --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..7bfef59 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..4ca4a9f --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,67 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' + +android { + compileSdkVersion 30 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.birmm.inspect" + minSdkVersion 21 + targetSdkVersion 30 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'androidx.core:core-ktx:1.3.2' + implementation 'androidx.constraintlayout:constraintlayout:2.0.4' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test.ext:junit:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:1.3.0' + //腾讯Android UI框架 + implementation 'com.qmuiteam:qmui:2.0.0-alpha10' + implementation 'com.qmuiteam:arch:0.3.1' + //沉浸式状态栏。基础依赖包,必须要依赖 + implementation 'com.gyf.immersionbar:immersionbar:3.0.0' + //fragment快速实现 + implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + + //MVP网络请求框架retrofit2+rxjava + implementation 'io.reactivex:rxjava:1.3.8' + implementation 'io.reactivex:rxandroid:1.2.1' + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.6.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + implementation 'com.squareup.retrofit2:adapter-rxjava:2.8.1' + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.8.6' + //Toast提示 + implementation 'com.sdsmdg.tastytoast:tastytoast:0.1.1' + //图片选择框架 + implementation 'com.github.LuckSiege.PictureSelector:picture_library:v2.6.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..603b140 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..88ea3aa --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,122 @@ + + + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+ + +
+
\ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..5cd135a --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..7bfef59 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..4ca4a9f --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,67 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' + +android { + compileSdkVersion 30 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.birmm.inspect" + minSdkVersion 21 + targetSdkVersion 30 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'androidx.core:core-ktx:1.3.2' + implementation 'androidx.constraintlayout:constraintlayout:2.0.4' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test.ext:junit:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:1.3.0' + //腾讯Android UI框架 + implementation 'com.qmuiteam:qmui:2.0.0-alpha10' + implementation 'com.qmuiteam:arch:0.3.1' + //沉浸式状态栏。基础依赖包,必须要依赖 + implementation 'com.gyf.immersionbar:immersionbar:3.0.0' + //fragment快速实现 + implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + + //MVP网络请求框架retrofit2+rxjava + implementation 'io.reactivex:rxjava:1.3.8' + implementation 'io.reactivex:rxandroid:1.2.1' + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.6.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + implementation 'com.squareup.retrofit2:adapter-rxjava:2.8.1' + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.8.6' + //Toast提示 + implementation 'com.sdsmdg.tastytoast:tastytoast:0.1.1' + //图片选择框架 + implementation 'com.github.LuckSiege.PictureSelector:picture_library:v2.6.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..ea03309 --- /dev/null +++ b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.casic.birmm.inspect + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.casic.birmm.inspect", appContext.packageName) + } +} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..603b140 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..88ea3aa --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,122 @@ + + + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+ + +
+
\ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..5cd135a --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..7bfef59 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..4ca4a9f --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,67 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' + +android { + compileSdkVersion 30 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.birmm.inspect" + minSdkVersion 21 + targetSdkVersion 30 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'androidx.core:core-ktx:1.3.2' + implementation 'androidx.constraintlayout:constraintlayout:2.0.4' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test.ext:junit:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:1.3.0' + //腾讯Android UI框架 + implementation 'com.qmuiteam:qmui:2.0.0-alpha10' + implementation 'com.qmuiteam:arch:0.3.1' + //沉浸式状态栏。基础依赖包,必须要依赖 + implementation 'com.gyf.immersionbar:immersionbar:3.0.0' + //fragment快速实现 + implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + + //MVP网络请求框架retrofit2+rxjava + implementation 'io.reactivex:rxjava:1.3.8' + implementation 'io.reactivex:rxandroid:1.2.1' + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.6.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + implementation 'com.squareup.retrofit2:adapter-rxjava:2.8.1' + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.8.6' + //Toast提示 + implementation 'com.sdsmdg.tastytoast:tastytoast:0.1.1' + //图片选择框架 + implementation 'com.github.LuckSiege.PictureSelector:picture_library:v2.6.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..ea03309 --- /dev/null +++ b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.casic.birmm.inspect + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.casic.birmm.inspect", appContext.packageName) + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..7096527 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..603b140 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..88ea3aa --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,122 @@ + + + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+ + +
+
\ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..5cd135a --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..7bfef59 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..4ca4a9f --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,67 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' + +android { + compileSdkVersion 30 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.birmm.inspect" + minSdkVersion 21 + targetSdkVersion 30 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'androidx.core:core-ktx:1.3.2' + implementation 'androidx.constraintlayout:constraintlayout:2.0.4' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test.ext:junit:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:1.3.0' + //腾讯Android UI框架 + implementation 'com.qmuiteam:qmui:2.0.0-alpha10' + implementation 'com.qmuiteam:arch:0.3.1' + //沉浸式状态栏。基础依赖包,必须要依赖 + implementation 'com.gyf.immersionbar:immersionbar:3.0.0' + //fragment快速实现 + implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + + //MVP网络请求框架retrofit2+rxjava + implementation 'io.reactivex:rxjava:1.3.8' + implementation 'io.reactivex:rxandroid:1.2.1' + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.6.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + implementation 'com.squareup.retrofit2:adapter-rxjava:2.8.1' + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.8.6' + //Toast提示 + implementation 'com.sdsmdg.tastytoast:tastytoast:0.1.1' + //图片选择框架 + implementation 'com.github.LuckSiege.PictureSelector:picture_library:v2.6.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..ea03309 --- /dev/null +++ b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.casic.birmm.inspect + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.casic.birmm.inspect", appContext.packageName) + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..7096527 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt new file mode 100644 index 0000000..aefdbb6 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt @@ -0,0 +1,36 @@ +package com.casic.birmm.inspect.base + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.qmuiteam.qmui.util.QMUIStatusBarHelper + +abstract class BaseActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(initLayoutView()) + QMUIStatusBarHelper.translucent(this) //沉浸式状态栏 + setupTopBarLayout() + initData() + initEvent() + } + + /** + * 初始化xml布局 + */ + abstract fun initLayoutView(): Int + + /** + * 特定页面定制沉浸式状态栏 + */ + protected abstract fun setupTopBarLayout() + + /** + * 初始化默认数据 + */ + abstract fun initData() + + /** + * 初始化业务逻辑 + */ + abstract fun initEvent() +} \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..603b140 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..88ea3aa --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,122 @@ + + + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+ + +
+
\ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..5cd135a --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..7bfef59 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..4ca4a9f --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,67 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' + +android { + compileSdkVersion 30 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.birmm.inspect" + minSdkVersion 21 + targetSdkVersion 30 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'androidx.core:core-ktx:1.3.2' + implementation 'androidx.constraintlayout:constraintlayout:2.0.4' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test.ext:junit:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:1.3.0' + //腾讯Android UI框架 + implementation 'com.qmuiteam:qmui:2.0.0-alpha10' + implementation 'com.qmuiteam:arch:0.3.1' + //沉浸式状态栏。基础依赖包,必须要依赖 + implementation 'com.gyf.immersionbar:immersionbar:3.0.0' + //fragment快速实现 + implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + + //MVP网络请求框架retrofit2+rxjava + implementation 'io.reactivex:rxjava:1.3.8' + implementation 'io.reactivex:rxandroid:1.2.1' + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.6.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + implementation 'com.squareup.retrofit2:adapter-rxjava:2.8.1' + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.8.6' + //Toast提示 + implementation 'com.sdsmdg.tastytoast:tastytoast:0.1.1' + //图片选择框架 + implementation 'com.github.LuckSiege.PictureSelector:picture_library:v2.6.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..ea03309 --- /dev/null +++ b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.casic.birmm.inspect + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.casic.birmm.inspect", appContext.packageName) + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..7096527 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt new file mode 100644 index 0000000..aefdbb6 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt @@ -0,0 +1,36 @@ +package com.casic.birmm.inspect.base + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.qmuiteam.qmui.util.QMUIStatusBarHelper + +abstract class BaseActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(initLayoutView()) + QMUIStatusBarHelper.translucent(this) //沉浸式状态栏 + setupTopBarLayout() + initData() + initEvent() + } + + /** + * 初始化xml布局 + */ + abstract fun initLayoutView(): Int + + /** + * 特定页面定制沉浸式状态栏 + */ + protected abstract fun setupTopBarLayout() + + /** + * 初始化默认数据 + */ + abstract fun initData() + + /** + * 初始化业务逻辑 + */ + abstract fun initEvent() +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt new file mode 100644 index 0000000..fc0ca75 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt @@ -0,0 +1,18 @@ +package com.casic.birmm.inspect.base + +import android.app.Application +import com.casic.birmm.inspect.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + companion object { + var instance: BaseApplication by Delegates.notNull() + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences() + } +} \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..603b140 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..88ea3aa --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,122 @@ + + + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+ + +
+
\ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..5cd135a --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..7bfef59 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..4ca4a9f --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,67 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' + +android { + compileSdkVersion 30 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.birmm.inspect" + minSdkVersion 21 + targetSdkVersion 30 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'androidx.core:core-ktx:1.3.2' + implementation 'androidx.constraintlayout:constraintlayout:2.0.4' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test.ext:junit:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:1.3.0' + //腾讯Android UI框架 + implementation 'com.qmuiteam:qmui:2.0.0-alpha10' + implementation 'com.qmuiteam:arch:0.3.1' + //沉浸式状态栏。基础依赖包,必须要依赖 + implementation 'com.gyf.immersionbar:immersionbar:3.0.0' + //fragment快速实现 + implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + + //MVP网络请求框架retrofit2+rxjava + implementation 'io.reactivex:rxjava:1.3.8' + implementation 'io.reactivex:rxandroid:1.2.1' + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.6.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + implementation 'com.squareup.retrofit2:adapter-rxjava:2.8.1' + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.8.6' + //Toast提示 + implementation 'com.sdsmdg.tastytoast:tastytoast:0.1.1' + //图片选择框架 + implementation 'com.github.LuckSiege.PictureSelector:picture_library:v2.6.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..ea03309 --- /dev/null +++ b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.casic.birmm.inspect + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.casic.birmm.inspect", appContext.packageName) + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..7096527 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt new file mode 100644 index 0000000..aefdbb6 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt @@ -0,0 +1,36 @@ +package com.casic.birmm.inspect.base + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.qmuiteam.qmui.util.QMUIStatusBarHelper + +abstract class BaseActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(initLayoutView()) + QMUIStatusBarHelper.translucent(this) //沉浸式状态栏 + setupTopBarLayout() + initData() + initEvent() + } + + /** + * 初始化xml布局 + */ + abstract fun initLayoutView(): Int + + /** + * 特定页面定制沉浸式状态栏 + */ + protected abstract fun setupTopBarLayout() + + /** + * 初始化默认数据 + */ + abstract fun initData() + + /** + * 初始化业务逻辑 + */ + abstract fun initEvent() +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt new file mode 100644 index 0000000..fc0ca75 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt @@ -0,0 +1,18 @@ +package com.casic.birmm.inspect.base + +import android.app.Application +import com.casic.birmm.inspect.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + companion object { + var instance: BaseApplication by Delegates.notNull() + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt new file mode 100644 index 0000000..ddc160a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt @@ -0,0 +1,56 @@ +package com.casic.birmm.inspect.ui + +import android.annotation.SuppressLint +import android.content.Intent +import android.os.CountDownTimer +import android.view.ViewGroup.MarginLayoutParams +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.activity_guide.* + +@SuppressLint("SetTextI18n") +class GuideActivity : BaseActivity() { + + private lateinit var countDownTimer: CountDownTimer + + override fun initLayoutView(): Int = R.layout.activity_guide + + override fun setupTopBarLayout() { + + } + + override fun initData() { + //根据不同设备状态栏高度设置"跳过"按钮的Margin值 + val statusBarHeight = QMUIDisplayHelper.getStatusBarHeight(this) + val rightMargin = QMUIDisplayHelper.dp2px(this, 10) + if (skipButton.layoutParams is MarginLayoutParams) { + val params = skipButton.layoutParams as MarginLayoutParams + params.setMargins(skipButton.width, statusBarHeight, rightMargin, 0) + skipButton.requestLayout() + } + + countDownTimer = object : CountDownTimer(4000, 1000) { + override fun onFinish() { + startLoginActivity() + } + + override fun onTick(millisUntilFinished: Long) { + skipButton.text = "跳过\u3000${(millisUntilFinished / 1000)}s" + } + } + } + + override fun initEvent() { + countDownTimer.start() + skipButton.setOnClickListener { + countDownTimer.cancel() + startLoginActivity() + } + } + + fun startLoginActivity() { + startActivity(Intent(this, LoginActivity::class.java)) + finish() + } +} \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..603b140 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..88ea3aa --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,122 @@ + + + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+ + +
+
\ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..5cd135a --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..7bfef59 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..4ca4a9f --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,67 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' + +android { + compileSdkVersion 30 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.birmm.inspect" + minSdkVersion 21 + targetSdkVersion 30 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'androidx.core:core-ktx:1.3.2' + implementation 'androidx.constraintlayout:constraintlayout:2.0.4' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test.ext:junit:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:1.3.0' + //腾讯Android UI框架 + implementation 'com.qmuiteam:qmui:2.0.0-alpha10' + implementation 'com.qmuiteam:arch:0.3.1' + //沉浸式状态栏。基础依赖包,必须要依赖 + implementation 'com.gyf.immersionbar:immersionbar:3.0.0' + //fragment快速实现 + implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + + //MVP网络请求框架retrofit2+rxjava + implementation 'io.reactivex:rxjava:1.3.8' + implementation 'io.reactivex:rxandroid:1.2.1' + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.6.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + implementation 'com.squareup.retrofit2:adapter-rxjava:2.8.1' + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.8.6' + //Toast提示 + implementation 'com.sdsmdg.tastytoast:tastytoast:0.1.1' + //图片选择框架 + implementation 'com.github.LuckSiege.PictureSelector:picture_library:v2.6.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..ea03309 --- /dev/null +++ b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.casic.birmm.inspect + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.casic.birmm.inspect", appContext.packageName) + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..7096527 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt new file mode 100644 index 0000000..aefdbb6 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt @@ -0,0 +1,36 @@ +package com.casic.birmm.inspect.base + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.qmuiteam.qmui.util.QMUIStatusBarHelper + +abstract class BaseActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(initLayoutView()) + QMUIStatusBarHelper.translucent(this) //沉浸式状态栏 + setupTopBarLayout() + initData() + initEvent() + } + + /** + * 初始化xml布局 + */ + abstract fun initLayoutView(): Int + + /** + * 特定页面定制沉浸式状态栏 + */ + protected abstract fun setupTopBarLayout() + + /** + * 初始化默认数据 + */ + abstract fun initData() + + /** + * 初始化业务逻辑 + */ + abstract fun initEvent() +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt new file mode 100644 index 0000000..fc0ca75 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt @@ -0,0 +1,18 @@ +package com.casic.birmm.inspect.base + +import android.app.Application +import com.casic.birmm.inspect.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + companion object { + var instance: BaseApplication by Delegates.notNull() + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt new file mode 100644 index 0000000..ddc160a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt @@ -0,0 +1,56 @@ +package com.casic.birmm.inspect.ui + +import android.annotation.SuppressLint +import android.content.Intent +import android.os.CountDownTimer +import android.view.ViewGroup.MarginLayoutParams +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.activity_guide.* + +@SuppressLint("SetTextI18n") +class GuideActivity : BaseActivity() { + + private lateinit var countDownTimer: CountDownTimer + + override fun initLayoutView(): Int = R.layout.activity_guide + + override fun setupTopBarLayout() { + + } + + override fun initData() { + //根据不同设备状态栏高度设置"跳过"按钮的Margin值 + val statusBarHeight = QMUIDisplayHelper.getStatusBarHeight(this) + val rightMargin = QMUIDisplayHelper.dp2px(this, 10) + if (skipButton.layoutParams is MarginLayoutParams) { + val params = skipButton.layoutParams as MarginLayoutParams + params.setMargins(skipButton.width, statusBarHeight, rightMargin, 0) + skipButton.requestLayout() + } + + countDownTimer = object : CountDownTimer(4000, 1000) { + override fun onFinish() { + startLoginActivity() + } + + override fun onTick(millisUntilFinished: Long) { + skipButton.text = "跳过\u3000${(millisUntilFinished / 1000)}s" + } + } + } + + override fun initEvent() { + countDownTimer.start() + skipButton.setOnClickListener { + countDownTimer.cancel() + startLoginActivity() + } + } + + fun startLoginActivity() { + startActivity(Intent(this, LoginActivity::class.java)) + finish() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt new file mode 100644 index 0000000..6ef4548 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt @@ -0,0 +1,81 @@ +package com.casic.birmm.inspect.ui + +import android.text.Editable +import android.text.TextWatcher +import android.view.KeyEvent +import android.view.inputmethod.EditorInfo +import android.widget.EditText +import android.widget.TextView +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.casic.birmm.inspect.utils.Constant +import com.casic.birmm.inspect.utils.SaveKeyValues +import com.casic.birmm.inspect.widgets.InputDialog +import kotlinx.android.synthetic.main.activity_login.* + + +class LoginActivity : BaseActivity() { + + companion object { + private const val Tag = "LoginActivity" + } + + override fun initLayoutView(): Int = R.layout.activity_login + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + loginButton.setChangeAlphaWhenPress(true) + val editText: EditText? = inputLayout.editText + editText?.addTextChangedListener(object : TextWatcher { + override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) { + + } + + override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) { + + } + + override fun afterTextChanged(s: Editable) { + if (s.toString().trim { it <= ' ' }.length > 12) { + inputLayout.error = "密码长度超出限制" + } else { + inputLayout.error = null + } + } + }) + //点击输入法键盘"完成" + editText?.setOnEditorActionListener { _: TextView?, actionId: Int, _: KeyEvent? -> + if (actionId == EditorInfo.IME_ACTION_DONE) { +// authenticatePresenter.onReadyRetrofitRequest() + return@setOnEditorActionListener true + } + false + } + + //修改服务器配置 + changeServerConfigView.setOnClickListener { + val defaultValue = SaveKeyValues.getValue( + Constant.DEFAULT_SERVER_CONFIG, + "http://139.198.6.177:8093/" + ) as String + InputDialog.Builder().setContext(this) + .setTitle("请输入后台服务器地址") + .setDefaultValue(defaultValue) + .setNegativeButton("取消") + .setPositiveButton("保存") + .setOnDialogClickListener(object : InputDialog.OnDialogButtonClickListener { + override fun onButtonClick(input: String) { + SaveKeyValues.putValue(Constant.DEFAULT_SERVER_CONFIG, input) + } + }) + .build().show() + } + } +} \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..603b140 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..88ea3aa --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,122 @@ + + + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+ + +
+
\ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..5cd135a --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..7bfef59 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..4ca4a9f --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,67 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' + +android { + compileSdkVersion 30 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.birmm.inspect" + minSdkVersion 21 + targetSdkVersion 30 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'androidx.core:core-ktx:1.3.2' + implementation 'androidx.constraintlayout:constraintlayout:2.0.4' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test.ext:junit:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:1.3.0' + //腾讯Android UI框架 + implementation 'com.qmuiteam:qmui:2.0.0-alpha10' + implementation 'com.qmuiteam:arch:0.3.1' + //沉浸式状态栏。基础依赖包,必须要依赖 + implementation 'com.gyf.immersionbar:immersionbar:3.0.0' + //fragment快速实现 + implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + + //MVP网络请求框架retrofit2+rxjava + implementation 'io.reactivex:rxjava:1.3.8' + implementation 'io.reactivex:rxandroid:1.2.1' + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.6.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + implementation 'com.squareup.retrofit2:adapter-rxjava:2.8.1' + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.8.6' + //Toast提示 + implementation 'com.sdsmdg.tastytoast:tastytoast:0.1.1' + //图片选择框架 + implementation 'com.github.LuckSiege.PictureSelector:picture_library:v2.6.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..ea03309 --- /dev/null +++ b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.casic.birmm.inspect + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.casic.birmm.inspect", appContext.packageName) + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..7096527 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt new file mode 100644 index 0000000..aefdbb6 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt @@ -0,0 +1,36 @@ +package com.casic.birmm.inspect.base + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.qmuiteam.qmui.util.QMUIStatusBarHelper + +abstract class BaseActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(initLayoutView()) + QMUIStatusBarHelper.translucent(this) //沉浸式状态栏 + setupTopBarLayout() + initData() + initEvent() + } + + /** + * 初始化xml布局 + */ + abstract fun initLayoutView(): Int + + /** + * 特定页面定制沉浸式状态栏 + */ + protected abstract fun setupTopBarLayout() + + /** + * 初始化默认数据 + */ + abstract fun initData() + + /** + * 初始化业务逻辑 + */ + abstract fun initEvent() +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt new file mode 100644 index 0000000..fc0ca75 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt @@ -0,0 +1,18 @@ +package com.casic.birmm.inspect.base + +import android.app.Application +import com.casic.birmm.inspect.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + companion object { + var instance: BaseApplication by Delegates.notNull() + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt new file mode 100644 index 0000000..ddc160a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt @@ -0,0 +1,56 @@ +package com.casic.birmm.inspect.ui + +import android.annotation.SuppressLint +import android.content.Intent +import android.os.CountDownTimer +import android.view.ViewGroup.MarginLayoutParams +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.activity_guide.* + +@SuppressLint("SetTextI18n") +class GuideActivity : BaseActivity() { + + private lateinit var countDownTimer: CountDownTimer + + override fun initLayoutView(): Int = R.layout.activity_guide + + override fun setupTopBarLayout() { + + } + + override fun initData() { + //根据不同设备状态栏高度设置"跳过"按钮的Margin值 + val statusBarHeight = QMUIDisplayHelper.getStatusBarHeight(this) + val rightMargin = QMUIDisplayHelper.dp2px(this, 10) + if (skipButton.layoutParams is MarginLayoutParams) { + val params = skipButton.layoutParams as MarginLayoutParams + params.setMargins(skipButton.width, statusBarHeight, rightMargin, 0) + skipButton.requestLayout() + } + + countDownTimer = object : CountDownTimer(4000, 1000) { + override fun onFinish() { + startLoginActivity() + } + + override fun onTick(millisUntilFinished: Long) { + skipButton.text = "跳过\u3000${(millisUntilFinished / 1000)}s" + } + } + } + + override fun initEvent() { + countDownTimer.start() + skipButton.setOnClickListener { + countDownTimer.cancel() + startLoginActivity() + } + } + + fun startLoginActivity() { + startActivity(Intent(this, LoginActivity::class.java)) + finish() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt new file mode 100644 index 0000000..6ef4548 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt @@ -0,0 +1,81 @@ +package com.casic.birmm.inspect.ui + +import android.text.Editable +import android.text.TextWatcher +import android.view.KeyEvent +import android.view.inputmethod.EditorInfo +import android.widget.EditText +import android.widget.TextView +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.casic.birmm.inspect.utils.Constant +import com.casic.birmm.inspect.utils.SaveKeyValues +import com.casic.birmm.inspect.widgets.InputDialog +import kotlinx.android.synthetic.main.activity_login.* + + +class LoginActivity : BaseActivity() { + + companion object { + private const val Tag = "LoginActivity" + } + + override fun initLayoutView(): Int = R.layout.activity_login + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + loginButton.setChangeAlphaWhenPress(true) + val editText: EditText? = inputLayout.editText + editText?.addTextChangedListener(object : TextWatcher { + override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) { + + } + + override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) { + + } + + override fun afterTextChanged(s: Editable) { + if (s.toString().trim { it <= ' ' }.length > 12) { + inputLayout.error = "密码长度超出限制" + } else { + inputLayout.error = null + } + } + }) + //点击输入法键盘"完成" + editText?.setOnEditorActionListener { _: TextView?, actionId: Int, _: KeyEvent? -> + if (actionId == EditorInfo.IME_ACTION_DONE) { +// authenticatePresenter.onReadyRetrofitRequest() + return@setOnEditorActionListener true + } + false + } + + //修改服务器配置 + changeServerConfigView.setOnClickListener { + val defaultValue = SaveKeyValues.getValue( + Constant.DEFAULT_SERVER_CONFIG, + "http://139.198.6.177:8093/" + ) as String + InputDialog.Builder().setContext(this) + .setTitle("请输入后台服务器地址") + .setDefaultValue(defaultValue) + .setNegativeButton("取消") + .setPositiveButton("保存") + .setOnDialogClickListener(object : InputDialog.OnDialogButtonClickListener { + override fun onButtonClick(input: String) { + SaveKeyValues.putValue(Constant.DEFAULT_SERVER_CONFIG, input) + } + }) + .build().show() + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt new file mode 100644 index 0000000..0e97af7 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt @@ -0,0 +1,21 @@ +package com.casic.birmm.inspect.ui + +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity + +class MainActivity : BaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..603b140 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..88ea3aa --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,122 @@ + + + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+ + +
+
\ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..5cd135a --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..7bfef59 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..4ca4a9f --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,67 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' + +android { + compileSdkVersion 30 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.birmm.inspect" + minSdkVersion 21 + targetSdkVersion 30 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'androidx.core:core-ktx:1.3.2' + implementation 'androidx.constraintlayout:constraintlayout:2.0.4' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test.ext:junit:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:1.3.0' + //腾讯Android UI框架 + implementation 'com.qmuiteam:qmui:2.0.0-alpha10' + implementation 'com.qmuiteam:arch:0.3.1' + //沉浸式状态栏。基础依赖包,必须要依赖 + implementation 'com.gyf.immersionbar:immersionbar:3.0.0' + //fragment快速实现 + implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + + //MVP网络请求框架retrofit2+rxjava + implementation 'io.reactivex:rxjava:1.3.8' + implementation 'io.reactivex:rxandroid:1.2.1' + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.6.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + implementation 'com.squareup.retrofit2:adapter-rxjava:2.8.1' + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.8.6' + //Toast提示 + implementation 'com.sdsmdg.tastytoast:tastytoast:0.1.1' + //图片选择框架 + implementation 'com.github.LuckSiege.PictureSelector:picture_library:v2.6.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..ea03309 --- /dev/null +++ b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.casic.birmm.inspect + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.casic.birmm.inspect", appContext.packageName) + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..7096527 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt new file mode 100644 index 0000000..aefdbb6 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt @@ -0,0 +1,36 @@ +package com.casic.birmm.inspect.base + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.qmuiteam.qmui.util.QMUIStatusBarHelper + +abstract class BaseActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(initLayoutView()) + QMUIStatusBarHelper.translucent(this) //沉浸式状态栏 + setupTopBarLayout() + initData() + initEvent() + } + + /** + * 初始化xml布局 + */ + abstract fun initLayoutView(): Int + + /** + * 特定页面定制沉浸式状态栏 + */ + protected abstract fun setupTopBarLayout() + + /** + * 初始化默认数据 + */ + abstract fun initData() + + /** + * 初始化业务逻辑 + */ + abstract fun initEvent() +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt new file mode 100644 index 0000000..fc0ca75 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt @@ -0,0 +1,18 @@ +package com.casic.birmm.inspect.base + +import android.app.Application +import com.casic.birmm.inspect.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + companion object { + var instance: BaseApplication by Delegates.notNull() + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt new file mode 100644 index 0000000..ddc160a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt @@ -0,0 +1,56 @@ +package com.casic.birmm.inspect.ui + +import android.annotation.SuppressLint +import android.content.Intent +import android.os.CountDownTimer +import android.view.ViewGroup.MarginLayoutParams +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.activity_guide.* + +@SuppressLint("SetTextI18n") +class GuideActivity : BaseActivity() { + + private lateinit var countDownTimer: CountDownTimer + + override fun initLayoutView(): Int = R.layout.activity_guide + + override fun setupTopBarLayout() { + + } + + override fun initData() { + //根据不同设备状态栏高度设置"跳过"按钮的Margin值 + val statusBarHeight = QMUIDisplayHelper.getStatusBarHeight(this) + val rightMargin = QMUIDisplayHelper.dp2px(this, 10) + if (skipButton.layoutParams is MarginLayoutParams) { + val params = skipButton.layoutParams as MarginLayoutParams + params.setMargins(skipButton.width, statusBarHeight, rightMargin, 0) + skipButton.requestLayout() + } + + countDownTimer = object : CountDownTimer(4000, 1000) { + override fun onFinish() { + startLoginActivity() + } + + override fun onTick(millisUntilFinished: Long) { + skipButton.text = "跳过\u3000${(millisUntilFinished / 1000)}s" + } + } + } + + override fun initEvent() { + countDownTimer.start() + skipButton.setOnClickListener { + countDownTimer.cancel() + startLoginActivity() + } + } + + fun startLoginActivity() { + startActivity(Intent(this, LoginActivity::class.java)) + finish() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt new file mode 100644 index 0000000..6ef4548 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt @@ -0,0 +1,81 @@ +package com.casic.birmm.inspect.ui + +import android.text.Editable +import android.text.TextWatcher +import android.view.KeyEvent +import android.view.inputmethod.EditorInfo +import android.widget.EditText +import android.widget.TextView +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.casic.birmm.inspect.utils.Constant +import com.casic.birmm.inspect.utils.SaveKeyValues +import com.casic.birmm.inspect.widgets.InputDialog +import kotlinx.android.synthetic.main.activity_login.* + + +class LoginActivity : BaseActivity() { + + companion object { + private const val Tag = "LoginActivity" + } + + override fun initLayoutView(): Int = R.layout.activity_login + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + loginButton.setChangeAlphaWhenPress(true) + val editText: EditText? = inputLayout.editText + editText?.addTextChangedListener(object : TextWatcher { + override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) { + + } + + override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) { + + } + + override fun afterTextChanged(s: Editable) { + if (s.toString().trim { it <= ' ' }.length > 12) { + inputLayout.error = "密码长度超出限制" + } else { + inputLayout.error = null + } + } + }) + //点击输入法键盘"完成" + editText?.setOnEditorActionListener { _: TextView?, actionId: Int, _: KeyEvent? -> + if (actionId == EditorInfo.IME_ACTION_DONE) { +// authenticatePresenter.onReadyRetrofitRequest() + return@setOnEditorActionListener true + } + false + } + + //修改服务器配置 + changeServerConfigView.setOnClickListener { + val defaultValue = SaveKeyValues.getValue( + Constant.DEFAULT_SERVER_CONFIG, + "http://139.198.6.177:8093/" + ) as String + InputDialog.Builder().setContext(this) + .setTitle("请输入后台服务器地址") + .setDefaultValue(defaultValue) + .setNegativeButton("取消") + .setPositiveButton("保存") + .setOnDialogClickListener(object : InputDialog.OnDialogButtonClickListener { + override fun onButtonClick(input: String) { + SaveKeyValues.putValue(Constant.DEFAULT_SERVER_CONFIG, input) + } + }) + .build().show() + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt new file mode 100644 index 0000000..0e97af7 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt @@ -0,0 +1,21 @@ +package com.casic.birmm.inspect.ui + +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity + +class MainActivity : BaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt new file mode 100644 index 0000000..21fbba2 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt @@ -0,0 +1,58 @@ +package com.casic.birmm.inspect.ui + +import android.content.Intent +import android.os.Build +import android.os.Bundle +import android.util.Log +import androidx.appcompat.app.AppCompatActivity +import com.casic.birmm.inspect.utils.Constant +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + companion object { + private const val TAG = "PermissionActivity" + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + if (EasyPermissions.hasPermissions(this, *Constant.USER_PERMISSIONS)) { + startGuideActivity() + } else { + EasyPermissions.requestPermissions( + this, + "需要获取相关权限", + Constant.PERMISSIONS_CODE, + *Constant.USER_PERMISSIONS + ) + } + } else { + startGuideActivity() + } + } + + private fun startGuideActivity() { + startActivity(Intent(this, GuideActivity::class.java)) + finish() + } + + override fun onRequestPermissionsResult( + requestCode: Int, + permissions: Array, + grantResults: IntArray + ) { + super.onRequestPermissionsResult(requestCode, permissions, grantResults) + EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this) + } + + override fun onPermissionsGranted(requestCode: Int, perms: List) { + startGuideActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + Log.e(TAG, "onPermissionsDenied: $perms") + } +} \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..603b140 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..88ea3aa --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,122 @@ + + + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+ + +
+
\ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..5cd135a --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..7bfef59 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..4ca4a9f --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,67 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' + +android { + compileSdkVersion 30 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.birmm.inspect" + minSdkVersion 21 + targetSdkVersion 30 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'androidx.core:core-ktx:1.3.2' + implementation 'androidx.constraintlayout:constraintlayout:2.0.4' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test.ext:junit:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:1.3.0' + //腾讯Android UI框架 + implementation 'com.qmuiteam:qmui:2.0.0-alpha10' + implementation 'com.qmuiteam:arch:0.3.1' + //沉浸式状态栏。基础依赖包,必须要依赖 + implementation 'com.gyf.immersionbar:immersionbar:3.0.0' + //fragment快速实现 + implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + + //MVP网络请求框架retrofit2+rxjava + implementation 'io.reactivex:rxjava:1.3.8' + implementation 'io.reactivex:rxandroid:1.2.1' + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.6.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + implementation 'com.squareup.retrofit2:adapter-rxjava:2.8.1' + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.8.6' + //Toast提示 + implementation 'com.sdsmdg.tastytoast:tastytoast:0.1.1' + //图片选择框架 + implementation 'com.github.LuckSiege.PictureSelector:picture_library:v2.6.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..ea03309 --- /dev/null +++ b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.casic.birmm.inspect + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.casic.birmm.inspect", appContext.packageName) + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..7096527 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt new file mode 100644 index 0000000..aefdbb6 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt @@ -0,0 +1,36 @@ +package com.casic.birmm.inspect.base + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.qmuiteam.qmui.util.QMUIStatusBarHelper + +abstract class BaseActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(initLayoutView()) + QMUIStatusBarHelper.translucent(this) //沉浸式状态栏 + setupTopBarLayout() + initData() + initEvent() + } + + /** + * 初始化xml布局 + */ + abstract fun initLayoutView(): Int + + /** + * 特定页面定制沉浸式状态栏 + */ + protected abstract fun setupTopBarLayout() + + /** + * 初始化默认数据 + */ + abstract fun initData() + + /** + * 初始化业务逻辑 + */ + abstract fun initEvent() +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt new file mode 100644 index 0000000..fc0ca75 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt @@ -0,0 +1,18 @@ +package com.casic.birmm.inspect.base + +import android.app.Application +import com.casic.birmm.inspect.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + companion object { + var instance: BaseApplication by Delegates.notNull() + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt new file mode 100644 index 0000000..ddc160a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt @@ -0,0 +1,56 @@ +package com.casic.birmm.inspect.ui + +import android.annotation.SuppressLint +import android.content.Intent +import android.os.CountDownTimer +import android.view.ViewGroup.MarginLayoutParams +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.activity_guide.* + +@SuppressLint("SetTextI18n") +class GuideActivity : BaseActivity() { + + private lateinit var countDownTimer: CountDownTimer + + override fun initLayoutView(): Int = R.layout.activity_guide + + override fun setupTopBarLayout() { + + } + + override fun initData() { + //根据不同设备状态栏高度设置"跳过"按钮的Margin值 + val statusBarHeight = QMUIDisplayHelper.getStatusBarHeight(this) + val rightMargin = QMUIDisplayHelper.dp2px(this, 10) + if (skipButton.layoutParams is MarginLayoutParams) { + val params = skipButton.layoutParams as MarginLayoutParams + params.setMargins(skipButton.width, statusBarHeight, rightMargin, 0) + skipButton.requestLayout() + } + + countDownTimer = object : CountDownTimer(4000, 1000) { + override fun onFinish() { + startLoginActivity() + } + + override fun onTick(millisUntilFinished: Long) { + skipButton.text = "跳过\u3000${(millisUntilFinished / 1000)}s" + } + } + } + + override fun initEvent() { + countDownTimer.start() + skipButton.setOnClickListener { + countDownTimer.cancel() + startLoginActivity() + } + } + + fun startLoginActivity() { + startActivity(Intent(this, LoginActivity::class.java)) + finish() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt new file mode 100644 index 0000000..6ef4548 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt @@ -0,0 +1,81 @@ +package com.casic.birmm.inspect.ui + +import android.text.Editable +import android.text.TextWatcher +import android.view.KeyEvent +import android.view.inputmethod.EditorInfo +import android.widget.EditText +import android.widget.TextView +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.casic.birmm.inspect.utils.Constant +import com.casic.birmm.inspect.utils.SaveKeyValues +import com.casic.birmm.inspect.widgets.InputDialog +import kotlinx.android.synthetic.main.activity_login.* + + +class LoginActivity : BaseActivity() { + + companion object { + private const val Tag = "LoginActivity" + } + + override fun initLayoutView(): Int = R.layout.activity_login + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + loginButton.setChangeAlphaWhenPress(true) + val editText: EditText? = inputLayout.editText + editText?.addTextChangedListener(object : TextWatcher { + override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) { + + } + + override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) { + + } + + override fun afterTextChanged(s: Editable) { + if (s.toString().trim { it <= ' ' }.length > 12) { + inputLayout.error = "密码长度超出限制" + } else { + inputLayout.error = null + } + } + }) + //点击输入法键盘"完成" + editText?.setOnEditorActionListener { _: TextView?, actionId: Int, _: KeyEvent? -> + if (actionId == EditorInfo.IME_ACTION_DONE) { +// authenticatePresenter.onReadyRetrofitRequest() + return@setOnEditorActionListener true + } + false + } + + //修改服务器配置 + changeServerConfigView.setOnClickListener { + val defaultValue = SaveKeyValues.getValue( + Constant.DEFAULT_SERVER_CONFIG, + "http://139.198.6.177:8093/" + ) as String + InputDialog.Builder().setContext(this) + .setTitle("请输入后台服务器地址") + .setDefaultValue(defaultValue) + .setNegativeButton("取消") + .setPositiveButton("保存") + .setOnDialogClickListener(object : InputDialog.OnDialogButtonClickListener { + override fun onButtonClick(input: String) { + SaveKeyValues.putValue(Constant.DEFAULT_SERVER_CONFIG, input) + } + }) + .build().show() + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt new file mode 100644 index 0000000..0e97af7 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt @@ -0,0 +1,21 @@ +package com.casic.birmm.inspect.ui + +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity + +class MainActivity : BaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt new file mode 100644 index 0000000..21fbba2 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt @@ -0,0 +1,58 @@ +package com.casic.birmm.inspect.ui + +import android.content.Intent +import android.os.Build +import android.os.Bundle +import android.util.Log +import androidx.appcompat.app.AppCompatActivity +import com.casic.birmm.inspect.utils.Constant +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + companion object { + private const val TAG = "PermissionActivity" + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + if (EasyPermissions.hasPermissions(this, *Constant.USER_PERMISSIONS)) { + startGuideActivity() + } else { + EasyPermissions.requestPermissions( + this, + "需要获取相关权限", + Constant.PERMISSIONS_CODE, + *Constant.USER_PERMISSIONS + ) + } + } else { + startGuideActivity() + } + } + + private fun startGuideActivity() { + startActivity(Intent(this, GuideActivity::class.java)) + finish() + } + + override fun onRequestPermissionsResult( + requestCode: Int, + permissions: Array, + grantResults: IntArray + ) { + super.onRequestPermissionsResult(requestCode, permissions, grantResults) + EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this) + } + + override fun onPermissionsGranted(requestCode: Int, perms: List) { + startGuideActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + Log.e(TAG, "onPermissionsDenied: $perms") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt new file mode 100644 index 0000000..53df6e1 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt @@ -0,0 +1,15 @@ +package com.casic.birmm.inspect.utils + +import android.Manifest + + +object Constant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.ACCESS_LOCATION_EXTRA_COMMANDS, + Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION + ) + + const val PERMISSIONS_CODE = 999 + + const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" +} \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..603b140 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..88ea3aa --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,122 @@ + + + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+ + +
+
\ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..5cd135a --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..7bfef59 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..4ca4a9f --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,67 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' + +android { + compileSdkVersion 30 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.birmm.inspect" + minSdkVersion 21 + targetSdkVersion 30 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'androidx.core:core-ktx:1.3.2' + implementation 'androidx.constraintlayout:constraintlayout:2.0.4' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test.ext:junit:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:1.3.0' + //腾讯Android UI框架 + implementation 'com.qmuiteam:qmui:2.0.0-alpha10' + implementation 'com.qmuiteam:arch:0.3.1' + //沉浸式状态栏。基础依赖包,必须要依赖 + implementation 'com.gyf.immersionbar:immersionbar:3.0.0' + //fragment快速实现 + implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + + //MVP网络请求框架retrofit2+rxjava + implementation 'io.reactivex:rxjava:1.3.8' + implementation 'io.reactivex:rxandroid:1.2.1' + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.6.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + implementation 'com.squareup.retrofit2:adapter-rxjava:2.8.1' + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.8.6' + //Toast提示 + implementation 'com.sdsmdg.tastytoast:tastytoast:0.1.1' + //图片选择框架 + implementation 'com.github.LuckSiege.PictureSelector:picture_library:v2.6.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..ea03309 --- /dev/null +++ b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.casic.birmm.inspect + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.casic.birmm.inspect", appContext.packageName) + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..7096527 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt new file mode 100644 index 0000000..aefdbb6 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt @@ -0,0 +1,36 @@ +package com.casic.birmm.inspect.base + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.qmuiteam.qmui.util.QMUIStatusBarHelper + +abstract class BaseActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(initLayoutView()) + QMUIStatusBarHelper.translucent(this) //沉浸式状态栏 + setupTopBarLayout() + initData() + initEvent() + } + + /** + * 初始化xml布局 + */ + abstract fun initLayoutView(): Int + + /** + * 特定页面定制沉浸式状态栏 + */ + protected abstract fun setupTopBarLayout() + + /** + * 初始化默认数据 + */ + abstract fun initData() + + /** + * 初始化业务逻辑 + */ + abstract fun initEvent() +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt new file mode 100644 index 0000000..fc0ca75 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt @@ -0,0 +1,18 @@ +package com.casic.birmm.inspect.base + +import android.app.Application +import com.casic.birmm.inspect.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + companion object { + var instance: BaseApplication by Delegates.notNull() + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt new file mode 100644 index 0000000..ddc160a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt @@ -0,0 +1,56 @@ +package com.casic.birmm.inspect.ui + +import android.annotation.SuppressLint +import android.content.Intent +import android.os.CountDownTimer +import android.view.ViewGroup.MarginLayoutParams +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.activity_guide.* + +@SuppressLint("SetTextI18n") +class GuideActivity : BaseActivity() { + + private lateinit var countDownTimer: CountDownTimer + + override fun initLayoutView(): Int = R.layout.activity_guide + + override fun setupTopBarLayout() { + + } + + override fun initData() { + //根据不同设备状态栏高度设置"跳过"按钮的Margin值 + val statusBarHeight = QMUIDisplayHelper.getStatusBarHeight(this) + val rightMargin = QMUIDisplayHelper.dp2px(this, 10) + if (skipButton.layoutParams is MarginLayoutParams) { + val params = skipButton.layoutParams as MarginLayoutParams + params.setMargins(skipButton.width, statusBarHeight, rightMargin, 0) + skipButton.requestLayout() + } + + countDownTimer = object : CountDownTimer(4000, 1000) { + override fun onFinish() { + startLoginActivity() + } + + override fun onTick(millisUntilFinished: Long) { + skipButton.text = "跳过\u3000${(millisUntilFinished / 1000)}s" + } + } + } + + override fun initEvent() { + countDownTimer.start() + skipButton.setOnClickListener { + countDownTimer.cancel() + startLoginActivity() + } + } + + fun startLoginActivity() { + startActivity(Intent(this, LoginActivity::class.java)) + finish() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt new file mode 100644 index 0000000..6ef4548 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt @@ -0,0 +1,81 @@ +package com.casic.birmm.inspect.ui + +import android.text.Editable +import android.text.TextWatcher +import android.view.KeyEvent +import android.view.inputmethod.EditorInfo +import android.widget.EditText +import android.widget.TextView +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.casic.birmm.inspect.utils.Constant +import com.casic.birmm.inspect.utils.SaveKeyValues +import com.casic.birmm.inspect.widgets.InputDialog +import kotlinx.android.synthetic.main.activity_login.* + + +class LoginActivity : BaseActivity() { + + companion object { + private const val Tag = "LoginActivity" + } + + override fun initLayoutView(): Int = R.layout.activity_login + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + loginButton.setChangeAlphaWhenPress(true) + val editText: EditText? = inputLayout.editText + editText?.addTextChangedListener(object : TextWatcher { + override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) { + + } + + override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) { + + } + + override fun afterTextChanged(s: Editable) { + if (s.toString().trim { it <= ' ' }.length > 12) { + inputLayout.error = "密码长度超出限制" + } else { + inputLayout.error = null + } + } + }) + //点击输入法键盘"完成" + editText?.setOnEditorActionListener { _: TextView?, actionId: Int, _: KeyEvent? -> + if (actionId == EditorInfo.IME_ACTION_DONE) { +// authenticatePresenter.onReadyRetrofitRequest() + return@setOnEditorActionListener true + } + false + } + + //修改服务器配置 + changeServerConfigView.setOnClickListener { + val defaultValue = SaveKeyValues.getValue( + Constant.DEFAULT_SERVER_CONFIG, + "http://139.198.6.177:8093/" + ) as String + InputDialog.Builder().setContext(this) + .setTitle("请输入后台服务器地址") + .setDefaultValue(defaultValue) + .setNegativeButton("取消") + .setPositiveButton("保存") + .setOnDialogClickListener(object : InputDialog.OnDialogButtonClickListener { + override fun onButtonClick(input: String) { + SaveKeyValues.putValue(Constant.DEFAULT_SERVER_CONFIG, input) + } + }) + .build().show() + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt new file mode 100644 index 0000000..0e97af7 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt @@ -0,0 +1,21 @@ +package com.casic.birmm.inspect.ui + +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity + +class MainActivity : BaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt new file mode 100644 index 0000000..21fbba2 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt @@ -0,0 +1,58 @@ +package com.casic.birmm.inspect.ui + +import android.content.Intent +import android.os.Build +import android.os.Bundle +import android.util.Log +import androidx.appcompat.app.AppCompatActivity +import com.casic.birmm.inspect.utils.Constant +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + companion object { + private const val TAG = "PermissionActivity" + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + if (EasyPermissions.hasPermissions(this, *Constant.USER_PERMISSIONS)) { + startGuideActivity() + } else { + EasyPermissions.requestPermissions( + this, + "需要获取相关权限", + Constant.PERMISSIONS_CODE, + *Constant.USER_PERMISSIONS + ) + } + } else { + startGuideActivity() + } + } + + private fun startGuideActivity() { + startActivity(Intent(this, GuideActivity::class.java)) + finish() + } + + override fun onRequestPermissionsResult( + requestCode: Int, + permissions: Array, + grantResults: IntArray + ) { + super.onRequestPermissionsResult(requestCode, permissions, grantResults) + EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this) + } + + override fun onPermissionsGranted(requestCode: Int, perms: List) { + startGuideActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + Log.e(TAG, "onPermissionsDenied: $perms") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt new file mode 100644 index 0000000..53df6e1 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt @@ -0,0 +1,15 @@ +package com.casic.birmm.inspect.utils + +import android.Manifest + + +object Constant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.ACCESS_LOCATION_EXTRA_COMMANDS, + Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION + ) + + const val PERMISSIONS_CODE = 999 + + const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt new file mode 100644 index 0000000..4c38241 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt @@ -0,0 +1,19 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.view.View +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object OtherUtils { + + //替换Toast + fun showTipsDialog(context: Context, message: String, view: View) { + val tipDialog = QMUITipDialog.Builder(context) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_NOTHING) + .setTipWord(message).create() + tipDialog.show() + view.postDelayed({ + tipDialog.dismiss() + }, 2000) + } +} \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..603b140 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..88ea3aa --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,122 @@ + + + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+ + +
+
\ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..5cd135a --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..7bfef59 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..4ca4a9f --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,67 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' + +android { + compileSdkVersion 30 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.birmm.inspect" + minSdkVersion 21 + targetSdkVersion 30 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'androidx.core:core-ktx:1.3.2' + implementation 'androidx.constraintlayout:constraintlayout:2.0.4' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test.ext:junit:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:1.3.0' + //腾讯Android UI框架 + implementation 'com.qmuiteam:qmui:2.0.0-alpha10' + implementation 'com.qmuiteam:arch:0.3.1' + //沉浸式状态栏。基础依赖包,必须要依赖 + implementation 'com.gyf.immersionbar:immersionbar:3.0.0' + //fragment快速实现 + implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + + //MVP网络请求框架retrofit2+rxjava + implementation 'io.reactivex:rxjava:1.3.8' + implementation 'io.reactivex:rxandroid:1.2.1' + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.6.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + implementation 'com.squareup.retrofit2:adapter-rxjava:2.8.1' + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.8.6' + //Toast提示 + implementation 'com.sdsmdg.tastytoast:tastytoast:0.1.1' + //图片选择框架 + implementation 'com.github.LuckSiege.PictureSelector:picture_library:v2.6.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..ea03309 --- /dev/null +++ b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.casic.birmm.inspect + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.casic.birmm.inspect", appContext.packageName) + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..7096527 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt new file mode 100644 index 0000000..aefdbb6 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt @@ -0,0 +1,36 @@ +package com.casic.birmm.inspect.base + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.qmuiteam.qmui.util.QMUIStatusBarHelper + +abstract class BaseActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(initLayoutView()) + QMUIStatusBarHelper.translucent(this) //沉浸式状态栏 + setupTopBarLayout() + initData() + initEvent() + } + + /** + * 初始化xml布局 + */ + abstract fun initLayoutView(): Int + + /** + * 特定页面定制沉浸式状态栏 + */ + protected abstract fun setupTopBarLayout() + + /** + * 初始化默认数据 + */ + abstract fun initData() + + /** + * 初始化业务逻辑 + */ + abstract fun initEvent() +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt new file mode 100644 index 0000000..fc0ca75 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt @@ -0,0 +1,18 @@ +package com.casic.birmm.inspect.base + +import android.app.Application +import com.casic.birmm.inspect.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + companion object { + var instance: BaseApplication by Delegates.notNull() + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt new file mode 100644 index 0000000..ddc160a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt @@ -0,0 +1,56 @@ +package com.casic.birmm.inspect.ui + +import android.annotation.SuppressLint +import android.content.Intent +import android.os.CountDownTimer +import android.view.ViewGroup.MarginLayoutParams +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.activity_guide.* + +@SuppressLint("SetTextI18n") +class GuideActivity : BaseActivity() { + + private lateinit var countDownTimer: CountDownTimer + + override fun initLayoutView(): Int = R.layout.activity_guide + + override fun setupTopBarLayout() { + + } + + override fun initData() { + //根据不同设备状态栏高度设置"跳过"按钮的Margin值 + val statusBarHeight = QMUIDisplayHelper.getStatusBarHeight(this) + val rightMargin = QMUIDisplayHelper.dp2px(this, 10) + if (skipButton.layoutParams is MarginLayoutParams) { + val params = skipButton.layoutParams as MarginLayoutParams + params.setMargins(skipButton.width, statusBarHeight, rightMargin, 0) + skipButton.requestLayout() + } + + countDownTimer = object : CountDownTimer(4000, 1000) { + override fun onFinish() { + startLoginActivity() + } + + override fun onTick(millisUntilFinished: Long) { + skipButton.text = "跳过\u3000${(millisUntilFinished / 1000)}s" + } + } + } + + override fun initEvent() { + countDownTimer.start() + skipButton.setOnClickListener { + countDownTimer.cancel() + startLoginActivity() + } + } + + fun startLoginActivity() { + startActivity(Intent(this, LoginActivity::class.java)) + finish() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt new file mode 100644 index 0000000..6ef4548 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt @@ -0,0 +1,81 @@ +package com.casic.birmm.inspect.ui + +import android.text.Editable +import android.text.TextWatcher +import android.view.KeyEvent +import android.view.inputmethod.EditorInfo +import android.widget.EditText +import android.widget.TextView +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.casic.birmm.inspect.utils.Constant +import com.casic.birmm.inspect.utils.SaveKeyValues +import com.casic.birmm.inspect.widgets.InputDialog +import kotlinx.android.synthetic.main.activity_login.* + + +class LoginActivity : BaseActivity() { + + companion object { + private const val Tag = "LoginActivity" + } + + override fun initLayoutView(): Int = R.layout.activity_login + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + loginButton.setChangeAlphaWhenPress(true) + val editText: EditText? = inputLayout.editText + editText?.addTextChangedListener(object : TextWatcher { + override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) { + + } + + override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) { + + } + + override fun afterTextChanged(s: Editable) { + if (s.toString().trim { it <= ' ' }.length > 12) { + inputLayout.error = "密码长度超出限制" + } else { + inputLayout.error = null + } + } + }) + //点击输入法键盘"完成" + editText?.setOnEditorActionListener { _: TextView?, actionId: Int, _: KeyEvent? -> + if (actionId == EditorInfo.IME_ACTION_DONE) { +// authenticatePresenter.onReadyRetrofitRequest() + return@setOnEditorActionListener true + } + false + } + + //修改服务器配置 + changeServerConfigView.setOnClickListener { + val defaultValue = SaveKeyValues.getValue( + Constant.DEFAULT_SERVER_CONFIG, + "http://139.198.6.177:8093/" + ) as String + InputDialog.Builder().setContext(this) + .setTitle("请输入后台服务器地址") + .setDefaultValue(defaultValue) + .setNegativeButton("取消") + .setPositiveButton("保存") + .setOnDialogClickListener(object : InputDialog.OnDialogButtonClickListener { + override fun onButtonClick(input: String) { + SaveKeyValues.putValue(Constant.DEFAULT_SERVER_CONFIG, input) + } + }) + .build().show() + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt new file mode 100644 index 0000000..0e97af7 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt @@ -0,0 +1,21 @@ +package com.casic.birmm.inspect.ui + +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity + +class MainActivity : BaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt new file mode 100644 index 0000000..21fbba2 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt @@ -0,0 +1,58 @@ +package com.casic.birmm.inspect.ui + +import android.content.Intent +import android.os.Build +import android.os.Bundle +import android.util.Log +import androidx.appcompat.app.AppCompatActivity +import com.casic.birmm.inspect.utils.Constant +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + companion object { + private const val TAG = "PermissionActivity" + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + if (EasyPermissions.hasPermissions(this, *Constant.USER_PERMISSIONS)) { + startGuideActivity() + } else { + EasyPermissions.requestPermissions( + this, + "需要获取相关权限", + Constant.PERMISSIONS_CODE, + *Constant.USER_PERMISSIONS + ) + } + } else { + startGuideActivity() + } + } + + private fun startGuideActivity() { + startActivity(Intent(this, GuideActivity::class.java)) + finish() + } + + override fun onRequestPermissionsResult( + requestCode: Int, + permissions: Array, + grantResults: IntArray + ) { + super.onRequestPermissionsResult(requestCode, permissions, grantResults) + EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this) + } + + override fun onPermissionsGranted(requestCode: Int, perms: List) { + startGuideActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + Log.e(TAG, "onPermissionsDenied: $perms") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt new file mode 100644 index 0000000..53df6e1 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt @@ -0,0 +1,15 @@ +package com.casic.birmm.inspect.utils + +import android.Manifest + + +object Constant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.ACCESS_LOCATION_EXTRA_COMMANDS, + Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION + ) + + const val PERMISSIONS_CODE = 999 + + const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt new file mode 100644 index 0000000..4c38241 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt @@ -0,0 +1,19 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.view.View +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object OtherUtils { + + //替换Toast + fun showTipsDialog(context: Context, message: String, view: View) { + val tipDialog = QMUITipDialog.Builder(context) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_NOTHING) + .setTipWord(message).create() + tipDialog.show() + view.postDelayed({ + tipDialog.dismiss() + }, 2000) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt b/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt new file mode 100644 index 0000000..04c9f5a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt @@ -0,0 +1,106 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.content.SharedPreferences +import com.casic.birmm.inspect.base.BaseApplication + +object SaveKeyValues { + private var sharedPreferences: SharedPreferences? = null + private var editor: SharedPreferences.Editor? = null + private var fileName: String? = null + + fun initSharedPreferences() { + val packageName = BaseApplication.instance.packageName + //获取到的包名带有“.”方便命名,取最后一个作为sp文件名,例如:com.casic.birmm.inspect + val split = packageName.split(".") + fileName = split[split.size - 1] + } + + /** + * 存储 + */ + fun putValue(key: String?, obj: Any) { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + val editor = sharedPreferences!!.edit() + when (obj) { + is String -> { + editor.putString(key, obj).apply() + } + is Int -> { + editor.putInt(key, obj).apply() + } + is Boolean -> { + editor.putBoolean(key, obj).apply() + } + is Float -> { + editor.putFloat(key, obj).apply() + } + is Long -> { + editor.putLong(key, obj).apply() + } + else -> { + editor.putString(key, obj.toString()).apply() + } + } + } + + /** + * 获取保存的数据 + */ + operator fun getValue(key: String?, defaultObject: Any?): Any? { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + return when (defaultObject) { + is String -> { + sharedPreferences!!.getString(key, defaultObject as String?) + } + is Int -> { + sharedPreferences!!.getInt(key, (defaultObject as Int?)!!) + } + is Boolean -> { + sharedPreferences!!.getBoolean(key, (defaultObject as Boolean?)!!) + } + is Float -> { + sharedPreferences!!.getFloat(key, (defaultObject as Float?)!!) + } + is Long -> { + sharedPreferences!!.getLong(key, (defaultObject as Long?)!!) + } + else -> { + sharedPreferences!!.getString(key, null) + } + } + } + + /** + * 移除某个key值已经对应的值 + */ + fun removeKey(key: String?) { + editor!!.remove(key) + editor!!.commit() + } + + /** + * 清除所有数据 + */ + fun clearAll() { + editor!!.clear() + editor!!.commit() + } + + /** + * 查询某个key是否存在 + */ + fun containsKey(key: String?): Boolean { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + return sharedPreferences!!.contains(key) + } +} \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..603b140 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..88ea3aa --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,122 @@ + + + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+ + +
+
\ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..5cd135a --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..7bfef59 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..4ca4a9f --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,67 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' + +android { + compileSdkVersion 30 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.birmm.inspect" + minSdkVersion 21 + targetSdkVersion 30 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'androidx.core:core-ktx:1.3.2' + implementation 'androidx.constraintlayout:constraintlayout:2.0.4' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test.ext:junit:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:1.3.0' + //腾讯Android UI框架 + implementation 'com.qmuiteam:qmui:2.0.0-alpha10' + implementation 'com.qmuiteam:arch:0.3.1' + //沉浸式状态栏。基础依赖包,必须要依赖 + implementation 'com.gyf.immersionbar:immersionbar:3.0.0' + //fragment快速实现 + implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + + //MVP网络请求框架retrofit2+rxjava + implementation 'io.reactivex:rxjava:1.3.8' + implementation 'io.reactivex:rxandroid:1.2.1' + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.6.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + implementation 'com.squareup.retrofit2:adapter-rxjava:2.8.1' + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.8.6' + //Toast提示 + implementation 'com.sdsmdg.tastytoast:tastytoast:0.1.1' + //图片选择框架 + implementation 'com.github.LuckSiege.PictureSelector:picture_library:v2.6.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..ea03309 --- /dev/null +++ b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.casic.birmm.inspect + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.casic.birmm.inspect", appContext.packageName) + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..7096527 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt new file mode 100644 index 0000000..aefdbb6 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt @@ -0,0 +1,36 @@ +package com.casic.birmm.inspect.base + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.qmuiteam.qmui.util.QMUIStatusBarHelper + +abstract class BaseActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(initLayoutView()) + QMUIStatusBarHelper.translucent(this) //沉浸式状态栏 + setupTopBarLayout() + initData() + initEvent() + } + + /** + * 初始化xml布局 + */ + abstract fun initLayoutView(): Int + + /** + * 特定页面定制沉浸式状态栏 + */ + protected abstract fun setupTopBarLayout() + + /** + * 初始化默认数据 + */ + abstract fun initData() + + /** + * 初始化业务逻辑 + */ + abstract fun initEvent() +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt new file mode 100644 index 0000000..fc0ca75 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt @@ -0,0 +1,18 @@ +package com.casic.birmm.inspect.base + +import android.app.Application +import com.casic.birmm.inspect.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + companion object { + var instance: BaseApplication by Delegates.notNull() + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt new file mode 100644 index 0000000..ddc160a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt @@ -0,0 +1,56 @@ +package com.casic.birmm.inspect.ui + +import android.annotation.SuppressLint +import android.content.Intent +import android.os.CountDownTimer +import android.view.ViewGroup.MarginLayoutParams +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.activity_guide.* + +@SuppressLint("SetTextI18n") +class GuideActivity : BaseActivity() { + + private lateinit var countDownTimer: CountDownTimer + + override fun initLayoutView(): Int = R.layout.activity_guide + + override fun setupTopBarLayout() { + + } + + override fun initData() { + //根据不同设备状态栏高度设置"跳过"按钮的Margin值 + val statusBarHeight = QMUIDisplayHelper.getStatusBarHeight(this) + val rightMargin = QMUIDisplayHelper.dp2px(this, 10) + if (skipButton.layoutParams is MarginLayoutParams) { + val params = skipButton.layoutParams as MarginLayoutParams + params.setMargins(skipButton.width, statusBarHeight, rightMargin, 0) + skipButton.requestLayout() + } + + countDownTimer = object : CountDownTimer(4000, 1000) { + override fun onFinish() { + startLoginActivity() + } + + override fun onTick(millisUntilFinished: Long) { + skipButton.text = "跳过\u3000${(millisUntilFinished / 1000)}s" + } + } + } + + override fun initEvent() { + countDownTimer.start() + skipButton.setOnClickListener { + countDownTimer.cancel() + startLoginActivity() + } + } + + fun startLoginActivity() { + startActivity(Intent(this, LoginActivity::class.java)) + finish() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt new file mode 100644 index 0000000..6ef4548 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt @@ -0,0 +1,81 @@ +package com.casic.birmm.inspect.ui + +import android.text.Editable +import android.text.TextWatcher +import android.view.KeyEvent +import android.view.inputmethod.EditorInfo +import android.widget.EditText +import android.widget.TextView +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.casic.birmm.inspect.utils.Constant +import com.casic.birmm.inspect.utils.SaveKeyValues +import com.casic.birmm.inspect.widgets.InputDialog +import kotlinx.android.synthetic.main.activity_login.* + + +class LoginActivity : BaseActivity() { + + companion object { + private const val Tag = "LoginActivity" + } + + override fun initLayoutView(): Int = R.layout.activity_login + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + loginButton.setChangeAlphaWhenPress(true) + val editText: EditText? = inputLayout.editText + editText?.addTextChangedListener(object : TextWatcher { + override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) { + + } + + override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) { + + } + + override fun afterTextChanged(s: Editable) { + if (s.toString().trim { it <= ' ' }.length > 12) { + inputLayout.error = "密码长度超出限制" + } else { + inputLayout.error = null + } + } + }) + //点击输入法键盘"完成" + editText?.setOnEditorActionListener { _: TextView?, actionId: Int, _: KeyEvent? -> + if (actionId == EditorInfo.IME_ACTION_DONE) { +// authenticatePresenter.onReadyRetrofitRequest() + return@setOnEditorActionListener true + } + false + } + + //修改服务器配置 + changeServerConfigView.setOnClickListener { + val defaultValue = SaveKeyValues.getValue( + Constant.DEFAULT_SERVER_CONFIG, + "http://139.198.6.177:8093/" + ) as String + InputDialog.Builder().setContext(this) + .setTitle("请输入后台服务器地址") + .setDefaultValue(defaultValue) + .setNegativeButton("取消") + .setPositiveButton("保存") + .setOnDialogClickListener(object : InputDialog.OnDialogButtonClickListener { + override fun onButtonClick(input: String) { + SaveKeyValues.putValue(Constant.DEFAULT_SERVER_CONFIG, input) + } + }) + .build().show() + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt new file mode 100644 index 0000000..0e97af7 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt @@ -0,0 +1,21 @@ +package com.casic.birmm.inspect.ui + +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity + +class MainActivity : BaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt new file mode 100644 index 0000000..21fbba2 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt @@ -0,0 +1,58 @@ +package com.casic.birmm.inspect.ui + +import android.content.Intent +import android.os.Build +import android.os.Bundle +import android.util.Log +import androidx.appcompat.app.AppCompatActivity +import com.casic.birmm.inspect.utils.Constant +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + companion object { + private const val TAG = "PermissionActivity" + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + if (EasyPermissions.hasPermissions(this, *Constant.USER_PERMISSIONS)) { + startGuideActivity() + } else { + EasyPermissions.requestPermissions( + this, + "需要获取相关权限", + Constant.PERMISSIONS_CODE, + *Constant.USER_PERMISSIONS + ) + } + } else { + startGuideActivity() + } + } + + private fun startGuideActivity() { + startActivity(Intent(this, GuideActivity::class.java)) + finish() + } + + override fun onRequestPermissionsResult( + requestCode: Int, + permissions: Array, + grantResults: IntArray + ) { + super.onRequestPermissionsResult(requestCode, permissions, grantResults) + EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this) + } + + override fun onPermissionsGranted(requestCode: Int, perms: List) { + startGuideActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + Log.e(TAG, "onPermissionsDenied: $perms") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt new file mode 100644 index 0000000..53df6e1 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt @@ -0,0 +1,15 @@ +package com.casic.birmm.inspect.utils + +import android.Manifest + + +object Constant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.ACCESS_LOCATION_EXTRA_COMMANDS, + Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION + ) + + const val PERMISSIONS_CODE = 999 + + const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt new file mode 100644 index 0000000..4c38241 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt @@ -0,0 +1,19 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.view.View +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object OtherUtils { + + //替换Toast + fun showTipsDialog(context: Context, message: String, view: View) { + val tipDialog = QMUITipDialog.Builder(context) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_NOTHING) + .setTipWord(message).create() + tipDialog.show() + view.postDelayed({ + tipDialog.dismiss() + }, 2000) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt b/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt new file mode 100644 index 0000000..04c9f5a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt @@ -0,0 +1,106 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.content.SharedPreferences +import com.casic.birmm.inspect.base.BaseApplication + +object SaveKeyValues { + private var sharedPreferences: SharedPreferences? = null + private var editor: SharedPreferences.Editor? = null + private var fileName: String? = null + + fun initSharedPreferences() { + val packageName = BaseApplication.instance.packageName + //获取到的包名带有“.”方便命名,取最后一个作为sp文件名,例如:com.casic.birmm.inspect + val split = packageName.split(".") + fileName = split[split.size - 1] + } + + /** + * 存储 + */ + fun putValue(key: String?, obj: Any) { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + val editor = sharedPreferences!!.edit() + when (obj) { + is String -> { + editor.putString(key, obj).apply() + } + is Int -> { + editor.putInt(key, obj).apply() + } + is Boolean -> { + editor.putBoolean(key, obj).apply() + } + is Float -> { + editor.putFloat(key, obj).apply() + } + is Long -> { + editor.putLong(key, obj).apply() + } + else -> { + editor.putString(key, obj.toString()).apply() + } + } + } + + /** + * 获取保存的数据 + */ + operator fun getValue(key: String?, defaultObject: Any?): Any? { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + return when (defaultObject) { + is String -> { + sharedPreferences!!.getString(key, defaultObject as String?) + } + is Int -> { + sharedPreferences!!.getInt(key, (defaultObject as Int?)!!) + } + is Boolean -> { + sharedPreferences!!.getBoolean(key, (defaultObject as Boolean?)!!) + } + is Float -> { + sharedPreferences!!.getFloat(key, (defaultObject as Float?)!!) + } + is Long -> { + sharedPreferences!!.getLong(key, (defaultObject as Long?)!!) + } + else -> { + sharedPreferences!!.getString(key, null) + } + } + } + + /** + * 移除某个key值已经对应的值 + */ + fun removeKey(key: String?) { + editor!!.remove(key) + editor!!.commit() + } + + /** + * 清除所有数据 + */ + fun clearAll() { + editor!!.clear() + editor!!.commit() + } + + /** + * 查询某个key是否存在 + */ + fun containsKey(key: String?): Boolean { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + return sharedPreferences!!.contains(key) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt b/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt new file mode 100644 index 0000000..04db86b --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt @@ -0,0 +1,119 @@ +package com.casic.birmm.inspect.widgets + +import android.app.Dialog +import android.content.Context +import android.graphics.Color +import android.graphics.drawable.ColorDrawable +import android.os.Bundle +import android.view.WindowManager +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.utils.OtherUtils +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.dialog_input.* + + +class InputDialog private constructor(builder: Builder) : Dialog(builder.mContext!!) { + + private var ctx: Context? = null + private var title: String? = null + private var value: String? = null + private var positiveBtn: String? = null + private var negativeBtn: String? = null + private var listener: OnDialogButtonClickListener? = null + + init { + this.ctx = builder.mContext + this.title = builder.title + this.value = builder.value + this.positiveBtn = builder.positiveBtn + this.negativeBtn = builder.negativeBtn + this.listener = builder.listener + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + configDialogLayout() + setContentView(R.layout.dialog_input) + setCancelable(false) + setCanceledOnTouchOutside(false) + + dialogTitleView.text = title + value.apply { + dialogInputView.setText(this) + } + + dialogCancelButton.text = negativeBtn + dialogCancelButton.setChangeAlphaWhenPress(true) + dialogCancelButton.setOnClickListener { + this.dismiss() + } + + dialogConfirmButton.text = positiveBtn + dialogConfirmButton.setChangeAlphaWhenPress(true) + dialogConfirmButton.setOnClickListener { + val inputValue = dialogInputView.text.toString().trim() + if (inputValue.isEmpty()) { + OtherUtils.showTipsDialog(ctx!!, "什么都没输入,请重新输入", dialogConfirmButton) + return@setOnClickListener + } + listener?.onButtonClick(inputValue) + this.dismiss() + } + } + + private fun configDialogLayout() { + window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT)) + window?.decorView?.setBackgroundColor(Color.TRANSPARENT) + val params: WindowManager.LayoutParams? = window?.attributes + params?.width = QMUIDisplayHelper.dp2px(ctx, 300) + params?.height = WindowManager.LayoutParams.WRAP_CONTENT + window?.attributes = params + } + + class Builder { + var mContext: Context? = null + var title: String? = null + var value: String? = null + var positiveBtn: String? = null + var negativeBtn: String? = null + var listener: OnDialogButtonClickListener? = null + + fun setContext(context: Context?): Builder { + mContext = context + return this + } + + fun setTitle(title: String?): Builder { + this.title = title + return this + } + + fun setDefaultValue(value: String?): Builder { + this.value = value + return this + } + + fun setPositiveButton(name: String?): Builder { + positiveBtn = name + return this + } + + fun setNegativeButton(name: String?): Builder { + negativeBtn = name + return this + } + + fun setOnDialogClickListener(listener: OnDialogButtonClickListener): Builder { + this.listener = listener + return this + } + + fun build(): InputDialog { + return InputDialog(this) + } + } + + interface OnDialogButtonClickListener { + fun onButtonClick(input: String) + } +} \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..603b140 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..88ea3aa --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,122 @@ + + + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+ + +
+
\ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..5cd135a --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..7bfef59 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..4ca4a9f --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,67 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' + +android { + compileSdkVersion 30 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.birmm.inspect" + minSdkVersion 21 + targetSdkVersion 30 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'androidx.core:core-ktx:1.3.2' + implementation 'androidx.constraintlayout:constraintlayout:2.0.4' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test.ext:junit:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:1.3.0' + //腾讯Android UI框架 + implementation 'com.qmuiteam:qmui:2.0.0-alpha10' + implementation 'com.qmuiteam:arch:0.3.1' + //沉浸式状态栏。基础依赖包,必须要依赖 + implementation 'com.gyf.immersionbar:immersionbar:3.0.0' + //fragment快速实现 + implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + + //MVP网络请求框架retrofit2+rxjava + implementation 'io.reactivex:rxjava:1.3.8' + implementation 'io.reactivex:rxandroid:1.2.1' + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.6.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + implementation 'com.squareup.retrofit2:adapter-rxjava:2.8.1' + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.8.6' + //Toast提示 + implementation 'com.sdsmdg.tastytoast:tastytoast:0.1.1' + //图片选择框架 + implementation 'com.github.LuckSiege.PictureSelector:picture_library:v2.6.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..ea03309 --- /dev/null +++ b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.casic.birmm.inspect + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.casic.birmm.inspect", appContext.packageName) + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..7096527 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt new file mode 100644 index 0000000..aefdbb6 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt @@ -0,0 +1,36 @@ +package com.casic.birmm.inspect.base + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.qmuiteam.qmui.util.QMUIStatusBarHelper + +abstract class BaseActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(initLayoutView()) + QMUIStatusBarHelper.translucent(this) //沉浸式状态栏 + setupTopBarLayout() + initData() + initEvent() + } + + /** + * 初始化xml布局 + */ + abstract fun initLayoutView(): Int + + /** + * 特定页面定制沉浸式状态栏 + */ + protected abstract fun setupTopBarLayout() + + /** + * 初始化默认数据 + */ + abstract fun initData() + + /** + * 初始化业务逻辑 + */ + abstract fun initEvent() +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt new file mode 100644 index 0000000..fc0ca75 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt @@ -0,0 +1,18 @@ +package com.casic.birmm.inspect.base + +import android.app.Application +import com.casic.birmm.inspect.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + companion object { + var instance: BaseApplication by Delegates.notNull() + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt new file mode 100644 index 0000000..ddc160a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt @@ -0,0 +1,56 @@ +package com.casic.birmm.inspect.ui + +import android.annotation.SuppressLint +import android.content.Intent +import android.os.CountDownTimer +import android.view.ViewGroup.MarginLayoutParams +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.activity_guide.* + +@SuppressLint("SetTextI18n") +class GuideActivity : BaseActivity() { + + private lateinit var countDownTimer: CountDownTimer + + override fun initLayoutView(): Int = R.layout.activity_guide + + override fun setupTopBarLayout() { + + } + + override fun initData() { + //根据不同设备状态栏高度设置"跳过"按钮的Margin值 + val statusBarHeight = QMUIDisplayHelper.getStatusBarHeight(this) + val rightMargin = QMUIDisplayHelper.dp2px(this, 10) + if (skipButton.layoutParams is MarginLayoutParams) { + val params = skipButton.layoutParams as MarginLayoutParams + params.setMargins(skipButton.width, statusBarHeight, rightMargin, 0) + skipButton.requestLayout() + } + + countDownTimer = object : CountDownTimer(4000, 1000) { + override fun onFinish() { + startLoginActivity() + } + + override fun onTick(millisUntilFinished: Long) { + skipButton.text = "跳过\u3000${(millisUntilFinished / 1000)}s" + } + } + } + + override fun initEvent() { + countDownTimer.start() + skipButton.setOnClickListener { + countDownTimer.cancel() + startLoginActivity() + } + } + + fun startLoginActivity() { + startActivity(Intent(this, LoginActivity::class.java)) + finish() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt new file mode 100644 index 0000000..6ef4548 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt @@ -0,0 +1,81 @@ +package com.casic.birmm.inspect.ui + +import android.text.Editable +import android.text.TextWatcher +import android.view.KeyEvent +import android.view.inputmethod.EditorInfo +import android.widget.EditText +import android.widget.TextView +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.casic.birmm.inspect.utils.Constant +import com.casic.birmm.inspect.utils.SaveKeyValues +import com.casic.birmm.inspect.widgets.InputDialog +import kotlinx.android.synthetic.main.activity_login.* + + +class LoginActivity : BaseActivity() { + + companion object { + private const val Tag = "LoginActivity" + } + + override fun initLayoutView(): Int = R.layout.activity_login + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + loginButton.setChangeAlphaWhenPress(true) + val editText: EditText? = inputLayout.editText + editText?.addTextChangedListener(object : TextWatcher { + override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) { + + } + + override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) { + + } + + override fun afterTextChanged(s: Editable) { + if (s.toString().trim { it <= ' ' }.length > 12) { + inputLayout.error = "密码长度超出限制" + } else { + inputLayout.error = null + } + } + }) + //点击输入法键盘"完成" + editText?.setOnEditorActionListener { _: TextView?, actionId: Int, _: KeyEvent? -> + if (actionId == EditorInfo.IME_ACTION_DONE) { +// authenticatePresenter.onReadyRetrofitRequest() + return@setOnEditorActionListener true + } + false + } + + //修改服务器配置 + changeServerConfigView.setOnClickListener { + val defaultValue = SaveKeyValues.getValue( + Constant.DEFAULT_SERVER_CONFIG, + "http://139.198.6.177:8093/" + ) as String + InputDialog.Builder().setContext(this) + .setTitle("请输入后台服务器地址") + .setDefaultValue(defaultValue) + .setNegativeButton("取消") + .setPositiveButton("保存") + .setOnDialogClickListener(object : InputDialog.OnDialogButtonClickListener { + override fun onButtonClick(input: String) { + SaveKeyValues.putValue(Constant.DEFAULT_SERVER_CONFIG, input) + } + }) + .build().show() + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt new file mode 100644 index 0000000..0e97af7 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt @@ -0,0 +1,21 @@ +package com.casic.birmm.inspect.ui + +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity + +class MainActivity : BaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt new file mode 100644 index 0000000..21fbba2 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt @@ -0,0 +1,58 @@ +package com.casic.birmm.inspect.ui + +import android.content.Intent +import android.os.Build +import android.os.Bundle +import android.util.Log +import androidx.appcompat.app.AppCompatActivity +import com.casic.birmm.inspect.utils.Constant +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + companion object { + private const val TAG = "PermissionActivity" + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + if (EasyPermissions.hasPermissions(this, *Constant.USER_PERMISSIONS)) { + startGuideActivity() + } else { + EasyPermissions.requestPermissions( + this, + "需要获取相关权限", + Constant.PERMISSIONS_CODE, + *Constant.USER_PERMISSIONS + ) + } + } else { + startGuideActivity() + } + } + + private fun startGuideActivity() { + startActivity(Intent(this, GuideActivity::class.java)) + finish() + } + + override fun onRequestPermissionsResult( + requestCode: Int, + permissions: Array, + grantResults: IntArray + ) { + super.onRequestPermissionsResult(requestCode, permissions, grantResults) + EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this) + } + + override fun onPermissionsGranted(requestCode: Int, perms: List) { + startGuideActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + Log.e(TAG, "onPermissionsDenied: $perms") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt new file mode 100644 index 0000000..53df6e1 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt @@ -0,0 +1,15 @@ +package com.casic.birmm.inspect.utils + +import android.Manifest + + +object Constant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.ACCESS_LOCATION_EXTRA_COMMANDS, + Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION + ) + + const val PERMISSIONS_CODE = 999 + + const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt new file mode 100644 index 0000000..4c38241 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt @@ -0,0 +1,19 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.view.View +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object OtherUtils { + + //替换Toast + fun showTipsDialog(context: Context, message: String, view: View) { + val tipDialog = QMUITipDialog.Builder(context) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_NOTHING) + .setTipWord(message).create() + tipDialog.show() + view.postDelayed({ + tipDialog.dismiss() + }, 2000) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt b/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt new file mode 100644 index 0000000..04c9f5a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt @@ -0,0 +1,106 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.content.SharedPreferences +import com.casic.birmm.inspect.base.BaseApplication + +object SaveKeyValues { + private var sharedPreferences: SharedPreferences? = null + private var editor: SharedPreferences.Editor? = null + private var fileName: String? = null + + fun initSharedPreferences() { + val packageName = BaseApplication.instance.packageName + //获取到的包名带有“.”方便命名,取最后一个作为sp文件名,例如:com.casic.birmm.inspect + val split = packageName.split(".") + fileName = split[split.size - 1] + } + + /** + * 存储 + */ + fun putValue(key: String?, obj: Any) { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + val editor = sharedPreferences!!.edit() + when (obj) { + is String -> { + editor.putString(key, obj).apply() + } + is Int -> { + editor.putInt(key, obj).apply() + } + is Boolean -> { + editor.putBoolean(key, obj).apply() + } + is Float -> { + editor.putFloat(key, obj).apply() + } + is Long -> { + editor.putLong(key, obj).apply() + } + else -> { + editor.putString(key, obj.toString()).apply() + } + } + } + + /** + * 获取保存的数据 + */ + operator fun getValue(key: String?, defaultObject: Any?): Any? { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + return when (defaultObject) { + is String -> { + sharedPreferences!!.getString(key, defaultObject as String?) + } + is Int -> { + sharedPreferences!!.getInt(key, (defaultObject as Int?)!!) + } + is Boolean -> { + sharedPreferences!!.getBoolean(key, (defaultObject as Boolean?)!!) + } + is Float -> { + sharedPreferences!!.getFloat(key, (defaultObject as Float?)!!) + } + is Long -> { + sharedPreferences!!.getLong(key, (defaultObject as Long?)!!) + } + else -> { + sharedPreferences!!.getString(key, null) + } + } + } + + /** + * 移除某个key值已经对应的值 + */ + fun removeKey(key: String?) { + editor!!.remove(key) + editor!!.commit() + } + + /** + * 清除所有数据 + */ + fun clearAll() { + editor!!.clear() + editor!!.commit() + } + + /** + * 查询某个key是否存在 + */ + fun containsKey(key: String?): Boolean { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + return sharedPreferences!!.contains(key) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt b/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt new file mode 100644 index 0000000..04db86b --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt @@ -0,0 +1,119 @@ +package com.casic.birmm.inspect.widgets + +import android.app.Dialog +import android.content.Context +import android.graphics.Color +import android.graphics.drawable.ColorDrawable +import android.os.Bundle +import android.view.WindowManager +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.utils.OtherUtils +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.dialog_input.* + + +class InputDialog private constructor(builder: Builder) : Dialog(builder.mContext!!) { + + private var ctx: Context? = null + private var title: String? = null + private var value: String? = null + private var positiveBtn: String? = null + private var negativeBtn: String? = null + private var listener: OnDialogButtonClickListener? = null + + init { + this.ctx = builder.mContext + this.title = builder.title + this.value = builder.value + this.positiveBtn = builder.positiveBtn + this.negativeBtn = builder.negativeBtn + this.listener = builder.listener + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + configDialogLayout() + setContentView(R.layout.dialog_input) + setCancelable(false) + setCanceledOnTouchOutside(false) + + dialogTitleView.text = title + value.apply { + dialogInputView.setText(this) + } + + dialogCancelButton.text = negativeBtn + dialogCancelButton.setChangeAlphaWhenPress(true) + dialogCancelButton.setOnClickListener { + this.dismiss() + } + + dialogConfirmButton.text = positiveBtn + dialogConfirmButton.setChangeAlphaWhenPress(true) + dialogConfirmButton.setOnClickListener { + val inputValue = dialogInputView.text.toString().trim() + if (inputValue.isEmpty()) { + OtherUtils.showTipsDialog(ctx!!, "什么都没输入,请重新输入", dialogConfirmButton) + return@setOnClickListener + } + listener?.onButtonClick(inputValue) + this.dismiss() + } + } + + private fun configDialogLayout() { + window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT)) + window?.decorView?.setBackgroundColor(Color.TRANSPARENT) + val params: WindowManager.LayoutParams? = window?.attributes + params?.width = QMUIDisplayHelper.dp2px(ctx, 300) + params?.height = WindowManager.LayoutParams.WRAP_CONTENT + window?.attributes = params + } + + class Builder { + var mContext: Context? = null + var title: String? = null + var value: String? = null + var positiveBtn: String? = null + var negativeBtn: String? = null + var listener: OnDialogButtonClickListener? = null + + fun setContext(context: Context?): Builder { + mContext = context + return this + } + + fun setTitle(title: String?): Builder { + this.title = title + return this + } + + fun setDefaultValue(value: String?): Builder { + this.value = value + return this + } + + fun setPositiveButton(name: String?): Builder { + positiveBtn = name + return this + } + + fun setNegativeButton(name: String?): Builder { + negativeBtn = name + return this + } + + fun setOnDialogClickListener(listener: OnDialogButtonClickListener): Builder { + this.listener = listener + return this + } + + fun build(): InputDialog { + return InputDialog(this) + } + } + + interface OnDialogButtonClickListener { + fun onButtonClick(input: String) + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..603b140 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..88ea3aa --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,122 @@ + + + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+ + +
+
\ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..5cd135a --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..7bfef59 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..4ca4a9f --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,67 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' + +android { + compileSdkVersion 30 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.birmm.inspect" + minSdkVersion 21 + targetSdkVersion 30 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'androidx.core:core-ktx:1.3.2' + implementation 'androidx.constraintlayout:constraintlayout:2.0.4' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test.ext:junit:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:1.3.0' + //腾讯Android UI框架 + implementation 'com.qmuiteam:qmui:2.0.0-alpha10' + implementation 'com.qmuiteam:arch:0.3.1' + //沉浸式状态栏。基础依赖包,必须要依赖 + implementation 'com.gyf.immersionbar:immersionbar:3.0.0' + //fragment快速实现 + implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + + //MVP网络请求框架retrofit2+rxjava + implementation 'io.reactivex:rxjava:1.3.8' + implementation 'io.reactivex:rxandroid:1.2.1' + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.6.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + implementation 'com.squareup.retrofit2:adapter-rxjava:2.8.1' + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.8.6' + //Toast提示 + implementation 'com.sdsmdg.tastytoast:tastytoast:0.1.1' + //图片选择框架 + implementation 'com.github.LuckSiege.PictureSelector:picture_library:v2.6.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..ea03309 --- /dev/null +++ b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.casic.birmm.inspect + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.casic.birmm.inspect", appContext.packageName) + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..7096527 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt new file mode 100644 index 0000000..aefdbb6 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt @@ -0,0 +1,36 @@ +package com.casic.birmm.inspect.base + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.qmuiteam.qmui.util.QMUIStatusBarHelper + +abstract class BaseActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(initLayoutView()) + QMUIStatusBarHelper.translucent(this) //沉浸式状态栏 + setupTopBarLayout() + initData() + initEvent() + } + + /** + * 初始化xml布局 + */ + abstract fun initLayoutView(): Int + + /** + * 特定页面定制沉浸式状态栏 + */ + protected abstract fun setupTopBarLayout() + + /** + * 初始化默认数据 + */ + abstract fun initData() + + /** + * 初始化业务逻辑 + */ + abstract fun initEvent() +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt new file mode 100644 index 0000000..fc0ca75 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt @@ -0,0 +1,18 @@ +package com.casic.birmm.inspect.base + +import android.app.Application +import com.casic.birmm.inspect.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + companion object { + var instance: BaseApplication by Delegates.notNull() + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt new file mode 100644 index 0000000..ddc160a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt @@ -0,0 +1,56 @@ +package com.casic.birmm.inspect.ui + +import android.annotation.SuppressLint +import android.content.Intent +import android.os.CountDownTimer +import android.view.ViewGroup.MarginLayoutParams +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.activity_guide.* + +@SuppressLint("SetTextI18n") +class GuideActivity : BaseActivity() { + + private lateinit var countDownTimer: CountDownTimer + + override fun initLayoutView(): Int = R.layout.activity_guide + + override fun setupTopBarLayout() { + + } + + override fun initData() { + //根据不同设备状态栏高度设置"跳过"按钮的Margin值 + val statusBarHeight = QMUIDisplayHelper.getStatusBarHeight(this) + val rightMargin = QMUIDisplayHelper.dp2px(this, 10) + if (skipButton.layoutParams is MarginLayoutParams) { + val params = skipButton.layoutParams as MarginLayoutParams + params.setMargins(skipButton.width, statusBarHeight, rightMargin, 0) + skipButton.requestLayout() + } + + countDownTimer = object : CountDownTimer(4000, 1000) { + override fun onFinish() { + startLoginActivity() + } + + override fun onTick(millisUntilFinished: Long) { + skipButton.text = "跳过\u3000${(millisUntilFinished / 1000)}s" + } + } + } + + override fun initEvent() { + countDownTimer.start() + skipButton.setOnClickListener { + countDownTimer.cancel() + startLoginActivity() + } + } + + fun startLoginActivity() { + startActivity(Intent(this, LoginActivity::class.java)) + finish() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt new file mode 100644 index 0000000..6ef4548 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt @@ -0,0 +1,81 @@ +package com.casic.birmm.inspect.ui + +import android.text.Editable +import android.text.TextWatcher +import android.view.KeyEvent +import android.view.inputmethod.EditorInfo +import android.widget.EditText +import android.widget.TextView +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.casic.birmm.inspect.utils.Constant +import com.casic.birmm.inspect.utils.SaveKeyValues +import com.casic.birmm.inspect.widgets.InputDialog +import kotlinx.android.synthetic.main.activity_login.* + + +class LoginActivity : BaseActivity() { + + companion object { + private const val Tag = "LoginActivity" + } + + override fun initLayoutView(): Int = R.layout.activity_login + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + loginButton.setChangeAlphaWhenPress(true) + val editText: EditText? = inputLayout.editText + editText?.addTextChangedListener(object : TextWatcher { + override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) { + + } + + override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) { + + } + + override fun afterTextChanged(s: Editable) { + if (s.toString().trim { it <= ' ' }.length > 12) { + inputLayout.error = "密码长度超出限制" + } else { + inputLayout.error = null + } + } + }) + //点击输入法键盘"完成" + editText?.setOnEditorActionListener { _: TextView?, actionId: Int, _: KeyEvent? -> + if (actionId == EditorInfo.IME_ACTION_DONE) { +// authenticatePresenter.onReadyRetrofitRequest() + return@setOnEditorActionListener true + } + false + } + + //修改服务器配置 + changeServerConfigView.setOnClickListener { + val defaultValue = SaveKeyValues.getValue( + Constant.DEFAULT_SERVER_CONFIG, + "http://139.198.6.177:8093/" + ) as String + InputDialog.Builder().setContext(this) + .setTitle("请输入后台服务器地址") + .setDefaultValue(defaultValue) + .setNegativeButton("取消") + .setPositiveButton("保存") + .setOnDialogClickListener(object : InputDialog.OnDialogButtonClickListener { + override fun onButtonClick(input: String) { + SaveKeyValues.putValue(Constant.DEFAULT_SERVER_CONFIG, input) + } + }) + .build().show() + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt new file mode 100644 index 0000000..0e97af7 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt @@ -0,0 +1,21 @@ +package com.casic.birmm.inspect.ui + +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity + +class MainActivity : BaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt new file mode 100644 index 0000000..21fbba2 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt @@ -0,0 +1,58 @@ +package com.casic.birmm.inspect.ui + +import android.content.Intent +import android.os.Build +import android.os.Bundle +import android.util.Log +import androidx.appcompat.app.AppCompatActivity +import com.casic.birmm.inspect.utils.Constant +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + companion object { + private const val TAG = "PermissionActivity" + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + if (EasyPermissions.hasPermissions(this, *Constant.USER_PERMISSIONS)) { + startGuideActivity() + } else { + EasyPermissions.requestPermissions( + this, + "需要获取相关权限", + Constant.PERMISSIONS_CODE, + *Constant.USER_PERMISSIONS + ) + } + } else { + startGuideActivity() + } + } + + private fun startGuideActivity() { + startActivity(Intent(this, GuideActivity::class.java)) + finish() + } + + override fun onRequestPermissionsResult( + requestCode: Int, + permissions: Array, + grantResults: IntArray + ) { + super.onRequestPermissionsResult(requestCode, permissions, grantResults) + EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this) + } + + override fun onPermissionsGranted(requestCode: Int, perms: List) { + startGuideActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + Log.e(TAG, "onPermissionsDenied: $perms") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt new file mode 100644 index 0000000..53df6e1 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt @@ -0,0 +1,15 @@ +package com.casic.birmm.inspect.utils + +import android.Manifest + + +object Constant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.ACCESS_LOCATION_EXTRA_COMMANDS, + Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION + ) + + const val PERMISSIONS_CODE = 999 + + const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt new file mode 100644 index 0000000..4c38241 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt @@ -0,0 +1,19 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.view.View +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object OtherUtils { + + //替换Toast + fun showTipsDialog(context: Context, message: String, view: View) { + val tipDialog = QMUITipDialog.Builder(context) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_NOTHING) + .setTipWord(message).create() + tipDialog.show() + view.postDelayed({ + tipDialog.dismiss() + }, 2000) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt b/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt new file mode 100644 index 0000000..04c9f5a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt @@ -0,0 +1,106 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.content.SharedPreferences +import com.casic.birmm.inspect.base.BaseApplication + +object SaveKeyValues { + private var sharedPreferences: SharedPreferences? = null + private var editor: SharedPreferences.Editor? = null + private var fileName: String? = null + + fun initSharedPreferences() { + val packageName = BaseApplication.instance.packageName + //获取到的包名带有“.”方便命名,取最后一个作为sp文件名,例如:com.casic.birmm.inspect + val split = packageName.split(".") + fileName = split[split.size - 1] + } + + /** + * 存储 + */ + fun putValue(key: String?, obj: Any) { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + val editor = sharedPreferences!!.edit() + when (obj) { + is String -> { + editor.putString(key, obj).apply() + } + is Int -> { + editor.putInt(key, obj).apply() + } + is Boolean -> { + editor.putBoolean(key, obj).apply() + } + is Float -> { + editor.putFloat(key, obj).apply() + } + is Long -> { + editor.putLong(key, obj).apply() + } + else -> { + editor.putString(key, obj.toString()).apply() + } + } + } + + /** + * 获取保存的数据 + */ + operator fun getValue(key: String?, defaultObject: Any?): Any? { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + return when (defaultObject) { + is String -> { + sharedPreferences!!.getString(key, defaultObject as String?) + } + is Int -> { + sharedPreferences!!.getInt(key, (defaultObject as Int?)!!) + } + is Boolean -> { + sharedPreferences!!.getBoolean(key, (defaultObject as Boolean?)!!) + } + is Float -> { + sharedPreferences!!.getFloat(key, (defaultObject as Float?)!!) + } + is Long -> { + sharedPreferences!!.getLong(key, (defaultObject as Long?)!!) + } + else -> { + sharedPreferences!!.getString(key, null) + } + } + } + + /** + * 移除某个key值已经对应的值 + */ + fun removeKey(key: String?) { + editor!!.remove(key) + editor!!.commit() + } + + /** + * 清除所有数据 + */ + fun clearAll() { + editor!!.clear() + editor!!.commit() + } + + /** + * 查询某个key是否存在 + */ + fun containsKey(key: String?): Boolean { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + return sharedPreferences!!.contains(key) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt b/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt new file mode 100644 index 0000000..04db86b --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt @@ -0,0 +1,119 @@ +package com.casic.birmm.inspect.widgets + +import android.app.Dialog +import android.content.Context +import android.graphics.Color +import android.graphics.drawable.ColorDrawable +import android.os.Bundle +import android.view.WindowManager +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.utils.OtherUtils +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.dialog_input.* + + +class InputDialog private constructor(builder: Builder) : Dialog(builder.mContext!!) { + + private var ctx: Context? = null + private var title: String? = null + private var value: String? = null + private var positiveBtn: String? = null + private var negativeBtn: String? = null + private var listener: OnDialogButtonClickListener? = null + + init { + this.ctx = builder.mContext + this.title = builder.title + this.value = builder.value + this.positiveBtn = builder.positiveBtn + this.negativeBtn = builder.negativeBtn + this.listener = builder.listener + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + configDialogLayout() + setContentView(R.layout.dialog_input) + setCancelable(false) + setCanceledOnTouchOutside(false) + + dialogTitleView.text = title + value.apply { + dialogInputView.setText(this) + } + + dialogCancelButton.text = negativeBtn + dialogCancelButton.setChangeAlphaWhenPress(true) + dialogCancelButton.setOnClickListener { + this.dismiss() + } + + dialogConfirmButton.text = positiveBtn + dialogConfirmButton.setChangeAlphaWhenPress(true) + dialogConfirmButton.setOnClickListener { + val inputValue = dialogInputView.text.toString().trim() + if (inputValue.isEmpty()) { + OtherUtils.showTipsDialog(ctx!!, "什么都没输入,请重新输入", dialogConfirmButton) + return@setOnClickListener + } + listener?.onButtonClick(inputValue) + this.dismiss() + } + } + + private fun configDialogLayout() { + window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT)) + window?.decorView?.setBackgroundColor(Color.TRANSPARENT) + val params: WindowManager.LayoutParams? = window?.attributes + params?.width = QMUIDisplayHelper.dp2px(ctx, 300) + params?.height = WindowManager.LayoutParams.WRAP_CONTENT + window?.attributes = params + } + + class Builder { + var mContext: Context? = null + var title: String? = null + var value: String? = null + var positiveBtn: String? = null + var negativeBtn: String? = null + var listener: OnDialogButtonClickListener? = null + + fun setContext(context: Context?): Builder { + mContext = context + return this + } + + fun setTitle(title: String?): Builder { + this.title = title + return this + } + + fun setDefaultValue(value: String?): Builder { + this.value = value + return this + } + + fun setPositiveButton(name: String?): Builder { + positiveBtn = name + return this + } + + fun setNegativeButton(name: String?): Builder { + negativeBtn = name + return this + } + + fun setOnDialogClickListener(listener: OnDialogButtonClickListener): Builder { + this.listener = listener + return this + } + + fun build(): InputDialog { + return InputDialog(this) + } + } + + interface OnDialogButtonClickListener { + fun onButtonClick(input: String) + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_dialog_button.xml b/app/src/main/res/drawable/bg_dialog_button.xml new file mode 100644 index 0000000..5f7d57d --- /dev/null +++ b/app/src/main/res/drawable/bg_dialog_button.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..603b140 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..88ea3aa --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,122 @@ + + + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+ + +
+
\ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..5cd135a --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..7bfef59 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..4ca4a9f --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,67 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' + +android { + compileSdkVersion 30 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.birmm.inspect" + minSdkVersion 21 + targetSdkVersion 30 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'androidx.core:core-ktx:1.3.2' + implementation 'androidx.constraintlayout:constraintlayout:2.0.4' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test.ext:junit:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:1.3.0' + //腾讯Android UI框架 + implementation 'com.qmuiteam:qmui:2.0.0-alpha10' + implementation 'com.qmuiteam:arch:0.3.1' + //沉浸式状态栏。基础依赖包,必须要依赖 + implementation 'com.gyf.immersionbar:immersionbar:3.0.0' + //fragment快速实现 + implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + + //MVP网络请求框架retrofit2+rxjava + implementation 'io.reactivex:rxjava:1.3.8' + implementation 'io.reactivex:rxandroid:1.2.1' + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.6.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + implementation 'com.squareup.retrofit2:adapter-rxjava:2.8.1' + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.8.6' + //Toast提示 + implementation 'com.sdsmdg.tastytoast:tastytoast:0.1.1' + //图片选择框架 + implementation 'com.github.LuckSiege.PictureSelector:picture_library:v2.6.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..ea03309 --- /dev/null +++ b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.casic.birmm.inspect + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.casic.birmm.inspect", appContext.packageName) + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..7096527 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt new file mode 100644 index 0000000..aefdbb6 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt @@ -0,0 +1,36 @@ +package com.casic.birmm.inspect.base + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.qmuiteam.qmui.util.QMUIStatusBarHelper + +abstract class BaseActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(initLayoutView()) + QMUIStatusBarHelper.translucent(this) //沉浸式状态栏 + setupTopBarLayout() + initData() + initEvent() + } + + /** + * 初始化xml布局 + */ + abstract fun initLayoutView(): Int + + /** + * 特定页面定制沉浸式状态栏 + */ + protected abstract fun setupTopBarLayout() + + /** + * 初始化默认数据 + */ + abstract fun initData() + + /** + * 初始化业务逻辑 + */ + abstract fun initEvent() +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt new file mode 100644 index 0000000..fc0ca75 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt @@ -0,0 +1,18 @@ +package com.casic.birmm.inspect.base + +import android.app.Application +import com.casic.birmm.inspect.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + companion object { + var instance: BaseApplication by Delegates.notNull() + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt new file mode 100644 index 0000000..ddc160a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt @@ -0,0 +1,56 @@ +package com.casic.birmm.inspect.ui + +import android.annotation.SuppressLint +import android.content.Intent +import android.os.CountDownTimer +import android.view.ViewGroup.MarginLayoutParams +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.activity_guide.* + +@SuppressLint("SetTextI18n") +class GuideActivity : BaseActivity() { + + private lateinit var countDownTimer: CountDownTimer + + override fun initLayoutView(): Int = R.layout.activity_guide + + override fun setupTopBarLayout() { + + } + + override fun initData() { + //根据不同设备状态栏高度设置"跳过"按钮的Margin值 + val statusBarHeight = QMUIDisplayHelper.getStatusBarHeight(this) + val rightMargin = QMUIDisplayHelper.dp2px(this, 10) + if (skipButton.layoutParams is MarginLayoutParams) { + val params = skipButton.layoutParams as MarginLayoutParams + params.setMargins(skipButton.width, statusBarHeight, rightMargin, 0) + skipButton.requestLayout() + } + + countDownTimer = object : CountDownTimer(4000, 1000) { + override fun onFinish() { + startLoginActivity() + } + + override fun onTick(millisUntilFinished: Long) { + skipButton.text = "跳过\u3000${(millisUntilFinished / 1000)}s" + } + } + } + + override fun initEvent() { + countDownTimer.start() + skipButton.setOnClickListener { + countDownTimer.cancel() + startLoginActivity() + } + } + + fun startLoginActivity() { + startActivity(Intent(this, LoginActivity::class.java)) + finish() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt new file mode 100644 index 0000000..6ef4548 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt @@ -0,0 +1,81 @@ +package com.casic.birmm.inspect.ui + +import android.text.Editable +import android.text.TextWatcher +import android.view.KeyEvent +import android.view.inputmethod.EditorInfo +import android.widget.EditText +import android.widget.TextView +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.casic.birmm.inspect.utils.Constant +import com.casic.birmm.inspect.utils.SaveKeyValues +import com.casic.birmm.inspect.widgets.InputDialog +import kotlinx.android.synthetic.main.activity_login.* + + +class LoginActivity : BaseActivity() { + + companion object { + private const val Tag = "LoginActivity" + } + + override fun initLayoutView(): Int = R.layout.activity_login + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + loginButton.setChangeAlphaWhenPress(true) + val editText: EditText? = inputLayout.editText + editText?.addTextChangedListener(object : TextWatcher { + override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) { + + } + + override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) { + + } + + override fun afterTextChanged(s: Editable) { + if (s.toString().trim { it <= ' ' }.length > 12) { + inputLayout.error = "密码长度超出限制" + } else { + inputLayout.error = null + } + } + }) + //点击输入法键盘"完成" + editText?.setOnEditorActionListener { _: TextView?, actionId: Int, _: KeyEvent? -> + if (actionId == EditorInfo.IME_ACTION_DONE) { +// authenticatePresenter.onReadyRetrofitRequest() + return@setOnEditorActionListener true + } + false + } + + //修改服务器配置 + changeServerConfigView.setOnClickListener { + val defaultValue = SaveKeyValues.getValue( + Constant.DEFAULT_SERVER_CONFIG, + "http://139.198.6.177:8093/" + ) as String + InputDialog.Builder().setContext(this) + .setTitle("请输入后台服务器地址") + .setDefaultValue(defaultValue) + .setNegativeButton("取消") + .setPositiveButton("保存") + .setOnDialogClickListener(object : InputDialog.OnDialogButtonClickListener { + override fun onButtonClick(input: String) { + SaveKeyValues.putValue(Constant.DEFAULT_SERVER_CONFIG, input) + } + }) + .build().show() + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt new file mode 100644 index 0000000..0e97af7 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt @@ -0,0 +1,21 @@ +package com.casic.birmm.inspect.ui + +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity + +class MainActivity : BaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt new file mode 100644 index 0000000..21fbba2 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt @@ -0,0 +1,58 @@ +package com.casic.birmm.inspect.ui + +import android.content.Intent +import android.os.Build +import android.os.Bundle +import android.util.Log +import androidx.appcompat.app.AppCompatActivity +import com.casic.birmm.inspect.utils.Constant +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + companion object { + private const val TAG = "PermissionActivity" + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + if (EasyPermissions.hasPermissions(this, *Constant.USER_PERMISSIONS)) { + startGuideActivity() + } else { + EasyPermissions.requestPermissions( + this, + "需要获取相关权限", + Constant.PERMISSIONS_CODE, + *Constant.USER_PERMISSIONS + ) + } + } else { + startGuideActivity() + } + } + + private fun startGuideActivity() { + startActivity(Intent(this, GuideActivity::class.java)) + finish() + } + + override fun onRequestPermissionsResult( + requestCode: Int, + permissions: Array, + grantResults: IntArray + ) { + super.onRequestPermissionsResult(requestCode, permissions, grantResults) + EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this) + } + + override fun onPermissionsGranted(requestCode: Int, perms: List) { + startGuideActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + Log.e(TAG, "onPermissionsDenied: $perms") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt new file mode 100644 index 0000000..53df6e1 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt @@ -0,0 +1,15 @@ +package com.casic.birmm.inspect.utils + +import android.Manifest + + +object Constant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.ACCESS_LOCATION_EXTRA_COMMANDS, + Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION + ) + + const val PERMISSIONS_CODE = 999 + + const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt new file mode 100644 index 0000000..4c38241 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt @@ -0,0 +1,19 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.view.View +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object OtherUtils { + + //替换Toast + fun showTipsDialog(context: Context, message: String, view: View) { + val tipDialog = QMUITipDialog.Builder(context) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_NOTHING) + .setTipWord(message).create() + tipDialog.show() + view.postDelayed({ + tipDialog.dismiss() + }, 2000) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt b/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt new file mode 100644 index 0000000..04c9f5a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt @@ -0,0 +1,106 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.content.SharedPreferences +import com.casic.birmm.inspect.base.BaseApplication + +object SaveKeyValues { + private var sharedPreferences: SharedPreferences? = null + private var editor: SharedPreferences.Editor? = null + private var fileName: String? = null + + fun initSharedPreferences() { + val packageName = BaseApplication.instance.packageName + //获取到的包名带有“.”方便命名,取最后一个作为sp文件名,例如:com.casic.birmm.inspect + val split = packageName.split(".") + fileName = split[split.size - 1] + } + + /** + * 存储 + */ + fun putValue(key: String?, obj: Any) { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + val editor = sharedPreferences!!.edit() + when (obj) { + is String -> { + editor.putString(key, obj).apply() + } + is Int -> { + editor.putInt(key, obj).apply() + } + is Boolean -> { + editor.putBoolean(key, obj).apply() + } + is Float -> { + editor.putFloat(key, obj).apply() + } + is Long -> { + editor.putLong(key, obj).apply() + } + else -> { + editor.putString(key, obj.toString()).apply() + } + } + } + + /** + * 获取保存的数据 + */ + operator fun getValue(key: String?, defaultObject: Any?): Any? { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + return when (defaultObject) { + is String -> { + sharedPreferences!!.getString(key, defaultObject as String?) + } + is Int -> { + sharedPreferences!!.getInt(key, (defaultObject as Int?)!!) + } + is Boolean -> { + sharedPreferences!!.getBoolean(key, (defaultObject as Boolean?)!!) + } + is Float -> { + sharedPreferences!!.getFloat(key, (defaultObject as Float?)!!) + } + is Long -> { + sharedPreferences!!.getLong(key, (defaultObject as Long?)!!) + } + else -> { + sharedPreferences!!.getString(key, null) + } + } + } + + /** + * 移除某个key值已经对应的值 + */ + fun removeKey(key: String?) { + editor!!.remove(key) + editor!!.commit() + } + + /** + * 清除所有数据 + */ + fun clearAll() { + editor!!.clear() + editor!!.commit() + } + + /** + * 查询某个key是否存在 + */ + fun containsKey(key: String?): Boolean { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + return sharedPreferences!!.contains(key) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt b/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt new file mode 100644 index 0000000..04db86b --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt @@ -0,0 +1,119 @@ +package com.casic.birmm.inspect.widgets + +import android.app.Dialog +import android.content.Context +import android.graphics.Color +import android.graphics.drawable.ColorDrawable +import android.os.Bundle +import android.view.WindowManager +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.utils.OtherUtils +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.dialog_input.* + + +class InputDialog private constructor(builder: Builder) : Dialog(builder.mContext!!) { + + private var ctx: Context? = null + private var title: String? = null + private var value: String? = null + private var positiveBtn: String? = null + private var negativeBtn: String? = null + private var listener: OnDialogButtonClickListener? = null + + init { + this.ctx = builder.mContext + this.title = builder.title + this.value = builder.value + this.positiveBtn = builder.positiveBtn + this.negativeBtn = builder.negativeBtn + this.listener = builder.listener + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + configDialogLayout() + setContentView(R.layout.dialog_input) + setCancelable(false) + setCanceledOnTouchOutside(false) + + dialogTitleView.text = title + value.apply { + dialogInputView.setText(this) + } + + dialogCancelButton.text = negativeBtn + dialogCancelButton.setChangeAlphaWhenPress(true) + dialogCancelButton.setOnClickListener { + this.dismiss() + } + + dialogConfirmButton.text = positiveBtn + dialogConfirmButton.setChangeAlphaWhenPress(true) + dialogConfirmButton.setOnClickListener { + val inputValue = dialogInputView.text.toString().trim() + if (inputValue.isEmpty()) { + OtherUtils.showTipsDialog(ctx!!, "什么都没输入,请重新输入", dialogConfirmButton) + return@setOnClickListener + } + listener?.onButtonClick(inputValue) + this.dismiss() + } + } + + private fun configDialogLayout() { + window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT)) + window?.decorView?.setBackgroundColor(Color.TRANSPARENT) + val params: WindowManager.LayoutParams? = window?.attributes + params?.width = QMUIDisplayHelper.dp2px(ctx, 300) + params?.height = WindowManager.LayoutParams.WRAP_CONTENT + window?.attributes = params + } + + class Builder { + var mContext: Context? = null + var title: String? = null + var value: String? = null + var positiveBtn: String? = null + var negativeBtn: String? = null + var listener: OnDialogButtonClickListener? = null + + fun setContext(context: Context?): Builder { + mContext = context + return this + } + + fun setTitle(title: String?): Builder { + this.title = title + return this + } + + fun setDefaultValue(value: String?): Builder { + this.value = value + return this + } + + fun setPositiveButton(name: String?): Builder { + positiveBtn = name + return this + } + + fun setNegativeButton(name: String?): Builder { + negativeBtn = name + return this + } + + fun setOnDialogClickListener(listener: OnDialogButtonClickListener): Builder { + this.listener = listener + return this + } + + fun build(): InputDialog { + return InputDialog(this) + } + } + + interface OnDialogButtonClickListener { + fun onButtonClick(input: String) + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_dialog_button.xml b/app/src/main/res/drawable/bg_dialog_button.xml new file mode 100644 index 0000000..5f7d57d --- /dev/null +++ b/app/src/main/res/drawable/bg_dialog_button.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_layout_white.xml b/app/src/main/res/drawable/bg_layout_white.xml new file mode 100644 index 0000000..19b473b --- /dev/null +++ b/app/src/main/res/drawable/bg_layout_white.xml @@ -0,0 +1,11 @@ + + + + + + + + \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..603b140 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..88ea3aa --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,122 @@ + + + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+ + +
+
\ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..5cd135a --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..7bfef59 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..4ca4a9f --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,67 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' + +android { + compileSdkVersion 30 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.birmm.inspect" + minSdkVersion 21 + targetSdkVersion 30 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'androidx.core:core-ktx:1.3.2' + implementation 'androidx.constraintlayout:constraintlayout:2.0.4' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test.ext:junit:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:1.3.0' + //腾讯Android UI框架 + implementation 'com.qmuiteam:qmui:2.0.0-alpha10' + implementation 'com.qmuiteam:arch:0.3.1' + //沉浸式状态栏。基础依赖包,必须要依赖 + implementation 'com.gyf.immersionbar:immersionbar:3.0.0' + //fragment快速实现 + implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + + //MVP网络请求框架retrofit2+rxjava + implementation 'io.reactivex:rxjava:1.3.8' + implementation 'io.reactivex:rxandroid:1.2.1' + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.6.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + implementation 'com.squareup.retrofit2:adapter-rxjava:2.8.1' + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.8.6' + //Toast提示 + implementation 'com.sdsmdg.tastytoast:tastytoast:0.1.1' + //图片选择框架 + implementation 'com.github.LuckSiege.PictureSelector:picture_library:v2.6.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..ea03309 --- /dev/null +++ b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.casic.birmm.inspect + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.casic.birmm.inspect", appContext.packageName) + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..7096527 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt new file mode 100644 index 0000000..aefdbb6 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt @@ -0,0 +1,36 @@ +package com.casic.birmm.inspect.base + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.qmuiteam.qmui.util.QMUIStatusBarHelper + +abstract class BaseActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(initLayoutView()) + QMUIStatusBarHelper.translucent(this) //沉浸式状态栏 + setupTopBarLayout() + initData() + initEvent() + } + + /** + * 初始化xml布局 + */ + abstract fun initLayoutView(): Int + + /** + * 特定页面定制沉浸式状态栏 + */ + protected abstract fun setupTopBarLayout() + + /** + * 初始化默认数据 + */ + abstract fun initData() + + /** + * 初始化业务逻辑 + */ + abstract fun initEvent() +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt new file mode 100644 index 0000000..fc0ca75 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt @@ -0,0 +1,18 @@ +package com.casic.birmm.inspect.base + +import android.app.Application +import com.casic.birmm.inspect.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + companion object { + var instance: BaseApplication by Delegates.notNull() + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt new file mode 100644 index 0000000..ddc160a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt @@ -0,0 +1,56 @@ +package com.casic.birmm.inspect.ui + +import android.annotation.SuppressLint +import android.content.Intent +import android.os.CountDownTimer +import android.view.ViewGroup.MarginLayoutParams +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.activity_guide.* + +@SuppressLint("SetTextI18n") +class GuideActivity : BaseActivity() { + + private lateinit var countDownTimer: CountDownTimer + + override fun initLayoutView(): Int = R.layout.activity_guide + + override fun setupTopBarLayout() { + + } + + override fun initData() { + //根据不同设备状态栏高度设置"跳过"按钮的Margin值 + val statusBarHeight = QMUIDisplayHelper.getStatusBarHeight(this) + val rightMargin = QMUIDisplayHelper.dp2px(this, 10) + if (skipButton.layoutParams is MarginLayoutParams) { + val params = skipButton.layoutParams as MarginLayoutParams + params.setMargins(skipButton.width, statusBarHeight, rightMargin, 0) + skipButton.requestLayout() + } + + countDownTimer = object : CountDownTimer(4000, 1000) { + override fun onFinish() { + startLoginActivity() + } + + override fun onTick(millisUntilFinished: Long) { + skipButton.text = "跳过\u3000${(millisUntilFinished / 1000)}s" + } + } + } + + override fun initEvent() { + countDownTimer.start() + skipButton.setOnClickListener { + countDownTimer.cancel() + startLoginActivity() + } + } + + fun startLoginActivity() { + startActivity(Intent(this, LoginActivity::class.java)) + finish() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt new file mode 100644 index 0000000..6ef4548 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt @@ -0,0 +1,81 @@ +package com.casic.birmm.inspect.ui + +import android.text.Editable +import android.text.TextWatcher +import android.view.KeyEvent +import android.view.inputmethod.EditorInfo +import android.widget.EditText +import android.widget.TextView +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.casic.birmm.inspect.utils.Constant +import com.casic.birmm.inspect.utils.SaveKeyValues +import com.casic.birmm.inspect.widgets.InputDialog +import kotlinx.android.synthetic.main.activity_login.* + + +class LoginActivity : BaseActivity() { + + companion object { + private const val Tag = "LoginActivity" + } + + override fun initLayoutView(): Int = R.layout.activity_login + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + loginButton.setChangeAlphaWhenPress(true) + val editText: EditText? = inputLayout.editText + editText?.addTextChangedListener(object : TextWatcher { + override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) { + + } + + override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) { + + } + + override fun afterTextChanged(s: Editable) { + if (s.toString().trim { it <= ' ' }.length > 12) { + inputLayout.error = "密码长度超出限制" + } else { + inputLayout.error = null + } + } + }) + //点击输入法键盘"完成" + editText?.setOnEditorActionListener { _: TextView?, actionId: Int, _: KeyEvent? -> + if (actionId == EditorInfo.IME_ACTION_DONE) { +// authenticatePresenter.onReadyRetrofitRequest() + return@setOnEditorActionListener true + } + false + } + + //修改服务器配置 + changeServerConfigView.setOnClickListener { + val defaultValue = SaveKeyValues.getValue( + Constant.DEFAULT_SERVER_CONFIG, + "http://139.198.6.177:8093/" + ) as String + InputDialog.Builder().setContext(this) + .setTitle("请输入后台服务器地址") + .setDefaultValue(defaultValue) + .setNegativeButton("取消") + .setPositiveButton("保存") + .setOnDialogClickListener(object : InputDialog.OnDialogButtonClickListener { + override fun onButtonClick(input: String) { + SaveKeyValues.putValue(Constant.DEFAULT_SERVER_CONFIG, input) + } + }) + .build().show() + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt new file mode 100644 index 0000000..0e97af7 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt @@ -0,0 +1,21 @@ +package com.casic.birmm.inspect.ui + +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity + +class MainActivity : BaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt new file mode 100644 index 0000000..21fbba2 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt @@ -0,0 +1,58 @@ +package com.casic.birmm.inspect.ui + +import android.content.Intent +import android.os.Build +import android.os.Bundle +import android.util.Log +import androidx.appcompat.app.AppCompatActivity +import com.casic.birmm.inspect.utils.Constant +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + companion object { + private const val TAG = "PermissionActivity" + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + if (EasyPermissions.hasPermissions(this, *Constant.USER_PERMISSIONS)) { + startGuideActivity() + } else { + EasyPermissions.requestPermissions( + this, + "需要获取相关权限", + Constant.PERMISSIONS_CODE, + *Constant.USER_PERMISSIONS + ) + } + } else { + startGuideActivity() + } + } + + private fun startGuideActivity() { + startActivity(Intent(this, GuideActivity::class.java)) + finish() + } + + override fun onRequestPermissionsResult( + requestCode: Int, + permissions: Array, + grantResults: IntArray + ) { + super.onRequestPermissionsResult(requestCode, permissions, grantResults) + EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this) + } + + override fun onPermissionsGranted(requestCode: Int, perms: List) { + startGuideActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + Log.e(TAG, "onPermissionsDenied: $perms") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt new file mode 100644 index 0000000..53df6e1 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt @@ -0,0 +1,15 @@ +package com.casic.birmm.inspect.utils + +import android.Manifest + + +object Constant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.ACCESS_LOCATION_EXTRA_COMMANDS, + Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION + ) + + const val PERMISSIONS_CODE = 999 + + const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt new file mode 100644 index 0000000..4c38241 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt @@ -0,0 +1,19 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.view.View +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object OtherUtils { + + //替换Toast + fun showTipsDialog(context: Context, message: String, view: View) { + val tipDialog = QMUITipDialog.Builder(context) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_NOTHING) + .setTipWord(message).create() + tipDialog.show() + view.postDelayed({ + tipDialog.dismiss() + }, 2000) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt b/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt new file mode 100644 index 0000000..04c9f5a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt @@ -0,0 +1,106 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.content.SharedPreferences +import com.casic.birmm.inspect.base.BaseApplication + +object SaveKeyValues { + private var sharedPreferences: SharedPreferences? = null + private var editor: SharedPreferences.Editor? = null + private var fileName: String? = null + + fun initSharedPreferences() { + val packageName = BaseApplication.instance.packageName + //获取到的包名带有“.”方便命名,取最后一个作为sp文件名,例如:com.casic.birmm.inspect + val split = packageName.split(".") + fileName = split[split.size - 1] + } + + /** + * 存储 + */ + fun putValue(key: String?, obj: Any) { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + val editor = sharedPreferences!!.edit() + when (obj) { + is String -> { + editor.putString(key, obj).apply() + } + is Int -> { + editor.putInt(key, obj).apply() + } + is Boolean -> { + editor.putBoolean(key, obj).apply() + } + is Float -> { + editor.putFloat(key, obj).apply() + } + is Long -> { + editor.putLong(key, obj).apply() + } + else -> { + editor.putString(key, obj.toString()).apply() + } + } + } + + /** + * 获取保存的数据 + */ + operator fun getValue(key: String?, defaultObject: Any?): Any? { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + return when (defaultObject) { + is String -> { + sharedPreferences!!.getString(key, defaultObject as String?) + } + is Int -> { + sharedPreferences!!.getInt(key, (defaultObject as Int?)!!) + } + is Boolean -> { + sharedPreferences!!.getBoolean(key, (defaultObject as Boolean?)!!) + } + is Float -> { + sharedPreferences!!.getFloat(key, (defaultObject as Float?)!!) + } + is Long -> { + sharedPreferences!!.getLong(key, (defaultObject as Long?)!!) + } + else -> { + sharedPreferences!!.getString(key, null) + } + } + } + + /** + * 移除某个key值已经对应的值 + */ + fun removeKey(key: String?) { + editor!!.remove(key) + editor!!.commit() + } + + /** + * 清除所有数据 + */ + fun clearAll() { + editor!!.clear() + editor!!.commit() + } + + /** + * 查询某个key是否存在 + */ + fun containsKey(key: String?): Boolean { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + return sharedPreferences!!.contains(key) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt b/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt new file mode 100644 index 0000000..04db86b --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt @@ -0,0 +1,119 @@ +package com.casic.birmm.inspect.widgets + +import android.app.Dialog +import android.content.Context +import android.graphics.Color +import android.graphics.drawable.ColorDrawable +import android.os.Bundle +import android.view.WindowManager +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.utils.OtherUtils +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.dialog_input.* + + +class InputDialog private constructor(builder: Builder) : Dialog(builder.mContext!!) { + + private var ctx: Context? = null + private var title: String? = null + private var value: String? = null + private var positiveBtn: String? = null + private var negativeBtn: String? = null + private var listener: OnDialogButtonClickListener? = null + + init { + this.ctx = builder.mContext + this.title = builder.title + this.value = builder.value + this.positiveBtn = builder.positiveBtn + this.negativeBtn = builder.negativeBtn + this.listener = builder.listener + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + configDialogLayout() + setContentView(R.layout.dialog_input) + setCancelable(false) + setCanceledOnTouchOutside(false) + + dialogTitleView.text = title + value.apply { + dialogInputView.setText(this) + } + + dialogCancelButton.text = negativeBtn + dialogCancelButton.setChangeAlphaWhenPress(true) + dialogCancelButton.setOnClickListener { + this.dismiss() + } + + dialogConfirmButton.text = positiveBtn + dialogConfirmButton.setChangeAlphaWhenPress(true) + dialogConfirmButton.setOnClickListener { + val inputValue = dialogInputView.text.toString().trim() + if (inputValue.isEmpty()) { + OtherUtils.showTipsDialog(ctx!!, "什么都没输入,请重新输入", dialogConfirmButton) + return@setOnClickListener + } + listener?.onButtonClick(inputValue) + this.dismiss() + } + } + + private fun configDialogLayout() { + window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT)) + window?.decorView?.setBackgroundColor(Color.TRANSPARENT) + val params: WindowManager.LayoutParams? = window?.attributes + params?.width = QMUIDisplayHelper.dp2px(ctx, 300) + params?.height = WindowManager.LayoutParams.WRAP_CONTENT + window?.attributes = params + } + + class Builder { + var mContext: Context? = null + var title: String? = null + var value: String? = null + var positiveBtn: String? = null + var negativeBtn: String? = null + var listener: OnDialogButtonClickListener? = null + + fun setContext(context: Context?): Builder { + mContext = context + return this + } + + fun setTitle(title: String?): Builder { + this.title = title + return this + } + + fun setDefaultValue(value: String?): Builder { + this.value = value + return this + } + + fun setPositiveButton(name: String?): Builder { + positiveBtn = name + return this + } + + fun setNegativeButton(name: String?): Builder { + negativeBtn = name + return this + } + + fun setOnDialogClickListener(listener: OnDialogButtonClickListener): Builder { + this.listener = listener + return this + } + + fun build(): InputDialog { + return InputDialog(this) + } + } + + interface OnDialogButtonClickListener { + fun onButtonClick(input: String) + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_dialog_button.xml b/app/src/main/res/drawable/bg_dialog_button.xml new file mode 100644 index 0000000..5f7d57d --- /dev/null +++ b/app/src/main/res/drawable/bg_dialog_button.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_layout_white.xml b/app/src/main/res/drawable/bg_layout_white.xml new file mode 100644 index 0000000..19b473b --- /dev/null +++ b/app/src/main/res/drawable/bg_layout_white.xml @@ -0,0 +1,11 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/guide1.png b/app/src/main/res/drawable/guide1.png new file mode 100644 index 0000000..074c768 --- /dev/null +++ b/app/src/main/res/drawable/guide1.png Binary files differ diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..603b140 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..88ea3aa --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,122 @@ + + + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+ + +
+
\ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..5cd135a --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..7bfef59 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..4ca4a9f --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,67 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' + +android { + compileSdkVersion 30 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.birmm.inspect" + minSdkVersion 21 + targetSdkVersion 30 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'androidx.core:core-ktx:1.3.2' + implementation 'androidx.constraintlayout:constraintlayout:2.0.4' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test.ext:junit:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:1.3.0' + //腾讯Android UI框架 + implementation 'com.qmuiteam:qmui:2.0.0-alpha10' + implementation 'com.qmuiteam:arch:0.3.1' + //沉浸式状态栏。基础依赖包,必须要依赖 + implementation 'com.gyf.immersionbar:immersionbar:3.0.0' + //fragment快速实现 + implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + + //MVP网络请求框架retrofit2+rxjava + implementation 'io.reactivex:rxjava:1.3.8' + implementation 'io.reactivex:rxandroid:1.2.1' + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.6.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + implementation 'com.squareup.retrofit2:adapter-rxjava:2.8.1' + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.8.6' + //Toast提示 + implementation 'com.sdsmdg.tastytoast:tastytoast:0.1.1' + //图片选择框架 + implementation 'com.github.LuckSiege.PictureSelector:picture_library:v2.6.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..ea03309 --- /dev/null +++ b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.casic.birmm.inspect + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.casic.birmm.inspect", appContext.packageName) + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..7096527 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt new file mode 100644 index 0000000..aefdbb6 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt @@ -0,0 +1,36 @@ +package com.casic.birmm.inspect.base + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.qmuiteam.qmui.util.QMUIStatusBarHelper + +abstract class BaseActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(initLayoutView()) + QMUIStatusBarHelper.translucent(this) //沉浸式状态栏 + setupTopBarLayout() + initData() + initEvent() + } + + /** + * 初始化xml布局 + */ + abstract fun initLayoutView(): Int + + /** + * 特定页面定制沉浸式状态栏 + */ + protected abstract fun setupTopBarLayout() + + /** + * 初始化默认数据 + */ + abstract fun initData() + + /** + * 初始化业务逻辑 + */ + abstract fun initEvent() +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt new file mode 100644 index 0000000..fc0ca75 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt @@ -0,0 +1,18 @@ +package com.casic.birmm.inspect.base + +import android.app.Application +import com.casic.birmm.inspect.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + companion object { + var instance: BaseApplication by Delegates.notNull() + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt new file mode 100644 index 0000000..ddc160a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt @@ -0,0 +1,56 @@ +package com.casic.birmm.inspect.ui + +import android.annotation.SuppressLint +import android.content.Intent +import android.os.CountDownTimer +import android.view.ViewGroup.MarginLayoutParams +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.activity_guide.* + +@SuppressLint("SetTextI18n") +class GuideActivity : BaseActivity() { + + private lateinit var countDownTimer: CountDownTimer + + override fun initLayoutView(): Int = R.layout.activity_guide + + override fun setupTopBarLayout() { + + } + + override fun initData() { + //根据不同设备状态栏高度设置"跳过"按钮的Margin值 + val statusBarHeight = QMUIDisplayHelper.getStatusBarHeight(this) + val rightMargin = QMUIDisplayHelper.dp2px(this, 10) + if (skipButton.layoutParams is MarginLayoutParams) { + val params = skipButton.layoutParams as MarginLayoutParams + params.setMargins(skipButton.width, statusBarHeight, rightMargin, 0) + skipButton.requestLayout() + } + + countDownTimer = object : CountDownTimer(4000, 1000) { + override fun onFinish() { + startLoginActivity() + } + + override fun onTick(millisUntilFinished: Long) { + skipButton.text = "跳过\u3000${(millisUntilFinished / 1000)}s" + } + } + } + + override fun initEvent() { + countDownTimer.start() + skipButton.setOnClickListener { + countDownTimer.cancel() + startLoginActivity() + } + } + + fun startLoginActivity() { + startActivity(Intent(this, LoginActivity::class.java)) + finish() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt new file mode 100644 index 0000000..6ef4548 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt @@ -0,0 +1,81 @@ +package com.casic.birmm.inspect.ui + +import android.text.Editable +import android.text.TextWatcher +import android.view.KeyEvent +import android.view.inputmethod.EditorInfo +import android.widget.EditText +import android.widget.TextView +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.casic.birmm.inspect.utils.Constant +import com.casic.birmm.inspect.utils.SaveKeyValues +import com.casic.birmm.inspect.widgets.InputDialog +import kotlinx.android.synthetic.main.activity_login.* + + +class LoginActivity : BaseActivity() { + + companion object { + private const val Tag = "LoginActivity" + } + + override fun initLayoutView(): Int = R.layout.activity_login + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + loginButton.setChangeAlphaWhenPress(true) + val editText: EditText? = inputLayout.editText + editText?.addTextChangedListener(object : TextWatcher { + override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) { + + } + + override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) { + + } + + override fun afterTextChanged(s: Editable) { + if (s.toString().trim { it <= ' ' }.length > 12) { + inputLayout.error = "密码长度超出限制" + } else { + inputLayout.error = null + } + } + }) + //点击输入法键盘"完成" + editText?.setOnEditorActionListener { _: TextView?, actionId: Int, _: KeyEvent? -> + if (actionId == EditorInfo.IME_ACTION_DONE) { +// authenticatePresenter.onReadyRetrofitRequest() + return@setOnEditorActionListener true + } + false + } + + //修改服务器配置 + changeServerConfigView.setOnClickListener { + val defaultValue = SaveKeyValues.getValue( + Constant.DEFAULT_SERVER_CONFIG, + "http://139.198.6.177:8093/" + ) as String + InputDialog.Builder().setContext(this) + .setTitle("请输入后台服务器地址") + .setDefaultValue(defaultValue) + .setNegativeButton("取消") + .setPositiveButton("保存") + .setOnDialogClickListener(object : InputDialog.OnDialogButtonClickListener { + override fun onButtonClick(input: String) { + SaveKeyValues.putValue(Constant.DEFAULT_SERVER_CONFIG, input) + } + }) + .build().show() + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt new file mode 100644 index 0000000..0e97af7 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt @@ -0,0 +1,21 @@ +package com.casic.birmm.inspect.ui + +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity + +class MainActivity : BaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt new file mode 100644 index 0000000..21fbba2 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt @@ -0,0 +1,58 @@ +package com.casic.birmm.inspect.ui + +import android.content.Intent +import android.os.Build +import android.os.Bundle +import android.util.Log +import androidx.appcompat.app.AppCompatActivity +import com.casic.birmm.inspect.utils.Constant +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + companion object { + private const val TAG = "PermissionActivity" + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + if (EasyPermissions.hasPermissions(this, *Constant.USER_PERMISSIONS)) { + startGuideActivity() + } else { + EasyPermissions.requestPermissions( + this, + "需要获取相关权限", + Constant.PERMISSIONS_CODE, + *Constant.USER_PERMISSIONS + ) + } + } else { + startGuideActivity() + } + } + + private fun startGuideActivity() { + startActivity(Intent(this, GuideActivity::class.java)) + finish() + } + + override fun onRequestPermissionsResult( + requestCode: Int, + permissions: Array, + grantResults: IntArray + ) { + super.onRequestPermissionsResult(requestCode, permissions, grantResults) + EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this) + } + + override fun onPermissionsGranted(requestCode: Int, perms: List) { + startGuideActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + Log.e(TAG, "onPermissionsDenied: $perms") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt new file mode 100644 index 0000000..53df6e1 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt @@ -0,0 +1,15 @@ +package com.casic.birmm.inspect.utils + +import android.Manifest + + +object Constant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.ACCESS_LOCATION_EXTRA_COMMANDS, + Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION + ) + + const val PERMISSIONS_CODE = 999 + + const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt new file mode 100644 index 0000000..4c38241 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt @@ -0,0 +1,19 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.view.View +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object OtherUtils { + + //替换Toast + fun showTipsDialog(context: Context, message: String, view: View) { + val tipDialog = QMUITipDialog.Builder(context) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_NOTHING) + .setTipWord(message).create() + tipDialog.show() + view.postDelayed({ + tipDialog.dismiss() + }, 2000) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt b/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt new file mode 100644 index 0000000..04c9f5a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt @@ -0,0 +1,106 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.content.SharedPreferences +import com.casic.birmm.inspect.base.BaseApplication + +object SaveKeyValues { + private var sharedPreferences: SharedPreferences? = null + private var editor: SharedPreferences.Editor? = null + private var fileName: String? = null + + fun initSharedPreferences() { + val packageName = BaseApplication.instance.packageName + //获取到的包名带有“.”方便命名,取最后一个作为sp文件名,例如:com.casic.birmm.inspect + val split = packageName.split(".") + fileName = split[split.size - 1] + } + + /** + * 存储 + */ + fun putValue(key: String?, obj: Any) { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + val editor = sharedPreferences!!.edit() + when (obj) { + is String -> { + editor.putString(key, obj).apply() + } + is Int -> { + editor.putInt(key, obj).apply() + } + is Boolean -> { + editor.putBoolean(key, obj).apply() + } + is Float -> { + editor.putFloat(key, obj).apply() + } + is Long -> { + editor.putLong(key, obj).apply() + } + else -> { + editor.putString(key, obj.toString()).apply() + } + } + } + + /** + * 获取保存的数据 + */ + operator fun getValue(key: String?, defaultObject: Any?): Any? { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + return when (defaultObject) { + is String -> { + sharedPreferences!!.getString(key, defaultObject as String?) + } + is Int -> { + sharedPreferences!!.getInt(key, (defaultObject as Int?)!!) + } + is Boolean -> { + sharedPreferences!!.getBoolean(key, (defaultObject as Boolean?)!!) + } + is Float -> { + sharedPreferences!!.getFloat(key, (defaultObject as Float?)!!) + } + is Long -> { + sharedPreferences!!.getLong(key, (defaultObject as Long?)!!) + } + else -> { + sharedPreferences!!.getString(key, null) + } + } + } + + /** + * 移除某个key值已经对应的值 + */ + fun removeKey(key: String?) { + editor!!.remove(key) + editor!!.commit() + } + + /** + * 清除所有数据 + */ + fun clearAll() { + editor!!.clear() + editor!!.commit() + } + + /** + * 查询某个key是否存在 + */ + fun containsKey(key: String?): Boolean { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + return sharedPreferences!!.contains(key) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt b/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt new file mode 100644 index 0000000..04db86b --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt @@ -0,0 +1,119 @@ +package com.casic.birmm.inspect.widgets + +import android.app.Dialog +import android.content.Context +import android.graphics.Color +import android.graphics.drawable.ColorDrawable +import android.os.Bundle +import android.view.WindowManager +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.utils.OtherUtils +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.dialog_input.* + + +class InputDialog private constructor(builder: Builder) : Dialog(builder.mContext!!) { + + private var ctx: Context? = null + private var title: String? = null + private var value: String? = null + private var positiveBtn: String? = null + private var negativeBtn: String? = null + private var listener: OnDialogButtonClickListener? = null + + init { + this.ctx = builder.mContext + this.title = builder.title + this.value = builder.value + this.positiveBtn = builder.positiveBtn + this.negativeBtn = builder.negativeBtn + this.listener = builder.listener + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + configDialogLayout() + setContentView(R.layout.dialog_input) + setCancelable(false) + setCanceledOnTouchOutside(false) + + dialogTitleView.text = title + value.apply { + dialogInputView.setText(this) + } + + dialogCancelButton.text = negativeBtn + dialogCancelButton.setChangeAlphaWhenPress(true) + dialogCancelButton.setOnClickListener { + this.dismiss() + } + + dialogConfirmButton.text = positiveBtn + dialogConfirmButton.setChangeAlphaWhenPress(true) + dialogConfirmButton.setOnClickListener { + val inputValue = dialogInputView.text.toString().trim() + if (inputValue.isEmpty()) { + OtherUtils.showTipsDialog(ctx!!, "什么都没输入,请重新输入", dialogConfirmButton) + return@setOnClickListener + } + listener?.onButtonClick(inputValue) + this.dismiss() + } + } + + private fun configDialogLayout() { + window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT)) + window?.decorView?.setBackgroundColor(Color.TRANSPARENT) + val params: WindowManager.LayoutParams? = window?.attributes + params?.width = QMUIDisplayHelper.dp2px(ctx, 300) + params?.height = WindowManager.LayoutParams.WRAP_CONTENT + window?.attributes = params + } + + class Builder { + var mContext: Context? = null + var title: String? = null + var value: String? = null + var positiveBtn: String? = null + var negativeBtn: String? = null + var listener: OnDialogButtonClickListener? = null + + fun setContext(context: Context?): Builder { + mContext = context + return this + } + + fun setTitle(title: String?): Builder { + this.title = title + return this + } + + fun setDefaultValue(value: String?): Builder { + this.value = value + return this + } + + fun setPositiveButton(name: String?): Builder { + positiveBtn = name + return this + } + + fun setNegativeButton(name: String?): Builder { + negativeBtn = name + return this + } + + fun setOnDialogClickListener(listener: OnDialogButtonClickListener): Builder { + this.listener = listener + return this + } + + fun build(): InputDialog { + return InputDialog(this) + } + } + + interface OnDialogButtonClickListener { + fun onButtonClick(input: String) + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_dialog_button.xml b/app/src/main/res/drawable/bg_dialog_button.xml new file mode 100644 index 0000000..5f7d57d --- /dev/null +++ b/app/src/main/res/drawable/bg_dialog_button.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_layout_white.xml b/app/src/main/res/drawable/bg_layout_white.xml new file mode 100644 index 0000000..19b473b --- /dev/null +++ b/app/src/main/res/drawable/bg_layout_white.xml @@ -0,0 +1,11 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/guide1.png b/app/src/main/res/drawable/guide1.png new file mode 100644 index 0000000..074c768 --- /dev/null +++ b/app/src/main/res/drawable/guide1.png Binary files differ diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..603b140 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..88ea3aa --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,122 @@ + + + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+ + +
+
\ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..5cd135a --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..7bfef59 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..4ca4a9f --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,67 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' + +android { + compileSdkVersion 30 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.birmm.inspect" + minSdkVersion 21 + targetSdkVersion 30 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'androidx.core:core-ktx:1.3.2' + implementation 'androidx.constraintlayout:constraintlayout:2.0.4' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test.ext:junit:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:1.3.0' + //腾讯Android UI框架 + implementation 'com.qmuiteam:qmui:2.0.0-alpha10' + implementation 'com.qmuiteam:arch:0.3.1' + //沉浸式状态栏。基础依赖包,必须要依赖 + implementation 'com.gyf.immersionbar:immersionbar:3.0.0' + //fragment快速实现 + implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + + //MVP网络请求框架retrofit2+rxjava + implementation 'io.reactivex:rxjava:1.3.8' + implementation 'io.reactivex:rxandroid:1.2.1' + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.6.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + implementation 'com.squareup.retrofit2:adapter-rxjava:2.8.1' + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.8.6' + //Toast提示 + implementation 'com.sdsmdg.tastytoast:tastytoast:0.1.1' + //图片选择框架 + implementation 'com.github.LuckSiege.PictureSelector:picture_library:v2.6.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..ea03309 --- /dev/null +++ b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.casic.birmm.inspect + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.casic.birmm.inspect", appContext.packageName) + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..7096527 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt new file mode 100644 index 0000000..aefdbb6 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt @@ -0,0 +1,36 @@ +package com.casic.birmm.inspect.base + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.qmuiteam.qmui.util.QMUIStatusBarHelper + +abstract class BaseActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(initLayoutView()) + QMUIStatusBarHelper.translucent(this) //沉浸式状态栏 + setupTopBarLayout() + initData() + initEvent() + } + + /** + * 初始化xml布局 + */ + abstract fun initLayoutView(): Int + + /** + * 特定页面定制沉浸式状态栏 + */ + protected abstract fun setupTopBarLayout() + + /** + * 初始化默认数据 + */ + abstract fun initData() + + /** + * 初始化业务逻辑 + */ + abstract fun initEvent() +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt new file mode 100644 index 0000000..fc0ca75 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt @@ -0,0 +1,18 @@ +package com.casic.birmm.inspect.base + +import android.app.Application +import com.casic.birmm.inspect.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + companion object { + var instance: BaseApplication by Delegates.notNull() + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt new file mode 100644 index 0000000..ddc160a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt @@ -0,0 +1,56 @@ +package com.casic.birmm.inspect.ui + +import android.annotation.SuppressLint +import android.content.Intent +import android.os.CountDownTimer +import android.view.ViewGroup.MarginLayoutParams +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.activity_guide.* + +@SuppressLint("SetTextI18n") +class GuideActivity : BaseActivity() { + + private lateinit var countDownTimer: CountDownTimer + + override fun initLayoutView(): Int = R.layout.activity_guide + + override fun setupTopBarLayout() { + + } + + override fun initData() { + //根据不同设备状态栏高度设置"跳过"按钮的Margin值 + val statusBarHeight = QMUIDisplayHelper.getStatusBarHeight(this) + val rightMargin = QMUIDisplayHelper.dp2px(this, 10) + if (skipButton.layoutParams is MarginLayoutParams) { + val params = skipButton.layoutParams as MarginLayoutParams + params.setMargins(skipButton.width, statusBarHeight, rightMargin, 0) + skipButton.requestLayout() + } + + countDownTimer = object : CountDownTimer(4000, 1000) { + override fun onFinish() { + startLoginActivity() + } + + override fun onTick(millisUntilFinished: Long) { + skipButton.text = "跳过\u3000${(millisUntilFinished / 1000)}s" + } + } + } + + override fun initEvent() { + countDownTimer.start() + skipButton.setOnClickListener { + countDownTimer.cancel() + startLoginActivity() + } + } + + fun startLoginActivity() { + startActivity(Intent(this, LoginActivity::class.java)) + finish() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt new file mode 100644 index 0000000..6ef4548 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt @@ -0,0 +1,81 @@ +package com.casic.birmm.inspect.ui + +import android.text.Editable +import android.text.TextWatcher +import android.view.KeyEvent +import android.view.inputmethod.EditorInfo +import android.widget.EditText +import android.widget.TextView +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.casic.birmm.inspect.utils.Constant +import com.casic.birmm.inspect.utils.SaveKeyValues +import com.casic.birmm.inspect.widgets.InputDialog +import kotlinx.android.synthetic.main.activity_login.* + + +class LoginActivity : BaseActivity() { + + companion object { + private const val Tag = "LoginActivity" + } + + override fun initLayoutView(): Int = R.layout.activity_login + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + loginButton.setChangeAlphaWhenPress(true) + val editText: EditText? = inputLayout.editText + editText?.addTextChangedListener(object : TextWatcher { + override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) { + + } + + override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) { + + } + + override fun afterTextChanged(s: Editable) { + if (s.toString().trim { it <= ' ' }.length > 12) { + inputLayout.error = "密码长度超出限制" + } else { + inputLayout.error = null + } + } + }) + //点击输入法键盘"完成" + editText?.setOnEditorActionListener { _: TextView?, actionId: Int, _: KeyEvent? -> + if (actionId == EditorInfo.IME_ACTION_DONE) { +// authenticatePresenter.onReadyRetrofitRequest() + return@setOnEditorActionListener true + } + false + } + + //修改服务器配置 + changeServerConfigView.setOnClickListener { + val defaultValue = SaveKeyValues.getValue( + Constant.DEFAULT_SERVER_CONFIG, + "http://139.198.6.177:8093/" + ) as String + InputDialog.Builder().setContext(this) + .setTitle("请输入后台服务器地址") + .setDefaultValue(defaultValue) + .setNegativeButton("取消") + .setPositiveButton("保存") + .setOnDialogClickListener(object : InputDialog.OnDialogButtonClickListener { + override fun onButtonClick(input: String) { + SaveKeyValues.putValue(Constant.DEFAULT_SERVER_CONFIG, input) + } + }) + .build().show() + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt new file mode 100644 index 0000000..0e97af7 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt @@ -0,0 +1,21 @@ +package com.casic.birmm.inspect.ui + +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity + +class MainActivity : BaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt new file mode 100644 index 0000000..21fbba2 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt @@ -0,0 +1,58 @@ +package com.casic.birmm.inspect.ui + +import android.content.Intent +import android.os.Build +import android.os.Bundle +import android.util.Log +import androidx.appcompat.app.AppCompatActivity +import com.casic.birmm.inspect.utils.Constant +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + companion object { + private const val TAG = "PermissionActivity" + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + if (EasyPermissions.hasPermissions(this, *Constant.USER_PERMISSIONS)) { + startGuideActivity() + } else { + EasyPermissions.requestPermissions( + this, + "需要获取相关权限", + Constant.PERMISSIONS_CODE, + *Constant.USER_PERMISSIONS + ) + } + } else { + startGuideActivity() + } + } + + private fun startGuideActivity() { + startActivity(Intent(this, GuideActivity::class.java)) + finish() + } + + override fun onRequestPermissionsResult( + requestCode: Int, + permissions: Array, + grantResults: IntArray + ) { + super.onRequestPermissionsResult(requestCode, permissions, grantResults) + EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this) + } + + override fun onPermissionsGranted(requestCode: Int, perms: List) { + startGuideActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + Log.e(TAG, "onPermissionsDenied: $perms") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt new file mode 100644 index 0000000..53df6e1 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt @@ -0,0 +1,15 @@ +package com.casic.birmm.inspect.utils + +import android.Manifest + + +object Constant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.ACCESS_LOCATION_EXTRA_COMMANDS, + Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION + ) + + const val PERMISSIONS_CODE = 999 + + const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt new file mode 100644 index 0000000..4c38241 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt @@ -0,0 +1,19 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.view.View +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object OtherUtils { + + //替换Toast + fun showTipsDialog(context: Context, message: String, view: View) { + val tipDialog = QMUITipDialog.Builder(context) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_NOTHING) + .setTipWord(message).create() + tipDialog.show() + view.postDelayed({ + tipDialog.dismiss() + }, 2000) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt b/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt new file mode 100644 index 0000000..04c9f5a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt @@ -0,0 +1,106 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.content.SharedPreferences +import com.casic.birmm.inspect.base.BaseApplication + +object SaveKeyValues { + private var sharedPreferences: SharedPreferences? = null + private var editor: SharedPreferences.Editor? = null + private var fileName: String? = null + + fun initSharedPreferences() { + val packageName = BaseApplication.instance.packageName + //获取到的包名带有“.”方便命名,取最后一个作为sp文件名,例如:com.casic.birmm.inspect + val split = packageName.split(".") + fileName = split[split.size - 1] + } + + /** + * 存储 + */ + fun putValue(key: String?, obj: Any) { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + val editor = sharedPreferences!!.edit() + when (obj) { + is String -> { + editor.putString(key, obj).apply() + } + is Int -> { + editor.putInt(key, obj).apply() + } + is Boolean -> { + editor.putBoolean(key, obj).apply() + } + is Float -> { + editor.putFloat(key, obj).apply() + } + is Long -> { + editor.putLong(key, obj).apply() + } + else -> { + editor.putString(key, obj.toString()).apply() + } + } + } + + /** + * 获取保存的数据 + */ + operator fun getValue(key: String?, defaultObject: Any?): Any? { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + return when (defaultObject) { + is String -> { + sharedPreferences!!.getString(key, defaultObject as String?) + } + is Int -> { + sharedPreferences!!.getInt(key, (defaultObject as Int?)!!) + } + is Boolean -> { + sharedPreferences!!.getBoolean(key, (defaultObject as Boolean?)!!) + } + is Float -> { + sharedPreferences!!.getFloat(key, (defaultObject as Float?)!!) + } + is Long -> { + sharedPreferences!!.getLong(key, (defaultObject as Long?)!!) + } + else -> { + sharedPreferences!!.getString(key, null) + } + } + } + + /** + * 移除某个key值已经对应的值 + */ + fun removeKey(key: String?) { + editor!!.remove(key) + editor!!.commit() + } + + /** + * 清除所有数据 + */ + fun clearAll() { + editor!!.clear() + editor!!.commit() + } + + /** + * 查询某个key是否存在 + */ + fun containsKey(key: String?): Boolean { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + return sharedPreferences!!.contains(key) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt b/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt new file mode 100644 index 0000000..04db86b --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt @@ -0,0 +1,119 @@ +package com.casic.birmm.inspect.widgets + +import android.app.Dialog +import android.content.Context +import android.graphics.Color +import android.graphics.drawable.ColorDrawable +import android.os.Bundle +import android.view.WindowManager +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.utils.OtherUtils +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.dialog_input.* + + +class InputDialog private constructor(builder: Builder) : Dialog(builder.mContext!!) { + + private var ctx: Context? = null + private var title: String? = null + private var value: String? = null + private var positiveBtn: String? = null + private var negativeBtn: String? = null + private var listener: OnDialogButtonClickListener? = null + + init { + this.ctx = builder.mContext + this.title = builder.title + this.value = builder.value + this.positiveBtn = builder.positiveBtn + this.negativeBtn = builder.negativeBtn + this.listener = builder.listener + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + configDialogLayout() + setContentView(R.layout.dialog_input) + setCancelable(false) + setCanceledOnTouchOutside(false) + + dialogTitleView.text = title + value.apply { + dialogInputView.setText(this) + } + + dialogCancelButton.text = negativeBtn + dialogCancelButton.setChangeAlphaWhenPress(true) + dialogCancelButton.setOnClickListener { + this.dismiss() + } + + dialogConfirmButton.text = positiveBtn + dialogConfirmButton.setChangeAlphaWhenPress(true) + dialogConfirmButton.setOnClickListener { + val inputValue = dialogInputView.text.toString().trim() + if (inputValue.isEmpty()) { + OtherUtils.showTipsDialog(ctx!!, "什么都没输入,请重新输入", dialogConfirmButton) + return@setOnClickListener + } + listener?.onButtonClick(inputValue) + this.dismiss() + } + } + + private fun configDialogLayout() { + window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT)) + window?.decorView?.setBackgroundColor(Color.TRANSPARENT) + val params: WindowManager.LayoutParams? = window?.attributes + params?.width = QMUIDisplayHelper.dp2px(ctx, 300) + params?.height = WindowManager.LayoutParams.WRAP_CONTENT + window?.attributes = params + } + + class Builder { + var mContext: Context? = null + var title: String? = null + var value: String? = null + var positiveBtn: String? = null + var negativeBtn: String? = null + var listener: OnDialogButtonClickListener? = null + + fun setContext(context: Context?): Builder { + mContext = context + return this + } + + fun setTitle(title: String?): Builder { + this.title = title + return this + } + + fun setDefaultValue(value: String?): Builder { + this.value = value + return this + } + + fun setPositiveButton(name: String?): Builder { + positiveBtn = name + return this + } + + fun setNegativeButton(name: String?): Builder { + negativeBtn = name + return this + } + + fun setOnDialogClickListener(listener: OnDialogButtonClickListener): Builder { + this.listener = listener + return this + } + + fun build(): InputDialog { + return InputDialog(this) + } + } + + interface OnDialogButtonClickListener { + fun onButtonClick(input: String) + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_dialog_button.xml b/app/src/main/res/drawable/bg_dialog_button.xml new file mode 100644 index 0000000..5f7d57d --- /dev/null +++ b/app/src/main/res/drawable/bg_dialog_button.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_layout_white.xml b/app/src/main/res/drawable/bg_layout_white.xml new file mode 100644 index 0000000..19b473b --- /dev/null +++ b/app/src/main/res/drawable/bg_layout_white.xml @@ -0,0 +1,11 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/guide1.png b/app/src/main/res/drawable/guide1.png new file mode 100644 index 0000000..074c768 --- /dev/null +++ b/app/src/main/res/drawable/guide1.png Binary files differ diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_lock.xml b/app/src/main/res/drawable/ic_lock.xml new file mode 100644 index 0000000..f0a5610 --- /dev/null +++ b/app/src/main/res/drawable/ic_lock.xml @@ -0,0 +1,12 @@ + + + + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..603b140 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..88ea3aa --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,122 @@ + + + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+ + +
+
\ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..5cd135a --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..7bfef59 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..4ca4a9f --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,67 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' + +android { + compileSdkVersion 30 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.birmm.inspect" + minSdkVersion 21 + targetSdkVersion 30 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'androidx.core:core-ktx:1.3.2' + implementation 'androidx.constraintlayout:constraintlayout:2.0.4' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test.ext:junit:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:1.3.0' + //腾讯Android UI框架 + implementation 'com.qmuiteam:qmui:2.0.0-alpha10' + implementation 'com.qmuiteam:arch:0.3.1' + //沉浸式状态栏。基础依赖包,必须要依赖 + implementation 'com.gyf.immersionbar:immersionbar:3.0.0' + //fragment快速实现 + implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + + //MVP网络请求框架retrofit2+rxjava + implementation 'io.reactivex:rxjava:1.3.8' + implementation 'io.reactivex:rxandroid:1.2.1' + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.6.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + implementation 'com.squareup.retrofit2:adapter-rxjava:2.8.1' + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.8.6' + //Toast提示 + implementation 'com.sdsmdg.tastytoast:tastytoast:0.1.1' + //图片选择框架 + implementation 'com.github.LuckSiege.PictureSelector:picture_library:v2.6.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..ea03309 --- /dev/null +++ b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.casic.birmm.inspect + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.casic.birmm.inspect", appContext.packageName) + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..7096527 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt new file mode 100644 index 0000000..aefdbb6 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt @@ -0,0 +1,36 @@ +package com.casic.birmm.inspect.base + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.qmuiteam.qmui.util.QMUIStatusBarHelper + +abstract class BaseActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(initLayoutView()) + QMUIStatusBarHelper.translucent(this) //沉浸式状态栏 + setupTopBarLayout() + initData() + initEvent() + } + + /** + * 初始化xml布局 + */ + abstract fun initLayoutView(): Int + + /** + * 特定页面定制沉浸式状态栏 + */ + protected abstract fun setupTopBarLayout() + + /** + * 初始化默认数据 + */ + abstract fun initData() + + /** + * 初始化业务逻辑 + */ + abstract fun initEvent() +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt new file mode 100644 index 0000000..fc0ca75 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt @@ -0,0 +1,18 @@ +package com.casic.birmm.inspect.base + +import android.app.Application +import com.casic.birmm.inspect.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + companion object { + var instance: BaseApplication by Delegates.notNull() + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt new file mode 100644 index 0000000..ddc160a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt @@ -0,0 +1,56 @@ +package com.casic.birmm.inspect.ui + +import android.annotation.SuppressLint +import android.content.Intent +import android.os.CountDownTimer +import android.view.ViewGroup.MarginLayoutParams +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.activity_guide.* + +@SuppressLint("SetTextI18n") +class GuideActivity : BaseActivity() { + + private lateinit var countDownTimer: CountDownTimer + + override fun initLayoutView(): Int = R.layout.activity_guide + + override fun setupTopBarLayout() { + + } + + override fun initData() { + //根据不同设备状态栏高度设置"跳过"按钮的Margin值 + val statusBarHeight = QMUIDisplayHelper.getStatusBarHeight(this) + val rightMargin = QMUIDisplayHelper.dp2px(this, 10) + if (skipButton.layoutParams is MarginLayoutParams) { + val params = skipButton.layoutParams as MarginLayoutParams + params.setMargins(skipButton.width, statusBarHeight, rightMargin, 0) + skipButton.requestLayout() + } + + countDownTimer = object : CountDownTimer(4000, 1000) { + override fun onFinish() { + startLoginActivity() + } + + override fun onTick(millisUntilFinished: Long) { + skipButton.text = "跳过\u3000${(millisUntilFinished / 1000)}s" + } + } + } + + override fun initEvent() { + countDownTimer.start() + skipButton.setOnClickListener { + countDownTimer.cancel() + startLoginActivity() + } + } + + fun startLoginActivity() { + startActivity(Intent(this, LoginActivity::class.java)) + finish() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt new file mode 100644 index 0000000..6ef4548 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt @@ -0,0 +1,81 @@ +package com.casic.birmm.inspect.ui + +import android.text.Editable +import android.text.TextWatcher +import android.view.KeyEvent +import android.view.inputmethod.EditorInfo +import android.widget.EditText +import android.widget.TextView +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.casic.birmm.inspect.utils.Constant +import com.casic.birmm.inspect.utils.SaveKeyValues +import com.casic.birmm.inspect.widgets.InputDialog +import kotlinx.android.synthetic.main.activity_login.* + + +class LoginActivity : BaseActivity() { + + companion object { + private const val Tag = "LoginActivity" + } + + override fun initLayoutView(): Int = R.layout.activity_login + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + loginButton.setChangeAlphaWhenPress(true) + val editText: EditText? = inputLayout.editText + editText?.addTextChangedListener(object : TextWatcher { + override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) { + + } + + override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) { + + } + + override fun afterTextChanged(s: Editable) { + if (s.toString().trim { it <= ' ' }.length > 12) { + inputLayout.error = "密码长度超出限制" + } else { + inputLayout.error = null + } + } + }) + //点击输入法键盘"完成" + editText?.setOnEditorActionListener { _: TextView?, actionId: Int, _: KeyEvent? -> + if (actionId == EditorInfo.IME_ACTION_DONE) { +// authenticatePresenter.onReadyRetrofitRequest() + return@setOnEditorActionListener true + } + false + } + + //修改服务器配置 + changeServerConfigView.setOnClickListener { + val defaultValue = SaveKeyValues.getValue( + Constant.DEFAULT_SERVER_CONFIG, + "http://139.198.6.177:8093/" + ) as String + InputDialog.Builder().setContext(this) + .setTitle("请输入后台服务器地址") + .setDefaultValue(defaultValue) + .setNegativeButton("取消") + .setPositiveButton("保存") + .setOnDialogClickListener(object : InputDialog.OnDialogButtonClickListener { + override fun onButtonClick(input: String) { + SaveKeyValues.putValue(Constant.DEFAULT_SERVER_CONFIG, input) + } + }) + .build().show() + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt new file mode 100644 index 0000000..0e97af7 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt @@ -0,0 +1,21 @@ +package com.casic.birmm.inspect.ui + +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity + +class MainActivity : BaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt new file mode 100644 index 0000000..21fbba2 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt @@ -0,0 +1,58 @@ +package com.casic.birmm.inspect.ui + +import android.content.Intent +import android.os.Build +import android.os.Bundle +import android.util.Log +import androidx.appcompat.app.AppCompatActivity +import com.casic.birmm.inspect.utils.Constant +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + companion object { + private const val TAG = "PermissionActivity" + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + if (EasyPermissions.hasPermissions(this, *Constant.USER_PERMISSIONS)) { + startGuideActivity() + } else { + EasyPermissions.requestPermissions( + this, + "需要获取相关权限", + Constant.PERMISSIONS_CODE, + *Constant.USER_PERMISSIONS + ) + } + } else { + startGuideActivity() + } + } + + private fun startGuideActivity() { + startActivity(Intent(this, GuideActivity::class.java)) + finish() + } + + override fun onRequestPermissionsResult( + requestCode: Int, + permissions: Array, + grantResults: IntArray + ) { + super.onRequestPermissionsResult(requestCode, permissions, grantResults) + EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this) + } + + override fun onPermissionsGranted(requestCode: Int, perms: List) { + startGuideActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + Log.e(TAG, "onPermissionsDenied: $perms") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt new file mode 100644 index 0000000..53df6e1 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt @@ -0,0 +1,15 @@ +package com.casic.birmm.inspect.utils + +import android.Manifest + + +object Constant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.ACCESS_LOCATION_EXTRA_COMMANDS, + Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION + ) + + const val PERMISSIONS_CODE = 999 + + const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt new file mode 100644 index 0000000..4c38241 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt @@ -0,0 +1,19 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.view.View +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object OtherUtils { + + //替换Toast + fun showTipsDialog(context: Context, message: String, view: View) { + val tipDialog = QMUITipDialog.Builder(context) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_NOTHING) + .setTipWord(message).create() + tipDialog.show() + view.postDelayed({ + tipDialog.dismiss() + }, 2000) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt b/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt new file mode 100644 index 0000000..04c9f5a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt @@ -0,0 +1,106 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.content.SharedPreferences +import com.casic.birmm.inspect.base.BaseApplication + +object SaveKeyValues { + private var sharedPreferences: SharedPreferences? = null + private var editor: SharedPreferences.Editor? = null + private var fileName: String? = null + + fun initSharedPreferences() { + val packageName = BaseApplication.instance.packageName + //获取到的包名带有“.”方便命名,取最后一个作为sp文件名,例如:com.casic.birmm.inspect + val split = packageName.split(".") + fileName = split[split.size - 1] + } + + /** + * 存储 + */ + fun putValue(key: String?, obj: Any) { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + val editor = sharedPreferences!!.edit() + when (obj) { + is String -> { + editor.putString(key, obj).apply() + } + is Int -> { + editor.putInt(key, obj).apply() + } + is Boolean -> { + editor.putBoolean(key, obj).apply() + } + is Float -> { + editor.putFloat(key, obj).apply() + } + is Long -> { + editor.putLong(key, obj).apply() + } + else -> { + editor.putString(key, obj.toString()).apply() + } + } + } + + /** + * 获取保存的数据 + */ + operator fun getValue(key: String?, defaultObject: Any?): Any? { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + return when (defaultObject) { + is String -> { + sharedPreferences!!.getString(key, defaultObject as String?) + } + is Int -> { + sharedPreferences!!.getInt(key, (defaultObject as Int?)!!) + } + is Boolean -> { + sharedPreferences!!.getBoolean(key, (defaultObject as Boolean?)!!) + } + is Float -> { + sharedPreferences!!.getFloat(key, (defaultObject as Float?)!!) + } + is Long -> { + sharedPreferences!!.getLong(key, (defaultObject as Long?)!!) + } + else -> { + sharedPreferences!!.getString(key, null) + } + } + } + + /** + * 移除某个key值已经对应的值 + */ + fun removeKey(key: String?) { + editor!!.remove(key) + editor!!.commit() + } + + /** + * 清除所有数据 + */ + fun clearAll() { + editor!!.clear() + editor!!.commit() + } + + /** + * 查询某个key是否存在 + */ + fun containsKey(key: String?): Boolean { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + return sharedPreferences!!.contains(key) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt b/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt new file mode 100644 index 0000000..04db86b --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt @@ -0,0 +1,119 @@ +package com.casic.birmm.inspect.widgets + +import android.app.Dialog +import android.content.Context +import android.graphics.Color +import android.graphics.drawable.ColorDrawable +import android.os.Bundle +import android.view.WindowManager +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.utils.OtherUtils +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.dialog_input.* + + +class InputDialog private constructor(builder: Builder) : Dialog(builder.mContext!!) { + + private var ctx: Context? = null + private var title: String? = null + private var value: String? = null + private var positiveBtn: String? = null + private var negativeBtn: String? = null + private var listener: OnDialogButtonClickListener? = null + + init { + this.ctx = builder.mContext + this.title = builder.title + this.value = builder.value + this.positiveBtn = builder.positiveBtn + this.negativeBtn = builder.negativeBtn + this.listener = builder.listener + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + configDialogLayout() + setContentView(R.layout.dialog_input) + setCancelable(false) + setCanceledOnTouchOutside(false) + + dialogTitleView.text = title + value.apply { + dialogInputView.setText(this) + } + + dialogCancelButton.text = negativeBtn + dialogCancelButton.setChangeAlphaWhenPress(true) + dialogCancelButton.setOnClickListener { + this.dismiss() + } + + dialogConfirmButton.text = positiveBtn + dialogConfirmButton.setChangeAlphaWhenPress(true) + dialogConfirmButton.setOnClickListener { + val inputValue = dialogInputView.text.toString().trim() + if (inputValue.isEmpty()) { + OtherUtils.showTipsDialog(ctx!!, "什么都没输入,请重新输入", dialogConfirmButton) + return@setOnClickListener + } + listener?.onButtonClick(inputValue) + this.dismiss() + } + } + + private fun configDialogLayout() { + window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT)) + window?.decorView?.setBackgroundColor(Color.TRANSPARENT) + val params: WindowManager.LayoutParams? = window?.attributes + params?.width = QMUIDisplayHelper.dp2px(ctx, 300) + params?.height = WindowManager.LayoutParams.WRAP_CONTENT + window?.attributes = params + } + + class Builder { + var mContext: Context? = null + var title: String? = null + var value: String? = null + var positiveBtn: String? = null + var negativeBtn: String? = null + var listener: OnDialogButtonClickListener? = null + + fun setContext(context: Context?): Builder { + mContext = context + return this + } + + fun setTitle(title: String?): Builder { + this.title = title + return this + } + + fun setDefaultValue(value: String?): Builder { + this.value = value + return this + } + + fun setPositiveButton(name: String?): Builder { + positiveBtn = name + return this + } + + fun setNegativeButton(name: String?): Builder { + negativeBtn = name + return this + } + + fun setOnDialogClickListener(listener: OnDialogButtonClickListener): Builder { + this.listener = listener + return this + } + + fun build(): InputDialog { + return InputDialog(this) + } + } + + interface OnDialogButtonClickListener { + fun onButtonClick(input: String) + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_dialog_button.xml b/app/src/main/res/drawable/bg_dialog_button.xml new file mode 100644 index 0000000..5f7d57d --- /dev/null +++ b/app/src/main/res/drawable/bg_dialog_button.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_layout_white.xml b/app/src/main/res/drawable/bg_layout_white.xml new file mode 100644 index 0000000..19b473b --- /dev/null +++ b/app/src/main/res/drawable/bg_layout_white.xml @@ -0,0 +1,11 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/guide1.png b/app/src/main/res/drawable/guide1.png new file mode 100644 index 0000000..074c768 --- /dev/null +++ b/app/src/main/res/drawable/guide1.png Binary files differ diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_lock.xml b/app/src/main/res/drawable/ic_lock.xml new file mode 100644 index 0000000..f0a5610 --- /dev/null +++ b/app/src/main/res/drawable/ic_lock.xml @@ -0,0 +1,12 @@ + + + + diff --git a/app/src/main/res/drawable/ic_login_bg.png b/app/src/main/res/drawable/ic_login_bg.png new file mode 100644 index 0000000..64789c3 --- /dev/null +++ b/app/src/main/res/drawable/ic_login_bg.png Binary files differ diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..603b140 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..88ea3aa --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,122 @@ + + + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+ + +
+
\ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..5cd135a --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..7bfef59 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..4ca4a9f --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,67 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' + +android { + compileSdkVersion 30 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.birmm.inspect" + minSdkVersion 21 + targetSdkVersion 30 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'androidx.core:core-ktx:1.3.2' + implementation 'androidx.constraintlayout:constraintlayout:2.0.4' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test.ext:junit:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:1.3.0' + //腾讯Android UI框架 + implementation 'com.qmuiteam:qmui:2.0.0-alpha10' + implementation 'com.qmuiteam:arch:0.3.1' + //沉浸式状态栏。基础依赖包,必须要依赖 + implementation 'com.gyf.immersionbar:immersionbar:3.0.0' + //fragment快速实现 + implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + + //MVP网络请求框架retrofit2+rxjava + implementation 'io.reactivex:rxjava:1.3.8' + implementation 'io.reactivex:rxandroid:1.2.1' + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.6.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + implementation 'com.squareup.retrofit2:adapter-rxjava:2.8.1' + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.8.6' + //Toast提示 + implementation 'com.sdsmdg.tastytoast:tastytoast:0.1.1' + //图片选择框架 + implementation 'com.github.LuckSiege.PictureSelector:picture_library:v2.6.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..ea03309 --- /dev/null +++ b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.casic.birmm.inspect + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.casic.birmm.inspect", appContext.packageName) + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..7096527 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt new file mode 100644 index 0000000..aefdbb6 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt @@ -0,0 +1,36 @@ +package com.casic.birmm.inspect.base + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.qmuiteam.qmui.util.QMUIStatusBarHelper + +abstract class BaseActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(initLayoutView()) + QMUIStatusBarHelper.translucent(this) //沉浸式状态栏 + setupTopBarLayout() + initData() + initEvent() + } + + /** + * 初始化xml布局 + */ + abstract fun initLayoutView(): Int + + /** + * 特定页面定制沉浸式状态栏 + */ + protected abstract fun setupTopBarLayout() + + /** + * 初始化默认数据 + */ + abstract fun initData() + + /** + * 初始化业务逻辑 + */ + abstract fun initEvent() +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt new file mode 100644 index 0000000..fc0ca75 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt @@ -0,0 +1,18 @@ +package com.casic.birmm.inspect.base + +import android.app.Application +import com.casic.birmm.inspect.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + companion object { + var instance: BaseApplication by Delegates.notNull() + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt new file mode 100644 index 0000000..ddc160a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt @@ -0,0 +1,56 @@ +package com.casic.birmm.inspect.ui + +import android.annotation.SuppressLint +import android.content.Intent +import android.os.CountDownTimer +import android.view.ViewGroup.MarginLayoutParams +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.activity_guide.* + +@SuppressLint("SetTextI18n") +class GuideActivity : BaseActivity() { + + private lateinit var countDownTimer: CountDownTimer + + override fun initLayoutView(): Int = R.layout.activity_guide + + override fun setupTopBarLayout() { + + } + + override fun initData() { + //根据不同设备状态栏高度设置"跳过"按钮的Margin值 + val statusBarHeight = QMUIDisplayHelper.getStatusBarHeight(this) + val rightMargin = QMUIDisplayHelper.dp2px(this, 10) + if (skipButton.layoutParams is MarginLayoutParams) { + val params = skipButton.layoutParams as MarginLayoutParams + params.setMargins(skipButton.width, statusBarHeight, rightMargin, 0) + skipButton.requestLayout() + } + + countDownTimer = object : CountDownTimer(4000, 1000) { + override fun onFinish() { + startLoginActivity() + } + + override fun onTick(millisUntilFinished: Long) { + skipButton.text = "跳过\u3000${(millisUntilFinished / 1000)}s" + } + } + } + + override fun initEvent() { + countDownTimer.start() + skipButton.setOnClickListener { + countDownTimer.cancel() + startLoginActivity() + } + } + + fun startLoginActivity() { + startActivity(Intent(this, LoginActivity::class.java)) + finish() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt new file mode 100644 index 0000000..6ef4548 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt @@ -0,0 +1,81 @@ +package com.casic.birmm.inspect.ui + +import android.text.Editable +import android.text.TextWatcher +import android.view.KeyEvent +import android.view.inputmethod.EditorInfo +import android.widget.EditText +import android.widget.TextView +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.casic.birmm.inspect.utils.Constant +import com.casic.birmm.inspect.utils.SaveKeyValues +import com.casic.birmm.inspect.widgets.InputDialog +import kotlinx.android.synthetic.main.activity_login.* + + +class LoginActivity : BaseActivity() { + + companion object { + private const val Tag = "LoginActivity" + } + + override fun initLayoutView(): Int = R.layout.activity_login + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + loginButton.setChangeAlphaWhenPress(true) + val editText: EditText? = inputLayout.editText + editText?.addTextChangedListener(object : TextWatcher { + override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) { + + } + + override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) { + + } + + override fun afterTextChanged(s: Editable) { + if (s.toString().trim { it <= ' ' }.length > 12) { + inputLayout.error = "密码长度超出限制" + } else { + inputLayout.error = null + } + } + }) + //点击输入法键盘"完成" + editText?.setOnEditorActionListener { _: TextView?, actionId: Int, _: KeyEvent? -> + if (actionId == EditorInfo.IME_ACTION_DONE) { +// authenticatePresenter.onReadyRetrofitRequest() + return@setOnEditorActionListener true + } + false + } + + //修改服务器配置 + changeServerConfigView.setOnClickListener { + val defaultValue = SaveKeyValues.getValue( + Constant.DEFAULT_SERVER_CONFIG, + "http://139.198.6.177:8093/" + ) as String + InputDialog.Builder().setContext(this) + .setTitle("请输入后台服务器地址") + .setDefaultValue(defaultValue) + .setNegativeButton("取消") + .setPositiveButton("保存") + .setOnDialogClickListener(object : InputDialog.OnDialogButtonClickListener { + override fun onButtonClick(input: String) { + SaveKeyValues.putValue(Constant.DEFAULT_SERVER_CONFIG, input) + } + }) + .build().show() + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt new file mode 100644 index 0000000..0e97af7 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt @@ -0,0 +1,21 @@ +package com.casic.birmm.inspect.ui + +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity + +class MainActivity : BaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt new file mode 100644 index 0000000..21fbba2 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt @@ -0,0 +1,58 @@ +package com.casic.birmm.inspect.ui + +import android.content.Intent +import android.os.Build +import android.os.Bundle +import android.util.Log +import androidx.appcompat.app.AppCompatActivity +import com.casic.birmm.inspect.utils.Constant +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + companion object { + private const val TAG = "PermissionActivity" + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + if (EasyPermissions.hasPermissions(this, *Constant.USER_PERMISSIONS)) { + startGuideActivity() + } else { + EasyPermissions.requestPermissions( + this, + "需要获取相关权限", + Constant.PERMISSIONS_CODE, + *Constant.USER_PERMISSIONS + ) + } + } else { + startGuideActivity() + } + } + + private fun startGuideActivity() { + startActivity(Intent(this, GuideActivity::class.java)) + finish() + } + + override fun onRequestPermissionsResult( + requestCode: Int, + permissions: Array, + grantResults: IntArray + ) { + super.onRequestPermissionsResult(requestCode, permissions, grantResults) + EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this) + } + + override fun onPermissionsGranted(requestCode: Int, perms: List) { + startGuideActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + Log.e(TAG, "onPermissionsDenied: $perms") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt new file mode 100644 index 0000000..53df6e1 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt @@ -0,0 +1,15 @@ +package com.casic.birmm.inspect.utils + +import android.Manifest + + +object Constant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.ACCESS_LOCATION_EXTRA_COMMANDS, + Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION + ) + + const val PERMISSIONS_CODE = 999 + + const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt new file mode 100644 index 0000000..4c38241 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt @@ -0,0 +1,19 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.view.View +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object OtherUtils { + + //替换Toast + fun showTipsDialog(context: Context, message: String, view: View) { + val tipDialog = QMUITipDialog.Builder(context) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_NOTHING) + .setTipWord(message).create() + tipDialog.show() + view.postDelayed({ + tipDialog.dismiss() + }, 2000) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt b/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt new file mode 100644 index 0000000..04c9f5a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt @@ -0,0 +1,106 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.content.SharedPreferences +import com.casic.birmm.inspect.base.BaseApplication + +object SaveKeyValues { + private var sharedPreferences: SharedPreferences? = null + private var editor: SharedPreferences.Editor? = null + private var fileName: String? = null + + fun initSharedPreferences() { + val packageName = BaseApplication.instance.packageName + //获取到的包名带有“.”方便命名,取最后一个作为sp文件名,例如:com.casic.birmm.inspect + val split = packageName.split(".") + fileName = split[split.size - 1] + } + + /** + * 存储 + */ + fun putValue(key: String?, obj: Any) { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + val editor = sharedPreferences!!.edit() + when (obj) { + is String -> { + editor.putString(key, obj).apply() + } + is Int -> { + editor.putInt(key, obj).apply() + } + is Boolean -> { + editor.putBoolean(key, obj).apply() + } + is Float -> { + editor.putFloat(key, obj).apply() + } + is Long -> { + editor.putLong(key, obj).apply() + } + else -> { + editor.putString(key, obj.toString()).apply() + } + } + } + + /** + * 获取保存的数据 + */ + operator fun getValue(key: String?, defaultObject: Any?): Any? { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + return when (defaultObject) { + is String -> { + sharedPreferences!!.getString(key, defaultObject as String?) + } + is Int -> { + sharedPreferences!!.getInt(key, (defaultObject as Int?)!!) + } + is Boolean -> { + sharedPreferences!!.getBoolean(key, (defaultObject as Boolean?)!!) + } + is Float -> { + sharedPreferences!!.getFloat(key, (defaultObject as Float?)!!) + } + is Long -> { + sharedPreferences!!.getLong(key, (defaultObject as Long?)!!) + } + else -> { + sharedPreferences!!.getString(key, null) + } + } + } + + /** + * 移除某个key值已经对应的值 + */ + fun removeKey(key: String?) { + editor!!.remove(key) + editor!!.commit() + } + + /** + * 清除所有数据 + */ + fun clearAll() { + editor!!.clear() + editor!!.commit() + } + + /** + * 查询某个key是否存在 + */ + fun containsKey(key: String?): Boolean { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + return sharedPreferences!!.contains(key) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt b/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt new file mode 100644 index 0000000..04db86b --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt @@ -0,0 +1,119 @@ +package com.casic.birmm.inspect.widgets + +import android.app.Dialog +import android.content.Context +import android.graphics.Color +import android.graphics.drawable.ColorDrawable +import android.os.Bundle +import android.view.WindowManager +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.utils.OtherUtils +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.dialog_input.* + + +class InputDialog private constructor(builder: Builder) : Dialog(builder.mContext!!) { + + private var ctx: Context? = null + private var title: String? = null + private var value: String? = null + private var positiveBtn: String? = null + private var negativeBtn: String? = null + private var listener: OnDialogButtonClickListener? = null + + init { + this.ctx = builder.mContext + this.title = builder.title + this.value = builder.value + this.positiveBtn = builder.positiveBtn + this.negativeBtn = builder.negativeBtn + this.listener = builder.listener + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + configDialogLayout() + setContentView(R.layout.dialog_input) + setCancelable(false) + setCanceledOnTouchOutside(false) + + dialogTitleView.text = title + value.apply { + dialogInputView.setText(this) + } + + dialogCancelButton.text = negativeBtn + dialogCancelButton.setChangeAlphaWhenPress(true) + dialogCancelButton.setOnClickListener { + this.dismiss() + } + + dialogConfirmButton.text = positiveBtn + dialogConfirmButton.setChangeAlphaWhenPress(true) + dialogConfirmButton.setOnClickListener { + val inputValue = dialogInputView.text.toString().trim() + if (inputValue.isEmpty()) { + OtherUtils.showTipsDialog(ctx!!, "什么都没输入,请重新输入", dialogConfirmButton) + return@setOnClickListener + } + listener?.onButtonClick(inputValue) + this.dismiss() + } + } + + private fun configDialogLayout() { + window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT)) + window?.decorView?.setBackgroundColor(Color.TRANSPARENT) + val params: WindowManager.LayoutParams? = window?.attributes + params?.width = QMUIDisplayHelper.dp2px(ctx, 300) + params?.height = WindowManager.LayoutParams.WRAP_CONTENT + window?.attributes = params + } + + class Builder { + var mContext: Context? = null + var title: String? = null + var value: String? = null + var positiveBtn: String? = null + var negativeBtn: String? = null + var listener: OnDialogButtonClickListener? = null + + fun setContext(context: Context?): Builder { + mContext = context + return this + } + + fun setTitle(title: String?): Builder { + this.title = title + return this + } + + fun setDefaultValue(value: String?): Builder { + this.value = value + return this + } + + fun setPositiveButton(name: String?): Builder { + positiveBtn = name + return this + } + + fun setNegativeButton(name: String?): Builder { + negativeBtn = name + return this + } + + fun setOnDialogClickListener(listener: OnDialogButtonClickListener): Builder { + this.listener = listener + return this + } + + fun build(): InputDialog { + return InputDialog(this) + } + } + + interface OnDialogButtonClickListener { + fun onButtonClick(input: String) + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_dialog_button.xml b/app/src/main/res/drawable/bg_dialog_button.xml new file mode 100644 index 0000000..5f7d57d --- /dev/null +++ b/app/src/main/res/drawable/bg_dialog_button.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_layout_white.xml b/app/src/main/res/drawable/bg_layout_white.xml new file mode 100644 index 0000000..19b473b --- /dev/null +++ b/app/src/main/res/drawable/bg_layout_white.xml @@ -0,0 +1,11 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/guide1.png b/app/src/main/res/drawable/guide1.png new file mode 100644 index 0000000..074c768 --- /dev/null +++ b/app/src/main/res/drawable/guide1.png Binary files differ diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_lock.xml b/app/src/main/res/drawable/ic_lock.xml new file mode 100644 index 0000000..f0a5610 --- /dev/null +++ b/app/src/main/res/drawable/ic_lock.xml @@ -0,0 +1,12 @@ + + + + diff --git a/app/src/main/res/drawable/ic_login_bg.png b/app/src/main/res/drawable/ic_login_bg.png new file mode 100644 index 0000000..64789c3 --- /dev/null +++ b/app/src/main/res/drawable/ic_login_bg.png Binary files differ diff --git a/app/src/main/res/drawable/ic_user.xml b/app/src/main/res/drawable/ic_user.xml new file mode 100644 index 0000000..8c4a29d --- /dev/null +++ b/app/src/main/res/drawable/ic_user.xml @@ -0,0 +1,15 @@ + + + + + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..603b140 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..88ea3aa --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,122 @@ + + + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+ + +
+
\ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..5cd135a --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..7bfef59 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..4ca4a9f --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,67 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' + +android { + compileSdkVersion 30 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.birmm.inspect" + minSdkVersion 21 + targetSdkVersion 30 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'androidx.core:core-ktx:1.3.2' + implementation 'androidx.constraintlayout:constraintlayout:2.0.4' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test.ext:junit:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:1.3.0' + //腾讯Android UI框架 + implementation 'com.qmuiteam:qmui:2.0.0-alpha10' + implementation 'com.qmuiteam:arch:0.3.1' + //沉浸式状态栏。基础依赖包,必须要依赖 + implementation 'com.gyf.immersionbar:immersionbar:3.0.0' + //fragment快速实现 + implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + + //MVP网络请求框架retrofit2+rxjava + implementation 'io.reactivex:rxjava:1.3.8' + implementation 'io.reactivex:rxandroid:1.2.1' + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.6.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + implementation 'com.squareup.retrofit2:adapter-rxjava:2.8.1' + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.8.6' + //Toast提示 + implementation 'com.sdsmdg.tastytoast:tastytoast:0.1.1' + //图片选择框架 + implementation 'com.github.LuckSiege.PictureSelector:picture_library:v2.6.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..ea03309 --- /dev/null +++ b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.casic.birmm.inspect + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.casic.birmm.inspect", appContext.packageName) + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..7096527 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt new file mode 100644 index 0000000..aefdbb6 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt @@ -0,0 +1,36 @@ +package com.casic.birmm.inspect.base + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.qmuiteam.qmui.util.QMUIStatusBarHelper + +abstract class BaseActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(initLayoutView()) + QMUIStatusBarHelper.translucent(this) //沉浸式状态栏 + setupTopBarLayout() + initData() + initEvent() + } + + /** + * 初始化xml布局 + */ + abstract fun initLayoutView(): Int + + /** + * 特定页面定制沉浸式状态栏 + */ + protected abstract fun setupTopBarLayout() + + /** + * 初始化默认数据 + */ + abstract fun initData() + + /** + * 初始化业务逻辑 + */ + abstract fun initEvent() +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt new file mode 100644 index 0000000..fc0ca75 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt @@ -0,0 +1,18 @@ +package com.casic.birmm.inspect.base + +import android.app.Application +import com.casic.birmm.inspect.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + companion object { + var instance: BaseApplication by Delegates.notNull() + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt new file mode 100644 index 0000000..ddc160a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt @@ -0,0 +1,56 @@ +package com.casic.birmm.inspect.ui + +import android.annotation.SuppressLint +import android.content.Intent +import android.os.CountDownTimer +import android.view.ViewGroup.MarginLayoutParams +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.activity_guide.* + +@SuppressLint("SetTextI18n") +class GuideActivity : BaseActivity() { + + private lateinit var countDownTimer: CountDownTimer + + override fun initLayoutView(): Int = R.layout.activity_guide + + override fun setupTopBarLayout() { + + } + + override fun initData() { + //根据不同设备状态栏高度设置"跳过"按钮的Margin值 + val statusBarHeight = QMUIDisplayHelper.getStatusBarHeight(this) + val rightMargin = QMUIDisplayHelper.dp2px(this, 10) + if (skipButton.layoutParams is MarginLayoutParams) { + val params = skipButton.layoutParams as MarginLayoutParams + params.setMargins(skipButton.width, statusBarHeight, rightMargin, 0) + skipButton.requestLayout() + } + + countDownTimer = object : CountDownTimer(4000, 1000) { + override fun onFinish() { + startLoginActivity() + } + + override fun onTick(millisUntilFinished: Long) { + skipButton.text = "跳过\u3000${(millisUntilFinished / 1000)}s" + } + } + } + + override fun initEvent() { + countDownTimer.start() + skipButton.setOnClickListener { + countDownTimer.cancel() + startLoginActivity() + } + } + + fun startLoginActivity() { + startActivity(Intent(this, LoginActivity::class.java)) + finish() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt new file mode 100644 index 0000000..6ef4548 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt @@ -0,0 +1,81 @@ +package com.casic.birmm.inspect.ui + +import android.text.Editable +import android.text.TextWatcher +import android.view.KeyEvent +import android.view.inputmethod.EditorInfo +import android.widget.EditText +import android.widget.TextView +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.casic.birmm.inspect.utils.Constant +import com.casic.birmm.inspect.utils.SaveKeyValues +import com.casic.birmm.inspect.widgets.InputDialog +import kotlinx.android.synthetic.main.activity_login.* + + +class LoginActivity : BaseActivity() { + + companion object { + private const val Tag = "LoginActivity" + } + + override fun initLayoutView(): Int = R.layout.activity_login + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + loginButton.setChangeAlphaWhenPress(true) + val editText: EditText? = inputLayout.editText + editText?.addTextChangedListener(object : TextWatcher { + override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) { + + } + + override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) { + + } + + override fun afterTextChanged(s: Editable) { + if (s.toString().trim { it <= ' ' }.length > 12) { + inputLayout.error = "密码长度超出限制" + } else { + inputLayout.error = null + } + } + }) + //点击输入法键盘"完成" + editText?.setOnEditorActionListener { _: TextView?, actionId: Int, _: KeyEvent? -> + if (actionId == EditorInfo.IME_ACTION_DONE) { +// authenticatePresenter.onReadyRetrofitRequest() + return@setOnEditorActionListener true + } + false + } + + //修改服务器配置 + changeServerConfigView.setOnClickListener { + val defaultValue = SaveKeyValues.getValue( + Constant.DEFAULT_SERVER_CONFIG, + "http://139.198.6.177:8093/" + ) as String + InputDialog.Builder().setContext(this) + .setTitle("请输入后台服务器地址") + .setDefaultValue(defaultValue) + .setNegativeButton("取消") + .setPositiveButton("保存") + .setOnDialogClickListener(object : InputDialog.OnDialogButtonClickListener { + override fun onButtonClick(input: String) { + SaveKeyValues.putValue(Constant.DEFAULT_SERVER_CONFIG, input) + } + }) + .build().show() + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt new file mode 100644 index 0000000..0e97af7 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt @@ -0,0 +1,21 @@ +package com.casic.birmm.inspect.ui + +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity + +class MainActivity : BaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt new file mode 100644 index 0000000..21fbba2 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt @@ -0,0 +1,58 @@ +package com.casic.birmm.inspect.ui + +import android.content.Intent +import android.os.Build +import android.os.Bundle +import android.util.Log +import androidx.appcompat.app.AppCompatActivity +import com.casic.birmm.inspect.utils.Constant +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + companion object { + private const val TAG = "PermissionActivity" + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + if (EasyPermissions.hasPermissions(this, *Constant.USER_PERMISSIONS)) { + startGuideActivity() + } else { + EasyPermissions.requestPermissions( + this, + "需要获取相关权限", + Constant.PERMISSIONS_CODE, + *Constant.USER_PERMISSIONS + ) + } + } else { + startGuideActivity() + } + } + + private fun startGuideActivity() { + startActivity(Intent(this, GuideActivity::class.java)) + finish() + } + + override fun onRequestPermissionsResult( + requestCode: Int, + permissions: Array, + grantResults: IntArray + ) { + super.onRequestPermissionsResult(requestCode, permissions, grantResults) + EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this) + } + + override fun onPermissionsGranted(requestCode: Int, perms: List) { + startGuideActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + Log.e(TAG, "onPermissionsDenied: $perms") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt new file mode 100644 index 0000000..53df6e1 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt @@ -0,0 +1,15 @@ +package com.casic.birmm.inspect.utils + +import android.Manifest + + +object Constant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.ACCESS_LOCATION_EXTRA_COMMANDS, + Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION + ) + + const val PERMISSIONS_CODE = 999 + + const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt new file mode 100644 index 0000000..4c38241 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt @@ -0,0 +1,19 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.view.View +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object OtherUtils { + + //替换Toast + fun showTipsDialog(context: Context, message: String, view: View) { + val tipDialog = QMUITipDialog.Builder(context) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_NOTHING) + .setTipWord(message).create() + tipDialog.show() + view.postDelayed({ + tipDialog.dismiss() + }, 2000) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt b/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt new file mode 100644 index 0000000..04c9f5a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt @@ -0,0 +1,106 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.content.SharedPreferences +import com.casic.birmm.inspect.base.BaseApplication + +object SaveKeyValues { + private var sharedPreferences: SharedPreferences? = null + private var editor: SharedPreferences.Editor? = null + private var fileName: String? = null + + fun initSharedPreferences() { + val packageName = BaseApplication.instance.packageName + //获取到的包名带有“.”方便命名,取最后一个作为sp文件名,例如:com.casic.birmm.inspect + val split = packageName.split(".") + fileName = split[split.size - 1] + } + + /** + * 存储 + */ + fun putValue(key: String?, obj: Any) { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + val editor = sharedPreferences!!.edit() + when (obj) { + is String -> { + editor.putString(key, obj).apply() + } + is Int -> { + editor.putInt(key, obj).apply() + } + is Boolean -> { + editor.putBoolean(key, obj).apply() + } + is Float -> { + editor.putFloat(key, obj).apply() + } + is Long -> { + editor.putLong(key, obj).apply() + } + else -> { + editor.putString(key, obj.toString()).apply() + } + } + } + + /** + * 获取保存的数据 + */ + operator fun getValue(key: String?, defaultObject: Any?): Any? { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + return when (defaultObject) { + is String -> { + sharedPreferences!!.getString(key, defaultObject as String?) + } + is Int -> { + sharedPreferences!!.getInt(key, (defaultObject as Int?)!!) + } + is Boolean -> { + sharedPreferences!!.getBoolean(key, (defaultObject as Boolean?)!!) + } + is Float -> { + sharedPreferences!!.getFloat(key, (defaultObject as Float?)!!) + } + is Long -> { + sharedPreferences!!.getLong(key, (defaultObject as Long?)!!) + } + else -> { + sharedPreferences!!.getString(key, null) + } + } + } + + /** + * 移除某个key值已经对应的值 + */ + fun removeKey(key: String?) { + editor!!.remove(key) + editor!!.commit() + } + + /** + * 清除所有数据 + */ + fun clearAll() { + editor!!.clear() + editor!!.commit() + } + + /** + * 查询某个key是否存在 + */ + fun containsKey(key: String?): Boolean { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + return sharedPreferences!!.contains(key) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt b/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt new file mode 100644 index 0000000..04db86b --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt @@ -0,0 +1,119 @@ +package com.casic.birmm.inspect.widgets + +import android.app.Dialog +import android.content.Context +import android.graphics.Color +import android.graphics.drawable.ColorDrawable +import android.os.Bundle +import android.view.WindowManager +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.utils.OtherUtils +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.dialog_input.* + + +class InputDialog private constructor(builder: Builder) : Dialog(builder.mContext!!) { + + private var ctx: Context? = null + private var title: String? = null + private var value: String? = null + private var positiveBtn: String? = null + private var negativeBtn: String? = null + private var listener: OnDialogButtonClickListener? = null + + init { + this.ctx = builder.mContext + this.title = builder.title + this.value = builder.value + this.positiveBtn = builder.positiveBtn + this.negativeBtn = builder.negativeBtn + this.listener = builder.listener + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + configDialogLayout() + setContentView(R.layout.dialog_input) + setCancelable(false) + setCanceledOnTouchOutside(false) + + dialogTitleView.text = title + value.apply { + dialogInputView.setText(this) + } + + dialogCancelButton.text = negativeBtn + dialogCancelButton.setChangeAlphaWhenPress(true) + dialogCancelButton.setOnClickListener { + this.dismiss() + } + + dialogConfirmButton.text = positiveBtn + dialogConfirmButton.setChangeAlphaWhenPress(true) + dialogConfirmButton.setOnClickListener { + val inputValue = dialogInputView.text.toString().trim() + if (inputValue.isEmpty()) { + OtherUtils.showTipsDialog(ctx!!, "什么都没输入,请重新输入", dialogConfirmButton) + return@setOnClickListener + } + listener?.onButtonClick(inputValue) + this.dismiss() + } + } + + private fun configDialogLayout() { + window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT)) + window?.decorView?.setBackgroundColor(Color.TRANSPARENT) + val params: WindowManager.LayoutParams? = window?.attributes + params?.width = QMUIDisplayHelper.dp2px(ctx, 300) + params?.height = WindowManager.LayoutParams.WRAP_CONTENT + window?.attributes = params + } + + class Builder { + var mContext: Context? = null + var title: String? = null + var value: String? = null + var positiveBtn: String? = null + var negativeBtn: String? = null + var listener: OnDialogButtonClickListener? = null + + fun setContext(context: Context?): Builder { + mContext = context + return this + } + + fun setTitle(title: String?): Builder { + this.title = title + return this + } + + fun setDefaultValue(value: String?): Builder { + this.value = value + return this + } + + fun setPositiveButton(name: String?): Builder { + positiveBtn = name + return this + } + + fun setNegativeButton(name: String?): Builder { + negativeBtn = name + return this + } + + fun setOnDialogClickListener(listener: OnDialogButtonClickListener): Builder { + this.listener = listener + return this + } + + fun build(): InputDialog { + return InputDialog(this) + } + } + + interface OnDialogButtonClickListener { + fun onButtonClick(input: String) + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_dialog_button.xml b/app/src/main/res/drawable/bg_dialog_button.xml new file mode 100644 index 0000000..5f7d57d --- /dev/null +++ b/app/src/main/res/drawable/bg_dialog_button.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_layout_white.xml b/app/src/main/res/drawable/bg_layout_white.xml new file mode 100644 index 0000000..19b473b --- /dev/null +++ b/app/src/main/res/drawable/bg_layout_white.xml @@ -0,0 +1,11 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/guide1.png b/app/src/main/res/drawable/guide1.png new file mode 100644 index 0000000..074c768 --- /dev/null +++ b/app/src/main/res/drawable/guide1.png Binary files differ diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_lock.xml b/app/src/main/res/drawable/ic_lock.xml new file mode 100644 index 0000000..f0a5610 --- /dev/null +++ b/app/src/main/res/drawable/ic_lock.xml @@ -0,0 +1,12 @@ + + + + diff --git a/app/src/main/res/drawable/ic_login_bg.png b/app/src/main/res/drawable/ic_login_bg.png new file mode 100644 index 0000000..64789c3 --- /dev/null +++ b/app/src/main/res/drawable/ic_login_bg.png Binary files differ diff --git a/app/src/main/res/drawable/ic_user.xml b/app/src/main/res/drawable/ic_user.xml new file mode 100644 index 0000000..8c4a29d --- /dev/null +++ b/app/src/main/res/drawable/ic_user.xml @@ -0,0 +1,15 @@ + + + + + diff --git a/app/src/main/res/layout/activity_guide.xml b/app/src/main/res/layout/activity_guide.xml new file mode 100644 index 0000000..e197626 --- /dev/null +++ b/app/src/main/res/layout/activity_guide.xml @@ -0,0 +1,19 @@ + + + + + \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..603b140 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..88ea3aa --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,122 @@ + + + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+ + +
+
\ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..5cd135a --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..7bfef59 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..4ca4a9f --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,67 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' + +android { + compileSdkVersion 30 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.birmm.inspect" + minSdkVersion 21 + targetSdkVersion 30 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'androidx.core:core-ktx:1.3.2' + implementation 'androidx.constraintlayout:constraintlayout:2.0.4' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test.ext:junit:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:1.3.0' + //腾讯Android UI框架 + implementation 'com.qmuiteam:qmui:2.0.0-alpha10' + implementation 'com.qmuiteam:arch:0.3.1' + //沉浸式状态栏。基础依赖包,必须要依赖 + implementation 'com.gyf.immersionbar:immersionbar:3.0.0' + //fragment快速实现 + implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + + //MVP网络请求框架retrofit2+rxjava + implementation 'io.reactivex:rxjava:1.3.8' + implementation 'io.reactivex:rxandroid:1.2.1' + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.6.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + implementation 'com.squareup.retrofit2:adapter-rxjava:2.8.1' + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.8.6' + //Toast提示 + implementation 'com.sdsmdg.tastytoast:tastytoast:0.1.1' + //图片选择框架 + implementation 'com.github.LuckSiege.PictureSelector:picture_library:v2.6.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..ea03309 --- /dev/null +++ b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.casic.birmm.inspect + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.casic.birmm.inspect", appContext.packageName) + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..7096527 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt new file mode 100644 index 0000000..aefdbb6 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt @@ -0,0 +1,36 @@ +package com.casic.birmm.inspect.base + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.qmuiteam.qmui.util.QMUIStatusBarHelper + +abstract class BaseActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(initLayoutView()) + QMUIStatusBarHelper.translucent(this) //沉浸式状态栏 + setupTopBarLayout() + initData() + initEvent() + } + + /** + * 初始化xml布局 + */ + abstract fun initLayoutView(): Int + + /** + * 特定页面定制沉浸式状态栏 + */ + protected abstract fun setupTopBarLayout() + + /** + * 初始化默认数据 + */ + abstract fun initData() + + /** + * 初始化业务逻辑 + */ + abstract fun initEvent() +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt new file mode 100644 index 0000000..fc0ca75 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt @@ -0,0 +1,18 @@ +package com.casic.birmm.inspect.base + +import android.app.Application +import com.casic.birmm.inspect.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + companion object { + var instance: BaseApplication by Delegates.notNull() + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt new file mode 100644 index 0000000..ddc160a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt @@ -0,0 +1,56 @@ +package com.casic.birmm.inspect.ui + +import android.annotation.SuppressLint +import android.content.Intent +import android.os.CountDownTimer +import android.view.ViewGroup.MarginLayoutParams +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.activity_guide.* + +@SuppressLint("SetTextI18n") +class GuideActivity : BaseActivity() { + + private lateinit var countDownTimer: CountDownTimer + + override fun initLayoutView(): Int = R.layout.activity_guide + + override fun setupTopBarLayout() { + + } + + override fun initData() { + //根据不同设备状态栏高度设置"跳过"按钮的Margin值 + val statusBarHeight = QMUIDisplayHelper.getStatusBarHeight(this) + val rightMargin = QMUIDisplayHelper.dp2px(this, 10) + if (skipButton.layoutParams is MarginLayoutParams) { + val params = skipButton.layoutParams as MarginLayoutParams + params.setMargins(skipButton.width, statusBarHeight, rightMargin, 0) + skipButton.requestLayout() + } + + countDownTimer = object : CountDownTimer(4000, 1000) { + override fun onFinish() { + startLoginActivity() + } + + override fun onTick(millisUntilFinished: Long) { + skipButton.text = "跳过\u3000${(millisUntilFinished / 1000)}s" + } + } + } + + override fun initEvent() { + countDownTimer.start() + skipButton.setOnClickListener { + countDownTimer.cancel() + startLoginActivity() + } + } + + fun startLoginActivity() { + startActivity(Intent(this, LoginActivity::class.java)) + finish() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt new file mode 100644 index 0000000..6ef4548 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt @@ -0,0 +1,81 @@ +package com.casic.birmm.inspect.ui + +import android.text.Editable +import android.text.TextWatcher +import android.view.KeyEvent +import android.view.inputmethod.EditorInfo +import android.widget.EditText +import android.widget.TextView +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.casic.birmm.inspect.utils.Constant +import com.casic.birmm.inspect.utils.SaveKeyValues +import com.casic.birmm.inspect.widgets.InputDialog +import kotlinx.android.synthetic.main.activity_login.* + + +class LoginActivity : BaseActivity() { + + companion object { + private const val Tag = "LoginActivity" + } + + override fun initLayoutView(): Int = R.layout.activity_login + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + loginButton.setChangeAlphaWhenPress(true) + val editText: EditText? = inputLayout.editText + editText?.addTextChangedListener(object : TextWatcher { + override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) { + + } + + override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) { + + } + + override fun afterTextChanged(s: Editable) { + if (s.toString().trim { it <= ' ' }.length > 12) { + inputLayout.error = "密码长度超出限制" + } else { + inputLayout.error = null + } + } + }) + //点击输入法键盘"完成" + editText?.setOnEditorActionListener { _: TextView?, actionId: Int, _: KeyEvent? -> + if (actionId == EditorInfo.IME_ACTION_DONE) { +// authenticatePresenter.onReadyRetrofitRequest() + return@setOnEditorActionListener true + } + false + } + + //修改服务器配置 + changeServerConfigView.setOnClickListener { + val defaultValue = SaveKeyValues.getValue( + Constant.DEFAULT_SERVER_CONFIG, + "http://139.198.6.177:8093/" + ) as String + InputDialog.Builder().setContext(this) + .setTitle("请输入后台服务器地址") + .setDefaultValue(defaultValue) + .setNegativeButton("取消") + .setPositiveButton("保存") + .setOnDialogClickListener(object : InputDialog.OnDialogButtonClickListener { + override fun onButtonClick(input: String) { + SaveKeyValues.putValue(Constant.DEFAULT_SERVER_CONFIG, input) + } + }) + .build().show() + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt new file mode 100644 index 0000000..0e97af7 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt @@ -0,0 +1,21 @@ +package com.casic.birmm.inspect.ui + +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity + +class MainActivity : BaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt new file mode 100644 index 0000000..21fbba2 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt @@ -0,0 +1,58 @@ +package com.casic.birmm.inspect.ui + +import android.content.Intent +import android.os.Build +import android.os.Bundle +import android.util.Log +import androidx.appcompat.app.AppCompatActivity +import com.casic.birmm.inspect.utils.Constant +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + companion object { + private const val TAG = "PermissionActivity" + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + if (EasyPermissions.hasPermissions(this, *Constant.USER_PERMISSIONS)) { + startGuideActivity() + } else { + EasyPermissions.requestPermissions( + this, + "需要获取相关权限", + Constant.PERMISSIONS_CODE, + *Constant.USER_PERMISSIONS + ) + } + } else { + startGuideActivity() + } + } + + private fun startGuideActivity() { + startActivity(Intent(this, GuideActivity::class.java)) + finish() + } + + override fun onRequestPermissionsResult( + requestCode: Int, + permissions: Array, + grantResults: IntArray + ) { + super.onRequestPermissionsResult(requestCode, permissions, grantResults) + EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this) + } + + override fun onPermissionsGranted(requestCode: Int, perms: List) { + startGuideActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + Log.e(TAG, "onPermissionsDenied: $perms") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt new file mode 100644 index 0000000..53df6e1 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt @@ -0,0 +1,15 @@ +package com.casic.birmm.inspect.utils + +import android.Manifest + + +object Constant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.ACCESS_LOCATION_EXTRA_COMMANDS, + Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION + ) + + const val PERMISSIONS_CODE = 999 + + const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt new file mode 100644 index 0000000..4c38241 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt @@ -0,0 +1,19 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.view.View +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object OtherUtils { + + //替换Toast + fun showTipsDialog(context: Context, message: String, view: View) { + val tipDialog = QMUITipDialog.Builder(context) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_NOTHING) + .setTipWord(message).create() + tipDialog.show() + view.postDelayed({ + tipDialog.dismiss() + }, 2000) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt b/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt new file mode 100644 index 0000000..04c9f5a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt @@ -0,0 +1,106 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.content.SharedPreferences +import com.casic.birmm.inspect.base.BaseApplication + +object SaveKeyValues { + private var sharedPreferences: SharedPreferences? = null + private var editor: SharedPreferences.Editor? = null + private var fileName: String? = null + + fun initSharedPreferences() { + val packageName = BaseApplication.instance.packageName + //获取到的包名带有“.”方便命名,取最后一个作为sp文件名,例如:com.casic.birmm.inspect + val split = packageName.split(".") + fileName = split[split.size - 1] + } + + /** + * 存储 + */ + fun putValue(key: String?, obj: Any) { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + val editor = sharedPreferences!!.edit() + when (obj) { + is String -> { + editor.putString(key, obj).apply() + } + is Int -> { + editor.putInt(key, obj).apply() + } + is Boolean -> { + editor.putBoolean(key, obj).apply() + } + is Float -> { + editor.putFloat(key, obj).apply() + } + is Long -> { + editor.putLong(key, obj).apply() + } + else -> { + editor.putString(key, obj.toString()).apply() + } + } + } + + /** + * 获取保存的数据 + */ + operator fun getValue(key: String?, defaultObject: Any?): Any? { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + return when (defaultObject) { + is String -> { + sharedPreferences!!.getString(key, defaultObject as String?) + } + is Int -> { + sharedPreferences!!.getInt(key, (defaultObject as Int?)!!) + } + is Boolean -> { + sharedPreferences!!.getBoolean(key, (defaultObject as Boolean?)!!) + } + is Float -> { + sharedPreferences!!.getFloat(key, (defaultObject as Float?)!!) + } + is Long -> { + sharedPreferences!!.getLong(key, (defaultObject as Long?)!!) + } + else -> { + sharedPreferences!!.getString(key, null) + } + } + } + + /** + * 移除某个key值已经对应的值 + */ + fun removeKey(key: String?) { + editor!!.remove(key) + editor!!.commit() + } + + /** + * 清除所有数据 + */ + fun clearAll() { + editor!!.clear() + editor!!.commit() + } + + /** + * 查询某个key是否存在 + */ + fun containsKey(key: String?): Boolean { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + return sharedPreferences!!.contains(key) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt b/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt new file mode 100644 index 0000000..04db86b --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt @@ -0,0 +1,119 @@ +package com.casic.birmm.inspect.widgets + +import android.app.Dialog +import android.content.Context +import android.graphics.Color +import android.graphics.drawable.ColorDrawable +import android.os.Bundle +import android.view.WindowManager +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.utils.OtherUtils +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.dialog_input.* + + +class InputDialog private constructor(builder: Builder) : Dialog(builder.mContext!!) { + + private var ctx: Context? = null + private var title: String? = null + private var value: String? = null + private var positiveBtn: String? = null + private var negativeBtn: String? = null + private var listener: OnDialogButtonClickListener? = null + + init { + this.ctx = builder.mContext + this.title = builder.title + this.value = builder.value + this.positiveBtn = builder.positiveBtn + this.negativeBtn = builder.negativeBtn + this.listener = builder.listener + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + configDialogLayout() + setContentView(R.layout.dialog_input) + setCancelable(false) + setCanceledOnTouchOutside(false) + + dialogTitleView.text = title + value.apply { + dialogInputView.setText(this) + } + + dialogCancelButton.text = negativeBtn + dialogCancelButton.setChangeAlphaWhenPress(true) + dialogCancelButton.setOnClickListener { + this.dismiss() + } + + dialogConfirmButton.text = positiveBtn + dialogConfirmButton.setChangeAlphaWhenPress(true) + dialogConfirmButton.setOnClickListener { + val inputValue = dialogInputView.text.toString().trim() + if (inputValue.isEmpty()) { + OtherUtils.showTipsDialog(ctx!!, "什么都没输入,请重新输入", dialogConfirmButton) + return@setOnClickListener + } + listener?.onButtonClick(inputValue) + this.dismiss() + } + } + + private fun configDialogLayout() { + window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT)) + window?.decorView?.setBackgroundColor(Color.TRANSPARENT) + val params: WindowManager.LayoutParams? = window?.attributes + params?.width = QMUIDisplayHelper.dp2px(ctx, 300) + params?.height = WindowManager.LayoutParams.WRAP_CONTENT + window?.attributes = params + } + + class Builder { + var mContext: Context? = null + var title: String? = null + var value: String? = null + var positiveBtn: String? = null + var negativeBtn: String? = null + var listener: OnDialogButtonClickListener? = null + + fun setContext(context: Context?): Builder { + mContext = context + return this + } + + fun setTitle(title: String?): Builder { + this.title = title + return this + } + + fun setDefaultValue(value: String?): Builder { + this.value = value + return this + } + + fun setPositiveButton(name: String?): Builder { + positiveBtn = name + return this + } + + fun setNegativeButton(name: String?): Builder { + negativeBtn = name + return this + } + + fun setOnDialogClickListener(listener: OnDialogButtonClickListener): Builder { + this.listener = listener + return this + } + + fun build(): InputDialog { + return InputDialog(this) + } + } + + interface OnDialogButtonClickListener { + fun onButtonClick(input: String) + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_dialog_button.xml b/app/src/main/res/drawable/bg_dialog_button.xml new file mode 100644 index 0000000..5f7d57d --- /dev/null +++ b/app/src/main/res/drawable/bg_dialog_button.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_layout_white.xml b/app/src/main/res/drawable/bg_layout_white.xml new file mode 100644 index 0000000..19b473b --- /dev/null +++ b/app/src/main/res/drawable/bg_layout_white.xml @@ -0,0 +1,11 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/guide1.png b/app/src/main/res/drawable/guide1.png new file mode 100644 index 0000000..074c768 --- /dev/null +++ b/app/src/main/res/drawable/guide1.png Binary files differ diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_lock.xml b/app/src/main/res/drawable/ic_lock.xml new file mode 100644 index 0000000..f0a5610 --- /dev/null +++ b/app/src/main/res/drawable/ic_lock.xml @@ -0,0 +1,12 @@ + + + + diff --git a/app/src/main/res/drawable/ic_login_bg.png b/app/src/main/res/drawable/ic_login_bg.png new file mode 100644 index 0000000..64789c3 --- /dev/null +++ b/app/src/main/res/drawable/ic_login_bg.png Binary files differ diff --git a/app/src/main/res/drawable/ic_user.xml b/app/src/main/res/drawable/ic_user.xml new file mode 100644 index 0000000..8c4a29d --- /dev/null +++ b/app/src/main/res/drawable/ic_user.xml @@ -0,0 +1,15 @@ + + + + + diff --git a/app/src/main/res/layout/activity_guide.xml b/app/src/main/res/layout/activity_guide.xml new file mode 100644 index 0000000..e197626 --- /dev/null +++ b/app/src/main/res/layout/activity_guide.xml @@ -0,0 +1,19 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_login.xml b/app/src/main/res/layout/activity_login.xml new file mode 100644 index 0000000..bcae777 --- /dev/null +++ b/app/src/main/res/layout/activity_login.xml @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..603b140 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..88ea3aa --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,122 @@ + + + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+ + +
+
\ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..5cd135a --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..7bfef59 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..4ca4a9f --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,67 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' + +android { + compileSdkVersion 30 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.birmm.inspect" + minSdkVersion 21 + targetSdkVersion 30 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'androidx.core:core-ktx:1.3.2' + implementation 'androidx.constraintlayout:constraintlayout:2.0.4' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test.ext:junit:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:1.3.0' + //腾讯Android UI框架 + implementation 'com.qmuiteam:qmui:2.0.0-alpha10' + implementation 'com.qmuiteam:arch:0.3.1' + //沉浸式状态栏。基础依赖包,必须要依赖 + implementation 'com.gyf.immersionbar:immersionbar:3.0.0' + //fragment快速实现 + implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + + //MVP网络请求框架retrofit2+rxjava + implementation 'io.reactivex:rxjava:1.3.8' + implementation 'io.reactivex:rxandroid:1.2.1' + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.6.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + implementation 'com.squareup.retrofit2:adapter-rxjava:2.8.1' + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.8.6' + //Toast提示 + implementation 'com.sdsmdg.tastytoast:tastytoast:0.1.1' + //图片选择框架 + implementation 'com.github.LuckSiege.PictureSelector:picture_library:v2.6.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..ea03309 --- /dev/null +++ b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.casic.birmm.inspect + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.casic.birmm.inspect", appContext.packageName) + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..7096527 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt new file mode 100644 index 0000000..aefdbb6 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt @@ -0,0 +1,36 @@ +package com.casic.birmm.inspect.base + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.qmuiteam.qmui.util.QMUIStatusBarHelper + +abstract class BaseActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(initLayoutView()) + QMUIStatusBarHelper.translucent(this) //沉浸式状态栏 + setupTopBarLayout() + initData() + initEvent() + } + + /** + * 初始化xml布局 + */ + abstract fun initLayoutView(): Int + + /** + * 特定页面定制沉浸式状态栏 + */ + protected abstract fun setupTopBarLayout() + + /** + * 初始化默认数据 + */ + abstract fun initData() + + /** + * 初始化业务逻辑 + */ + abstract fun initEvent() +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt new file mode 100644 index 0000000..fc0ca75 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt @@ -0,0 +1,18 @@ +package com.casic.birmm.inspect.base + +import android.app.Application +import com.casic.birmm.inspect.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + companion object { + var instance: BaseApplication by Delegates.notNull() + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt new file mode 100644 index 0000000..ddc160a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt @@ -0,0 +1,56 @@ +package com.casic.birmm.inspect.ui + +import android.annotation.SuppressLint +import android.content.Intent +import android.os.CountDownTimer +import android.view.ViewGroup.MarginLayoutParams +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.activity_guide.* + +@SuppressLint("SetTextI18n") +class GuideActivity : BaseActivity() { + + private lateinit var countDownTimer: CountDownTimer + + override fun initLayoutView(): Int = R.layout.activity_guide + + override fun setupTopBarLayout() { + + } + + override fun initData() { + //根据不同设备状态栏高度设置"跳过"按钮的Margin值 + val statusBarHeight = QMUIDisplayHelper.getStatusBarHeight(this) + val rightMargin = QMUIDisplayHelper.dp2px(this, 10) + if (skipButton.layoutParams is MarginLayoutParams) { + val params = skipButton.layoutParams as MarginLayoutParams + params.setMargins(skipButton.width, statusBarHeight, rightMargin, 0) + skipButton.requestLayout() + } + + countDownTimer = object : CountDownTimer(4000, 1000) { + override fun onFinish() { + startLoginActivity() + } + + override fun onTick(millisUntilFinished: Long) { + skipButton.text = "跳过\u3000${(millisUntilFinished / 1000)}s" + } + } + } + + override fun initEvent() { + countDownTimer.start() + skipButton.setOnClickListener { + countDownTimer.cancel() + startLoginActivity() + } + } + + fun startLoginActivity() { + startActivity(Intent(this, LoginActivity::class.java)) + finish() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt new file mode 100644 index 0000000..6ef4548 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt @@ -0,0 +1,81 @@ +package com.casic.birmm.inspect.ui + +import android.text.Editable +import android.text.TextWatcher +import android.view.KeyEvent +import android.view.inputmethod.EditorInfo +import android.widget.EditText +import android.widget.TextView +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.casic.birmm.inspect.utils.Constant +import com.casic.birmm.inspect.utils.SaveKeyValues +import com.casic.birmm.inspect.widgets.InputDialog +import kotlinx.android.synthetic.main.activity_login.* + + +class LoginActivity : BaseActivity() { + + companion object { + private const val Tag = "LoginActivity" + } + + override fun initLayoutView(): Int = R.layout.activity_login + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + loginButton.setChangeAlphaWhenPress(true) + val editText: EditText? = inputLayout.editText + editText?.addTextChangedListener(object : TextWatcher { + override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) { + + } + + override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) { + + } + + override fun afterTextChanged(s: Editable) { + if (s.toString().trim { it <= ' ' }.length > 12) { + inputLayout.error = "密码长度超出限制" + } else { + inputLayout.error = null + } + } + }) + //点击输入法键盘"完成" + editText?.setOnEditorActionListener { _: TextView?, actionId: Int, _: KeyEvent? -> + if (actionId == EditorInfo.IME_ACTION_DONE) { +// authenticatePresenter.onReadyRetrofitRequest() + return@setOnEditorActionListener true + } + false + } + + //修改服务器配置 + changeServerConfigView.setOnClickListener { + val defaultValue = SaveKeyValues.getValue( + Constant.DEFAULT_SERVER_CONFIG, + "http://139.198.6.177:8093/" + ) as String + InputDialog.Builder().setContext(this) + .setTitle("请输入后台服务器地址") + .setDefaultValue(defaultValue) + .setNegativeButton("取消") + .setPositiveButton("保存") + .setOnDialogClickListener(object : InputDialog.OnDialogButtonClickListener { + override fun onButtonClick(input: String) { + SaveKeyValues.putValue(Constant.DEFAULT_SERVER_CONFIG, input) + } + }) + .build().show() + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt new file mode 100644 index 0000000..0e97af7 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt @@ -0,0 +1,21 @@ +package com.casic.birmm.inspect.ui + +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity + +class MainActivity : BaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt new file mode 100644 index 0000000..21fbba2 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt @@ -0,0 +1,58 @@ +package com.casic.birmm.inspect.ui + +import android.content.Intent +import android.os.Build +import android.os.Bundle +import android.util.Log +import androidx.appcompat.app.AppCompatActivity +import com.casic.birmm.inspect.utils.Constant +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + companion object { + private const val TAG = "PermissionActivity" + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + if (EasyPermissions.hasPermissions(this, *Constant.USER_PERMISSIONS)) { + startGuideActivity() + } else { + EasyPermissions.requestPermissions( + this, + "需要获取相关权限", + Constant.PERMISSIONS_CODE, + *Constant.USER_PERMISSIONS + ) + } + } else { + startGuideActivity() + } + } + + private fun startGuideActivity() { + startActivity(Intent(this, GuideActivity::class.java)) + finish() + } + + override fun onRequestPermissionsResult( + requestCode: Int, + permissions: Array, + grantResults: IntArray + ) { + super.onRequestPermissionsResult(requestCode, permissions, grantResults) + EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this) + } + + override fun onPermissionsGranted(requestCode: Int, perms: List) { + startGuideActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + Log.e(TAG, "onPermissionsDenied: $perms") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt new file mode 100644 index 0000000..53df6e1 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt @@ -0,0 +1,15 @@ +package com.casic.birmm.inspect.utils + +import android.Manifest + + +object Constant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.ACCESS_LOCATION_EXTRA_COMMANDS, + Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION + ) + + const val PERMISSIONS_CODE = 999 + + const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt new file mode 100644 index 0000000..4c38241 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt @@ -0,0 +1,19 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.view.View +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object OtherUtils { + + //替换Toast + fun showTipsDialog(context: Context, message: String, view: View) { + val tipDialog = QMUITipDialog.Builder(context) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_NOTHING) + .setTipWord(message).create() + tipDialog.show() + view.postDelayed({ + tipDialog.dismiss() + }, 2000) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt b/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt new file mode 100644 index 0000000..04c9f5a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt @@ -0,0 +1,106 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.content.SharedPreferences +import com.casic.birmm.inspect.base.BaseApplication + +object SaveKeyValues { + private var sharedPreferences: SharedPreferences? = null + private var editor: SharedPreferences.Editor? = null + private var fileName: String? = null + + fun initSharedPreferences() { + val packageName = BaseApplication.instance.packageName + //获取到的包名带有“.”方便命名,取最后一个作为sp文件名,例如:com.casic.birmm.inspect + val split = packageName.split(".") + fileName = split[split.size - 1] + } + + /** + * 存储 + */ + fun putValue(key: String?, obj: Any) { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + val editor = sharedPreferences!!.edit() + when (obj) { + is String -> { + editor.putString(key, obj).apply() + } + is Int -> { + editor.putInt(key, obj).apply() + } + is Boolean -> { + editor.putBoolean(key, obj).apply() + } + is Float -> { + editor.putFloat(key, obj).apply() + } + is Long -> { + editor.putLong(key, obj).apply() + } + else -> { + editor.putString(key, obj.toString()).apply() + } + } + } + + /** + * 获取保存的数据 + */ + operator fun getValue(key: String?, defaultObject: Any?): Any? { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + return when (defaultObject) { + is String -> { + sharedPreferences!!.getString(key, defaultObject as String?) + } + is Int -> { + sharedPreferences!!.getInt(key, (defaultObject as Int?)!!) + } + is Boolean -> { + sharedPreferences!!.getBoolean(key, (defaultObject as Boolean?)!!) + } + is Float -> { + sharedPreferences!!.getFloat(key, (defaultObject as Float?)!!) + } + is Long -> { + sharedPreferences!!.getLong(key, (defaultObject as Long?)!!) + } + else -> { + sharedPreferences!!.getString(key, null) + } + } + } + + /** + * 移除某个key值已经对应的值 + */ + fun removeKey(key: String?) { + editor!!.remove(key) + editor!!.commit() + } + + /** + * 清除所有数据 + */ + fun clearAll() { + editor!!.clear() + editor!!.commit() + } + + /** + * 查询某个key是否存在 + */ + fun containsKey(key: String?): Boolean { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + return sharedPreferences!!.contains(key) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt b/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt new file mode 100644 index 0000000..04db86b --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt @@ -0,0 +1,119 @@ +package com.casic.birmm.inspect.widgets + +import android.app.Dialog +import android.content.Context +import android.graphics.Color +import android.graphics.drawable.ColorDrawable +import android.os.Bundle +import android.view.WindowManager +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.utils.OtherUtils +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.dialog_input.* + + +class InputDialog private constructor(builder: Builder) : Dialog(builder.mContext!!) { + + private var ctx: Context? = null + private var title: String? = null + private var value: String? = null + private var positiveBtn: String? = null + private var negativeBtn: String? = null + private var listener: OnDialogButtonClickListener? = null + + init { + this.ctx = builder.mContext + this.title = builder.title + this.value = builder.value + this.positiveBtn = builder.positiveBtn + this.negativeBtn = builder.negativeBtn + this.listener = builder.listener + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + configDialogLayout() + setContentView(R.layout.dialog_input) + setCancelable(false) + setCanceledOnTouchOutside(false) + + dialogTitleView.text = title + value.apply { + dialogInputView.setText(this) + } + + dialogCancelButton.text = negativeBtn + dialogCancelButton.setChangeAlphaWhenPress(true) + dialogCancelButton.setOnClickListener { + this.dismiss() + } + + dialogConfirmButton.text = positiveBtn + dialogConfirmButton.setChangeAlphaWhenPress(true) + dialogConfirmButton.setOnClickListener { + val inputValue = dialogInputView.text.toString().trim() + if (inputValue.isEmpty()) { + OtherUtils.showTipsDialog(ctx!!, "什么都没输入,请重新输入", dialogConfirmButton) + return@setOnClickListener + } + listener?.onButtonClick(inputValue) + this.dismiss() + } + } + + private fun configDialogLayout() { + window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT)) + window?.decorView?.setBackgroundColor(Color.TRANSPARENT) + val params: WindowManager.LayoutParams? = window?.attributes + params?.width = QMUIDisplayHelper.dp2px(ctx, 300) + params?.height = WindowManager.LayoutParams.WRAP_CONTENT + window?.attributes = params + } + + class Builder { + var mContext: Context? = null + var title: String? = null + var value: String? = null + var positiveBtn: String? = null + var negativeBtn: String? = null + var listener: OnDialogButtonClickListener? = null + + fun setContext(context: Context?): Builder { + mContext = context + return this + } + + fun setTitle(title: String?): Builder { + this.title = title + return this + } + + fun setDefaultValue(value: String?): Builder { + this.value = value + return this + } + + fun setPositiveButton(name: String?): Builder { + positiveBtn = name + return this + } + + fun setNegativeButton(name: String?): Builder { + negativeBtn = name + return this + } + + fun setOnDialogClickListener(listener: OnDialogButtonClickListener): Builder { + this.listener = listener + return this + } + + fun build(): InputDialog { + return InputDialog(this) + } + } + + interface OnDialogButtonClickListener { + fun onButtonClick(input: String) + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_dialog_button.xml b/app/src/main/res/drawable/bg_dialog_button.xml new file mode 100644 index 0000000..5f7d57d --- /dev/null +++ b/app/src/main/res/drawable/bg_dialog_button.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_layout_white.xml b/app/src/main/res/drawable/bg_layout_white.xml new file mode 100644 index 0000000..19b473b --- /dev/null +++ b/app/src/main/res/drawable/bg_layout_white.xml @@ -0,0 +1,11 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/guide1.png b/app/src/main/res/drawable/guide1.png new file mode 100644 index 0000000..074c768 --- /dev/null +++ b/app/src/main/res/drawable/guide1.png Binary files differ diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_lock.xml b/app/src/main/res/drawable/ic_lock.xml new file mode 100644 index 0000000..f0a5610 --- /dev/null +++ b/app/src/main/res/drawable/ic_lock.xml @@ -0,0 +1,12 @@ + + + + diff --git a/app/src/main/res/drawable/ic_login_bg.png b/app/src/main/res/drawable/ic_login_bg.png new file mode 100644 index 0000000..64789c3 --- /dev/null +++ b/app/src/main/res/drawable/ic_login_bg.png Binary files differ diff --git a/app/src/main/res/drawable/ic_user.xml b/app/src/main/res/drawable/ic_user.xml new file mode 100644 index 0000000..8c4a29d --- /dev/null +++ b/app/src/main/res/drawable/ic_user.xml @@ -0,0 +1,15 @@ + + + + + diff --git a/app/src/main/res/layout/activity_guide.xml b/app/src/main/res/layout/activity_guide.xml new file mode 100644 index 0000000..e197626 --- /dev/null +++ b/app/src/main/res/layout/activity_guide.xml @@ -0,0 +1,19 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_login.xml b/app/src/main/res/layout/activity_login.xml new file mode 100644 index 0000000..bcae777 --- /dev/null +++ b/app/src/main/res/layout/activity_login.xml @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..def59e4 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,18 @@ + + + + + + \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..603b140 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..88ea3aa --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,122 @@ + + + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+ + +
+
\ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..5cd135a --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..7bfef59 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..4ca4a9f --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,67 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' + +android { + compileSdkVersion 30 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.birmm.inspect" + minSdkVersion 21 + targetSdkVersion 30 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'androidx.core:core-ktx:1.3.2' + implementation 'androidx.constraintlayout:constraintlayout:2.0.4' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test.ext:junit:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:1.3.0' + //腾讯Android UI框架 + implementation 'com.qmuiteam:qmui:2.0.0-alpha10' + implementation 'com.qmuiteam:arch:0.3.1' + //沉浸式状态栏。基础依赖包,必须要依赖 + implementation 'com.gyf.immersionbar:immersionbar:3.0.0' + //fragment快速实现 + implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + + //MVP网络请求框架retrofit2+rxjava + implementation 'io.reactivex:rxjava:1.3.8' + implementation 'io.reactivex:rxandroid:1.2.1' + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.6.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + implementation 'com.squareup.retrofit2:adapter-rxjava:2.8.1' + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.8.6' + //Toast提示 + implementation 'com.sdsmdg.tastytoast:tastytoast:0.1.1' + //图片选择框架 + implementation 'com.github.LuckSiege.PictureSelector:picture_library:v2.6.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..ea03309 --- /dev/null +++ b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.casic.birmm.inspect + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.casic.birmm.inspect", appContext.packageName) + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..7096527 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt new file mode 100644 index 0000000..aefdbb6 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt @@ -0,0 +1,36 @@ +package com.casic.birmm.inspect.base + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.qmuiteam.qmui.util.QMUIStatusBarHelper + +abstract class BaseActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(initLayoutView()) + QMUIStatusBarHelper.translucent(this) //沉浸式状态栏 + setupTopBarLayout() + initData() + initEvent() + } + + /** + * 初始化xml布局 + */ + abstract fun initLayoutView(): Int + + /** + * 特定页面定制沉浸式状态栏 + */ + protected abstract fun setupTopBarLayout() + + /** + * 初始化默认数据 + */ + abstract fun initData() + + /** + * 初始化业务逻辑 + */ + abstract fun initEvent() +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt new file mode 100644 index 0000000..fc0ca75 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt @@ -0,0 +1,18 @@ +package com.casic.birmm.inspect.base + +import android.app.Application +import com.casic.birmm.inspect.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + companion object { + var instance: BaseApplication by Delegates.notNull() + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt new file mode 100644 index 0000000..ddc160a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt @@ -0,0 +1,56 @@ +package com.casic.birmm.inspect.ui + +import android.annotation.SuppressLint +import android.content.Intent +import android.os.CountDownTimer +import android.view.ViewGroup.MarginLayoutParams +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.activity_guide.* + +@SuppressLint("SetTextI18n") +class GuideActivity : BaseActivity() { + + private lateinit var countDownTimer: CountDownTimer + + override fun initLayoutView(): Int = R.layout.activity_guide + + override fun setupTopBarLayout() { + + } + + override fun initData() { + //根据不同设备状态栏高度设置"跳过"按钮的Margin值 + val statusBarHeight = QMUIDisplayHelper.getStatusBarHeight(this) + val rightMargin = QMUIDisplayHelper.dp2px(this, 10) + if (skipButton.layoutParams is MarginLayoutParams) { + val params = skipButton.layoutParams as MarginLayoutParams + params.setMargins(skipButton.width, statusBarHeight, rightMargin, 0) + skipButton.requestLayout() + } + + countDownTimer = object : CountDownTimer(4000, 1000) { + override fun onFinish() { + startLoginActivity() + } + + override fun onTick(millisUntilFinished: Long) { + skipButton.text = "跳过\u3000${(millisUntilFinished / 1000)}s" + } + } + } + + override fun initEvent() { + countDownTimer.start() + skipButton.setOnClickListener { + countDownTimer.cancel() + startLoginActivity() + } + } + + fun startLoginActivity() { + startActivity(Intent(this, LoginActivity::class.java)) + finish() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt new file mode 100644 index 0000000..6ef4548 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt @@ -0,0 +1,81 @@ +package com.casic.birmm.inspect.ui + +import android.text.Editable +import android.text.TextWatcher +import android.view.KeyEvent +import android.view.inputmethod.EditorInfo +import android.widget.EditText +import android.widget.TextView +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.casic.birmm.inspect.utils.Constant +import com.casic.birmm.inspect.utils.SaveKeyValues +import com.casic.birmm.inspect.widgets.InputDialog +import kotlinx.android.synthetic.main.activity_login.* + + +class LoginActivity : BaseActivity() { + + companion object { + private const val Tag = "LoginActivity" + } + + override fun initLayoutView(): Int = R.layout.activity_login + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + loginButton.setChangeAlphaWhenPress(true) + val editText: EditText? = inputLayout.editText + editText?.addTextChangedListener(object : TextWatcher { + override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) { + + } + + override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) { + + } + + override fun afterTextChanged(s: Editable) { + if (s.toString().trim { it <= ' ' }.length > 12) { + inputLayout.error = "密码长度超出限制" + } else { + inputLayout.error = null + } + } + }) + //点击输入法键盘"完成" + editText?.setOnEditorActionListener { _: TextView?, actionId: Int, _: KeyEvent? -> + if (actionId == EditorInfo.IME_ACTION_DONE) { +// authenticatePresenter.onReadyRetrofitRequest() + return@setOnEditorActionListener true + } + false + } + + //修改服务器配置 + changeServerConfigView.setOnClickListener { + val defaultValue = SaveKeyValues.getValue( + Constant.DEFAULT_SERVER_CONFIG, + "http://139.198.6.177:8093/" + ) as String + InputDialog.Builder().setContext(this) + .setTitle("请输入后台服务器地址") + .setDefaultValue(defaultValue) + .setNegativeButton("取消") + .setPositiveButton("保存") + .setOnDialogClickListener(object : InputDialog.OnDialogButtonClickListener { + override fun onButtonClick(input: String) { + SaveKeyValues.putValue(Constant.DEFAULT_SERVER_CONFIG, input) + } + }) + .build().show() + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt new file mode 100644 index 0000000..0e97af7 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt @@ -0,0 +1,21 @@ +package com.casic.birmm.inspect.ui + +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity + +class MainActivity : BaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt new file mode 100644 index 0000000..21fbba2 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt @@ -0,0 +1,58 @@ +package com.casic.birmm.inspect.ui + +import android.content.Intent +import android.os.Build +import android.os.Bundle +import android.util.Log +import androidx.appcompat.app.AppCompatActivity +import com.casic.birmm.inspect.utils.Constant +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + companion object { + private const val TAG = "PermissionActivity" + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + if (EasyPermissions.hasPermissions(this, *Constant.USER_PERMISSIONS)) { + startGuideActivity() + } else { + EasyPermissions.requestPermissions( + this, + "需要获取相关权限", + Constant.PERMISSIONS_CODE, + *Constant.USER_PERMISSIONS + ) + } + } else { + startGuideActivity() + } + } + + private fun startGuideActivity() { + startActivity(Intent(this, GuideActivity::class.java)) + finish() + } + + override fun onRequestPermissionsResult( + requestCode: Int, + permissions: Array, + grantResults: IntArray + ) { + super.onRequestPermissionsResult(requestCode, permissions, grantResults) + EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this) + } + + override fun onPermissionsGranted(requestCode: Int, perms: List) { + startGuideActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + Log.e(TAG, "onPermissionsDenied: $perms") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt new file mode 100644 index 0000000..53df6e1 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt @@ -0,0 +1,15 @@ +package com.casic.birmm.inspect.utils + +import android.Manifest + + +object Constant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.ACCESS_LOCATION_EXTRA_COMMANDS, + Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION + ) + + const val PERMISSIONS_CODE = 999 + + const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt new file mode 100644 index 0000000..4c38241 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt @@ -0,0 +1,19 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.view.View +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object OtherUtils { + + //替换Toast + fun showTipsDialog(context: Context, message: String, view: View) { + val tipDialog = QMUITipDialog.Builder(context) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_NOTHING) + .setTipWord(message).create() + tipDialog.show() + view.postDelayed({ + tipDialog.dismiss() + }, 2000) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt b/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt new file mode 100644 index 0000000..04c9f5a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt @@ -0,0 +1,106 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.content.SharedPreferences +import com.casic.birmm.inspect.base.BaseApplication + +object SaveKeyValues { + private var sharedPreferences: SharedPreferences? = null + private var editor: SharedPreferences.Editor? = null + private var fileName: String? = null + + fun initSharedPreferences() { + val packageName = BaseApplication.instance.packageName + //获取到的包名带有“.”方便命名,取最后一个作为sp文件名,例如:com.casic.birmm.inspect + val split = packageName.split(".") + fileName = split[split.size - 1] + } + + /** + * 存储 + */ + fun putValue(key: String?, obj: Any) { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + val editor = sharedPreferences!!.edit() + when (obj) { + is String -> { + editor.putString(key, obj).apply() + } + is Int -> { + editor.putInt(key, obj).apply() + } + is Boolean -> { + editor.putBoolean(key, obj).apply() + } + is Float -> { + editor.putFloat(key, obj).apply() + } + is Long -> { + editor.putLong(key, obj).apply() + } + else -> { + editor.putString(key, obj.toString()).apply() + } + } + } + + /** + * 获取保存的数据 + */ + operator fun getValue(key: String?, defaultObject: Any?): Any? { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + return when (defaultObject) { + is String -> { + sharedPreferences!!.getString(key, defaultObject as String?) + } + is Int -> { + sharedPreferences!!.getInt(key, (defaultObject as Int?)!!) + } + is Boolean -> { + sharedPreferences!!.getBoolean(key, (defaultObject as Boolean?)!!) + } + is Float -> { + sharedPreferences!!.getFloat(key, (defaultObject as Float?)!!) + } + is Long -> { + sharedPreferences!!.getLong(key, (defaultObject as Long?)!!) + } + else -> { + sharedPreferences!!.getString(key, null) + } + } + } + + /** + * 移除某个key值已经对应的值 + */ + fun removeKey(key: String?) { + editor!!.remove(key) + editor!!.commit() + } + + /** + * 清除所有数据 + */ + fun clearAll() { + editor!!.clear() + editor!!.commit() + } + + /** + * 查询某个key是否存在 + */ + fun containsKey(key: String?): Boolean { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + return sharedPreferences!!.contains(key) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt b/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt new file mode 100644 index 0000000..04db86b --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt @@ -0,0 +1,119 @@ +package com.casic.birmm.inspect.widgets + +import android.app.Dialog +import android.content.Context +import android.graphics.Color +import android.graphics.drawable.ColorDrawable +import android.os.Bundle +import android.view.WindowManager +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.utils.OtherUtils +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.dialog_input.* + + +class InputDialog private constructor(builder: Builder) : Dialog(builder.mContext!!) { + + private var ctx: Context? = null + private var title: String? = null + private var value: String? = null + private var positiveBtn: String? = null + private var negativeBtn: String? = null + private var listener: OnDialogButtonClickListener? = null + + init { + this.ctx = builder.mContext + this.title = builder.title + this.value = builder.value + this.positiveBtn = builder.positiveBtn + this.negativeBtn = builder.negativeBtn + this.listener = builder.listener + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + configDialogLayout() + setContentView(R.layout.dialog_input) + setCancelable(false) + setCanceledOnTouchOutside(false) + + dialogTitleView.text = title + value.apply { + dialogInputView.setText(this) + } + + dialogCancelButton.text = negativeBtn + dialogCancelButton.setChangeAlphaWhenPress(true) + dialogCancelButton.setOnClickListener { + this.dismiss() + } + + dialogConfirmButton.text = positiveBtn + dialogConfirmButton.setChangeAlphaWhenPress(true) + dialogConfirmButton.setOnClickListener { + val inputValue = dialogInputView.text.toString().trim() + if (inputValue.isEmpty()) { + OtherUtils.showTipsDialog(ctx!!, "什么都没输入,请重新输入", dialogConfirmButton) + return@setOnClickListener + } + listener?.onButtonClick(inputValue) + this.dismiss() + } + } + + private fun configDialogLayout() { + window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT)) + window?.decorView?.setBackgroundColor(Color.TRANSPARENT) + val params: WindowManager.LayoutParams? = window?.attributes + params?.width = QMUIDisplayHelper.dp2px(ctx, 300) + params?.height = WindowManager.LayoutParams.WRAP_CONTENT + window?.attributes = params + } + + class Builder { + var mContext: Context? = null + var title: String? = null + var value: String? = null + var positiveBtn: String? = null + var negativeBtn: String? = null + var listener: OnDialogButtonClickListener? = null + + fun setContext(context: Context?): Builder { + mContext = context + return this + } + + fun setTitle(title: String?): Builder { + this.title = title + return this + } + + fun setDefaultValue(value: String?): Builder { + this.value = value + return this + } + + fun setPositiveButton(name: String?): Builder { + positiveBtn = name + return this + } + + fun setNegativeButton(name: String?): Builder { + negativeBtn = name + return this + } + + fun setOnDialogClickListener(listener: OnDialogButtonClickListener): Builder { + this.listener = listener + return this + } + + fun build(): InputDialog { + return InputDialog(this) + } + } + + interface OnDialogButtonClickListener { + fun onButtonClick(input: String) + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_dialog_button.xml b/app/src/main/res/drawable/bg_dialog_button.xml new file mode 100644 index 0000000..5f7d57d --- /dev/null +++ b/app/src/main/res/drawable/bg_dialog_button.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_layout_white.xml b/app/src/main/res/drawable/bg_layout_white.xml new file mode 100644 index 0000000..19b473b --- /dev/null +++ b/app/src/main/res/drawable/bg_layout_white.xml @@ -0,0 +1,11 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/guide1.png b/app/src/main/res/drawable/guide1.png new file mode 100644 index 0000000..074c768 --- /dev/null +++ b/app/src/main/res/drawable/guide1.png Binary files differ diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_lock.xml b/app/src/main/res/drawable/ic_lock.xml new file mode 100644 index 0000000..f0a5610 --- /dev/null +++ b/app/src/main/res/drawable/ic_lock.xml @@ -0,0 +1,12 @@ + + + + diff --git a/app/src/main/res/drawable/ic_login_bg.png b/app/src/main/res/drawable/ic_login_bg.png new file mode 100644 index 0000000..64789c3 --- /dev/null +++ b/app/src/main/res/drawable/ic_login_bg.png Binary files differ diff --git a/app/src/main/res/drawable/ic_user.xml b/app/src/main/res/drawable/ic_user.xml new file mode 100644 index 0000000..8c4a29d --- /dev/null +++ b/app/src/main/res/drawable/ic_user.xml @@ -0,0 +1,15 @@ + + + + + diff --git a/app/src/main/res/layout/activity_guide.xml b/app/src/main/res/layout/activity_guide.xml new file mode 100644 index 0000000..e197626 --- /dev/null +++ b/app/src/main/res/layout/activity_guide.xml @@ -0,0 +1,19 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_login.xml b/app/src/main/res/layout/activity_login.xml new file mode 100644 index 0000000..bcae777 --- /dev/null +++ b/app/src/main/res/layout/activity_login.xml @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..def59e4 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,18 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_input.xml b/app/src/main/res/layout/dialog_input.xml new file mode 100644 index 0000000..f5a8bc6 --- /dev/null +++ b/app/src/main/res/layout/dialog_input.xml @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..603b140 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..88ea3aa --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,122 @@ + + + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+ + +
+
\ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..5cd135a --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..7bfef59 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..4ca4a9f --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,67 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' + +android { + compileSdkVersion 30 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.birmm.inspect" + minSdkVersion 21 + targetSdkVersion 30 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'androidx.core:core-ktx:1.3.2' + implementation 'androidx.constraintlayout:constraintlayout:2.0.4' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test.ext:junit:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:1.3.0' + //腾讯Android UI框架 + implementation 'com.qmuiteam:qmui:2.0.0-alpha10' + implementation 'com.qmuiteam:arch:0.3.1' + //沉浸式状态栏。基础依赖包,必须要依赖 + implementation 'com.gyf.immersionbar:immersionbar:3.0.0' + //fragment快速实现 + implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + + //MVP网络请求框架retrofit2+rxjava + implementation 'io.reactivex:rxjava:1.3.8' + implementation 'io.reactivex:rxandroid:1.2.1' + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.6.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + implementation 'com.squareup.retrofit2:adapter-rxjava:2.8.1' + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.8.6' + //Toast提示 + implementation 'com.sdsmdg.tastytoast:tastytoast:0.1.1' + //图片选择框架 + implementation 'com.github.LuckSiege.PictureSelector:picture_library:v2.6.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..ea03309 --- /dev/null +++ b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.casic.birmm.inspect + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.casic.birmm.inspect", appContext.packageName) + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..7096527 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt new file mode 100644 index 0000000..aefdbb6 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt @@ -0,0 +1,36 @@ +package com.casic.birmm.inspect.base + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.qmuiteam.qmui.util.QMUIStatusBarHelper + +abstract class BaseActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(initLayoutView()) + QMUIStatusBarHelper.translucent(this) //沉浸式状态栏 + setupTopBarLayout() + initData() + initEvent() + } + + /** + * 初始化xml布局 + */ + abstract fun initLayoutView(): Int + + /** + * 特定页面定制沉浸式状态栏 + */ + protected abstract fun setupTopBarLayout() + + /** + * 初始化默认数据 + */ + abstract fun initData() + + /** + * 初始化业务逻辑 + */ + abstract fun initEvent() +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt new file mode 100644 index 0000000..fc0ca75 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt @@ -0,0 +1,18 @@ +package com.casic.birmm.inspect.base + +import android.app.Application +import com.casic.birmm.inspect.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + companion object { + var instance: BaseApplication by Delegates.notNull() + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt new file mode 100644 index 0000000..ddc160a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt @@ -0,0 +1,56 @@ +package com.casic.birmm.inspect.ui + +import android.annotation.SuppressLint +import android.content.Intent +import android.os.CountDownTimer +import android.view.ViewGroup.MarginLayoutParams +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.activity_guide.* + +@SuppressLint("SetTextI18n") +class GuideActivity : BaseActivity() { + + private lateinit var countDownTimer: CountDownTimer + + override fun initLayoutView(): Int = R.layout.activity_guide + + override fun setupTopBarLayout() { + + } + + override fun initData() { + //根据不同设备状态栏高度设置"跳过"按钮的Margin值 + val statusBarHeight = QMUIDisplayHelper.getStatusBarHeight(this) + val rightMargin = QMUIDisplayHelper.dp2px(this, 10) + if (skipButton.layoutParams is MarginLayoutParams) { + val params = skipButton.layoutParams as MarginLayoutParams + params.setMargins(skipButton.width, statusBarHeight, rightMargin, 0) + skipButton.requestLayout() + } + + countDownTimer = object : CountDownTimer(4000, 1000) { + override fun onFinish() { + startLoginActivity() + } + + override fun onTick(millisUntilFinished: Long) { + skipButton.text = "跳过\u3000${(millisUntilFinished / 1000)}s" + } + } + } + + override fun initEvent() { + countDownTimer.start() + skipButton.setOnClickListener { + countDownTimer.cancel() + startLoginActivity() + } + } + + fun startLoginActivity() { + startActivity(Intent(this, LoginActivity::class.java)) + finish() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt new file mode 100644 index 0000000..6ef4548 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt @@ -0,0 +1,81 @@ +package com.casic.birmm.inspect.ui + +import android.text.Editable +import android.text.TextWatcher +import android.view.KeyEvent +import android.view.inputmethod.EditorInfo +import android.widget.EditText +import android.widget.TextView +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.casic.birmm.inspect.utils.Constant +import com.casic.birmm.inspect.utils.SaveKeyValues +import com.casic.birmm.inspect.widgets.InputDialog +import kotlinx.android.synthetic.main.activity_login.* + + +class LoginActivity : BaseActivity() { + + companion object { + private const val Tag = "LoginActivity" + } + + override fun initLayoutView(): Int = R.layout.activity_login + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + loginButton.setChangeAlphaWhenPress(true) + val editText: EditText? = inputLayout.editText + editText?.addTextChangedListener(object : TextWatcher { + override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) { + + } + + override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) { + + } + + override fun afterTextChanged(s: Editable) { + if (s.toString().trim { it <= ' ' }.length > 12) { + inputLayout.error = "密码长度超出限制" + } else { + inputLayout.error = null + } + } + }) + //点击输入法键盘"完成" + editText?.setOnEditorActionListener { _: TextView?, actionId: Int, _: KeyEvent? -> + if (actionId == EditorInfo.IME_ACTION_DONE) { +// authenticatePresenter.onReadyRetrofitRequest() + return@setOnEditorActionListener true + } + false + } + + //修改服务器配置 + changeServerConfigView.setOnClickListener { + val defaultValue = SaveKeyValues.getValue( + Constant.DEFAULT_SERVER_CONFIG, + "http://139.198.6.177:8093/" + ) as String + InputDialog.Builder().setContext(this) + .setTitle("请输入后台服务器地址") + .setDefaultValue(defaultValue) + .setNegativeButton("取消") + .setPositiveButton("保存") + .setOnDialogClickListener(object : InputDialog.OnDialogButtonClickListener { + override fun onButtonClick(input: String) { + SaveKeyValues.putValue(Constant.DEFAULT_SERVER_CONFIG, input) + } + }) + .build().show() + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt new file mode 100644 index 0000000..0e97af7 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt @@ -0,0 +1,21 @@ +package com.casic.birmm.inspect.ui + +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity + +class MainActivity : BaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt new file mode 100644 index 0000000..21fbba2 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt @@ -0,0 +1,58 @@ +package com.casic.birmm.inspect.ui + +import android.content.Intent +import android.os.Build +import android.os.Bundle +import android.util.Log +import androidx.appcompat.app.AppCompatActivity +import com.casic.birmm.inspect.utils.Constant +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + companion object { + private const val TAG = "PermissionActivity" + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + if (EasyPermissions.hasPermissions(this, *Constant.USER_PERMISSIONS)) { + startGuideActivity() + } else { + EasyPermissions.requestPermissions( + this, + "需要获取相关权限", + Constant.PERMISSIONS_CODE, + *Constant.USER_PERMISSIONS + ) + } + } else { + startGuideActivity() + } + } + + private fun startGuideActivity() { + startActivity(Intent(this, GuideActivity::class.java)) + finish() + } + + override fun onRequestPermissionsResult( + requestCode: Int, + permissions: Array, + grantResults: IntArray + ) { + super.onRequestPermissionsResult(requestCode, permissions, grantResults) + EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this) + } + + override fun onPermissionsGranted(requestCode: Int, perms: List) { + startGuideActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + Log.e(TAG, "onPermissionsDenied: $perms") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt new file mode 100644 index 0000000..53df6e1 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt @@ -0,0 +1,15 @@ +package com.casic.birmm.inspect.utils + +import android.Manifest + + +object Constant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.ACCESS_LOCATION_EXTRA_COMMANDS, + Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION + ) + + const val PERMISSIONS_CODE = 999 + + const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt new file mode 100644 index 0000000..4c38241 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt @@ -0,0 +1,19 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.view.View +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object OtherUtils { + + //替换Toast + fun showTipsDialog(context: Context, message: String, view: View) { + val tipDialog = QMUITipDialog.Builder(context) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_NOTHING) + .setTipWord(message).create() + tipDialog.show() + view.postDelayed({ + tipDialog.dismiss() + }, 2000) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt b/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt new file mode 100644 index 0000000..04c9f5a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt @@ -0,0 +1,106 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.content.SharedPreferences +import com.casic.birmm.inspect.base.BaseApplication + +object SaveKeyValues { + private var sharedPreferences: SharedPreferences? = null + private var editor: SharedPreferences.Editor? = null + private var fileName: String? = null + + fun initSharedPreferences() { + val packageName = BaseApplication.instance.packageName + //获取到的包名带有“.”方便命名,取最后一个作为sp文件名,例如:com.casic.birmm.inspect + val split = packageName.split(".") + fileName = split[split.size - 1] + } + + /** + * 存储 + */ + fun putValue(key: String?, obj: Any) { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + val editor = sharedPreferences!!.edit() + when (obj) { + is String -> { + editor.putString(key, obj).apply() + } + is Int -> { + editor.putInt(key, obj).apply() + } + is Boolean -> { + editor.putBoolean(key, obj).apply() + } + is Float -> { + editor.putFloat(key, obj).apply() + } + is Long -> { + editor.putLong(key, obj).apply() + } + else -> { + editor.putString(key, obj.toString()).apply() + } + } + } + + /** + * 获取保存的数据 + */ + operator fun getValue(key: String?, defaultObject: Any?): Any? { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + return when (defaultObject) { + is String -> { + sharedPreferences!!.getString(key, defaultObject as String?) + } + is Int -> { + sharedPreferences!!.getInt(key, (defaultObject as Int?)!!) + } + is Boolean -> { + sharedPreferences!!.getBoolean(key, (defaultObject as Boolean?)!!) + } + is Float -> { + sharedPreferences!!.getFloat(key, (defaultObject as Float?)!!) + } + is Long -> { + sharedPreferences!!.getLong(key, (defaultObject as Long?)!!) + } + else -> { + sharedPreferences!!.getString(key, null) + } + } + } + + /** + * 移除某个key值已经对应的值 + */ + fun removeKey(key: String?) { + editor!!.remove(key) + editor!!.commit() + } + + /** + * 清除所有数据 + */ + fun clearAll() { + editor!!.clear() + editor!!.commit() + } + + /** + * 查询某个key是否存在 + */ + fun containsKey(key: String?): Boolean { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + return sharedPreferences!!.contains(key) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt b/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt new file mode 100644 index 0000000..04db86b --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt @@ -0,0 +1,119 @@ +package com.casic.birmm.inspect.widgets + +import android.app.Dialog +import android.content.Context +import android.graphics.Color +import android.graphics.drawable.ColorDrawable +import android.os.Bundle +import android.view.WindowManager +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.utils.OtherUtils +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.dialog_input.* + + +class InputDialog private constructor(builder: Builder) : Dialog(builder.mContext!!) { + + private var ctx: Context? = null + private var title: String? = null + private var value: String? = null + private var positiveBtn: String? = null + private var negativeBtn: String? = null + private var listener: OnDialogButtonClickListener? = null + + init { + this.ctx = builder.mContext + this.title = builder.title + this.value = builder.value + this.positiveBtn = builder.positiveBtn + this.negativeBtn = builder.negativeBtn + this.listener = builder.listener + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + configDialogLayout() + setContentView(R.layout.dialog_input) + setCancelable(false) + setCanceledOnTouchOutside(false) + + dialogTitleView.text = title + value.apply { + dialogInputView.setText(this) + } + + dialogCancelButton.text = negativeBtn + dialogCancelButton.setChangeAlphaWhenPress(true) + dialogCancelButton.setOnClickListener { + this.dismiss() + } + + dialogConfirmButton.text = positiveBtn + dialogConfirmButton.setChangeAlphaWhenPress(true) + dialogConfirmButton.setOnClickListener { + val inputValue = dialogInputView.text.toString().trim() + if (inputValue.isEmpty()) { + OtherUtils.showTipsDialog(ctx!!, "什么都没输入,请重新输入", dialogConfirmButton) + return@setOnClickListener + } + listener?.onButtonClick(inputValue) + this.dismiss() + } + } + + private fun configDialogLayout() { + window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT)) + window?.decorView?.setBackgroundColor(Color.TRANSPARENT) + val params: WindowManager.LayoutParams? = window?.attributes + params?.width = QMUIDisplayHelper.dp2px(ctx, 300) + params?.height = WindowManager.LayoutParams.WRAP_CONTENT + window?.attributes = params + } + + class Builder { + var mContext: Context? = null + var title: String? = null + var value: String? = null + var positiveBtn: String? = null + var negativeBtn: String? = null + var listener: OnDialogButtonClickListener? = null + + fun setContext(context: Context?): Builder { + mContext = context + return this + } + + fun setTitle(title: String?): Builder { + this.title = title + return this + } + + fun setDefaultValue(value: String?): Builder { + this.value = value + return this + } + + fun setPositiveButton(name: String?): Builder { + positiveBtn = name + return this + } + + fun setNegativeButton(name: String?): Builder { + negativeBtn = name + return this + } + + fun setOnDialogClickListener(listener: OnDialogButtonClickListener): Builder { + this.listener = listener + return this + } + + fun build(): InputDialog { + return InputDialog(this) + } + } + + interface OnDialogButtonClickListener { + fun onButtonClick(input: String) + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_dialog_button.xml b/app/src/main/res/drawable/bg_dialog_button.xml new file mode 100644 index 0000000..5f7d57d --- /dev/null +++ b/app/src/main/res/drawable/bg_dialog_button.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_layout_white.xml b/app/src/main/res/drawable/bg_layout_white.xml new file mode 100644 index 0000000..19b473b --- /dev/null +++ b/app/src/main/res/drawable/bg_layout_white.xml @@ -0,0 +1,11 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/guide1.png b/app/src/main/res/drawable/guide1.png new file mode 100644 index 0000000..074c768 --- /dev/null +++ b/app/src/main/res/drawable/guide1.png Binary files differ diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_lock.xml b/app/src/main/res/drawable/ic_lock.xml new file mode 100644 index 0000000..f0a5610 --- /dev/null +++ b/app/src/main/res/drawable/ic_lock.xml @@ -0,0 +1,12 @@ + + + + diff --git a/app/src/main/res/drawable/ic_login_bg.png b/app/src/main/res/drawable/ic_login_bg.png new file mode 100644 index 0000000..64789c3 --- /dev/null +++ b/app/src/main/res/drawable/ic_login_bg.png Binary files differ diff --git a/app/src/main/res/drawable/ic_user.xml b/app/src/main/res/drawable/ic_user.xml new file mode 100644 index 0000000..8c4a29d --- /dev/null +++ b/app/src/main/res/drawable/ic_user.xml @@ -0,0 +1,15 @@ + + + + + diff --git a/app/src/main/res/layout/activity_guide.xml b/app/src/main/res/layout/activity_guide.xml new file mode 100644 index 0000000..e197626 --- /dev/null +++ b/app/src/main/res/layout/activity_guide.xml @@ -0,0 +1,19 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_login.xml b/app/src/main/res/layout/activity_login.xml new file mode 100644 index 0000000..bcae777 --- /dev/null +++ b/app/src/main/res/layout/activity_login.xml @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..def59e4 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,18 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_input.xml b/app/src/main/res/layout/dialog_input.xml new file mode 100644 index 0000000..f5a8bc6 --- /dev/null +++ b/app/src/main/res/layout/dialog_input.xml @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..603b140 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..88ea3aa --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,122 @@ + + + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+ + +
+
\ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..5cd135a --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..7bfef59 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..4ca4a9f --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,67 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' + +android { + compileSdkVersion 30 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.birmm.inspect" + minSdkVersion 21 + targetSdkVersion 30 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'androidx.core:core-ktx:1.3.2' + implementation 'androidx.constraintlayout:constraintlayout:2.0.4' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test.ext:junit:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:1.3.0' + //腾讯Android UI框架 + implementation 'com.qmuiteam:qmui:2.0.0-alpha10' + implementation 'com.qmuiteam:arch:0.3.1' + //沉浸式状态栏。基础依赖包,必须要依赖 + implementation 'com.gyf.immersionbar:immersionbar:3.0.0' + //fragment快速实现 + implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + + //MVP网络请求框架retrofit2+rxjava + implementation 'io.reactivex:rxjava:1.3.8' + implementation 'io.reactivex:rxandroid:1.2.1' + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.6.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + implementation 'com.squareup.retrofit2:adapter-rxjava:2.8.1' + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.8.6' + //Toast提示 + implementation 'com.sdsmdg.tastytoast:tastytoast:0.1.1' + //图片选择框架 + implementation 'com.github.LuckSiege.PictureSelector:picture_library:v2.6.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..ea03309 --- /dev/null +++ b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.casic.birmm.inspect + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.casic.birmm.inspect", appContext.packageName) + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..7096527 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt new file mode 100644 index 0000000..aefdbb6 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt @@ -0,0 +1,36 @@ +package com.casic.birmm.inspect.base + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.qmuiteam.qmui.util.QMUIStatusBarHelper + +abstract class BaseActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(initLayoutView()) + QMUIStatusBarHelper.translucent(this) //沉浸式状态栏 + setupTopBarLayout() + initData() + initEvent() + } + + /** + * 初始化xml布局 + */ + abstract fun initLayoutView(): Int + + /** + * 特定页面定制沉浸式状态栏 + */ + protected abstract fun setupTopBarLayout() + + /** + * 初始化默认数据 + */ + abstract fun initData() + + /** + * 初始化业务逻辑 + */ + abstract fun initEvent() +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt new file mode 100644 index 0000000..fc0ca75 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt @@ -0,0 +1,18 @@ +package com.casic.birmm.inspect.base + +import android.app.Application +import com.casic.birmm.inspect.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + companion object { + var instance: BaseApplication by Delegates.notNull() + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt new file mode 100644 index 0000000..ddc160a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt @@ -0,0 +1,56 @@ +package com.casic.birmm.inspect.ui + +import android.annotation.SuppressLint +import android.content.Intent +import android.os.CountDownTimer +import android.view.ViewGroup.MarginLayoutParams +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.activity_guide.* + +@SuppressLint("SetTextI18n") +class GuideActivity : BaseActivity() { + + private lateinit var countDownTimer: CountDownTimer + + override fun initLayoutView(): Int = R.layout.activity_guide + + override fun setupTopBarLayout() { + + } + + override fun initData() { + //根据不同设备状态栏高度设置"跳过"按钮的Margin值 + val statusBarHeight = QMUIDisplayHelper.getStatusBarHeight(this) + val rightMargin = QMUIDisplayHelper.dp2px(this, 10) + if (skipButton.layoutParams is MarginLayoutParams) { + val params = skipButton.layoutParams as MarginLayoutParams + params.setMargins(skipButton.width, statusBarHeight, rightMargin, 0) + skipButton.requestLayout() + } + + countDownTimer = object : CountDownTimer(4000, 1000) { + override fun onFinish() { + startLoginActivity() + } + + override fun onTick(millisUntilFinished: Long) { + skipButton.text = "跳过\u3000${(millisUntilFinished / 1000)}s" + } + } + } + + override fun initEvent() { + countDownTimer.start() + skipButton.setOnClickListener { + countDownTimer.cancel() + startLoginActivity() + } + } + + fun startLoginActivity() { + startActivity(Intent(this, LoginActivity::class.java)) + finish() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt new file mode 100644 index 0000000..6ef4548 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt @@ -0,0 +1,81 @@ +package com.casic.birmm.inspect.ui + +import android.text.Editable +import android.text.TextWatcher +import android.view.KeyEvent +import android.view.inputmethod.EditorInfo +import android.widget.EditText +import android.widget.TextView +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.casic.birmm.inspect.utils.Constant +import com.casic.birmm.inspect.utils.SaveKeyValues +import com.casic.birmm.inspect.widgets.InputDialog +import kotlinx.android.synthetic.main.activity_login.* + + +class LoginActivity : BaseActivity() { + + companion object { + private const val Tag = "LoginActivity" + } + + override fun initLayoutView(): Int = R.layout.activity_login + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + loginButton.setChangeAlphaWhenPress(true) + val editText: EditText? = inputLayout.editText + editText?.addTextChangedListener(object : TextWatcher { + override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) { + + } + + override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) { + + } + + override fun afterTextChanged(s: Editable) { + if (s.toString().trim { it <= ' ' }.length > 12) { + inputLayout.error = "密码长度超出限制" + } else { + inputLayout.error = null + } + } + }) + //点击输入法键盘"完成" + editText?.setOnEditorActionListener { _: TextView?, actionId: Int, _: KeyEvent? -> + if (actionId == EditorInfo.IME_ACTION_DONE) { +// authenticatePresenter.onReadyRetrofitRequest() + return@setOnEditorActionListener true + } + false + } + + //修改服务器配置 + changeServerConfigView.setOnClickListener { + val defaultValue = SaveKeyValues.getValue( + Constant.DEFAULT_SERVER_CONFIG, + "http://139.198.6.177:8093/" + ) as String + InputDialog.Builder().setContext(this) + .setTitle("请输入后台服务器地址") + .setDefaultValue(defaultValue) + .setNegativeButton("取消") + .setPositiveButton("保存") + .setOnDialogClickListener(object : InputDialog.OnDialogButtonClickListener { + override fun onButtonClick(input: String) { + SaveKeyValues.putValue(Constant.DEFAULT_SERVER_CONFIG, input) + } + }) + .build().show() + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt new file mode 100644 index 0000000..0e97af7 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt @@ -0,0 +1,21 @@ +package com.casic.birmm.inspect.ui + +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity + +class MainActivity : BaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt new file mode 100644 index 0000000..21fbba2 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt @@ -0,0 +1,58 @@ +package com.casic.birmm.inspect.ui + +import android.content.Intent +import android.os.Build +import android.os.Bundle +import android.util.Log +import androidx.appcompat.app.AppCompatActivity +import com.casic.birmm.inspect.utils.Constant +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + companion object { + private const val TAG = "PermissionActivity" + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + if (EasyPermissions.hasPermissions(this, *Constant.USER_PERMISSIONS)) { + startGuideActivity() + } else { + EasyPermissions.requestPermissions( + this, + "需要获取相关权限", + Constant.PERMISSIONS_CODE, + *Constant.USER_PERMISSIONS + ) + } + } else { + startGuideActivity() + } + } + + private fun startGuideActivity() { + startActivity(Intent(this, GuideActivity::class.java)) + finish() + } + + override fun onRequestPermissionsResult( + requestCode: Int, + permissions: Array, + grantResults: IntArray + ) { + super.onRequestPermissionsResult(requestCode, permissions, grantResults) + EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this) + } + + override fun onPermissionsGranted(requestCode: Int, perms: List) { + startGuideActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + Log.e(TAG, "onPermissionsDenied: $perms") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt new file mode 100644 index 0000000..53df6e1 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt @@ -0,0 +1,15 @@ +package com.casic.birmm.inspect.utils + +import android.Manifest + + +object Constant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.ACCESS_LOCATION_EXTRA_COMMANDS, + Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION + ) + + const val PERMISSIONS_CODE = 999 + + const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt new file mode 100644 index 0000000..4c38241 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt @@ -0,0 +1,19 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.view.View +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object OtherUtils { + + //替换Toast + fun showTipsDialog(context: Context, message: String, view: View) { + val tipDialog = QMUITipDialog.Builder(context) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_NOTHING) + .setTipWord(message).create() + tipDialog.show() + view.postDelayed({ + tipDialog.dismiss() + }, 2000) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt b/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt new file mode 100644 index 0000000..04c9f5a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt @@ -0,0 +1,106 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.content.SharedPreferences +import com.casic.birmm.inspect.base.BaseApplication + +object SaveKeyValues { + private var sharedPreferences: SharedPreferences? = null + private var editor: SharedPreferences.Editor? = null + private var fileName: String? = null + + fun initSharedPreferences() { + val packageName = BaseApplication.instance.packageName + //获取到的包名带有“.”方便命名,取最后一个作为sp文件名,例如:com.casic.birmm.inspect + val split = packageName.split(".") + fileName = split[split.size - 1] + } + + /** + * 存储 + */ + fun putValue(key: String?, obj: Any) { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + val editor = sharedPreferences!!.edit() + when (obj) { + is String -> { + editor.putString(key, obj).apply() + } + is Int -> { + editor.putInt(key, obj).apply() + } + is Boolean -> { + editor.putBoolean(key, obj).apply() + } + is Float -> { + editor.putFloat(key, obj).apply() + } + is Long -> { + editor.putLong(key, obj).apply() + } + else -> { + editor.putString(key, obj.toString()).apply() + } + } + } + + /** + * 获取保存的数据 + */ + operator fun getValue(key: String?, defaultObject: Any?): Any? { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + return when (defaultObject) { + is String -> { + sharedPreferences!!.getString(key, defaultObject as String?) + } + is Int -> { + sharedPreferences!!.getInt(key, (defaultObject as Int?)!!) + } + is Boolean -> { + sharedPreferences!!.getBoolean(key, (defaultObject as Boolean?)!!) + } + is Float -> { + sharedPreferences!!.getFloat(key, (defaultObject as Float?)!!) + } + is Long -> { + sharedPreferences!!.getLong(key, (defaultObject as Long?)!!) + } + else -> { + sharedPreferences!!.getString(key, null) + } + } + } + + /** + * 移除某个key值已经对应的值 + */ + fun removeKey(key: String?) { + editor!!.remove(key) + editor!!.commit() + } + + /** + * 清除所有数据 + */ + fun clearAll() { + editor!!.clear() + editor!!.commit() + } + + /** + * 查询某个key是否存在 + */ + fun containsKey(key: String?): Boolean { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + return sharedPreferences!!.contains(key) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt b/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt new file mode 100644 index 0000000..04db86b --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt @@ -0,0 +1,119 @@ +package com.casic.birmm.inspect.widgets + +import android.app.Dialog +import android.content.Context +import android.graphics.Color +import android.graphics.drawable.ColorDrawable +import android.os.Bundle +import android.view.WindowManager +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.utils.OtherUtils +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.dialog_input.* + + +class InputDialog private constructor(builder: Builder) : Dialog(builder.mContext!!) { + + private var ctx: Context? = null + private var title: String? = null + private var value: String? = null + private var positiveBtn: String? = null + private var negativeBtn: String? = null + private var listener: OnDialogButtonClickListener? = null + + init { + this.ctx = builder.mContext + this.title = builder.title + this.value = builder.value + this.positiveBtn = builder.positiveBtn + this.negativeBtn = builder.negativeBtn + this.listener = builder.listener + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + configDialogLayout() + setContentView(R.layout.dialog_input) + setCancelable(false) + setCanceledOnTouchOutside(false) + + dialogTitleView.text = title + value.apply { + dialogInputView.setText(this) + } + + dialogCancelButton.text = negativeBtn + dialogCancelButton.setChangeAlphaWhenPress(true) + dialogCancelButton.setOnClickListener { + this.dismiss() + } + + dialogConfirmButton.text = positiveBtn + dialogConfirmButton.setChangeAlphaWhenPress(true) + dialogConfirmButton.setOnClickListener { + val inputValue = dialogInputView.text.toString().trim() + if (inputValue.isEmpty()) { + OtherUtils.showTipsDialog(ctx!!, "什么都没输入,请重新输入", dialogConfirmButton) + return@setOnClickListener + } + listener?.onButtonClick(inputValue) + this.dismiss() + } + } + + private fun configDialogLayout() { + window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT)) + window?.decorView?.setBackgroundColor(Color.TRANSPARENT) + val params: WindowManager.LayoutParams? = window?.attributes + params?.width = QMUIDisplayHelper.dp2px(ctx, 300) + params?.height = WindowManager.LayoutParams.WRAP_CONTENT + window?.attributes = params + } + + class Builder { + var mContext: Context? = null + var title: String? = null + var value: String? = null + var positiveBtn: String? = null + var negativeBtn: String? = null + var listener: OnDialogButtonClickListener? = null + + fun setContext(context: Context?): Builder { + mContext = context + return this + } + + fun setTitle(title: String?): Builder { + this.title = title + return this + } + + fun setDefaultValue(value: String?): Builder { + this.value = value + return this + } + + fun setPositiveButton(name: String?): Builder { + positiveBtn = name + return this + } + + fun setNegativeButton(name: String?): Builder { + negativeBtn = name + return this + } + + fun setOnDialogClickListener(listener: OnDialogButtonClickListener): Builder { + this.listener = listener + return this + } + + fun build(): InputDialog { + return InputDialog(this) + } + } + + interface OnDialogButtonClickListener { + fun onButtonClick(input: String) + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_dialog_button.xml b/app/src/main/res/drawable/bg_dialog_button.xml new file mode 100644 index 0000000..5f7d57d --- /dev/null +++ b/app/src/main/res/drawable/bg_dialog_button.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_layout_white.xml b/app/src/main/res/drawable/bg_layout_white.xml new file mode 100644 index 0000000..19b473b --- /dev/null +++ b/app/src/main/res/drawable/bg_layout_white.xml @@ -0,0 +1,11 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/guide1.png b/app/src/main/res/drawable/guide1.png new file mode 100644 index 0000000..074c768 --- /dev/null +++ b/app/src/main/res/drawable/guide1.png Binary files differ diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_lock.xml b/app/src/main/res/drawable/ic_lock.xml new file mode 100644 index 0000000..f0a5610 --- /dev/null +++ b/app/src/main/res/drawable/ic_lock.xml @@ -0,0 +1,12 @@ + + + + diff --git a/app/src/main/res/drawable/ic_login_bg.png b/app/src/main/res/drawable/ic_login_bg.png new file mode 100644 index 0000000..64789c3 --- /dev/null +++ b/app/src/main/res/drawable/ic_login_bg.png Binary files differ diff --git a/app/src/main/res/drawable/ic_user.xml b/app/src/main/res/drawable/ic_user.xml new file mode 100644 index 0000000..8c4a29d --- /dev/null +++ b/app/src/main/res/drawable/ic_user.xml @@ -0,0 +1,15 @@ + + + + + diff --git a/app/src/main/res/layout/activity_guide.xml b/app/src/main/res/layout/activity_guide.xml new file mode 100644 index 0000000..e197626 --- /dev/null +++ b/app/src/main/res/layout/activity_guide.xml @@ -0,0 +1,19 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_login.xml b/app/src/main/res/layout/activity_login.xml new file mode 100644 index 0000000..bcae777 --- /dev/null +++ b/app/src/main/res/layout/activity_login.xml @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..def59e4 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,18 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_input.xml b/app/src/main/res/layout/dialog_input.xml new file mode 100644 index 0000000..f5a8bc6 --- /dev/null +++ b/app/src/main/res/layout/dialog_input.xml @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..603b140 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..88ea3aa --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,122 @@ + + + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+ + +
+
\ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..5cd135a --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..7bfef59 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..4ca4a9f --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,67 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' + +android { + compileSdkVersion 30 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.birmm.inspect" + minSdkVersion 21 + targetSdkVersion 30 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'androidx.core:core-ktx:1.3.2' + implementation 'androidx.constraintlayout:constraintlayout:2.0.4' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test.ext:junit:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:1.3.0' + //腾讯Android UI框架 + implementation 'com.qmuiteam:qmui:2.0.0-alpha10' + implementation 'com.qmuiteam:arch:0.3.1' + //沉浸式状态栏。基础依赖包,必须要依赖 + implementation 'com.gyf.immersionbar:immersionbar:3.0.0' + //fragment快速实现 + implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + + //MVP网络请求框架retrofit2+rxjava + implementation 'io.reactivex:rxjava:1.3.8' + implementation 'io.reactivex:rxandroid:1.2.1' + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.6.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + implementation 'com.squareup.retrofit2:adapter-rxjava:2.8.1' + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.8.6' + //Toast提示 + implementation 'com.sdsmdg.tastytoast:tastytoast:0.1.1' + //图片选择框架 + implementation 'com.github.LuckSiege.PictureSelector:picture_library:v2.6.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..ea03309 --- /dev/null +++ b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.casic.birmm.inspect + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.casic.birmm.inspect", appContext.packageName) + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..7096527 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt new file mode 100644 index 0000000..aefdbb6 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt @@ -0,0 +1,36 @@ +package com.casic.birmm.inspect.base + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.qmuiteam.qmui.util.QMUIStatusBarHelper + +abstract class BaseActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(initLayoutView()) + QMUIStatusBarHelper.translucent(this) //沉浸式状态栏 + setupTopBarLayout() + initData() + initEvent() + } + + /** + * 初始化xml布局 + */ + abstract fun initLayoutView(): Int + + /** + * 特定页面定制沉浸式状态栏 + */ + protected abstract fun setupTopBarLayout() + + /** + * 初始化默认数据 + */ + abstract fun initData() + + /** + * 初始化业务逻辑 + */ + abstract fun initEvent() +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt new file mode 100644 index 0000000..fc0ca75 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt @@ -0,0 +1,18 @@ +package com.casic.birmm.inspect.base + +import android.app.Application +import com.casic.birmm.inspect.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + companion object { + var instance: BaseApplication by Delegates.notNull() + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt new file mode 100644 index 0000000..ddc160a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt @@ -0,0 +1,56 @@ +package com.casic.birmm.inspect.ui + +import android.annotation.SuppressLint +import android.content.Intent +import android.os.CountDownTimer +import android.view.ViewGroup.MarginLayoutParams +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.activity_guide.* + +@SuppressLint("SetTextI18n") +class GuideActivity : BaseActivity() { + + private lateinit var countDownTimer: CountDownTimer + + override fun initLayoutView(): Int = R.layout.activity_guide + + override fun setupTopBarLayout() { + + } + + override fun initData() { + //根据不同设备状态栏高度设置"跳过"按钮的Margin值 + val statusBarHeight = QMUIDisplayHelper.getStatusBarHeight(this) + val rightMargin = QMUIDisplayHelper.dp2px(this, 10) + if (skipButton.layoutParams is MarginLayoutParams) { + val params = skipButton.layoutParams as MarginLayoutParams + params.setMargins(skipButton.width, statusBarHeight, rightMargin, 0) + skipButton.requestLayout() + } + + countDownTimer = object : CountDownTimer(4000, 1000) { + override fun onFinish() { + startLoginActivity() + } + + override fun onTick(millisUntilFinished: Long) { + skipButton.text = "跳过\u3000${(millisUntilFinished / 1000)}s" + } + } + } + + override fun initEvent() { + countDownTimer.start() + skipButton.setOnClickListener { + countDownTimer.cancel() + startLoginActivity() + } + } + + fun startLoginActivity() { + startActivity(Intent(this, LoginActivity::class.java)) + finish() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt new file mode 100644 index 0000000..6ef4548 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt @@ -0,0 +1,81 @@ +package com.casic.birmm.inspect.ui + +import android.text.Editable +import android.text.TextWatcher +import android.view.KeyEvent +import android.view.inputmethod.EditorInfo +import android.widget.EditText +import android.widget.TextView +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.casic.birmm.inspect.utils.Constant +import com.casic.birmm.inspect.utils.SaveKeyValues +import com.casic.birmm.inspect.widgets.InputDialog +import kotlinx.android.synthetic.main.activity_login.* + + +class LoginActivity : BaseActivity() { + + companion object { + private const val Tag = "LoginActivity" + } + + override fun initLayoutView(): Int = R.layout.activity_login + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + loginButton.setChangeAlphaWhenPress(true) + val editText: EditText? = inputLayout.editText + editText?.addTextChangedListener(object : TextWatcher { + override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) { + + } + + override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) { + + } + + override fun afterTextChanged(s: Editable) { + if (s.toString().trim { it <= ' ' }.length > 12) { + inputLayout.error = "密码长度超出限制" + } else { + inputLayout.error = null + } + } + }) + //点击输入法键盘"完成" + editText?.setOnEditorActionListener { _: TextView?, actionId: Int, _: KeyEvent? -> + if (actionId == EditorInfo.IME_ACTION_DONE) { +// authenticatePresenter.onReadyRetrofitRequest() + return@setOnEditorActionListener true + } + false + } + + //修改服务器配置 + changeServerConfigView.setOnClickListener { + val defaultValue = SaveKeyValues.getValue( + Constant.DEFAULT_SERVER_CONFIG, + "http://139.198.6.177:8093/" + ) as String + InputDialog.Builder().setContext(this) + .setTitle("请输入后台服务器地址") + .setDefaultValue(defaultValue) + .setNegativeButton("取消") + .setPositiveButton("保存") + .setOnDialogClickListener(object : InputDialog.OnDialogButtonClickListener { + override fun onButtonClick(input: String) { + SaveKeyValues.putValue(Constant.DEFAULT_SERVER_CONFIG, input) + } + }) + .build().show() + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt new file mode 100644 index 0000000..0e97af7 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt @@ -0,0 +1,21 @@ +package com.casic.birmm.inspect.ui + +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity + +class MainActivity : BaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt new file mode 100644 index 0000000..21fbba2 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt @@ -0,0 +1,58 @@ +package com.casic.birmm.inspect.ui + +import android.content.Intent +import android.os.Build +import android.os.Bundle +import android.util.Log +import androidx.appcompat.app.AppCompatActivity +import com.casic.birmm.inspect.utils.Constant +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + companion object { + private const val TAG = "PermissionActivity" + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + if (EasyPermissions.hasPermissions(this, *Constant.USER_PERMISSIONS)) { + startGuideActivity() + } else { + EasyPermissions.requestPermissions( + this, + "需要获取相关权限", + Constant.PERMISSIONS_CODE, + *Constant.USER_PERMISSIONS + ) + } + } else { + startGuideActivity() + } + } + + private fun startGuideActivity() { + startActivity(Intent(this, GuideActivity::class.java)) + finish() + } + + override fun onRequestPermissionsResult( + requestCode: Int, + permissions: Array, + grantResults: IntArray + ) { + super.onRequestPermissionsResult(requestCode, permissions, grantResults) + EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this) + } + + override fun onPermissionsGranted(requestCode: Int, perms: List) { + startGuideActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + Log.e(TAG, "onPermissionsDenied: $perms") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt new file mode 100644 index 0000000..53df6e1 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt @@ -0,0 +1,15 @@ +package com.casic.birmm.inspect.utils + +import android.Manifest + + +object Constant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.ACCESS_LOCATION_EXTRA_COMMANDS, + Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION + ) + + const val PERMISSIONS_CODE = 999 + + const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt new file mode 100644 index 0000000..4c38241 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt @@ -0,0 +1,19 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.view.View +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object OtherUtils { + + //替换Toast + fun showTipsDialog(context: Context, message: String, view: View) { + val tipDialog = QMUITipDialog.Builder(context) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_NOTHING) + .setTipWord(message).create() + tipDialog.show() + view.postDelayed({ + tipDialog.dismiss() + }, 2000) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt b/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt new file mode 100644 index 0000000..04c9f5a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt @@ -0,0 +1,106 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.content.SharedPreferences +import com.casic.birmm.inspect.base.BaseApplication + +object SaveKeyValues { + private var sharedPreferences: SharedPreferences? = null + private var editor: SharedPreferences.Editor? = null + private var fileName: String? = null + + fun initSharedPreferences() { + val packageName = BaseApplication.instance.packageName + //获取到的包名带有“.”方便命名,取最后一个作为sp文件名,例如:com.casic.birmm.inspect + val split = packageName.split(".") + fileName = split[split.size - 1] + } + + /** + * 存储 + */ + fun putValue(key: String?, obj: Any) { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + val editor = sharedPreferences!!.edit() + when (obj) { + is String -> { + editor.putString(key, obj).apply() + } + is Int -> { + editor.putInt(key, obj).apply() + } + is Boolean -> { + editor.putBoolean(key, obj).apply() + } + is Float -> { + editor.putFloat(key, obj).apply() + } + is Long -> { + editor.putLong(key, obj).apply() + } + else -> { + editor.putString(key, obj.toString()).apply() + } + } + } + + /** + * 获取保存的数据 + */ + operator fun getValue(key: String?, defaultObject: Any?): Any? { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + return when (defaultObject) { + is String -> { + sharedPreferences!!.getString(key, defaultObject as String?) + } + is Int -> { + sharedPreferences!!.getInt(key, (defaultObject as Int?)!!) + } + is Boolean -> { + sharedPreferences!!.getBoolean(key, (defaultObject as Boolean?)!!) + } + is Float -> { + sharedPreferences!!.getFloat(key, (defaultObject as Float?)!!) + } + is Long -> { + sharedPreferences!!.getLong(key, (defaultObject as Long?)!!) + } + else -> { + sharedPreferences!!.getString(key, null) + } + } + } + + /** + * 移除某个key值已经对应的值 + */ + fun removeKey(key: String?) { + editor!!.remove(key) + editor!!.commit() + } + + /** + * 清除所有数据 + */ + fun clearAll() { + editor!!.clear() + editor!!.commit() + } + + /** + * 查询某个key是否存在 + */ + fun containsKey(key: String?): Boolean { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + return sharedPreferences!!.contains(key) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt b/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt new file mode 100644 index 0000000..04db86b --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt @@ -0,0 +1,119 @@ +package com.casic.birmm.inspect.widgets + +import android.app.Dialog +import android.content.Context +import android.graphics.Color +import android.graphics.drawable.ColorDrawable +import android.os.Bundle +import android.view.WindowManager +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.utils.OtherUtils +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.dialog_input.* + + +class InputDialog private constructor(builder: Builder) : Dialog(builder.mContext!!) { + + private var ctx: Context? = null + private var title: String? = null + private var value: String? = null + private var positiveBtn: String? = null + private var negativeBtn: String? = null + private var listener: OnDialogButtonClickListener? = null + + init { + this.ctx = builder.mContext + this.title = builder.title + this.value = builder.value + this.positiveBtn = builder.positiveBtn + this.negativeBtn = builder.negativeBtn + this.listener = builder.listener + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + configDialogLayout() + setContentView(R.layout.dialog_input) + setCancelable(false) + setCanceledOnTouchOutside(false) + + dialogTitleView.text = title + value.apply { + dialogInputView.setText(this) + } + + dialogCancelButton.text = negativeBtn + dialogCancelButton.setChangeAlphaWhenPress(true) + dialogCancelButton.setOnClickListener { + this.dismiss() + } + + dialogConfirmButton.text = positiveBtn + dialogConfirmButton.setChangeAlphaWhenPress(true) + dialogConfirmButton.setOnClickListener { + val inputValue = dialogInputView.text.toString().trim() + if (inputValue.isEmpty()) { + OtherUtils.showTipsDialog(ctx!!, "什么都没输入,请重新输入", dialogConfirmButton) + return@setOnClickListener + } + listener?.onButtonClick(inputValue) + this.dismiss() + } + } + + private fun configDialogLayout() { + window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT)) + window?.decorView?.setBackgroundColor(Color.TRANSPARENT) + val params: WindowManager.LayoutParams? = window?.attributes + params?.width = QMUIDisplayHelper.dp2px(ctx, 300) + params?.height = WindowManager.LayoutParams.WRAP_CONTENT + window?.attributes = params + } + + class Builder { + var mContext: Context? = null + var title: String? = null + var value: String? = null + var positiveBtn: String? = null + var negativeBtn: String? = null + var listener: OnDialogButtonClickListener? = null + + fun setContext(context: Context?): Builder { + mContext = context + return this + } + + fun setTitle(title: String?): Builder { + this.title = title + return this + } + + fun setDefaultValue(value: String?): Builder { + this.value = value + return this + } + + fun setPositiveButton(name: String?): Builder { + positiveBtn = name + return this + } + + fun setNegativeButton(name: String?): Builder { + negativeBtn = name + return this + } + + fun setOnDialogClickListener(listener: OnDialogButtonClickListener): Builder { + this.listener = listener + return this + } + + fun build(): InputDialog { + return InputDialog(this) + } + } + + interface OnDialogButtonClickListener { + fun onButtonClick(input: String) + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_dialog_button.xml b/app/src/main/res/drawable/bg_dialog_button.xml new file mode 100644 index 0000000..5f7d57d --- /dev/null +++ b/app/src/main/res/drawable/bg_dialog_button.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_layout_white.xml b/app/src/main/res/drawable/bg_layout_white.xml new file mode 100644 index 0000000..19b473b --- /dev/null +++ b/app/src/main/res/drawable/bg_layout_white.xml @@ -0,0 +1,11 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/guide1.png b/app/src/main/res/drawable/guide1.png new file mode 100644 index 0000000..074c768 --- /dev/null +++ b/app/src/main/res/drawable/guide1.png Binary files differ diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_lock.xml b/app/src/main/res/drawable/ic_lock.xml new file mode 100644 index 0000000..f0a5610 --- /dev/null +++ b/app/src/main/res/drawable/ic_lock.xml @@ -0,0 +1,12 @@ + + + + diff --git a/app/src/main/res/drawable/ic_login_bg.png b/app/src/main/res/drawable/ic_login_bg.png new file mode 100644 index 0000000..64789c3 --- /dev/null +++ b/app/src/main/res/drawable/ic_login_bg.png Binary files differ diff --git a/app/src/main/res/drawable/ic_user.xml b/app/src/main/res/drawable/ic_user.xml new file mode 100644 index 0000000..8c4a29d --- /dev/null +++ b/app/src/main/res/drawable/ic_user.xml @@ -0,0 +1,15 @@ + + + + + diff --git a/app/src/main/res/layout/activity_guide.xml b/app/src/main/res/layout/activity_guide.xml new file mode 100644 index 0000000..e197626 --- /dev/null +++ b/app/src/main/res/layout/activity_guide.xml @@ -0,0 +1,19 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_login.xml b/app/src/main/res/layout/activity_login.xml new file mode 100644 index 0000000..bcae777 --- /dev/null +++ b/app/src/main/res/layout/activity_login.xml @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..def59e4 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,18 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_input.xml b/app/src/main/res/layout/dialog_input.xml new file mode 100644 index 0000000..f5a8bc6 --- /dev/null +++ b/app/src/main/res/layout/dialog_input.xml @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..a571e60 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher.png Binary files differ diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..603b140 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..88ea3aa --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,122 @@ + + + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+ + +
+
\ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..5cd135a --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..7bfef59 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..4ca4a9f --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,67 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' + +android { + compileSdkVersion 30 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.birmm.inspect" + minSdkVersion 21 + targetSdkVersion 30 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'androidx.core:core-ktx:1.3.2' + implementation 'androidx.constraintlayout:constraintlayout:2.0.4' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test.ext:junit:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:1.3.0' + //腾讯Android UI框架 + implementation 'com.qmuiteam:qmui:2.0.0-alpha10' + implementation 'com.qmuiteam:arch:0.3.1' + //沉浸式状态栏。基础依赖包,必须要依赖 + implementation 'com.gyf.immersionbar:immersionbar:3.0.0' + //fragment快速实现 + implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + + //MVP网络请求框架retrofit2+rxjava + implementation 'io.reactivex:rxjava:1.3.8' + implementation 'io.reactivex:rxandroid:1.2.1' + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.6.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + implementation 'com.squareup.retrofit2:adapter-rxjava:2.8.1' + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.8.6' + //Toast提示 + implementation 'com.sdsmdg.tastytoast:tastytoast:0.1.1' + //图片选择框架 + implementation 'com.github.LuckSiege.PictureSelector:picture_library:v2.6.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..ea03309 --- /dev/null +++ b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.casic.birmm.inspect + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.casic.birmm.inspect", appContext.packageName) + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..7096527 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt new file mode 100644 index 0000000..aefdbb6 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt @@ -0,0 +1,36 @@ +package com.casic.birmm.inspect.base + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.qmuiteam.qmui.util.QMUIStatusBarHelper + +abstract class BaseActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(initLayoutView()) + QMUIStatusBarHelper.translucent(this) //沉浸式状态栏 + setupTopBarLayout() + initData() + initEvent() + } + + /** + * 初始化xml布局 + */ + abstract fun initLayoutView(): Int + + /** + * 特定页面定制沉浸式状态栏 + */ + protected abstract fun setupTopBarLayout() + + /** + * 初始化默认数据 + */ + abstract fun initData() + + /** + * 初始化业务逻辑 + */ + abstract fun initEvent() +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt new file mode 100644 index 0000000..fc0ca75 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt @@ -0,0 +1,18 @@ +package com.casic.birmm.inspect.base + +import android.app.Application +import com.casic.birmm.inspect.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + companion object { + var instance: BaseApplication by Delegates.notNull() + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt new file mode 100644 index 0000000..ddc160a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt @@ -0,0 +1,56 @@ +package com.casic.birmm.inspect.ui + +import android.annotation.SuppressLint +import android.content.Intent +import android.os.CountDownTimer +import android.view.ViewGroup.MarginLayoutParams +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.activity_guide.* + +@SuppressLint("SetTextI18n") +class GuideActivity : BaseActivity() { + + private lateinit var countDownTimer: CountDownTimer + + override fun initLayoutView(): Int = R.layout.activity_guide + + override fun setupTopBarLayout() { + + } + + override fun initData() { + //根据不同设备状态栏高度设置"跳过"按钮的Margin值 + val statusBarHeight = QMUIDisplayHelper.getStatusBarHeight(this) + val rightMargin = QMUIDisplayHelper.dp2px(this, 10) + if (skipButton.layoutParams is MarginLayoutParams) { + val params = skipButton.layoutParams as MarginLayoutParams + params.setMargins(skipButton.width, statusBarHeight, rightMargin, 0) + skipButton.requestLayout() + } + + countDownTimer = object : CountDownTimer(4000, 1000) { + override fun onFinish() { + startLoginActivity() + } + + override fun onTick(millisUntilFinished: Long) { + skipButton.text = "跳过\u3000${(millisUntilFinished / 1000)}s" + } + } + } + + override fun initEvent() { + countDownTimer.start() + skipButton.setOnClickListener { + countDownTimer.cancel() + startLoginActivity() + } + } + + fun startLoginActivity() { + startActivity(Intent(this, LoginActivity::class.java)) + finish() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt new file mode 100644 index 0000000..6ef4548 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt @@ -0,0 +1,81 @@ +package com.casic.birmm.inspect.ui + +import android.text.Editable +import android.text.TextWatcher +import android.view.KeyEvent +import android.view.inputmethod.EditorInfo +import android.widget.EditText +import android.widget.TextView +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.casic.birmm.inspect.utils.Constant +import com.casic.birmm.inspect.utils.SaveKeyValues +import com.casic.birmm.inspect.widgets.InputDialog +import kotlinx.android.synthetic.main.activity_login.* + + +class LoginActivity : BaseActivity() { + + companion object { + private const val Tag = "LoginActivity" + } + + override fun initLayoutView(): Int = R.layout.activity_login + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + loginButton.setChangeAlphaWhenPress(true) + val editText: EditText? = inputLayout.editText + editText?.addTextChangedListener(object : TextWatcher { + override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) { + + } + + override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) { + + } + + override fun afterTextChanged(s: Editable) { + if (s.toString().trim { it <= ' ' }.length > 12) { + inputLayout.error = "密码长度超出限制" + } else { + inputLayout.error = null + } + } + }) + //点击输入法键盘"完成" + editText?.setOnEditorActionListener { _: TextView?, actionId: Int, _: KeyEvent? -> + if (actionId == EditorInfo.IME_ACTION_DONE) { +// authenticatePresenter.onReadyRetrofitRequest() + return@setOnEditorActionListener true + } + false + } + + //修改服务器配置 + changeServerConfigView.setOnClickListener { + val defaultValue = SaveKeyValues.getValue( + Constant.DEFAULT_SERVER_CONFIG, + "http://139.198.6.177:8093/" + ) as String + InputDialog.Builder().setContext(this) + .setTitle("请输入后台服务器地址") + .setDefaultValue(defaultValue) + .setNegativeButton("取消") + .setPositiveButton("保存") + .setOnDialogClickListener(object : InputDialog.OnDialogButtonClickListener { + override fun onButtonClick(input: String) { + SaveKeyValues.putValue(Constant.DEFAULT_SERVER_CONFIG, input) + } + }) + .build().show() + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt new file mode 100644 index 0000000..0e97af7 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt @@ -0,0 +1,21 @@ +package com.casic.birmm.inspect.ui + +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity + +class MainActivity : BaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt new file mode 100644 index 0000000..21fbba2 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt @@ -0,0 +1,58 @@ +package com.casic.birmm.inspect.ui + +import android.content.Intent +import android.os.Build +import android.os.Bundle +import android.util.Log +import androidx.appcompat.app.AppCompatActivity +import com.casic.birmm.inspect.utils.Constant +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + companion object { + private const val TAG = "PermissionActivity" + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + if (EasyPermissions.hasPermissions(this, *Constant.USER_PERMISSIONS)) { + startGuideActivity() + } else { + EasyPermissions.requestPermissions( + this, + "需要获取相关权限", + Constant.PERMISSIONS_CODE, + *Constant.USER_PERMISSIONS + ) + } + } else { + startGuideActivity() + } + } + + private fun startGuideActivity() { + startActivity(Intent(this, GuideActivity::class.java)) + finish() + } + + override fun onRequestPermissionsResult( + requestCode: Int, + permissions: Array, + grantResults: IntArray + ) { + super.onRequestPermissionsResult(requestCode, permissions, grantResults) + EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this) + } + + override fun onPermissionsGranted(requestCode: Int, perms: List) { + startGuideActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + Log.e(TAG, "onPermissionsDenied: $perms") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt new file mode 100644 index 0000000..53df6e1 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt @@ -0,0 +1,15 @@ +package com.casic.birmm.inspect.utils + +import android.Manifest + + +object Constant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.ACCESS_LOCATION_EXTRA_COMMANDS, + Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION + ) + + const val PERMISSIONS_CODE = 999 + + const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt new file mode 100644 index 0000000..4c38241 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt @@ -0,0 +1,19 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.view.View +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object OtherUtils { + + //替换Toast + fun showTipsDialog(context: Context, message: String, view: View) { + val tipDialog = QMUITipDialog.Builder(context) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_NOTHING) + .setTipWord(message).create() + tipDialog.show() + view.postDelayed({ + tipDialog.dismiss() + }, 2000) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt b/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt new file mode 100644 index 0000000..04c9f5a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt @@ -0,0 +1,106 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.content.SharedPreferences +import com.casic.birmm.inspect.base.BaseApplication + +object SaveKeyValues { + private var sharedPreferences: SharedPreferences? = null + private var editor: SharedPreferences.Editor? = null + private var fileName: String? = null + + fun initSharedPreferences() { + val packageName = BaseApplication.instance.packageName + //获取到的包名带有“.”方便命名,取最后一个作为sp文件名,例如:com.casic.birmm.inspect + val split = packageName.split(".") + fileName = split[split.size - 1] + } + + /** + * 存储 + */ + fun putValue(key: String?, obj: Any) { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + val editor = sharedPreferences!!.edit() + when (obj) { + is String -> { + editor.putString(key, obj).apply() + } + is Int -> { + editor.putInt(key, obj).apply() + } + is Boolean -> { + editor.putBoolean(key, obj).apply() + } + is Float -> { + editor.putFloat(key, obj).apply() + } + is Long -> { + editor.putLong(key, obj).apply() + } + else -> { + editor.putString(key, obj.toString()).apply() + } + } + } + + /** + * 获取保存的数据 + */ + operator fun getValue(key: String?, defaultObject: Any?): Any? { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + return when (defaultObject) { + is String -> { + sharedPreferences!!.getString(key, defaultObject as String?) + } + is Int -> { + sharedPreferences!!.getInt(key, (defaultObject as Int?)!!) + } + is Boolean -> { + sharedPreferences!!.getBoolean(key, (defaultObject as Boolean?)!!) + } + is Float -> { + sharedPreferences!!.getFloat(key, (defaultObject as Float?)!!) + } + is Long -> { + sharedPreferences!!.getLong(key, (defaultObject as Long?)!!) + } + else -> { + sharedPreferences!!.getString(key, null) + } + } + } + + /** + * 移除某个key值已经对应的值 + */ + fun removeKey(key: String?) { + editor!!.remove(key) + editor!!.commit() + } + + /** + * 清除所有数据 + */ + fun clearAll() { + editor!!.clear() + editor!!.commit() + } + + /** + * 查询某个key是否存在 + */ + fun containsKey(key: String?): Boolean { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + return sharedPreferences!!.contains(key) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt b/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt new file mode 100644 index 0000000..04db86b --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt @@ -0,0 +1,119 @@ +package com.casic.birmm.inspect.widgets + +import android.app.Dialog +import android.content.Context +import android.graphics.Color +import android.graphics.drawable.ColorDrawable +import android.os.Bundle +import android.view.WindowManager +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.utils.OtherUtils +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.dialog_input.* + + +class InputDialog private constructor(builder: Builder) : Dialog(builder.mContext!!) { + + private var ctx: Context? = null + private var title: String? = null + private var value: String? = null + private var positiveBtn: String? = null + private var negativeBtn: String? = null + private var listener: OnDialogButtonClickListener? = null + + init { + this.ctx = builder.mContext + this.title = builder.title + this.value = builder.value + this.positiveBtn = builder.positiveBtn + this.negativeBtn = builder.negativeBtn + this.listener = builder.listener + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + configDialogLayout() + setContentView(R.layout.dialog_input) + setCancelable(false) + setCanceledOnTouchOutside(false) + + dialogTitleView.text = title + value.apply { + dialogInputView.setText(this) + } + + dialogCancelButton.text = negativeBtn + dialogCancelButton.setChangeAlphaWhenPress(true) + dialogCancelButton.setOnClickListener { + this.dismiss() + } + + dialogConfirmButton.text = positiveBtn + dialogConfirmButton.setChangeAlphaWhenPress(true) + dialogConfirmButton.setOnClickListener { + val inputValue = dialogInputView.text.toString().trim() + if (inputValue.isEmpty()) { + OtherUtils.showTipsDialog(ctx!!, "什么都没输入,请重新输入", dialogConfirmButton) + return@setOnClickListener + } + listener?.onButtonClick(inputValue) + this.dismiss() + } + } + + private fun configDialogLayout() { + window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT)) + window?.decorView?.setBackgroundColor(Color.TRANSPARENT) + val params: WindowManager.LayoutParams? = window?.attributes + params?.width = QMUIDisplayHelper.dp2px(ctx, 300) + params?.height = WindowManager.LayoutParams.WRAP_CONTENT + window?.attributes = params + } + + class Builder { + var mContext: Context? = null + var title: String? = null + var value: String? = null + var positiveBtn: String? = null + var negativeBtn: String? = null + var listener: OnDialogButtonClickListener? = null + + fun setContext(context: Context?): Builder { + mContext = context + return this + } + + fun setTitle(title: String?): Builder { + this.title = title + return this + } + + fun setDefaultValue(value: String?): Builder { + this.value = value + return this + } + + fun setPositiveButton(name: String?): Builder { + positiveBtn = name + return this + } + + fun setNegativeButton(name: String?): Builder { + negativeBtn = name + return this + } + + fun setOnDialogClickListener(listener: OnDialogButtonClickListener): Builder { + this.listener = listener + return this + } + + fun build(): InputDialog { + return InputDialog(this) + } + } + + interface OnDialogButtonClickListener { + fun onButtonClick(input: String) + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_dialog_button.xml b/app/src/main/res/drawable/bg_dialog_button.xml new file mode 100644 index 0000000..5f7d57d --- /dev/null +++ b/app/src/main/res/drawable/bg_dialog_button.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_layout_white.xml b/app/src/main/res/drawable/bg_layout_white.xml new file mode 100644 index 0000000..19b473b --- /dev/null +++ b/app/src/main/res/drawable/bg_layout_white.xml @@ -0,0 +1,11 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/guide1.png b/app/src/main/res/drawable/guide1.png new file mode 100644 index 0000000..074c768 --- /dev/null +++ b/app/src/main/res/drawable/guide1.png Binary files differ diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_lock.xml b/app/src/main/res/drawable/ic_lock.xml new file mode 100644 index 0000000..f0a5610 --- /dev/null +++ b/app/src/main/res/drawable/ic_lock.xml @@ -0,0 +1,12 @@ + + + + diff --git a/app/src/main/res/drawable/ic_login_bg.png b/app/src/main/res/drawable/ic_login_bg.png new file mode 100644 index 0000000..64789c3 --- /dev/null +++ b/app/src/main/res/drawable/ic_login_bg.png Binary files differ diff --git a/app/src/main/res/drawable/ic_user.xml b/app/src/main/res/drawable/ic_user.xml new file mode 100644 index 0000000..8c4a29d --- /dev/null +++ b/app/src/main/res/drawable/ic_user.xml @@ -0,0 +1,15 @@ + + + + + diff --git a/app/src/main/res/layout/activity_guide.xml b/app/src/main/res/layout/activity_guide.xml new file mode 100644 index 0000000..e197626 --- /dev/null +++ b/app/src/main/res/layout/activity_guide.xml @@ -0,0 +1,19 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_login.xml b/app/src/main/res/layout/activity_login.xml new file mode 100644 index 0000000..bcae777 --- /dev/null +++ b/app/src/main/res/layout/activity_login.xml @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..def59e4 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,18 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_input.xml b/app/src/main/res/layout/dialog_input.xml new file mode 100644 index 0000000..f5a8bc6 --- /dev/null +++ b/app/src/main/res/layout/dialog_input.xml @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..a571e60 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 0000000..61da551 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png Binary files differ diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..603b140 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..88ea3aa --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,122 @@ + + + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+ + +
+
\ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..5cd135a --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..7bfef59 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..4ca4a9f --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,67 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' + +android { + compileSdkVersion 30 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.birmm.inspect" + minSdkVersion 21 + targetSdkVersion 30 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'androidx.core:core-ktx:1.3.2' + implementation 'androidx.constraintlayout:constraintlayout:2.0.4' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test.ext:junit:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:1.3.0' + //腾讯Android UI框架 + implementation 'com.qmuiteam:qmui:2.0.0-alpha10' + implementation 'com.qmuiteam:arch:0.3.1' + //沉浸式状态栏。基础依赖包,必须要依赖 + implementation 'com.gyf.immersionbar:immersionbar:3.0.0' + //fragment快速实现 + implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + + //MVP网络请求框架retrofit2+rxjava + implementation 'io.reactivex:rxjava:1.3.8' + implementation 'io.reactivex:rxandroid:1.2.1' + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.6.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + implementation 'com.squareup.retrofit2:adapter-rxjava:2.8.1' + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.8.6' + //Toast提示 + implementation 'com.sdsmdg.tastytoast:tastytoast:0.1.1' + //图片选择框架 + implementation 'com.github.LuckSiege.PictureSelector:picture_library:v2.6.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..ea03309 --- /dev/null +++ b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.casic.birmm.inspect + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.casic.birmm.inspect", appContext.packageName) + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..7096527 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt new file mode 100644 index 0000000..aefdbb6 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt @@ -0,0 +1,36 @@ +package com.casic.birmm.inspect.base + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.qmuiteam.qmui.util.QMUIStatusBarHelper + +abstract class BaseActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(initLayoutView()) + QMUIStatusBarHelper.translucent(this) //沉浸式状态栏 + setupTopBarLayout() + initData() + initEvent() + } + + /** + * 初始化xml布局 + */ + abstract fun initLayoutView(): Int + + /** + * 特定页面定制沉浸式状态栏 + */ + protected abstract fun setupTopBarLayout() + + /** + * 初始化默认数据 + */ + abstract fun initData() + + /** + * 初始化业务逻辑 + */ + abstract fun initEvent() +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt new file mode 100644 index 0000000..fc0ca75 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt @@ -0,0 +1,18 @@ +package com.casic.birmm.inspect.base + +import android.app.Application +import com.casic.birmm.inspect.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + companion object { + var instance: BaseApplication by Delegates.notNull() + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt new file mode 100644 index 0000000..ddc160a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt @@ -0,0 +1,56 @@ +package com.casic.birmm.inspect.ui + +import android.annotation.SuppressLint +import android.content.Intent +import android.os.CountDownTimer +import android.view.ViewGroup.MarginLayoutParams +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.activity_guide.* + +@SuppressLint("SetTextI18n") +class GuideActivity : BaseActivity() { + + private lateinit var countDownTimer: CountDownTimer + + override fun initLayoutView(): Int = R.layout.activity_guide + + override fun setupTopBarLayout() { + + } + + override fun initData() { + //根据不同设备状态栏高度设置"跳过"按钮的Margin值 + val statusBarHeight = QMUIDisplayHelper.getStatusBarHeight(this) + val rightMargin = QMUIDisplayHelper.dp2px(this, 10) + if (skipButton.layoutParams is MarginLayoutParams) { + val params = skipButton.layoutParams as MarginLayoutParams + params.setMargins(skipButton.width, statusBarHeight, rightMargin, 0) + skipButton.requestLayout() + } + + countDownTimer = object : CountDownTimer(4000, 1000) { + override fun onFinish() { + startLoginActivity() + } + + override fun onTick(millisUntilFinished: Long) { + skipButton.text = "跳过\u3000${(millisUntilFinished / 1000)}s" + } + } + } + + override fun initEvent() { + countDownTimer.start() + skipButton.setOnClickListener { + countDownTimer.cancel() + startLoginActivity() + } + } + + fun startLoginActivity() { + startActivity(Intent(this, LoginActivity::class.java)) + finish() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt new file mode 100644 index 0000000..6ef4548 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt @@ -0,0 +1,81 @@ +package com.casic.birmm.inspect.ui + +import android.text.Editable +import android.text.TextWatcher +import android.view.KeyEvent +import android.view.inputmethod.EditorInfo +import android.widget.EditText +import android.widget.TextView +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.casic.birmm.inspect.utils.Constant +import com.casic.birmm.inspect.utils.SaveKeyValues +import com.casic.birmm.inspect.widgets.InputDialog +import kotlinx.android.synthetic.main.activity_login.* + + +class LoginActivity : BaseActivity() { + + companion object { + private const val Tag = "LoginActivity" + } + + override fun initLayoutView(): Int = R.layout.activity_login + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + loginButton.setChangeAlphaWhenPress(true) + val editText: EditText? = inputLayout.editText + editText?.addTextChangedListener(object : TextWatcher { + override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) { + + } + + override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) { + + } + + override fun afterTextChanged(s: Editable) { + if (s.toString().trim { it <= ' ' }.length > 12) { + inputLayout.error = "密码长度超出限制" + } else { + inputLayout.error = null + } + } + }) + //点击输入法键盘"完成" + editText?.setOnEditorActionListener { _: TextView?, actionId: Int, _: KeyEvent? -> + if (actionId == EditorInfo.IME_ACTION_DONE) { +// authenticatePresenter.onReadyRetrofitRequest() + return@setOnEditorActionListener true + } + false + } + + //修改服务器配置 + changeServerConfigView.setOnClickListener { + val defaultValue = SaveKeyValues.getValue( + Constant.DEFAULT_SERVER_CONFIG, + "http://139.198.6.177:8093/" + ) as String + InputDialog.Builder().setContext(this) + .setTitle("请输入后台服务器地址") + .setDefaultValue(defaultValue) + .setNegativeButton("取消") + .setPositiveButton("保存") + .setOnDialogClickListener(object : InputDialog.OnDialogButtonClickListener { + override fun onButtonClick(input: String) { + SaveKeyValues.putValue(Constant.DEFAULT_SERVER_CONFIG, input) + } + }) + .build().show() + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt new file mode 100644 index 0000000..0e97af7 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt @@ -0,0 +1,21 @@ +package com.casic.birmm.inspect.ui + +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity + +class MainActivity : BaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt new file mode 100644 index 0000000..21fbba2 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt @@ -0,0 +1,58 @@ +package com.casic.birmm.inspect.ui + +import android.content.Intent +import android.os.Build +import android.os.Bundle +import android.util.Log +import androidx.appcompat.app.AppCompatActivity +import com.casic.birmm.inspect.utils.Constant +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + companion object { + private const val TAG = "PermissionActivity" + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + if (EasyPermissions.hasPermissions(this, *Constant.USER_PERMISSIONS)) { + startGuideActivity() + } else { + EasyPermissions.requestPermissions( + this, + "需要获取相关权限", + Constant.PERMISSIONS_CODE, + *Constant.USER_PERMISSIONS + ) + } + } else { + startGuideActivity() + } + } + + private fun startGuideActivity() { + startActivity(Intent(this, GuideActivity::class.java)) + finish() + } + + override fun onRequestPermissionsResult( + requestCode: Int, + permissions: Array, + grantResults: IntArray + ) { + super.onRequestPermissionsResult(requestCode, permissions, grantResults) + EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this) + } + + override fun onPermissionsGranted(requestCode: Int, perms: List) { + startGuideActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + Log.e(TAG, "onPermissionsDenied: $perms") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt new file mode 100644 index 0000000..53df6e1 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt @@ -0,0 +1,15 @@ +package com.casic.birmm.inspect.utils + +import android.Manifest + + +object Constant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.ACCESS_LOCATION_EXTRA_COMMANDS, + Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION + ) + + const val PERMISSIONS_CODE = 999 + + const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt new file mode 100644 index 0000000..4c38241 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt @@ -0,0 +1,19 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.view.View +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object OtherUtils { + + //替换Toast + fun showTipsDialog(context: Context, message: String, view: View) { + val tipDialog = QMUITipDialog.Builder(context) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_NOTHING) + .setTipWord(message).create() + tipDialog.show() + view.postDelayed({ + tipDialog.dismiss() + }, 2000) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt b/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt new file mode 100644 index 0000000..04c9f5a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt @@ -0,0 +1,106 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.content.SharedPreferences +import com.casic.birmm.inspect.base.BaseApplication + +object SaveKeyValues { + private var sharedPreferences: SharedPreferences? = null + private var editor: SharedPreferences.Editor? = null + private var fileName: String? = null + + fun initSharedPreferences() { + val packageName = BaseApplication.instance.packageName + //获取到的包名带有“.”方便命名,取最后一个作为sp文件名,例如:com.casic.birmm.inspect + val split = packageName.split(".") + fileName = split[split.size - 1] + } + + /** + * 存储 + */ + fun putValue(key: String?, obj: Any) { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + val editor = sharedPreferences!!.edit() + when (obj) { + is String -> { + editor.putString(key, obj).apply() + } + is Int -> { + editor.putInt(key, obj).apply() + } + is Boolean -> { + editor.putBoolean(key, obj).apply() + } + is Float -> { + editor.putFloat(key, obj).apply() + } + is Long -> { + editor.putLong(key, obj).apply() + } + else -> { + editor.putString(key, obj.toString()).apply() + } + } + } + + /** + * 获取保存的数据 + */ + operator fun getValue(key: String?, defaultObject: Any?): Any? { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + return when (defaultObject) { + is String -> { + sharedPreferences!!.getString(key, defaultObject as String?) + } + is Int -> { + sharedPreferences!!.getInt(key, (defaultObject as Int?)!!) + } + is Boolean -> { + sharedPreferences!!.getBoolean(key, (defaultObject as Boolean?)!!) + } + is Float -> { + sharedPreferences!!.getFloat(key, (defaultObject as Float?)!!) + } + is Long -> { + sharedPreferences!!.getLong(key, (defaultObject as Long?)!!) + } + else -> { + sharedPreferences!!.getString(key, null) + } + } + } + + /** + * 移除某个key值已经对应的值 + */ + fun removeKey(key: String?) { + editor!!.remove(key) + editor!!.commit() + } + + /** + * 清除所有数据 + */ + fun clearAll() { + editor!!.clear() + editor!!.commit() + } + + /** + * 查询某个key是否存在 + */ + fun containsKey(key: String?): Boolean { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + return sharedPreferences!!.contains(key) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt b/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt new file mode 100644 index 0000000..04db86b --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt @@ -0,0 +1,119 @@ +package com.casic.birmm.inspect.widgets + +import android.app.Dialog +import android.content.Context +import android.graphics.Color +import android.graphics.drawable.ColorDrawable +import android.os.Bundle +import android.view.WindowManager +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.utils.OtherUtils +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.dialog_input.* + + +class InputDialog private constructor(builder: Builder) : Dialog(builder.mContext!!) { + + private var ctx: Context? = null + private var title: String? = null + private var value: String? = null + private var positiveBtn: String? = null + private var negativeBtn: String? = null + private var listener: OnDialogButtonClickListener? = null + + init { + this.ctx = builder.mContext + this.title = builder.title + this.value = builder.value + this.positiveBtn = builder.positiveBtn + this.negativeBtn = builder.negativeBtn + this.listener = builder.listener + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + configDialogLayout() + setContentView(R.layout.dialog_input) + setCancelable(false) + setCanceledOnTouchOutside(false) + + dialogTitleView.text = title + value.apply { + dialogInputView.setText(this) + } + + dialogCancelButton.text = negativeBtn + dialogCancelButton.setChangeAlphaWhenPress(true) + dialogCancelButton.setOnClickListener { + this.dismiss() + } + + dialogConfirmButton.text = positiveBtn + dialogConfirmButton.setChangeAlphaWhenPress(true) + dialogConfirmButton.setOnClickListener { + val inputValue = dialogInputView.text.toString().trim() + if (inputValue.isEmpty()) { + OtherUtils.showTipsDialog(ctx!!, "什么都没输入,请重新输入", dialogConfirmButton) + return@setOnClickListener + } + listener?.onButtonClick(inputValue) + this.dismiss() + } + } + + private fun configDialogLayout() { + window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT)) + window?.decorView?.setBackgroundColor(Color.TRANSPARENT) + val params: WindowManager.LayoutParams? = window?.attributes + params?.width = QMUIDisplayHelper.dp2px(ctx, 300) + params?.height = WindowManager.LayoutParams.WRAP_CONTENT + window?.attributes = params + } + + class Builder { + var mContext: Context? = null + var title: String? = null + var value: String? = null + var positiveBtn: String? = null + var negativeBtn: String? = null + var listener: OnDialogButtonClickListener? = null + + fun setContext(context: Context?): Builder { + mContext = context + return this + } + + fun setTitle(title: String?): Builder { + this.title = title + return this + } + + fun setDefaultValue(value: String?): Builder { + this.value = value + return this + } + + fun setPositiveButton(name: String?): Builder { + positiveBtn = name + return this + } + + fun setNegativeButton(name: String?): Builder { + negativeBtn = name + return this + } + + fun setOnDialogClickListener(listener: OnDialogButtonClickListener): Builder { + this.listener = listener + return this + } + + fun build(): InputDialog { + return InputDialog(this) + } + } + + interface OnDialogButtonClickListener { + fun onButtonClick(input: String) + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_dialog_button.xml b/app/src/main/res/drawable/bg_dialog_button.xml new file mode 100644 index 0000000..5f7d57d --- /dev/null +++ b/app/src/main/res/drawable/bg_dialog_button.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_layout_white.xml b/app/src/main/res/drawable/bg_layout_white.xml new file mode 100644 index 0000000..19b473b --- /dev/null +++ b/app/src/main/res/drawable/bg_layout_white.xml @@ -0,0 +1,11 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/guide1.png b/app/src/main/res/drawable/guide1.png new file mode 100644 index 0000000..074c768 --- /dev/null +++ b/app/src/main/res/drawable/guide1.png Binary files differ diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_lock.xml b/app/src/main/res/drawable/ic_lock.xml new file mode 100644 index 0000000..f0a5610 --- /dev/null +++ b/app/src/main/res/drawable/ic_lock.xml @@ -0,0 +1,12 @@ + + + + diff --git a/app/src/main/res/drawable/ic_login_bg.png b/app/src/main/res/drawable/ic_login_bg.png new file mode 100644 index 0000000..64789c3 --- /dev/null +++ b/app/src/main/res/drawable/ic_login_bg.png Binary files differ diff --git a/app/src/main/res/drawable/ic_user.xml b/app/src/main/res/drawable/ic_user.xml new file mode 100644 index 0000000..8c4a29d --- /dev/null +++ b/app/src/main/res/drawable/ic_user.xml @@ -0,0 +1,15 @@ + + + + + diff --git a/app/src/main/res/layout/activity_guide.xml b/app/src/main/res/layout/activity_guide.xml new file mode 100644 index 0000000..e197626 --- /dev/null +++ b/app/src/main/res/layout/activity_guide.xml @@ -0,0 +1,19 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_login.xml b/app/src/main/res/layout/activity_login.xml new file mode 100644 index 0000000..bcae777 --- /dev/null +++ b/app/src/main/res/layout/activity_login.xml @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..def59e4 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,18 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_input.xml b/app/src/main/res/layout/dialog_input.xml new file mode 100644 index 0000000..f5a8bc6 --- /dev/null +++ b/app/src/main/res/layout/dialog_input.xml @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..a571e60 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 0000000..61da551 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..c41dd28 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher.png Binary files differ diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..603b140 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..88ea3aa --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,122 @@ + + + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+ + +
+
\ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..5cd135a --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..7bfef59 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..4ca4a9f --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,67 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' + +android { + compileSdkVersion 30 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.birmm.inspect" + minSdkVersion 21 + targetSdkVersion 30 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'androidx.core:core-ktx:1.3.2' + implementation 'androidx.constraintlayout:constraintlayout:2.0.4' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test.ext:junit:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:1.3.0' + //腾讯Android UI框架 + implementation 'com.qmuiteam:qmui:2.0.0-alpha10' + implementation 'com.qmuiteam:arch:0.3.1' + //沉浸式状态栏。基础依赖包,必须要依赖 + implementation 'com.gyf.immersionbar:immersionbar:3.0.0' + //fragment快速实现 + implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + + //MVP网络请求框架retrofit2+rxjava + implementation 'io.reactivex:rxjava:1.3.8' + implementation 'io.reactivex:rxandroid:1.2.1' + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.6.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + implementation 'com.squareup.retrofit2:adapter-rxjava:2.8.1' + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.8.6' + //Toast提示 + implementation 'com.sdsmdg.tastytoast:tastytoast:0.1.1' + //图片选择框架 + implementation 'com.github.LuckSiege.PictureSelector:picture_library:v2.6.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..ea03309 --- /dev/null +++ b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.casic.birmm.inspect + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.casic.birmm.inspect", appContext.packageName) + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..7096527 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt new file mode 100644 index 0000000..aefdbb6 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt @@ -0,0 +1,36 @@ +package com.casic.birmm.inspect.base + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.qmuiteam.qmui.util.QMUIStatusBarHelper + +abstract class BaseActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(initLayoutView()) + QMUIStatusBarHelper.translucent(this) //沉浸式状态栏 + setupTopBarLayout() + initData() + initEvent() + } + + /** + * 初始化xml布局 + */ + abstract fun initLayoutView(): Int + + /** + * 特定页面定制沉浸式状态栏 + */ + protected abstract fun setupTopBarLayout() + + /** + * 初始化默认数据 + */ + abstract fun initData() + + /** + * 初始化业务逻辑 + */ + abstract fun initEvent() +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt new file mode 100644 index 0000000..fc0ca75 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt @@ -0,0 +1,18 @@ +package com.casic.birmm.inspect.base + +import android.app.Application +import com.casic.birmm.inspect.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + companion object { + var instance: BaseApplication by Delegates.notNull() + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt new file mode 100644 index 0000000..ddc160a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt @@ -0,0 +1,56 @@ +package com.casic.birmm.inspect.ui + +import android.annotation.SuppressLint +import android.content.Intent +import android.os.CountDownTimer +import android.view.ViewGroup.MarginLayoutParams +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.activity_guide.* + +@SuppressLint("SetTextI18n") +class GuideActivity : BaseActivity() { + + private lateinit var countDownTimer: CountDownTimer + + override fun initLayoutView(): Int = R.layout.activity_guide + + override fun setupTopBarLayout() { + + } + + override fun initData() { + //根据不同设备状态栏高度设置"跳过"按钮的Margin值 + val statusBarHeight = QMUIDisplayHelper.getStatusBarHeight(this) + val rightMargin = QMUIDisplayHelper.dp2px(this, 10) + if (skipButton.layoutParams is MarginLayoutParams) { + val params = skipButton.layoutParams as MarginLayoutParams + params.setMargins(skipButton.width, statusBarHeight, rightMargin, 0) + skipButton.requestLayout() + } + + countDownTimer = object : CountDownTimer(4000, 1000) { + override fun onFinish() { + startLoginActivity() + } + + override fun onTick(millisUntilFinished: Long) { + skipButton.text = "跳过\u3000${(millisUntilFinished / 1000)}s" + } + } + } + + override fun initEvent() { + countDownTimer.start() + skipButton.setOnClickListener { + countDownTimer.cancel() + startLoginActivity() + } + } + + fun startLoginActivity() { + startActivity(Intent(this, LoginActivity::class.java)) + finish() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt new file mode 100644 index 0000000..6ef4548 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt @@ -0,0 +1,81 @@ +package com.casic.birmm.inspect.ui + +import android.text.Editable +import android.text.TextWatcher +import android.view.KeyEvent +import android.view.inputmethod.EditorInfo +import android.widget.EditText +import android.widget.TextView +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.casic.birmm.inspect.utils.Constant +import com.casic.birmm.inspect.utils.SaveKeyValues +import com.casic.birmm.inspect.widgets.InputDialog +import kotlinx.android.synthetic.main.activity_login.* + + +class LoginActivity : BaseActivity() { + + companion object { + private const val Tag = "LoginActivity" + } + + override fun initLayoutView(): Int = R.layout.activity_login + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + loginButton.setChangeAlphaWhenPress(true) + val editText: EditText? = inputLayout.editText + editText?.addTextChangedListener(object : TextWatcher { + override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) { + + } + + override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) { + + } + + override fun afterTextChanged(s: Editable) { + if (s.toString().trim { it <= ' ' }.length > 12) { + inputLayout.error = "密码长度超出限制" + } else { + inputLayout.error = null + } + } + }) + //点击输入法键盘"完成" + editText?.setOnEditorActionListener { _: TextView?, actionId: Int, _: KeyEvent? -> + if (actionId == EditorInfo.IME_ACTION_DONE) { +// authenticatePresenter.onReadyRetrofitRequest() + return@setOnEditorActionListener true + } + false + } + + //修改服务器配置 + changeServerConfigView.setOnClickListener { + val defaultValue = SaveKeyValues.getValue( + Constant.DEFAULT_SERVER_CONFIG, + "http://139.198.6.177:8093/" + ) as String + InputDialog.Builder().setContext(this) + .setTitle("请输入后台服务器地址") + .setDefaultValue(defaultValue) + .setNegativeButton("取消") + .setPositiveButton("保存") + .setOnDialogClickListener(object : InputDialog.OnDialogButtonClickListener { + override fun onButtonClick(input: String) { + SaveKeyValues.putValue(Constant.DEFAULT_SERVER_CONFIG, input) + } + }) + .build().show() + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt new file mode 100644 index 0000000..0e97af7 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt @@ -0,0 +1,21 @@ +package com.casic.birmm.inspect.ui + +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity + +class MainActivity : BaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt new file mode 100644 index 0000000..21fbba2 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt @@ -0,0 +1,58 @@ +package com.casic.birmm.inspect.ui + +import android.content.Intent +import android.os.Build +import android.os.Bundle +import android.util.Log +import androidx.appcompat.app.AppCompatActivity +import com.casic.birmm.inspect.utils.Constant +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + companion object { + private const val TAG = "PermissionActivity" + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + if (EasyPermissions.hasPermissions(this, *Constant.USER_PERMISSIONS)) { + startGuideActivity() + } else { + EasyPermissions.requestPermissions( + this, + "需要获取相关权限", + Constant.PERMISSIONS_CODE, + *Constant.USER_PERMISSIONS + ) + } + } else { + startGuideActivity() + } + } + + private fun startGuideActivity() { + startActivity(Intent(this, GuideActivity::class.java)) + finish() + } + + override fun onRequestPermissionsResult( + requestCode: Int, + permissions: Array, + grantResults: IntArray + ) { + super.onRequestPermissionsResult(requestCode, permissions, grantResults) + EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this) + } + + override fun onPermissionsGranted(requestCode: Int, perms: List) { + startGuideActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + Log.e(TAG, "onPermissionsDenied: $perms") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt new file mode 100644 index 0000000..53df6e1 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt @@ -0,0 +1,15 @@ +package com.casic.birmm.inspect.utils + +import android.Manifest + + +object Constant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.ACCESS_LOCATION_EXTRA_COMMANDS, + Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION + ) + + const val PERMISSIONS_CODE = 999 + + const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt new file mode 100644 index 0000000..4c38241 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt @@ -0,0 +1,19 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.view.View +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object OtherUtils { + + //替换Toast + fun showTipsDialog(context: Context, message: String, view: View) { + val tipDialog = QMUITipDialog.Builder(context) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_NOTHING) + .setTipWord(message).create() + tipDialog.show() + view.postDelayed({ + tipDialog.dismiss() + }, 2000) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt b/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt new file mode 100644 index 0000000..04c9f5a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt @@ -0,0 +1,106 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.content.SharedPreferences +import com.casic.birmm.inspect.base.BaseApplication + +object SaveKeyValues { + private var sharedPreferences: SharedPreferences? = null + private var editor: SharedPreferences.Editor? = null + private var fileName: String? = null + + fun initSharedPreferences() { + val packageName = BaseApplication.instance.packageName + //获取到的包名带有“.”方便命名,取最后一个作为sp文件名,例如:com.casic.birmm.inspect + val split = packageName.split(".") + fileName = split[split.size - 1] + } + + /** + * 存储 + */ + fun putValue(key: String?, obj: Any) { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + val editor = sharedPreferences!!.edit() + when (obj) { + is String -> { + editor.putString(key, obj).apply() + } + is Int -> { + editor.putInt(key, obj).apply() + } + is Boolean -> { + editor.putBoolean(key, obj).apply() + } + is Float -> { + editor.putFloat(key, obj).apply() + } + is Long -> { + editor.putLong(key, obj).apply() + } + else -> { + editor.putString(key, obj.toString()).apply() + } + } + } + + /** + * 获取保存的数据 + */ + operator fun getValue(key: String?, defaultObject: Any?): Any? { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + return when (defaultObject) { + is String -> { + sharedPreferences!!.getString(key, defaultObject as String?) + } + is Int -> { + sharedPreferences!!.getInt(key, (defaultObject as Int?)!!) + } + is Boolean -> { + sharedPreferences!!.getBoolean(key, (defaultObject as Boolean?)!!) + } + is Float -> { + sharedPreferences!!.getFloat(key, (defaultObject as Float?)!!) + } + is Long -> { + sharedPreferences!!.getLong(key, (defaultObject as Long?)!!) + } + else -> { + sharedPreferences!!.getString(key, null) + } + } + } + + /** + * 移除某个key值已经对应的值 + */ + fun removeKey(key: String?) { + editor!!.remove(key) + editor!!.commit() + } + + /** + * 清除所有数据 + */ + fun clearAll() { + editor!!.clear() + editor!!.commit() + } + + /** + * 查询某个key是否存在 + */ + fun containsKey(key: String?): Boolean { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + return sharedPreferences!!.contains(key) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt b/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt new file mode 100644 index 0000000..04db86b --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt @@ -0,0 +1,119 @@ +package com.casic.birmm.inspect.widgets + +import android.app.Dialog +import android.content.Context +import android.graphics.Color +import android.graphics.drawable.ColorDrawable +import android.os.Bundle +import android.view.WindowManager +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.utils.OtherUtils +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.dialog_input.* + + +class InputDialog private constructor(builder: Builder) : Dialog(builder.mContext!!) { + + private var ctx: Context? = null + private var title: String? = null + private var value: String? = null + private var positiveBtn: String? = null + private var negativeBtn: String? = null + private var listener: OnDialogButtonClickListener? = null + + init { + this.ctx = builder.mContext + this.title = builder.title + this.value = builder.value + this.positiveBtn = builder.positiveBtn + this.negativeBtn = builder.negativeBtn + this.listener = builder.listener + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + configDialogLayout() + setContentView(R.layout.dialog_input) + setCancelable(false) + setCanceledOnTouchOutside(false) + + dialogTitleView.text = title + value.apply { + dialogInputView.setText(this) + } + + dialogCancelButton.text = negativeBtn + dialogCancelButton.setChangeAlphaWhenPress(true) + dialogCancelButton.setOnClickListener { + this.dismiss() + } + + dialogConfirmButton.text = positiveBtn + dialogConfirmButton.setChangeAlphaWhenPress(true) + dialogConfirmButton.setOnClickListener { + val inputValue = dialogInputView.text.toString().trim() + if (inputValue.isEmpty()) { + OtherUtils.showTipsDialog(ctx!!, "什么都没输入,请重新输入", dialogConfirmButton) + return@setOnClickListener + } + listener?.onButtonClick(inputValue) + this.dismiss() + } + } + + private fun configDialogLayout() { + window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT)) + window?.decorView?.setBackgroundColor(Color.TRANSPARENT) + val params: WindowManager.LayoutParams? = window?.attributes + params?.width = QMUIDisplayHelper.dp2px(ctx, 300) + params?.height = WindowManager.LayoutParams.WRAP_CONTENT + window?.attributes = params + } + + class Builder { + var mContext: Context? = null + var title: String? = null + var value: String? = null + var positiveBtn: String? = null + var negativeBtn: String? = null + var listener: OnDialogButtonClickListener? = null + + fun setContext(context: Context?): Builder { + mContext = context + return this + } + + fun setTitle(title: String?): Builder { + this.title = title + return this + } + + fun setDefaultValue(value: String?): Builder { + this.value = value + return this + } + + fun setPositiveButton(name: String?): Builder { + positiveBtn = name + return this + } + + fun setNegativeButton(name: String?): Builder { + negativeBtn = name + return this + } + + fun setOnDialogClickListener(listener: OnDialogButtonClickListener): Builder { + this.listener = listener + return this + } + + fun build(): InputDialog { + return InputDialog(this) + } + } + + interface OnDialogButtonClickListener { + fun onButtonClick(input: String) + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_dialog_button.xml b/app/src/main/res/drawable/bg_dialog_button.xml new file mode 100644 index 0000000..5f7d57d --- /dev/null +++ b/app/src/main/res/drawable/bg_dialog_button.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_layout_white.xml b/app/src/main/res/drawable/bg_layout_white.xml new file mode 100644 index 0000000..19b473b --- /dev/null +++ b/app/src/main/res/drawable/bg_layout_white.xml @@ -0,0 +1,11 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/guide1.png b/app/src/main/res/drawable/guide1.png new file mode 100644 index 0000000..074c768 --- /dev/null +++ b/app/src/main/res/drawable/guide1.png Binary files differ diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_lock.xml b/app/src/main/res/drawable/ic_lock.xml new file mode 100644 index 0000000..f0a5610 --- /dev/null +++ b/app/src/main/res/drawable/ic_lock.xml @@ -0,0 +1,12 @@ + + + + diff --git a/app/src/main/res/drawable/ic_login_bg.png b/app/src/main/res/drawable/ic_login_bg.png new file mode 100644 index 0000000..64789c3 --- /dev/null +++ b/app/src/main/res/drawable/ic_login_bg.png Binary files differ diff --git a/app/src/main/res/drawable/ic_user.xml b/app/src/main/res/drawable/ic_user.xml new file mode 100644 index 0000000..8c4a29d --- /dev/null +++ b/app/src/main/res/drawable/ic_user.xml @@ -0,0 +1,15 @@ + + + + + diff --git a/app/src/main/res/layout/activity_guide.xml b/app/src/main/res/layout/activity_guide.xml new file mode 100644 index 0000000..e197626 --- /dev/null +++ b/app/src/main/res/layout/activity_guide.xml @@ -0,0 +1,19 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_login.xml b/app/src/main/res/layout/activity_login.xml new file mode 100644 index 0000000..bcae777 --- /dev/null +++ b/app/src/main/res/layout/activity_login.xml @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..def59e4 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,18 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_input.xml b/app/src/main/res/layout/dialog_input.xml new file mode 100644 index 0000000..f5a8bc6 --- /dev/null +++ b/app/src/main/res/layout/dialog_input.xml @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..a571e60 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 0000000..61da551 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..c41dd28 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png new file mode 100644 index 0000000..db5080a --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png Binary files differ diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..603b140 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..88ea3aa --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,122 @@ + + + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+ + +
+
\ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..5cd135a --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..7bfef59 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..4ca4a9f --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,67 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' + +android { + compileSdkVersion 30 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.birmm.inspect" + minSdkVersion 21 + targetSdkVersion 30 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'androidx.core:core-ktx:1.3.2' + implementation 'androidx.constraintlayout:constraintlayout:2.0.4' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test.ext:junit:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:1.3.0' + //腾讯Android UI框架 + implementation 'com.qmuiteam:qmui:2.0.0-alpha10' + implementation 'com.qmuiteam:arch:0.3.1' + //沉浸式状态栏。基础依赖包,必须要依赖 + implementation 'com.gyf.immersionbar:immersionbar:3.0.0' + //fragment快速实现 + implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + + //MVP网络请求框架retrofit2+rxjava + implementation 'io.reactivex:rxjava:1.3.8' + implementation 'io.reactivex:rxandroid:1.2.1' + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.6.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + implementation 'com.squareup.retrofit2:adapter-rxjava:2.8.1' + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.8.6' + //Toast提示 + implementation 'com.sdsmdg.tastytoast:tastytoast:0.1.1' + //图片选择框架 + implementation 'com.github.LuckSiege.PictureSelector:picture_library:v2.6.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..ea03309 --- /dev/null +++ b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.casic.birmm.inspect + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.casic.birmm.inspect", appContext.packageName) + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..7096527 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt new file mode 100644 index 0000000..aefdbb6 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt @@ -0,0 +1,36 @@ +package com.casic.birmm.inspect.base + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.qmuiteam.qmui.util.QMUIStatusBarHelper + +abstract class BaseActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(initLayoutView()) + QMUIStatusBarHelper.translucent(this) //沉浸式状态栏 + setupTopBarLayout() + initData() + initEvent() + } + + /** + * 初始化xml布局 + */ + abstract fun initLayoutView(): Int + + /** + * 特定页面定制沉浸式状态栏 + */ + protected abstract fun setupTopBarLayout() + + /** + * 初始化默认数据 + */ + abstract fun initData() + + /** + * 初始化业务逻辑 + */ + abstract fun initEvent() +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt new file mode 100644 index 0000000..fc0ca75 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt @@ -0,0 +1,18 @@ +package com.casic.birmm.inspect.base + +import android.app.Application +import com.casic.birmm.inspect.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + companion object { + var instance: BaseApplication by Delegates.notNull() + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt new file mode 100644 index 0000000..ddc160a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt @@ -0,0 +1,56 @@ +package com.casic.birmm.inspect.ui + +import android.annotation.SuppressLint +import android.content.Intent +import android.os.CountDownTimer +import android.view.ViewGroup.MarginLayoutParams +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.activity_guide.* + +@SuppressLint("SetTextI18n") +class GuideActivity : BaseActivity() { + + private lateinit var countDownTimer: CountDownTimer + + override fun initLayoutView(): Int = R.layout.activity_guide + + override fun setupTopBarLayout() { + + } + + override fun initData() { + //根据不同设备状态栏高度设置"跳过"按钮的Margin值 + val statusBarHeight = QMUIDisplayHelper.getStatusBarHeight(this) + val rightMargin = QMUIDisplayHelper.dp2px(this, 10) + if (skipButton.layoutParams is MarginLayoutParams) { + val params = skipButton.layoutParams as MarginLayoutParams + params.setMargins(skipButton.width, statusBarHeight, rightMargin, 0) + skipButton.requestLayout() + } + + countDownTimer = object : CountDownTimer(4000, 1000) { + override fun onFinish() { + startLoginActivity() + } + + override fun onTick(millisUntilFinished: Long) { + skipButton.text = "跳过\u3000${(millisUntilFinished / 1000)}s" + } + } + } + + override fun initEvent() { + countDownTimer.start() + skipButton.setOnClickListener { + countDownTimer.cancel() + startLoginActivity() + } + } + + fun startLoginActivity() { + startActivity(Intent(this, LoginActivity::class.java)) + finish() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt new file mode 100644 index 0000000..6ef4548 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt @@ -0,0 +1,81 @@ +package com.casic.birmm.inspect.ui + +import android.text.Editable +import android.text.TextWatcher +import android.view.KeyEvent +import android.view.inputmethod.EditorInfo +import android.widget.EditText +import android.widget.TextView +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.casic.birmm.inspect.utils.Constant +import com.casic.birmm.inspect.utils.SaveKeyValues +import com.casic.birmm.inspect.widgets.InputDialog +import kotlinx.android.synthetic.main.activity_login.* + + +class LoginActivity : BaseActivity() { + + companion object { + private const val Tag = "LoginActivity" + } + + override fun initLayoutView(): Int = R.layout.activity_login + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + loginButton.setChangeAlphaWhenPress(true) + val editText: EditText? = inputLayout.editText + editText?.addTextChangedListener(object : TextWatcher { + override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) { + + } + + override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) { + + } + + override fun afterTextChanged(s: Editable) { + if (s.toString().trim { it <= ' ' }.length > 12) { + inputLayout.error = "密码长度超出限制" + } else { + inputLayout.error = null + } + } + }) + //点击输入法键盘"完成" + editText?.setOnEditorActionListener { _: TextView?, actionId: Int, _: KeyEvent? -> + if (actionId == EditorInfo.IME_ACTION_DONE) { +// authenticatePresenter.onReadyRetrofitRequest() + return@setOnEditorActionListener true + } + false + } + + //修改服务器配置 + changeServerConfigView.setOnClickListener { + val defaultValue = SaveKeyValues.getValue( + Constant.DEFAULT_SERVER_CONFIG, + "http://139.198.6.177:8093/" + ) as String + InputDialog.Builder().setContext(this) + .setTitle("请输入后台服务器地址") + .setDefaultValue(defaultValue) + .setNegativeButton("取消") + .setPositiveButton("保存") + .setOnDialogClickListener(object : InputDialog.OnDialogButtonClickListener { + override fun onButtonClick(input: String) { + SaveKeyValues.putValue(Constant.DEFAULT_SERVER_CONFIG, input) + } + }) + .build().show() + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt new file mode 100644 index 0000000..0e97af7 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt @@ -0,0 +1,21 @@ +package com.casic.birmm.inspect.ui + +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity + +class MainActivity : BaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt new file mode 100644 index 0000000..21fbba2 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt @@ -0,0 +1,58 @@ +package com.casic.birmm.inspect.ui + +import android.content.Intent +import android.os.Build +import android.os.Bundle +import android.util.Log +import androidx.appcompat.app.AppCompatActivity +import com.casic.birmm.inspect.utils.Constant +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + companion object { + private const val TAG = "PermissionActivity" + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + if (EasyPermissions.hasPermissions(this, *Constant.USER_PERMISSIONS)) { + startGuideActivity() + } else { + EasyPermissions.requestPermissions( + this, + "需要获取相关权限", + Constant.PERMISSIONS_CODE, + *Constant.USER_PERMISSIONS + ) + } + } else { + startGuideActivity() + } + } + + private fun startGuideActivity() { + startActivity(Intent(this, GuideActivity::class.java)) + finish() + } + + override fun onRequestPermissionsResult( + requestCode: Int, + permissions: Array, + grantResults: IntArray + ) { + super.onRequestPermissionsResult(requestCode, permissions, grantResults) + EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this) + } + + override fun onPermissionsGranted(requestCode: Int, perms: List) { + startGuideActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + Log.e(TAG, "onPermissionsDenied: $perms") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt new file mode 100644 index 0000000..53df6e1 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt @@ -0,0 +1,15 @@ +package com.casic.birmm.inspect.utils + +import android.Manifest + + +object Constant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.ACCESS_LOCATION_EXTRA_COMMANDS, + Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION + ) + + const val PERMISSIONS_CODE = 999 + + const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt new file mode 100644 index 0000000..4c38241 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt @@ -0,0 +1,19 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.view.View +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object OtherUtils { + + //替换Toast + fun showTipsDialog(context: Context, message: String, view: View) { + val tipDialog = QMUITipDialog.Builder(context) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_NOTHING) + .setTipWord(message).create() + tipDialog.show() + view.postDelayed({ + tipDialog.dismiss() + }, 2000) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt b/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt new file mode 100644 index 0000000..04c9f5a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt @@ -0,0 +1,106 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.content.SharedPreferences +import com.casic.birmm.inspect.base.BaseApplication + +object SaveKeyValues { + private var sharedPreferences: SharedPreferences? = null + private var editor: SharedPreferences.Editor? = null + private var fileName: String? = null + + fun initSharedPreferences() { + val packageName = BaseApplication.instance.packageName + //获取到的包名带有“.”方便命名,取最后一个作为sp文件名,例如:com.casic.birmm.inspect + val split = packageName.split(".") + fileName = split[split.size - 1] + } + + /** + * 存储 + */ + fun putValue(key: String?, obj: Any) { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + val editor = sharedPreferences!!.edit() + when (obj) { + is String -> { + editor.putString(key, obj).apply() + } + is Int -> { + editor.putInt(key, obj).apply() + } + is Boolean -> { + editor.putBoolean(key, obj).apply() + } + is Float -> { + editor.putFloat(key, obj).apply() + } + is Long -> { + editor.putLong(key, obj).apply() + } + else -> { + editor.putString(key, obj.toString()).apply() + } + } + } + + /** + * 获取保存的数据 + */ + operator fun getValue(key: String?, defaultObject: Any?): Any? { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + return when (defaultObject) { + is String -> { + sharedPreferences!!.getString(key, defaultObject as String?) + } + is Int -> { + sharedPreferences!!.getInt(key, (defaultObject as Int?)!!) + } + is Boolean -> { + sharedPreferences!!.getBoolean(key, (defaultObject as Boolean?)!!) + } + is Float -> { + sharedPreferences!!.getFloat(key, (defaultObject as Float?)!!) + } + is Long -> { + sharedPreferences!!.getLong(key, (defaultObject as Long?)!!) + } + else -> { + sharedPreferences!!.getString(key, null) + } + } + } + + /** + * 移除某个key值已经对应的值 + */ + fun removeKey(key: String?) { + editor!!.remove(key) + editor!!.commit() + } + + /** + * 清除所有数据 + */ + fun clearAll() { + editor!!.clear() + editor!!.commit() + } + + /** + * 查询某个key是否存在 + */ + fun containsKey(key: String?): Boolean { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + return sharedPreferences!!.contains(key) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt b/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt new file mode 100644 index 0000000..04db86b --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt @@ -0,0 +1,119 @@ +package com.casic.birmm.inspect.widgets + +import android.app.Dialog +import android.content.Context +import android.graphics.Color +import android.graphics.drawable.ColorDrawable +import android.os.Bundle +import android.view.WindowManager +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.utils.OtherUtils +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.dialog_input.* + + +class InputDialog private constructor(builder: Builder) : Dialog(builder.mContext!!) { + + private var ctx: Context? = null + private var title: String? = null + private var value: String? = null + private var positiveBtn: String? = null + private var negativeBtn: String? = null + private var listener: OnDialogButtonClickListener? = null + + init { + this.ctx = builder.mContext + this.title = builder.title + this.value = builder.value + this.positiveBtn = builder.positiveBtn + this.negativeBtn = builder.negativeBtn + this.listener = builder.listener + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + configDialogLayout() + setContentView(R.layout.dialog_input) + setCancelable(false) + setCanceledOnTouchOutside(false) + + dialogTitleView.text = title + value.apply { + dialogInputView.setText(this) + } + + dialogCancelButton.text = negativeBtn + dialogCancelButton.setChangeAlphaWhenPress(true) + dialogCancelButton.setOnClickListener { + this.dismiss() + } + + dialogConfirmButton.text = positiveBtn + dialogConfirmButton.setChangeAlphaWhenPress(true) + dialogConfirmButton.setOnClickListener { + val inputValue = dialogInputView.text.toString().trim() + if (inputValue.isEmpty()) { + OtherUtils.showTipsDialog(ctx!!, "什么都没输入,请重新输入", dialogConfirmButton) + return@setOnClickListener + } + listener?.onButtonClick(inputValue) + this.dismiss() + } + } + + private fun configDialogLayout() { + window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT)) + window?.decorView?.setBackgroundColor(Color.TRANSPARENT) + val params: WindowManager.LayoutParams? = window?.attributes + params?.width = QMUIDisplayHelper.dp2px(ctx, 300) + params?.height = WindowManager.LayoutParams.WRAP_CONTENT + window?.attributes = params + } + + class Builder { + var mContext: Context? = null + var title: String? = null + var value: String? = null + var positiveBtn: String? = null + var negativeBtn: String? = null + var listener: OnDialogButtonClickListener? = null + + fun setContext(context: Context?): Builder { + mContext = context + return this + } + + fun setTitle(title: String?): Builder { + this.title = title + return this + } + + fun setDefaultValue(value: String?): Builder { + this.value = value + return this + } + + fun setPositiveButton(name: String?): Builder { + positiveBtn = name + return this + } + + fun setNegativeButton(name: String?): Builder { + negativeBtn = name + return this + } + + fun setOnDialogClickListener(listener: OnDialogButtonClickListener): Builder { + this.listener = listener + return this + } + + fun build(): InputDialog { + return InputDialog(this) + } + } + + interface OnDialogButtonClickListener { + fun onButtonClick(input: String) + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_dialog_button.xml b/app/src/main/res/drawable/bg_dialog_button.xml new file mode 100644 index 0000000..5f7d57d --- /dev/null +++ b/app/src/main/res/drawable/bg_dialog_button.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_layout_white.xml b/app/src/main/res/drawable/bg_layout_white.xml new file mode 100644 index 0000000..19b473b --- /dev/null +++ b/app/src/main/res/drawable/bg_layout_white.xml @@ -0,0 +1,11 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/guide1.png b/app/src/main/res/drawable/guide1.png new file mode 100644 index 0000000..074c768 --- /dev/null +++ b/app/src/main/res/drawable/guide1.png Binary files differ diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_lock.xml b/app/src/main/res/drawable/ic_lock.xml new file mode 100644 index 0000000..f0a5610 --- /dev/null +++ b/app/src/main/res/drawable/ic_lock.xml @@ -0,0 +1,12 @@ + + + + diff --git a/app/src/main/res/drawable/ic_login_bg.png b/app/src/main/res/drawable/ic_login_bg.png new file mode 100644 index 0000000..64789c3 --- /dev/null +++ b/app/src/main/res/drawable/ic_login_bg.png Binary files differ diff --git a/app/src/main/res/drawable/ic_user.xml b/app/src/main/res/drawable/ic_user.xml new file mode 100644 index 0000000..8c4a29d --- /dev/null +++ b/app/src/main/res/drawable/ic_user.xml @@ -0,0 +1,15 @@ + + + + + diff --git a/app/src/main/res/layout/activity_guide.xml b/app/src/main/res/layout/activity_guide.xml new file mode 100644 index 0000000..e197626 --- /dev/null +++ b/app/src/main/res/layout/activity_guide.xml @@ -0,0 +1,19 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_login.xml b/app/src/main/res/layout/activity_login.xml new file mode 100644 index 0000000..bcae777 --- /dev/null +++ b/app/src/main/res/layout/activity_login.xml @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..def59e4 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,18 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_input.xml b/app/src/main/res/layout/dialog_input.xml new file mode 100644 index 0000000..f5a8bc6 --- /dev/null +++ b/app/src/main/res/layout/dialog_input.xml @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..a571e60 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 0000000..61da551 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..c41dd28 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png new file mode 100644 index 0000000..db5080a --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..6dba46d --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ic_launcher.png Binary files differ diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..603b140 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..88ea3aa --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,122 @@ + + + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+ + +
+
\ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..5cd135a --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..7bfef59 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..4ca4a9f --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,67 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' + +android { + compileSdkVersion 30 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.birmm.inspect" + minSdkVersion 21 + targetSdkVersion 30 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'androidx.core:core-ktx:1.3.2' + implementation 'androidx.constraintlayout:constraintlayout:2.0.4' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test.ext:junit:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:1.3.0' + //腾讯Android UI框架 + implementation 'com.qmuiteam:qmui:2.0.0-alpha10' + implementation 'com.qmuiteam:arch:0.3.1' + //沉浸式状态栏。基础依赖包,必须要依赖 + implementation 'com.gyf.immersionbar:immersionbar:3.0.0' + //fragment快速实现 + implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + + //MVP网络请求框架retrofit2+rxjava + implementation 'io.reactivex:rxjava:1.3.8' + implementation 'io.reactivex:rxandroid:1.2.1' + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.6.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + implementation 'com.squareup.retrofit2:adapter-rxjava:2.8.1' + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.8.6' + //Toast提示 + implementation 'com.sdsmdg.tastytoast:tastytoast:0.1.1' + //图片选择框架 + implementation 'com.github.LuckSiege.PictureSelector:picture_library:v2.6.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..ea03309 --- /dev/null +++ b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.casic.birmm.inspect + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.casic.birmm.inspect", appContext.packageName) + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..7096527 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt new file mode 100644 index 0000000..aefdbb6 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt @@ -0,0 +1,36 @@ +package com.casic.birmm.inspect.base + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.qmuiteam.qmui.util.QMUIStatusBarHelper + +abstract class BaseActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(initLayoutView()) + QMUIStatusBarHelper.translucent(this) //沉浸式状态栏 + setupTopBarLayout() + initData() + initEvent() + } + + /** + * 初始化xml布局 + */ + abstract fun initLayoutView(): Int + + /** + * 特定页面定制沉浸式状态栏 + */ + protected abstract fun setupTopBarLayout() + + /** + * 初始化默认数据 + */ + abstract fun initData() + + /** + * 初始化业务逻辑 + */ + abstract fun initEvent() +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt new file mode 100644 index 0000000..fc0ca75 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt @@ -0,0 +1,18 @@ +package com.casic.birmm.inspect.base + +import android.app.Application +import com.casic.birmm.inspect.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + companion object { + var instance: BaseApplication by Delegates.notNull() + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt new file mode 100644 index 0000000..ddc160a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt @@ -0,0 +1,56 @@ +package com.casic.birmm.inspect.ui + +import android.annotation.SuppressLint +import android.content.Intent +import android.os.CountDownTimer +import android.view.ViewGroup.MarginLayoutParams +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.activity_guide.* + +@SuppressLint("SetTextI18n") +class GuideActivity : BaseActivity() { + + private lateinit var countDownTimer: CountDownTimer + + override fun initLayoutView(): Int = R.layout.activity_guide + + override fun setupTopBarLayout() { + + } + + override fun initData() { + //根据不同设备状态栏高度设置"跳过"按钮的Margin值 + val statusBarHeight = QMUIDisplayHelper.getStatusBarHeight(this) + val rightMargin = QMUIDisplayHelper.dp2px(this, 10) + if (skipButton.layoutParams is MarginLayoutParams) { + val params = skipButton.layoutParams as MarginLayoutParams + params.setMargins(skipButton.width, statusBarHeight, rightMargin, 0) + skipButton.requestLayout() + } + + countDownTimer = object : CountDownTimer(4000, 1000) { + override fun onFinish() { + startLoginActivity() + } + + override fun onTick(millisUntilFinished: Long) { + skipButton.text = "跳过\u3000${(millisUntilFinished / 1000)}s" + } + } + } + + override fun initEvent() { + countDownTimer.start() + skipButton.setOnClickListener { + countDownTimer.cancel() + startLoginActivity() + } + } + + fun startLoginActivity() { + startActivity(Intent(this, LoginActivity::class.java)) + finish() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt new file mode 100644 index 0000000..6ef4548 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt @@ -0,0 +1,81 @@ +package com.casic.birmm.inspect.ui + +import android.text.Editable +import android.text.TextWatcher +import android.view.KeyEvent +import android.view.inputmethod.EditorInfo +import android.widget.EditText +import android.widget.TextView +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.casic.birmm.inspect.utils.Constant +import com.casic.birmm.inspect.utils.SaveKeyValues +import com.casic.birmm.inspect.widgets.InputDialog +import kotlinx.android.synthetic.main.activity_login.* + + +class LoginActivity : BaseActivity() { + + companion object { + private const val Tag = "LoginActivity" + } + + override fun initLayoutView(): Int = R.layout.activity_login + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + loginButton.setChangeAlphaWhenPress(true) + val editText: EditText? = inputLayout.editText + editText?.addTextChangedListener(object : TextWatcher { + override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) { + + } + + override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) { + + } + + override fun afterTextChanged(s: Editable) { + if (s.toString().trim { it <= ' ' }.length > 12) { + inputLayout.error = "密码长度超出限制" + } else { + inputLayout.error = null + } + } + }) + //点击输入法键盘"完成" + editText?.setOnEditorActionListener { _: TextView?, actionId: Int, _: KeyEvent? -> + if (actionId == EditorInfo.IME_ACTION_DONE) { +// authenticatePresenter.onReadyRetrofitRequest() + return@setOnEditorActionListener true + } + false + } + + //修改服务器配置 + changeServerConfigView.setOnClickListener { + val defaultValue = SaveKeyValues.getValue( + Constant.DEFAULT_SERVER_CONFIG, + "http://139.198.6.177:8093/" + ) as String + InputDialog.Builder().setContext(this) + .setTitle("请输入后台服务器地址") + .setDefaultValue(defaultValue) + .setNegativeButton("取消") + .setPositiveButton("保存") + .setOnDialogClickListener(object : InputDialog.OnDialogButtonClickListener { + override fun onButtonClick(input: String) { + SaveKeyValues.putValue(Constant.DEFAULT_SERVER_CONFIG, input) + } + }) + .build().show() + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt new file mode 100644 index 0000000..0e97af7 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt @@ -0,0 +1,21 @@ +package com.casic.birmm.inspect.ui + +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity + +class MainActivity : BaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt new file mode 100644 index 0000000..21fbba2 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt @@ -0,0 +1,58 @@ +package com.casic.birmm.inspect.ui + +import android.content.Intent +import android.os.Build +import android.os.Bundle +import android.util.Log +import androidx.appcompat.app.AppCompatActivity +import com.casic.birmm.inspect.utils.Constant +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + companion object { + private const val TAG = "PermissionActivity" + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + if (EasyPermissions.hasPermissions(this, *Constant.USER_PERMISSIONS)) { + startGuideActivity() + } else { + EasyPermissions.requestPermissions( + this, + "需要获取相关权限", + Constant.PERMISSIONS_CODE, + *Constant.USER_PERMISSIONS + ) + } + } else { + startGuideActivity() + } + } + + private fun startGuideActivity() { + startActivity(Intent(this, GuideActivity::class.java)) + finish() + } + + override fun onRequestPermissionsResult( + requestCode: Int, + permissions: Array, + grantResults: IntArray + ) { + super.onRequestPermissionsResult(requestCode, permissions, grantResults) + EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this) + } + + override fun onPermissionsGranted(requestCode: Int, perms: List) { + startGuideActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + Log.e(TAG, "onPermissionsDenied: $perms") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt new file mode 100644 index 0000000..53df6e1 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt @@ -0,0 +1,15 @@ +package com.casic.birmm.inspect.utils + +import android.Manifest + + +object Constant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.ACCESS_LOCATION_EXTRA_COMMANDS, + Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION + ) + + const val PERMISSIONS_CODE = 999 + + const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt new file mode 100644 index 0000000..4c38241 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt @@ -0,0 +1,19 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.view.View +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object OtherUtils { + + //替换Toast + fun showTipsDialog(context: Context, message: String, view: View) { + val tipDialog = QMUITipDialog.Builder(context) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_NOTHING) + .setTipWord(message).create() + tipDialog.show() + view.postDelayed({ + tipDialog.dismiss() + }, 2000) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt b/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt new file mode 100644 index 0000000..04c9f5a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt @@ -0,0 +1,106 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.content.SharedPreferences +import com.casic.birmm.inspect.base.BaseApplication + +object SaveKeyValues { + private var sharedPreferences: SharedPreferences? = null + private var editor: SharedPreferences.Editor? = null + private var fileName: String? = null + + fun initSharedPreferences() { + val packageName = BaseApplication.instance.packageName + //获取到的包名带有“.”方便命名,取最后一个作为sp文件名,例如:com.casic.birmm.inspect + val split = packageName.split(".") + fileName = split[split.size - 1] + } + + /** + * 存储 + */ + fun putValue(key: String?, obj: Any) { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + val editor = sharedPreferences!!.edit() + when (obj) { + is String -> { + editor.putString(key, obj).apply() + } + is Int -> { + editor.putInt(key, obj).apply() + } + is Boolean -> { + editor.putBoolean(key, obj).apply() + } + is Float -> { + editor.putFloat(key, obj).apply() + } + is Long -> { + editor.putLong(key, obj).apply() + } + else -> { + editor.putString(key, obj.toString()).apply() + } + } + } + + /** + * 获取保存的数据 + */ + operator fun getValue(key: String?, defaultObject: Any?): Any? { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + return when (defaultObject) { + is String -> { + sharedPreferences!!.getString(key, defaultObject as String?) + } + is Int -> { + sharedPreferences!!.getInt(key, (defaultObject as Int?)!!) + } + is Boolean -> { + sharedPreferences!!.getBoolean(key, (defaultObject as Boolean?)!!) + } + is Float -> { + sharedPreferences!!.getFloat(key, (defaultObject as Float?)!!) + } + is Long -> { + sharedPreferences!!.getLong(key, (defaultObject as Long?)!!) + } + else -> { + sharedPreferences!!.getString(key, null) + } + } + } + + /** + * 移除某个key值已经对应的值 + */ + fun removeKey(key: String?) { + editor!!.remove(key) + editor!!.commit() + } + + /** + * 清除所有数据 + */ + fun clearAll() { + editor!!.clear() + editor!!.commit() + } + + /** + * 查询某个key是否存在 + */ + fun containsKey(key: String?): Boolean { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + return sharedPreferences!!.contains(key) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt b/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt new file mode 100644 index 0000000..04db86b --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt @@ -0,0 +1,119 @@ +package com.casic.birmm.inspect.widgets + +import android.app.Dialog +import android.content.Context +import android.graphics.Color +import android.graphics.drawable.ColorDrawable +import android.os.Bundle +import android.view.WindowManager +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.utils.OtherUtils +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.dialog_input.* + + +class InputDialog private constructor(builder: Builder) : Dialog(builder.mContext!!) { + + private var ctx: Context? = null + private var title: String? = null + private var value: String? = null + private var positiveBtn: String? = null + private var negativeBtn: String? = null + private var listener: OnDialogButtonClickListener? = null + + init { + this.ctx = builder.mContext + this.title = builder.title + this.value = builder.value + this.positiveBtn = builder.positiveBtn + this.negativeBtn = builder.negativeBtn + this.listener = builder.listener + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + configDialogLayout() + setContentView(R.layout.dialog_input) + setCancelable(false) + setCanceledOnTouchOutside(false) + + dialogTitleView.text = title + value.apply { + dialogInputView.setText(this) + } + + dialogCancelButton.text = negativeBtn + dialogCancelButton.setChangeAlphaWhenPress(true) + dialogCancelButton.setOnClickListener { + this.dismiss() + } + + dialogConfirmButton.text = positiveBtn + dialogConfirmButton.setChangeAlphaWhenPress(true) + dialogConfirmButton.setOnClickListener { + val inputValue = dialogInputView.text.toString().trim() + if (inputValue.isEmpty()) { + OtherUtils.showTipsDialog(ctx!!, "什么都没输入,请重新输入", dialogConfirmButton) + return@setOnClickListener + } + listener?.onButtonClick(inputValue) + this.dismiss() + } + } + + private fun configDialogLayout() { + window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT)) + window?.decorView?.setBackgroundColor(Color.TRANSPARENT) + val params: WindowManager.LayoutParams? = window?.attributes + params?.width = QMUIDisplayHelper.dp2px(ctx, 300) + params?.height = WindowManager.LayoutParams.WRAP_CONTENT + window?.attributes = params + } + + class Builder { + var mContext: Context? = null + var title: String? = null + var value: String? = null + var positiveBtn: String? = null + var negativeBtn: String? = null + var listener: OnDialogButtonClickListener? = null + + fun setContext(context: Context?): Builder { + mContext = context + return this + } + + fun setTitle(title: String?): Builder { + this.title = title + return this + } + + fun setDefaultValue(value: String?): Builder { + this.value = value + return this + } + + fun setPositiveButton(name: String?): Builder { + positiveBtn = name + return this + } + + fun setNegativeButton(name: String?): Builder { + negativeBtn = name + return this + } + + fun setOnDialogClickListener(listener: OnDialogButtonClickListener): Builder { + this.listener = listener + return this + } + + fun build(): InputDialog { + return InputDialog(this) + } + } + + interface OnDialogButtonClickListener { + fun onButtonClick(input: String) + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_dialog_button.xml b/app/src/main/res/drawable/bg_dialog_button.xml new file mode 100644 index 0000000..5f7d57d --- /dev/null +++ b/app/src/main/res/drawable/bg_dialog_button.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_layout_white.xml b/app/src/main/res/drawable/bg_layout_white.xml new file mode 100644 index 0000000..19b473b --- /dev/null +++ b/app/src/main/res/drawable/bg_layout_white.xml @@ -0,0 +1,11 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/guide1.png b/app/src/main/res/drawable/guide1.png new file mode 100644 index 0000000..074c768 --- /dev/null +++ b/app/src/main/res/drawable/guide1.png Binary files differ diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_lock.xml b/app/src/main/res/drawable/ic_lock.xml new file mode 100644 index 0000000..f0a5610 --- /dev/null +++ b/app/src/main/res/drawable/ic_lock.xml @@ -0,0 +1,12 @@ + + + + diff --git a/app/src/main/res/drawable/ic_login_bg.png b/app/src/main/res/drawable/ic_login_bg.png new file mode 100644 index 0000000..64789c3 --- /dev/null +++ b/app/src/main/res/drawable/ic_login_bg.png Binary files differ diff --git a/app/src/main/res/drawable/ic_user.xml b/app/src/main/res/drawable/ic_user.xml new file mode 100644 index 0000000..8c4a29d --- /dev/null +++ b/app/src/main/res/drawable/ic_user.xml @@ -0,0 +1,15 @@ + + + + + diff --git a/app/src/main/res/layout/activity_guide.xml b/app/src/main/res/layout/activity_guide.xml new file mode 100644 index 0000000..e197626 --- /dev/null +++ b/app/src/main/res/layout/activity_guide.xml @@ -0,0 +1,19 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_login.xml b/app/src/main/res/layout/activity_login.xml new file mode 100644 index 0000000..bcae777 --- /dev/null +++ b/app/src/main/res/layout/activity_login.xml @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..def59e4 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,18 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_input.xml b/app/src/main/res/layout/dialog_input.xml new file mode 100644 index 0000000..f5a8bc6 --- /dev/null +++ b/app/src/main/res/layout/dialog_input.xml @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..a571e60 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 0000000..61da551 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..c41dd28 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png new file mode 100644 index 0000000..db5080a --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..6dba46d --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png new file mode 100644 index 0000000..da31a87 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png Binary files differ diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..603b140 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..88ea3aa --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,122 @@ + + + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+ + +
+
\ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..5cd135a --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..7bfef59 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..4ca4a9f --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,67 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' + +android { + compileSdkVersion 30 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.birmm.inspect" + minSdkVersion 21 + targetSdkVersion 30 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'androidx.core:core-ktx:1.3.2' + implementation 'androidx.constraintlayout:constraintlayout:2.0.4' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test.ext:junit:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:1.3.0' + //腾讯Android UI框架 + implementation 'com.qmuiteam:qmui:2.0.0-alpha10' + implementation 'com.qmuiteam:arch:0.3.1' + //沉浸式状态栏。基础依赖包,必须要依赖 + implementation 'com.gyf.immersionbar:immersionbar:3.0.0' + //fragment快速实现 + implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + + //MVP网络请求框架retrofit2+rxjava + implementation 'io.reactivex:rxjava:1.3.8' + implementation 'io.reactivex:rxandroid:1.2.1' + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.6.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + implementation 'com.squareup.retrofit2:adapter-rxjava:2.8.1' + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.8.6' + //Toast提示 + implementation 'com.sdsmdg.tastytoast:tastytoast:0.1.1' + //图片选择框架 + implementation 'com.github.LuckSiege.PictureSelector:picture_library:v2.6.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..ea03309 --- /dev/null +++ b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.casic.birmm.inspect + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.casic.birmm.inspect", appContext.packageName) + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..7096527 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt new file mode 100644 index 0000000..aefdbb6 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt @@ -0,0 +1,36 @@ +package com.casic.birmm.inspect.base + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.qmuiteam.qmui.util.QMUIStatusBarHelper + +abstract class BaseActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(initLayoutView()) + QMUIStatusBarHelper.translucent(this) //沉浸式状态栏 + setupTopBarLayout() + initData() + initEvent() + } + + /** + * 初始化xml布局 + */ + abstract fun initLayoutView(): Int + + /** + * 特定页面定制沉浸式状态栏 + */ + protected abstract fun setupTopBarLayout() + + /** + * 初始化默认数据 + */ + abstract fun initData() + + /** + * 初始化业务逻辑 + */ + abstract fun initEvent() +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt new file mode 100644 index 0000000..fc0ca75 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt @@ -0,0 +1,18 @@ +package com.casic.birmm.inspect.base + +import android.app.Application +import com.casic.birmm.inspect.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + companion object { + var instance: BaseApplication by Delegates.notNull() + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt new file mode 100644 index 0000000..ddc160a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt @@ -0,0 +1,56 @@ +package com.casic.birmm.inspect.ui + +import android.annotation.SuppressLint +import android.content.Intent +import android.os.CountDownTimer +import android.view.ViewGroup.MarginLayoutParams +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.activity_guide.* + +@SuppressLint("SetTextI18n") +class GuideActivity : BaseActivity() { + + private lateinit var countDownTimer: CountDownTimer + + override fun initLayoutView(): Int = R.layout.activity_guide + + override fun setupTopBarLayout() { + + } + + override fun initData() { + //根据不同设备状态栏高度设置"跳过"按钮的Margin值 + val statusBarHeight = QMUIDisplayHelper.getStatusBarHeight(this) + val rightMargin = QMUIDisplayHelper.dp2px(this, 10) + if (skipButton.layoutParams is MarginLayoutParams) { + val params = skipButton.layoutParams as MarginLayoutParams + params.setMargins(skipButton.width, statusBarHeight, rightMargin, 0) + skipButton.requestLayout() + } + + countDownTimer = object : CountDownTimer(4000, 1000) { + override fun onFinish() { + startLoginActivity() + } + + override fun onTick(millisUntilFinished: Long) { + skipButton.text = "跳过\u3000${(millisUntilFinished / 1000)}s" + } + } + } + + override fun initEvent() { + countDownTimer.start() + skipButton.setOnClickListener { + countDownTimer.cancel() + startLoginActivity() + } + } + + fun startLoginActivity() { + startActivity(Intent(this, LoginActivity::class.java)) + finish() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt new file mode 100644 index 0000000..6ef4548 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt @@ -0,0 +1,81 @@ +package com.casic.birmm.inspect.ui + +import android.text.Editable +import android.text.TextWatcher +import android.view.KeyEvent +import android.view.inputmethod.EditorInfo +import android.widget.EditText +import android.widget.TextView +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.casic.birmm.inspect.utils.Constant +import com.casic.birmm.inspect.utils.SaveKeyValues +import com.casic.birmm.inspect.widgets.InputDialog +import kotlinx.android.synthetic.main.activity_login.* + + +class LoginActivity : BaseActivity() { + + companion object { + private const val Tag = "LoginActivity" + } + + override fun initLayoutView(): Int = R.layout.activity_login + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + loginButton.setChangeAlphaWhenPress(true) + val editText: EditText? = inputLayout.editText + editText?.addTextChangedListener(object : TextWatcher { + override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) { + + } + + override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) { + + } + + override fun afterTextChanged(s: Editable) { + if (s.toString().trim { it <= ' ' }.length > 12) { + inputLayout.error = "密码长度超出限制" + } else { + inputLayout.error = null + } + } + }) + //点击输入法键盘"完成" + editText?.setOnEditorActionListener { _: TextView?, actionId: Int, _: KeyEvent? -> + if (actionId == EditorInfo.IME_ACTION_DONE) { +// authenticatePresenter.onReadyRetrofitRequest() + return@setOnEditorActionListener true + } + false + } + + //修改服务器配置 + changeServerConfigView.setOnClickListener { + val defaultValue = SaveKeyValues.getValue( + Constant.DEFAULT_SERVER_CONFIG, + "http://139.198.6.177:8093/" + ) as String + InputDialog.Builder().setContext(this) + .setTitle("请输入后台服务器地址") + .setDefaultValue(defaultValue) + .setNegativeButton("取消") + .setPositiveButton("保存") + .setOnDialogClickListener(object : InputDialog.OnDialogButtonClickListener { + override fun onButtonClick(input: String) { + SaveKeyValues.putValue(Constant.DEFAULT_SERVER_CONFIG, input) + } + }) + .build().show() + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt new file mode 100644 index 0000000..0e97af7 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt @@ -0,0 +1,21 @@ +package com.casic.birmm.inspect.ui + +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity + +class MainActivity : BaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt new file mode 100644 index 0000000..21fbba2 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt @@ -0,0 +1,58 @@ +package com.casic.birmm.inspect.ui + +import android.content.Intent +import android.os.Build +import android.os.Bundle +import android.util.Log +import androidx.appcompat.app.AppCompatActivity +import com.casic.birmm.inspect.utils.Constant +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + companion object { + private const val TAG = "PermissionActivity" + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + if (EasyPermissions.hasPermissions(this, *Constant.USER_PERMISSIONS)) { + startGuideActivity() + } else { + EasyPermissions.requestPermissions( + this, + "需要获取相关权限", + Constant.PERMISSIONS_CODE, + *Constant.USER_PERMISSIONS + ) + } + } else { + startGuideActivity() + } + } + + private fun startGuideActivity() { + startActivity(Intent(this, GuideActivity::class.java)) + finish() + } + + override fun onRequestPermissionsResult( + requestCode: Int, + permissions: Array, + grantResults: IntArray + ) { + super.onRequestPermissionsResult(requestCode, permissions, grantResults) + EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this) + } + + override fun onPermissionsGranted(requestCode: Int, perms: List) { + startGuideActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + Log.e(TAG, "onPermissionsDenied: $perms") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt new file mode 100644 index 0000000..53df6e1 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt @@ -0,0 +1,15 @@ +package com.casic.birmm.inspect.utils + +import android.Manifest + + +object Constant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.ACCESS_LOCATION_EXTRA_COMMANDS, + Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION + ) + + const val PERMISSIONS_CODE = 999 + + const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt new file mode 100644 index 0000000..4c38241 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt @@ -0,0 +1,19 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.view.View +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object OtherUtils { + + //替换Toast + fun showTipsDialog(context: Context, message: String, view: View) { + val tipDialog = QMUITipDialog.Builder(context) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_NOTHING) + .setTipWord(message).create() + tipDialog.show() + view.postDelayed({ + tipDialog.dismiss() + }, 2000) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt b/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt new file mode 100644 index 0000000..04c9f5a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt @@ -0,0 +1,106 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.content.SharedPreferences +import com.casic.birmm.inspect.base.BaseApplication + +object SaveKeyValues { + private var sharedPreferences: SharedPreferences? = null + private var editor: SharedPreferences.Editor? = null + private var fileName: String? = null + + fun initSharedPreferences() { + val packageName = BaseApplication.instance.packageName + //获取到的包名带有“.”方便命名,取最后一个作为sp文件名,例如:com.casic.birmm.inspect + val split = packageName.split(".") + fileName = split[split.size - 1] + } + + /** + * 存储 + */ + fun putValue(key: String?, obj: Any) { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + val editor = sharedPreferences!!.edit() + when (obj) { + is String -> { + editor.putString(key, obj).apply() + } + is Int -> { + editor.putInt(key, obj).apply() + } + is Boolean -> { + editor.putBoolean(key, obj).apply() + } + is Float -> { + editor.putFloat(key, obj).apply() + } + is Long -> { + editor.putLong(key, obj).apply() + } + else -> { + editor.putString(key, obj.toString()).apply() + } + } + } + + /** + * 获取保存的数据 + */ + operator fun getValue(key: String?, defaultObject: Any?): Any? { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + return when (defaultObject) { + is String -> { + sharedPreferences!!.getString(key, defaultObject as String?) + } + is Int -> { + sharedPreferences!!.getInt(key, (defaultObject as Int?)!!) + } + is Boolean -> { + sharedPreferences!!.getBoolean(key, (defaultObject as Boolean?)!!) + } + is Float -> { + sharedPreferences!!.getFloat(key, (defaultObject as Float?)!!) + } + is Long -> { + sharedPreferences!!.getLong(key, (defaultObject as Long?)!!) + } + else -> { + sharedPreferences!!.getString(key, null) + } + } + } + + /** + * 移除某个key值已经对应的值 + */ + fun removeKey(key: String?) { + editor!!.remove(key) + editor!!.commit() + } + + /** + * 清除所有数据 + */ + fun clearAll() { + editor!!.clear() + editor!!.commit() + } + + /** + * 查询某个key是否存在 + */ + fun containsKey(key: String?): Boolean { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + return sharedPreferences!!.contains(key) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt b/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt new file mode 100644 index 0000000..04db86b --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt @@ -0,0 +1,119 @@ +package com.casic.birmm.inspect.widgets + +import android.app.Dialog +import android.content.Context +import android.graphics.Color +import android.graphics.drawable.ColorDrawable +import android.os.Bundle +import android.view.WindowManager +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.utils.OtherUtils +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.dialog_input.* + + +class InputDialog private constructor(builder: Builder) : Dialog(builder.mContext!!) { + + private var ctx: Context? = null + private var title: String? = null + private var value: String? = null + private var positiveBtn: String? = null + private var negativeBtn: String? = null + private var listener: OnDialogButtonClickListener? = null + + init { + this.ctx = builder.mContext + this.title = builder.title + this.value = builder.value + this.positiveBtn = builder.positiveBtn + this.negativeBtn = builder.negativeBtn + this.listener = builder.listener + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + configDialogLayout() + setContentView(R.layout.dialog_input) + setCancelable(false) + setCanceledOnTouchOutside(false) + + dialogTitleView.text = title + value.apply { + dialogInputView.setText(this) + } + + dialogCancelButton.text = negativeBtn + dialogCancelButton.setChangeAlphaWhenPress(true) + dialogCancelButton.setOnClickListener { + this.dismiss() + } + + dialogConfirmButton.text = positiveBtn + dialogConfirmButton.setChangeAlphaWhenPress(true) + dialogConfirmButton.setOnClickListener { + val inputValue = dialogInputView.text.toString().trim() + if (inputValue.isEmpty()) { + OtherUtils.showTipsDialog(ctx!!, "什么都没输入,请重新输入", dialogConfirmButton) + return@setOnClickListener + } + listener?.onButtonClick(inputValue) + this.dismiss() + } + } + + private fun configDialogLayout() { + window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT)) + window?.decorView?.setBackgroundColor(Color.TRANSPARENT) + val params: WindowManager.LayoutParams? = window?.attributes + params?.width = QMUIDisplayHelper.dp2px(ctx, 300) + params?.height = WindowManager.LayoutParams.WRAP_CONTENT + window?.attributes = params + } + + class Builder { + var mContext: Context? = null + var title: String? = null + var value: String? = null + var positiveBtn: String? = null + var negativeBtn: String? = null + var listener: OnDialogButtonClickListener? = null + + fun setContext(context: Context?): Builder { + mContext = context + return this + } + + fun setTitle(title: String?): Builder { + this.title = title + return this + } + + fun setDefaultValue(value: String?): Builder { + this.value = value + return this + } + + fun setPositiveButton(name: String?): Builder { + positiveBtn = name + return this + } + + fun setNegativeButton(name: String?): Builder { + negativeBtn = name + return this + } + + fun setOnDialogClickListener(listener: OnDialogButtonClickListener): Builder { + this.listener = listener + return this + } + + fun build(): InputDialog { + return InputDialog(this) + } + } + + interface OnDialogButtonClickListener { + fun onButtonClick(input: String) + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_dialog_button.xml b/app/src/main/res/drawable/bg_dialog_button.xml new file mode 100644 index 0000000..5f7d57d --- /dev/null +++ b/app/src/main/res/drawable/bg_dialog_button.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_layout_white.xml b/app/src/main/res/drawable/bg_layout_white.xml new file mode 100644 index 0000000..19b473b --- /dev/null +++ b/app/src/main/res/drawable/bg_layout_white.xml @@ -0,0 +1,11 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/guide1.png b/app/src/main/res/drawable/guide1.png new file mode 100644 index 0000000..074c768 --- /dev/null +++ b/app/src/main/res/drawable/guide1.png Binary files differ diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_lock.xml b/app/src/main/res/drawable/ic_lock.xml new file mode 100644 index 0000000..f0a5610 --- /dev/null +++ b/app/src/main/res/drawable/ic_lock.xml @@ -0,0 +1,12 @@ + + + + diff --git a/app/src/main/res/drawable/ic_login_bg.png b/app/src/main/res/drawable/ic_login_bg.png new file mode 100644 index 0000000..64789c3 --- /dev/null +++ b/app/src/main/res/drawable/ic_login_bg.png Binary files differ diff --git a/app/src/main/res/drawable/ic_user.xml b/app/src/main/res/drawable/ic_user.xml new file mode 100644 index 0000000..8c4a29d --- /dev/null +++ b/app/src/main/res/drawable/ic_user.xml @@ -0,0 +1,15 @@ + + + + + diff --git a/app/src/main/res/layout/activity_guide.xml b/app/src/main/res/layout/activity_guide.xml new file mode 100644 index 0000000..e197626 --- /dev/null +++ b/app/src/main/res/layout/activity_guide.xml @@ -0,0 +1,19 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_login.xml b/app/src/main/res/layout/activity_login.xml new file mode 100644 index 0000000..bcae777 --- /dev/null +++ b/app/src/main/res/layout/activity_login.xml @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..def59e4 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,18 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_input.xml b/app/src/main/res/layout/dialog_input.xml new file mode 100644 index 0000000..f5a8bc6 --- /dev/null +++ b/app/src/main/res/layout/dialog_input.xml @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..a571e60 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 0000000..61da551 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..c41dd28 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png new file mode 100644 index 0000000..db5080a --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..6dba46d --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png new file mode 100644 index 0000000..da31a87 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..15ac681 --- /dev/null +++ b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png Binary files differ diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..603b140 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..88ea3aa --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,122 @@ + + + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+ + +
+
\ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..5cd135a --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..7bfef59 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..4ca4a9f --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,67 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' + +android { + compileSdkVersion 30 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.birmm.inspect" + minSdkVersion 21 + targetSdkVersion 30 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'androidx.core:core-ktx:1.3.2' + implementation 'androidx.constraintlayout:constraintlayout:2.0.4' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test.ext:junit:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:1.3.0' + //腾讯Android UI框架 + implementation 'com.qmuiteam:qmui:2.0.0-alpha10' + implementation 'com.qmuiteam:arch:0.3.1' + //沉浸式状态栏。基础依赖包,必须要依赖 + implementation 'com.gyf.immersionbar:immersionbar:3.0.0' + //fragment快速实现 + implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + + //MVP网络请求框架retrofit2+rxjava + implementation 'io.reactivex:rxjava:1.3.8' + implementation 'io.reactivex:rxandroid:1.2.1' + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.6.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + implementation 'com.squareup.retrofit2:adapter-rxjava:2.8.1' + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.8.6' + //Toast提示 + implementation 'com.sdsmdg.tastytoast:tastytoast:0.1.1' + //图片选择框架 + implementation 'com.github.LuckSiege.PictureSelector:picture_library:v2.6.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..ea03309 --- /dev/null +++ b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.casic.birmm.inspect + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.casic.birmm.inspect", appContext.packageName) + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..7096527 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt new file mode 100644 index 0000000..aefdbb6 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt @@ -0,0 +1,36 @@ +package com.casic.birmm.inspect.base + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.qmuiteam.qmui.util.QMUIStatusBarHelper + +abstract class BaseActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(initLayoutView()) + QMUIStatusBarHelper.translucent(this) //沉浸式状态栏 + setupTopBarLayout() + initData() + initEvent() + } + + /** + * 初始化xml布局 + */ + abstract fun initLayoutView(): Int + + /** + * 特定页面定制沉浸式状态栏 + */ + protected abstract fun setupTopBarLayout() + + /** + * 初始化默认数据 + */ + abstract fun initData() + + /** + * 初始化业务逻辑 + */ + abstract fun initEvent() +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt new file mode 100644 index 0000000..fc0ca75 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt @@ -0,0 +1,18 @@ +package com.casic.birmm.inspect.base + +import android.app.Application +import com.casic.birmm.inspect.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + companion object { + var instance: BaseApplication by Delegates.notNull() + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt new file mode 100644 index 0000000..ddc160a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt @@ -0,0 +1,56 @@ +package com.casic.birmm.inspect.ui + +import android.annotation.SuppressLint +import android.content.Intent +import android.os.CountDownTimer +import android.view.ViewGroup.MarginLayoutParams +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.activity_guide.* + +@SuppressLint("SetTextI18n") +class GuideActivity : BaseActivity() { + + private lateinit var countDownTimer: CountDownTimer + + override fun initLayoutView(): Int = R.layout.activity_guide + + override fun setupTopBarLayout() { + + } + + override fun initData() { + //根据不同设备状态栏高度设置"跳过"按钮的Margin值 + val statusBarHeight = QMUIDisplayHelper.getStatusBarHeight(this) + val rightMargin = QMUIDisplayHelper.dp2px(this, 10) + if (skipButton.layoutParams is MarginLayoutParams) { + val params = skipButton.layoutParams as MarginLayoutParams + params.setMargins(skipButton.width, statusBarHeight, rightMargin, 0) + skipButton.requestLayout() + } + + countDownTimer = object : CountDownTimer(4000, 1000) { + override fun onFinish() { + startLoginActivity() + } + + override fun onTick(millisUntilFinished: Long) { + skipButton.text = "跳过\u3000${(millisUntilFinished / 1000)}s" + } + } + } + + override fun initEvent() { + countDownTimer.start() + skipButton.setOnClickListener { + countDownTimer.cancel() + startLoginActivity() + } + } + + fun startLoginActivity() { + startActivity(Intent(this, LoginActivity::class.java)) + finish() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt new file mode 100644 index 0000000..6ef4548 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt @@ -0,0 +1,81 @@ +package com.casic.birmm.inspect.ui + +import android.text.Editable +import android.text.TextWatcher +import android.view.KeyEvent +import android.view.inputmethod.EditorInfo +import android.widget.EditText +import android.widget.TextView +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.casic.birmm.inspect.utils.Constant +import com.casic.birmm.inspect.utils.SaveKeyValues +import com.casic.birmm.inspect.widgets.InputDialog +import kotlinx.android.synthetic.main.activity_login.* + + +class LoginActivity : BaseActivity() { + + companion object { + private const val Tag = "LoginActivity" + } + + override fun initLayoutView(): Int = R.layout.activity_login + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + loginButton.setChangeAlphaWhenPress(true) + val editText: EditText? = inputLayout.editText + editText?.addTextChangedListener(object : TextWatcher { + override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) { + + } + + override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) { + + } + + override fun afterTextChanged(s: Editable) { + if (s.toString().trim { it <= ' ' }.length > 12) { + inputLayout.error = "密码长度超出限制" + } else { + inputLayout.error = null + } + } + }) + //点击输入法键盘"完成" + editText?.setOnEditorActionListener { _: TextView?, actionId: Int, _: KeyEvent? -> + if (actionId == EditorInfo.IME_ACTION_DONE) { +// authenticatePresenter.onReadyRetrofitRequest() + return@setOnEditorActionListener true + } + false + } + + //修改服务器配置 + changeServerConfigView.setOnClickListener { + val defaultValue = SaveKeyValues.getValue( + Constant.DEFAULT_SERVER_CONFIG, + "http://139.198.6.177:8093/" + ) as String + InputDialog.Builder().setContext(this) + .setTitle("请输入后台服务器地址") + .setDefaultValue(defaultValue) + .setNegativeButton("取消") + .setPositiveButton("保存") + .setOnDialogClickListener(object : InputDialog.OnDialogButtonClickListener { + override fun onButtonClick(input: String) { + SaveKeyValues.putValue(Constant.DEFAULT_SERVER_CONFIG, input) + } + }) + .build().show() + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt new file mode 100644 index 0000000..0e97af7 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt @@ -0,0 +1,21 @@ +package com.casic.birmm.inspect.ui + +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity + +class MainActivity : BaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt new file mode 100644 index 0000000..21fbba2 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt @@ -0,0 +1,58 @@ +package com.casic.birmm.inspect.ui + +import android.content.Intent +import android.os.Build +import android.os.Bundle +import android.util.Log +import androidx.appcompat.app.AppCompatActivity +import com.casic.birmm.inspect.utils.Constant +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + companion object { + private const val TAG = "PermissionActivity" + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + if (EasyPermissions.hasPermissions(this, *Constant.USER_PERMISSIONS)) { + startGuideActivity() + } else { + EasyPermissions.requestPermissions( + this, + "需要获取相关权限", + Constant.PERMISSIONS_CODE, + *Constant.USER_PERMISSIONS + ) + } + } else { + startGuideActivity() + } + } + + private fun startGuideActivity() { + startActivity(Intent(this, GuideActivity::class.java)) + finish() + } + + override fun onRequestPermissionsResult( + requestCode: Int, + permissions: Array, + grantResults: IntArray + ) { + super.onRequestPermissionsResult(requestCode, permissions, grantResults) + EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this) + } + + override fun onPermissionsGranted(requestCode: Int, perms: List) { + startGuideActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + Log.e(TAG, "onPermissionsDenied: $perms") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt new file mode 100644 index 0000000..53df6e1 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt @@ -0,0 +1,15 @@ +package com.casic.birmm.inspect.utils + +import android.Manifest + + +object Constant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.ACCESS_LOCATION_EXTRA_COMMANDS, + Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION + ) + + const val PERMISSIONS_CODE = 999 + + const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt new file mode 100644 index 0000000..4c38241 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt @@ -0,0 +1,19 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.view.View +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object OtherUtils { + + //替换Toast + fun showTipsDialog(context: Context, message: String, view: View) { + val tipDialog = QMUITipDialog.Builder(context) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_NOTHING) + .setTipWord(message).create() + tipDialog.show() + view.postDelayed({ + tipDialog.dismiss() + }, 2000) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt b/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt new file mode 100644 index 0000000..04c9f5a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt @@ -0,0 +1,106 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.content.SharedPreferences +import com.casic.birmm.inspect.base.BaseApplication + +object SaveKeyValues { + private var sharedPreferences: SharedPreferences? = null + private var editor: SharedPreferences.Editor? = null + private var fileName: String? = null + + fun initSharedPreferences() { + val packageName = BaseApplication.instance.packageName + //获取到的包名带有“.”方便命名,取最后一个作为sp文件名,例如:com.casic.birmm.inspect + val split = packageName.split(".") + fileName = split[split.size - 1] + } + + /** + * 存储 + */ + fun putValue(key: String?, obj: Any) { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + val editor = sharedPreferences!!.edit() + when (obj) { + is String -> { + editor.putString(key, obj).apply() + } + is Int -> { + editor.putInt(key, obj).apply() + } + is Boolean -> { + editor.putBoolean(key, obj).apply() + } + is Float -> { + editor.putFloat(key, obj).apply() + } + is Long -> { + editor.putLong(key, obj).apply() + } + else -> { + editor.putString(key, obj.toString()).apply() + } + } + } + + /** + * 获取保存的数据 + */ + operator fun getValue(key: String?, defaultObject: Any?): Any? { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + return when (defaultObject) { + is String -> { + sharedPreferences!!.getString(key, defaultObject as String?) + } + is Int -> { + sharedPreferences!!.getInt(key, (defaultObject as Int?)!!) + } + is Boolean -> { + sharedPreferences!!.getBoolean(key, (defaultObject as Boolean?)!!) + } + is Float -> { + sharedPreferences!!.getFloat(key, (defaultObject as Float?)!!) + } + is Long -> { + sharedPreferences!!.getLong(key, (defaultObject as Long?)!!) + } + else -> { + sharedPreferences!!.getString(key, null) + } + } + } + + /** + * 移除某个key值已经对应的值 + */ + fun removeKey(key: String?) { + editor!!.remove(key) + editor!!.commit() + } + + /** + * 清除所有数据 + */ + fun clearAll() { + editor!!.clear() + editor!!.commit() + } + + /** + * 查询某个key是否存在 + */ + fun containsKey(key: String?): Boolean { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + return sharedPreferences!!.contains(key) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt b/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt new file mode 100644 index 0000000..04db86b --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt @@ -0,0 +1,119 @@ +package com.casic.birmm.inspect.widgets + +import android.app.Dialog +import android.content.Context +import android.graphics.Color +import android.graphics.drawable.ColorDrawable +import android.os.Bundle +import android.view.WindowManager +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.utils.OtherUtils +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.dialog_input.* + + +class InputDialog private constructor(builder: Builder) : Dialog(builder.mContext!!) { + + private var ctx: Context? = null + private var title: String? = null + private var value: String? = null + private var positiveBtn: String? = null + private var negativeBtn: String? = null + private var listener: OnDialogButtonClickListener? = null + + init { + this.ctx = builder.mContext + this.title = builder.title + this.value = builder.value + this.positiveBtn = builder.positiveBtn + this.negativeBtn = builder.negativeBtn + this.listener = builder.listener + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + configDialogLayout() + setContentView(R.layout.dialog_input) + setCancelable(false) + setCanceledOnTouchOutside(false) + + dialogTitleView.text = title + value.apply { + dialogInputView.setText(this) + } + + dialogCancelButton.text = negativeBtn + dialogCancelButton.setChangeAlphaWhenPress(true) + dialogCancelButton.setOnClickListener { + this.dismiss() + } + + dialogConfirmButton.text = positiveBtn + dialogConfirmButton.setChangeAlphaWhenPress(true) + dialogConfirmButton.setOnClickListener { + val inputValue = dialogInputView.text.toString().trim() + if (inputValue.isEmpty()) { + OtherUtils.showTipsDialog(ctx!!, "什么都没输入,请重新输入", dialogConfirmButton) + return@setOnClickListener + } + listener?.onButtonClick(inputValue) + this.dismiss() + } + } + + private fun configDialogLayout() { + window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT)) + window?.decorView?.setBackgroundColor(Color.TRANSPARENT) + val params: WindowManager.LayoutParams? = window?.attributes + params?.width = QMUIDisplayHelper.dp2px(ctx, 300) + params?.height = WindowManager.LayoutParams.WRAP_CONTENT + window?.attributes = params + } + + class Builder { + var mContext: Context? = null + var title: String? = null + var value: String? = null + var positiveBtn: String? = null + var negativeBtn: String? = null + var listener: OnDialogButtonClickListener? = null + + fun setContext(context: Context?): Builder { + mContext = context + return this + } + + fun setTitle(title: String?): Builder { + this.title = title + return this + } + + fun setDefaultValue(value: String?): Builder { + this.value = value + return this + } + + fun setPositiveButton(name: String?): Builder { + positiveBtn = name + return this + } + + fun setNegativeButton(name: String?): Builder { + negativeBtn = name + return this + } + + fun setOnDialogClickListener(listener: OnDialogButtonClickListener): Builder { + this.listener = listener + return this + } + + fun build(): InputDialog { + return InputDialog(this) + } + } + + interface OnDialogButtonClickListener { + fun onButtonClick(input: String) + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_dialog_button.xml b/app/src/main/res/drawable/bg_dialog_button.xml new file mode 100644 index 0000000..5f7d57d --- /dev/null +++ b/app/src/main/res/drawable/bg_dialog_button.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_layout_white.xml b/app/src/main/res/drawable/bg_layout_white.xml new file mode 100644 index 0000000..19b473b --- /dev/null +++ b/app/src/main/res/drawable/bg_layout_white.xml @@ -0,0 +1,11 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/guide1.png b/app/src/main/res/drawable/guide1.png new file mode 100644 index 0000000..074c768 --- /dev/null +++ b/app/src/main/res/drawable/guide1.png Binary files differ diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_lock.xml b/app/src/main/res/drawable/ic_lock.xml new file mode 100644 index 0000000..f0a5610 --- /dev/null +++ b/app/src/main/res/drawable/ic_lock.xml @@ -0,0 +1,12 @@ + + + + diff --git a/app/src/main/res/drawable/ic_login_bg.png b/app/src/main/res/drawable/ic_login_bg.png new file mode 100644 index 0000000..64789c3 --- /dev/null +++ b/app/src/main/res/drawable/ic_login_bg.png Binary files differ diff --git a/app/src/main/res/drawable/ic_user.xml b/app/src/main/res/drawable/ic_user.xml new file mode 100644 index 0000000..8c4a29d --- /dev/null +++ b/app/src/main/res/drawable/ic_user.xml @@ -0,0 +1,15 @@ + + + + + diff --git a/app/src/main/res/layout/activity_guide.xml b/app/src/main/res/layout/activity_guide.xml new file mode 100644 index 0000000..e197626 --- /dev/null +++ b/app/src/main/res/layout/activity_guide.xml @@ -0,0 +1,19 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_login.xml b/app/src/main/res/layout/activity_login.xml new file mode 100644 index 0000000..bcae777 --- /dev/null +++ b/app/src/main/res/layout/activity_login.xml @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..def59e4 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,18 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_input.xml b/app/src/main/res/layout/dialog_input.xml new file mode 100644 index 0000000..f5a8bc6 --- /dev/null +++ b/app/src/main/res/layout/dialog_input.xml @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..a571e60 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 0000000..61da551 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..c41dd28 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png new file mode 100644 index 0000000..db5080a --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..6dba46d --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png new file mode 100644 index 0000000..da31a87 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..15ac681 --- /dev/null +++ b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..b216f2d --- /dev/null +++ b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png Binary files differ diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..603b140 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..88ea3aa --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,122 @@ + + + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+ + +
+
\ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..5cd135a --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..7bfef59 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..4ca4a9f --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,67 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' + +android { + compileSdkVersion 30 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.birmm.inspect" + minSdkVersion 21 + targetSdkVersion 30 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'androidx.core:core-ktx:1.3.2' + implementation 'androidx.constraintlayout:constraintlayout:2.0.4' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test.ext:junit:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:1.3.0' + //腾讯Android UI框架 + implementation 'com.qmuiteam:qmui:2.0.0-alpha10' + implementation 'com.qmuiteam:arch:0.3.1' + //沉浸式状态栏。基础依赖包,必须要依赖 + implementation 'com.gyf.immersionbar:immersionbar:3.0.0' + //fragment快速实现 + implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + + //MVP网络请求框架retrofit2+rxjava + implementation 'io.reactivex:rxjava:1.3.8' + implementation 'io.reactivex:rxandroid:1.2.1' + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.6.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + implementation 'com.squareup.retrofit2:adapter-rxjava:2.8.1' + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.8.6' + //Toast提示 + implementation 'com.sdsmdg.tastytoast:tastytoast:0.1.1' + //图片选择框架 + implementation 'com.github.LuckSiege.PictureSelector:picture_library:v2.6.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..ea03309 --- /dev/null +++ b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.casic.birmm.inspect + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.casic.birmm.inspect", appContext.packageName) + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..7096527 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt new file mode 100644 index 0000000..aefdbb6 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt @@ -0,0 +1,36 @@ +package com.casic.birmm.inspect.base + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.qmuiteam.qmui.util.QMUIStatusBarHelper + +abstract class BaseActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(initLayoutView()) + QMUIStatusBarHelper.translucent(this) //沉浸式状态栏 + setupTopBarLayout() + initData() + initEvent() + } + + /** + * 初始化xml布局 + */ + abstract fun initLayoutView(): Int + + /** + * 特定页面定制沉浸式状态栏 + */ + protected abstract fun setupTopBarLayout() + + /** + * 初始化默认数据 + */ + abstract fun initData() + + /** + * 初始化业务逻辑 + */ + abstract fun initEvent() +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt new file mode 100644 index 0000000..fc0ca75 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt @@ -0,0 +1,18 @@ +package com.casic.birmm.inspect.base + +import android.app.Application +import com.casic.birmm.inspect.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + companion object { + var instance: BaseApplication by Delegates.notNull() + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt new file mode 100644 index 0000000..ddc160a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt @@ -0,0 +1,56 @@ +package com.casic.birmm.inspect.ui + +import android.annotation.SuppressLint +import android.content.Intent +import android.os.CountDownTimer +import android.view.ViewGroup.MarginLayoutParams +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.activity_guide.* + +@SuppressLint("SetTextI18n") +class GuideActivity : BaseActivity() { + + private lateinit var countDownTimer: CountDownTimer + + override fun initLayoutView(): Int = R.layout.activity_guide + + override fun setupTopBarLayout() { + + } + + override fun initData() { + //根据不同设备状态栏高度设置"跳过"按钮的Margin值 + val statusBarHeight = QMUIDisplayHelper.getStatusBarHeight(this) + val rightMargin = QMUIDisplayHelper.dp2px(this, 10) + if (skipButton.layoutParams is MarginLayoutParams) { + val params = skipButton.layoutParams as MarginLayoutParams + params.setMargins(skipButton.width, statusBarHeight, rightMargin, 0) + skipButton.requestLayout() + } + + countDownTimer = object : CountDownTimer(4000, 1000) { + override fun onFinish() { + startLoginActivity() + } + + override fun onTick(millisUntilFinished: Long) { + skipButton.text = "跳过\u3000${(millisUntilFinished / 1000)}s" + } + } + } + + override fun initEvent() { + countDownTimer.start() + skipButton.setOnClickListener { + countDownTimer.cancel() + startLoginActivity() + } + } + + fun startLoginActivity() { + startActivity(Intent(this, LoginActivity::class.java)) + finish() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt new file mode 100644 index 0000000..6ef4548 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt @@ -0,0 +1,81 @@ +package com.casic.birmm.inspect.ui + +import android.text.Editable +import android.text.TextWatcher +import android.view.KeyEvent +import android.view.inputmethod.EditorInfo +import android.widget.EditText +import android.widget.TextView +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.casic.birmm.inspect.utils.Constant +import com.casic.birmm.inspect.utils.SaveKeyValues +import com.casic.birmm.inspect.widgets.InputDialog +import kotlinx.android.synthetic.main.activity_login.* + + +class LoginActivity : BaseActivity() { + + companion object { + private const val Tag = "LoginActivity" + } + + override fun initLayoutView(): Int = R.layout.activity_login + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + loginButton.setChangeAlphaWhenPress(true) + val editText: EditText? = inputLayout.editText + editText?.addTextChangedListener(object : TextWatcher { + override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) { + + } + + override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) { + + } + + override fun afterTextChanged(s: Editable) { + if (s.toString().trim { it <= ' ' }.length > 12) { + inputLayout.error = "密码长度超出限制" + } else { + inputLayout.error = null + } + } + }) + //点击输入法键盘"完成" + editText?.setOnEditorActionListener { _: TextView?, actionId: Int, _: KeyEvent? -> + if (actionId == EditorInfo.IME_ACTION_DONE) { +// authenticatePresenter.onReadyRetrofitRequest() + return@setOnEditorActionListener true + } + false + } + + //修改服务器配置 + changeServerConfigView.setOnClickListener { + val defaultValue = SaveKeyValues.getValue( + Constant.DEFAULT_SERVER_CONFIG, + "http://139.198.6.177:8093/" + ) as String + InputDialog.Builder().setContext(this) + .setTitle("请输入后台服务器地址") + .setDefaultValue(defaultValue) + .setNegativeButton("取消") + .setPositiveButton("保存") + .setOnDialogClickListener(object : InputDialog.OnDialogButtonClickListener { + override fun onButtonClick(input: String) { + SaveKeyValues.putValue(Constant.DEFAULT_SERVER_CONFIG, input) + } + }) + .build().show() + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt new file mode 100644 index 0000000..0e97af7 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt @@ -0,0 +1,21 @@ +package com.casic.birmm.inspect.ui + +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity + +class MainActivity : BaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt new file mode 100644 index 0000000..21fbba2 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt @@ -0,0 +1,58 @@ +package com.casic.birmm.inspect.ui + +import android.content.Intent +import android.os.Build +import android.os.Bundle +import android.util.Log +import androidx.appcompat.app.AppCompatActivity +import com.casic.birmm.inspect.utils.Constant +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + companion object { + private const val TAG = "PermissionActivity" + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + if (EasyPermissions.hasPermissions(this, *Constant.USER_PERMISSIONS)) { + startGuideActivity() + } else { + EasyPermissions.requestPermissions( + this, + "需要获取相关权限", + Constant.PERMISSIONS_CODE, + *Constant.USER_PERMISSIONS + ) + } + } else { + startGuideActivity() + } + } + + private fun startGuideActivity() { + startActivity(Intent(this, GuideActivity::class.java)) + finish() + } + + override fun onRequestPermissionsResult( + requestCode: Int, + permissions: Array, + grantResults: IntArray + ) { + super.onRequestPermissionsResult(requestCode, permissions, grantResults) + EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this) + } + + override fun onPermissionsGranted(requestCode: Int, perms: List) { + startGuideActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + Log.e(TAG, "onPermissionsDenied: $perms") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt new file mode 100644 index 0000000..53df6e1 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt @@ -0,0 +1,15 @@ +package com.casic.birmm.inspect.utils + +import android.Manifest + + +object Constant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.ACCESS_LOCATION_EXTRA_COMMANDS, + Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION + ) + + const val PERMISSIONS_CODE = 999 + + const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt new file mode 100644 index 0000000..4c38241 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt @@ -0,0 +1,19 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.view.View +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object OtherUtils { + + //替换Toast + fun showTipsDialog(context: Context, message: String, view: View) { + val tipDialog = QMUITipDialog.Builder(context) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_NOTHING) + .setTipWord(message).create() + tipDialog.show() + view.postDelayed({ + tipDialog.dismiss() + }, 2000) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt b/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt new file mode 100644 index 0000000..04c9f5a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt @@ -0,0 +1,106 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.content.SharedPreferences +import com.casic.birmm.inspect.base.BaseApplication + +object SaveKeyValues { + private var sharedPreferences: SharedPreferences? = null + private var editor: SharedPreferences.Editor? = null + private var fileName: String? = null + + fun initSharedPreferences() { + val packageName = BaseApplication.instance.packageName + //获取到的包名带有“.”方便命名,取最后一个作为sp文件名,例如:com.casic.birmm.inspect + val split = packageName.split(".") + fileName = split[split.size - 1] + } + + /** + * 存储 + */ + fun putValue(key: String?, obj: Any) { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + val editor = sharedPreferences!!.edit() + when (obj) { + is String -> { + editor.putString(key, obj).apply() + } + is Int -> { + editor.putInt(key, obj).apply() + } + is Boolean -> { + editor.putBoolean(key, obj).apply() + } + is Float -> { + editor.putFloat(key, obj).apply() + } + is Long -> { + editor.putLong(key, obj).apply() + } + else -> { + editor.putString(key, obj.toString()).apply() + } + } + } + + /** + * 获取保存的数据 + */ + operator fun getValue(key: String?, defaultObject: Any?): Any? { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + return when (defaultObject) { + is String -> { + sharedPreferences!!.getString(key, defaultObject as String?) + } + is Int -> { + sharedPreferences!!.getInt(key, (defaultObject as Int?)!!) + } + is Boolean -> { + sharedPreferences!!.getBoolean(key, (defaultObject as Boolean?)!!) + } + is Float -> { + sharedPreferences!!.getFloat(key, (defaultObject as Float?)!!) + } + is Long -> { + sharedPreferences!!.getLong(key, (defaultObject as Long?)!!) + } + else -> { + sharedPreferences!!.getString(key, null) + } + } + } + + /** + * 移除某个key值已经对应的值 + */ + fun removeKey(key: String?) { + editor!!.remove(key) + editor!!.commit() + } + + /** + * 清除所有数据 + */ + fun clearAll() { + editor!!.clear() + editor!!.commit() + } + + /** + * 查询某个key是否存在 + */ + fun containsKey(key: String?): Boolean { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + return sharedPreferences!!.contains(key) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt b/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt new file mode 100644 index 0000000..04db86b --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt @@ -0,0 +1,119 @@ +package com.casic.birmm.inspect.widgets + +import android.app.Dialog +import android.content.Context +import android.graphics.Color +import android.graphics.drawable.ColorDrawable +import android.os.Bundle +import android.view.WindowManager +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.utils.OtherUtils +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.dialog_input.* + + +class InputDialog private constructor(builder: Builder) : Dialog(builder.mContext!!) { + + private var ctx: Context? = null + private var title: String? = null + private var value: String? = null + private var positiveBtn: String? = null + private var negativeBtn: String? = null + private var listener: OnDialogButtonClickListener? = null + + init { + this.ctx = builder.mContext + this.title = builder.title + this.value = builder.value + this.positiveBtn = builder.positiveBtn + this.negativeBtn = builder.negativeBtn + this.listener = builder.listener + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + configDialogLayout() + setContentView(R.layout.dialog_input) + setCancelable(false) + setCanceledOnTouchOutside(false) + + dialogTitleView.text = title + value.apply { + dialogInputView.setText(this) + } + + dialogCancelButton.text = negativeBtn + dialogCancelButton.setChangeAlphaWhenPress(true) + dialogCancelButton.setOnClickListener { + this.dismiss() + } + + dialogConfirmButton.text = positiveBtn + dialogConfirmButton.setChangeAlphaWhenPress(true) + dialogConfirmButton.setOnClickListener { + val inputValue = dialogInputView.text.toString().trim() + if (inputValue.isEmpty()) { + OtherUtils.showTipsDialog(ctx!!, "什么都没输入,请重新输入", dialogConfirmButton) + return@setOnClickListener + } + listener?.onButtonClick(inputValue) + this.dismiss() + } + } + + private fun configDialogLayout() { + window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT)) + window?.decorView?.setBackgroundColor(Color.TRANSPARENT) + val params: WindowManager.LayoutParams? = window?.attributes + params?.width = QMUIDisplayHelper.dp2px(ctx, 300) + params?.height = WindowManager.LayoutParams.WRAP_CONTENT + window?.attributes = params + } + + class Builder { + var mContext: Context? = null + var title: String? = null + var value: String? = null + var positiveBtn: String? = null + var negativeBtn: String? = null + var listener: OnDialogButtonClickListener? = null + + fun setContext(context: Context?): Builder { + mContext = context + return this + } + + fun setTitle(title: String?): Builder { + this.title = title + return this + } + + fun setDefaultValue(value: String?): Builder { + this.value = value + return this + } + + fun setPositiveButton(name: String?): Builder { + positiveBtn = name + return this + } + + fun setNegativeButton(name: String?): Builder { + negativeBtn = name + return this + } + + fun setOnDialogClickListener(listener: OnDialogButtonClickListener): Builder { + this.listener = listener + return this + } + + fun build(): InputDialog { + return InputDialog(this) + } + } + + interface OnDialogButtonClickListener { + fun onButtonClick(input: String) + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_dialog_button.xml b/app/src/main/res/drawable/bg_dialog_button.xml new file mode 100644 index 0000000..5f7d57d --- /dev/null +++ b/app/src/main/res/drawable/bg_dialog_button.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_layout_white.xml b/app/src/main/res/drawable/bg_layout_white.xml new file mode 100644 index 0000000..19b473b --- /dev/null +++ b/app/src/main/res/drawable/bg_layout_white.xml @@ -0,0 +1,11 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/guide1.png b/app/src/main/res/drawable/guide1.png new file mode 100644 index 0000000..074c768 --- /dev/null +++ b/app/src/main/res/drawable/guide1.png Binary files differ diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_lock.xml b/app/src/main/res/drawable/ic_lock.xml new file mode 100644 index 0000000..f0a5610 --- /dev/null +++ b/app/src/main/res/drawable/ic_lock.xml @@ -0,0 +1,12 @@ + + + + diff --git a/app/src/main/res/drawable/ic_login_bg.png b/app/src/main/res/drawable/ic_login_bg.png new file mode 100644 index 0000000..64789c3 --- /dev/null +++ b/app/src/main/res/drawable/ic_login_bg.png Binary files differ diff --git a/app/src/main/res/drawable/ic_user.xml b/app/src/main/res/drawable/ic_user.xml new file mode 100644 index 0000000..8c4a29d --- /dev/null +++ b/app/src/main/res/drawable/ic_user.xml @@ -0,0 +1,15 @@ + + + + + diff --git a/app/src/main/res/layout/activity_guide.xml b/app/src/main/res/layout/activity_guide.xml new file mode 100644 index 0000000..e197626 --- /dev/null +++ b/app/src/main/res/layout/activity_guide.xml @@ -0,0 +1,19 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_login.xml b/app/src/main/res/layout/activity_login.xml new file mode 100644 index 0000000..bcae777 --- /dev/null +++ b/app/src/main/res/layout/activity_login.xml @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..def59e4 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,18 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_input.xml b/app/src/main/res/layout/dialog_input.xml new file mode 100644 index 0000000..f5a8bc6 --- /dev/null +++ b/app/src/main/res/layout/dialog_input.xml @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..a571e60 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 0000000..61da551 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..c41dd28 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png new file mode 100644 index 0000000..db5080a --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..6dba46d --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png new file mode 100644 index 0000000..da31a87 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..15ac681 --- /dev/null +++ b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..b216f2d --- /dev/null +++ b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..f25a419 --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png Binary files differ diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..603b140 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..88ea3aa --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,122 @@ + + + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+ + +
+
\ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..5cd135a --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..7bfef59 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..4ca4a9f --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,67 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' + +android { + compileSdkVersion 30 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.birmm.inspect" + minSdkVersion 21 + targetSdkVersion 30 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'androidx.core:core-ktx:1.3.2' + implementation 'androidx.constraintlayout:constraintlayout:2.0.4' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test.ext:junit:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:1.3.0' + //腾讯Android UI框架 + implementation 'com.qmuiteam:qmui:2.0.0-alpha10' + implementation 'com.qmuiteam:arch:0.3.1' + //沉浸式状态栏。基础依赖包,必须要依赖 + implementation 'com.gyf.immersionbar:immersionbar:3.0.0' + //fragment快速实现 + implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + + //MVP网络请求框架retrofit2+rxjava + implementation 'io.reactivex:rxjava:1.3.8' + implementation 'io.reactivex:rxandroid:1.2.1' + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.6.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + implementation 'com.squareup.retrofit2:adapter-rxjava:2.8.1' + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.8.6' + //Toast提示 + implementation 'com.sdsmdg.tastytoast:tastytoast:0.1.1' + //图片选择框架 + implementation 'com.github.LuckSiege.PictureSelector:picture_library:v2.6.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..ea03309 --- /dev/null +++ b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.casic.birmm.inspect + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.casic.birmm.inspect", appContext.packageName) + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..7096527 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt new file mode 100644 index 0000000..aefdbb6 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt @@ -0,0 +1,36 @@ +package com.casic.birmm.inspect.base + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.qmuiteam.qmui.util.QMUIStatusBarHelper + +abstract class BaseActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(initLayoutView()) + QMUIStatusBarHelper.translucent(this) //沉浸式状态栏 + setupTopBarLayout() + initData() + initEvent() + } + + /** + * 初始化xml布局 + */ + abstract fun initLayoutView(): Int + + /** + * 特定页面定制沉浸式状态栏 + */ + protected abstract fun setupTopBarLayout() + + /** + * 初始化默认数据 + */ + abstract fun initData() + + /** + * 初始化业务逻辑 + */ + abstract fun initEvent() +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt new file mode 100644 index 0000000..fc0ca75 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt @@ -0,0 +1,18 @@ +package com.casic.birmm.inspect.base + +import android.app.Application +import com.casic.birmm.inspect.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + companion object { + var instance: BaseApplication by Delegates.notNull() + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt new file mode 100644 index 0000000..ddc160a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt @@ -0,0 +1,56 @@ +package com.casic.birmm.inspect.ui + +import android.annotation.SuppressLint +import android.content.Intent +import android.os.CountDownTimer +import android.view.ViewGroup.MarginLayoutParams +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.activity_guide.* + +@SuppressLint("SetTextI18n") +class GuideActivity : BaseActivity() { + + private lateinit var countDownTimer: CountDownTimer + + override fun initLayoutView(): Int = R.layout.activity_guide + + override fun setupTopBarLayout() { + + } + + override fun initData() { + //根据不同设备状态栏高度设置"跳过"按钮的Margin值 + val statusBarHeight = QMUIDisplayHelper.getStatusBarHeight(this) + val rightMargin = QMUIDisplayHelper.dp2px(this, 10) + if (skipButton.layoutParams is MarginLayoutParams) { + val params = skipButton.layoutParams as MarginLayoutParams + params.setMargins(skipButton.width, statusBarHeight, rightMargin, 0) + skipButton.requestLayout() + } + + countDownTimer = object : CountDownTimer(4000, 1000) { + override fun onFinish() { + startLoginActivity() + } + + override fun onTick(millisUntilFinished: Long) { + skipButton.text = "跳过\u3000${(millisUntilFinished / 1000)}s" + } + } + } + + override fun initEvent() { + countDownTimer.start() + skipButton.setOnClickListener { + countDownTimer.cancel() + startLoginActivity() + } + } + + fun startLoginActivity() { + startActivity(Intent(this, LoginActivity::class.java)) + finish() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt new file mode 100644 index 0000000..6ef4548 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt @@ -0,0 +1,81 @@ +package com.casic.birmm.inspect.ui + +import android.text.Editable +import android.text.TextWatcher +import android.view.KeyEvent +import android.view.inputmethod.EditorInfo +import android.widget.EditText +import android.widget.TextView +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.casic.birmm.inspect.utils.Constant +import com.casic.birmm.inspect.utils.SaveKeyValues +import com.casic.birmm.inspect.widgets.InputDialog +import kotlinx.android.synthetic.main.activity_login.* + + +class LoginActivity : BaseActivity() { + + companion object { + private const val Tag = "LoginActivity" + } + + override fun initLayoutView(): Int = R.layout.activity_login + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + loginButton.setChangeAlphaWhenPress(true) + val editText: EditText? = inputLayout.editText + editText?.addTextChangedListener(object : TextWatcher { + override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) { + + } + + override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) { + + } + + override fun afterTextChanged(s: Editable) { + if (s.toString().trim { it <= ' ' }.length > 12) { + inputLayout.error = "密码长度超出限制" + } else { + inputLayout.error = null + } + } + }) + //点击输入法键盘"完成" + editText?.setOnEditorActionListener { _: TextView?, actionId: Int, _: KeyEvent? -> + if (actionId == EditorInfo.IME_ACTION_DONE) { +// authenticatePresenter.onReadyRetrofitRequest() + return@setOnEditorActionListener true + } + false + } + + //修改服务器配置 + changeServerConfigView.setOnClickListener { + val defaultValue = SaveKeyValues.getValue( + Constant.DEFAULT_SERVER_CONFIG, + "http://139.198.6.177:8093/" + ) as String + InputDialog.Builder().setContext(this) + .setTitle("请输入后台服务器地址") + .setDefaultValue(defaultValue) + .setNegativeButton("取消") + .setPositiveButton("保存") + .setOnDialogClickListener(object : InputDialog.OnDialogButtonClickListener { + override fun onButtonClick(input: String) { + SaveKeyValues.putValue(Constant.DEFAULT_SERVER_CONFIG, input) + } + }) + .build().show() + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt new file mode 100644 index 0000000..0e97af7 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt @@ -0,0 +1,21 @@ +package com.casic.birmm.inspect.ui + +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity + +class MainActivity : BaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt new file mode 100644 index 0000000..21fbba2 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt @@ -0,0 +1,58 @@ +package com.casic.birmm.inspect.ui + +import android.content.Intent +import android.os.Build +import android.os.Bundle +import android.util.Log +import androidx.appcompat.app.AppCompatActivity +import com.casic.birmm.inspect.utils.Constant +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + companion object { + private const val TAG = "PermissionActivity" + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + if (EasyPermissions.hasPermissions(this, *Constant.USER_PERMISSIONS)) { + startGuideActivity() + } else { + EasyPermissions.requestPermissions( + this, + "需要获取相关权限", + Constant.PERMISSIONS_CODE, + *Constant.USER_PERMISSIONS + ) + } + } else { + startGuideActivity() + } + } + + private fun startGuideActivity() { + startActivity(Intent(this, GuideActivity::class.java)) + finish() + } + + override fun onRequestPermissionsResult( + requestCode: Int, + permissions: Array, + grantResults: IntArray + ) { + super.onRequestPermissionsResult(requestCode, permissions, grantResults) + EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this) + } + + override fun onPermissionsGranted(requestCode: Int, perms: List) { + startGuideActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + Log.e(TAG, "onPermissionsDenied: $perms") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt new file mode 100644 index 0000000..53df6e1 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt @@ -0,0 +1,15 @@ +package com.casic.birmm.inspect.utils + +import android.Manifest + + +object Constant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.ACCESS_LOCATION_EXTRA_COMMANDS, + Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION + ) + + const val PERMISSIONS_CODE = 999 + + const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt new file mode 100644 index 0000000..4c38241 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt @@ -0,0 +1,19 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.view.View +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object OtherUtils { + + //替换Toast + fun showTipsDialog(context: Context, message: String, view: View) { + val tipDialog = QMUITipDialog.Builder(context) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_NOTHING) + .setTipWord(message).create() + tipDialog.show() + view.postDelayed({ + tipDialog.dismiss() + }, 2000) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt b/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt new file mode 100644 index 0000000..04c9f5a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt @@ -0,0 +1,106 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.content.SharedPreferences +import com.casic.birmm.inspect.base.BaseApplication + +object SaveKeyValues { + private var sharedPreferences: SharedPreferences? = null + private var editor: SharedPreferences.Editor? = null + private var fileName: String? = null + + fun initSharedPreferences() { + val packageName = BaseApplication.instance.packageName + //获取到的包名带有“.”方便命名,取最后一个作为sp文件名,例如:com.casic.birmm.inspect + val split = packageName.split(".") + fileName = split[split.size - 1] + } + + /** + * 存储 + */ + fun putValue(key: String?, obj: Any) { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + val editor = sharedPreferences!!.edit() + when (obj) { + is String -> { + editor.putString(key, obj).apply() + } + is Int -> { + editor.putInt(key, obj).apply() + } + is Boolean -> { + editor.putBoolean(key, obj).apply() + } + is Float -> { + editor.putFloat(key, obj).apply() + } + is Long -> { + editor.putLong(key, obj).apply() + } + else -> { + editor.putString(key, obj.toString()).apply() + } + } + } + + /** + * 获取保存的数据 + */ + operator fun getValue(key: String?, defaultObject: Any?): Any? { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + return when (defaultObject) { + is String -> { + sharedPreferences!!.getString(key, defaultObject as String?) + } + is Int -> { + sharedPreferences!!.getInt(key, (defaultObject as Int?)!!) + } + is Boolean -> { + sharedPreferences!!.getBoolean(key, (defaultObject as Boolean?)!!) + } + is Float -> { + sharedPreferences!!.getFloat(key, (defaultObject as Float?)!!) + } + is Long -> { + sharedPreferences!!.getLong(key, (defaultObject as Long?)!!) + } + else -> { + sharedPreferences!!.getString(key, null) + } + } + } + + /** + * 移除某个key值已经对应的值 + */ + fun removeKey(key: String?) { + editor!!.remove(key) + editor!!.commit() + } + + /** + * 清除所有数据 + */ + fun clearAll() { + editor!!.clear() + editor!!.commit() + } + + /** + * 查询某个key是否存在 + */ + fun containsKey(key: String?): Boolean { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + return sharedPreferences!!.contains(key) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt b/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt new file mode 100644 index 0000000..04db86b --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt @@ -0,0 +1,119 @@ +package com.casic.birmm.inspect.widgets + +import android.app.Dialog +import android.content.Context +import android.graphics.Color +import android.graphics.drawable.ColorDrawable +import android.os.Bundle +import android.view.WindowManager +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.utils.OtherUtils +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.dialog_input.* + + +class InputDialog private constructor(builder: Builder) : Dialog(builder.mContext!!) { + + private var ctx: Context? = null + private var title: String? = null + private var value: String? = null + private var positiveBtn: String? = null + private var negativeBtn: String? = null + private var listener: OnDialogButtonClickListener? = null + + init { + this.ctx = builder.mContext + this.title = builder.title + this.value = builder.value + this.positiveBtn = builder.positiveBtn + this.negativeBtn = builder.negativeBtn + this.listener = builder.listener + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + configDialogLayout() + setContentView(R.layout.dialog_input) + setCancelable(false) + setCanceledOnTouchOutside(false) + + dialogTitleView.text = title + value.apply { + dialogInputView.setText(this) + } + + dialogCancelButton.text = negativeBtn + dialogCancelButton.setChangeAlphaWhenPress(true) + dialogCancelButton.setOnClickListener { + this.dismiss() + } + + dialogConfirmButton.text = positiveBtn + dialogConfirmButton.setChangeAlphaWhenPress(true) + dialogConfirmButton.setOnClickListener { + val inputValue = dialogInputView.text.toString().trim() + if (inputValue.isEmpty()) { + OtherUtils.showTipsDialog(ctx!!, "什么都没输入,请重新输入", dialogConfirmButton) + return@setOnClickListener + } + listener?.onButtonClick(inputValue) + this.dismiss() + } + } + + private fun configDialogLayout() { + window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT)) + window?.decorView?.setBackgroundColor(Color.TRANSPARENT) + val params: WindowManager.LayoutParams? = window?.attributes + params?.width = QMUIDisplayHelper.dp2px(ctx, 300) + params?.height = WindowManager.LayoutParams.WRAP_CONTENT + window?.attributes = params + } + + class Builder { + var mContext: Context? = null + var title: String? = null + var value: String? = null + var positiveBtn: String? = null + var negativeBtn: String? = null + var listener: OnDialogButtonClickListener? = null + + fun setContext(context: Context?): Builder { + mContext = context + return this + } + + fun setTitle(title: String?): Builder { + this.title = title + return this + } + + fun setDefaultValue(value: String?): Builder { + this.value = value + return this + } + + fun setPositiveButton(name: String?): Builder { + positiveBtn = name + return this + } + + fun setNegativeButton(name: String?): Builder { + negativeBtn = name + return this + } + + fun setOnDialogClickListener(listener: OnDialogButtonClickListener): Builder { + this.listener = listener + return this + } + + fun build(): InputDialog { + return InputDialog(this) + } + } + + interface OnDialogButtonClickListener { + fun onButtonClick(input: String) + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_dialog_button.xml b/app/src/main/res/drawable/bg_dialog_button.xml new file mode 100644 index 0000000..5f7d57d --- /dev/null +++ b/app/src/main/res/drawable/bg_dialog_button.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_layout_white.xml b/app/src/main/res/drawable/bg_layout_white.xml new file mode 100644 index 0000000..19b473b --- /dev/null +++ b/app/src/main/res/drawable/bg_layout_white.xml @@ -0,0 +1,11 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/guide1.png b/app/src/main/res/drawable/guide1.png new file mode 100644 index 0000000..074c768 --- /dev/null +++ b/app/src/main/res/drawable/guide1.png Binary files differ diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_lock.xml b/app/src/main/res/drawable/ic_lock.xml new file mode 100644 index 0000000..f0a5610 --- /dev/null +++ b/app/src/main/res/drawable/ic_lock.xml @@ -0,0 +1,12 @@ + + + + diff --git a/app/src/main/res/drawable/ic_login_bg.png b/app/src/main/res/drawable/ic_login_bg.png new file mode 100644 index 0000000..64789c3 --- /dev/null +++ b/app/src/main/res/drawable/ic_login_bg.png Binary files differ diff --git a/app/src/main/res/drawable/ic_user.xml b/app/src/main/res/drawable/ic_user.xml new file mode 100644 index 0000000..8c4a29d --- /dev/null +++ b/app/src/main/res/drawable/ic_user.xml @@ -0,0 +1,15 @@ + + + + + diff --git a/app/src/main/res/layout/activity_guide.xml b/app/src/main/res/layout/activity_guide.xml new file mode 100644 index 0000000..e197626 --- /dev/null +++ b/app/src/main/res/layout/activity_guide.xml @@ -0,0 +1,19 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_login.xml b/app/src/main/res/layout/activity_login.xml new file mode 100644 index 0000000..bcae777 --- /dev/null +++ b/app/src/main/res/layout/activity_login.xml @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..def59e4 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,18 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_input.xml b/app/src/main/res/layout/dialog_input.xml new file mode 100644 index 0000000..f5a8bc6 --- /dev/null +++ b/app/src/main/res/layout/dialog_input.xml @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..a571e60 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 0000000..61da551 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..c41dd28 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png new file mode 100644 index 0000000..db5080a --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..6dba46d --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png new file mode 100644 index 0000000..da31a87 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..15ac681 --- /dev/null +++ b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..b216f2d --- /dev/null +++ b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..f25a419 --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..e96783c --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png Binary files differ diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..603b140 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..88ea3aa --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,122 @@ + + + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+ + +
+
\ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..5cd135a --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..7bfef59 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..4ca4a9f --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,67 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' + +android { + compileSdkVersion 30 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.birmm.inspect" + minSdkVersion 21 + targetSdkVersion 30 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'androidx.core:core-ktx:1.3.2' + implementation 'androidx.constraintlayout:constraintlayout:2.0.4' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test.ext:junit:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:1.3.0' + //腾讯Android UI框架 + implementation 'com.qmuiteam:qmui:2.0.0-alpha10' + implementation 'com.qmuiteam:arch:0.3.1' + //沉浸式状态栏。基础依赖包,必须要依赖 + implementation 'com.gyf.immersionbar:immersionbar:3.0.0' + //fragment快速实现 + implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + + //MVP网络请求框架retrofit2+rxjava + implementation 'io.reactivex:rxjava:1.3.8' + implementation 'io.reactivex:rxandroid:1.2.1' + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.6.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + implementation 'com.squareup.retrofit2:adapter-rxjava:2.8.1' + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.8.6' + //Toast提示 + implementation 'com.sdsmdg.tastytoast:tastytoast:0.1.1' + //图片选择框架 + implementation 'com.github.LuckSiege.PictureSelector:picture_library:v2.6.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..ea03309 --- /dev/null +++ b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.casic.birmm.inspect + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.casic.birmm.inspect", appContext.packageName) + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..7096527 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt new file mode 100644 index 0000000..aefdbb6 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt @@ -0,0 +1,36 @@ +package com.casic.birmm.inspect.base + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.qmuiteam.qmui.util.QMUIStatusBarHelper + +abstract class BaseActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(initLayoutView()) + QMUIStatusBarHelper.translucent(this) //沉浸式状态栏 + setupTopBarLayout() + initData() + initEvent() + } + + /** + * 初始化xml布局 + */ + abstract fun initLayoutView(): Int + + /** + * 特定页面定制沉浸式状态栏 + */ + protected abstract fun setupTopBarLayout() + + /** + * 初始化默认数据 + */ + abstract fun initData() + + /** + * 初始化业务逻辑 + */ + abstract fun initEvent() +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt new file mode 100644 index 0000000..fc0ca75 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt @@ -0,0 +1,18 @@ +package com.casic.birmm.inspect.base + +import android.app.Application +import com.casic.birmm.inspect.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + companion object { + var instance: BaseApplication by Delegates.notNull() + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt new file mode 100644 index 0000000..ddc160a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt @@ -0,0 +1,56 @@ +package com.casic.birmm.inspect.ui + +import android.annotation.SuppressLint +import android.content.Intent +import android.os.CountDownTimer +import android.view.ViewGroup.MarginLayoutParams +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.activity_guide.* + +@SuppressLint("SetTextI18n") +class GuideActivity : BaseActivity() { + + private lateinit var countDownTimer: CountDownTimer + + override fun initLayoutView(): Int = R.layout.activity_guide + + override fun setupTopBarLayout() { + + } + + override fun initData() { + //根据不同设备状态栏高度设置"跳过"按钮的Margin值 + val statusBarHeight = QMUIDisplayHelper.getStatusBarHeight(this) + val rightMargin = QMUIDisplayHelper.dp2px(this, 10) + if (skipButton.layoutParams is MarginLayoutParams) { + val params = skipButton.layoutParams as MarginLayoutParams + params.setMargins(skipButton.width, statusBarHeight, rightMargin, 0) + skipButton.requestLayout() + } + + countDownTimer = object : CountDownTimer(4000, 1000) { + override fun onFinish() { + startLoginActivity() + } + + override fun onTick(millisUntilFinished: Long) { + skipButton.text = "跳过\u3000${(millisUntilFinished / 1000)}s" + } + } + } + + override fun initEvent() { + countDownTimer.start() + skipButton.setOnClickListener { + countDownTimer.cancel() + startLoginActivity() + } + } + + fun startLoginActivity() { + startActivity(Intent(this, LoginActivity::class.java)) + finish() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt new file mode 100644 index 0000000..6ef4548 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt @@ -0,0 +1,81 @@ +package com.casic.birmm.inspect.ui + +import android.text.Editable +import android.text.TextWatcher +import android.view.KeyEvent +import android.view.inputmethod.EditorInfo +import android.widget.EditText +import android.widget.TextView +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.casic.birmm.inspect.utils.Constant +import com.casic.birmm.inspect.utils.SaveKeyValues +import com.casic.birmm.inspect.widgets.InputDialog +import kotlinx.android.synthetic.main.activity_login.* + + +class LoginActivity : BaseActivity() { + + companion object { + private const val Tag = "LoginActivity" + } + + override fun initLayoutView(): Int = R.layout.activity_login + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + loginButton.setChangeAlphaWhenPress(true) + val editText: EditText? = inputLayout.editText + editText?.addTextChangedListener(object : TextWatcher { + override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) { + + } + + override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) { + + } + + override fun afterTextChanged(s: Editable) { + if (s.toString().trim { it <= ' ' }.length > 12) { + inputLayout.error = "密码长度超出限制" + } else { + inputLayout.error = null + } + } + }) + //点击输入法键盘"完成" + editText?.setOnEditorActionListener { _: TextView?, actionId: Int, _: KeyEvent? -> + if (actionId == EditorInfo.IME_ACTION_DONE) { +// authenticatePresenter.onReadyRetrofitRequest() + return@setOnEditorActionListener true + } + false + } + + //修改服务器配置 + changeServerConfigView.setOnClickListener { + val defaultValue = SaveKeyValues.getValue( + Constant.DEFAULT_SERVER_CONFIG, + "http://139.198.6.177:8093/" + ) as String + InputDialog.Builder().setContext(this) + .setTitle("请输入后台服务器地址") + .setDefaultValue(defaultValue) + .setNegativeButton("取消") + .setPositiveButton("保存") + .setOnDialogClickListener(object : InputDialog.OnDialogButtonClickListener { + override fun onButtonClick(input: String) { + SaveKeyValues.putValue(Constant.DEFAULT_SERVER_CONFIG, input) + } + }) + .build().show() + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt new file mode 100644 index 0000000..0e97af7 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt @@ -0,0 +1,21 @@ +package com.casic.birmm.inspect.ui + +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity + +class MainActivity : BaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt new file mode 100644 index 0000000..21fbba2 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt @@ -0,0 +1,58 @@ +package com.casic.birmm.inspect.ui + +import android.content.Intent +import android.os.Build +import android.os.Bundle +import android.util.Log +import androidx.appcompat.app.AppCompatActivity +import com.casic.birmm.inspect.utils.Constant +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + companion object { + private const val TAG = "PermissionActivity" + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + if (EasyPermissions.hasPermissions(this, *Constant.USER_PERMISSIONS)) { + startGuideActivity() + } else { + EasyPermissions.requestPermissions( + this, + "需要获取相关权限", + Constant.PERMISSIONS_CODE, + *Constant.USER_PERMISSIONS + ) + } + } else { + startGuideActivity() + } + } + + private fun startGuideActivity() { + startActivity(Intent(this, GuideActivity::class.java)) + finish() + } + + override fun onRequestPermissionsResult( + requestCode: Int, + permissions: Array, + grantResults: IntArray + ) { + super.onRequestPermissionsResult(requestCode, permissions, grantResults) + EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this) + } + + override fun onPermissionsGranted(requestCode: Int, perms: List) { + startGuideActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + Log.e(TAG, "onPermissionsDenied: $perms") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt new file mode 100644 index 0000000..53df6e1 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt @@ -0,0 +1,15 @@ +package com.casic.birmm.inspect.utils + +import android.Manifest + + +object Constant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.ACCESS_LOCATION_EXTRA_COMMANDS, + Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION + ) + + const val PERMISSIONS_CODE = 999 + + const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt new file mode 100644 index 0000000..4c38241 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt @@ -0,0 +1,19 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.view.View +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object OtherUtils { + + //替换Toast + fun showTipsDialog(context: Context, message: String, view: View) { + val tipDialog = QMUITipDialog.Builder(context) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_NOTHING) + .setTipWord(message).create() + tipDialog.show() + view.postDelayed({ + tipDialog.dismiss() + }, 2000) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt b/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt new file mode 100644 index 0000000..04c9f5a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt @@ -0,0 +1,106 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.content.SharedPreferences +import com.casic.birmm.inspect.base.BaseApplication + +object SaveKeyValues { + private var sharedPreferences: SharedPreferences? = null + private var editor: SharedPreferences.Editor? = null + private var fileName: String? = null + + fun initSharedPreferences() { + val packageName = BaseApplication.instance.packageName + //获取到的包名带有“.”方便命名,取最后一个作为sp文件名,例如:com.casic.birmm.inspect + val split = packageName.split(".") + fileName = split[split.size - 1] + } + + /** + * 存储 + */ + fun putValue(key: String?, obj: Any) { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + val editor = sharedPreferences!!.edit() + when (obj) { + is String -> { + editor.putString(key, obj).apply() + } + is Int -> { + editor.putInt(key, obj).apply() + } + is Boolean -> { + editor.putBoolean(key, obj).apply() + } + is Float -> { + editor.putFloat(key, obj).apply() + } + is Long -> { + editor.putLong(key, obj).apply() + } + else -> { + editor.putString(key, obj.toString()).apply() + } + } + } + + /** + * 获取保存的数据 + */ + operator fun getValue(key: String?, defaultObject: Any?): Any? { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + return when (defaultObject) { + is String -> { + sharedPreferences!!.getString(key, defaultObject as String?) + } + is Int -> { + sharedPreferences!!.getInt(key, (defaultObject as Int?)!!) + } + is Boolean -> { + sharedPreferences!!.getBoolean(key, (defaultObject as Boolean?)!!) + } + is Float -> { + sharedPreferences!!.getFloat(key, (defaultObject as Float?)!!) + } + is Long -> { + sharedPreferences!!.getLong(key, (defaultObject as Long?)!!) + } + else -> { + sharedPreferences!!.getString(key, null) + } + } + } + + /** + * 移除某个key值已经对应的值 + */ + fun removeKey(key: String?) { + editor!!.remove(key) + editor!!.commit() + } + + /** + * 清除所有数据 + */ + fun clearAll() { + editor!!.clear() + editor!!.commit() + } + + /** + * 查询某个key是否存在 + */ + fun containsKey(key: String?): Boolean { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + return sharedPreferences!!.contains(key) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt b/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt new file mode 100644 index 0000000..04db86b --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt @@ -0,0 +1,119 @@ +package com.casic.birmm.inspect.widgets + +import android.app.Dialog +import android.content.Context +import android.graphics.Color +import android.graphics.drawable.ColorDrawable +import android.os.Bundle +import android.view.WindowManager +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.utils.OtherUtils +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.dialog_input.* + + +class InputDialog private constructor(builder: Builder) : Dialog(builder.mContext!!) { + + private var ctx: Context? = null + private var title: String? = null + private var value: String? = null + private var positiveBtn: String? = null + private var negativeBtn: String? = null + private var listener: OnDialogButtonClickListener? = null + + init { + this.ctx = builder.mContext + this.title = builder.title + this.value = builder.value + this.positiveBtn = builder.positiveBtn + this.negativeBtn = builder.negativeBtn + this.listener = builder.listener + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + configDialogLayout() + setContentView(R.layout.dialog_input) + setCancelable(false) + setCanceledOnTouchOutside(false) + + dialogTitleView.text = title + value.apply { + dialogInputView.setText(this) + } + + dialogCancelButton.text = negativeBtn + dialogCancelButton.setChangeAlphaWhenPress(true) + dialogCancelButton.setOnClickListener { + this.dismiss() + } + + dialogConfirmButton.text = positiveBtn + dialogConfirmButton.setChangeAlphaWhenPress(true) + dialogConfirmButton.setOnClickListener { + val inputValue = dialogInputView.text.toString().trim() + if (inputValue.isEmpty()) { + OtherUtils.showTipsDialog(ctx!!, "什么都没输入,请重新输入", dialogConfirmButton) + return@setOnClickListener + } + listener?.onButtonClick(inputValue) + this.dismiss() + } + } + + private fun configDialogLayout() { + window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT)) + window?.decorView?.setBackgroundColor(Color.TRANSPARENT) + val params: WindowManager.LayoutParams? = window?.attributes + params?.width = QMUIDisplayHelper.dp2px(ctx, 300) + params?.height = WindowManager.LayoutParams.WRAP_CONTENT + window?.attributes = params + } + + class Builder { + var mContext: Context? = null + var title: String? = null + var value: String? = null + var positiveBtn: String? = null + var negativeBtn: String? = null + var listener: OnDialogButtonClickListener? = null + + fun setContext(context: Context?): Builder { + mContext = context + return this + } + + fun setTitle(title: String?): Builder { + this.title = title + return this + } + + fun setDefaultValue(value: String?): Builder { + this.value = value + return this + } + + fun setPositiveButton(name: String?): Builder { + positiveBtn = name + return this + } + + fun setNegativeButton(name: String?): Builder { + negativeBtn = name + return this + } + + fun setOnDialogClickListener(listener: OnDialogButtonClickListener): Builder { + this.listener = listener + return this + } + + fun build(): InputDialog { + return InputDialog(this) + } + } + + interface OnDialogButtonClickListener { + fun onButtonClick(input: String) + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_dialog_button.xml b/app/src/main/res/drawable/bg_dialog_button.xml new file mode 100644 index 0000000..5f7d57d --- /dev/null +++ b/app/src/main/res/drawable/bg_dialog_button.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_layout_white.xml b/app/src/main/res/drawable/bg_layout_white.xml new file mode 100644 index 0000000..19b473b --- /dev/null +++ b/app/src/main/res/drawable/bg_layout_white.xml @@ -0,0 +1,11 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/guide1.png b/app/src/main/res/drawable/guide1.png new file mode 100644 index 0000000..074c768 --- /dev/null +++ b/app/src/main/res/drawable/guide1.png Binary files differ diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_lock.xml b/app/src/main/res/drawable/ic_lock.xml new file mode 100644 index 0000000..f0a5610 --- /dev/null +++ b/app/src/main/res/drawable/ic_lock.xml @@ -0,0 +1,12 @@ + + + + diff --git a/app/src/main/res/drawable/ic_login_bg.png b/app/src/main/res/drawable/ic_login_bg.png new file mode 100644 index 0000000..64789c3 --- /dev/null +++ b/app/src/main/res/drawable/ic_login_bg.png Binary files differ diff --git a/app/src/main/res/drawable/ic_user.xml b/app/src/main/res/drawable/ic_user.xml new file mode 100644 index 0000000..8c4a29d --- /dev/null +++ b/app/src/main/res/drawable/ic_user.xml @@ -0,0 +1,15 @@ + + + + + diff --git a/app/src/main/res/layout/activity_guide.xml b/app/src/main/res/layout/activity_guide.xml new file mode 100644 index 0000000..e197626 --- /dev/null +++ b/app/src/main/res/layout/activity_guide.xml @@ -0,0 +1,19 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_login.xml b/app/src/main/res/layout/activity_login.xml new file mode 100644 index 0000000..bcae777 --- /dev/null +++ b/app/src/main/res/layout/activity_login.xml @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..def59e4 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,18 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_input.xml b/app/src/main/res/layout/dialog_input.xml new file mode 100644 index 0000000..f5a8bc6 --- /dev/null +++ b/app/src/main/res/layout/dialog_input.xml @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..a571e60 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 0000000..61da551 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..c41dd28 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png new file mode 100644 index 0000000..db5080a --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..6dba46d --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png new file mode 100644 index 0000000..da31a87 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..15ac681 --- /dev/null +++ b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..b216f2d --- /dev/null +++ b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..f25a419 --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..e96783c --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml new file mode 100644 index 0000000..662ee77 --- /dev/null +++ b/app/src/main/res/values/colors.xml @@ -0,0 +1,21 @@ + + + #6200EE + #3700B3 + #03DAC5 + + #FFFFFF + #E5E5E5 + #C0C0C0 + #808080 + #000000 + + #1565E3 + #575757 + + #06134C + #090E47 + #98A0BD + + #54000000 + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..603b140 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..88ea3aa --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,122 @@ + + + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+ + +
+
\ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..5cd135a --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..7bfef59 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..4ca4a9f --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,67 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' + +android { + compileSdkVersion 30 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.birmm.inspect" + minSdkVersion 21 + targetSdkVersion 30 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'androidx.core:core-ktx:1.3.2' + implementation 'androidx.constraintlayout:constraintlayout:2.0.4' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test.ext:junit:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:1.3.0' + //腾讯Android UI框架 + implementation 'com.qmuiteam:qmui:2.0.0-alpha10' + implementation 'com.qmuiteam:arch:0.3.1' + //沉浸式状态栏。基础依赖包,必须要依赖 + implementation 'com.gyf.immersionbar:immersionbar:3.0.0' + //fragment快速实现 + implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + + //MVP网络请求框架retrofit2+rxjava + implementation 'io.reactivex:rxjava:1.3.8' + implementation 'io.reactivex:rxandroid:1.2.1' + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.6.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + implementation 'com.squareup.retrofit2:adapter-rxjava:2.8.1' + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.8.6' + //Toast提示 + implementation 'com.sdsmdg.tastytoast:tastytoast:0.1.1' + //图片选择框架 + implementation 'com.github.LuckSiege.PictureSelector:picture_library:v2.6.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..ea03309 --- /dev/null +++ b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.casic.birmm.inspect + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.casic.birmm.inspect", appContext.packageName) + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..7096527 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt new file mode 100644 index 0000000..aefdbb6 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt @@ -0,0 +1,36 @@ +package com.casic.birmm.inspect.base + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.qmuiteam.qmui.util.QMUIStatusBarHelper + +abstract class BaseActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(initLayoutView()) + QMUIStatusBarHelper.translucent(this) //沉浸式状态栏 + setupTopBarLayout() + initData() + initEvent() + } + + /** + * 初始化xml布局 + */ + abstract fun initLayoutView(): Int + + /** + * 特定页面定制沉浸式状态栏 + */ + protected abstract fun setupTopBarLayout() + + /** + * 初始化默认数据 + */ + abstract fun initData() + + /** + * 初始化业务逻辑 + */ + abstract fun initEvent() +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt new file mode 100644 index 0000000..fc0ca75 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt @@ -0,0 +1,18 @@ +package com.casic.birmm.inspect.base + +import android.app.Application +import com.casic.birmm.inspect.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + companion object { + var instance: BaseApplication by Delegates.notNull() + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt new file mode 100644 index 0000000..ddc160a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt @@ -0,0 +1,56 @@ +package com.casic.birmm.inspect.ui + +import android.annotation.SuppressLint +import android.content.Intent +import android.os.CountDownTimer +import android.view.ViewGroup.MarginLayoutParams +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.activity_guide.* + +@SuppressLint("SetTextI18n") +class GuideActivity : BaseActivity() { + + private lateinit var countDownTimer: CountDownTimer + + override fun initLayoutView(): Int = R.layout.activity_guide + + override fun setupTopBarLayout() { + + } + + override fun initData() { + //根据不同设备状态栏高度设置"跳过"按钮的Margin值 + val statusBarHeight = QMUIDisplayHelper.getStatusBarHeight(this) + val rightMargin = QMUIDisplayHelper.dp2px(this, 10) + if (skipButton.layoutParams is MarginLayoutParams) { + val params = skipButton.layoutParams as MarginLayoutParams + params.setMargins(skipButton.width, statusBarHeight, rightMargin, 0) + skipButton.requestLayout() + } + + countDownTimer = object : CountDownTimer(4000, 1000) { + override fun onFinish() { + startLoginActivity() + } + + override fun onTick(millisUntilFinished: Long) { + skipButton.text = "跳过\u3000${(millisUntilFinished / 1000)}s" + } + } + } + + override fun initEvent() { + countDownTimer.start() + skipButton.setOnClickListener { + countDownTimer.cancel() + startLoginActivity() + } + } + + fun startLoginActivity() { + startActivity(Intent(this, LoginActivity::class.java)) + finish() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt new file mode 100644 index 0000000..6ef4548 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt @@ -0,0 +1,81 @@ +package com.casic.birmm.inspect.ui + +import android.text.Editable +import android.text.TextWatcher +import android.view.KeyEvent +import android.view.inputmethod.EditorInfo +import android.widget.EditText +import android.widget.TextView +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.casic.birmm.inspect.utils.Constant +import com.casic.birmm.inspect.utils.SaveKeyValues +import com.casic.birmm.inspect.widgets.InputDialog +import kotlinx.android.synthetic.main.activity_login.* + + +class LoginActivity : BaseActivity() { + + companion object { + private const val Tag = "LoginActivity" + } + + override fun initLayoutView(): Int = R.layout.activity_login + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + loginButton.setChangeAlphaWhenPress(true) + val editText: EditText? = inputLayout.editText + editText?.addTextChangedListener(object : TextWatcher { + override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) { + + } + + override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) { + + } + + override fun afterTextChanged(s: Editable) { + if (s.toString().trim { it <= ' ' }.length > 12) { + inputLayout.error = "密码长度超出限制" + } else { + inputLayout.error = null + } + } + }) + //点击输入法键盘"完成" + editText?.setOnEditorActionListener { _: TextView?, actionId: Int, _: KeyEvent? -> + if (actionId == EditorInfo.IME_ACTION_DONE) { +// authenticatePresenter.onReadyRetrofitRequest() + return@setOnEditorActionListener true + } + false + } + + //修改服务器配置 + changeServerConfigView.setOnClickListener { + val defaultValue = SaveKeyValues.getValue( + Constant.DEFAULT_SERVER_CONFIG, + "http://139.198.6.177:8093/" + ) as String + InputDialog.Builder().setContext(this) + .setTitle("请输入后台服务器地址") + .setDefaultValue(defaultValue) + .setNegativeButton("取消") + .setPositiveButton("保存") + .setOnDialogClickListener(object : InputDialog.OnDialogButtonClickListener { + override fun onButtonClick(input: String) { + SaveKeyValues.putValue(Constant.DEFAULT_SERVER_CONFIG, input) + } + }) + .build().show() + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt new file mode 100644 index 0000000..0e97af7 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt @@ -0,0 +1,21 @@ +package com.casic.birmm.inspect.ui + +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity + +class MainActivity : BaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt new file mode 100644 index 0000000..21fbba2 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt @@ -0,0 +1,58 @@ +package com.casic.birmm.inspect.ui + +import android.content.Intent +import android.os.Build +import android.os.Bundle +import android.util.Log +import androidx.appcompat.app.AppCompatActivity +import com.casic.birmm.inspect.utils.Constant +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + companion object { + private const val TAG = "PermissionActivity" + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + if (EasyPermissions.hasPermissions(this, *Constant.USER_PERMISSIONS)) { + startGuideActivity() + } else { + EasyPermissions.requestPermissions( + this, + "需要获取相关权限", + Constant.PERMISSIONS_CODE, + *Constant.USER_PERMISSIONS + ) + } + } else { + startGuideActivity() + } + } + + private fun startGuideActivity() { + startActivity(Intent(this, GuideActivity::class.java)) + finish() + } + + override fun onRequestPermissionsResult( + requestCode: Int, + permissions: Array, + grantResults: IntArray + ) { + super.onRequestPermissionsResult(requestCode, permissions, grantResults) + EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this) + } + + override fun onPermissionsGranted(requestCode: Int, perms: List) { + startGuideActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + Log.e(TAG, "onPermissionsDenied: $perms") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt new file mode 100644 index 0000000..53df6e1 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt @@ -0,0 +1,15 @@ +package com.casic.birmm.inspect.utils + +import android.Manifest + + +object Constant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.ACCESS_LOCATION_EXTRA_COMMANDS, + Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION + ) + + const val PERMISSIONS_CODE = 999 + + const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt new file mode 100644 index 0000000..4c38241 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt @@ -0,0 +1,19 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.view.View +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object OtherUtils { + + //替换Toast + fun showTipsDialog(context: Context, message: String, view: View) { + val tipDialog = QMUITipDialog.Builder(context) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_NOTHING) + .setTipWord(message).create() + tipDialog.show() + view.postDelayed({ + tipDialog.dismiss() + }, 2000) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt b/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt new file mode 100644 index 0000000..04c9f5a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt @@ -0,0 +1,106 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.content.SharedPreferences +import com.casic.birmm.inspect.base.BaseApplication + +object SaveKeyValues { + private var sharedPreferences: SharedPreferences? = null + private var editor: SharedPreferences.Editor? = null + private var fileName: String? = null + + fun initSharedPreferences() { + val packageName = BaseApplication.instance.packageName + //获取到的包名带有“.”方便命名,取最后一个作为sp文件名,例如:com.casic.birmm.inspect + val split = packageName.split(".") + fileName = split[split.size - 1] + } + + /** + * 存储 + */ + fun putValue(key: String?, obj: Any) { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + val editor = sharedPreferences!!.edit() + when (obj) { + is String -> { + editor.putString(key, obj).apply() + } + is Int -> { + editor.putInt(key, obj).apply() + } + is Boolean -> { + editor.putBoolean(key, obj).apply() + } + is Float -> { + editor.putFloat(key, obj).apply() + } + is Long -> { + editor.putLong(key, obj).apply() + } + else -> { + editor.putString(key, obj.toString()).apply() + } + } + } + + /** + * 获取保存的数据 + */ + operator fun getValue(key: String?, defaultObject: Any?): Any? { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + return when (defaultObject) { + is String -> { + sharedPreferences!!.getString(key, defaultObject as String?) + } + is Int -> { + sharedPreferences!!.getInt(key, (defaultObject as Int?)!!) + } + is Boolean -> { + sharedPreferences!!.getBoolean(key, (defaultObject as Boolean?)!!) + } + is Float -> { + sharedPreferences!!.getFloat(key, (defaultObject as Float?)!!) + } + is Long -> { + sharedPreferences!!.getLong(key, (defaultObject as Long?)!!) + } + else -> { + sharedPreferences!!.getString(key, null) + } + } + } + + /** + * 移除某个key值已经对应的值 + */ + fun removeKey(key: String?) { + editor!!.remove(key) + editor!!.commit() + } + + /** + * 清除所有数据 + */ + fun clearAll() { + editor!!.clear() + editor!!.commit() + } + + /** + * 查询某个key是否存在 + */ + fun containsKey(key: String?): Boolean { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + return sharedPreferences!!.contains(key) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt b/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt new file mode 100644 index 0000000..04db86b --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt @@ -0,0 +1,119 @@ +package com.casic.birmm.inspect.widgets + +import android.app.Dialog +import android.content.Context +import android.graphics.Color +import android.graphics.drawable.ColorDrawable +import android.os.Bundle +import android.view.WindowManager +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.utils.OtherUtils +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.dialog_input.* + + +class InputDialog private constructor(builder: Builder) : Dialog(builder.mContext!!) { + + private var ctx: Context? = null + private var title: String? = null + private var value: String? = null + private var positiveBtn: String? = null + private var negativeBtn: String? = null + private var listener: OnDialogButtonClickListener? = null + + init { + this.ctx = builder.mContext + this.title = builder.title + this.value = builder.value + this.positiveBtn = builder.positiveBtn + this.negativeBtn = builder.negativeBtn + this.listener = builder.listener + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + configDialogLayout() + setContentView(R.layout.dialog_input) + setCancelable(false) + setCanceledOnTouchOutside(false) + + dialogTitleView.text = title + value.apply { + dialogInputView.setText(this) + } + + dialogCancelButton.text = negativeBtn + dialogCancelButton.setChangeAlphaWhenPress(true) + dialogCancelButton.setOnClickListener { + this.dismiss() + } + + dialogConfirmButton.text = positiveBtn + dialogConfirmButton.setChangeAlphaWhenPress(true) + dialogConfirmButton.setOnClickListener { + val inputValue = dialogInputView.text.toString().trim() + if (inputValue.isEmpty()) { + OtherUtils.showTipsDialog(ctx!!, "什么都没输入,请重新输入", dialogConfirmButton) + return@setOnClickListener + } + listener?.onButtonClick(inputValue) + this.dismiss() + } + } + + private fun configDialogLayout() { + window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT)) + window?.decorView?.setBackgroundColor(Color.TRANSPARENT) + val params: WindowManager.LayoutParams? = window?.attributes + params?.width = QMUIDisplayHelper.dp2px(ctx, 300) + params?.height = WindowManager.LayoutParams.WRAP_CONTENT + window?.attributes = params + } + + class Builder { + var mContext: Context? = null + var title: String? = null + var value: String? = null + var positiveBtn: String? = null + var negativeBtn: String? = null + var listener: OnDialogButtonClickListener? = null + + fun setContext(context: Context?): Builder { + mContext = context + return this + } + + fun setTitle(title: String?): Builder { + this.title = title + return this + } + + fun setDefaultValue(value: String?): Builder { + this.value = value + return this + } + + fun setPositiveButton(name: String?): Builder { + positiveBtn = name + return this + } + + fun setNegativeButton(name: String?): Builder { + negativeBtn = name + return this + } + + fun setOnDialogClickListener(listener: OnDialogButtonClickListener): Builder { + this.listener = listener + return this + } + + fun build(): InputDialog { + return InputDialog(this) + } + } + + interface OnDialogButtonClickListener { + fun onButtonClick(input: String) + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_dialog_button.xml b/app/src/main/res/drawable/bg_dialog_button.xml new file mode 100644 index 0000000..5f7d57d --- /dev/null +++ b/app/src/main/res/drawable/bg_dialog_button.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_layout_white.xml b/app/src/main/res/drawable/bg_layout_white.xml new file mode 100644 index 0000000..19b473b --- /dev/null +++ b/app/src/main/res/drawable/bg_layout_white.xml @@ -0,0 +1,11 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/guide1.png b/app/src/main/res/drawable/guide1.png new file mode 100644 index 0000000..074c768 --- /dev/null +++ b/app/src/main/res/drawable/guide1.png Binary files differ diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_lock.xml b/app/src/main/res/drawable/ic_lock.xml new file mode 100644 index 0000000..f0a5610 --- /dev/null +++ b/app/src/main/res/drawable/ic_lock.xml @@ -0,0 +1,12 @@ + + + + diff --git a/app/src/main/res/drawable/ic_login_bg.png b/app/src/main/res/drawable/ic_login_bg.png new file mode 100644 index 0000000..64789c3 --- /dev/null +++ b/app/src/main/res/drawable/ic_login_bg.png Binary files differ diff --git a/app/src/main/res/drawable/ic_user.xml b/app/src/main/res/drawable/ic_user.xml new file mode 100644 index 0000000..8c4a29d --- /dev/null +++ b/app/src/main/res/drawable/ic_user.xml @@ -0,0 +1,15 @@ + + + + + diff --git a/app/src/main/res/layout/activity_guide.xml b/app/src/main/res/layout/activity_guide.xml new file mode 100644 index 0000000..e197626 --- /dev/null +++ b/app/src/main/res/layout/activity_guide.xml @@ -0,0 +1,19 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_login.xml b/app/src/main/res/layout/activity_login.xml new file mode 100644 index 0000000..bcae777 --- /dev/null +++ b/app/src/main/res/layout/activity_login.xml @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..def59e4 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,18 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_input.xml b/app/src/main/res/layout/dialog_input.xml new file mode 100644 index 0000000..f5a8bc6 --- /dev/null +++ b/app/src/main/res/layout/dialog_input.xml @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..a571e60 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 0000000..61da551 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..c41dd28 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png new file mode 100644 index 0000000..db5080a --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..6dba46d --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png new file mode 100644 index 0000000..da31a87 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..15ac681 --- /dev/null +++ b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..b216f2d --- /dev/null +++ b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..f25a419 --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..e96783c --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml new file mode 100644 index 0000000..662ee77 --- /dev/null +++ b/app/src/main/res/values/colors.xml @@ -0,0 +1,21 @@ + + + #6200EE + #3700B3 + #03DAC5 + + #FFFFFF + #E5E5E5 + #C0C0C0 + #808080 + #000000 + + #1565E3 + #575757 + + #06134C + #090E47 + #98A0BD + + #54000000 + diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml new file mode 100644 index 0000000..2dddf37 --- /dev/null +++ b/app/src/main/res/values/dimens.xml @@ -0,0 +1,14 @@ + + + 16sp + 18sp + + + 10dp + + + 10dp + + + 1px + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..603b140 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..88ea3aa --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,122 @@ + + + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+ + +
+
\ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..5cd135a --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..7bfef59 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..4ca4a9f --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,67 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' + +android { + compileSdkVersion 30 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.birmm.inspect" + minSdkVersion 21 + targetSdkVersion 30 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'androidx.core:core-ktx:1.3.2' + implementation 'androidx.constraintlayout:constraintlayout:2.0.4' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test.ext:junit:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:1.3.0' + //腾讯Android UI框架 + implementation 'com.qmuiteam:qmui:2.0.0-alpha10' + implementation 'com.qmuiteam:arch:0.3.1' + //沉浸式状态栏。基础依赖包,必须要依赖 + implementation 'com.gyf.immersionbar:immersionbar:3.0.0' + //fragment快速实现 + implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + + //MVP网络请求框架retrofit2+rxjava + implementation 'io.reactivex:rxjava:1.3.8' + implementation 'io.reactivex:rxandroid:1.2.1' + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.6.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + implementation 'com.squareup.retrofit2:adapter-rxjava:2.8.1' + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.8.6' + //Toast提示 + implementation 'com.sdsmdg.tastytoast:tastytoast:0.1.1' + //图片选择框架 + implementation 'com.github.LuckSiege.PictureSelector:picture_library:v2.6.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..ea03309 --- /dev/null +++ b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.casic.birmm.inspect + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.casic.birmm.inspect", appContext.packageName) + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..7096527 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt new file mode 100644 index 0000000..aefdbb6 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt @@ -0,0 +1,36 @@ +package com.casic.birmm.inspect.base + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.qmuiteam.qmui.util.QMUIStatusBarHelper + +abstract class BaseActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(initLayoutView()) + QMUIStatusBarHelper.translucent(this) //沉浸式状态栏 + setupTopBarLayout() + initData() + initEvent() + } + + /** + * 初始化xml布局 + */ + abstract fun initLayoutView(): Int + + /** + * 特定页面定制沉浸式状态栏 + */ + protected abstract fun setupTopBarLayout() + + /** + * 初始化默认数据 + */ + abstract fun initData() + + /** + * 初始化业务逻辑 + */ + abstract fun initEvent() +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt new file mode 100644 index 0000000..fc0ca75 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt @@ -0,0 +1,18 @@ +package com.casic.birmm.inspect.base + +import android.app.Application +import com.casic.birmm.inspect.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + companion object { + var instance: BaseApplication by Delegates.notNull() + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt new file mode 100644 index 0000000..ddc160a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt @@ -0,0 +1,56 @@ +package com.casic.birmm.inspect.ui + +import android.annotation.SuppressLint +import android.content.Intent +import android.os.CountDownTimer +import android.view.ViewGroup.MarginLayoutParams +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.activity_guide.* + +@SuppressLint("SetTextI18n") +class GuideActivity : BaseActivity() { + + private lateinit var countDownTimer: CountDownTimer + + override fun initLayoutView(): Int = R.layout.activity_guide + + override fun setupTopBarLayout() { + + } + + override fun initData() { + //根据不同设备状态栏高度设置"跳过"按钮的Margin值 + val statusBarHeight = QMUIDisplayHelper.getStatusBarHeight(this) + val rightMargin = QMUIDisplayHelper.dp2px(this, 10) + if (skipButton.layoutParams is MarginLayoutParams) { + val params = skipButton.layoutParams as MarginLayoutParams + params.setMargins(skipButton.width, statusBarHeight, rightMargin, 0) + skipButton.requestLayout() + } + + countDownTimer = object : CountDownTimer(4000, 1000) { + override fun onFinish() { + startLoginActivity() + } + + override fun onTick(millisUntilFinished: Long) { + skipButton.text = "跳过\u3000${(millisUntilFinished / 1000)}s" + } + } + } + + override fun initEvent() { + countDownTimer.start() + skipButton.setOnClickListener { + countDownTimer.cancel() + startLoginActivity() + } + } + + fun startLoginActivity() { + startActivity(Intent(this, LoginActivity::class.java)) + finish() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt new file mode 100644 index 0000000..6ef4548 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt @@ -0,0 +1,81 @@ +package com.casic.birmm.inspect.ui + +import android.text.Editable +import android.text.TextWatcher +import android.view.KeyEvent +import android.view.inputmethod.EditorInfo +import android.widget.EditText +import android.widget.TextView +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.casic.birmm.inspect.utils.Constant +import com.casic.birmm.inspect.utils.SaveKeyValues +import com.casic.birmm.inspect.widgets.InputDialog +import kotlinx.android.synthetic.main.activity_login.* + + +class LoginActivity : BaseActivity() { + + companion object { + private const val Tag = "LoginActivity" + } + + override fun initLayoutView(): Int = R.layout.activity_login + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + loginButton.setChangeAlphaWhenPress(true) + val editText: EditText? = inputLayout.editText + editText?.addTextChangedListener(object : TextWatcher { + override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) { + + } + + override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) { + + } + + override fun afterTextChanged(s: Editable) { + if (s.toString().trim { it <= ' ' }.length > 12) { + inputLayout.error = "密码长度超出限制" + } else { + inputLayout.error = null + } + } + }) + //点击输入法键盘"完成" + editText?.setOnEditorActionListener { _: TextView?, actionId: Int, _: KeyEvent? -> + if (actionId == EditorInfo.IME_ACTION_DONE) { +// authenticatePresenter.onReadyRetrofitRequest() + return@setOnEditorActionListener true + } + false + } + + //修改服务器配置 + changeServerConfigView.setOnClickListener { + val defaultValue = SaveKeyValues.getValue( + Constant.DEFAULT_SERVER_CONFIG, + "http://139.198.6.177:8093/" + ) as String + InputDialog.Builder().setContext(this) + .setTitle("请输入后台服务器地址") + .setDefaultValue(defaultValue) + .setNegativeButton("取消") + .setPositiveButton("保存") + .setOnDialogClickListener(object : InputDialog.OnDialogButtonClickListener { + override fun onButtonClick(input: String) { + SaveKeyValues.putValue(Constant.DEFAULT_SERVER_CONFIG, input) + } + }) + .build().show() + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt new file mode 100644 index 0000000..0e97af7 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt @@ -0,0 +1,21 @@ +package com.casic.birmm.inspect.ui + +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity + +class MainActivity : BaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt new file mode 100644 index 0000000..21fbba2 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt @@ -0,0 +1,58 @@ +package com.casic.birmm.inspect.ui + +import android.content.Intent +import android.os.Build +import android.os.Bundle +import android.util.Log +import androidx.appcompat.app.AppCompatActivity +import com.casic.birmm.inspect.utils.Constant +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + companion object { + private const val TAG = "PermissionActivity" + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + if (EasyPermissions.hasPermissions(this, *Constant.USER_PERMISSIONS)) { + startGuideActivity() + } else { + EasyPermissions.requestPermissions( + this, + "需要获取相关权限", + Constant.PERMISSIONS_CODE, + *Constant.USER_PERMISSIONS + ) + } + } else { + startGuideActivity() + } + } + + private fun startGuideActivity() { + startActivity(Intent(this, GuideActivity::class.java)) + finish() + } + + override fun onRequestPermissionsResult( + requestCode: Int, + permissions: Array, + grantResults: IntArray + ) { + super.onRequestPermissionsResult(requestCode, permissions, grantResults) + EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this) + } + + override fun onPermissionsGranted(requestCode: Int, perms: List) { + startGuideActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + Log.e(TAG, "onPermissionsDenied: $perms") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt new file mode 100644 index 0000000..53df6e1 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt @@ -0,0 +1,15 @@ +package com.casic.birmm.inspect.utils + +import android.Manifest + + +object Constant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.ACCESS_LOCATION_EXTRA_COMMANDS, + Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION + ) + + const val PERMISSIONS_CODE = 999 + + const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt new file mode 100644 index 0000000..4c38241 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt @@ -0,0 +1,19 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.view.View +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object OtherUtils { + + //替换Toast + fun showTipsDialog(context: Context, message: String, view: View) { + val tipDialog = QMUITipDialog.Builder(context) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_NOTHING) + .setTipWord(message).create() + tipDialog.show() + view.postDelayed({ + tipDialog.dismiss() + }, 2000) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt b/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt new file mode 100644 index 0000000..04c9f5a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt @@ -0,0 +1,106 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.content.SharedPreferences +import com.casic.birmm.inspect.base.BaseApplication + +object SaveKeyValues { + private var sharedPreferences: SharedPreferences? = null + private var editor: SharedPreferences.Editor? = null + private var fileName: String? = null + + fun initSharedPreferences() { + val packageName = BaseApplication.instance.packageName + //获取到的包名带有“.”方便命名,取最后一个作为sp文件名,例如:com.casic.birmm.inspect + val split = packageName.split(".") + fileName = split[split.size - 1] + } + + /** + * 存储 + */ + fun putValue(key: String?, obj: Any) { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + val editor = sharedPreferences!!.edit() + when (obj) { + is String -> { + editor.putString(key, obj).apply() + } + is Int -> { + editor.putInt(key, obj).apply() + } + is Boolean -> { + editor.putBoolean(key, obj).apply() + } + is Float -> { + editor.putFloat(key, obj).apply() + } + is Long -> { + editor.putLong(key, obj).apply() + } + else -> { + editor.putString(key, obj.toString()).apply() + } + } + } + + /** + * 获取保存的数据 + */ + operator fun getValue(key: String?, defaultObject: Any?): Any? { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + return when (defaultObject) { + is String -> { + sharedPreferences!!.getString(key, defaultObject as String?) + } + is Int -> { + sharedPreferences!!.getInt(key, (defaultObject as Int?)!!) + } + is Boolean -> { + sharedPreferences!!.getBoolean(key, (defaultObject as Boolean?)!!) + } + is Float -> { + sharedPreferences!!.getFloat(key, (defaultObject as Float?)!!) + } + is Long -> { + sharedPreferences!!.getLong(key, (defaultObject as Long?)!!) + } + else -> { + sharedPreferences!!.getString(key, null) + } + } + } + + /** + * 移除某个key值已经对应的值 + */ + fun removeKey(key: String?) { + editor!!.remove(key) + editor!!.commit() + } + + /** + * 清除所有数据 + */ + fun clearAll() { + editor!!.clear() + editor!!.commit() + } + + /** + * 查询某个key是否存在 + */ + fun containsKey(key: String?): Boolean { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + return sharedPreferences!!.contains(key) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt b/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt new file mode 100644 index 0000000..04db86b --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt @@ -0,0 +1,119 @@ +package com.casic.birmm.inspect.widgets + +import android.app.Dialog +import android.content.Context +import android.graphics.Color +import android.graphics.drawable.ColorDrawable +import android.os.Bundle +import android.view.WindowManager +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.utils.OtherUtils +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.dialog_input.* + + +class InputDialog private constructor(builder: Builder) : Dialog(builder.mContext!!) { + + private var ctx: Context? = null + private var title: String? = null + private var value: String? = null + private var positiveBtn: String? = null + private var negativeBtn: String? = null + private var listener: OnDialogButtonClickListener? = null + + init { + this.ctx = builder.mContext + this.title = builder.title + this.value = builder.value + this.positiveBtn = builder.positiveBtn + this.negativeBtn = builder.negativeBtn + this.listener = builder.listener + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + configDialogLayout() + setContentView(R.layout.dialog_input) + setCancelable(false) + setCanceledOnTouchOutside(false) + + dialogTitleView.text = title + value.apply { + dialogInputView.setText(this) + } + + dialogCancelButton.text = negativeBtn + dialogCancelButton.setChangeAlphaWhenPress(true) + dialogCancelButton.setOnClickListener { + this.dismiss() + } + + dialogConfirmButton.text = positiveBtn + dialogConfirmButton.setChangeAlphaWhenPress(true) + dialogConfirmButton.setOnClickListener { + val inputValue = dialogInputView.text.toString().trim() + if (inputValue.isEmpty()) { + OtherUtils.showTipsDialog(ctx!!, "什么都没输入,请重新输入", dialogConfirmButton) + return@setOnClickListener + } + listener?.onButtonClick(inputValue) + this.dismiss() + } + } + + private fun configDialogLayout() { + window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT)) + window?.decorView?.setBackgroundColor(Color.TRANSPARENT) + val params: WindowManager.LayoutParams? = window?.attributes + params?.width = QMUIDisplayHelper.dp2px(ctx, 300) + params?.height = WindowManager.LayoutParams.WRAP_CONTENT + window?.attributes = params + } + + class Builder { + var mContext: Context? = null + var title: String? = null + var value: String? = null + var positiveBtn: String? = null + var negativeBtn: String? = null + var listener: OnDialogButtonClickListener? = null + + fun setContext(context: Context?): Builder { + mContext = context + return this + } + + fun setTitle(title: String?): Builder { + this.title = title + return this + } + + fun setDefaultValue(value: String?): Builder { + this.value = value + return this + } + + fun setPositiveButton(name: String?): Builder { + positiveBtn = name + return this + } + + fun setNegativeButton(name: String?): Builder { + negativeBtn = name + return this + } + + fun setOnDialogClickListener(listener: OnDialogButtonClickListener): Builder { + this.listener = listener + return this + } + + fun build(): InputDialog { + return InputDialog(this) + } + } + + interface OnDialogButtonClickListener { + fun onButtonClick(input: String) + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_dialog_button.xml b/app/src/main/res/drawable/bg_dialog_button.xml new file mode 100644 index 0000000..5f7d57d --- /dev/null +++ b/app/src/main/res/drawable/bg_dialog_button.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_layout_white.xml b/app/src/main/res/drawable/bg_layout_white.xml new file mode 100644 index 0000000..19b473b --- /dev/null +++ b/app/src/main/res/drawable/bg_layout_white.xml @@ -0,0 +1,11 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/guide1.png b/app/src/main/res/drawable/guide1.png new file mode 100644 index 0000000..074c768 --- /dev/null +++ b/app/src/main/res/drawable/guide1.png Binary files differ diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_lock.xml b/app/src/main/res/drawable/ic_lock.xml new file mode 100644 index 0000000..f0a5610 --- /dev/null +++ b/app/src/main/res/drawable/ic_lock.xml @@ -0,0 +1,12 @@ + + + + diff --git a/app/src/main/res/drawable/ic_login_bg.png b/app/src/main/res/drawable/ic_login_bg.png new file mode 100644 index 0000000..64789c3 --- /dev/null +++ b/app/src/main/res/drawable/ic_login_bg.png Binary files differ diff --git a/app/src/main/res/drawable/ic_user.xml b/app/src/main/res/drawable/ic_user.xml new file mode 100644 index 0000000..8c4a29d --- /dev/null +++ b/app/src/main/res/drawable/ic_user.xml @@ -0,0 +1,15 @@ + + + + + diff --git a/app/src/main/res/layout/activity_guide.xml b/app/src/main/res/layout/activity_guide.xml new file mode 100644 index 0000000..e197626 --- /dev/null +++ b/app/src/main/res/layout/activity_guide.xml @@ -0,0 +1,19 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_login.xml b/app/src/main/res/layout/activity_login.xml new file mode 100644 index 0000000..bcae777 --- /dev/null +++ b/app/src/main/res/layout/activity_login.xml @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..def59e4 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,18 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_input.xml b/app/src/main/res/layout/dialog_input.xml new file mode 100644 index 0000000..f5a8bc6 --- /dev/null +++ b/app/src/main/res/layout/dialog_input.xml @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..a571e60 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 0000000..61da551 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..c41dd28 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png new file mode 100644 index 0000000..db5080a --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..6dba46d --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png new file mode 100644 index 0000000..da31a87 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..15ac681 --- /dev/null +++ b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..b216f2d --- /dev/null +++ b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..f25a419 --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..e96783c --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml new file mode 100644 index 0000000..662ee77 --- /dev/null +++ b/app/src/main/res/values/colors.xml @@ -0,0 +1,21 @@ + + + #6200EE + #3700B3 + #03DAC5 + + #FFFFFF + #E5E5E5 + #C0C0C0 + #808080 + #000000 + + #1565E3 + #575757 + + #06134C + #090E47 + #98A0BD + + #54000000 + diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml new file mode 100644 index 0000000..2dddf37 --- /dev/null +++ b/app/src/main/res/values/dimens.xml @@ -0,0 +1,14 @@ + + + 16sp + 18sp + + + 10dp + + + 10dp + + + 1px + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml new file mode 100644 index 0000000..fda9031 --- /dev/null +++ b/app/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + 航小科智巡宝 + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..603b140 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..88ea3aa --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,122 @@ + + + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+ + +
+
\ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..5cd135a --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..7bfef59 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..4ca4a9f --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,67 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' + +android { + compileSdkVersion 30 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.birmm.inspect" + minSdkVersion 21 + targetSdkVersion 30 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'androidx.core:core-ktx:1.3.2' + implementation 'androidx.constraintlayout:constraintlayout:2.0.4' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test.ext:junit:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:1.3.0' + //腾讯Android UI框架 + implementation 'com.qmuiteam:qmui:2.0.0-alpha10' + implementation 'com.qmuiteam:arch:0.3.1' + //沉浸式状态栏。基础依赖包,必须要依赖 + implementation 'com.gyf.immersionbar:immersionbar:3.0.0' + //fragment快速实现 + implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + + //MVP网络请求框架retrofit2+rxjava + implementation 'io.reactivex:rxjava:1.3.8' + implementation 'io.reactivex:rxandroid:1.2.1' + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.6.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + implementation 'com.squareup.retrofit2:adapter-rxjava:2.8.1' + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.8.6' + //Toast提示 + implementation 'com.sdsmdg.tastytoast:tastytoast:0.1.1' + //图片选择框架 + implementation 'com.github.LuckSiege.PictureSelector:picture_library:v2.6.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..ea03309 --- /dev/null +++ b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.casic.birmm.inspect + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.casic.birmm.inspect", appContext.packageName) + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..7096527 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt new file mode 100644 index 0000000..aefdbb6 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt @@ -0,0 +1,36 @@ +package com.casic.birmm.inspect.base + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.qmuiteam.qmui.util.QMUIStatusBarHelper + +abstract class BaseActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(initLayoutView()) + QMUIStatusBarHelper.translucent(this) //沉浸式状态栏 + setupTopBarLayout() + initData() + initEvent() + } + + /** + * 初始化xml布局 + */ + abstract fun initLayoutView(): Int + + /** + * 特定页面定制沉浸式状态栏 + */ + protected abstract fun setupTopBarLayout() + + /** + * 初始化默认数据 + */ + abstract fun initData() + + /** + * 初始化业务逻辑 + */ + abstract fun initEvent() +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt new file mode 100644 index 0000000..fc0ca75 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt @@ -0,0 +1,18 @@ +package com.casic.birmm.inspect.base + +import android.app.Application +import com.casic.birmm.inspect.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + companion object { + var instance: BaseApplication by Delegates.notNull() + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt new file mode 100644 index 0000000..ddc160a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt @@ -0,0 +1,56 @@ +package com.casic.birmm.inspect.ui + +import android.annotation.SuppressLint +import android.content.Intent +import android.os.CountDownTimer +import android.view.ViewGroup.MarginLayoutParams +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.activity_guide.* + +@SuppressLint("SetTextI18n") +class GuideActivity : BaseActivity() { + + private lateinit var countDownTimer: CountDownTimer + + override fun initLayoutView(): Int = R.layout.activity_guide + + override fun setupTopBarLayout() { + + } + + override fun initData() { + //根据不同设备状态栏高度设置"跳过"按钮的Margin值 + val statusBarHeight = QMUIDisplayHelper.getStatusBarHeight(this) + val rightMargin = QMUIDisplayHelper.dp2px(this, 10) + if (skipButton.layoutParams is MarginLayoutParams) { + val params = skipButton.layoutParams as MarginLayoutParams + params.setMargins(skipButton.width, statusBarHeight, rightMargin, 0) + skipButton.requestLayout() + } + + countDownTimer = object : CountDownTimer(4000, 1000) { + override fun onFinish() { + startLoginActivity() + } + + override fun onTick(millisUntilFinished: Long) { + skipButton.text = "跳过\u3000${(millisUntilFinished / 1000)}s" + } + } + } + + override fun initEvent() { + countDownTimer.start() + skipButton.setOnClickListener { + countDownTimer.cancel() + startLoginActivity() + } + } + + fun startLoginActivity() { + startActivity(Intent(this, LoginActivity::class.java)) + finish() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt new file mode 100644 index 0000000..6ef4548 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt @@ -0,0 +1,81 @@ +package com.casic.birmm.inspect.ui + +import android.text.Editable +import android.text.TextWatcher +import android.view.KeyEvent +import android.view.inputmethod.EditorInfo +import android.widget.EditText +import android.widget.TextView +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.casic.birmm.inspect.utils.Constant +import com.casic.birmm.inspect.utils.SaveKeyValues +import com.casic.birmm.inspect.widgets.InputDialog +import kotlinx.android.synthetic.main.activity_login.* + + +class LoginActivity : BaseActivity() { + + companion object { + private const val Tag = "LoginActivity" + } + + override fun initLayoutView(): Int = R.layout.activity_login + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + loginButton.setChangeAlphaWhenPress(true) + val editText: EditText? = inputLayout.editText + editText?.addTextChangedListener(object : TextWatcher { + override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) { + + } + + override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) { + + } + + override fun afterTextChanged(s: Editable) { + if (s.toString().trim { it <= ' ' }.length > 12) { + inputLayout.error = "密码长度超出限制" + } else { + inputLayout.error = null + } + } + }) + //点击输入法键盘"完成" + editText?.setOnEditorActionListener { _: TextView?, actionId: Int, _: KeyEvent? -> + if (actionId == EditorInfo.IME_ACTION_DONE) { +// authenticatePresenter.onReadyRetrofitRequest() + return@setOnEditorActionListener true + } + false + } + + //修改服务器配置 + changeServerConfigView.setOnClickListener { + val defaultValue = SaveKeyValues.getValue( + Constant.DEFAULT_SERVER_CONFIG, + "http://139.198.6.177:8093/" + ) as String + InputDialog.Builder().setContext(this) + .setTitle("请输入后台服务器地址") + .setDefaultValue(defaultValue) + .setNegativeButton("取消") + .setPositiveButton("保存") + .setOnDialogClickListener(object : InputDialog.OnDialogButtonClickListener { + override fun onButtonClick(input: String) { + SaveKeyValues.putValue(Constant.DEFAULT_SERVER_CONFIG, input) + } + }) + .build().show() + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt new file mode 100644 index 0000000..0e97af7 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt @@ -0,0 +1,21 @@ +package com.casic.birmm.inspect.ui + +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity + +class MainActivity : BaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt new file mode 100644 index 0000000..21fbba2 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt @@ -0,0 +1,58 @@ +package com.casic.birmm.inspect.ui + +import android.content.Intent +import android.os.Build +import android.os.Bundle +import android.util.Log +import androidx.appcompat.app.AppCompatActivity +import com.casic.birmm.inspect.utils.Constant +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + companion object { + private const val TAG = "PermissionActivity" + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + if (EasyPermissions.hasPermissions(this, *Constant.USER_PERMISSIONS)) { + startGuideActivity() + } else { + EasyPermissions.requestPermissions( + this, + "需要获取相关权限", + Constant.PERMISSIONS_CODE, + *Constant.USER_PERMISSIONS + ) + } + } else { + startGuideActivity() + } + } + + private fun startGuideActivity() { + startActivity(Intent(this, GuideActivity::class.java)) + finish() + } + + override fun onRequestPermissionsResult( + requestCode: Int, + permissions: Array, + grantResults: IntArray + ) { + super.onRequestPermissionsResult(requestCode, permissions, grantResults) + EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this) + } + + override fun onPermissionsGranted(requestCode: Int, perms: List) { + startGuideActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + Log.e(TAG, "onPermissionsDenied: $perms") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt new file mode 100644 index 0000000..53df6e1 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt @@ -0,0 +1,15 @@ +package com.casic.birmm.inspect.utils + +import android.Manifest + + +object Constant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.ACCESS_LOCATION_EXTRA_COMMANDS, + Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION + ) + + const val PERMISSIONS_CODE = 999 + + const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt new file mode 100644 index 0000000..4c38241 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt @@ -0,0 +1,19 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.view.View +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object OtherUtils { + + //替换Toast + fun showTipsDialog(context: Context, message: String, view: View) { + val tipDialog = QMUITipDialog.Builder(context) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_NOTHING) + .setTipWord(message).create() + tipDialog.show() + view.postDelayed({ + tipDialog.dismiss() + }, 2000) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt b/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt new file mode 100644 index 0000000..04c9f5a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt @@ -0,0 +1,106 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.content.SharedPreferences +import com.casic.birmm.inspect.base.BaseApplication + +object SaveKeyValues { + private var sharedPreferences: SharedPreferences? = null + private var editor: SharedPreferences.Editor? = null + private var fileName: String? = null + + fun initSharedPreferences() { + val packageName = BaseApplication.instance.packageName + //获取到的包名带有“.”方便命名,取最后一个作为sp文件名,例如:com.casic.birmm.inspect + val split = packageName.split(".") + fileName = split[split.size - 1] + } + + /** + * 存储 + */ + fun putValue(key: String?, obj: Any) { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + val editor = sharedPreferences!!.edit() + when (obj) { + is String -> { + editor.putString(key, obj).apply() + } + is Int -> { + editor.putInt(key, obj).apply() + } + is Boolean -> { + editor.putBoolean(key, obj).apply() + } + is Float -> { + editor.putFloat(key, obj).apply() + } + is Long -> { + editor.putLong(key, obj).apply() + } + else -> { + editor.putString(key, obj.toString()).apply() + } + } + } + + /** + * 获取保存的数据 + */ + operator fun getValue(key: String?, defaultObject: Any?): Any? { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + return when (defaultObject) { + is String -> { + sharedPreferences!!.getString(key, defaultObject as String?) + } + is Int -> { + sharedPreferences!!.getInt(key, (defaultObject as Int?)!!) + } + is Boolean -> { + sharedPreferences!!.getBoolean(key, (defaultObject as Boolean?)!!) + } + is Float -> { + sharedPreferences!!.getFloat(key, (defaultObject as Float?)!!) + } + is Long -> { + sharedPreferences!!.getLong(key, (defaultObject as Long?)!!) + } + else -> { + sharedPreferences!!.getString(key, null) + } + } + } + + /** + * 移除某个key值已经对应的值 + */ + fun removeKey(key: String?) { + editor!!.remove(key) + editor!!.commit() + } + + /** + * 清除所有数据 + */ + fun clearAll() { + editor!!.clear() + editor!!.commit() + } + + /** + * 查询某个key是否存在 + */ + fun containsKey(key: String?): Boolean { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + return sharedPreferences!!.contains(key) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt b/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt new file mode 100644 index 0000000..04db86b --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt @@ -0,0 +1,119 @@ +package com.casic.birmm.inspect.widgets + +import android.app.Dialog +import android.content.Context +import android.graphics.Color +import android.graphics.drawable.ColorDrawable +import android.os.Bundle +import android.view.WindowManager +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.utils.OtherUtils +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.dialog_input.* + + +class InputDialog private constructor(builder: Builder) : Dialog(builder.mContext!!) { + + private var ctx: Context? = null + private var title: String? = null + private var value: String? = null + private var positiveBtn: String? = null + private var negativeBtn: String? = null + private var listener: OnDialogButtonClickListener? = null + + init { + this.ctx = builder.mContext + this.title = builder.title + this.value = builder.value + this.positiveBtn = builder.positiveBtn + this.negativeBtn = builder.negativeBtn + this.listener = builder.listener + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + configDialogLayout() + setContentView(R.layout.dialog_input) + setCancelable(false) + setCanceledOnTouchOutside(false) + + dialogTitleView.text = title + value.apply { + dialogInputView.setText(this) + } + + dialogCancelButton.text = negativeBtn + dialogCancelButton.setChangeAlphaWhenPress(true) + dialogCancelButton.setOnClickListener { + this.dismiss() + } + + dialogConfirmButton.text = positiveBtn + dialogConfirmButton.setChangeAlphaWhenPress(true) + dialogConfirmButton.setOnClickListener { + val inputValue = dialogInputView.text.toString().trim() + if (inputValue.isEmpty()) { + OtherUtils.showTipsDialog(ctx!!, "什么都没输入,请重新输入", dialogConfirmButton) + return@setOnClickListener + } + listener?.onButtonClick(inputValue) + this.dismiss() + } + } + + private fun configDialogLayout() { + window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT)) + window?.decorView?.setBackgroundColor(Color.TRANSPARENT) + val params: WindowManager.LayoutParams? = window?.attributes + params?.width = QMUIDisplayHelper.dp2px(ctx, 300) + params?.height = WindowManager.LayoutParams.WRAP_CONTENT + window?.attributes = params + } + + class Builder { + var mContext: Context? = null + var title: String? = null + var value: String? = null + var positiveBtn: String? = null + var negativeBtn: String? = null + var listener: OnDialogButtonClickListener? = null + + fun setContext(context: Context?): Builder { + mContext = context + return this + } + + fun setTitle(title: String?): Builder { + this.title = title + return this + } + + fun setDefaultValue(value: String?): Builder { + this.value = value + return this + } + + fun setPositiveButton(name: String?): Builder { + positiveBtn = name + return this + } + + fun setNegativeButton(name: String?): Builder { + negativeBtn = name + return this + } + + fun setOnDialogClickListener(listener: OnDialogButtonClickListener): Builder { + this.listener = listener + return this + } + + fun build(): InputDialog { + return InputDialog(this) + } + } + + interface OnDialogButtonClickListener { + fun onButtonClick(input: String) + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_dialog_button.xml b/app/src/main/res/drawable/bg_dialog_button.xml new file mode 100644 index 0000000..5f7d57d --- /dev/null +++ b/app/src/main/res/drawable/bg_dialog_button.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_layout_white.xml b/app/src/main/res/drawable/bg_layout_white.xml new file mode 100644 index 0000000..19b473b --- /dev/null +++ b/app/src/main/res/drawable/bg_layout_white.xml @@ -0,0 +1,11 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/guide1.png b/app/src/main/res/drawable/guide1.png new file mode 100644 index 0000000..074c768 --- /dev/null +++ b/app/src/main/res/drawable/guide1.png Binary files differ diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_lock.xml b/app/src/main/res/drawable/ic_lock.xml new file mode 100644 index 0000000..f0a5610 --- /dev/null +++ b/app/src/main/res/drawable/ic_lock.xml @@ -0,0 +1,12 @@ + + + + diff --git a/app/src/main/res/drawable/ic_login_bg.png b/app/src/main/res/drawable/ic_login_bg.png new file mode 100644 index 0000000..64789c3 --- /dev/null +++ b/app/src/main/res/drawable/ic_login_bg.png Binary files differ diff --git a/app/src/main/res/drawable/ic_user.xml b/app/src/main/res/drawable/ic_user.xml new file mode 100644 index 0000000..8c4a29d --- /dev/null +++ b/app/src/main/res/drawable/ic_user.xml @@ -0,0 +1,15 @@ + + + + + diff --git a/app/src/main/res/layout/activity_guide.xml b/app/src/main/res/layout/activity_guide.xml new file mode 100644 index 0000000..e197626 --- /dev/null +++ b/app/src/main/res/layout/activity_guide.xml @@ -0,0 +1,19 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_login.xml b/app/src/main/res/layout/activity_login.xml new file mode 100644 index 0000000..bcae777 --- /dev/null +++ b/app/src/main/res/layout/activity_login.xml @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..def59e4 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,18 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_input.xml b/app/src/main/res/layout/dialog_input.xml new file mode 100644 index 0000000..f5a8bc6 --- /dev/null +++ b/app/src/main/res/layout/dialog_input.xml @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..a571e60 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 0000000..61da551 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..c41dd28 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png new file mode 100644 index 0000000..db5080a --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..6dba46d --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png new file mode 100644 index 0000000..da31a87 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..15ac681 --- /dev/null +++ b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..b216f2d --- /dev/null +++ b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..f25a419 --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..e96783c --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml new file mode 100644 index 0000000..662ee77 --- /dev/null +++ b/app/src/main/res/values/colors.xml @@ -0,0 +1,21 @@ + + + #6200EE + #3700B3 + #03DAC5 + + #FFFFFF + #E5E5E5 + #C0C0C0 + #808080 + #000000 + + #1565E3 + #575757 + + #06134C + #090E47 + #98A0BD + + #54000000 + diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml new file mode 100644 index 0000000..2dddf37 --- /dev/null +++ b/app/src/main/res/values/dimens.xml @@ -0,0 +1,14 @@ + + + 16sp + 18sp + + + 10dp + + + 10dp + + + 1px + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml new file mode 100644 index 0000000..fda9031 --- /dev/null +++ b/app/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + 航小科智巡宝 + diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml new file mode 100644 index 0000000..f16f3a9 --- /dev/null +++ b/app/src/main/res/values/styles.xml @@ -0,0 +1,23 @@ + + + + + + + + + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..603b140 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..88ea3aa --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,122 @@ + + + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+ + +
+
\ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..5cd135a --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..7bfef59 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..4ca4a9f --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,67 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' + +android { + compileSdkVersion 30 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.birmm.inspect" + minSdkVersion 21 + targetSdkVersion 30 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'androidx.core:core-ktx:1.3.2' + implementation 'androidx.constraintlayout:constraintlayout:2.0.4' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test.ext:junit:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:1.3.0' + //腾讯Android UI框架 + implementation 'com.qmuiteam:qmui:2.0.0-alpha10' + implementation 'com.qmuiteam:arch:0.3.1' + //沉浸式状态栏。基础依赖包,必须要依赖 + implementation 'com.gyf.immersionbar:immersionbar:3.0.0' + //fragment快速实现 + implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + + //MVP网络请求框架retrofit2+rxjava + implementation 'io.reactivex:rxjava:1.3.8' + implementation 'io.reactivex:rxandroid:1.2.1' + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.6.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + implementation 'com.squareup.retrofit2:adapter-rxjava:2.8.1' + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.8.6' + //Toast提示 + implementation 'com.sdsmdg.tastytoast:tastytoast:0.1.1' + //图片选择框架 + implementation 'com.github.LuckSiege.PictureSelector:picture_library:v2.6.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..ea03309 --- /dev/null +++ b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.casic.birmm.inspect + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.casic.birmm.inspect", appContext.packageName) + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..7096527 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt new file mode 100644 index 0000000..aefdbb6 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt @@ -0,0 +1,36 @@ +package com.casic.birmm.inspect.base + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.qmuiteam.qmui.util.QMUIStatusBarHelper + +abstract class BaseActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(initLayoutView()) + QMUIStatusBarHelper.translucent(this) //沉浸式状态栏 + setupTopBarLayout() + initData() + initEvent() + } + + /** + * 初始化xml布局 + */ + abstract fun initLayoutView(): Int + + /** + * 特定页面定制沉浸式状态栏 + */ + protected abstract fun setupTopBarLayout() + + /** + * 初始化默认数据 + */ + abstract fun initData() + + /** + * 初始化业务逻辑 + */ + abstract fun initEvent() +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt new file mode 100644 index 0000000..fc0ca75 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt @@ -0,0 +1,18 @@ +package com.casic.birmm.inspect.base + +import android.app.Application +import com.casic.birmm.inspect.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + companion object { + var instance: BaseApplication by Delegates.notNull() + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt new file mode 100644 index 0000000..ddc160a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt @@ -0,0 +1,56 @@ +package com.casic.birmm.inspect.ui + +import android.annotation.SuppressLint +import android.content.Intent +import android.os.CountDownTimer +import android.view.ViewGroup.MarginLayoutParams +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.activity_guide.* + +@SuppressLint("SetTextI18n") +class GuideActivity : BaseActivity() { + + private lateinit var countDownTimer: CountDownTimer + + override fun initLayoutView(): Int = R.layout.activity_guide + + override fun setupTopBarLayout() { + + } + + override fun initData() { + //根据不同设备状态栏高度设置"跳过"按钮的Margin值 + val statusBarHeight = QMUIDisplayHelper.getStatusBarHeight(this) + val rightMargin = QMUIDisplayHelper.dp2px(this, 10) + if (skipButton.layoutParams is MarginLayoutParams) { + val params = skipButton.layoutParams as MarginLayoutParams + params.setMargins(skipButton.width, statusBarHeight, rightMargin, 0) + skipButton.requestLayout() + } + + countDownTimer = object : CountDownTimer(4000, 1000) { + override fun onFinish() { + startLoginActivity() + } + + override fun onTick(millisUntilFinished: Long) { + skipButton.text = "跳过\u3000${(millisUntilFinished / 1000)}s" + } + } + } + + override fun initEvent() { + countDownTimer.start() + skipButton.setOnClickListener { + countDownTimer.cancel() + startLoginActivity() + } + } + + fun startLoginActivity() { + startActivity(Intent(this, LoginActivity::class.java)) + finish() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt new file mode 100644 index 0000000..6ef4548 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt @@ -0,0 +1,81 @@ +package com.casic.birmm.inspect.ui + +import android.text.Editable +import android.text.TextWatcher +import android.view.KeyEvent +import android.view.inputmethod.EditorInfo +import android.widget.EditText +import android.widget.TextView +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.casic.birmm.inspect.utils.Constant +import com.casic.birmm.inspect.utils.SaveKeyValues +import com.casic.birmm.inspect.widgets.InputDialog +import kotlinx.android.synthetic.main.activity_login.* + + +class LoginActivity : BaseActivity() { + + companion object { + private const val Tag = "LoginActivity" + } + + override fun initLayoutView(): Int = R.layout.activity_login + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + loginButton.setChangeAlphaWhenPress(true) + val editText: EditText? = inputLayout.editText + editText?.addTextChangedListener(object : TextWatcher { + override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) { + + } + + override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) { + + } + + override fun afterTextChanged(s: Editable) { + if (s.toString().trim { it <= ' ' }.length > 12) { + inputLayout.error = "密码长度超出限制" + } else { + inputLayout.error = null + } + } + }) + //点击输入法键盘"完成" + editText?.setOnEditorActionListener { _: TextView?, actionId: Int, _: KeyEvent? -> + if (actionId == EditorInfo.IME_ACTION_DONE) { +// authenticatePresenter.onReadyRetrofitRequest() + return@setOnEditorActionListener true + } + false + } + + //修改服务器配置 + changeServerConfigView.setOnClickListener { + val defaultValue = SaveKeyValues.getValue( + Constant.DEFAULT_SERVER_CONFIG, + "http://139.198.6.177:8093/" + ) as String + InputDialog.Builder().setContext(this) + .setTitle("请输入后台服务器地址") + .setDefaultValue(defaultValue) + .setNegativeButton("取消") + .setPositiveButton("保存") + .setOnDialogClickListener(object : InputDialog.OnDialogButtonClickListener { + override fun onButtonClick(input: String) { + SaveKeyValues.putValue(Constant.DEFAULT_SERVER_CONFIG, input) + } + }) + .build().show() + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt new file mode 100644 index 0000000..0e97af7 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt @@ -0,0 +1,21 @@ +package com.casic.birmm.inspect.ui + +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity + +class MainActivity : BaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt new file mode 100644 index 0000000..21fbba2 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt @@ -0,0 +1,58 @@ +package com.casic.birmm.inspect.ui + +import android.content.Intent +import android.os.Build +import android.os.Bundle +import android.util.Log +import androidx.appcompat.app.AppCompatActivity +import com.casic.birmm.inspect.utils.Constant +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + companion object { + private const val TAG = "PermissionActivity" + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + if (EasyPermissions.hasPermissions(this, *Constant.USER_PERMISSIONS)) { + startGuideActivity() + } else { + EasyPermissions.requestPermissions( + this, + "需要获取相关权限", + Constant.PERMISSIONS_CODE, + *Constant.USER_PERMISSIONS + ) + } + } else { + startGuideActivity() + } + } + + private fun startGuideActivity() { + startActivity(Intent(this, GuideActivity::class.java)) + finish() + } + + override fun onRequestPermissionsResult( + requestCode: Int, + permissions: Array, + grantResults: IntArray + ) { + super.onRequestPermissionsResult(requestCode, permissions, grantResults) + EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this) + } + + override fun onPermissionsGranted(requestCode: Int, perms: List) { + startGuideActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + Log.e(TAG, "onPermissionsDenied: $perms") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt new file mode 100644 index 0000000..53df6e1 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt @@ -0,0 +1,15 @@ +package com.casic.birmm.inspect.utils + +import android.Manifest + + +object Constant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.ACCESS_LOCATION_EXTRA_COMMANDS, + Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION + ) + + const val PERMISSIONS_CODE = 999 + + const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt new file mode 100644 index 0000000..4c38241 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt @@ -0,0 +1,19 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.view.View +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object OtherUtils { + + //替换Toast + fun showTipsDialog(context: Context, message: String, view: View) { + val tipDialog = QMUITipDialog.Builder(context) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_NOTHING) + .setTipWord(message).create() + tipDialog.show() + view.postDelayed({ + tipDialog.dismiss() + }, 2000) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt b/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt new file mode 100644 index 0000000..04c9f5a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt @@ -0,0 +1,106 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.content.SharedPreferences +import com.casic.birmm.inspect.base.BaseApplication + +object SaveKeyValues { + private var sharedPreferences: SharedPreferences? = null + private var editor: SharedPreferences.Editor? = null + private var fileName: String? = null + + fun initSharedPreferences() { + val packageName = BaseApplication.instance.packageName + //获取到的包名带有“.”方便命名,取最后一个作为sp文件名,例如:com.casic.birmm.inspect + val split = packageName.split(".") + fileName = split[split.size - 1] + } + + /** + * 存储 + */ + fun putValue(key: String?, obj: Any) { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + val editor = sharedPreferences!!.edit() + when (obj) { + is String -> { + editor.putString(key, obj).apply() + } + is Int -> { + editor.putInt(key, obj).apply() + } + is Boolean -> { + editor.putBoolean(key, obj).apply() + } + is Float -> { + editor.putFloat(key, obj).apply() + } + is Long -> { + editor.putLong(key, obj).apply() + } + else -> { + editor.putString(key, obj.toString()).apply() + } + } + } + + /** + * 获取保存的数据 + */ + operator fun getValue(key: String?, defaultObject: Any?): Any? { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + return when (defaultObject) { + is String -> { + sharedPreferences!!.getString(key, defaultObject as String?) + } + is Int -> { + sharedPreferences!!.getInt(key, (defaultObject as Int?)!!) + } + is Boolean -> { + sharedPreferences!!.getBoolean(key, (defaultObject as Boolean?)!!) + } + is Float -> { + sharedPreferences!!.getFloat(key, (defaultObject as Float?)!!) + } + is Long -> { + sharedPreferences!!.getLong(key, (defaultObject as Long?)!!) + } + else -> { + sharedPreferences!!.getString(key, null) + } + } + } + + /** + * 移除某个key值已经对应的值 + */ + fun removeKey(key: String?) { + editor!!.remove(key) + editor!!.commit() + } + + /** + * 清除所有数据 + */ + fun clearAll() { + editor!!.clear() + editor!!.commit() + } + + /** + * 查询某个key是否存在 + */ + fun containsKey(key: String?): Boolean { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + return sharedPreferences!!.contains(key) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt b/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt new file mode 100644 index 0000000..04db86b --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt @@ -0,0 +1,119 @@ +package com.casic.birmm.inspect.widgets + +import android.app.Dialog +import android.content.Context +import android.graphics.Color +import android.graphics.drawable.ColorDrawable +import android.os.Bundle +import android.view.WindowManager +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.utils.OtherUtils +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.dialog_input.* + + +class InputDialog private constructor(builder: Builder) : Dialog(builder.mContext!!) { + + private var ctx: Context? = null + private var title: String? = null + private var value: String? = null + private var positiveBtn: String? = null + private var negativeBtn: String? = null + private var listener: OnDialogButtonClickListener? = null + + init { + this.ctx = builder.mContext + this.title = builder.title + this.value = builder.value + this.positiveBtn = builder.positiveBtn + this.negativeBtn = builder.negativeBtn + this.listener = builder.listener + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + configDialogLayout() + setContentView(R.layout.dialog_input) + setCancelable(false) + setCanceledOnTouchOutside(false) + + dialogTitleView.text = title + value.apply { + dialogInputView.setText(this) + } + + dialogCancelButton.text = negativeBtn + dialogCancelButton.setChangeAlphaWhenPress(true) + dialogCancelButton.setOnClickListener { + this.dismiss() + } + + dialogConfirmButton.text = positiveBtn + dialogConfirmButton.setChangeAlphaWhenPress(true) + dialogConfirmButton.setOnClickListener { + val inputValue = dialogInputView.text.toString().trim() + if (inputValue.isEmpty()) { + OtherUtils.showTipsDialog(ctx!!, "什么都没输入,请重新输入", dialogConfirmButton) + return@setOnClickListener + } + listener?.onButtonClick(inputValue) + this.dismiss() + } + } + + private fun configDialogLayout() { + window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT)) + window?.decorView?.setBackgroundColor(Color.TRANSPARENT) + val params: WindowManager.LayoutParams? = window?.attributes + params?.width = QMUIDisplayHelper.dp2px(ctx, 300) + params?.height = WindowManager.LayoutParams.WRAP_CONTENT + window?.attributes = params + } + + class Builder { + var mContext: Context? = null + var title: String? = null + var value: String? = null + var positiveBtn: String? = null + var negativeBtn: String? = null + var listener: OnDialogButtonClickListener? = null + + fun setContext(context: Context?): Builder { + mContext = context + return this + } + + fun setTitle(title: String?): Builder { + this.title = title + return this + } + + fun setDefaultValue(value: String?): Builder { + this.value = value + return this + } + + fun setPositiveButton(name: String?): Builder { + positiveBtn = name + return this + } + + fun setNegativeButton(name: String?): Builder { + negativeBtn = name + return this + } + + fun setOnDialogClickListener(listener: OnDialogButtonClickListener): Builder { + this.listener = listener + return this + } + + fun build(): InputDialog { + return InputDialog(this) + } + } + + interface OnDialogButtonClickListener { + fun onButtonClick(input: String) + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_dialog_button.xml b/app/src/main/res/drawable/bg_dialog_button.xml new file mode 100644 index 0000000..5f7d57d --- /dev/null +++ b/app/src/main/res/drawable/bg_dialog_button.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_layout_white.xml b/app/src/main/res/drawable/bg_layout_white.xml new file mode 100644 index 0000000..19b473b --- /dev/null +++ b/app/src/main/res/drawable/bg_layout_white.xml @@ -0,0 +1,11 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/guide1.png b/app/src/main/res/drawable/guide1.png new file mode 100644 index 0000000..074c768 --- /dev/null +++ b/app/src/main/res/drawable/guide1.png Binary files differ diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_lock.xml b/app/src/main/res/drawable/ic_lock.xml new file mode 100644 index 0000000..f0a5610 --- /dev/null +++ b/app/src/main/res/drawable/ic_lock.xml @@ -0,0 +1,12 @@ + + + + diff --git a/app/src/main/res/drawable/ic_login_bg.png b/app/src/main/res/drawable/ic_login_bg.png new file mode 100644 index 0000000..64789c3 --- /dev/null +++ b/app/src/main/res/drawable/ic_login_bg.png Binary files differ diff --git a/app/src/main/res/drawable/ic_user.xml b/app/src/main/res/drawable/ic_user.xml new file mode 100644 index 0000000..8c4a29d --- /dev/null +++ b/app/src/main/res/drawable/ic_user.xml @@ -0,0 +1,15 @@ + + + + + diff --git a/app/src/main/res/layout/activity_guide.xml b/app/src/main/res/layout/activity_guide.xml new file mode 100644 index 0000000..e197626 --- /dev/null +++ b/app/src/main/res/layout/activity_guide.xml @@ -0,0 +1,19 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_login.xml b/app/src/main/res/layout/activity_login.xml new file mode 100644 index 0000000..bcae777 --- /dev/null +++ b/app/src/main/res/layout/activity_login.xml @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..def59e4 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,18 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_input.xml b/app/src/main/res/layout/dialog_input.xml new file mode 100644 index 0000000..f5a8bc6 --- /dev/null +++ b/app/src/main/res/layout/dialog_input.xml @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..a571e60 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 0000000..61da551 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..c41dd28 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png new file mode 100644 index 0000000..db5080a --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..6dba46d --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png new file mode 100644 index 0000000..da31a87 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..15ac681 --- /dev/null +++ b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..b216f2d --- /dev/null +++ b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..f25a419 --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..e96783c --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml new file mode 100644 index 0000000..662ee77 --- /dev/null +++ b/app/src/main/res/values/colors.xml @@ -0,0 +1,21 @@ + + + #6200EE + #3700B3 + #03DAC5 + + #FFFFFF + #E5E5E5 + #C0C0C0 + #808080 + #000000 + + #1565E3 + #575757 + + #06134C + #090E47 + #98A0BD + + #54000000 + diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml new file mode 100644 index 0000000..2dddf37 --- /dev/null +++ b/app/src/main/res/values/dimens.xml @@ -0,0 +1,14 @@ + + + 16sp + 18sp + + + 10dp + + + 10dp + + + 1px + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml new file mode 100644 index 0000000..fda9031 --- /dev/null +++ b/app/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + 航小科智巡宝 + diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml new file mode 100644 index 0000000..f16f3a9 --- /dev/null +++ b/app/src/main/res/values/styles.xml @@ -0,0 +1,23 @@ + + + + + + + + + diff --git a/app/src/test/java/com/casic/birmm/inspect/ExampleUnitTest.kt b/app/src/test/java/com/casic/birmm/inspect/ExampleUnitTest.kt new file mode 100644 index 0000000..21e44ca --- /dev/null +++ b/app/src/test/java/com/casic/birmm/inspect/ExampleUnitTest.kt @@ -0,0 +1,17 @@ +package com.casic.birmm.inspect + +import org.junit.Test + +import org.junit.Assert.* + +/** + * Example local unit test, which will execute on the development machine (host). + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +class ExampleUnitTest { + @Test + fun addition_isCorrect() { + assertEquals(4, 2 + 2) + } +} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..603b140 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..88ea3aa --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,122 @@ + + + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+ + +
+
\ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..5cd135a --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..7bfef59 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..4ca4a9f --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,67 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' + +android { + compileSdkVersion 30 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.birmm.inspect" + minSdkVersion 21 + targetSdkVersion 30 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'androidx.core:core-ktx:1.3.2' + implementation 'androidx.constraintlayout:constraintlayout:2.0.4' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test.ext:junit:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:1.3.0' + //腾讯Android UI框架 + implementation 'com.qmuiteam:qmui:2.0.0-alpha10' + implementation 'com.qmuiteam:arch:0.3.1' + //沉浸式状态栏。基础依赖包,必须要依赖 + implementation 'com.gyf.immersionbar:immersionbar:3.0.0' + //fragment快速实现 + implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + + //MVP网络请求框架retrofit2+rxjava + implementation 'io.reactivex:rxjava:1.3.8' + implementation 'io.reactivex:rxandroid:1.2.1' + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.6.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + implementation 'com.squareup.retrofit2:adapter-rxjava:2.8.1' + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.8.6' + //Toast提示 + implementation 'com.sdsmdg.tastytoast:tastytoast:0.1.1' + //图片选择框架 + implementation 'com.github.LuckSiege.PictureSelector:picture_library:v2.6.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..ea03309 --- /dev/null +++ b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.casic.birmm.inspect + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.casic.birmm.inspect", appContext.packageName) + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..7096527 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt new file mode 100644 index 0000000..aefdbb6 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt @@ -0,0 +1,36 @@ +package com.casic.birmm.inspect.base + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.qmuiteam.qmui.util.QMUIStatusBarHelper + +abstract class BaseActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(initLayoutView()) + QMUIStatusBarHelper.translucent(this) //沉浸式状态栏 + setupTopBarLayout() + initData() + initEvent() + } + + /** + * 初始化xml布局 + */ + abstract fun initLayoutView(): Int + + /** + * 特定页面定制沉浸式状态栏 + */ + protected abstract fun setupTopBarLayout() + + /** + * 初始化默认数据 + */ + abstract fun initData() + + /** + * 初始化业务逻辑 + */ + abstract fun initEvent() +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt new file mode 100644 index 0000000..fc0ca75 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt @@ -0,0 +1,18 @@ +package com.casic.birmm.inspect.base + +import android.app.Application +import com.casic.birmm.inspect.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + companion object { + var instance: BaseApplication by Delegates.notNull() + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt new file mode 100644 index 0000000..ddc160a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt @@ -0,0 +1,56 @@ +package com.casic.birmm.inspect.ui + +import android.annotation.SuppressLint +import android.content.Intent +import android.os.CountDownTimer +import android.view.ViewGroup.MarginLayoutParams +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.activity_guide.* + +@SuppressLint("SetTextI18n") +class GuideActivity : BaseActivity() { + + private lateinit var countDownTimer: CountDownTimer + + override fun initLayoutView(): Int = R.layout.activity_guide + + override fun setupTopBarLayout() { + + } + + override fun initData() { + //根据不同设备状态栏高度设置"跳过"按钮的Margin值 + val statusBarHeight = QMUIDisplayHelper.getStatusBarHeight(this) + val rightMargin = QMUIDisplayHelper.dp2px(this, 10) + if (skipButton.layoutParams is MarginLayoutParams) { + val params = skipButton.layoutParams as MarginLayoutParams + params.setMargins(skipButton.width, statusBarHeight, rightMargin, 0) + skipButton.requestLayout() + } + + countDownTimer = object : CountDownTimer(4000, 1000) { + override fun onFinish() { + startLoginActivity() + } + + override fun onTick(millisUntilFinished: Long) { + skipButton.text = "跳过\u3000${(millisUntilFinished / 1000)}s" + } + } + } + + override fun initEvent() { + countDownTimer.start() + skipButton.setOnClickListener { + countDownTimer.cancel() + startLoginActivity() + } + } + + fun startLoginActivity() { + startActivity(Intent(this, LoginActivity::class.java)) + finish() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt new file mode 100644 index 0000000..6ef4548 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt @@ -0,0 +1,81 @@ +package com.casic.birmm.inspect.ui + +import android.text.Editable +import android.text.TextWatcher +import android.view.KeyEvent +import android.view.inputmethod.EditorInfo +import android.widget.EditText +import android.widget.TextView +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.casic.birmm.inspect.utils.Constant +import com.casic.birmm.inspect.utils.SaveKeyValues +import com.casic.birmm.inspect.widgets.InputDialog +import kotlinx.android.synthetic.main.activity_login.* + + +class LoginActivity : BaseActivity() { + + companion object { + private const val Tag = "LoginActivity" + } + + override fun initLayoutView(): Int = R.layout.activity_login + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + loginButton.setChangeAlphaWhenPress(true) + val editText: EditText? = inputLayout.editText + editText?.addTextChangedListener(object : TextWatcher { + override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) { + + } + + override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) { + + } + + override fun afterTextChanged(s: Editable) { + if (s.toString().trim { it <= ' ' }.length > 12) { + inputLayout.error = "密码长度超出限制" + } else { + inputLayout.error = null + } + } + }) + //点击输入法键盘"完成" + editText?.setOnEditorActionListener { _: TextView?, actionId: Int, _: KeyEvent? -> + if (actionId == EditorInfo.IME_ACTION_DONE) { +// authenticatePresenter.onReadyRetrofitRequest() + return@setOnEditorActionListener true + } + false + } + + //修改服务器配置 + changeServerConfigView.setOnClickListener { + val defaultValue = SaveKeyValues.getValue( + Constant.DEFAULT_SERVER_CONFIG, + "http://139.198.6.177:8093/" + ) as String + InputDialog.Builder().setContext(this) + .setTitle("请输入后台服务器地址") + .setDefaultValue(defaultValue) + .setNegativeButton("取消") + .setPositiveButton("保存") + .setOnDialogClickListener(object : InputDialog.OnDialogButtonClickListener { + override fun onButtonClick(input: String) { + SaveKeyValues.putValue(Constant.DEFAULT_SERVER_CONFIG, input) + } + }) + .build().show() + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt new file mode 100644 index 0000000..0e97af7 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt @@ -0,0 +1,21 @@ +package com.casic.birmm.inspect.ui + +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity + +class MainActivity : BaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt new file mode 100644 index 0000000..21fbba2 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt @@ -0,0 +1,58 @@ +package com.casic.birmm.inspect.ui + +import android.content.Intent +import android.os.Build +import android.os.Bundle +import android.util.Log +import androidx.appcompat.app.AppCompatActivity +import com.casic.birmm.inspect.utils.Constant +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + companion object { + private const val TAG = "PermissionActivity" + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + if (EasyPermissions.hasPermissions(this, *Constant.USER_PERMISSIONS)) { + startGuideActivity() + } else { + EasyPermissions.requestPermissions( + this, + "需要获取相关权限", + Constant.PERMISSIONS_CODE, + *Constant.USER_PERMISSIONS + ) + } + } else { + startGuideActivity() + } + } + + private fun startGuideActivity() { + startActivity(Intent(this, GuideActivity::class.java)) + finish() + } + + override fun onRequestPermissionsResult( + requestCode: Int, + permissions: Array, + grantResults: IntArray + ) { + super.onRequestPermissionsResult(requestCode, permissions, grantResults) + EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this) + } + + override fun onPermissionsGranted(requestCode: Int, perms: List) { + startGuideActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + Log.e(TAG, "onPermissionsDenied: $perms") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt new file mode 100644 index 0000000..53df6e1 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt @@ -0,0 +1,15 @@ +package com.casic.birmm.inspect.utils + +import android.Manifest + + +object Constant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.ACCESS_LOCATION_EXTRA_COMMANDS, + Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION + ) + + const val PERMISSIONS_CODE = 999 + + const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt new file mode 100644 index 0000000..4c38241 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt @@ -0,0 +1,19 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.view.View +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object OtherUtils { + + //替换Toast + fun showTipsDialog(context: Context, message: String, view: View) { + val tipDialog = QMUITipDialog.Builder(context) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_NOTHING) + .setTipWord(message).create() + tipDialog.show() + view.postDelayed({ + tipDialog.dismiss() + }, 2000) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt b/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt new file mode 100644 index 0000000..04c9f5a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt @@ -0,0 +1,106 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.content.SharedPreferences +import com.casic.birmm.inspect.base.BaseApplication + +object SaveKeyValues { + private var sharedPreferences: SharedPreferences? = null + private var editor: SharedPreferences.Editor? = null + private var fileName: String? = null + + fun initSharedPreferences() { + val packageName = BaseApplication.instance.packageName + //获取到的包名带有“.”方便命名,取最后一个作为sp文件名,例如:com.casic.birmm.inspect + val split = packageName.split(".") + fileName = split[split.size - 1] + } + + /** + * 存储 + */ + fun putValue(key: String?, obj: Any) { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + val editor = sharedPreferences!!.edit() + when (obj) { + is String -> { + editor.putString(key, obj).apply() + } + is Int -> { + editor.putInt(key, obj).apply() + } + is Boolean -> { + editor.putBoolean(key, obj).apply() + } + is Float -> { + editor.putFloat(key, obj).apply() + } + is Long -> { + editor.putLong(key, obj).apply() + } + else -> { + editor.putString(key, obj.toString()).apply() + } + } + } + + /** + * 获取保存的数据 + */ + operator fun getValue(key: String?, defaultObject: Any?): Any? { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + return when (defaultObject) { + is String -> { + sharedPreferences!!.getString(key, defaultObject as String?) + } + is Int -> { + sharedPreferences!!.getInt(key, (defaultObject as Int?)!!) + } + is Boolean -> { + sharedPreferences!!.getBoolean(key, (defaultObject as Boolean?)!!) + } + is Float -> { + sharedPreferences!!.getFloat(key, (defaultObject as Float?)!!) + } + is Long -> { + sharedPreferences!!.getLong(key, (defaultObject as Long?)!!) + } + else -> { + sharedPreferences!!.getString(key, null) + } + } + } + + /** + * 移除某个key值已经对应的值 + */ + fun removeKey(key: String?) { + editor!!.remove(key) + editor!!.commit() + } + + /** + * 清除所有数据 + */ + fun clearAll() { + editor!!.clear() + editor!!.commit() + } + + /** + * 查询某个key是否存在 + */ + fun containsKey(key: String?): Boolean { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + return sharedPreferences!!.contains(key) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt b/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt new file mode 100644 index 0000000..04db86b --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt @@ -0,0 +1,119 @@ +package com.casic.birmm.inspect.widgets + +import android.app.Dialog +import android.content.Context +import android.graphics.Color +import android.graphics.drawable.ColorDrawable +import android.os.Bundle +import android.view.WindowManager +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.utils.OtherUtils +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.dialog_input.* + + +class InputDialog private constructor(builder: Builder) : Dialog(builder.mContext!!) { + + private var ctx: Context? = null + private var title: String? = null + private var value: String? = null + private var positiveBtn: String? = null + private var negativeBtn: String? = null + private var listener: OnDialogButtonClickListener? = null + + init { + this.ctx = builder.mContext + this.title = builder.title + this.value = builder.value + this.positiveBtn = builder.positiveBtn + this.negativeBtn = builder.negativeBtn + this.listener = builder.listener + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + configDialogLayout() + setContentView(R.layout.dialog_input) + setCancelable(false) + setCanceledOnTouchOutside(false) + + dialogTitleView.text = title + value.apply { + dialogInputView.setText(this) + } + + dialogCancelButton.text = negativeBtn + dialogCancelButton.setChangeAlphaWhenPress(true) + dialogCancelButton.setOnClickListener { + this.dismiss() + } + + dialogConfirmButton.text = positiveBtn + dialogConfirmButton.setChangeAlphaWhenPress(true) + dialogConfirmButton.setOnClickListener { + val inputValue = dialogInputView.text.toString().trim() + if (inputValue.isEmpty()) { + OtherUtils.showTipsDialog(ctx!!, "什么都没输入,请重新输入", dialogConfirmButton) + return@setOnClickListener + } + listener?.onButtonClick(inputValue) + this.dismiss() + } + } + + private fun configDialogLayout() { + window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT)) + window?.decorView?.setBackgroundColor(Color.TRANSPARENT) + val params: WindowManager.LayoutParams? = window?.attributes + params?.width = QMUIDisplayHelper.dp2px(ctx, 300) + params?.height = WindowManager.LayoutParams.WRAP_CONTENT + window?.attributes = params + } + + class Builder { + var mContext: Context? = null + var title: String? = null + var value: String? = null + var positiveBtn: String? = null + var negativeBtn: String? = null + var listener: OnDialogButtonClickListener? = null + + fun setContext(context: Context?): Builder { + mContext = context + return this + } + + fun setTitle(title: String?): Builder { + this.title = title + return this + } + + fun setDefaultValue(value: String?): Builder { + this.value = value + return this + } + + fun setPositiveButton(name: String?): Builder { + positiveBtn = name + return this + } + + fun setNegativeButton(name: String?): Builder { + negativeBtn = name + return this + } + + fun setOnDialogClickListener(listener: OnDialogButtonClickListener): Builder { + this.listener = listener + return this + } + + fun build(): InputDialog { + return InputDialog(this) + } + } + + interface OnDialogButtonClickListener { + fun onButtonClick(input: String) + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_dialog_button.xml b/app/src/main/res/drawable/bg_dialog_button.xml new file mode 100644 index 0000000..5f7d57d --- /dev/null +++ b/app/src/main/res/drawable/bg_dialog_button.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_layout_white.xml b/app/src/main/res/drawable/bg_layout_white.xml new file mode 100644 index 0000000..19b473b --- /dev/null +++ b/app/src/main/res/drawable/bg_layout_white.xml @@ -0,0 +1,11 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/guide1.png b/app/src/main/res/drawable/guide1.png new file mode 100644 index 0000000..074c768 --- /dev/null +++ b/app/src/main/res/drawable/guide1.png Binary files differ diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_lock.xml b/app/src/main/res/drawable/ic_lock.xml new file mode 100644 index 0000000..f0a5610 --- /dev/null +++ b/app/src/main/res/drawable/ic_lock.xml @@ -0,0 +1,12 @@ + + + + diff --git a/app/src/main/res/drawable/ic_login_bg.png b/app/src/main/res/drawable/ic_login_bg.png new file mode 100644 index 0000000..64789c3 --- /dev/null +++ b/app/src/main/res/drawable/ic_login_bg.png Binary files differ diff --git a/app/src/main/res/drawable/ic_user.xml b/app/src/main/res/drawable/ic_user.xml new file mode 100644 index 0000000..8c4a29d --- /dev/null +++ b/app/src/main/res/drawable/ic_user.xml @@ -0,0 +1,15 @@ + + + + + diff --git a/app/src/main/res/layout/activity_guide.xml b/app/src/main/res/layout/activity_guide.xml new file mode 100644 index 0000000..e197626 --- /dev/null +++ b/app/src/main/res/layout/activity_guide.xml @@ -0,0 +1,19 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_login.xml b/app/src/main/res/layout/activity_login.xml new file mode 100644 index 0000000..bcae777 --- /dev/null +++ b/app/src/main/res/layout/activity_login.xml @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..def59e4 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,18 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_input.xml b/app/src/main/res/layout/dialog_input.xml new file mode 100644 index 0000000..f5a8bc6 --- /dev/null +++ b/app/src/main/res/layout/dialog_input.xml @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..a571e60 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 0000000..61da551 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..c41dd28 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png new file mode 100644 index 0000000..db5080a --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..6dba46d --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png new file mode 100644 index 0000000..da31a87 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..15ac681 --- /dev/null +++ b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..b216f2d --- /dev/null +++ b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..f25a419 --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..e96783c --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml new file mode 100644 index 0000000..662ee77 --- /dev/null +++ b/app/src/main/res/values/colors.xml @@ -0,0 +1,21 @@ + + + #6200EE + #3700B3 + #03DAC5 + + #FFFFFF + #E5E5E5 + #C0C0C0 + #808080 + #000000 + + #1565E3 + #575757 + + #06134C + #090E47 + #98A0BD + + #54000000 + diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml new file mode 100644 index 0000000..2dddf37 --- /dev/null +++ b/app/src/main/res/values/dimens.xml @@ -0,0 +1,14 @@ + + + 16sp + 18sp + + + 10dp + + + 10dp + + + 1px + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml new file mode 100644 index 0000000..fda9031 --- /dev/null +++ b/app/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + 航小科智巡宝 + diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml new file mode 100644 index 0000000..f16f3a9 --- /dev/null +++ b/app/src/main/res/values/styles.xml @@ -0,0 +1,23 @@ + + + + + + + + + diff --git a/app/src/test/java/com/casic/birmm/inspect/ExampleUnitTest.kt b/app/src/test/java/com/casic/birmm/inspect/ExampleUnitTest.kt new file mode 100644 index 0000000..21e44ca --- /dev/null +++ b/app/src/test/java/com/casic/birmm/inspect/ExampleUnitTest.kt @@ -0,0 +1,17 @@ +package com.casic.birmm.inspect + +import org.junit.Test + +import org.junit.Assert.* + +/** + * Example local unit test, which will execute on the development machine (host). + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +class ExampleUnitTest { + @Test + fun addition_isCorrect() { + assertEquals(4, 2 + 2) + } +} diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..500f939 --- /dev/null +++ b/build.gradle @@ -0,0 +1,31 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. + +buildscript { + ext.kotlin_version = '1.3.61' + repositories { + maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' } + google() + jcenter() + } + dependencies { + classpath 'com.android.tools.build:gradle:3.6.3' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files + } +} + +allprojects { + repositories { + maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' } + //依赖库 + maven { url 'https://jitpack.io' } + google() + jcenter() + } +} + +task clean(type: Delete) { + delete rootProject.buildDir +} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..603b140 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..88ea3aa --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,122 @@ + + + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+ + +
+
\ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..5cd135a --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..7bfef59 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..4ca4a9f --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,67 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' + +android { + compileSdkVersion 30 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.birmm.inspect" + minSdkVersion 21 + targetSdkVersion 30 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'androidx.core:core-ktx:1.3.2' + implementation 'androidx.constraintlayout:constraintlayout:2.0.4' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test.ext:junit:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:1.3.0' + //腾讯Android UI框架 + implementation 'com.qmuiteam:qmui:2.0.0-alpha10' + implementation 'com.qmuiteam:arch:0.3.1' + //沉浸式状态栏。基础依赖包,必须要依赖 + implementation 'com.gyf.immersionbar:immersionbar:3.0.0' + //fragment快速实现 + implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + + //MVP网络请求框架retrofit2+rxjava + implementation 'io.reactivex:rxjava:1.3.8' + implementation 'io.reactivex:rxandroid:1.2.1' + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.6.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + implementation 'com.squareup.retrofit2:adapter-rxjava:2.8.1' + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.8.6' + //Toast提示 + implementation 'com.sdsmdg.tastytoast:tastytoast:0.1.1' + //图片选择框架 + implementation 'com.github.LuckSiege.PictureSelector:picture_library:v2.6.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..ea03309 --- /dev/null +++ b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.casic.birmm.inspect + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.casic.birmm.inspect", appContext.packageName) + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..7096527 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt new file mode 100644 index 0000000..aefdbb6 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt @@ -0,0 +1,36 @@ +package com.casic.birmm.inspect.base + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.qmuiteam.qmui.util.QMUIStatusBarHelper + +abstract class BaseActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(initLayoutView()) + QMUIStatusBarHelper.translucent(this) //沉浸式状态栏 + setupTopBarLayout() + initData() + initEvent() + } + + /** + * 初始化xml布局 + */ + abstract fun initLayoutView(): Int + + /** + * 特定页面定制沉浸式状态栏 + */ + protected abstract fun setupTopBarLayout() + + /** + * 初始化默认数据 + */ + abstract fun initData() + + /** + * 初始化业务逻辑 + */ + abstract fun initEvent() +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt new file mode 100644 index 0000000..fc0ca75 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt @@ -0,0 +1,18 @@ +package com.casic.birmm.inspect.base + +import android.app.Application +import com.casic.birmm.inspect.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + companion object { + var instance: BaseApplication by Delegates.notNull() + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt new file mode 100644 index 0000000..ddc160a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt @@ -0,0 +1,56 @@ +package com.casic.birmm.inspect.ui + +import android.annotation.SuppressLint +import android.content.Intent +import android.os.CountDownTimer +import android.view.ViewGroup.MarginLayoutParams +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.activity_guide.* + +@SuppressLint("SetTextI18n") +class GuideActivity : BaseActivity() { + + private lateinit var countDownTimer: CountDownTimer + + override fun initLayoutView(): Int = R.layout.activity_guide + + override fun setupTopBarLayout() { + + } + + override fun initData() { + //根据不同设备状态栏高度设置"跳过"按钮的Margin值 + val statusBarHeight = QMUIDisplayHelper.getStatusBarHeight(this) + val rightMargin = QMUIDisplayHelper.dp2px(this, 10) + if (skipButton.layoutParams is MarginLayoutParams) { + val params = skipButton.layoutParams as MarginLayoutParams + params.setMargins(skipButton.width, statusBarHeight, rightMargin, 0) + skipButton.requestLayout() + } + + countDownTimer = object : CountDownTimer(4000, 1000) { + override fun onFinish() { + startLoginActivity() + } + + override fun onTick(millisUntilFinished: Long) { + skipButton.text = "跳过\u3000${(millisUntilFinished / 1000)}s" + } + } + } + + override fun initEvent() { + countDownTimer.start() + skipButton.setOnClickListener { + countDownTimer.cancel() + startLoginActivity() + } + } + + fun startLoginActivity() { + startActivity(Intent(this, LoginActivity::class.java)) + finish() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt new file mode 100644 index 0000000..6ef4548 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt @@ -0,0 +1,81 @@ +package com.casic.birmm.inspect.ui + +import android.text.Editable +import android.text.TextWatcher +import android.view.KeyEvent +import android.view.inputmethod.EditorInfo +import android.widget.EditText +import android.widget.TextView +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.casic.birmm.inspect.utils.Constant +import com.casic.birmm.inspect.utils.SaveKeyValues +import com.casic.birmm.inspect.widgets.InputDialog +import kotlinx.android.synthetic.main.activity_login.* + + +class LoginActivity : BaseActivity() { + + companion object { + private const val Tag = "LoginActivity" + } + + override fun initLayoutView(): Int = R.layout.activity_login + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + loginButton.setChangeAlphaWhenPress(true) + val editText: EditText? = inputLayout.editText + editText?.addTextChangedListener(object : TextWatcher { + override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) { + + } + + override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) { + + } + + override fun afterTextChanged(s: Editable) { + if (s.toString().trim { it <= ' ' }.length > 12) { + inputLayout.error = "密码长度超出限制" + } else { + inputLayout.error = null + } + } + }) + //点击输入法键盘"完成" + editText?.setOnEditorActionListener { _: TextView?, actionId: Int, _: KeyEvent? -> + if (actionId == EditorInfo.IME_ACTION_DONE) { +// authenticatePresenter.onReadyRetrofitRequest() + return@setOnEditorActionListener true + } + false + } + + //修改服务器配置 + changeServerConfigView.setOnClickListener { + val defaultValue = SaveKeyValues.getValue( + Constant.DEFAULT_SERVER_CONFIG, + "http://139.198.6.177:8093/" + ) as String + InputDialog.Builder().setContext(this) + .setTitle("请输入后台服务器地址") + .setDefaultValue(defaultValue) + .setNegativeButton("取消") + .setPositiveButton("保存") + .setOnDialogClickListener(object : InputDialog.OnDialogButtonClickListener { + override fun onButtonClick(input: String) { + SaveKeyValues.putValue(Constant.DEFAULT_SERVER_CONFIG, input) + } + }) + .build().show() + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt new file mode 100644 index 0000000..0e97af7 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt @@ -0,0 +1,21 @@ +package com.casic.birmm.inspect.ui + +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity + +class MainActivity : BaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt new file mode 100644 index 0000000..21fbba2 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt @@ -0,0 +1,58 @@ +package com.casic.birmm.inspect.ui + +import android.content.Intent +import android.os.Build +import android.os.Bundle +import android.util.Log +import androidx.appcompat.app.AppCompatActivity +import com.casic.birmm.inspect.utils.Constant +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + companion object { + private const val TAG = "PermissionActivity" + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + if (EasyPermissions.hasPermissions(this, *Constant.USER_PERMISSIONS)) { + startGuideActivity() + } else { + EasyPermissions.requestPermissions( + this, + "需要获取相关权限", + Constant.PERMISSIONS_CODE, + *Constant.USER_PERMISSIONS + ) + } + } else { + startGuideActivity() + } + } + + private fun startGuideActivity() { + startActivity(Intent(this, GuideActivity::class.java)) + finish() + } + + override fun onRequestPermissionsResult( + requestCode: Int, + permissions: Array, + grantResults: IntArray + ) { + super.onRequestPermissionsResult(requestCode, permissions, grantResults) + EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this) + } + + override fun onPermissionsGranted(requestCode: Int, perms: List) { + startGuideActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + Log.e(TAG, "onPermissionsDenied: $perms") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt new file mode 100644 index 0000000..53df6e1 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt @@ -0,0 +1,15 @@ +package com.casic.birmm.inspect.utils + +import android.Manifest + + +object Constant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.ACCESS_LOCATION_EXTRA_COMMANDS, + Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION + ) + + const val PERMISSIONS_CODE = 999 + + const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt new file mode 100644 index 0000000..4c38241 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt @@ -0,0 +1,19 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.view.View +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object OtherUtils { + + //替换Toast + fun showTipsDialog(context: Context, message: String, view: View) { + val tipDialog = QMUITipDialog.Builder(context) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_NOTHING) + .setTipWord(message).create() + tipDialog.show() + view.postDelayed({ + tipDialog.dismiss() + }, 2000) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt b/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt new file mode 100644 index 0000000..04c9f5a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt @@ -0,0 +1,106 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.content.SharedPreferences +import com.casic.birmm.inspect.base.BaseApplication + +object SaveKeyValues { + private var sharedPreferences: SharedPreferences? = null + private var editor: SharedPreferences.Editor? = null + private var fileName: String? = null + + fun initSharedPreferences() { + val packageName = BaseApplication.instance.packageName + //获取到的包名带有“.”方便命名,取最后一个作为sp文件名,例如:com.casic.birmm.inspect + val split = packageName.split(".") + fileName = split[split.size - 1] + } + + /** + * 存储 + */ + fun putValue(key: String?, obj: Any) { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + val editor = sharedPreferences!!.edit() + when (obj) { + is String -> { + editor.putString(key, obj).apply() + } + is Int -> { + editor.putInt(key, obj).apply() + } + is Boolean -> { + editor.putBoolean(key, obj).apply() + } + is Float -> { + editor.putFloat(key, obj).apply() + } + is Long -> { + editor.putLong(key, obj).apply() + } + else -> { + editor.putString(key, obj.toString()).apply() + } + } + } + + /** + * 获取保存的数据 + */ + operator fun getValue(key: String?, defaultObject: Any?): Any? { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + return when (defaultObject) { + is String -> { + sharedPreferences!!.getString(key, defaultObject as String?) + } + is Int -> { + sharedPreferences!!.getInt(key, (defaultObject as Int?)!!) + } + is Boolean -> { + sharedPreferences!!.getBoolean(key, (defaultObject as Boolean?)!!) + } + is Float -> { + sharedPreferences!!.getFloat(key, (defaultObject as Float?)!!) + } + is Long -> { + sharedPreferences!!.getLong(key, (defaultObject as Long?)!!) + } + else -> { + sharedPreferences!!.getString(key, null) + } + } + } + + /** + * 移除某个key值已经对应的值 + */ + fun removeKey(key: String?) { + editor!!.remove(key) + editor!!.commit() + } + + /** + * 清除所有数据 + */ + fun clearAll() { + editor!!.clear() + editor!!.commit() + } + + /** + * 查询某个key是否存在 + */ + fun containsKey(key: String?): Boolean { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + return sharedPreferences!!.contains(key) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt b/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt new file mode 100644 index 0000000..04db86b --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt @@ -0,0 +1,119 @@ +package com.casic.birmm.inspect.widgets + +import android.app.Dialog +import android.content.Context +import android.graphics.Color +import android.graphics.drawable.ColorDrawable +import android.os.Bundle +import android.view.WindowManager +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.utils.OtherUtils +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.dialog_input.* + + +class InputDialog private constructor(builder: Builder) : Dialog(builder.mContext!!) { + + private var ctx: Context? = null + private var title: String? = null + private var value: String? = null + private var positiveBtn: String? = null + private var negativeBtn: String? = null + private var listener: OnDialogButtonClickListener? = null + + init { + this.ctx = builder.mContext + this.title = builder.title + this.value = builder.value + this.positiveBtn = builder.positiveBtn + this.negativeBtn = builder.negativeBtn + this.listener = builder.listener + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + configDialogLayout() + setContentView(R.layout.dialog_input) + setCancelable(false) + setCanceledOnTouchOutside(false) + + dialogTitleView.text = title + value.apply { + dialogInputView.setText(this) + } + + dialogCancelButton.text = negativeBtn + dialogCancelButton.setChangeAlphaWhenPress(true) + dialogCancelButton.setOnClickListener { + this.dismiss() + } + + dialogConfirmButton.text = positiveBtn + dialogConfirmButton.setChangeAlphaWhenPress(true) + dialogConfirmButton.setOnClickListener { + val inputValue = dialogInputView.text.toString().trim() + if (inputValue.isEmpty()) { + OtherUtils.showTipsDialog(ctx!!, "什么都没输入,请重新输入", dialogConfirmButton) + return@setOnClickListener + } + listener?.onButtonClick(inputValue) + this.dismiss() + } + } + + private fun configDialogLayout() { + window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT)) + window?.decorView?.setBackgroundColor(Color.TRANSPARENT) + val params: WindowManager.LayoutParams? = window?.attributes + params?.width = QMUIDisplayHelper.dp2px(ctx, 300) + params?.height = WindowManager.LayoutParams.WRAP_CONTENT + window?.attributes = params + } + + class Builder { + var mContext: Context? = null + var title: String? = null + var value: String? = null + var positiveBtn: String? = null + var negativeBtn: String? = null + var listener: OnDialogButtonClickListener? = null + + fun setContext(context: Context?): Builder { + mContext = context + return this + } + + fun setTitle(title: String?): Builder { + this.title = title + return this + } + + fun setDefaultValue(value: String?): Builder { + this.value = value + return this + } + + fun setPositiveButton(name: String?): Builder { + positiveBtn = name + return this + } + + fun setNegativeButton(name: String?): Builder { + negativeBtn = name + return this + } + + fun setOnDialogClickListener(listener: OnDialogButtonClickListener): Builder { + this.listener = listener + return this + } + + fun build(): InputDialog { + return InputDialog(this) + } + } + + interface OnDialogButtonClickListener { + fun onButtonClick(input: String) + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_dialog_button.xml b/app/src/main/res/drawable/bg_dialog_button.xml new file mode 100644 index 0000000..5f7d57d --- /dev/null +++ b/app/src/main/res/drawable/bg_dialog_button.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_layout_white.xml b/app/src/main/res/drawable/bg_layout_white.xml new file mode 100644 index 0000000..19b473b --- /dev/null +++ b/app/src/main/res/drawable/bg_layout_white.xml @@ -0,0 +1,11 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/guide1.png b/app/src/main/res/drawable/guide1.png new file mode 100644 index 0000000..074c768 --- /dev/null +++ b/app/src/main/res/drawable/guide1.png Binary files differ diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_lock.xml b/app/src/main/res/drawable/ic_lock.xml new file mode 100644 index 0000000..f0a5610 --- /dev/null +++ b/app/src/main/res/drawable/ic_lock.xml @@ -0,0 +1,12 @@ + + + + diff --git a/app/src/main/res/drawable/ic_login_bg.png b/app/src/main/res/drawable/ic_login_bg.png new file mode 100644 index 0000000..64789c3 --- /dev/null +++ b/app/src/main/res/drawable/ic_login_bg.png Binary files differ diff --git a/app/src/main/res/drawable/ic_user.xml b/app/src/main/res/drawable/ic_user.xml new file mode 100644 index 0000000..8c4a29d --- /dev/null +++ b/app/src/main/res/drawable/ic_user.xml @@ -0,0 +1,15 @@ + + + + + diff --git a/app/src/main/res/layout/activity_guide.xml b/app/src/main/res/layout/activity_guide.xml new file mode 100644 index 0000000..e197626 --- /dev/null +++ b/app/src/main/res/layout/activity_guide.xml @@ -0,0 +1,19 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_login.xml b/app/src/main/res/layout/activity_login.xml new file mode 100644 index 0000000..bcae777 --- /dev/null +++ b/app/src/main/res/layout/activity_login.xml @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..def59e4 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,18 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_input.xml b/app/src/main/res/layout/dialog_input.xml new file mode 100644 index 0000000..f5a8bc6 --- /dev/null +++ b/app/src/main/res/layout/dialog_input.xml @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..a571e60 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 0000000..61da551 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..c41dd28 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png new file mode 100644 index 0000000..db5080a --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..6dba46d --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png new file mode 100644 index 0000000..da31a87 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..15ac681 --- /dev/null +++ b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..b216f2d --- /dev/null +++ b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..f25a419 --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..e96783c --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml new file mode 100644 index 0000000..662ee77 --- /dev/null +++ b/app/src/main/res/values/colors.xml @@ -0,0 +1,21 @@ + + + #6200EE + #3700B3 + #03DAC5 + + #FFFFFF + #E5E5E5 + #C0C0C0 + #808080 + #000000 + + #1565E3 + #575757 + + #06134C + #090E47 + #98A0BD + + #54000000 + diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml new file mode 100644 index 0000000..2dddf37 --- /dev/null +++ b/app/src/main/res/values/dimens.xml @@ -0,0 +1,14 @@ + + + 16sp + 18sp + + + 10dp + + + 10dp + + + 1px + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml new file mode 100644 index 0000000..fda9031 --- /dev/null +++ b/app/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + 航小科智巡宝 + diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml new file mode 100644 index 0000000..f16f3a9 --- /dev/null +++ b/app/src/main/res/values/styles.xml @@ -0,0 +1,23 @@ + + + + + + + + + diff --git a/app/src/test/java/com/casic/birmm/inspect/ExampleUnitTest.kt b/app/src/test/java/com/casic/birmm/inspect/ExampleUnitTest.kt new file mode 100644 index 0000000..21e44ca --- /dev/null +++ b/app/src/test/java/com/casic/birmm/inspect/ExampleUnitTest.kt @@ -0,0 +1,17 @@ +package com.casic.birmm.inspect + +import org.junit.Test + +import org.junit.Assert.* + +/** + * Example local unit test, which will execute on the development machine (host). + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +class ExampleUnitTest { + @Test + fun addition_isCorrect() { + assertEquals(4, 2 + 2) + } +} diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..500f939 --- /dev/null +++ b/build.gradle @@ -0,0 +1,31 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. + +buildscript { + ext.kotlin_version = '1.3.61' + repositories { + maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' } + google() + jcenter() + } + dependencies { + classpath 'com.android.tools.build:gradle:3.6.3' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files + } +} + +allprojects { + repositories { + maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' } + //依赖库 + maven { url 'https://jitpack.io' } + google() + jcenter() + } +} + +task clean(type: Delete) { + delete rootProject.buildDir +} diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..23339e0 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,21 @@ +# Project-wide Gradle settings. +# IDE (e.g. Android Studio) users: +# Gradle settings configured through the IDE *will override* +# any settings specified in this file. +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +org.gradle.jvmargs=-Xmx1536m +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. More details, visit +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects +# org.gradle.parallel=true +# AndroidX package structure to make it clearer which packages are bundled with the +# Android operating system, and which are packaged with your app's APK +# https://developer.android.com/topic/libraries/support-library/androidx-rn +android.useAndroidX=true +# Automatically convert third-party libraries to use AndroidX +android.enableJetifier=true +# Kotlin code style for this project: "official" or "obsolete": +kotlin.code.style=official diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..603b140 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..88ea3aa --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,122 @@ + + + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+ + +
+
\ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..5cd135a --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..7bfef59 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..4ca4a9f --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,67 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' + +android { + compileSdkVersion 30 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.birmm.inspect" + minSdkVersion 21 + targetSdkVersion 30 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'androidx.core:core-ktx:1.3.2' + implementation 'androidx.constraintlayout:constraintlayout:2.0.4' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test.ext:junit:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:1.3.0' + //腾讯Android UI框架 + implementation 'com.qmuiteam:qmui:2.0.0-alpha10' + implementation 'com.qmuiteam:arch:0.3.1' + //沉浸式状态栏。基础依赖包,必须要依赖 + implementation 'com.gyf.immersionbar:immersionbar:3.0.0' + //fragment快速实现 + implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + + //MVP网络请求框架retrofit2+rxjava + implementation 'io.reactivex:rxjava:1.3.8' + implementation 'io.reactivex:rxandroid:1.2.1' + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.6.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + implementation 'com.squareup.retrofit2:adapter-rxjava:2.8.1' + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.8.6' + //Toast提示 + implementation 'com.sdsmdg.tastytoast:tastytoast:0.1.1' + //图片选择框架 + implementation 'com.github.LuckSiege.PictureSelector:picture_library:v2.6.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..ea03309 --- /dev/null +++ b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.casic.birmm.inspect + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.casic.birmm.inspect", appContext.packageName) + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..7096527 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt new file mode 100644 index 0000000..aefdbb6 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt @@ -0,0 +1,36 @@ +package com.casic.birmm.inspect.base + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.qmuiteam.qmui.util.QMUIStatusBarHelper + +abstract class BaseActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(initLayoutView()) + QMUIStatusBarHelper.translucent(this) //沉浸式状态栏 + setupTopBarLayout() + initData() + initEvent() + } + + /** + * 初始化xml布局 + */ + abstract fun initLayoutView(): Int + + /** + * 特定页面定制沉浸式状态栏 + */ + protected abstract fun setupTopBarLayout() + + /** + * 初始化默认数据 + */ + abstract fun initData() + + /** + * 初始化业务逻辑 + */ + abstract fun initEvent() +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt new file mode 100644 index 0000000..fc0ca75 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt @@ -0,0 +1,18 @@ +package com.casic.birmm.inspect.base + +import android.app.Application +import com.casic.birmm.inspect.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + companion object { + var instance: BaseApplication by Delegates.notNull() + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt new file mode 100644 index 0000000..ddc160a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt @@ -0,0 +1,56 @@ +package com.casic.birmm.inspect.ui + +import android.annotation.SuppressLint +import android.content.Intent +import android.os.CountDownTimer +import android.view.ViewGroup.MarginLayoutParams +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.activity_guide.* + +@SuppressLint("SetTextI18n") +class GuideActivity : BaseActivity() { + + private lateinit var countDownTimer: CountDownTimer + + override fun initLayoutView(): Int = R.layout.activity_guide + + override fun setupTopBarLayout() { + + } + + override fun initData() { + //根据不同设备状态栏高度设置"跳过"按钮的Margin值 + val statusBarHeight = QMUIDisplayHelper.getStatusBarHeight(this) + val rightMargin = QMUIDisplayHelper.dp2px(this, 10) + if (skipButton.layoutParams is MarginLayoutParams) { + val params = skipButton.layoutParams as MarginLayoutParams + params.setMargins(skipButton.width, statusBarHeight, rightMargin, 0) + skipButton.requestLayout() + } + + countDownTimer = object : CountDownTimer(4000, 1000) { + override fun onFinish() { + startLoginActivity() + } + + override fun onTick(millisUntilFinished: Long) { + skipButton.text = "跳过\u3000${(millisUntilFinished / 1000)}s" + } + } + } + + override fun initEvent() { + countDownTimer.start() + skipButton.setOnClickListener { + countDownTimer.cancel() + startLoginActivity() + } + } + + fun startLoginActivity() { + startActivity(Intent(this, LoginActivity::class.java)) + finish() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt new file mode 100644 index 0000000..6ef4548 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt @@ -0,0 +1,81 @@ +package com.casic.birmm.inspect.ui + +import android.text.Editable +import android.text.TextWatcher +import android.view.KeyEvent +import android.view.inputmethod.EditorInfo +import android.widget.EditText +import android.widget.TextView +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.casic.birmm.inspect.utils.Constant +import com.casic.birmm.inspect.utils.SaveKeyValues +import com.casic.birmm.inspect.widgets.InputDialog +import kotlinx.android.synthetic.main.activity_login.* + + +class LoginActivity : BaseActivity() { + + companion object { + private const val Tag = "LoginActivity" + } + + override fun initLayoutView(): Int = R.layout.activity_login + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + loginButton.setChangeAlphaWhenPress(true) + val editText: EditText? = inputLayout.editText + editText?.addTextChangedListener(object : TextWatcher { + override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) { + + } + + override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) { + + } + + override fun afterTextChanged(s: Editable) { + if (s.toString().trim { it <= ' ' }.length > 12) { + inputLayout.error = "密码长度超出限制" + } else { + inputLayout.error = null + } + } + }) + //点击输入法键盘"完成" + editText?.setOnEditorActionListener { _: TextView?, actionId: Int, _: KeyEvent? -> + if (actionId == EditorInfo.IME_ACTION_DONE) { +// authenticatePresenter.onReadyRetrofitRequest() + return@setOnEditorActionListener true + } + false + } + + //修改服务器配置 + changeServerConfigView.setOnClickListener { + val defaultValue = SaveKeyValues.getValue( + Constant.DEFAULT_SERVER_CONFIG, + "http://139.198.6.177:8093/" + ) as String + InputDialog.Builder().setContext(this) + .setTitle("请输入后台服务器地址") + .setDefaultValue(defaultValue) + .setNegativeButton("取消") + .setPositiveButton("保存") + .setOnDialogClickListener(object : InputDialog.OnDialogButtonClickListener { + override fun onButtonClick(input: String) { + SaveKeyValues.putValue(Constant.DEFAULT_SERVER_CONFIG, input) + } + }) + .build().show() + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt new file mode 100644 index 0000000..0e97af7 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt @@ -0,0 +1,21 @@ +package com.casic.birmm.inspect.ui + +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity + +class MainActivity : BaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt new file mode 100644 index 0000000..21fbba2 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt @@ -0,0 +1,58 @@ +package com.casic.birmm.inspect.ui + +import android.content.Intent +import android.os.Build +import android.os.Bundle +import android.util.Log +import androidx.appcompat.app.AppCompatActivity +import com.casic.birmm.inspect.utils.Constant +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + companion object { + private const val TAG = "PermissionActivity" + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + if (EasyPermissions.hasPermissions(this, *Constant.USER_PERMISSIONS)) { + startGuideActivity() + } else { + EasyPermissions.requestPermissions( + this, + "需要获取相关权限", + Constant.PERMISSIONS_CODE, + *Constant.USER_PERMISSIONS + ) + } + } else { + startGuideActivity() + } + } + + private fun startGuideActivity() { + startActivity(Intent(this, GuideActivity::class.java)) + finish() + } + + override fun onRequestPermissionsResult( + requestCode: Int, + permissions: Array, + grantResults: IntArray + ) { + super.onRequestPermissionsResult(requestCode, permissions, grantResults) + EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this) + } + + override fun onPermissionsGranted(requestCode: Int, perms: List) { + startGuideActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + Log.e(TAG, "onPermissionsDenied: $perms") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt new file mode 100644 index 0000000..53df6e1 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt @@ -0,0 +1,15 @@ +package com.casic.birmm.inspect.utils + +import android.Manifest + + +object Constant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.ACCESS_LOCATION_EXTRA_COMMANDS, + Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION + ) + + const val PERMISSIONS_CODE = 999 + + const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt new file mode 100644 index 0000000..4c38241 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt @@ -0,0 +1,19 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.view.View +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object OtherUtils { + + //替换Toast + fun showTipsDialog(context: Context, message: String, view: View) { + val tipDialog = QMUITipDialog.Builder(context) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_NOTHING) + .setTipWord(message).create() + tipDialog.show() + view.postDelayed({ + tipDialog.dismiss() + }, 2000) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt b/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt new file mode 100644 index 0000000..04c9f5a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt @@ -0,0 +1,106 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.content.SharedPreferences +import com.casic.birmm.inspect.base.BaseApplication + +object SaveKeyValues { + private var sharedPreferences: SharedPreferences? = null + private var editor: SharedPreferences.Editor? = null + private var fileName: String? = null + + fun initSharedPreferences() { + val packageName = BaseApplication.instance.packageName + //获取到的包名带有“.”方便命名,取最后一个作为sp文件名,例如:com.casic.birmm.inspect + val split = packageName.split(".") + fileName = split[split.size - 1] + } + + /** + * 存储 + */ + fun putValue(key: String?, obj: Any) { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + val editor = sharedPreferences!!.edit() + when (obj) { + is String -> { + editor.putString(key, obj).apply() + } + is Int -> { + editor.putInt(key, obj).apply() + } + is Boolean -> { + editor.putBoolean(key, obj).apply() + } + is Float -> { + editor.putFloat(key, obj).apply() + } + is Long -> { + editor.putLong(key, obj).apply() + } + else -> { + editor.putString(key, obj.toString()).apply() + } + } + } + + /** + * 获取保存的数据 + */ + operator fun getValue(key: String?, defaultObject: Any?): Any? { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + return when (defaultObject) { + is String -> { + sharedPreferences!!.getString(key, defaultObject as String?) + } + is Int -> { + sharedPreferences!!.getInt(key, (defaultObject as Int?)!!) + } + is Boolean -> { + sharedPreferences!!.getBoolean(key, (defaultObject as Boolean?)!!) + } + is Float -> { + sharedPreferences!!.getFloat(key, (defaultObject as Float?)!!) + } + is Long -> { + sharedPreferences!!.getLong(key, (defaultObject as Long?)!!) + } + else -> { + sharedPreferences!!.getString(key, null) + } + } + } + + /** + * 移除某个key值已经对应的值 + */ + fun removeKey(key: String?) { + editor!!.remove(key) + editor!!.commit() + } + + /** + * 清除所有数据 + */ + fun clearAll() { + editor!!.clear() + editor!!.commit() + } + + /** + * 查询某个key是否存在 + */ + fun containsKey(key: String?): Boolean { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + return sharedPreferences!!.contains(key) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt b/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt new file mode 100644 index 0000000..04db86b --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt @@ -0,0 +1,119 @@ +package com.casic.birmm.inspect.widgets + +import android.app.Dialog +import android.content.Context +import android.graphics.Color +import android.graphics.drawable.ColorDrawable +import android.os.Bundle +import android.view.WindowManager +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.utils.OtherUtils +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.dialog_input.* + + +class InputDialog private constructor(builder: Builder) : Dialog(builder.mContext!!) { + + private var ctx: Context? = null + private var title: String? = null + private var value: String? = null + private var positiveBtn: String? = null + private var negativeBtn: String? = null + private var listener: OnDialogButtonClickListener? = null + + init { + this.ctx = builder.mContext + this.title = builder.title + this.value = builder.value + this.positiveBtn = builder.positiveBtn + this.negativeBtn = builder.negativeBtn + this.listener = builder.listener + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + configDialogLayout() + setContentView(R.layout.dialog_input) + setCancelable(false) + setCanceledOnTouchOutside(false) + + dialogTitleView.text = title + value.apply { + dialogInputView.setText(this) + } + + dialogCancelButton.text = negativeBtn + dialogCancelButton.setChangeAlphaWhenPress(true) + dialogCancelButton.setOnClickListener { + this.dismiss() + } + + dialogConfirmButton.text = positiveBtn + dialogConfirmButton.setChangeAlphaWhenPress(true) + dialogConfirmButton.setOnClickListener { + val inputValue = dialogInputView.text.toString().trim() + if (inputValue.isEmpty()) { + OtherUtils.showTipsDialog(ctx!!, "什么都没输入,请重新输入", dialogConfirmButton) + return@setOnClickListener + } + listener?.onButtonClick(inputValue) + this.dismiss() + } + } + + private fun configDialogLayout() { + window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT)) + window?.decorView?.setBackgroundColor(Color.TRANSPARENT) + val params: WindowManager.LayoutParams? = window?.attributes + params?.width = QMUIDisplayHelper.dp2px(ctx, 300) + params?.height = WindowManager.LayoutParams.WRAP_CONTENT + window?.attributes = params + } + + class Builder { + var mContext: Context? = null + var title: String? = null + var value: String? = null + var positiveBtn: String? = null + var negativeBtn: String? = null + var listener: OnDialogButtonClickListener? = null + + fun setContext(context: Context?): Builder { + mContext = context + return this + } + + fun setTitle(title: String?): Builder { + this.title = title + return this + } + + fun setDefaultValue(value: String?): Builder { + this.value = value + return this + } + + fun setPositiveButton(name: String?): Builder { + positiveBtn = name + return this + } + + fun setNegativeButton(name: String?): Builder { + negativeBtn = name + return this + } + + fun setOnDialogClickListener(listener: OnDialogButtonClickListener): Builder { + this.listener = listener + return this + } + + fun build(): InputDialog { + return InputDialog(this) + } + } + + interface OnDialogButtonClickListener { + fun onButtonClick(input: String) + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_dialog_button.xml b/app/src/main/res/drawable/bg_dialog_button.xml new file mode 100644 index 0000000..5f7d57d --- /dev/null +++ b/app/src/main/res/drawable/bg_dialog_button.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_layout_white.xml b/app/src/main/res/drawable/bg_layout_white.xml new file mode 100644 index 0000000..19b473b --- /dev/null +++ b/app/src/main/res/drawable/bg_layout_white.xml @@ -0,0 +1,11 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/guide1.png b/app/src/main/res/drawable/guide1.png new file mode 100644 index 0000000..074c768 --- /dev/null +++ b/app/src/main/res/drawable/guide1.png Binary files differ diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_lock.xml b/app/src/main/res/drawable/ic_lock.xml new file mode 100644 index 0000000..f0a5610 --- /dev/null +++ b/app/src/main/res/drawable/ic_lock.xml @@ -0,0 +1,12 @@ + + + + diff --git a/app/src/main/res/drawable/ic_login_bg.png b/app/src/main/res/drawable/ic_login_bg.png new file mode 100644 index 0000000..64789c3 --- /dev/null +++ b/app/src/main/res/drawable/ic_login_bg.png Binary files differ diff --git a/app/src/main/res/drawable/ic_user.xml b/app/src/main/res/drawable/ic_user.xml new file mode 100644 index 0000000..8c4a29d --- /dev/null +++ b/app/src/main/res/drawable/ic_user.xml @@ -0,0 +1,15 @@ + + + + + diff --git a/app/src/main/res/layout/activity_guide.xml b/app/src/main/res/layout/activity_guide.xml new file mode 100644 index 0000000..e197626 --- /dev/null +++ b/app/src/main/res/layout/activity_guide.xml @@ -0,0 +1,19 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_login.xml b/app/src/main/res/layout/activity_login.xml new file mode 100644 index 0000000..bcae777 --- /dev/null +++ b/app/src/main/res/layout/activity_login.xml @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..def59e4 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,18 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_input.xml b/app/src/main/res/layout/dialog_input.xml new file mode 100644 index 0000000..f5a8bc6 --- /dev/null +++ b/app/src/main/res/layout/dialog_input.xml @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..a571e60 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 0000000..61da551 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..c41dd28 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png new file mode 100644 index 0000000..db5080a --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..6dba46d --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png new file mode 100644 index 0000000..da31a87 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..15ac681 --- /dev/null +++ b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..b216f2d --- /dev/null +++ b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..f25a419 --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..e96783c --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml new file mode 100644 index 0000000..662ee77 --- /dev/null +++ b/app/src/main/res/values/colors.xml @@ -0,0 +1,21 @@ + + + #6200EE + #3700B3 + #03DAC5 + + #FFFFFF + #E5E5E5 + #C0C0C0 + #808080 + #000000 + + #1565E3 + #575757 + + #06134C + #090E47 + #98A0BD + + #54000000 + diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml new file mode 100644 index 0000000..2dddf37 --- /dev/null +++ b/app/src/main/res/values/dimens.xml @@ -0,0 +1,14 @@ + + + 16sp + 18sp + + + 10dp + + + 10dp + + + 1px + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml new file mode 100644 index 0000000..fda9031 --- /dev/null +++ b/app/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + 航小科智巡宝 + diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml new file mode 100644 index 0000000..f16f3a9 --- /dev/null +++ b/app/src/main/res/values/styles.xml @@ -0,0 +1,23 @@ + + + + + + + + + diff --git a/app/src/test/java/com/casic/birmm/inspect/ExampleUnitTest.kt b/app/src/test/java/com/casic/birmm/inspect/ExampleUnitTest.kt new file mode 100644 index 0000000..21e44ca --- /dev/null +++ b/app/src/test/java/com/casic/birmm/inspect/ExampleUnitTest.kt @@ -0,0 +1,17 @@ +package com.casic.birmm.inspect + +import org.junit.Test + +import org.junit.Assert.* + +/** + * Example local unit test, which will execute on the development machine (host). + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +class ExampleUnitTest { + @Test + fun addition_isCorrect() { + assertEquals(4, 2 + 2) + } +} diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..500f939 --- /dev/null +++ b/build.gradle @@ -0,0 +1,31 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. + +buildscript { + ext.kotlin_version = '1.3.61' + repositories { + maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' } + google() + jcenter() + } + dependencies { + classpath 'com.android.tools.build:gradle:3.6.3' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files + } +} + +allprojects { + repositories { + maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' } + //依赖库 + maven { url 'https://jitpack.io' } + google() + jcenter() + } +} + +task clean(type: Delete) { + delete rootProject.buildDir +} diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..23339e0 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,21 @@ +# Project-wide Gradle settings. +# IDE (e.g. Android Studio) users: +# Gradle settings configured through the IDE *will override* +# any settings specified in this file. +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +org.gradle.jvmargs=-Xmx1536m +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. More details, visit +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects +# org.gradle.parallel=true +# AndroidX package structure to make it clearer which packages are bundled with the +# Android operating system, and which are packaged with your app's APK +# https://developer.android.com/topic/libraries/support-library/androidx-rn +android.useAndroidX=true +# Automatically convert third-party libraries to use AndroidX +android.enableJetifier=true +# Kotlin code style for this project: "official" or "obsolete": +kotlin.code.style=official diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..f6b961f --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.jar Binary files differ diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..603b140 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..88ea3aa --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,122 @@ + + + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+ + +
+
\ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..5cd135a --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..7bfef59 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..4ca4a9f --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,67 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' + +android { + compileSdkVersion 30 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.birmm.inspect" + minSdkVersion 21 + targetSdkVersion 30 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'androidx.core:core-ktx:1.3.2' + implementation 'androidx.constraintlayout:constraintlayout:2.0.4' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test.ext:junit:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:1.3.0' + //腾讯Android UI框架 + implementation 'com.qmuiteam:qmui:2.0.0-alpha10' + implementation 'com.qmuiteam:arch:0.3.1' + //沉浸式状态栏。基础依赖包,必须要依赖 + implementation 'com.gyf.immersionbar:immersionbar:3.0.0' + //fragment快速实现 + implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + + //MVP网络请求框架retrofit2+rxjava + implementation 'io.reactivex:rxjava:1.3.8' + implementation 'io.reactivex:rxandroid:1.2.1' + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.6.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + implementation 'com.squareup.retrofit2:adapter-rxjava:2.8.1' + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.8.6' + //Toast提示 + implementation 'com.sdsmdg.tastytoast:tastytoast:0.1.1' + //图片选择框架 + implementation 'com.github.LuckSiege.PictureSelector:picture_library:v2.6.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..ea03309 --- /dev/null +++ b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.casic.birmm.inspect + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.casic.birmm.inspect", appContext.packageName) + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..7096527 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt new file mode 100644 index 0000000..aefdbb6 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt @@ -0,0 +1,36 @@ +package com.casic.birmm.inspect.base + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.qmuiteam.qmui.util.QMUIStatusBarHelper + +abstract class BaseActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(initLayoutView()) + QMUIStatusBarHelper.translucent(this) //沉浸式状态栏 + setupTopBarLayout() + initData() + initEvent() + } + + /** + * 初始化xml布局 + */ + abstract fun initLayoutView(): Int + + /** + * 特定页面定制沉浸式状态栏 + */ + protected abstract fun setupTopBarLayout() + + /** + * 初始化默认数据 + */ + abstract fun initData() + + /** + * 初始化业务逻辑 + */ + abstract fun initEvent() +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt new file mode 100644 index 0000000..fc0ca75 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt @@ -0,0 +1,18 @@ +package com.casic.birmm.inspect.base + +import android.app.Application +import com.casic.birmm.inspect.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + companion object { + var instance: BaseApplication by Delegates.notNull() + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt new file mode 100644 index 0000000..ddc160a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt @@ -0,0 +1,56 @@ +package com.casic.birmm.inspect.ui + +import android.annotation.SuppressLint +import android.content.Intent +import android.os.CountDownTimer +import android.view.ViewGroup.MarginLayoutParams +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.activity_guide.* + +@SuppressLint("SetTextI18n") +class GuideActivity : BaseActivity() { + + private lateinit var countDownTimer: CountDownTimer + + override fun initLayoutView(): Int = R.layout.activity_guide + + override fun setupTopBarLayout() { + + } + + override fun initData() { + //根据不同设备状态栏高度设置"跳过"按钮的Margin值 + val statusBarHeight = QMUIDisplayHelper.getStatusBarHeight(this) + val rightMargin = QMUIDisplayHelper.dp2px(this, 10) + if (skipButton.layoutParams is MarginLayoutParams) { + val params = skipButton.layoutParams as MarginLayoutParams + params.setMargins(skipButton.width, statusBarHeight, rightMargin, 0) + skipButton.requestLayout() + } + + countDownTimer = object : CountDownTimer(4000, 1000) { + override fun onFinish() { + startLoginActivity() + } + + override fun onTick(millisUntilFinished: Long) { + skipButton.text = "跳过\u3000${(millisUntilFinished / 1000)}s" + } + } + } + + override fun initEvent() { + countDownTimer.start() + skipButton.setOnClickListener { + countDownTimer.cancel() + startLoginActivity() + } + } + + fun startLoginActivity() { + startActivity(Intent(this, LoginActivity::class.java)) + finish() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt new file mode 100644 index 0000000..6ef4548 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt @@ -0,0 +1,81 @@ +package com.casic.birmm.inspect.ui + +import android.text.Editable +import android.text.TextWatcher +import android.view.KeyEvent +import android.view.inputmethod.EditorInfo +import android.widget.EditText +import android.widget.TextView +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.casic.birmm.inspect.utils.Constant +import com.casic.birmm.inspect.utils.SaveKeyValues +import com.casic.birmm.inspect.widgets.InputDialog +import kotlinx.android.synthetic.main.activity_login.* + + +class LoginActivity : BaseActivity() { + + companion object { + private const val Tag = "LoginActivity" + } + + override fun initLayoutView(): Int = R.layout.activity_login + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + loginButton.setChangeAlphaWhenPress(true) + val editText: EditText? = inputLayout.editText + editText?.addTextChangedListener(object : TextWatcher { + override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) { + + } + + override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) { + + } + + override fun afterTextChanged(s: Editable) { + if (s.toString().trim { it <= ' ' }.length > 12) { + inputLayout.error = "密码长度超出限制" + } else { + inputLayout.error = null + } + } + }) + //点击输入法键盘"完成" + editText?.setOnEditorActionListener { _: TextView?, actionId: Int, _: KeyEvent? -> + if (actionId == EditorInfo.IME_ACTION_DONE) { +// authenticatePresenter.onReadyRetrofitRequest() + return@setOnEditorActionListener true + } + false + } + + //修改服务器配置 + changeServerConfigView.setOnClickListener { + val defaultValue = SaveKeyValues.getValue( + Constant.DEFAULT_SERVER_CONFIG, + "http://139.198.6.177:8093/" + ) as String + InputDialog.Builder().setContext(this) + .setTitle("请输入后台服务器地址") + .setDefaultValue(defaultValue) + .setNegativeButton("取消") + .setPositiveButton("保存") + .setOnDialogClickListener(object : InputDialog.OnDialogButtonClickListener { + override fun onButtonClick(input: String) { + SaveKeyValues.putValue(Constant.DEFAULT_SERVER_CONFIG, input) + } + }) + .build().show() + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt new file mode 100644 index 0000000..0e97af7 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt @@ -0,0 +1,21 @@ +package com.casic.birmm.inspect.ui + +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity + +class MainActivity : BaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt new file mode 100644 index 0000000..21fbba2 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt @@ -0,0 +1,58 @@ +package com.casic.birmm.inspect.ui + +import android.content.Intent +import android.os.Build +import android.os.Bundle +import android.util.Log +import androidx.appcompat.app.AppCompatActivity +import com.casic.birmm.inspect.utils.Constant +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + companion object { + private const val TAG = "PermissionActivity" + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + if (EasyPermissions.hasPermissions(this, *Constant.USER_PERMISSIONS)) { + startGuideActivity() + } else { + EasyPermissions.requestPermissions( + this, + "需要获取相关权限", + Constant.PERMISSIONS_CODE, + *Constant.USER_PERMISSIONS + ) + } + } else { + startGuideActivity() + } + } + + private fun startGuideActivity() { + startActivity(Intent(this, GuideActivity::class.java)) + finish() + } + + override fun onRequestPermissionsResult( + requestCode: Int, + permissions: Array, + grantResults: IntArray + ) { + super.onRequestPermissionsResult(requestCode, permissions, grantResults) + EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this) + } + + override fun onPermissionsGranted(requestCode: Int, perms: List) { + startGuideActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + Log.e(TAG, "onPermissionsDenied: $perms") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt new file mode 100644 index 0000000..53df6e1 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt @@ -0,0 +1,15 @@ +package com.casic.birmm.inspect.utils + +import android.Manifest + + +object Constant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.ACCESS_LOCATION_EXTRA_COMMANDS, + Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION + ) + + const val PERMISSIONS_CODE = 999 + + const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt new file mode 100644 index 0000000..4c38241 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt @@ -0,0 +1,19 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.view.View +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object OtherUtils { + + //替换Toast + fun showTipsDialog(context: Context, message: String, view: View) { + val tipDialog = QMUITipDialog.Builder(context) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_NOTHING) + .setTipWord(message).create() + tipDialog.show() + view.postDelayed({ + tipDialog.dismiss() + }, 2000) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt b/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt new file mode 100644 index 0000000..04c9f5a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt @@ -0,0 +1,106 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.content.SharedPreferences +import com.casic.birmm.inspect.base.BaseApplication + +object SaveKeyValues { + private var sharedPreferences: SharedPreferences? = null + private var editor: SharedPreferences.Editor? = null + private var fileName: String? = null + + fun initSharedPreferences() { + val packageName = BaseApplication.instance.packageName + //获取到的包名带有“.”方便命名,取最后一个作为sp文件名,例如:com.casic.birmm.inspect + val split = packageName.split(".") + fileName = split[split.size - 1] + } + + /** + * 存储 + */ + fun putValue(key: String?, obj: Any) { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + val editor = sharedPreferences!!.edit() + when (obj) { + is String -> { + editor.putString(key, obj).apply() + } + is Int -> { + editor.putInt(key, obj).apply() + } + is Boolean -> { + editor.putBoolean(key, obj).apply() + } + is Float -> { + editor.putFloat(key, obj).apply() + } + is Long -> { + editor.putLong(key, obj).apply() + } + else -> { + editor.putString(key, obj.toString()).apply() + } + } + } + + /** + * 获取保存的数据 + */ + operator fun getValue(key: String?, defaultObject: Any?): Any? { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + return when (defaultObject) { + is String -> { + sharedPreferences!!.getString(key, defaultObject as String?) + } + is Int -> { + sharedPreferences!!.getInt(key, (defaultObject as Int?)!!) + } + is Boolean -> { + sharedPreferences!!.getBoolean(key, (defaultObject as Boolean?)!!) + } + is Float -> { + sharedPreferences!!.getFloat(key, (defaultObject as Float?)!!) + } + is Long -> { + sharedPreferences!!.getLong(key, (defaultObject as Long?)!!) + } + else -> { + sharedPreferences!!.getString(key, null) + } + } + } + + /** + * 移除某个key值已经对应的值 + */ + fun removeKey(key: String?) { + editor!!.remove(key) + editor!!.commit() + } + + /** + * 清除所有数据 + */ + fun clearAll() { + editor!!.clear() + editor!!.commit() + } + + /** + * 查询某个key是否存在 + */ + fun containsKey(key: String?): Boolean { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + return sharedPreferences!!.contains(key) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt b/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt new file mode 100644 index 0000000..04db86b --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt @@ -0,0 +1,119 @@ +package com.casic.birmm.inspect.widgets + +import android.app.Dialog +import android.content.Context +import android.graphics.Color +import android.graphics.drawable.ColorDrawable +import android.os.Bundle +import android.view.WindowManager +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.utils.OtherUtils +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.dialog_input.* + + +class InputDialog private constructor(builder: Builder) : Dialog(builder.mContext!!) { + + private var ctx: Context? = null + private var title: String? = null + private var value: String? = null + private var positiveBtn: String? = null + private var negativeBtn: String? = null + private var listener: OnDialogButtonClickListener? = null + + init { + this.ctx = builder.mContext + this.title = builder.title + this.value = builder.value + this.positiveBtn = builder.positiveBtn + this.negativeBtn = builder.negativeBtn + this.listener = builder.listener + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + configDialogLayout() + setContentView(R.layout.dialog_input) + setCancelable(false) + setCanceledOnTouchOutside(false) + + dialogTitleView.text = title + value.apply { + dialogInputView.setText(this) + } + + dialogCancelButton.text = negativeBtn + dialogCancelButton.setChangeAlphaWhenPress(true) + dialogCancelButton.setOnClickListener { + this.dismiss() + } + + dialogConfirmButton.text = positiveBtn + dialogConfirmButton.setChangeAlphaWhenPress(true) + dialogConfirmButton.setOnClickListener { + val inputValue = dialogInputView.text.toString().trim() + if (inputValue.isEmpty()) { + OtherUtils.showTipsDialog(ctx!!, "什么都没输入,请重新输入", dialogConfirmButton) + return@setOnClickListener + } + listener?.onButtonClick(inputValue) + this.dismiss() + } + } + + private fun configDialogLayout() { + window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT)) + window?.decorView?.setBackgroundColor(Color.TRANSPARENT) + val params: WindowManager.LayoutParams? = window?.attributes + params?.width = QMUIDisplayHelper.dp2px(ctx, 300) + params?.height = WindowManager.LayoutParams.WRAP_CONTENT + window?.attributes = params + } + + class Builder { + var mContext: Context? = null + var title: String? = null + var value: String? = null + var positiveBtn: String? = null + var negativeBtn: String? = null + var listener: OnDialogButtonClickListener? = null + + fun setContext(context: Context?): Builder { + mContext = context + return this + } + + fun setTitle(title: String?): Builder { + this.title = title + return this + } + + fun setDefaultValue(value: String?): Builder { + this.value = value + return this + } + + fun setPositiveButton(name: String?): Builder { + positiveBtn = name + return this + } + + fun setNegativeButton(name: String?): Builder { + negativeBtn = name + return this + } + + fun setOnDialogClickListener(listener: OnDialogButtonClickListener): Builder { + this.listener = listener + return this + } + + fun build(): InputDialog { + return InputDialog(this) + } + } + + interface OnDialogButtonClickListener { + fun onButtonClick(input: String) + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_dialog_button.xml b/app/src/main/res/drawable/bg_dialog_button.xml new file mode 100644 index 0000000..5f7d57d --- /dev/null +++ b/app/src/main/res/drawable/bg_dialog_button.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_layout_white.xml b/app/src/main/res/drawable/bg_layout_white.xml new file mode 100644 index 0000000..19b473b --- /dev/null +++ b/app/src/main/res/drawable/bg_layout_white.xml @@ -0,0 +1,11 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/guide1.png b/app/src/main/res/drawable/guide1.png new file mode 100644 index 0000000..074c768 --- /dev/null +++ b/app/src/main/res/drawable/guide1.png Binary files differ diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_lock.xml b/app/src/main/res/drawable/ic_lock.xml new file mode 100644 index 0000000..f0a5610 --- /dev/null +++ b/app/src/main/res/drawable/ic_lock.xml @@ -0,0 +1,12 @@ + + + + diff --git a/app/src/main/res/drawable/ic_login_bg.png b/app/src/main/res/drawable/ic_login_bg.png new file mode 100644 index 0000000..64789c3 --- /dev/null +++ b/app/src/main/res/drawable/ic_login_bg.png Binary files differ diff --git a/app/src/main/res/drawable/ic_user.xml b/app/src/main/res/drawable/ic_user.xml new file mode 100644 index 0000000..8c4a29d --- /dev/null +++ b/app/src/main/res/drawable/ic_user.xml @@ -0,0 +1,15 @@ + + + + + diff --git a/app/src/main/res/layout/activity_guide.xml b/app/src/main/res/layout/activity_guide.xml new file mode 100644 index 0000000..e197626 --- /dev/null +++ b/app/src/main/res/layout/activity_guide.xml @@ -0,0 +1,19 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_login.xml b/app/src/main/res/layout/activity_login.xml new file mode 100644 index 0000000..bcae777 --- /dev/null +++ b/app/src/main/res/layout/activity_login.xml @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..def59e4 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,18 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_input.xml b/app/src/main/res/layout/dialog_input.xml new file mode 100644 index 0000000..f5a8bc6 --- /dev/null +++ b/app/src/main/res/layout/dialog_input.xml @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..a571e60 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 0000000..61da551 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..c41dd28 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png new file mode 100644 index 0000000..db5080a --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..6dba46d --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png new file mode 100644 index 0000000..da31a87 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..15ac681 --- /dev/null +++ b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..b216f2d --- /dev/null +++ b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..f25a419 --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..e96783c --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml new file mode 100644 index 0000000..662ee77 --- /dev/null +++ b/app/src/main/res/values/colors.xml @@ -0,0 +1,21 @@ + + + #6200EE + #3700B3 + #03DAC5 + + #FFFFFF + #E5E5E5 + #C0C0C0 + #808080 + #000000 + + #1565E3 + #575757 + + #06134C + #090E47 + #98A0BD + + #54000000 + diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml new file mode 100644 index 0000000..2dddf37 --- /dev/null +++ b/app/src/main/res/values/dimens.xml @@ -0,0 +1,14 @@ + + + 16sp + 18sp + + + 10dp + + + 10dp + + + 1px + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml new file mode 100644 index 0000000..fda9031 --- /dev/null +++ b/app/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + 航小科智巡宝 + diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml new file mode 100644 index 0000000..f16f3a9 --- /dev/null +++ b/app/src/main/res/values/styles.xml @@ -0,0 +1,23 @@ + + + + + + + + + diff --git a/app/src/test/java/com/casic/birmm/inspect/ExampleUnitTest.kt b/app/src/test/java/com/casic/birmm/inspect/ExampleUnitTest.kt new file mode 100644 index 0000000..21e44ca --- /dev/null +++ b/app/src/test/java/com/casic/birmm/inspect/ExampleUnitTest.kt @@ -0,0 +1,17 @@ +package com.casic.birmm.inspect + +import org.junit.Test + +import org.junit.Assert.* + +/** + * Example local unit test, which will execute on the development machine (host). + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +class ExampleUnitTest { + @Test + fun addition_isCorrect() { + assertEquals(4, 2 + 2) + } +} diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..500f939 --- /dev/null +++ b/build.gradle @@ -0,0 +1,31 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. + +buildscript { + ext.kotlin_version = '1.3.61' + repositories { + maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' } + google() + jcenter() + } + dependencies { + classpath 'com.android.tools.build:gradle:3.6.3' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files + } +} + +allprojects { + repositories { + maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' } + //依赖库 + maven { url 'https://jitpack.io' } + google() + jcenter() + } +} + +task clean(type: Delete) { + delete rootProject.buildDir +} diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..23339e0 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,21 @@ +# Project-wide Gradle settings. +# IDE (e.g. Android Studio) users: +# Gradle settings configured through the IDE *will override* +# any settings specified in this file. +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +org.gradle.jvmargs=-Xmx1536m +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. More details, visit +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects +# org.gradle.parallel=true +# AndroidX package structure to make it clearer which packages are bundled with the +# Android operating system, and which are packaged with your app's APK +# https://developer.android.com/topic/libraries/support-library/androidx-rn +android.useAndroidX=true +# Automatically convert third-party libraries to use AndroidX +android.enableJetifier=true +# Kotlin code style for this project: "official" or "obsolete": +kotlin.code.style=official diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..f6b961f --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.jar Binary files differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..0c4d16d --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Tue Jul 06 17:41:55 CST 2021 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..603b140 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..88ea3aa --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,122 @@ + + + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+ + +
+
\ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..5cd135a --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..7bfef59 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..4ca4a9f --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,67 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' + +android { + compileSdkVersion 30 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.birmm.inspect" + minSdkVersion 21 + targetSdkVersion 30 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'androidx.core:core-ktx:1.3.2' + implementation 'androidx.constraintlayout:constraintlayout:2.0.4' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test.ext:junit:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:1.3.0' + //腾讯Android UI框架 + implementation 'com.qmuiteam:qmui:2.0.0-alpha10' + implementation 'com.qmuiteam:arch:0.3.1' + //沉浸式状态栏。基础依赖包,必须要依赖 + implementation 'com.gyf.immersionbar:immersionbar:3.0.0' + //fragment快速实现 + implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + + //MVP网络请求框架retrofit2+rxjava + implementation 'io.reactivex:rxjava:1.3.8' + implementation 'io.reactivex:rxandroid:1.2.1' + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.6.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + implementation 'com.squareup.retrofit2:adapter-rxjava:2.8.1' + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.8.6' + //Toast提示 + implementation 'com.sdsmdg.tastytoast:tastytoast:0.1.1' + //图片选择框架 + implementation 'com.github.LuckSiege.PictureSelector:picture_library:v2.6.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..ea03309 --- /dev/null +++ b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.casic.birmm.inspect + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.casic.birmm.inspect", appContext.packageName) + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..7096527 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt new file mode 100644 index 0000000..aefdbb6 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt @@ -0,0 +1,36 @@ +package com.casic.birmm.inspect.base + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.qmuiteam.qmui.util.QMUIStatusBarHelper + +abstract class BaseActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(initLayoutView()) + QMUIStatusBarHelper.translucent(this) //沉浸式状态栏 + setupTopBarLayout() + initData() + initEvent() + } + + /** + * 初始化xml布局 + */ + abstract fun initLayoutView(): Int + + /** + * 特定页面定制沉浸式状态栏 + */ + protected abstract fun setupTopBarLayout() + + /** + * 初始化默认数据 + */ + abstract fun initData() + + /** + * 初始化业务逻辑 + */ + abstract fun initEvent() +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt new file mode 100644 index 0000000..fc0ca75 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt @@ -0,0 +1,18 @@ +package com.casic.birmm.inspect.base + +import android.app.Application +import com.casic.birmm.inspect.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + companion object { + var instance: BaseApplication by Delegates.notNull() + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt new file mode 100644 index 0000000..ddc160a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt @@ -0,0 +1,56 @@ +package com.casic.birmm.inspect.ui + +import android.annotation.SuppressLint +import android.content.Intent +import android.os.CountDownTimer +import android.view.ViewGroup.MarginLayoutParams +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.activity_guide.* + +@SuppressLint("SetTextI18n") +class GuideActivity : BaseActivity() { + + private lateinit var countDownTimer: CountDownTimer + + override fun initLayoutView(): Int = R.layout.activity_guide + + override fun setupTopBarLayout() { + + } + + override fun initData() { + //根据不同设备状态栏高度设置"跳过"按钮的Margin值 + val statusBarHeight = QMUIDisplayHelper.getStatusBarHeight(this) + val rightMargin = QMUIDisplayHelper.dp2px(this, 10) + if (skipButton.layoutParams is MarginLayoutParams) { + val params = skipButton.layoutParams as MarginLayoutParams + params.setMargins(skipButton.width, statusBarHeight, rightMargin, 0) + skipButton.requestLayout() + } + + countDownTimer = object : CountDownTimer(4000, 1000) { + override fun onFinish() { + startLoginActivity() + } + + override fun onTick(millisUntilFinished: Long) { + skipButton.text = "跳过\u3000${(millisUntilFinished / 1000)}s" + } + } + } + + override fun initEvent() { + countDownTimer.start() + skipButton.setOnClickListener { + countDownTimer.cancel() + startLoginActivity() + } + } + + fun startLoginActivity() { + startActivity(Intent(this, LoginActivity::class.java)) + finish() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt new file mode 100644 index 0000000..6ef4548 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt @@ -0,0 +1,81 @@ +package com.casic.birmm.inspect.ui + +import android.text.Editable +import android.text.TextWatcher +import android.view.KeyEvent +import android.view.inputmethod.EditorInfo +import android.widget.EditText +import android.widget.TextView +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.casic.birmm.inspect.utils.Constant +import com.casic.birmm.inspect.utils.SaveKeyValues +import com.casic.birmm.inspect.widgets.InputDialog +import kotlinx.android.synthetic.main.activity_login.* + + +class LoginActivity : BaseActivity() { + + companion object { + private const val Tag = "LoginActivity" + } + + override fun initLayoutView(): Int = R.layout.activity_login + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + loginButton.setChangeAlphaWhenPress(true) + val editText: EditText? = inputLayout.editText + editText?.addTextChangedListener(object : TextWatcher { + override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) { + + } + + override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) { + + } + + override fun afterTextChanged(s: Editable) { + if (s.toString().trim { it <= ' ' }.length > 12) { + inputLayout.error = "密码长度超出限制" + } else { + inputLayout.error = null + } + } + }) + //点击输入法键盘"完成" + editText?.setOnEditorActionListener { _: TextView?, actionId: Int, _: KeyEvent? -> + if (actionId == EditorInfo.IME_ACTION_DONE) { +// authenticatePresenter.onReadyRetrofitRequest() + return@setOnEditorActionListener true + } + false + } + + //修改服务器配置 + changeServerConfigView.setOnClickListener { + val defaultValue = SaveKeyValues.getValue( + Constant.DEFAULT_SERVER_CONFIG, + "http://139.198.6.177:8093/" + ) as String + InputDialog.Builder().setContext(this) + .setTitle("请输入后台服务器地址") + .setDefaultValue(defaultValue) + .setNegativeButton("取消") + .setPositiveButton("保存") + .setOnDialogClickListener(object : InputDialog.OnDialogButtonClickListener { + override fun onButtonClick(input: String) { + SaveKeyValues.putValue(Constant.DEFAULT_SERVER_CONFIG, input) + } + }) + .build().show() + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt new file mode 100644 index 0000000..0e97af7 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt @@ -0,0 +1,21 @@ +package com.casic.birmm.inspect.ui + +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity + +class MainActivity : BaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt new file mode 100644 index 0000000..21fbba2 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt @@ -0,0 +1,58 @@ +package com.casic.birmm.inspect.ui + +import android.content.Intent +import android.os.Build +import android.os.Bundle +import android.util.Log +import androidx.appcompat.app.AppCompatActivity +import com.casic.birmm.inspect.utils.Constant +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + companion object { + private const val TAG = "PermissionActivity" + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + if (EasyPermissions.hasPermissions(this, *Constant.USER_PERMISSIONS)) { + startGuideActivity() + } else { + EasyPermissions.requestPermissions( + this, + "需要获取相关权限", + Constant.PERMISSIONS_CODE, + *Constant.USER_PERMISSIONS + ) + } + } else { + startGuideActivity() + } + } + + private fun startGuideActivity() { + startActivity(Intent(this, GuideActivity::class.java)) + finish() + } + + override fun onRequestPermissionsResult( + requestCode: Int, + permissions: Array, + grantResults: IntArray + ) { + super.onRequestPermissionsResult(requestCode, permissions, grantResults) + EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this) + } + + override fun onPermissionsGranted(requestCode: Int, perms: List) { + startGuideActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + Log.e(TAG, "onPermissionsDenied: $perms") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt new file mode 100644 index 0000000..53df6e1 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt @@ -0,0 +1,15 @@ +package com.casic.birmm.inspect.utils + +import android.Manifest + + +object Constant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.ACCESS_LOCATION_EXTRA_COMMANDS, + Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION + ) + + const val PERMISSIONS_CODE = 999 + + const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt new file mode 100644 index 0000000..4c38241 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt @@ -0,0 +1,19 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.view.View +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object OtherUtils { + + //替换Toast + fun showTipsDialog(context: Context, message: String, view: View) { + val tipDialog = QMUITipDialog.Builder(context) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_NOTHING) + .setTipWord(message).create() + tipDialog.show() + view.postDelayed({ + tipDialog.dismiss() + }, 2000) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt b/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt new file mode 100644 index 0000000..04c9f5a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt @@ -0,0 +1,106 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.content.SharedPreferences +import com.casic.birmm.inspect.base.BaseApplication + +object SaveKeyValues { + private var sharedPreferences: SharedPreferences? = null + private var editor: SharedPreferences.Editor? = null + private var fileName: String? = null + + fun initSharedPreferences() { + val packageName = BaseApplication.instance.packageName + //获取到的包名带有“.”方便命名,取最后一个作为sp文件名,例如:com.casic.birmm.inspect + val split = packageName.split(".") + fileName = split[split.size - 1] + } + + /** + * 存储 + */ + fun putValue(key: String?, obj: Any) { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + val editor = sharedPreferences!!.edit() + when (obj) { + is String -> { + editor.putString(key, obj).apply() + } + is Int -> { + editor.putInt(key, obj).apply() + } + is Boolean -> { + editor.putBoolean(key, obj).apply() + } + is Float -> { + editor.putFloat(key, obj).apply() + } + is Long -> { + editor.putLong(key, obj).apply() + } + else -> { + editor.putString(key, obj.toString()).apply() + } + } + } + + /** + * 获取保存的数据 + */ + operator fun getValue(key: String?, defaultObject: Any?): Any? { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + return when (defaultObject) { + is String -> { + sharedPreferences!!.getString(key, defaultObject as String?) + } + is Int -> { + sharedPreferences!!.getInt(key, (defaultObject as Int?)!!) + } + is Boolean -> { + sharedPreferences!!.getBoolean(key, (defaultObject as Boolean?)!!) + } + is Float -> { + sharedPreferences!!.getFloat(key, (defaultObject as Float?)!!) + } + is Long -> { + sharedPreferences!!.getLong(key, (defaultObject as Long?)!!) + } + else -> { + sharedPreferences!!.getString(key, null) + } + } + } + + /** + * 移除某个key值已经对应的值 + */ + fun removeKey(key: String?) { + editor!!.remove(key) + editor!!.commit() + } + + /** + * 清除所有数据 + */ + fun clearAll() { + editor!!.clear() + editor!!.commit() + } + + /** + * 查询某个key是否存在 + */ + fun containsKey(key: String?): Boolean { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + return sharedPreferences!!.contains(key) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt b/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt new file mode 100644 index 0000000..04db86b --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt @@ -0,0 +1,119 @@ +package com.casic.birmm.inspect.widgets + +import android.app.Dialog +import android.content.Context +import android.graphics.Color +import android.graphics.drawable.ColorDrawable +import android.os.Bundle +import android.view.WindowManager +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.utils.OtherUtils +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.dialog_input.* + + +class InputDialog private constructor(builder: Builder) : Dialog(builder.mContext!!) { + + private var ctx: Context? = null + private var title: String? = null + private var value: String? = null + private var positiveBtn: String? = null + private var negativeBtn: String? = null + private var listener: OnDialogButtonClickListener? = null + + init { + this.ctx = builder.mContext + this.title = builder.title + this.value = builder.value + this.positiveBtn = builder.positiveBtn + this.negativeBtn = builder.negativeBtn + this.listener = builder.listener + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + configDialogLayout() + setContentView(R.layout.dialog_input) + setCancelable(false) + setCanceledOnTouchOutside(false) + + dialogTitleView.text = title + value.apply { + dialogInputView.setText(this) + } + + dialogCancelButton.text = negativeBtn + dialogCancelButton.setChangeAlphaWhenPress(true) + dialogCancelButton.setOnClickListener { + this.dismiss() + } + + dialogConfirmButton.text = positiveBtn + dialogConfirmButton.setChangeAlphaWhenPress(true) + dialogConfirmButton.setOnClickListener { + val inputValue = dialogInputView.text.toString().trim() + if (inputValue.isEmpty()) { + OtherUtils.showTipsDialog(ctx!!, "什么都没输入,请重新输入", dialogConfirmButton) + return@setOnClickListener + } + listener?.onButtonClick(inputValue) + this.dismiss() + } + } + + private fun configDialogLayout() { + window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT)) + window?.decorView?.setBackgroundColor(Color.TRANSPARENT) + val params: WindowManager.LayoutParams? = window?.attributes + params?.width = QMUIDisplayHelper.dp2px(ctx, 300) + params?.height = WindowManager.LayoutParams.WRAP_CONTENT + window?.attributes = params + } + + class Builder { + var mContext: Context? = null + var title: String? = null + var value: String? = null + var positiveBtn: String? = null + var negativeBtn: String? = null + var listener: OnDialogButtonClickListener? = null + + fun setContext(context: Context?): Builder { + mContext = context + return this + } + + fun setTitle(title: String?): Builder { + this.title = title + return this + } + + fun setDefaultValue(value: String?): Builder { + this.value = value + return this + } + + fun setPositiveButton(name: String?): Builder { + positiveBtn = name + return this + } + + fun setNegativeButton(name: String?): Builder { + negativeBtn = name + return this + } + + fun setOnDialogClickListener(listener: OnDialogButtonClickListener): Builder { + this.listener = listener + return this + } + + fun build(): InputDialog { + return InputDialog(this) + } + } + + interface OnDialogButtonClickListener { + fun onButtonClick(input: String) + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_dialog_button.xml b/app/src/main/res/drawable/bg_dialog_button.xml new file mode 100644 index 0000000..5f7d57d --- /dev/null +++ b/app/src/main/res/drawable/bg_dialog_button.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_layout_white.xml b/app/src/main/res/drawable/bg_layout_white.xml new file mode 100644 index 0000000..19b473b --- /dev/null +++ b/app/src/main/res/drawable/bg_layout_white.xml @@ -0,0 +1,11 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/guide1.png b/app/src/main/res/drawable/guide1.png new file mode 100644 index 0000000..074c768 --- /dev/null +++ b/app/src/main/res/drawable/guide1.png Binary files differ diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_lock.xml b/app/src/main/res/drawable/ic_lock.xml new file mode 100644 index 0000000..f0a5610 --- /dev/null +++ b/app/src/main/res/drawable/ic_lock.xml @@ -0,0 +1,12 @@ + + + + diff --git a/app/src/main/res/drawable/ic_login_bg.png b/app/src/main/res/drawable/ic_login_bg.png new file mode 100644 index 0000000..64789c3 --- /dev/null +++ b/app/src/main/res/drawable/ic_login_bg.png Binary files differ diff --git a/app/src/main/res/drawable/ic_user.xml b/app/src/main/res/drawable/ic_user.xml new file mode 100644 index 0000000..8c4a29d --- /dev/null +++ b/app/src/main/res/drawable/ic_user.xml @@ -0,0 +1,15 @@ + + + + + diff --git a/app/src/main/res/layout/activity_guide.xml b/app/src/main/res/layout/activity_guide.xml new file mode 100644 index 0000000..e197626 --- /dev/null +++ b/app/src/main/res/layout/activity_guide.xml @@ -0,0 +1,19 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_login.xml b/app/src/main/res/layout/activity_login.xml new file mode 100644 index 0000000..bcae777 --- /dev/null +++ b/app/src/main/res/layout/activity_login.xml @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..def59e4 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,18 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_input.xml b/app/src/main/res/layout/dialog_input.xml new file mode 100644 index 0000000..f5a8bc6 --- /dev/null +++ b/app/src/main/res/layout/dialog_input.xml @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..a571e60 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 0000000..61da551 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..c41dd28 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png new file mode 100644 index 0000000..db5080a --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..6dba46d --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png new file mode 100644 index 0000000..da31a87 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..15ac681 --- /dev/null +++ b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..b216f2d --- /dev/null +++ b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..f25a419 --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..e96783c --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml new file mode 100644 index 0000000..662ee77 --- /dev/null +++ b/app/src/main/res/values/colors.xml @@ -0,0 +1,21 @@ + + + #6200EE + #3700B3 + #03DAC5 + + #FFFFFF + #E5E5E5 + #C0C0C0 + #808080 + #000000 + + #1565E3 + #575757 + + #06134C + #090E47 + #98A0BD + + #54000000 + diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml new file mode 100644 index 0000000..2dddf37 --- /dev/null +++ b/app/src/main/res/values/dimens.xml @@ -0,0 +1,14 @@ + + + 16sp + 18sp + + + 10dp + + + 10dp + + + 1px + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml new file mode 100644 index 0000000..fda9031 --- /dev/null +++ b/app/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + 航小科智巡宝 + diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml new file mode 100644 index 0000000..f16f3a9 --- /dev/null +++ b/app/src/main/res/values/styles.xml @@ -0,0 +1,23 @@ + + + + + + + + + diff --git a/app/src/test/java/com/casic/birmm/inspect/ExampleUnitTest.kt b/app/src/test/java/com/casic/birmm/inspect/ExampleUnitTest.kt new file mode 100644 index 0000000..21e44ca --- /dev/null +++ b/app/src/test/java/com/casic/birmm/inspect/ExampleUnitTest.kt @@ -0,0 +1,17 @@ +package com.casic.birmm.inspect + +import org.junit.Test + +import org.junit.Assert.* + +/** + * Example local unit test, which will execute on the development machine (host). + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +class ExampleUnitTest { + @Test + fun addition_isCorrect() { + assertEquals(4, 2 + 2) + } +} diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..500f939 --- /dev/null +++ b/build.gradle @@ -0,0 +1,31 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. + +buildscript { + ext.kotlin_version = '1.3.61' + repositories { + maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' } + google() + jcenter() + } + dependencies { + classpath 'com.android.tools.build:gradle:3.6.3' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files + } +} + +allprojects { + repositories { + maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' } + //依赖库 + maven { url 'https://jitpack.io' } + google() + jcenter() + } +} + +task clean(type: Delete) { + delete rootProject.buildDir +} diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..23339e0 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,21 @@ +# Project-wide Gradle settings. +# IDE (e.g. Android Studio) users: +# Gradle settings configured through the IDE *will override* +# any settings specified in this file. +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +org.gradle.jvmargs=-Xmx1536m +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. More details, visit +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects +# org.gradle.parallel=true +# AndroidX package structure to make it clearer which packages are bundled with the +# Android operating system, and which are packaged with your app's APK +# https://developer.android.com/topic/libraries/support-library/androidx-rn +android.useAndroidX=true +# Automatically convert third-party libraries to use AndroidX +android.enableJetifier=true +# Kotlin code style for this project: "official" or "obsolete": +kotlin.code.style=official diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..f6b961f --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.jar Binary files differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..0c4d16d --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Tue Jul 06 17:41:55 CST 2021 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip diff --git a/gradlew b/gradlew new file mode 100755 index 0000000..cccdd3d --- /dev/null +++ b/gradlew @@ -0,0 +1,172 @@ +#!/usr/bin/env sh + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=$(save "$@") + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then + cd "$(dirname "$0")" +fi + +exec "$JAVACMD" "$@" diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..603b140 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..88ea3aa --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,122 @@ + + + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+ + +
+
\ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..5cd135a --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..7bfef59 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..4ca4a9f --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,67 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' + +android { + compileSdkVersion 30 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.birmm.inspect" + minSdkVersion 21 + targetSdkVersion 30 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'androidx.core:core-ktx:1.3.2' + implementation 'androidx.constraintlayout:constraintlayout:2.0.4' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test.ext:junit:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:1.3.0' + //腾讯Android UI框架 + implementation 'com.qmuiteam:qmui:2.0.0-alpha10' + implementation 'com.qmuiteam:arch:0.3.1' + //沉浸式状态栏。基础依赖包,必须要依赖 + implementation 'com.gyf.immersionbar:immersionbar:3.0.0' + //fragment快速实现 + implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + + //MVP网络请求框架retrofit2+rxjava + implementation 'io.reactivex:rxjava:1.3.8' + implementation 'io.reactivex:rxandroid:1.2.1' + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.6.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + implementation 'com.squareup.retrofit2:adapter-rxjava:2.8.1' + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.8.6' + //Toast提示 + implementation 'com.sdsmdg.tastytoast:tastytoast:0.1.1' + //图片选择框架 + implementation 'com.github.LuckSiege.PictureSelector:picture_library:v2.6.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..ea03309 --- /dev/null +++ b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.casic.birmm.inspect + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.casic.birmm.inspect", appContext.packageName) + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..7096527 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt new file mode 100644 index 0000000..aefdbb6 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt @@ -0,0 +1,36 @@ +package com.casic.birmm.inspect.base + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.qmuiteam.qmui.util.QMUIStatusBarHelper + +abstract class BaseActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(initLayoutView()) + QMUIStatusBarHelper.translucent(this) //沉浸式状态栏 + setupTopBarLayout() + initData() + initEvent() + } + + /** + * 初始化xml布局 + */ + abstract fun initLayoutView(): Int + + /** + * 特定页面定制沉浸式状态栏 + */ + protected abstract fun setupTopBarLayout() + + /** + * 初始化默认数据 + */ + abstract fun initData() + + /** + * 初始化业务逻辑 + */ + abstract fun initEvent() +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt new file mode 100644 index 0000000..fc0ca75 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt @@ -0,0 +1,18 @@ +package com.casic.birmm.inspect.base + +import android.app.Application +import com.casic.birmm.inspect.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + companion object { + var instance: BaseApplication by Delegates.notNull() + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt new file mode 100644 index 0000000..ddc160a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt @@ -0,0 +1,56 @@ +package com.casic.birmm.inspect.ui + +import android.annotation.SuppressLint +import android.content.Intent +import android.os.CountDownTimer +import android.view.ViewGroup.MarginLayoutParams +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.activity_guide.* + +@SuppressLint("SetTextI18n") +class GuideActivity : BaseActivity() { + + private lateinit var countDownTimer: CountDownTimer + + override fun initLayoutView(): Int = R.layout.activity_guide + + override fun setupTopBarLayout() { + + } + + override fun initData() { + //根据不同设备状态栏高度设置"跳过"按钮的Margin值 + val statusBarHeight = QMUIDisplayHelper.getStatusBarHeight(this) + val rightMargin = QMUIDisplayHelper.dp2px(this, 10) + if (skipButton.layoutParams is MarginLayoutParams) { + val params = skipButton.layoutParams as MarginLayoutParams + params.setMargins(skipButton.width, statusBarHeight, rightMargin, 0) + skipButton.requestLayout() + } + + countDownTimer = object : CountDownTimer(4000, 1000) { + override fun onFinish() { + startLoginActivity() + } + + override fun onTick(millisUntilFinished: Long) { + skipButton.text = "跳过\u3000${(millisUntilFinished / 1000)}s" + } + } + } + + override fun initEvent() { + countDownTimer.start() + skipButton.setOnClickListener { + countDownTimer.cancel() + startLoginActivity() + } + } + + fun startLoginActivity() { + startActivity(Intent(this, LoginActivity::class.java)) + finish() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt new file mode 100644 index 0000000..6ef4548 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt @@ -0,0 +1,81 @@ +package com.casic.birmm.inspect.ui + +import android.text.Editable +import android.text.TextWatcher +import android.view.KeyEvent +import android.view.inputmethod.EditorInfo +import android.widget.EditText +import android.widget.TextView +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.casic.birmm.inspect.utils.Constant +import com.casic.birmm.inspect.utils.SaveKeyValues +import com.casic.birmm.inspect.widgets.InputDialog +import kotlinx.android.synthetic.main.activity_login.* + + +class LoginActivity : BaseActivity() { + + companion object { + private const val Tag = "LoginActivity" + } + + override fun initLayoutView(): Int = R.layout.activity_login + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + loginButton.setChangeAlphaWhenPress(true) + val editText: EditText? = inputLayout.editText + editText?.addTextChangedListener(object : TextWatcher { + override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) { + + } + + override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) { + + } + + override fun afterTextChanged(s: Editable) { + if (s.toString().trim { it <= ' ' }.length > 12) { + inputLayout.error = "密码长度超出限制" + } else { + inputLayout.error = null + } + } + }) + //点击输入法键盘"完成" + editText?.setOnEditorActionListener { _: TextView?, actionId: Int, _: KeyEvent? -> + if (actionId == EditorInfo.IME_ACTION_DONE) { +// authenticatePresenter.onReadyRetrofitRequest() + return@setOnEditorActionListener true + } + false + } + + //修改服务器配置 + changeServerConfigView.setOnClickListener { + val defaultValue = SaveKeyValues.getValue( + Constant.DEFAULT_SERVER_CONFIG, + "http://139.198.6.177:8093/" + ) as String + InputDialog.Builder().setContext(this) + .setTitle("请输入后台服务器地址") + .setDefaultValue(defaultValue) + .setNegativeButton("取消") + .setPositiveButton("保存") + .setOnDialogClickListener(object : InputDialog.OnDialogButtonClickListener { + override fun onButtonClick(input: String) { + SaveKeyValues.putValue(Constant.DEFAULT_SERVER_CONFIG, input) + } + }) + .build().show() + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt new file mode 100644 index 0000000..0e97af7 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt @@ -0,0 +1,21 @@ +package com.casic.birmm.inspect.ui + +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity + +class MainActivity : BaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt new file mode 100644 index 0000000..21fbba2 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt @@ -0,0 +1,58 @@ +package com.casic.birmm.inspect.ui + +import android.content.Intent +import android.os.Build +import android.os.Bundle +import android.util.Log +import androidx.appcompat.app.AppCompatActivity +import com.casic.birmm.inspect.utils.Constant +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + companion object { + private const val TAG = "PermissionActivity" + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + if (EasyPermissions.hasPermissions(this, *Constant.USER_PERMISSIONS)) { + startGuideActivity() + } else { + EasyPermissions.requestPermissions( + this, + "需要获取相关权限", + Constant.PERMISSIONS_CODE, + *Constant.USER_PERMISSIONS + ) + } + } else { + startGuideActivity() + } + } + + private fun startGuideActivity() { + startActivity(Intent(this, GuideActivity::class.java)) + finish() + } + + override fun onRequestPermissionsResult( + requestCode: Int, + permissions: Array, + grantResults: IntArray + ) { + super.onRequestPermissionsResult(requestCode, permissions, grantResults) + EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this) + } + + override fun onPermissionsGranted(requestCode: Int, perms: List) { + startGuideActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + Log.e(TAG, "onPermissionsDenied: $perms") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt new file mode 100644 index 0000000..53df6e1 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt @@ -0,0 +1,15 @@ +package com.casic.birmm.inspect.utils + +import android.Manifest + + +object Constant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.ACCESS_LOCATION_EXTRA_COMMANDS, + Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION + ) + + const val PERMISSIONS_CODE = 999 + + const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt new file mode 100644 index 0000000..4c38241 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt @@ -0,0 +1,19 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.view.View +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object OtherUtils { + + //替换Toast + fun showTipsDialog(context: Context, message: String, view: View) { + val tipDialog = QMUITipDialog.Builder(context) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_NOTHING) + .setTipWord(message).create() + tipDialog.show() + view.postDelayed({ + tipDialog.dismiss() + }, 2000) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt b/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt new file mode 100644 index 0000000..04c9f5a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt @@ -0,0 +1,106 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.content.SharedPreferences +import com.casic.birmm.inspect.base.BaseApplication + +object SaveKeyValues { + private var sharedPreferences: SharedPreferences? = null + private var editor: SharedPreferences.Editor? = null + private var fileName: String? = null + + fun initSharedPreferences() { + val packageName = BaseApplication.instance.packageName + //获取到的包名带有“.”方便命名,取最后一个作为sp文件名,例如:com.casic.birmm.inspect + val split = packageName.split(".") + fileName = split[split.size - 1] + } + + /** + * 存储 + */ + fun putValue(key: String?, obj: Any) { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + val editor = sharedPreferences!!.edit() + when (obj) { + is String -> { + editor.putString(key, obj).apply() + } + is Int -> { + editor.putInt(key, obj).apply() + } + is Boolean -> { + editor.putBoolean(key, obj).apply() + } + is Float -> { + editor.putFloat(key, obj).apply() + } + is Long -> { + editor.putLong(key, obj).apply() + } + else -> { + editor.putString(key, obj.toString()).apply() + } + } + } + + /** + * 获取保存的数据 + */ + operator fun getValue(key: String?, defaultObject: Any?): Any? { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + return when (defaultObject) { + is String -> { + sharedPreferences!!.getString(key, defaultObject as String?) + } + is Int -> { + sharedPreferences!!.getInt(key, (defaultObject as Int?)!!) + } + is Boolean -> { + sharedPreferences!!.getBoolean(key, (defaultObject as Boolean?)!!) + } + is Float -> { + sharedPreferences!!.getFloat(key, (defaultObject as Float?)!!) + } + is Long -> { + sharedPreferences!!.getLong(key, (defaultObject as Long?)!!) + } + else -> { + sharedPreferences!!.getString(key, null) + } + } + } + + /** + * 移除某个key值已经对应的值 + */ + fun removeKey(key: String?) { + editor!!.remove(key) + editor!!.commit() + } + + /** + * 清除所有数据 + */ + fun clearAll() { + editor!!.clear() + editor!!.commit() + } + + /** + * 查询某个key是否存在 + */ + fun containsKey(key: String?): Boolean { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + return sharedPreferences!!.contains(key) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt b/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt new file mode 100644 index 0000000..04db86b --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt @@ -0,0 +1,119 @@ +package com.casic.birmm.inspect.widgets + +import android.app.Dialog +import android.content.Context +import android.graphics.Color +import android.graphics.drawable.ColorDrawable +import android.os.Bundle +import android.view.WindowManager +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.utils.OtherUtils +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.dialog_input.* + + +class InputDialog private constructor(builder: Builder) : Dialog(builder.mContext!!) { + + private var ctx: Context? = null + private var title: String? = null + private var value: String? = null + private var positiveBtn: String? = null + private var negativeBtn: String? = null + private var listener: OnDialogButtonClickListener? = null + + init { + this.ctx = builder.mContext + this.title = builder.title + this.value = builder.value + this.positiveBtn = builder.positiveBtn + this.negativeBtn = builder.negativeBtn + this.listener = builder.listener + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + configDialogLayout() + setContentView(R.layout.dialog_input) + setCancelable(false) + setCanceledOnTouchOutside(false) + + dialogTitleView.text = title + value.apply { + dialogInputView.setText(this) + } + + dialogCancelButton.text = negativeBtn + dialogCancelButton.setChangeAlphaWhenPress(true) + dialogCancelButton.setOnClickListener { + this.dismiss() + } + + dialogConfirmButton.text = positiveBtn + dialogConfirmButton.setChangeAlphaWhenPress(true) + dialogConfirmButton.setOnClickListener { + val inputValue = dialogInputView.text.toString().trim() + if (inputValue.isEmpty()) { + OtherUtils.showTipsDialog(ctx!!, "什么都没输入,请重新输入", dialogConfirmButton) + return@setOnClickListener + } + listener?.onButtonClick(inputValue) + this.dismiss() + } + } + + private fun configDialogLayout() { + window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT)) + window?.decorView?.setBackgroundColor(Color.TRANSPARENT) + val params: WindowManager.LayoutParams? = window?.attributes + params?.width = QMUIDisplayHelper.dp2px(ctx, 300) + params?.height = WindowManager.LayoutParams.WRAP_CONTENT + window?.attributes = params + } + + class Builder { + var mContext: Context? = null + var title: String? = null + var value: String? = null + var positiveBtn: String? = null + var negativeBtn: String? = null + var listener: OnDialogButtonClickListener? = null + + fun setContext(context: Context?): Builder { + mContext = context + return this + } + + fun setTitle(title: String?): Builder { + this.title = title + return this + } + + fun setDefaultValue(value: String?): Builder { + this.value = value + return this + } + + fun setPositiveButton(name: String?): Builder { + positiveBtn = name + return this + } + + fun setNegativeButton(name: String?): Builder { + negativeBtn = name + return this + } + + fun setOnDialogClickListener(listener: OnDialogButtonClickListener): Builder { + this.listener = listener + return this + } + + fun build(): InputDialog { + return InputDialog(this) + } + } + + interface OnDialogButtonClickListener { + fun onButtonClick(input: String) + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_dialog_button.xml b/app/src/main/res/drawable/bg_dialog_button.xml new file mode 100644 index 0000000..5f7d57d --- /dev/null +++ b/app/src/main/res/drawable/bg_dialog_button.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_layout_white.xml b/app/src/main/res/drawable/bg_layout_white.xml new file mode 100644 index 0000000..19b473b --- /dev/null +++ b/app/src/main/res/drawable/bg_layout_white.xml @@ -0,0 +1,11 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/guide1.png b/app/src/main/res/drawable/guide1.png new file mode 100644 index 0000000..074c768 --- /dev/null +++ b/app/src/main/res/drawable/guide1.png Binary files differ diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_lock.xml b/app/src/main/res/drawable/ic_lock.xml new file mode 100644 index 0000000..f0a5610 --- /dev/null +++ b/app/src/main/res/drawable/ic_lock.xml @@ -0,0 +1,12 @@ + + + + diff --git a/app/src/main/res/drawable/ic_login_bg.png b/app/src/main/res/drawable/ic_login_bg.png new file mode 100644 index 0000000..64789c3 --- /dev/null +++ b/app/src/main/res/drawable/ic_login_bg.png Binary files differ diff --git a/app/src/main/res/drawable/ic_user.xml b/app/src/main/res/drawable/ic_user.xml new file mode 100644 index 0000000..8c4a29d --- /dev/null +++ b/app/src/main/res/drawable/ic_user.xml @@ -0,0 +1,15 @@ + + + + + diff --git a/app/src/main/res/layout/activity_guide.xml b/app/src/main/res/layout/activity_guide.xml new file mode 100644 index 0000000..e197626 --- /dev/null +++ b/app/src/main/res/layout/activity_guide.xml @@ -0,0 +1,19 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_login.xml b/app/src/main/res/layout/activity_login.xml new file mode 100644 index 0000000..bcae777 --- /dev/null +++ b/app/src/main/res/layout/activity_login.xml @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..def59e4 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,18 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_input.xml b/app/src/main/res/layout/dialog_input.xml new file mode 100644 index 0000000..f5a8bc6 --- /dev/null +++ b/app/src/main/res/layout/dialog_input.xml @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..a571e60 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 0000000..61da551 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..c41dd28 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png new file mode 100644 index 0000000..db5080a --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..6dba46d --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png new file mode 100644 index 0000000..da31a87 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..15ac681 --- /dev/null +++ b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..b216f2d --- /dev/null +++ b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..f25a419 --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..e96783c --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml new file mode 100644 index 0000000..662ee77 --- /dev/null +++ b/app/src/main/res/values/colors.xml @@ -0,0 +1,21 @@ + + + #6200EE + #3700B3 + #03DAC5 + + #FFFFFF + #E5E5E5 + #C0C0C0 + #808080 + #000000 + + #1565E3 + #575757 + + #06134C + #090E47 + #98A0BD + + #54000000 + diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml new file mode 100644 index 0000000..2dddf37 --- /dev/null +++ b/app/src/main/res/values/dimens.xml @@ -0,0 +1,14 @@ + + + 16sp + 18sp + + + 10dp + + + 10dp + + + 1px + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml new file mode 100644 index 0000000..fda9031 --- /dev/null +++ b/app/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + 航小科智巡宝 + diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml new file mode 100644 index 0000000..f16f3a9 --- /dev/null +++ b/app/src/main/res/values/styles.xml @@ -0,0 +1,23 @@ + + + + + + + + + diff --git a/app/src/test/java/com/casic/birmm/inspect/ExampleUnitTest.kt b/app/src/test/java/com/casic/birmm/inspect/ExampleUnitTest.kt new file mode 100644 index 0000000..21e44ca --- /dev/null +++ b/app/src/test/java/com/casic/birmm/inspect/ExampleUnitTest.kt @@ -0,0 +1,17 @@ +package com.casic.birmm.inspect + +import org.junit.Test + +import org.junit.Assert.* + +/** + * Example local unit test, which will execute on the development machine (host). + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +class ExampleUnitTest { + @Test + fun addition_isCorrect() { + assertEquals(4, 2 + 2) + } +} diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..500f939 --- /dev/null +++ b/build.gradle @@ -0,0 +1,31 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. + +buildscript { + ext.kotlin_version = '1.3.61' + repositories { + maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' } + google() + jcenter() + } + dependencies { + classpath 'com.android.tools.build:gradle:3.6.3' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files + } +} + +allprojects { + repositories { + maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' } + //依赖库 + maven { url 'https://jitpack.io' } + google() + jcenter() + } +} + +task clean(type: Delete) { + delete rootProject.buildDir +} diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..23339e0 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,21 @@ +# Project-wide Gradle settings. +# IDE (e.g. Android Studio) users: +# Gradle settings configured through the IDE *will override* +# any settings specified in this file. +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +org.gradle.jvmargs=-Xmx1536m +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. More details, visit +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects +# org.gradle.parallel=true +# AndroidX package structure to make it clearer which packages are bundled with the +# Android operating system, and which are packaged with your app's APK +# https://developer.android.com/topic/libraries/support-library/androidx-rn +android.useAndroidX=true +# Automatically convert third-party libraries to use AndroidX +android.enableJetifier=true +# Kotlin code style for this project: "official" or "obsolete": +kotlin.code.style=official diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..f6b961f --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.jar Binary files differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..0c4d16d --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Tue Jul 06 17:41:55 CST 2021 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip diff --git a/gradlew b/gradlew new file mode 100755 index 0000000..cccdd3d --- /dev/null +++ b/gradlew @@ -0,0 +1,172 @@ +#!/usr/bin/env sh + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=$(save "$@") + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then + cd "$(dirname "$0")" +fi + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..e95643d --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,84 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..603b140 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..88ea3aa --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,122 @@ + + + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+ + +
+
\ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..5cd135a --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..7bfef59 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..4ca4a9f --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,67 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' + +android { + compileSdkVersion 30 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.birmm.inspect" + minSdkVersion 21 + targetSdkVersion 30 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'androidx.core:core-ktx:1.3.2' + implementation 'androidx.constraintlayout:constraintlayout:2.0.4' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test.ext:junit:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:1.3.0' + //腾讯Android UI框架 + implementation 'com.qmuiteam:qmui:2.0.0-alpha10' + implementation 'com.qmuiteam:arch:0.3.1' + //沉浸式状态栏。基础依赖包,必须要依赖 + implementation 'com.gyf.immersionbar:immersionbar:3.0.0' + //fragment快速实现 + implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' + + //MVP网络请求框架retrofit2+rxjava + implementation 'io.reactivex:rxjava:1.3.8' + implementation 'io.reactivex:rxandroid:1.2.1' + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.6.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + implementation 'com.squareup.retrofit2:adapter-rxjava:2.8.1' + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.8.6' + //Toast提示 + implementation 'com.sdsmdg.tastytoast:tastytoast:0.1.1' + //图片选择框架 + implementation 'com.github.LuckSiege.PictureSelector:picture_library:v2.6.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..ea03309 --- /dev/null +++ b/app/src/androidTest/java/com/casic/birmm/inspect/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.casic.birmm.inspect + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.casic.birmm.inspect", appContext.packageName) + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..7096527 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt new file mode 100644 index 0000000..aefdbb6 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseActivity.kt @@ -0,0 +1,36 @@ +package com.casic.birmm.inspect.base + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.qmuiteam.qmui.util.QMUIStatusBarHelper + +abstract class BaseActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(initLayoutView()) + QMUIStatusBarHelper.translucent(this) //沉浸式状态栏 + setupTopBarLayout() + initData() + initEvent() + } + + /** + * 初始化xml布局 + */ + abstract fun initLayoutView(): Int + + /** + * 特定页面定制沉浸式状态栏 + */ + protected abstract fun setupTopBarLayout() + + /** + * 初始化默认数据 + */ + abstract fun initData() + + /** + * 初始化业务逻辑 + */ + abstract fun initEvent() +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt new file mode 100644 index 0000000..fc0ca75 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/base/BaseApplication.kt @@ -0,0 +1,18 @@ +package com.casic.birmm.inspect.base + +import android.app.Application +import com.casic.birmm.inspect.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + companion object { + var instance: BaseApplication by Delegates.notNull() + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt new file mode 100644 index 0000000..ddc160a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/GuideActivity.kt @@ -0,0 +1,56 @@ +package com.casic.birmm.inspect.ui + +import android.annotation.SuppressLint +import android.content.Intent +import android.os.CountDownTimer +import android.view.ViewGroup.MarginLayoutParams +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.activity_guide.* + +@SuppressLint("SetTextI18n") +class GuideActivity : BaseActivity() { + + private lateinit var countDownTimer: CountDownTimer + + override fun initLayoutView(): Int = R.layout.activity_guide + + override fun setupTopBarLayout() { + + } + + override fun initData() { + //根据不同设备状态栏高度设置"跳过"按钮的Margin值 + val statusBarHeight = QMUIDisplayHelper.getStatusBarHeight(this) + val rightMargin = QMUIDisplayHelper.dp2px(this, 10) + if (skipButton.layoutParams is MarginLayoutParams) { + val params = skipButton.layoutParams as MarginLayoutParams + params.setMargins(skipButton.width, statusBarHeight, rightMargin, 0) + skipButton.requestLayout() + } + + countDownTimer = object : CountDownTimer(4000, 1000) { + override fun onFinish() { + startLoginActivity() + } + + override fun onTick(millisUntilFinished: Long) { + skipButton.text = "跳过\u3000${(millisUntilFinished / 1000)}s" + } + } + } + + override fun initEvent() { + countDownTimer.start() + skipButton.setOnClickListener { + countDownTimer.cancel() + startLoginActivity() + } + } + + fun startLoginActivity() { + startActivity(Intent(this, LoginActivity::class.java)) + finish() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt new file mode 100644 index 0000000..6ef4548 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/LoginActivity.kt @@ -0,0 +1,81 @@ +package com.casic.birmm.inspect.ui + +import android.text.Editable +import android.text.TextWatcher +import android.view.KeyEvent +import android.view.inputmethod.EditorInfo +import android.widget.EditText +import android.widget.TextView +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity +import com.casic.birmm.inspect.utils.Constant +import com.casic.birmm.inspect.utils.SaveKeyValues +import com.casic.birmm.inspect.widgets.InputDialog +import kotlinx.android.synthetic.main.activity_login.* + + +class LoginActivity : BaseActivity() { + + companion object { + private const val Tag = "LoginActivity" + } + + override fun initLayoutView(): Int = R.layout.activity_login + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + loginButton.setChangeAlphaWhenPress(true) + val editText: EditText? = inputLayout.editText + editText?.addTextChangedListener(object : TextWatcher { + override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) { + + } + + override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) { + + } + + override fun afterTextChanged(s: Editable) { + if (s.toString().trim { it <= ' ' }.length > 12) { + inputLayout.error = "密码长度超出限制" + } else { + inputLayout.error = null + } + } + }) + //点击输入法键盘"完成" + editText?.setOnEditorActionListener { _: TextView?, actionId: Int, _: KeyEvent? -> + if (actionId == EditorInfo.IME_ACTION_DONE) { +// authenticatePresenter.onReadyRetrofitRequest() + return@setOnEditorActionListener true + } + false + } + + //修改服务器配置 + changeServerConfigView.setOnClickListener { + val defaultValue = SaveKeyValues.getValue( + Constant.DEFAULT_SERVER_CONFIG, + "http://139.198.6.177:8093/" + ) as String + InputDialog.Builder().setContext(this) + .setTitle("请输入后台服务器地址") + .setDefaultValue(defaultValue) + .setNegativeButton("取消") + .setPositiveButton("保存") + .setOnDialogClickListener(object : InputDialog.OnDialogButtonClickListener { + override fun onButtonClick(input: String) { + SaveKeyValues.putValue(Constant.DEFAULT_SERVER_CONFIG, input) + } + }) + .build().show() + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt new file mode 100644 index 0000000..0e97af7 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/MainActivity.kt @@ -0,0 +1,21 @@ +package com.casic.birmm.inspect.ui + +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.base.BaseActivity + +class MainActivity : BaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} diff --git a/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt new file mode 100644 index 0000000..21fbba2 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/ui/PermissionActivity.kt @@ -0,0 +1,58 @@ +package com.casic.birmm.inspect.ui + +import android.content.Intent +import android.os.Build +import android.os.Bundle +import android.util.Log +import androidx.appcompat.app.AppCompatActivity +import com.casic.birmm.inspect.utils.Constant +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + companion object { + private const val TAG = "PermissionActivity" + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + if (EasyPermissions.hasPermissions(this, *Constant.USER_PERMISSIONS)) { + startGuideActivity() + } else { + EasyPermissions.requestPermissions( + this, + "需要获取相关权限", + Constant.PERMISSIONS_CODE, + *Constant.USER_PERMISSIONS + ) + } + } else { + startGuideActivity() + } + } + + private fun startGuideActivity() { + startActivity(Intent(this, GuideActivity::class.java)) + finish() + } + + override fun onRequestPermissionsResult( + requestCode: Int, + permissions: Array, + grantResults: IntArray + ) { + super.onRequestPermissionsResult(requestCode, permissions, grantResults) + EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this) + } + + override fun onPermissionsGranted(requestCode: Int, perms: List) { + startGuideActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + Log.e(TAG, "onPermissionsDenied: $perms") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt new file mode 100644 index 0000000..53df6e1 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/Constant.kt @@ -0,0 +1,15 @@ +package com.casic.birmm.inspect.utils + +import android.Manifest + + +object Constant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.ACCESS_LOCATION_EXTRA_COMMANDS, + Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION + ) + + const val PERMISSIONS_CODE = 999 + + const val DEFAULT_SERVER_CONFIG = "defaultServerConfig" +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt new file mode 100644 index 0000000..4c38241 --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/OtherUtils.kt @@ -0,0 +1,19 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.view.View +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object OtherUtils { + + //替换Toast + fun showTipsDialog(context: Context, message: String, view: View) { + val tipDialog = QMUITipDialog.Builder(context) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_NOTHING) + .setTipWord(message).create() + tipDialog.show() + view.postDelayed({ + tipDialog.dismiss() + }, 2000) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt b/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt new file mode 100644 index 0000000..04c9f5a --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/utils/SaveKeyValues.kt @@ -0,0 +1,106 @@ +package com.casic.birmm.inspect.utils + +import android.content.Context +import android.content.SharedPreferences +import com.casic.birmm.inspect.base.BaseApplication + +object SaveKeyValues { + private var sharedPreferences: SharedPreferences? = null + private var editor: SharedPreferences.Editor? = null + private var fileName: String? = null + + fun initSharedPreferences() { + val packageName = BaseApplication.instance.packageName + //获取到的包名带有“.”方便命名,取最后一个作为sp文件名,例如:com.casic.birmm.inspect + val split = packageName.split(".") + fileName = split[split.size - 1] + } + + /** + * 存储 + */ + fun putValue(key: String?, obj: Any) { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + val editor = sharedPreferences!!.edit() + when (obj) { + is String -> { + editor.putString(key, obj).apply() + } + is Int -> { + editor.putInt(key, obj).apply() + } + is Boolean -> { + editor.putBoolean(key, obj).apply() + } + is Float -> { + editor.putFloat(key, obj).apply() + } + is Long -> { + editor.putLong(key, obj).apply() + } + else -> { + editor.putString(key, obj.toString()).apply() + } + } + } + + /** + * 获取保存的数据 + */ + operator fun getValue(key: String?, defaultObject: Any?): Any? { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + return when (defaultObject) { + is String -> { + sharedPreferences!!.getString(key, defaultObject as String?) + } + is Int -> { + sharedPreferences!!.getInt(key, (defaultObject as Int?)!!) + } + is Boolean -> { + sharedPreferences!!.getBoolean(key, (defaultObject as Boolean?)!!) + } + is Float -> { + sharedPreferences!!.getFloat(key, (defaultObject as Float?)!!) + } + is Long -> { + sharedPreferences!!.getLong(key, (defaultObject as Long?)!!) + } + else -> { + sharedPreferences!!.getString(key, null) + } + } + } + + /** + * 移除某个key值已经对应的值 + */ + fun removeKey(key: String?) { + editor!!.remove(key) + editor!!.commit() + } + + /** + * 清除所有数据 + */ + fun clearAll() { + editor!!.clear() + editor!!.commit() + } + + /** + * 查询某个key是否存在 + */ + fun containsKey(key: String?): Boolean { + sharedPreferences = BaseApplication.instance.getSharedPreferences( + fileName, + Context.MODE_PRIVATE + ) + return sharedPreferences!!.contains(key) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt b/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt new file mode 100644 index 0000000..04db86b --- /dev/null +++ b/app/src/main/java/com/casic/birmm/inspect/widgets/InputDialog.kt @@ -0,0 +1,119 @@ +package com.casic.birmm.inspect.widgets + +import android.app.Dialog +import android.content.Context +import android.graphics.Color +import android.graphics.drawable.ColorDrawable +import android.os.Bundle +import android.view.WindowManager +import com.casic.birmm.inspect.R +import com.casic.birmm.inspect.utils.OtherUtils +import com.qmuiteam.qmui.util.QMUIDisplayHelper +import kotlinx.android.synthetic.main.dialog_input.* + + +class InputDialog private constructor(builder: Builder) : Dialog(builder.mContext!!) { + + private var ctx: Context? = null + private var title: String? = null + private var value: String? = null + private var positiveBtn: String? = null + private var negativeBtn: String? = null + private var listener: OnDialogButtonClickListener? = null + + init { + this.ctx = builder.mContext + this.title = builder.title + this.value = builder.value + this.positiveBtn = builder.positiveBtn + this.negativeBtn = builder.negativeBtn + this.listener = builder.listener + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + configDialogLayout() + setContentView(R.layout.dialog_input) + setCancelable(false) + setCanceledOnTouchOutside(false) + + dialogTitleView.text = title + value.apply { + dialogInputView.setText(this) + } + + dialogCancelButton.text = negativeBtn + dialogCancelButton.setChangeAlphaWhenPress(true) + dialogCancelButton.setOnClickListener { + this.dismiss() + } + + dialogConfirmButton.text = positiveBtn + dialogConfirmButton.setChangeAlphaWhenPress(true) + dialogConfirmButton.setOnClickListener { + val inputValue = dialogInputView.text.toString().trim() + if (inputValue.isEmpty()) { + OtherUtils.showTipsDialog(ctx!!, "什么都没输入,请重新输入", dialogConfirmButton) + return@setOnClickListener + } + listener?.onButtonClick(inputValue) + this.dismiss() + } + } + + private fun configDialogLayout() { + window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT)) + window?.decorView?.setBackgroundColor(Color.TRANSPARENT) + val params: WindowManager.LayoutParams? = window?.attributes + params?.width = QMUIDisplayHelper.dp2px(ctx, 300) + params?.height = WindowManager.LayoutParams.WRAP_CONTENT + window?.attributes = params + } + + class Builder { + var mContext: Context? = null + var title: String? = null + var value: String? = null + var positiveBtn: String? = null + var negativeBtn: String? = null + var listener: OnDialogButtonClickListener? = null + + fun setContext(context: Context?): Builder { + mContext = context + return this + } + + fun setTitle(title: String?): Builder { + this.title = title + return this + } + + fun setDefaultValue(value: String?): Builder { + this.value = value + return this + } + + fun setPositiveButton(name: String?): Builder { + positiveBtn = name + return this + } + + fun setNegativeButton(name: String?): Builder { + negativeBtn = name + return this + } + + fun setOnDialogClickListener(listener: OnDialogButtonClickListener): Builder { + this.listener = listener + return this + } + + fun build(): InputDialog { + return InputDialog(this) + } + } + + interface OnDialogButtonClickListener { + fun onButtonClick(input: String) + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_dialog_button.xml b/app/src/main/res/drawable/bg_dialog_button.xml new file mode 100644 index 0000000..5f7d57d --- /dev/null +++ b/app/src/main/res/drawable/bg_dialog_button.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_layout_white.xml b/app/src/main/res/drawable/bg_layout_white.xml new file mode 100644 index 0000000..19b473b --- /dev/null +++ b/app/src/main/res/drawable/bg_layout_white.xml @@ -0,0 +1,11 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/guide1.png b/app/src/main/res/drawable/guide1.png new file mode 100644 index 0000000..074c768 --- /dev/null +++ b/app/src/main/res/drawable/guide1.png Binary files differ diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_lock.xml b/app/src/main/res/drawable/ic_lock.xml new file mode 100644 index 0000000..f0a5610 --- /dev/null +++ b/app/src/main/res/drawable/ic_lock.xml @@ -0,0 +1,12 @@ + + + + diff --git a/app/src/main/res/drawable/ic_login_bg.png b/app/src/main/res/drawable/ic_login_bg.png new file mode 100644 index 0000000..64789c3 --- /dev/null +++ b/app/src/main/res/drawable/ic_login_bg.png Binary files differ diff --git a/app/src/main/res/drawable/ic_user.xml b/app/src/main/res/drawable/ic_user.xml new file mode 100644 index 0000000..8c4a29d --- /dev/null +++ b/app/src/main/res/drawable/ic_user.xml @@ -0,0 +1,15 @@ + + + + + diff --git a/app/src/main/res/layout/activity_guide.xml b/app/src/main/res/layout/activity_guide.xml new file mode 100644 index 0000000..e197626 --- /dev/null +++ b/app/src/main/res/layout/activity_guide.xml @@ -0,0 +1,19 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_login.xml b/app/src/main/res/layout/activity_login.xml new file mode 100644 index 0000000..bcae777 --- /dev/null +++ b/app/src/main/res/layout/activity_login.xml @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..def59e4 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,18 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_input.xml b/app/src/main/res/layout/dialog_input.xml new file mode 100644 index 0000000..f5a8bc6 --- /dev/null +++ b/app/src/main/res/layout/dialog_input.xml @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..a571e60 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 0000000..61da551 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..c41dd28 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png new file mode 100644 index 0000000..db5080a --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..6dba46d --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png new file mode 100644 index 0000000..da31a87 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..15ac681 --- /dev/null +++ b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..b216f2d --- /dev/null +++ b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..f25a419 --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..e96783c --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png Binary files differ diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml new file mode 100644 index 0000000..662ee77 --- /dev/null +++ b/app/src/main/res/values/colors.xml @@ -0,0 +1,21 @@ + + + #6200EE + #3700B3 + #03DAC5 + + #FFFFFF + #E5E5E5 + #C0C0C0 + #808080 + #000000 + + #1565E3 + #575757 + + #06134C + #090E47 + #98A0BD + + #54000000 + diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml new file mode 100644 index 0000000..2dddf37 --- /dev/null +++ b/app/src/main/res/values/dimens.xml @@ -0,0 +1,14 @@ + + + 16sp + 18sp + + + 10dp + + + 10dp + + + 1px + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml new file mode 100644 index 0000000..fda9031 --- /dev/null +++ b/app/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + 航小科智巡宝 + diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml new file mode 100644 index 0000000..f16f3a9 --- /dev/null +++ b/app/src/main/res/values/styles.xml @@ -0,0 +1,23 @@ + + + + + + + + + diff --git a/app/src/test/java/com/casic/birmm/inspect/ExampleUnitTest.kt b/app/src/test/java/com/casic/birmm/inspect/ExampleUnitTest.kt new file mode 100644 index 0000000..21e44ca --- /dev/null +++ b/app/src/test/java/com/casic/birmm/inspect/ExampleUnitTest.kt @@ -0,0 +1,17 @@ +package com.casic.birmm.inspect + +import org.junit.Test + +import org.junit.Assert.* + +/** + * Example local unit test, which will execute on the development machine (host). + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +class ExampleUnitTest { + @Test + fun addition_isCorrect() { + assertEquals(4, 2 + 2) + } +} diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..500f939 --- /dev/null +++ b/build.gradle @@ -0,0 +1,31 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. + +buildscript { + ext.kotlin_version = '1.3.61' + repositories { + maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' } + google() + jcenter() + } + dependencies { + classpath 'com.android.tools.build:gradle:3.6.3' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files + } +} + +allprojects { + repositories { + maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' } + //依赖库 + maven { url 'https://jitpack.io' } + google() + jcenter() + } +} + +task clean(type: Delete) { + delete rootProject.buildDir +} diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..23339e0 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,21 @@ +# Project-wide Gradle settings. +# IDE (e.g. Android Studio) users: +# Gradle settings configured through the IDE *will override* +# any settings specified in this file. +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +org.gradle.jvmargs=-Xmx1536m +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. More details, visit +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects +# org.gradle.parallel=true +# AndroidX package structure to make it clearer which packages are bundled with the +# Android operating system, and which are packaged with your app's APK +# https://developer.android.com/topic/libraries/support-library/androidx-rn +android.useAndroidX=true +# Automatically convert third-party libraries to use AndroidX +android.enableJetifier=true +# Kotlin code style for this project: "official" or "obsolete": +kotlin.code.style=official diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..f6b961f --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.jar Binary files differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..0c4d16d --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Tue Jul 06 17:41:55 CST 2021 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip diff --git a/gradlew b/gradlew new file mode 100755 index 0000000..cccdd3d --- /dev/null +++ b/gradlew @@ -0,0 +1,172 @@ +#!/usr/bin/env sh + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=$(save "$@") + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then + cd "$(dirname "$0")" +fi + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..e95643d --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,84 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..0c65381 --- /dev/null +++ b/settings.gradle @@ -0,0 +1,2 @@ +rootProject.name='inspect_app' +include ':app'