diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..10cfdbf --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*.iml +.gradle +/local.properties +/.idea +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..10cfdbf --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*.iml +.gradle +/local.properties +/.idea +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..a4cd2ca --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,101 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'org.greenrobot.greendao' + +android { +// signingConfigs { +// release { +// storeFile file('/Users/a203/Desktop/AndroidProjects/CasicSmartWell/app/CasicSmartWell.jks') +// storePassword '123456789' +// keyAlias 'key0' +// keyPassword '123456789' +// } +// } + compileSdkVersion 31 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.smart.town.sanxi" + minSdkVersion 23 + targetSdkVersion 31 + versionCode 1 + versionName "1.0.0" + + manifestPlaceholders = [GETUI_APPID: "A9V4DvwLcdAqkFCQuFyhq6"] + } + + buildTypes { + release { + minifyEnabled false +// signingConfig signingConfigs.release + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + + ndk { abiFilters "armeabi", "armeabi-v7a", "arm64-v8" } + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlin { + experimental { + coroutines 'enable' + } + } + + greendao { + schemaVersion 1//数据库版本号 + targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 + daoPackage 'com.casic.smart.town.sanxi.greendao'//设置DaoMaster、DaoSession、Dao包名 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + //基础依赖库 + implementation files('libs/lite-release.aar') + implementation 'androidx.appcompat:appcompat:1.4.2' + implementation 'androidx.core:core-ktx:1.8.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:3.0.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' + //MVVM+LiveData + implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.1" + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0" + implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + //Kotlin协程 + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1' + //图片加载框架 + implementation 'com.github.bumptech.glide:glide:4.9.0' + //返回值转换器 + implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' + implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + //okhttp3日志拦截器 + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //网络请求和接口封装 + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.9.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.9.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' + //高德地图 + implementation 'com.amap.api:3dmap:latest.integration' + //推送SDK + implementation 'com.getui:gtsdk:3.2.10.0' //个推SDK + implementation 'com.getui:gtc:3.1.9.0' //个推核心组件 + //数据库框架 + implementation 'org.greenrobot:greendao:3.3.0' + //桌面角标 + implementation "me.leolin:ShortcutBadger:1.1.22@aar" +} \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..10cfdbf --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*.iml +.gradle +/local.properties +/.idea +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..a4cd2ca --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,101 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'org.greenrobot.greendao' + +android { +// signingConfigs { +// release { +// storeFile file('/Users/a203/Desktop/AndroidProjects/CasicSmartWell/app/CasicSmartWell.jks') +// storePassword '123456789' +// keyAlias 'key0' +// keyPassword '123456789' +// } +// } + compileSdkVersion 31 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.smart.town.sanxi" + minSdkVersion 23 + targetSdkVersion 31 + versionCode 1 + versionName "1.0.0" + + manifestPlaceholders = [GETUI_APPID: "A9V4DvwLcdAqkFCQuFyhq6"] + } + + buildTypes { + release { + minifyEnabled false +// signingConfig signingConfigs.release + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + + ndk { abiFilters "armeabi", "armeabi-v7a", "arm64-v8" } + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlin { + experimental { + coroutines 'enable' + } + } + + greendao { + schemaVersion 1//数据库版本号 + targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 + daoPackage 'com.casic.smart.town.sanxi.greendao'//设置DaoMaster、DaoSession、Dao包名 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + //基础依赖库 + implementation files('libs/lite-release.aar') + implementation 'androidx.appcompat:appcompat:1.4.2' + implementation 'androidx.core:core-ktx:1.8.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:3.0.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' + //MVVM+LiveData + implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.1" + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0" + implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + //Kotlin协程 + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1' + //图片加载框架 + implementation 'com.github.bumptech.glide:glide:4.9.0' + //返回值转换器 + implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' + implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + //okhttp3日志拦截器 + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //网络请求和接口封装 + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.9.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.9.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' + //高德地图 + implementation 'com.amap.api:3dmap:latest.integration' + //推送SDK + implementation 'com.getui:gtsdk:3.2.10.0' //个推SDK + implementation 'com.getui:gtc:3.1.9.0' //个推核心组件 + //数据库框架 + implementation 'org.greenrobot:greendao:3.3.0' + //桌面角标 + implementation "me.leolin:ShortcutBadger:1.1.22@aar" +} \ No newline at end of file diff --git a/app/libs/lite-release.aar b/app/libs/lite-release.aar new file mode 100644 index 0000000..45da4df --- /dev/null +++ b/app/libs/lite-release.aar Binary files differ diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..10cfdbf --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*.iml +.gradle +/local.properties +/.idea +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..a4cd2ca --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,101 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'org.greenrobot.greendao' + +android { +// signingConfigs { +// release { +// storeFile file('/Users/a203/Desktop/AndroidProjects/CasicSmartWell/app/CasicSmartWell.jks') +// storePassword '123456789' +// keyAlias 'key0' +// keyPassword '123456789' +// } +// } + compileSdkVersion 31 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.smart.town.sanxi" + minSdkVersion 23 + targetSdkVersion 31 + versionCode 1 + versionName "1.0.0" + + manifestPlaceholders = [GETUI_APPID: "A9V4DvwLcdAqkFCQuFyhq6"] + } + + buildTypes { + release { + minifyEnabled false +// signingConfig signingConfigs.release + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + + ndk { abiFilters "armeabi", "armeabi-v7a", "arm64-v8" } + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlin { + experimental { + coroutines 'enable' + } + } + + greendao { + schemaVersion 1//数据库版本号 + targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 + daoPackage 'com.casic.smart.town.sanxi.greendao'//设置DaoMaster、DaoSession、Dao包名 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + //基础依赖库 + implementation files('libs/lite-release.aar') + implementation 'androidx.appcompat:appcompat:1.4.2' + implementation 'androidx.core:core-ktx:1.8.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:3.0.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' + //MVVM+LiveData + implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.1" + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0" + implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + //Kotlin协程 + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1' + //图片加载框架 + implementation 'com.github.bumptech.glide:glide:4.9.0' + //返回值转换器 + implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' + implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + //okhttp3日志拦截器 + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //网络请求和接口封装 + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.9.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.9.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' + //高德地图 + implementation 'com.amap.api:3dmap:latest.integration' + //推送SDK + implementation 'com.getui:gtsdk:3.2.10.0' //个推SDK + implementation 'com.getui:gtc:3.1.9.0' //个推核心组件 + //数据库框架 + implementation 'org.greenrobot:greendao:3.3.0' + //桌面角标 + implementation "me.leolin:ShortcutBadger:1.1.22@aar" +} \ No newline at end of file diff --git a/app/libs/lite-release.aar b/app/libs/lite-release.aar new file mode 100644 index 0000000..45da4df --- /dev/null +++ b/app/libs/lite-release.aar Binary files differ diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /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 \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..10cfdbf --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*.iml +.gradle +/local.properties +/.idea +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..a4cd2ca --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,101 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'org.greenrobot.greendao' + +android { +// signingConfigs { +// release { +// storeFile file('/Users/a203/Desktop/AndroidProjects/CasicSmartWell/app/CasicSmartWell.jks') +// storePassword '123456789' +// keyAlias 'key0' +// keyPassword '123456789' +// } +// } + compileSdkVersion 31 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.smart.town.sanxi" + minSdkVersion 23 + targetSdkVersion 31 + versionCode 1 + versionName "1.0.0" + + manifestPlaceholders = [GETUI_APPID: "A9V4DvwLcdAqkFCQuFyhq6"] + } + + buildTypes { + release { + minifyEnabled false +// signingConfig signingConfigs.release + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + + ndk { abiFilters "armeabi", "armeabi-v7a", "arm64-v8" } + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlin { + experimental { + coroutines 'enable' + } + } + + greendao { + schemaVersion 1//数据库版本号 + targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 + daoPackage 'com.casic.smart.town.sanxi.greendao'//设置DaoMaster、DaoSession、Dao包名 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + //基础依赖库 + implementation files('libs/lite-release.aar') + implementation 'androidx.appcompat:appcompat:1.4.2' + implementation 'androidx.core:core-ktx:1.8.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:3.0.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' + //MVVM+LiveData + implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.1" + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0" + implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + //Kotlin协程 + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1' + //图片加载框架 + implementation 'com.github.bumptech.glide:glide:4.9.0' + //返回值转换器 + implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' + implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + //okhttp3日志拦截器 + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //网络请求和接口封装 + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.9.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.9.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' + //高德地图 + implementation 'com.amap.api:3dmap:latest.integration' + //推送SDK + implementation 'com.getui:gtsdk:3.2.10.0' //个推SDK + implementation 'com.getui:gtc:3.1.9.0' //个推核心组件 + //数据库框架 + implementation 'org.greenrobot:greendao:3.3.0' + //桌面角标 + implementation "me.leolin:ShortcutBadger:1.1.22@aar" +} \ No newline at end of file diff --git a/app/libs/lite-release.aar b/app/libs/lite-release.aar new file mode 100644 index 0000000..45da4df --- /dev/null +++ b/app/libs/lite-release.aar Binary files differ diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /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 \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..a83c28a --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..10cfdbf --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*.iml +.gradle +/local.properties +/.idea +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..a4cd2ca --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,101 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'org.greenrobot.greendao' + +android { +// signingConfigs { +// release { +// storeFile file('/Users/a203/Desktop/AndroidProjects/CasicSmartWell/app/CasicSmartWell.jks') +// storePassword '123456789' +// keyAlias 'key0' +// keyPassword '123456789' +// } +// } + compileSdkVersion 31 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.smart.town.sanxi" + minSdkVersion 23 + targetSdkVersion 31 + versionCode 1 + versionName "1.0.0" + + manifestPlaceholders = [GETUI_APPID: "A9V4DvwLcdAqkFCQuFyhq6"] + } + + buildTypes { + release { + minifyEnabled false +// signingConfig signingConfigs.release + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + + ndk { abiFilters "armeabi", "armeabi-v7a", "arm64-v8" } + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlin { + experimental { + coroutines 'enable' + } + } + + greendao { + schemaVersion 1//数据库版本号 + targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 + daoPackage 'com.casic.smart.town.sanxi.greendao'//设置DaoMaster、DaoSession、Dao包名 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + //基础依赖库 + implementation files('libs/lite-release.aar') + implementation 'androidx.appcompat:appcompat:1.4.2' + implementation 'androidx.core:core-ktx:1.8.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:3.0.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' + //MVVM+LiveData + implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.1" + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0" + implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + //Kotlin协程 + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1' + //图片加载框架 + implementation 'com.github.bumptech.glide:glide:4.9.0' + //返回值转换器 + implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' + implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + //okhttp3日志拦截器 + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //网络请求和接口封装 + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.9.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.9.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' + //高德地图 + implementation 'com.amap.api:3dmap:latest.integration' + //推送SDK + implementation 'com.getui:gtsdk:3.2.10.0' //个推SDK + implementation 'com.getui:gtc:3.1.9.0' //个推核心组件 + //数据库框架 + implementation 'org.greenrobot:greendao:3.3.0' + //桌面角标 + implementation "me.leolin:ShortcutBadger:1.1.22@aar" +} \ No newline at end of file diff --git a/app/libs/lite-release.aar b/app/libs/lite-release.aar new file mode 100644 index 0000000..45da4df --- /dev/null +++ b/app/libs/lite-release.aar Binary files differ diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /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 \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..a83c28a --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/svg/monitor.svg b/app/src/main/assets/svg/monitor.svg new file mode 100644 index 0000000..c8d3e25 --- /dev/null +++ b/app/src/main/assets/svg/monitor.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..10cfdbf --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*.iml +.gradle +/local.properties +/.idea +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..a4cd2ca --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,101 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'org.greenrobot.greendao' + +android { +// signingConfigs { +// release { +// storeFile file('/Users/a203/Desktop/AndroidProjects/CasicSmartWell/app/CasicSmartWell.jks') +// storePassword '123456789' +// keyAlias 'key0' +// keyPassword '123456789' +// } +// } + compileSdkVersion 31 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.smart.town.sanxi" + minSdkVersion 23 + targetSdkVersion 31 + versionCode 1 + versionName "1.0.0" + + manifestPlaceholders = [GETUI_APPID: "A9V4DvwLcdAqkFCQuFyhq6"] + } + + buildTypes { + release { + minifyEnabled false +// signingConfig signingConfigs.release + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + + ndk { abiFilters "armeabi", "armeabi-v7a", "arm64-v8" } + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlin { + experimental { + coroutines 'enable' + } + } + + greendao { + schemaVersion 1//数据库版本号 + targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 + daoPackage 'com.casic.smart.town.sanxi.greendao'//设置DaoMaster、DaoSession、Dao包名 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + //基础依赖库 + implementation files('libs/lite-release.aar') + implementation 'androidx.appcompat:appcompat:1.4.2' + implementation 'androidx.core:core-ktx:1.8.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:3.0.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' + //MVVM+LiveData + implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.1" + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0" + implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + //Kotlin协程 + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1' + //图片加载框架 + implementation 'com.github.bumptech.glide:glide:4.9.0' + //返回值转换器 + implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' + implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + //okhttp3日志拦截器 + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //网络请求和接口封装 + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.9.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.9.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' + //高德地图 + implementation 'com.amap.api:3dmap:latest.integration' + //推送SDK + implementation 'com.getui:gtsdk:3.2.10.0' //个推SDK + implementation 'com.getui:gtc:3.1.9.0' //个推核心组件 + //数据库框架 + implementation 'org.greenrobot:greendao:3.3.0' + //桌面角标 + implementation "me.leolin:ShortcutBadger:1.1.22@aar" +} \ No newline at end of file diff --git a/app/libs/lite-release.aar b/app/libs/lite-release.aar new file mode 100644 index 0000000..45da4df --- /dev/null +++ b/app/libs/lite-release.aar Binary files differ diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /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 \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..a83c28a --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/svg/monitor.svg b/app/src/main/assets/svg/monitor.svg new file mode 100644 index 0000000..c8d3e25 --- /dev/null +++ b/app/src/main/assets/svg/monitor.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/msg.svg b/app/src/main/assets/svg/msg.svg new file mode 100644 index 0000000..e864e48 --- /dev/null +++ b/app/src/main/assets/svg/msg.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..10cfdbf --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*.iml +.gradle +/local.properties +/.idea +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..a4cd2ca --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,101 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'org.greenrobot.greendao' + +android { +// signingConfigs { +// release { +// storeFile file('/Users/a203/Desktop/AndroidProjects/CasicSmartWell/app/CasicSmartWell.jks') +// storePassword '123456789' +// keyAlias 'key0' +// keyPassword '123456789' +// } +// } + compileSdkVersion 31 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.smart.town.sanxi" + minSdkVersion 23 + targetSdkVersion 31 + versionCode 1 + versionName "1.0.0" + + manifestPlaceholders = [GETUI_APPID: "A9V4DvwLcdAqkFCQuFyhq6"] + } + + buildTypes { + release { + minifyEnabled false +// signingConfig signingConfigs.release + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + + ndk { abiFilters "armeabi", "armeabi-v7a", "arm64-v8" } + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlin { + experimental { + coroutines 'enable' + } + } + + greendao { + schemaVersion 1//数据库版本号 + targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 + daoPackage 'com.casic.smart.town.sanxi.greendao'//设置DaoMaster、DaoSession、Dao包名 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + //基础依赖库 + implementation files('libs/lite-release.aar') + implementation 'androidx.appcompat:appcompat:1.4.2' + implementation 'androidx.core:core-ktx:1.8.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:3.0.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' + //MVVM+LiveData + implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.1" + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0" + implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + //Kotlin协程 + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1' + //图片加载框架 + implementation 'com.github.bumptech.glide:glide:4.9.0' + //返回值转换器 + implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' + implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + //okhttp3日志拦截器 + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //网络请求和接口封装 + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.9.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.9.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' + //高德地图 + implementation 'com.amap.api:3dmap:latest.integration' + //推送SDK + implementation 'com.getui:gtsdk:3.2.10.0' //个推SDK + implementation 'com.getui:gtc:3.1.9.0' //个推核心组件 + //数据库框架 + implementation 'org.greenrobot:greendao:3.3.0' + //桌面角标 + implementation "me.leolin:ShortcutBadger:1.1.22@aar" +} \ No newline at end of file diff --git a/app/libs/lite-release.aar b/app/libs/lite-release.aar new file mode 100644 index 0000000..45da4df --- /dev/null +++ b/app/libs/lite-release.aar Binary files differ diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /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 \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..a83c28a --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/svg/monitor.svg b/app/src/main/assets/svg/monitor.svg new file mode 100644 index 0000000..c8d3e25 --- /dev/null +++ b/app/src/main/assets/svg/monitor.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/msg.svg b/app/src/main/assets/svg/msg.svg new file mode 100644 index 0000000..e864e48 --- /dev/null +++ b/app/src/main/assets/svg/msg.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/statistics.svg b/app/src/main/assets/svg/statistics.svg new file mode 100644 index 0000000..974000e --- /dev/null +++ b/app/src/main/assets/svg/statistics.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..10cfdbf --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*.iml +.gradle +/local.properties +/.idea +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..a4cd2ca --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,101 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'org.greenrobot.greendao' + +android { +// signingConfigs { +// release { +// storeFile file('/Users/a203/Desktop/AndroidProjects/CasicSmartWell/app/CasicSmartWell.jks') +// storePassword '123456789' +// keyAlias 'key0' +// keyPassword '123456789' +// } +// } + compileSdkVersion 31 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.smart.town.sanxi" + minSdkVersion 23 + targetSdkVersion 31 + versionCode 1 + versionName "1.0.0" + + manifestPlaceholders = [GETUI_APPID: "A9V4DvwLcdAqkFCQuFyhq6"] + } + + buildTypes { + release { + minifyEnabled false +// signingConfig signingConfigs.release + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + + ndk { abiFilters "armeabi", "armeabi-v7a", "arm64-v8" } + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlin { + experimental { + coroutines 'enable' + } + } + + greendao { + schemaVersion 1//数据库版本号 + targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 + daoPackage 'com.casic.smart.town.sanxi.greendao'//设置DaoMaster、DaoSession、Dao包名 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + //基础依赖库 + implementation files('libs/lite-release.aar') + implementation 'androidx.appcompat:appcompat:1.4.2' + implementation 'androidx.core:core-ktx:1.8.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:3.0.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' + //MVVM+LiveData + implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.1" + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0" + implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + //Kotlin协程 + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1' + //图片加载框架 + implementation 'com.github.bumptech.glide:glide:4.9.0' + //返回值转换器 + implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' + implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + //okhttp3日志拦截器 + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //网络请求和接口封装 + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.9.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.9.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' + //高德地图 + implementation 'com.amap.api:3dmap:latest.integration' + //推送SDK + implementation 'com.getui:gtsdk:3.2.10.0' //个推SDK + implementation 'com.getui:gtc:3.1.9.0' //个推核心组件 + //数据库框架 + implementation 'org.greenrobot:greendao:3.3.0' + //桌面角标 + implementation "me.leolin:ShortcutBadger:1.1.22@aar" +} \ No newline at end of file diff --git a/app/libs/lite-release.aar b/app/libs/lite-release.aar new file mode 100644 index 0000000..45da4df --- /dev/null +++ b/app/libs/lite-release.aar Binary files differ diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /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 \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..a83c28a --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/svg/monitor.svg b/app/src/main/assets/svg/monitor.svg new file mode 100644 index 0000000..c8d3e25 --- /dev/null +++ b/app/src/main/assets/svg/monitor.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/msg.svg b/app/src/main/assets/svg/msg.svg new file mode 100644 index 0000000..e864e48 --- /dev/null +++ b/app/src/main/assets/svg/msg.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/statistics.svg b/app/src/main/assets/svg/statistics.svg new file mode 100644 index 0000000..974000e --- /dev/null +++ b/app/src/main/assets/svg/statistics.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt new file mode 100644 index 0000000..6b9cce0 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.adapter + +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentManager +import androidx.fragment.app.FragmentPagerAdapter + +class ViewPagerAdapter(list: ArrayList, manager: FragmentManager) : + FragmentPagerAdapter(manager) { + + private var pageList: List = list + + override fun getItem(position: Int) = pageList[position] + + override fun getCount() = pageList.size +} \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..10cfdbf --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*.iml +.gradle +/local.properties +/.idea +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..a4cd2ca --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,101 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'org.greenrobot.greendao' + +android { +// signingConfigs { +// release { +// storeFile file('/Users/a203/Desktop/AndroidProjects/CasicSmartWell/app/CasicSmartWell.jks') +// storePassword '123456789' +// keyAlias 'key0' +// keyPassword '123456789' +// } +// } + compileSdkVersion 31 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.smart.town.sanxi" + minSdkVersion 23 + targetSdkVersion 31 + versionCode 1 + versionName "1.0.0" + + manifestPlaceholders = [GETUI_APPID: "A9V4DvwLcdAqkFCQuFyhq6"] + } + + buildTypes { + release { + minifyEnabled false +// signingConfig signingConfigs.release + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + + ndk { abiFilters "armeabi", "armeabi-v7a", "arm64-v8" } + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlin { + experimental { + coroutines 'enable' + } + } + + greendao { + schemaVersion 1//数据库版本号 + targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 + daoPackage 'com.casic.smart.town.sanxi.greendao'//设置DaoMaster、DaoSession、Dao包名 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + //基础依赖库 + implementation files('libs/lite-release.aar') + implementation 'androidx.appcompat:appcompat:1.4.2' + implementation 'androidx.core:core-ktx:1.8.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:3.0.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' + //MVVM+LiveData + implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.1" + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0" + implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + //Kotlin协程 + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1' + //图片加载框架 + implementation 'com.github.bumptech.glide:glide:4.9.0' + //返回值转换器 + implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' + implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + //okhttp3日志拦截器 + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //网络请求和接口封装 + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.9.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.9.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' + //高德地图 + implementation 'com.amap.api:3dmap:latest.integration' + //推送SDK + implementation 'com.getui:gtsdk:3.2.10.0' //个推SDK + implementation 'com.getui:gtc:3.1.9.0' //个推核心组件 + //数据库框架 + implementation 'org.greenrobot:greendao:3.3.0' + //桌面角标 + implementation "me.leolin:ShortcutBadger:1.1.22@aar" +} \ No newline at end of file diff --git a/app/libs/lite-release.aar b/app/libs/lite-release.aar new file mode 100644 index 0000000..45da4df --- /dev/null +++ b/app/libs/lite-release.aar Binary files differ diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /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 \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..a83c28a --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/svg/monitor.svg b/app/src/main/assets/svg/monitor.svg new file mode 100644 index 0000000..c8d3e25 --- /dev/null +++ b/app/src/main/assets/svg/monitor.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/msg.svg b/app/src/main/assets/svg/msg.svg new file mode 100644 index 0000000..e864e48 --- /dev/null +++ b/app/src/main/assets/svg/msg.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/statistics.svg b/app/src/main/assets/svg/statistics.svg new file mode 100644 index 0000000..974000e --- /dev/null +++ b/app/src/main/assets/svg/statistics.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt new file mode 100644 index 0000000..6b9cce0 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.adapter + +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentManager +import androidx.fragment.app.FragmentPagerAdapter + +class ViewPagerAdapter(list: ArrayList, manager: FragmentManager) : + FragmentPagerAdapter(manager) { + + private var pageList: List = list + + override fun getItem(position: Int) = pageList[position] + + override fun getCount() = pageList.size +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt new file mode 100644 index 0000000..4e017b1 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt @@ -0,0 +1,40 @@ +package com.casic.smart.town.sanxi.base + +import android.app.Application +import android.util.Log +import com.casic.smart.town.sanxi.greendao.DaoMaster +import com.casic.smart.town.sanxi.greendao.DaoSession +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + private val kTag = "BaseApplication" + + companion object { + private var instance: BaseApplication by Delegates.notNull() + + fun obtainInstance() = instance + + private lateinit var daoSession: DaoSession + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences(this) + //推送 + PushManager.getInstance().initialize(this) + PushManager.getInstance().setDebugLogger(this) { + Log.d(kTag, it) + } + val devOpenHelper = DaoMaster.DevOpenHelper(this, "SmartTown.db", null) + val daoMaster = DaoMaster(devOpenHelper.writableDatabase) + daoSession = daoMaster.newSession() + } + + fun obtainDaoSession(): DaoSession { + return daoSession + } +} \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..10cfdbf --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*.iml +.gradle +/local.properties +/.idea +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..a4cd2ca --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,101 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'org.greenrobot.greendao' + +android { +// signingConfigs { +// release { +// storeFile file('/Users/a203/Desktop/AndroidProjects/CasicSmartWell/app/CasicSmartWell.jks') +// storePassword '123456789' +// keyAlias 'key0' +// keyPassword '123456789' +// } +// } + compileSdkVersion 31 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.smart.town.sanxi" + minSdkVersion 23 + targetSdkVersion 31 + versionCode 1 + versionName "1.0.0" + + manifestPlaceholders = [GETUI_APPID: "A9V4DvwLcdAqkFCQuFyhq6"] + } + + buildTypes { + release { + minifyEnabled false +// signingConfig signingConfigs.release + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + + ndk { abiFilters "armeabi", "armeabi-v7a", "arm64-v8" } + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlin { + experimental { + coroutines 'enable' + } + } + + greendao { + schemaVersion 1//数据库版本号 + targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 + daoPackage 'com.casic.smart.town.sanxi.greendao'//设置DaoMaster、DaoSession、Dao包名 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + //基础依赖库 + implementation files('libs/lite-release.aar') + implementation 'androidx.appcompat:appcompat:1.4.2' + implementation 'androidx.core:core-ktx:1.8.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:3.0.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' + //MVVM+LiveData + implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.1" + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0" + implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + //Kotlin协程 + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1' + //图片加载框架 + implementation 'com.github.bumptech.glide:glide:4.9.0' + //返回值转换器 + implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' + implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + //okhttp3日志拦截器 + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //网络请求和接口封装 + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.9.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.9.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' + //高德地图 + implementation 'com.amap.api:3dmap:latest.integration' + //推送SDK + implementation 'com.getui:gtsdk:3.2.10.0' //个推SDK + implementation 'com.getui:gtc:3.1.9.0' //个推核心组件 + //数据库框架 + implementation 'org.greenrobot:greendao:3.3.0' + //桌面角标 + implementation "me.leolin:ShortcutBadger:1.1.22@aar" +} \ No newline at end of file diff --git a/app/libs/lite-release.aar b/app/libs/lite-release.aar new file mode 100644 index 0000000..45da4df --- /dev/null +++ b/app/libs/lite-release.aar Binary files differ diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /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 \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..a83c28a --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/svg/monitor.svg b/app/src/main/assets/svg/monitor.svg new file mode 100644 index 0000000..c8d3e25 --- /dev/null +++ b/app/src/main/assets/svg/monitor.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/msg.svg b/app/src/main/assets/svg/msg.svg new file mode 100644 index 0000000..e864e48 --- /dev/null +++ b/app/src/main/assets/svg/msg.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/statistics.svg b/app/src/main/assets/svg/statistics.svg new file mode 100644 index 0000000..974000e --- /dev/null +++ b/app/src/main/assets/svg/statistics.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt new file mode 100644 index 0000000..6b9cce0 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.adapter + +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentManager +import androidx.fragment.app.FragmentPagerAdapter + +class ViewPagerAdapter(list: ArrayList, manager: FragmentManager) : + FragmentPagerAdapter(manager) { + + private var pageList: List = list + + override fun getItem(position: Int) = pageList[position] + + override fun getCount() = pageList.size +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt new file mode 100644 index 0000000..4e017b1 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt @@ -0,0 +1,40 @@ +package com.casic.smart.town.sanxi.base + +import android.app.Application +import android.util.Log +import com.casic.smart.town.sanxi.greendao.DaoMaster +import com.casic.smart.town.sanxi.greendao.DaoSession +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + private val kTag = "BaseApplication" + + companion object { + private var instance: BaseApplication by Delegates.notNull() + + fun obtainInstance() = instance + + private lateinit var daoSession: DaoSession + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences(this) + //推送 + PushManager.getInstance().initialize(this) + PushManager.getInstance().setDebugLogger(this) { + Log.d(kTag, it) + } + val devOpenHelper = DaoMaster.DevOpenHelper(this, "SmartTown.db", null) + val daoMaster = DaoMaster(devOpenHelper.writableDatabase) + daoSession = daoMaster.newSession() + } + + fun obtainDaoSession(): DaoSession { + return daoSession + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java new file mode 100644 index 0000000..b8f67dc --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java @@ -0,0 +1,133 @@ +package com.casic.smart.town.sanxi.bean; + +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Generated; +import org.greenrobot.greendao.annotation.Id; +import org.greenrobot.greendao.annotation.Unique; + +@Entity +public class AlarmMessageLocaleBean { + @Id(autoincrement = true) + private Long id;//主键自增 + + @Unique + private String messageId; + private String appId; + private String clientId; + private String taskId; + private String userId; + private String title; + private String content; + private String deviceCode; + private String isRead;//0-未读,1-已读 + private String alarmTime; + + @Generated(hash = 566950134) + public AlarmMessageLocaleBean(Long id, String messageId, String appId, + String clientId, String taskId, String userId, String title, + String content, String deviceCode, String isRead, String alarmTime) { + this.id = id; + this.messageId = messageId; + this.appId = appId; + this.clientId = clientId; + this.taskId = taskId; + this.userId = userId; + this.title = title; + this.content = content; + this.deviceCode = deviceCode; + this.isRead = isRead; + this.alarmTime = alarmTime; + } + + @Generated(hash = 1737519562) + public AlarmMessageLocaleBean() { + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getMessageId() { + return this.messageId; + } + + public void setMessageId(String messageId) { + this.messageId = messageId; + } + + public String getAppId() { + return this.appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public String getClientId() { + return this.clientId; + } + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public String getTaskId() { + return this.taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getUserId() { + return this.userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getTitle() { + return this.title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return this.content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getDeviceCode() { + return this.deviceCode; + } + + public void setDeviceCode(String deviceCode) { + this.deviceCode = deviceCode; + } + + public String getIsRead() { + return this.isRead; + } + + public void setIsRead(String isRead) { + this.isRead = isRead; + } + + public String getAlarmTime() { + return this.alarmTime; + } + + public void setAlarmTime(String alarmTime) { + this.alarmTime = alarmTime; + } +} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..10cfdbf --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*.iml +.gradle +/local.properties +/.idea +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..a4cd2ca --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,101 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'org.greenrobot.greendao' + +android { +// signingConfigs { +// release { +// storeFile file('/Users/a203/Desktop/AndroidProjects/CasicSmartWell/app/CasicSmartWell.jks') +// storePassword '123456789' +// keyAlias 'key0' +// keyPassword '123456789' +// } +// } + compileSdkVersion 31 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.smart.town.sanxi" + minSdkVersion 23 + targetSdkVersion 31 + versionCode 1 + versionName "1.0.0" + + manifestPlaceholders = [GETUI_APPID: "A9V4DvwLcdAqkFCQuFyhq6"] + } + + buildTypes { + release { + minifyEnabled false +// signingConfig signingConfigs.release + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + + ndk { abiFilters "armeabi", "armeabi-v7a", "arm64-v8" } + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlin { + experimental { + coroutines 'enable' + } + } + + greendao { + schemaVersion 1//数据库版本号 + targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 + daoPackage 'com.casic.smart.town.sanxi.greendao'//设置DaoMaster、DaoSession、Dao包名 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + //基础依赖库 + implementation files('libs/lite-release.aar') + implementation 'androidx.appcompat:appcompat:1.4.2' + implementation 'androidx.core:core-ktx:1.8.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:3.0.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' + //MVVM+LiveData + implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.1" + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0" + implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + //Kotlin协程 + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1' + //图片加载框架 + implementation 'com.github.bumptech.glide:glide:4.9.0' + //返回值转换器 + implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' + implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + //okhttp3日志拦截器 + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //网络请求和接口封装 + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.9.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.9.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' + //高德地图 + implementation 'com.amap.api:3dmap:latest.integration' + //推送SDK + implementation 'com.getui:gtsdk:3.2.10.0' //个推SDK + implementation 'com.getui:gtc:3.1.9.0' //个推核心组件 + //数据库框架 + implementation 'org.greenrobot:greendao:3.3.0' + //桌面角标 + implementation "me.leolin:ShortcutBadger:1.1.22@aar" +} \ No newline at end of file diff --git a/app/libs/lite-release.aar b/app/libs/lite-release.aar new file mode 100644 index 0000000..45da4df --- /dev/null +++ b/app/libs/lite-release.aar Binary files differ diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /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 \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..a83c28a --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/svg/monitor.svg b/app/src/main/assets/svg/monitor.svg new file mode 100644 index 0000000..c8d3e25 --- /dev/null +++ b/app/src/main/assets/svg/monitor.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/msg.svg b/app/src/main/assets/svg/msg.svg new file mode 100644 index 0000000..e864e48 --- /dev/null +++ b/app/src/main/assets/svg/msg.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/statistics.svg b/app/src/main/assets/svg/statistics.svg new file mode 100644 index 0000000..974000e --- /dev/null +++ b/app/src/main/assets/svg/statistics.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt new file mode 100644 index 0000000..6b9cce0 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.adapter + +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentManager +import androidx.fragment.app.FragmentPagerAdapter + +class ViewPagerAdapter(list: ArrayList, manager: FragmentManager) : + FragmentPagerAdapter(manager) { + + private var pageList: List = list + + override fun getItem(position: Int) = pageList[position] + + override fun getCount() = pageList.size +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt new file mode 100644 index 0000000..4e017b1 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt @@ -0,0 +1,40 @@ +package com.casic.smart.town.sanxi.base + +import android.app.Application +import android.util.Log +import com.casic.smart.town.sanxi.greendao.DaoMaster +import com.casic.smart.town.sanxi.greendao.DaoSession +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + private val kTag = "BaseApplication" + + companion object { + private var instance: BaseApplication by Delegates.notNull() + + fun obtainInstance() = instance + + private lateinit var daoSession: DaoSession + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences(this) + //推送 + PushManager.getInstance().initialize(this) + PushManager.getInstance().setDebugLogger(this) { + Log.d(kTag, it) + } + val devOpenHelper = DaoMaster.DevOpenHelper(this, "SmartTown.db", null) + val daoMaster = DaoMaster(devOpenHelper.writableDatabase) + daoSession = daoMaster.newSession() + } + + fun obtainDaoSession(): DaoSession { + return daoSession + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java new file mode 100644 index 0000000..b8f67dc --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java @@ -0,0 +1,133 @@ +package com.casic.smart.town.sanxi.bean; + +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Generated; +import org.greenrobot.greendao.annotation.Id; +import org.greenrobot.greendao.annotation.Unique; + +@Entity +public class AlarmMessageLocaleBean { + @Id(autoincrement = true) + private Long id;//主键自增 + + @Unique + private String messageId; + private String appId; + private String clientId; + private String taskId; + private String userId; + private String title; + private String content; + private String deviceCode; + private String isRead;//0-未读,1-已读 + private String alarmTime; + + @Generated(hash = 566950134) + public AlarmMessageLocaleBean(Long id, String messageId, String appId, + String clientId, String taskId, String userId, String title, + String content, String deviceCode, String isRead, String alarmTime) { + this.id = id; + this.messageId = messageId; + this.appId = appId; + this.clientId = clientId; + this.taskId = taskId; + this.userId = userId; + this.title = title; + this.content = content; + this.deviceCode = deviceCode; + this.isRead = isRead; + this.alarmTime = alarmTime; + } + + @Generated(hash = 1737519562) + public AlarmMessageLocaleBean() { + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getMessageId() { + return this.messageId; + } + + public void setMessageId(String messageId) { + this.messageId = messageId; + } + + public String getAppId() { + return this.appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public String getClientId() { + return this.clientId; + } + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public String getTaskId() { + return this.taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getUserId() { + return this.userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getTitle() { + return this.title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return this.content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getDeviceCode() { + return this.deviceCode; + } + + public void setDeviceCode(String deviceCode) { + this.deviceCode = deviceCode; + } + + public String getIsRead() { + return this.isRead; + } + + public void setIsRead(String isRead) { + this.isRead = isRead; + } + + public String getAlarmTime() { + return this.alarmTime; + } + + public void setAlarmTime(String alarmTime) { + this.alarmTime = alarmTime; + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt new file mode 100644 index 0000000..650e201 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class AlarmPageFragment: KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_alarm + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..10cfdbf --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*.iml +.gradle +/local.properties +/.idea +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..a4cd2ca --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,101 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'org.greenrobot.greendao' + +android { +// signingConfigs { +// release { +// storeFile file('/Users/a203/Desktop/AndroidProjects/CasicSmartWell/app/CasicSmartWell.jks') +// storePassword '123456789' +// keyAlias 'key0' +// keyPassword '123456789' +// } +// } + compileSdkVersion 31 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.smart.town.sanxi" + minSdkVersion 23 + targetSdkVersion 31 + versionCode 1 + versionName "1.0.0" + + manifestPlaceholders = [GETUI_APPID: "A9V4DvwLcdAqkFCQuFyhq6"] + } + + buildTypes { + release { + minifyEnabled false +// signingConfig signingConfigs.release + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + + ndk { abiFilters "armeabi", "armeabi-v7a", "arm64-v8" } + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlin { + experimental { + coroutines 'enable' + } + } + + greendao { + schemaVersion 1//数据库版本号 + targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 + daoPackage 'com.casic.smart.town.sanxi.greendao'//设置DaoMaster、DaoSession、Dao包名 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + //基础依赖库 + implementation files('libs/lite-release.aar') + implementation 'androidx.appcompat:appcompat:1.4.2' + implementation 'androidx.core:core-ktx:1.8.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:3.0.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' + //MVVM+LiveData + implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.1" + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0" + implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + //Kotlin协程 + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1' + //图片加载框架 + implementation 'com.github.bumptech.glide:glide:4.9.0' + //返回值转换器 + implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' + implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + //okhttp3日志拦截器 + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //网络请求和接口封装 + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.9.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.9.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' + //高德地图 + implementation 'com.amap.api:3dmap:latest.integration' + //推送SDK + implementation 'com.getui:gtsdk:3.2.10.0' //个推SDK + implementation 'com.getui:gtc:3.1.9.0' //个推核心组件 + //数据库框架 + implementation 'org.greenrobot:greendao:3.3.0' + //桌面角标 + implementation "me.leolin:ShortcutBadger:1.1.22@aar" +} \ No newline at end of file diff --git a/app/libs/lite-release.aar b/app/libs/lite-release.aar new file mode 100644 index 0000000..45da4df --- /dev/null +++ b/app/libs/lite-release.aar Binary files differ diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /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 \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..a83c28a --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/svg/monitor.svg b/app/src/main/assets/svg/monitor.svg new file mode 100644 index 0000000..c8d3e25 --- /dev/null +++ b/app/src/main/assets/svg/monitor.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/msg.svg b/app/src/main/assets/svg/msg.svg new file mode 100644 index 0000000..e864e48 --- /dev/null +++ b/app/src/main/assets/svg/msg.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/statistics.svg b/app/src/main/assets/svg/statistics.svg new file mode 100644 index 0000000..974000e --- /dev/null +++ b/app/src/main/assets/svg/statistics.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt new file mode 100644 index 0000000..6b9cce0 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.adapter + +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentManager +import androidx.fragment.app.FragmentPagerAdapter + +class ViewPagerAdapter(list: ArrayList, manager: FragmentManager) : + FragmentPagerAdapter(manager) { + + private var pageList: List = list + + override fun getItem(position: Int) = pageList[position] + + override fun getCount() = pageList.size +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt new file mode 100644 index 0000000..4e017b1 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt @@ -0,0 +1,40 @@ +package com.casic.smart.town.sanxi.base + +import android.app.Application +import android.util.Log +import com.casic.smart.town.sanxi.greendao.DaoMaster +import com.casic.smart.town.sanxi.greendao.DaoSession +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + private val kTag = "BaseApplication" + + companion object { + private var instance: BaseApplication by Delegates.notNull() + + fun obtainInstance() = instance + + private lateinit var daoSession: DaoSession + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences(this) + //推送 + PushManager.getInstance().initialize(this) + PushManager.getInstance().setDebugLogger(this) { + Log.d(kTag, it) + } + val devOpenHelper = DaoMaster.DevOpenHelper(this, "SmartTown.db", null) + val daoMaster = DaoMaster(devOpenHelper.writableDatabase) + daoSession = daoMaster.newSession() + } + + fun obtainDaoSession(): DaoSession { + return daoSession + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java new file mode 100644 index 0000000..b8f67dc --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java @@ -0,0 +1,133 @@ +package com.casic.smart.town.sanxi.bean; + +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Generated; +import org.greenrobot.greendao.annotation.Id; +import org.greenrobot.greendao.annotation.Unique; + +@Entity +public class AlarmMessageLocaleBean { + @Id(autoincrement = true) + private Long id;//主键自增 + + @Unique + private String messageId; + private String appId; + private String clientId; + private String taskId; + private String userId; + private String title; + private String content; + private String deviceCode; + private String isRead;//0-未读,1-已读 + private String alarmTime; + + @Generated(hash = 566950134) + public AlarmMessageLocaleBean(Long id, String messageId, String appId, + String clientId, String taskId, String userId, String title, + String content, String deviceCode, String isRead, String alarmTime) { + this.id = id; + this.messageId = messageId; + this.appId = appId; + this.clientId = clientId; + this.taskId = taskId; + this.userId = userId; + this.title = title; + this.content = content; + this.deviceCode = deviceCode; + this.isRead = isRead; + this.alarmTime = alarmTime; + } + + @Generated(hash = 1737519562) + public AlarmMessageLocaleBean() { + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getMessageId() { + return this.messageId; + } + + public void setMessageId(String messageId) { + this.messageId = messageId; + } + + public String getAppId() { + return this.appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public String getClientId() { + return this.clientId; + } + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public String getTaskId() { + return this.taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getUserId() { + return this.userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getTitle() { + return this.title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return this.content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getDeviceCode() { + return this.deviceCode; + } + + public void setDeviceCode(String deviceCode) { + this.deviceCode = deviceCode; + } + + public String getIsRead() { + return this.isRead; + } + + public void setIsRead(String isRead) { + this.isRead = isRead; + } + + public String getAlarmTime() { + return this.alarmTime; + } + + public void setAlarmTime(String alarmTime) { + this.alarmTime = alarmTime; + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt new file mode 100644 index 0000000..650e201 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class AlarmPageFragment: KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_alarm + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt new file mode 100644 index 0000000..deac8ac --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt @@ -0,0 +1,76 @@ +package com.casic.smart.town.sanxi.fragment + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.Fragment +import com.amap.api.maps.AMap +import com.amap.api.maps.AMapOptions +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.view.MonitorRecordActivity +import com.pengxh.kt.lite.extensions.navigatePageTo +import com.pengxh.kt.lite.extensions.show +import kotlinx.android.synthetic.main.fragment_monitor.view.* + +class MonitorPageFragment : Fragment() { + + private val kTag = "HomePageFragment" + private lateinit var monitorView: View + private lateinit var aMap: AMap + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? + ): View { + monitorView = inflater.inflate(R.layout.fragment_monitor, container, false) + //地图初始化 + initMap(savedInstanceState) + + monitorView.rightOperateView.setOnClickListener { + requireContext().navigatePageTo() + } + return monitorView + } + + private fun initMap(savedInstanceState: Bundle?) { + monitorView.mapView.onCreate(savedInstanceState) + aMap = monitorView.mapView.map + aMap.mapType = AMap.MAP_TYPE_NORMAL + val uiSettings = aMap.uiSettings + uiSettings.isCompassEnabled = true + uiSettings.zoomPosition = AMapOptions.ZOOM_POSITION_RIGHT_CENTER + uiSettings.isTiltGesturesEnabled = false//不许地图随手势倾斜角度 + + // 地图加载成功监听 +// aMap.addOnMapLoadedListener(this) + // 地图缩放监听 +// aMap.addOnCameraChangeListener(this) + // marker 点击事件监听 +// aMap.addOnMarkerClickListener(this) + // 点击marker弹出自定义popup +// aMap.setInfoWindowAdapter(this) + //信息窗点击事件 +// aMap.addOnInfoWindowClickListener(this) + } + + /***以下是地图生命周期管理************************************************************************/ + override fun onResume() { + super.onResume() + monitorView.mapView.onResume() + } + + override fun onPause() { + super.onPause() + monitorView.mapView.onPause() + } + + override fun onSaveInstanceState(outState: Bundle) { + super.onSaveInstanceState(outState) + monitorView.mapView.onSaveInstanceState(outState) + } + + override fun onDestroy() { + super.onDestroy() + monitorView.mapView.onDestroy() + } +} \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..10cfdbf --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*.iml +.gradle +/local.properties +/.idea +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..a4cd2ca --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,101 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'org.greenrobot.greendao' + +android { +// signingConfigs { +// release { +// storeFile file('/Users/a203/Desktop/AndroidProjects/CasicSmartWell/app/CasicSmartWell.jks') +// storePassword '123456789' +// keyAlias 'key0' +// keyPassword '123456789' +// } +// } + compileSdkVersion 31 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.smart.town.sanxi" + minSdkVersion 23 + targetSdkVersion 31 + versionCode 1 + versionName "1.0.0" + + manifestPlaceholders = [GETUI_APPID: "A9V4DvwLcdAqkFCQuFyhq6"] + } + + buildTypes { + release { + minifyEnabled false +// signingConfig signingConfigs.release + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + + ndk { abiFilters "armeabi", "armeabi-v7a", "arm64-v8" } + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlin { + experimental { + coroutines 'enable' + } + } + + greendao { + schemaVersion 1//数据库版本号 + targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 + daoPackage 'com.casic.smart.town.sanxi.greendao'//设置DaoMaster、DaoSession、Dao包名 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + //基础依赖库 + implementation files('libs/lite-release.aar') + implementation 'androidx.appcompat:appcompat:1.4.2' + implementation 'androidx.core:core-ktx:1.8.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:3.0.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' + //MVVM+LiveData + implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.1" + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0" + implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + //Kotlin协程 + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1' + //图片加载框架 + implementation 'com.github.bumptech.glide:glide:4.9.0' + //返回值转换器 + implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' + implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + //okhttp3日志拦截器 + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //网络请求和接口封装 + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.9.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.9.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' + //高德地图 + implementation 'com.amap.api:3dmap:latest.integration' + //推送SDK + implementation 'com.getui:gtsdk:3.2.10.0' //个推SDK + implementation 'com.getui:gtc:3.1.9.0' //个推核心组件 + //数据库框架 + implementation 'org.greenrobot:greendao:3.3.0' + //桌面角标 + implementation "me.leolin:ShortcutBadger:1.1.22@aar" +} \ No newline at end of file diff --git a/app/libs/lite-release.aar b/app/libs/lite-release.aar new file mode 100644 index 0000000..45da4df --- /dev/null +++ b/app/libs/lite-release.aar Binary files differ diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /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 \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..a83c28a --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/svg/monitor.svg b/app/src/main/assets/svg/monitor.svg new file mode 100644 index 0000000..c8d3e25 --- /dev/null +++ b/app/src/main/assets/svg/monitor.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/msg.svg b/app/src/main/assets/svg/msg.svg new file mode 100644 index 0000000..e864e48 --- /dev/null +++ b/app/src/main/assets/svg/msg.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/statistics.svg b/app/src/main/assets/svg/statistics.svg new file mode 100644 index 0000000..974000e --- /dev/null +++ b/app/src/main/assets/svg/statistics.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt new file mode 100644 index 0000000..6b9cce0 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.adapter + +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentManager +import androidx.fragment.app.FragmentPagerAdapter + +class ViewPagerAdapter(list: ArrayList, manager: FragmentManager) : + FragmentPagerAdapter(manager) { + + private var pageList: List = list + + override fun getItem(position: Int) = pageList[position] + + override fun getCount() = pageList.size +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt new file mode 100644 index 0000000..4e017b1 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt @@ -0,0 +1,40 @@ +package com.casic.smart.town.sanxi.base + +import android.app.Application +import android.util.Log +import com.casic.smart.town.sanxi.greendao.DaoMaster +import com.casic.smart.town.sanxi.greendao.DaoSession +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + private val kTag = "BaseApplication" + + companion object { + private var instance: BaseApplication by Delegates.notNull() + + fun obtainInstance() = instance + + private lateinit var daoSession: DaoSession + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences(this) + //推送 + PushManager.getInstance().initialize(this) + PushManager.getInstance().setDebugLogger(this) { + Log.d(kTag, it) + } + val devOpenHelper = DaoMaster.DevOpenHelper(this, "SmartTown.db", null) + val daoMaster = DaoMaster(devOpenHelper.writableDatabase) + daoSession = daoMaster.newSession() + } + + fun obtainDaoSession(): DaoSession { + return daoSession + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java new file mode 100644 index 0000000..b8f67dc --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java @@ -0,0 +1,133 @@ +package com.casic.smart.town.sanxi.bean; + +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Generated; +import org.greenrobot.greendao.annotation.Id; +import org.greenrobot.greendao.annotation.Unique; + +@Entity +public class AlarmMessageLocaleBean { + @Id(autoincrement = true) + private Long id;//主键自增 + + @Unique + private String messageId; + private String appId; + private String clientId; + private String taskId; + private String userId; + private String title; + private String content; + private String deviceCode; + private String isRead;//0-未读,1-已读 + private String alarmTime; + + @Generated(hash = 566950134) + public AlarmMessageLocaleBean(Long id, String messageId, String appId, + String clientId, String taskId, String userId, String title, + String content, String deviceCode, String isRead, String alarmTime) { + this.id = id; + this.messageId = messageId; + this.appId = appId; + this.clientId = clientId; + this.taskId = taskId; + this.userId = userId; + this.title = title; + this.content = content; + this.deviceCode = deviceCode; + this.isRead = isRead; + this.alarmTime = alarmTime; + } + + @Generated(hash = 1737519562) + public AlarmMessageLocaleBean() { + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getMessageId() { + return this.messageId; + } + + public void setMessageId(String messageId) { + this.messageId = messageId; + } + + public String getAppId() { + return this.appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public String getClientId() { + return this.clientId; + } + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public String getTaskId() { + return this.taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getUserId() { + return this.userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getTitle() { + return this.title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return this.content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getDeviceCode() { + return this.deviceCode; + } + + public void setDeviceCode(String deviceCode) { + this.deviceCode = deviceCode; + } + + public String getIsRead() { + return this.isRead; + } + + public void setIsRead(String isRead) { + this.isRead = isRead; + } + + public String getAlarmTime() { + return this.alarmTime; + } + + public void setAlarmTime(String alarmTime) { + this.alarmTime = alarmTime; + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt new file mode 100644 index 0000000..650e201 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class AlarmPageFragment: KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_alarm + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt new file mode 100644 index 0000000..deac8ac --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt @@ -0,0 +1,76 @@ +package com.casic.smart.town.sanxi.fragment + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.Fragment +import com.amap.api.maps.AMap +import com.amap.api.maps.AMapOptions +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.view.MonitorRecordActivity +import com.pengxh.kt.lite.extensions.navigatePageTo +import com.pengxh.kt.lite.extensions.show +import kotlinx.android.synthetic.main.fragment_monitor.view.* + +class MonitorPageFragment : Fragment() { + + private val kTag = "HomePageFragment" + private lateinit var monitorView: View + private lateinit var aMap: AMap + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? + ): View { + monitorView = inflater.inflate(R.layout.fragment_monitor, container, false) + //地图初始化 + initMap(savedInstanceState) + + monitorView.rightOperateView.setOnClickListener { + requireContext().navigatePageTo() + } + return monitorView + } + + private fun initMap(savedInstanceState: Bundle?) { + monitorView.mapView.onCreate(savedInstanceState) + aMap = monitorView.mapView.map + aMap.mapType = AMap.MAP_TYPE_NORMAL + val uiSettings = aMap.uiSettings + uiSettings.isCompassEnabled = true + uiSettings.zoomPosition = AMapOptions.ZOOM_POSITION_RIGHT_CENTER + uiSettings.isTiltGesturesEnabled = false//不许地图随手势倾斜角度 + + // 地图加载成功监听 +// aMap.addOnMapLoadedListener(this) + // 地图缩放监听 +// aMap.addOnCameraChangeListener(this) + // marker 点击事件监听 +// aMap.addOnMarkerClickListener(this) + // 点击marker弹出自定义popup +// aMap.setInfoWindowAdapter(this) + //信息窗点击事件 +// aMap.addOnInfoWindowClickListener(this) + } + + /***以下是地图生命周期管理************************************************************************/ + override fun onResume() { + super.onResume() + monitorView.mapView.onResume() + } + + override fun onPause() { + super.onPause() + monitorView.mapView.onPause() + } + + override fun onSaveInstanceState(outState: Bundle) { + super.onSaveInstanceState(outState) + monitorView.mapView.onSaveInstanceState(outState) + } + + override fun onDestroy() { + super.onDestroy() + monitorView.mapView.onDestroy() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt new file mode 100644 index 0000000..e84df12 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class StatisticsPageFragment : KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_statistics + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..10cfdbf --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*.iml +.gradle +/local.properties +/.idea +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..a4cd2ca --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,101 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'org.greenrobot.greendao' + +android { +// signingConfigs { +// release { +// storeFile file('/Users/a203/Desktop/AndroidProjects/CasicSmartWell/app/CasicSmartWell.jks') +// storePassword '123456789' +// keyAlias 'key0' +// keyPassword '123456789' +// } +// } + compileSdkVersion 31 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.smart.town.sanxi" + minSdkVersion 23 + targetSdkVersion 31 + versionCode 1 + versionName "1.0.0" + + manifestPlaceholders = [GETUI_APPID: "A9V4DvwLcdAqkFCQuFyhq6"] + } + + buildTypes { + release { + minifyEnabled false +// signingConfig signingConfigs.release + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + + ndk { abiFilters "armeabi", "armeabi-v7a", "arm64-v8" } + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlin { + experimental { + coroutines 'enable' + } + } + + greendao { + schemaVersion 1//数据库版本号 + targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 + daoPackage 'com.casic.smart.town.sanxi.greendao'//设置DaoMaster、DaoSession、Dao包名 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + //基础依赖库 + implementation files('libs/lite-release.aar') + implementation 'androidx.appcompat:appcompat:1.4.2' + implementation 'androidx.core:core-ktx:1.8.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:3.0.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' + //MVVM+LiveData + implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.1" + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0" + implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + //Kotlin协程 + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1' + //图片加载框架 + implementation 'com.github.bumptech.glide:glide:4.9.0' + //返回值转换器 + implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' + implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + //okhttp3日志拦截器 + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //网络请求和接口封装 + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.9.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.9.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' + //高德地图 + implementation 'com.amap.api:3dmap:latest.integration' + //推送SDK + implementation 'com.getui:gtsdk:3.2.10.0' //个推SDK + implementation 'com.getui:gtc:3.1.9.0' //个推核心组件 + //数据库框架 + implementation 'org.greenrobot:greendao:3.3.0' + //桌面角标 + implementation "me.leolin:ShortcutBadger:1.1.22@aar" +} \ No newline at end of file diff --git a/app/libs/lite-release.aar b/app/libs/lite-release.aar new file mode 100644 index 0000000..45da4df --- /dev/null +++ b/app/libs/lite-release.aar Binary files differ diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /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 \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..a83c28a --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/svg/monitor.svg b/app/src/main/assets/svg/monitor.svg new file mode 100644 index 0000000..c8d3e25 --- /dev/null +++ b/app/src/main/assets/svg/monitor.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/msg.svg b/app/src/main/assets/svg/msg.svg new file mode 100644 index 0000000..e864e48 --- /dev/null +++ b/app/src/main/assets/svg/msg.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/statistics.svg b/app/src/main/assets/svg/statistics.svg new file mode 100644 index 0000000..974000e --- /dev/null +++ b/app/src/main/assets/svg/statistics.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt new file mode 100644 index 0000000..6b9cce0 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.adapter + +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentManager +import androidx.fragment.app.FragmentPagerAdapter + +class ViewPagerAdapter(list: ArrayList, manager: FragmentManager) : + FragmentPagerAdapter(manager) { + + private var pageList: List = list + + override fun getItem(position: Int) = pageList[position] + + override fun getCount() = pageList.size +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt new file mode 100644 index 0000000..4e017b1 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt @@ -0,0 +1,40 @@ +package com.casic.smart.town.sanxi.base + +import android.app.Application +import android.util.Log +import com.casic.smart.town.sanxi.greendao.DaoMaster +import com.casic.smart.town.sanxi.greendao.DaoSession +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + private val kTag = "BaseApplication" + + companion object { + private var instance: BaseApplication by Delegates.notNull() + + fun obtainInstance() = instance + + private lateinit var daoSession: DaoSession + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences(this) + //推送 + PushManager.getInstance().initialize(this) + PushManager.getInstance().setDebugLogger(this) { + Log.d(kTag, it) + } + val devOpenHelper = DaoMaster.DevOpenHelper(this, "SmartTown.db", null) + val daoMaster = DaoMaster(devOpenHelper.writableDatabase) + daoSession = daoMaster.newSession() + } + + fun obtainDaoSession(): DaoSession { + return daoSession + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java new file mode 100644 index 0000000..b8f67dc --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java @@ -0,0 +1,133 @@ +package com.casic.smart.town.sanxi.bean; + +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Generated; +import org.greenrobot.greendao.annotation.Id; +import org.greenrobot.greendao.annotation.Unique; + +@Entity +public class AlarmMessageLocaleBean { + @Id(autoincrement = true) + private Long id;//主键自增 + + @Unique + private String messageId; + private String appId; + private String clientId; + private String taskId; + private String userId; + private String title; + private String content; + private String deviceCode; + private String isRead;//0-未读,1-已读 + private String alarmTime; + + @Generated(hash = 566950134) + public AlarmMessageLocaleBean(Long id, String messageId, String appId, + String clientId, String taskId, String userId, String title, + String content, String deviceCode, String isRead, String alarmTime) { + this.id = id; + this.messageId = messageId; + this.appId = appId; + this.clientId = clientId; + this.taskId = taskId; + this.userId = userId; + this.title = title; + this.content = content; + this.deviceCode = deviceCode; + this.isRead = isRead; + this.alarmTime = alarmTime; + } + + @Generated(hash = 1737519562) + public AlarmMessageLocaleBean() { + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getMessageId() { + return this.messageId; + } + + public void setMessageId(String messageId) { + this.messageId = messageId; + } + + public String getAppId() { + return this.appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public String getClientId() { + return this.clientId; + } + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public String getTaskId() { + return this.taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getUserId() { + return this.userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getTitle() { + return this.title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return this.content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getDeviceCode() { + return this.deviceCode; + } + + public void setDeviceCode(String deviceCode) { + this.deviceCode = deviceCode; + } + + public String getIsRead() { + return this.isRead; + } + + public void setIsRead(String isRead) { + this.isRead = isRead; + } + + public String getAlarmTime() { + return this.alarmTime; + } + + public void setAlarmTime(String alarmTime) { + this.alarmTime = alarmTime; + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt new file mode 100644 index 0000000..650e201 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class AlarmPageFragment: KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_alarm + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt new file mode 100644 index 0000000..deac8ac --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt @@ -0,0 +1,76 @@ +package com.casic.smart.town.sanxi.fragment + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.Fragment +import com.amap.api.maps.AMap +import com.amap.api.maps.AMapOptions +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.view.MonitorRecordActivity +import com.pengxh.kt.lite.extensions.navigatePageTo +import com.pengxh.kt.lite.extensions.show +import kotlinx.android.synthetic.main.fragment_monitor.view.* + +class MonitorPageFragment : Fragment() { + + private val kTag = "HomePageFragment" + private lateinit var monitorView: View + private lateinit var aMap: AMap + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? + ): View { + monitorView = inflater.inflate(R.layout.fragment_monitor, container, false) + //地图初始化 + initMap(savedInstanceState) + + monitorView.rightOperateView.setOnClickListener { + requireContext().navigatePageTo() + } + return monitorView + } + + private fun initMap(savedInstanceState: Bundle?) { + monitorView.mapView.onCreate(savedInstanceState) + aMap = monitorView.mapView.map + aMap.mapType = AMap.MAP_TYPE_NORMAL + val uiSettings = aMap.uiSettings + uiSettings.isCompassEnabled = true + uiSettings.zoomPosition = AMapOptions.ZOOM_POSITION_RIGHT_CENTER + uiSettings.isTiltGesturesEnabled = false//不许地图随手势倾斜角度 + + // 地图加载成功监听 +// aMap.addOnMapLoadedListener(this) + // 地图缩放监听 +// aMap.addOnCameraChangeListener(this) + // marker 点击事件监听 +// aMap.addOnMarkerClickListener(this) + // 点击marker弹出自定义popup +// aMap.setInfoWindowAdapter(this) + //信息窗点击事件 +// aMap.addOnInfoWindowClickListener(this) + } + + /***以下是地图生命周期管理************************************************************************/ + override fun onResume() { + super.onResume() + monitorView.mapView.onResume() + } + + override fun onPause() { + super.onPause() + monitorView.mapView.onPause() + } + + override fun onSaveInstanceState(outState: Bundle) { + super.onSaveInstanceState(outState) + monitorView.mapView.onSaveInstanceState(outState) + } + + override fun onDestroy() { + super.onDestroy() + monitorView.mapView.onDestroy() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt new file mode 100644 index 0000000..e84df12 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class StatisticsPageFragment : KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_statistics + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java new file mode 100644 index 0000000..68d7901 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java @@ -0,0 +1,255 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.database.Cursor; +import android.database.sqlite.SQLiteStatement; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.Property; +import org.greenrobot.greendao.internal.DaoConfig; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseStatement; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * DAO for table "ALARM_MESSAGE_LOCALE_BEAN". +*/ +public class AlarmMessageLocaleBeanDao extends AbstractDao { + + public static final String TABLENAME = "ALARM_MESSAGE_LOCALE_BEAN"; + + /** + * Properties of entity AlarmMessageLocaleBean.
+ * Can be used for QueryBuilder and for referencing column names. + */ + public static class Properties { + public final static Property Id = new Property(0, Long.class, "id", true, "_id"); + public final static Property MessageId = new Property(1, String.class, "messageId", false, "MESSAGE_ID"); + public final static Property AppId = new Property(2, String.class, "appId", false, "APP_ID"); + public final static Property ClientId = new Property(3, String.class, "clientId", false, "CLIENT_ID"); + public final static Property TaskId = new Property(4, String.class, "taskId", false, "TASK_ID"); + public final static Property UserId = new Property(5, String.class, "userId", false, "USER_ID"); + public final static Property Title = new Property(6, String.class, "title", false, "TITLE"); + public final static Property Content = new Property(7, String.class, "content", false, "CONTENT"); + public final static Property DeviceCode = new Property(8, String.class, "deviceCode", false, "DEVICE_CODE"); + public final static Property IsRead = new Property(9, String.class, "isRead", false, "IS_READ"); + public final static Property AlarmTime = new Property(10, String.class, "alarmTime", false, "ALARM_TIME"); + } + + + public AlarmMessageLocaleBeanDao(DaoConfig config) { + super(config); + } + + public AlarmMessageLocaleBeanDao(DaoConfig config, DaoSession daoSession) { + super(config, daoSession); + } + + /** Creates the underlying database table. */ + public static void createTable(Database db, boolean ifNotExists) { + String constraint = ifNotExists? "IF NOT EXISTS ": ""; + db.execSQL("CREATE TABLE " + constraint + "\"ALARM_MESSAGE_LOCALE_BEAN\" (" + // + "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id + "\"MESSAGE_ID\" TEXT UNIQUE ," + // 1: messageId + "\"APP_ID\" TEXT," + // 2: appId + "\"CLIENT_ID\" TEXT," + // 3: clientId + "\"TASK_ID\" TEXT," + // 4: taskId + "\"USER_ID\" TEXT," + // 5: userId + "\"TITLE\" TEXT," + // 6: title + "\"CONTENT\" TEXT," + // 7: content + "\"DEVICE_CODE\" TEXT," + // 8: deviceCode + "\"IS_READ\" TEXT," + // 9: isRead + "\"ALARM_TIME\" TEXT);"); // 10: alarmTime + } + + /** Drops the underlying database table. */ + public static void dropTable(Database db, boolean ifExists) { + String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"ALARM_MESSAGE_LOCALE_BEAN\""; + db.execSQL(sql); + } + + @Override + protected final void bindValues(DatabaseStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + protected final void bindValues(SQLiteStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + public Long readKey(Cursor cursor, int offset) { + return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); + } + + @Override + public AlarmMessageLocaleBean readEntity(Cursor cursor, int offset) { + AlarmMessageLocaleBean entity = new AlarmMessageLocaleBean( // + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // messageId + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // appId + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // clientId + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // taskId + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // userId + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // title + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // content + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // deviceCode + cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // isRead + cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10) // alarmTime + ); + return entity; + } + + @Override + public void readEntity(Cursor cursor, AlarmMessageLocaleBean entity, int offset) { + entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); + entity.setMessageId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setAppId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setClientId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setTaskId(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); + entity.setUserId(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setTitle(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setContent(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); + entity.setDeviceCode(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); + entity.setIsRead(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9)); + entity.setAlarmTime(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); + } + + @Override + protected final Long updateKeyAfterInsert(AlarmMessageLocaleBean entity, long rowId) { + entity.setId(rowId); + return rowId; + } + + @Override + public Long getKey(AlarmMessageLocaleBean entity) { + if(entity != null) { + return entity.getId(); + } else { + return null; + } + } + + @Override + public boolean hasKey(AlarmMessageLocaleBean entity) { + return entity.getId() != null; + } + + @Override + protected final boolean isEntityUpdateable() { + return true; + } + +} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..10cfdbf --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*.iml +.gradle +/local.properties +/.idea +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..a4cd2ca --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,101 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'org.greenrobot.greendao' + +android { +// signingConfigs { +// release { +// storeFile file('/Users/a203/Desktop/AndroidProjects/CasicSmartWell/app/CasicSmartWell.jks') +// storePassword '123456789' +// keyAlias 'key0' +// keyPassword '123456789' +// } +// } + compileSdkVersion 31 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.smart.town.sanxi" + minSdkVersion 23 + targetSdkVersion 31 + versionCode 1 + versionName "1.0.0" + + manifestPlaceholders = [GETUI_APPID: "A9V4DvwLcdAqkFCQuFyhq6"] + } + + buildTypes { + release { + minifyEnabled false +// signingConfig signingConfigs.release + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + + ndk { abiFilters "armeabi", "armeabi-v7a", "arm64-v8" } + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlin { + experimental { + coroutines 'enable' + } + } + + greendao { + schemaVersion 1//数据库版本号 + targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 + daoPackage 'com.casic.smart.town.sanxi.greendao'//设置DaoMaster、DaoSession、Dao包名 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + //基础依赖库 + implementation files('libs/lite-release.aar') + implementation 'androidx.appcompat:appcompat:1.4.2' + implementation 'androidx.core:core-ktx:1.8.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:3.0.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' + //MVVM+LiveData + implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.1" + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0" + implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + //Kotlin协程 + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1' + //图片加载框架 + implementation 'com.github.bumptech.glide:glide:4.9.0' + //返回值转换器 + implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' + implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + //okhttp3日志拦截器 + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //网络请求和接口封装 + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.9.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.9.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' + //高德地图 + implementation 'com.amap.api:3dmap:latest.integration' + //推送SDK + implementation 'com.getui:gtsdk:3.2.10.0' //个推SDK + implementation 'com.getui:gtc:3.1.9.0' //个推核心组件 + //数据库框架 + implementation 'org.greenrobot:greendao:3.3.0' + //桌面角标 + implementation "me.leolin:ShortcutBadger:1.1.22@aar" +} \ No newline at end of file diff --git a/app/libs/lite-release.aar b/app/libs/lite-release.aar new file mode 100644 index 0000000..45da4df --- /dev/null +++ b/app/libs/lite-release.aar Binary files differ diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /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 \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..a83c28a --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/svg/monitor.svg b/app/src/main/assets/svg/monitor.svg new file mode 100644 index 0000000..c8d3e25 --- /dev/null +++ b/app/src/main/assets/svg/monitor.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/msg.svg b/app/src/main/assets/svg/msg.svg new file mode 100644 index 0000000..e864e48 --- /dev/null +++ b/app/src/main/assets/svg/msg.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/statistics.svg b/app/src/main/assets/svg/statistics.svg new file mode 100644 index 0000000..974000e --- /dev/null +++ b/app/src/main/assets/svg/statistics.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt new file mode 100644 index 0000000..6b9cce0 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.adapter + +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentManager +import androidx.fragment.app.FragmentPagerAdapter + +class ViewPagerAdapter(list: ArrayList, manager: FragmentManager) : + FragmentPagerAdapter(manager) { + + private var pageList: List = list + + override fun getItem(position: Int) = pageList[position] + + override fun getCount() = pageList.size +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt new file mode 100644 index 0000000..4e017b1 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt @@ -0,0 +1,40 @@ +package com.casic.smart.town.sanxi.base + +import android.app.Application +import android.util.Log +import com.casic.smart.town.sanxi.greendao.DaoMaster +import com.casic.smart.town.sanxi.greendao.DaoSession +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + private val kTag = "BaseApplication" + + companion object { + private var instance: BaseApplication by Delegates.notNull() + + fun obtainInstance() = instance + + private lateinit var daoSession: DaoSession + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences(this) + //推送 + PushManager.getInstance().initialize(this) + PushManager.getInstance().setDebugLogger(this) { + Log.d(kTag, it) + } + val devOpenHelper = DaoMaster.DevOpenHelper(this, "SmartTown.db", null) + val daoMaster = DaoMaster(devOpenHelper.writableDatabase) + daoSession = daoMaster.newSession() + } + + fun obtainDaoSession(): DaoSession { + return daoSession + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java new file mode 100644 index 0000000..b8f67dc --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java @@ -0,0 +1,133 @@ +package com.casic.smart.town.sanxi.bean; + +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Generated; +import org.greenrobot.greendao.annotation.Id; +import org.greenrobot.greendao.annotation.Unique; + +@Entity +public class AlarmMessageLocaleBean { + @Id(autoincrement = true) + private Long id;//主键自增 + + @Unique + private String messageId; + private String appId; + private String clientId; + private String taskId; + private String userId; + private String title; + private String content; + private String deviceCode; + private String isRead;//0-未读,1-已读 + private String alarmTime; + + @Generated(hash = 566950134) + public AlarmMessageLocaleBean(Long id, String messageId, String appId, + String clientId, String taskId, String userId, String title, + String content, String deviceCode, String isRead, String alarmTime) { + this.id = id; + this.messageId = messageId; + this.appId = appId; + this.clientId = clientId; + this.taskId = taskId; + this.userId = userId; + this.title = title; + this.content = content; + this.deviceCode = deviceCode; + this.isRead = isRead; + this.alarmTime = alarmTime; + } + + @Generated(hash = 1737519562) + public AlarmMessageLocaleBean() { + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getMessageId() { + return this.messageId; + } + + public void setMessageId(String messageId) { + this.messageId = messageId; + } + + public String getAppId() { + return this.appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public String getClientId() { + return this.clientId; + } + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public String getTaskId() { + return this.taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getUserId() { + return this.userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getTitle() { + return this.title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return this.content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getDeviceCode() { + return this.deviceCode; + } + + public void setDeviceCode(String deviceCode) { + this.deviceCode = deviceCode; + } + + public String getIsRead() { + return this.isRead; + } + + public void setIsRead(String isRead) { + this.isRead = isRead; + } + + public String getAlarmTime() { + return this.alarmTime; + } + + public void setAlarmTime(String alarmTime) { + this.alarmTime = alarmTime; + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt new file mode 100644 index 0000000..650e201 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class AlarmPageFragment: KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_alarm + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt new file mode 100644 index 0000000..deac8ac --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt @@ -0,0 +1,76 @@ +package com.casic.smart.town.sanxi.fragment + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.Fragment +import com.amap.api.maps.AMap +import com.amap.api.maps.AMapOptions +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.view.MonitorRecordActivity +import com.pengxh.kt.lite.extensions.navigatePageTo +import com.pengxh.kt.lite.extensions.show +import kotlinx.android.synthetic.main.fragment_monitor.view.* + +class MonitorPageFragment : Fragment() { + + private val kTag = "HomePageFragment" + private lateinit var monitorView: View + private lateinit var aMap: AMap + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? + ): View { + monitorView = inflater.inflate(R.layout.fragment_monitor, container, false) + //地图初始化 + initMap(savedInstanceState) + + monitorView.rightOperateView.setOnClickListener { + requireContext().navigatePageTo() + } + return monitorView + } + + private fun initMap(savedInstanceState: Bundle?) { + monitorView.mapView.onCreate(savedInstanceState) + aMap = monitorView.mapView.map + aMap.mapType = AMap.MAP_TYPE_NORMAL + val uiSettings = aMap.uiSettings + uiSettings.isCompassEnabled = true + uiSettings.zoomPosition = AMapOptions.ZOOM_POSITION_RIGHT_CENTER + uiSettings.isTiltGesturesEnabled = false//不许地图随手势倾斜角度 + + // 地图加载成功监听 +// aMap.addOnMapLoadedListener(this) + // 地图缩放监听 +// aMap.addOnCameraChangeListener(this) + // marker 点击事件监听 +// aMap.addOnMarkerClickListener(this) + // 点击marker弹出自定义popup +// aMap.setInfoWindowAdapter(this) + //信息窗点击事件 +// aMap.addOnInfoWindowClickListener(this) + } + + /***以下是地图生命周期管理************************************************************************/ + override fun onResume() { + super.onResume() + monitorView.mapView.onResume() + } + + override fun onPause() { + super.onPause() + monitorView.mapView.onPause() + } + + override fun onSaveInstanceState(outState: Bundle) { + super.onSaveInstanceState(outState) + monitorView.mapView.onSaveInstanceState(outState) + } + + override fun onDestroy() { + super.onDestroy() + monitorView.mapView.onDestroy() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt new file mode 100644 index 0000000..e84df12 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class StatisticsPageFragment : KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_statistics + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java new file mode 100644 index 0000000..68d7901 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java @@ -0,0 +1,255 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.database.Cursor; +import android.database.sqlite.SQLiteStatement; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.Property; +import org.greenrobot.greendao.internal.DaoConfig; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseStatement; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * DAO for table "ALARM_MESSAGE_LOCALE_BEAN". +*/ +public class AlarmMessageLocaleBeanDao extends AbstractDao { + + public static final String TABLENAME = "ALARM_MESSAGE_LOCALE_BEAN"; + + /** + * Properties of entity AlarmMessageLocaleBean.
+ * Can be used for QueryBuilder and for referencing column names. + */ + public static class Properties { + public final static Property Id = new Property(0, Long.class, "id", true, "_id"); + public final static Property MessageId = new Property(1, String.class, "messageId", false, "MESSAGE_ID"); + public final static Property AppId = new Property(2, String.class, "appId", false, "APP_ID"); + public final static Property ClientId = new Property(3, String.class, "clientId", false, "CLIENT_ID"); + public final static Property TaskId = new Property(4, String.class, "taskId", false, "TASK_ID"); + public final static Property UserId = new Property(5, String.class, "userId", false, "USER_ID"); + public final static Property Title = new Property(6, String.class, "title", false, "TITLE"); + public final static Property Content = new Property(7, String.class, "content", false, "CONTENT"); + public final static Property DeviceCode = new Property(8, String.class, "deviceCode", false, "DEVICE_CODE"); + public final static Property IsRead = new Property(9, String.class, "isRead", false, "IS_READ"); + public final static Property AlarmTime = new Property(10, String.class, "alarmTime", false, "ALARM_TIME"); + } + + + public AlarmMessageLocaleBeanDao(DaoConfig config) { + super(config); + } + + public AlarmMessageLocaleBeanDao(DaoConfig config, DaoSession daoSession) { + super(config, daoSession); + } + + /** Creates the underlying database table. */ + public static void createTable(Database db, boolean ifNotExists) { + String constraint = ifNotExists? "IF NOT EXISTS ": ""; + db.execSQL("CREATE TABLE " + constraint + "\"ALARM_MESSAGE_LOCALE_BEAN\" (" + // + "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id + "\"MESSAGE_ID\" TEXT UNIQUE ," + // 1: messageId + "\"APP_ID\" TEXT," + // 2: appId + "\"CLIENT_ID\" TEXT," + // 3: clientId + "\"TASK_ID\" TEXT," + // 4: taskId + "\"USER_ID\" TEXT," + // 5: userId + "\"TITLE\" TEXT," + // 6: title + "\"CONTENT\" TEXT," + // 7: content + "\"DEVICE_CODE\" TEXT," + // 8: deviceCode + "\"IS_READ\" TEXT," + // 9: isRead + "\"ALARM_TIME\" TEXT);"); // 10: alarmTime + } + + /** Drops the underlying database table. */ + public static void dropTable(Database db, boolean ifExists) { + String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"ALARM_MESSAGE_LOCALE_BEAN\""; + db.execSQL(sql); + } + + @Override + protected final void bindValues(DatabaseStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + protected final void bindValues(SQLiteStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + public Long readKey(Cursor cursor, int offset) { + return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); + } + + @Override + public AlarmMessageLocaleBean readEntity(Cursor cursor, int offset) { + AlarmMessageLocaleBean entity = new AlarmMessageLocaleBean( // + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // messageId + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // appId + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // clientId + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // taskId + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // userId + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // title + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // content + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // deviceCode + cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // isRead + cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10) // alarmTime + ); + return entity; + } + + @Override + public void readEntity(Cursor cursor, AlarmMessageLocaleBean entity, int offset) { + entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); + entity.setMessageId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setAppId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setClientId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setTaskId(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); + entity.setUserId(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setTitle(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setContent(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); + entity.setDeviceCode(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); + entity.setIsRead(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9)); + entity.setAlarmTime(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); + } + + @Override + protected final Long updateKeyAfterInsert(AlarmMessageLocaleBean entity, long rowId) { + entity.setId(rowId); + return rowId; + } + + @Override + public Long getKey(AlarmMessageLocaleBean entity) { + if(entity != null) { + return entity.getId(); + } else { + return null; + } + } + + @Override + public boolean hasKey(AlarmMessageLocaleBean entity) { + return entity.getId() != null; + } + + @Override + protected final boolean isEntityUpdateable() { + return true; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java new file mode 100644 index 0000000..4222c40 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java @@ -0,0 +1,96 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.content.Context; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteDatabase.CursorFactory; +import android.util.Log; + +import org.greenrobot.greendao.AbstractDaoMaster; +import org.greenrobot.greendao.database.StandardDatabase; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseOpenHelper; +import org.greenrobot.greendao.identityscope.IdentityScopeType; + + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * Master of DAO (schema version 1): knows all DAOs. + */ +public class DaoMaster extends AbstractDaoMaster { + public static final int SCHEMA_VERSION = 1; + + /** Creates underlying database table using DAOs. */ + public static void createAllTables(Database db, boolean ifNotExists) { + AlarmMessageLocaleBeanDao.createTable(db, ifNotExists); + } + + /** Drops underlying database table using DAOs. */ + public static void dropAllTables(Database db, boolean ifExists) { + AlarmMessageLocaleBeanDao.dropTable(db, ifExists); + } + + /** + * WARNING: Drops all table on Upgrade! Use only during development. + * Convenience method using a {@link DevOpenHelper}. + */ + public static DaoSession newDevSession(Context context, String name) { + Database db = new DevOpenHelper(context, name).getWritableDb(); + DaoMaster daoMaster = new DaoMaster(db); + return daoMaster.newSession(); + } + + public DaoMaster(SQLiteDatabase db) { + this(new StandardDatabase(db)); + } + + public DaoMaster(Database db) { + super(db, SCHEMA_VERSION); + registerDaoClass(AlarmMessageLocaleBeanDao.class); + } + + public DaoSession newSession() { + return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); + } + + public DaoSession newSession(IdentityScopeType type) { + return new DaoSession(db, type, daoConfigMap); + } + + /** + * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} - + */ + public static abstract class OpenHelper extends DatabaseOpenHelper { + public OpenHelper(Context context, String name) { + super(context, name, SCHEMA_VERSION); + } + + public OpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory, SCHEMA_VERSION); + } + + @Override + public void onCreate(Database db) { + Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); + createAllTables(db, false); + } + } + + /** WARNING: Drops all table on Upgrade! Use only during development. */ + public static class DevOpenHelper extends OpenHelper { + public DevOpenHelper(Context context, String name) { + super(context, name); + } + + public DevOpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory); + } + + @Override + public void onUpgrade(Database db, int oldVersion, int newVersion) { + Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); + dropAllTables(db, true); + onCreate(db); + } + } + +} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..10cfdbf --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*.iml +.gradle +/local.properties +/.idea +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..a4cd2ca --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,101 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'org.greenrobot.greendao' + +android { +// signingConfigs { +// release { +// storeFile file('/Users/a203/Desktop/AndroidProjects/CasicSmartWell/app/CasicSmartWell.jks') +// storePassword '123456789' +// keyAlias 'key0' +// keyPassword '123456789' +// } +// } + compileSdkVersion 31 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.smart.town.sanxi" + minSdkVersion 23 + targetSdkVersion 31 + versionCode 1 + versionName "1.0.0" + + manifestPlaceholders = [GETUI_APPID: "A9V4DvwLcdAqkFCQuFyhq6"] + } + + buildTypes { + release { + minifyEnabled false +// signingConfig signingConfigs.release + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + + ndk { abiFilters "armeabi", "armeabi-v7a", "arm64-v8" } + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlin { + experimental { + coroutines 'enable' + } + } + + greendao { + schemaVersion 1//数据库版本号 + targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 + daoPackage 'com.casic.smart.town.sanxi.greendao'//设置DaoMaster、DaoSession、Dao包名 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + //基础依赖库 + implementation files('libs/lite-release.aar') + implementation 'androidx.appcompat:appcompat:1.4.2' + implementation 'androidx.core:core-ktx:1.8.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:3.0.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' + //MVVM+LiveData + implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.1" + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0" + implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + //Kotlin协程 + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1' + //图片加载框架 + implementation 'com.github.bumptech.glide:glide:4.9.0' + //返回值转换器 + implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' + implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + //okhttp3日志拦截器 + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //网络请求和接口封装 + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.9.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.9.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' + //高德地图 + implementation 'com.amap.api:3dmap:latest.integration' + //推送SDK + implementation 'com.getui:gtsdk:3.2.10.0' //个推SDK + implementation 'com.getui:gtc:3.1.9.0' //个推核心组件 + //数据库框架 + implementation 'org.greenrobot:greendao:3.3.0' + //桌面角标 + implementation "me.leolin:ShortcutBadger:1.1.22@aar" +} \ No newline at end of file diff --git a/app/libs/lite-release.aar b/app/libs/lite-release.aar new file mode 100644 index 0000000..45da4df --- /dev/null +++ b/app/libs/lite-release.aar Binary files differ diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /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 \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..a83c28a --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/svg/monitor.svg b/app/src/main/assets/svg/monitor.svg new file mode 100644 index 0000000..c8d3e25 --- /dev/null +++ b/app/src/main/assets/svg/monitor.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/msg.svg b/app/src/main/assets/svg/msg.svg new file mode 100644 index 0000000..e864e48 --- /dev/null +++ b/app/src/main/assets/svg/msg.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/statistics.svg b/app/src/main/assets/svg/statistics.svg new file mode 100644 index 0000000..974000e --- /dev/null +++ b/app/src/main/assets/svg/statistics.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt new file mode 100644 index 0000000..6b9cce0 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.adapter + +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentManager +import androidx.fragment.app.FragmentPagerAdapter + +class ViewPagerAdapter(list: ArrayList, manager: FragmentManager) : + FragmentPagerAdapter(manager) { + + private var pageList: List = list + + override fun getItem(position: Int) = pageList[position] + + override fun getCount() = pageList.size +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt new file mode 100644 index 0000000..4e017b1 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt @@ -0,0 +1,40 @@ +package com.casic.smart.town.sanxi.base + +import android.app.Application +import android.util.Log +import com.casic.smart.town.sanxi.greendao.DaoMaster +import com.casic.smart.town.sanxi.greendao.DaoSession +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + private val kTag = "BaseApplication" + + companion object { + private var instance: BaseApplication by Delegates.notNull() + + fun obtainInstance() = instance + + private lateinit var daoSession: DaoSession + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences(this) + //推送 + PushManager.getInstance().initialize(this) + PushManager.getInstance().setDebugLogger(this) { + Log.d(kTag, it) + } + val devOpenHelper = DaoMaster.DevOpenHelper(this, "SmartTown.db", null) + val daoMaster = DaoMaster(devOpenHelper.writableDatabase) + daoSession = daoMaster.newSession() + } + + fun obtainDaoSession(): DaoSession { + return daoSession + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java new file mode 100644 index 0000000..b8f67dc --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java @@ -0,0 +1,133 @@ +package com.casic.smart.town.sanxi.bean; + +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Generated; +import org.greenrobot.greendao.annotation.Id; +import org.greenrobot.greendao.annotation.Unique; + +@Entity +public class AlarmMessageLocaleBean { + @Id(autoincrement = true) + private Long id;//主键自增 + + @Unique + private String messageId; + private String appId; + private String clientId; + private String taskId; + private String userId; + private String title; + private String content; + private String deviceCode; + private String isRead;//0-未读,1-已读 + private String alarmTime; + + @Generated(hash = 566950134) + public AlarmMessageLocaleBean(Long id, String messageId, String appId, + String clientId, String taskId, String userId, String title, + String content, String deviceCode, String isRead, String alarmTime) { + this.id = id; + this.messageId = messageId; + this.appId = appId; + this.clientId = clientId; + this.taskId = taskId; + this.userId = userId; + this.title = title; + this.content = content; + this.deviceCode = deviceCode; + this.isRead = isRead; + this.alarmTime = alarmTime; + } + + @Generated(hash = 1737519562) + public AlarmMessageLocaleBean() { + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getMessageId() { + return this.messageId; + } + + public void setMessageId(String messageId) { + this.messageId = messageId; + } + + public String getAppId() { + return this.appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public String getClientId() { + return this.clientId; + } + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public String getTaskId() { + return this.taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getUserId() { + return this.userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getTitle() { + return this.title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return this.content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getDeviceCode() { + return this.deviceCode; + } + + public void setDeviceCode(String deviceCode) { + this.deviceCode = deviceCode; + } + + public String getIsRead() { + return this.isRead; + } + + public void setIsRead(String isRead) { + this.isRead = isRead; + } + + public String getAlarmTime() { + return this.alarmTime; + } + + public void setAlarmTime(String alarmTime) { + this.alarmTime = alarmTime; + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt new file mode 100644 index 0000000..650e201 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class AlarmPageFragment: KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_alarm + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt new file mode 100644 index 0000000..deac8ac --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt @@ -0,0 +1,76 @@ +package com.casic.smart.town.sanxi.fragment + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.Fragment +import com.amap.api.maps.AMap +import com.amap.api.maps.AMapOptions +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.view.MonitorRecordActivity +import com.pengxh.kt.lite.extensions.navigatePageTo +import com.pengxh.kt.lite.extensions.show +import kotlinx.android.synthetic.main.fragment_monitor.view.* + +class MonitorPageFragment : Fragment() { + + private val kTag = "HomePageFragment" + private lateinit var monitorView: View + private lateinit var aMap: AMap + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? + ): View { + monitorView = inflater.inflate(R.layout.fragment_monitor, container, false) + //地图初始化 + initMap(savedInstanceState) + + monitorView.rightOperateView.setOnClickListener { + requireContext().navigatePageTo() + } + return monitorView + } + + private fun initMap(savedInstanceState: Bundle?) { + monitorView.mapView.onCreate(savedInstanceState) + aMap = monitorView.mapView.map + aMap.mapType = AMap.MAP_TYPE_NORMAL + val uiSettings = aMap.uiSettings + uiSettings.isCompassEnabled = true + uiSettings.zoomPosition = AMapOptions.ZOOM_POSITION_RIGHT_CENTER + uiSettings.isTiltGesturesEnabled = false//不许地图随手势倾斜角度 + + // 地图加载成功监听 +// aMap.addOnMapLoadedListener(this) + // 地图缩放监听 +// aMap.addOnCameraChangeListener(this) + // marker 点击事件监听 +// aMap.addOnMarkerClickListener(this) + // 点击marker弹出自定义popup +// aMap.setInfoWindowAdapter(this) + //信息窗点击事件 +// aMap.addOnInfoWindowClickListener(this) + } + + /***以下是地图生命周期管理************************************************************************/ + override fun onResume() { + super.onResume() + monitorView.mapView.onResume() + } + + override fun onPause() { + super.onPause() + monitorView.mapView.onPause() + } + + override fun onSaveInstanceState(outState: Bundle) { + super.onSaveInstanceState(outState) + monitorView.mapView.onSaveInstanceState(outState) + } + + override fun onDestroy() { + super.onDestroy() + monitorView.mapView.onDestroy() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt new file mode 100644 index 0000000..e84df12 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class StatisticsPageFragment : KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_statistics + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java new file mode 100644 index 0000000..68d7901 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java @@ -0,0 +1,255 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.database.Cursor; +import android.database.sqlite.SQLiteStatement; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.Property; +import org.greenrobot.greendao.internal.DaoConfig; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseStatement; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * DAO for table "ALARM_MESSAGE_LOCALE_BEAN". +*/ +public class AlarmMessageLocaleBeanDao extends AbstractDao { + + public static final String TABLENAME = "ALARM_MESSAGE_LOCALE_BEAN"; + + /** + * Properties of entity AlarmMessageLocaleBean.
+ * Can be used for QueryBuilder and for referencing column names. + */ + public static class Properties { + public final static Property Id = new Property(0, Long.class, "id", true, "_id"); + public final static Property MessageId = new Property(1, String.class, "messageId", false, "MESSAGE_ID"); + public final static Property AppId = new Property(2, String.class, "appId", false, "APP_ID"); + public final static Property ClientId = new Property(3, String.class, "clientId", false, "CLIENT_ID"); + public final static Property TaskId = new Property(4, String.class, "taskId", false, "TASK_ID"); + public final static Property UserId = new Property(5, String.class, "userId", false, "USER_ID"); + public final static Property Title = new Property(6, String.class, "title", false, "TITLE"); + public final static Property Content = new Property(7, String.class, "content", false, "CONTENT"); + public final static Property DeviceCode = new Property(8, String.class, "deviceCode", false, "DEVICE_CODE"); + public final static Property IsRead = new Property(9, String.class, "isRead", false, "IS_READ"); + public final static Property AlarmTime = new Property(10, String.class, "alarmTime", false, "ALARM_TIME"); + } + + + public AlarmMessageLocaleBeanDao(DaoConfig config) { + super(config); + } + + public AlarmMessageLocaleBeanDao(DaoConfig config, DaoSession daoSession) { + super(config, daoSession); + } + + /** Creates the underlying database table. */ + public static void createTable(Database db, boolean ifNotExists) { + String constraint = ifNotExists? "IF NOT EXISTS ": ""; + db.execSQL("CREATE TABLE " + constraint + "\"ALARM_MESSAGE_LOCALE_BEAN\" (" + // + "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id + "\"MESSAGE_ID\" TEXT UNIQUE ," + // 1: messageId + "\"APP_ID\" TEXT," + // 2: appId + "\"CLIENT_ID\" TEXT," + // 3: clientId + "\"TASK_ID\" TEXT," + // 4: taskId + "\"USER_ID\" TEXT," + // 5: userId + "\"TITLE\" TEXT," + // 6: title + "\"CONTENT\" TEXT," + // 7: content + "\"DEVICE_CODE\" TEXT," + // 8: deviceCode + "\"IS_READ\" TEXT," + // 9: isRead + "\"ALARM_TIME\" TEXT);"); // 10: alarmTime + } + + /** Drops the underlying database table. */ + public static void dropTable(Database db, boolean ifExists) { + String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"ALARM_MESSAGE_LOCALE_BEAN\""; + db.execSQL(sql); + } + + @Override + protected final void bindValues(DatabaseStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + protected final void bindValues(SQLiteStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + public Long readKey(Cursor cursor, int offset) { + return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); + } + + @Override + public AlarmMessageLocaleBean readEntity(Cursor cursor, int offset) { + AlarmMessageLocaleBean entity = new AlarmMessageLocaleBean( // + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // messageId + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // appId + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // clientId + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // taskId + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // userId + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // title + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // content + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // deviceCode + cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // isRead + cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10) // alarmTime + ); + return entity; + } + + @Override + public void readEntity(Cursor cursor, AlarmMessageLocaleBean entity, int offset) { + entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); + entity.setMessageId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setAppId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setClientId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setTaskId(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); + entity.setUserId(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setTitle(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setContent(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); + entity.setDeviceCode(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); + entity.setIsRead(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9)); + entity.setAlarmTime(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); + } + + @Override + protected final Long updateKeyAfterInsert(AlarmMessageLocaleBean entity, long rowId) { + entity.setId(rowId); + return rowId; + } + + @Override + public Long getKey(AlarmMessageLocaleBean entity) { + if(entity != null) { + return entity.getId(); + } else { + return null; + } + } + + @Override + public boolean hasKey(AlarmMessageLocaleBean entity) { + return entity.getId() != null; + } + + @Override + protected final boolean isEntityUpdateable() { + return true; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java new file mode 100644 index 0000000..4222c40 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java @@ -0,0 +1,96 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.content.Context; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteDatabase.CursorFactory; +import android.util.Log; + +import org.greenrobot.greendao.AbstractDaoMaster; +import org.greenrobot.greendao.database.StandardDatabase; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseOpenHelper; +import org.greenrobot.greendao.identityscope.IdentityScopeType; + + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * Master of DAO (schema version 1): knows all DAOs. + */ +public class DaoMaster extends AbstractDaoMaster { + public static final int SCHEMA_VERSION = 1; + + /** Creates underlying database table using DAOs. */ + public static void createAllTables(Database db, boolean ifNotExists) { + AlarmMessageLocaleBeanDao.createTable(db, ifNotExists); + } + + /** Drops underlying database table using DAOs. */ + public static void dropAllTables(Database db, boolean ifExists) { + AlarmMessageLocaleBeanDao.dropTable(db, ifExists); + } + + /** + * WARNING: Drops all table on Upgrade! Use only during development. + * Convenience method using a {@link DevOpenHelper}. + */ + public static DaoSession newDevSession(Context context, String name) { + Database db = new DevOpenHelper(context, name).getWritableDb(); + DaoMaster daoMaster = new DaoMaster(db); + return daoMaster.newSession(); + } + + public DaoMaster(SQLiteDatabase db) { + this(new StandardDatabase(db)); + } + + public DaoMaster(Database db) { + super(db, SCHEMA_VERSION); + registerDaoClass(AlarmMessageLocaleBeanDao.class); + } + + public DaoSession newSession() { + return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); + } + + public DaoSession newSession(IdentityScopeType type) { + return new DaoSession(db, type, daoConfigMap); + } + + /** + * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} - + */ + public static abstract class OpenHelper extends DatabaseOpenHelper { + public OpenHelper(Context context, String name) { + super(context, name, SCHEMA_VERSION); + } + + public OpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory, SCHEMA_VERSION); + } + + @Override + public void onCreate(Database db) { + Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); + createAllTables(db, false); + } + } + + /** WARNING: Drops all table on Upgrade! Use only during development. */ + public static class DevOpenHelper extends OpenHelper { + public DevOpenHelper(Context context, String name) { + super(context, name); + } + + public DevOpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory); + } + + @Override + public void onUpgrade(Database db, int oldVersion, int newVersion) { + Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); + dropAllTables(db, true); + onCreate(db); + } + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java new file mode 100644 index 0000000..480ed84 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java @@ -0,0 +1,48 @@ +package com.casic.smart.town.sanxi.greendao; + +import java.util.Map; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.AbstractDaoSession; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.identityscope.IdentityScopeType; +import org.greenrobot.greendao.internal.DaoConfig; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. + +/** + * {@inheritDoc} + * + * @see org.greenrobot.greendao.AbstractDaoSession + */ +public class DaoSession extends AbstractDaoSession { + + private final DaoConfig alarmMessageLocaleBeanDaoConfig; + + private final AlarmMessageLocaleBeanDao alarmMessageLocaleBeanDao; + + public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> + daoConfigMap) { + super(db); + + alarmMessageLocaleBeanDaoConfig = daoConfigMap.get(AlarmMessageLocaleBeanDao.class).clone(); + alarmMessageLocaleBeanDaoConfig.initIdentityScope(type); + + alarmMessageLocaleBeanDao = new AlarmMessageLocaleBeanDao(alarmMessageLocaleBeanDaoConfig, this); + + registerDao(AlarmMessageLocaleBean.class, alarmMessageLocaleBeanDao); + } + + public void clear() { + alarmMessageLocaleBeanDaoConfig.clearIdentityScope(); + } + + public AlarmMessageLocaleBeanDao getAlarmMessageLocaleBeanDao() { + return alarmMessageLocaleBeanDao; + } + +} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..10cfdbf --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*.iml +.gradle +/local.properties +/.idea +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..a4cd2ca --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,101 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'org.greenrobot.greendao' + +android { +// signingConfigs { +// release { +// storeFile file('/Users/a203/Desktop/AndroidProjects/CasicSmartWell/app/CasicSmartWell.jks') +// storePassword '123456789' +// keyAlias 'key0' +// keyPassword '123456789' +// } +// } + compileSdkVersion 31 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.smart.town.sanxi" + minSdkVersion 23 + targetSdkVersion 31 + versionCode 1 + versionName "1.0.0" + + manifestPlaceholders = [GETUI_APPID: "A9V4DvwLcdAqkFCQuFyhq6"] + } + + buildTypes { + release { + minifyEnabled false +// signingConfig signingConfigs.release + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + + ndk { abiFilters "armeabi", "armeabi-v7a", "arm64-v8" } + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlin { + experimental { + coroutines 'enable' + } + } + + greendao { + schemaVersion 1//数据库版本号 + targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 + daoPackage 'com.casic.smart.town.sanxi.greendao'//设置DaoMaster、DaoSession、Dao包名 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + //基础依赖库 + implementation files('libs/lite-release.aar') + implementation 'androidx.appcompat:appcompat:1.4.2' + implementation 'androidx.core:core-ktx:1.8.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:3.0.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' + //MVVM+LiveData + implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.1" + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0" + implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + //Kotlin协程 + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1' + //图片加载框架 + implementation 'com.github.bumptech.glide:glide:4.9.0' + //返回值转换器 + implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' + implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + //okhttp3日志拦截器 + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //网络请求和接口封装 + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.9.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.9.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' + //高德地图 + implementation 'com.amap.api:3dmap:latest.integration' + //推送SDK + implementation 'com.getui:gtsdk:3.2.10.0' //个推SDK + implementation 'com.getui:gtc:3.1.9.0' //个推核心组件 + //数据库框架 + implementation 'org.greenrobot:greendao:3.3.0' + //桌面角标 + implementation "me.leolin:ShortcutBadger:1.1.22@aar" +} \ No newline at end of file diff --git a/app/libs/lite-release.aar b/app/libs/lite-release.aar new file mode 100644 index 0000000..45da4df --- /dev/null +++ b/app/libs/lite-release.aar Binary files differ diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /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 \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..a83c28a --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/svg/monitor.svg b/app/src/main/assets/svg/monitor.svg new file mode 100644 index 0000000..c8d3e25 --- /dev/null +++ b/app/src/main/assets/svg/monitor.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/msg.svg b/app/src/main/assets/svg/msg.svg new file mode 100644 index 0000000..e864e48 --- /dev/null +++ b/app/src/main/assets/svg/msg.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/statistics.svg b/app/src/main/assets/svg/statistics.svg new file mode 100644 index 0000000..974000e --- /dev/null +++ b/app/src/main/assets/svg/statistics.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt new file mode 100644 index 0000000..6b9cce0 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.adapter + +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentManager +import androidx.fragment.app.FragmentPagerAdapter + +class ViewPagerAdapter(list: ArrayList, manager: FragmentManager) : + FragmentPagerAdapter(manager) { + + private var pageList: List = list + + override fun getItem(position: Int) = pageList[position] + + override fun getCount() = pageList.size +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt new file mode 100644 index 0000000..4e017b1 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt @@ -0,0 +1,40 @@ +package com.casic.smart.town.sanxi.base + +import android.app.Application +import android.util.Log +import com.casic.smart.town.sanxi.greendao.DaoMaster +import com.casic.smart.town.sanxi.greendao.DaoSession +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + private val kTag = "BaseApplication" + + companion object { + private var instance: BaseApplication by Delegates.notNull() + + fun obtainInstance() = instance + + private lateinit var daoSession: DaoSession + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences(this) + //推送 + PushManager.getInstance().initialize(this) + PushManager.getInstance().setDebugLogger(this) { + Log.d(kTag, it) + } + val devOpenHelper = DaoMaster.DevOpenHelper(this, "SmartTown.db", null) + val daoMaster = DaoMaster(devOpenHelper.writableDatabase) + daoSession = daoMaster.newSession() + } + + fun obtainDaoSession(): DaoSession { + return daoSession + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java new file mode 100644 index 0000000..b8f67dc --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java @@ -0,0 +1,133 @@ +package com.casic.smart.town.sanxi.bean; + +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Generated; +import org.greenrobot.greendao.annotation.Id; +import org.greenrobot.greendao.annotation.Unique; + +@Entity +public class AlarmMessageLocaleBean { + @Id(autoincrement = true) + private Long id;//主键自增 + + @Unique + private String messageId; + private String appId; + private String clientId; + private String taskId; + private String userId; + private String title; + private String content; + private String deviceCode; + private String isRead;//0-未读,1-已读 + private String alarmTime; + + @Generated(hash = 566950134) + public AlarmMessageLocaleBean(Long id, String messageId, String appId, + String clientId, String taskId, String userId, String title, + String content, String deviceCode, String isRead, String alarmTime) { + this.id = id; + this.messageId = messageId; + this.appId = appId; + this.clientId = clientId; + this.taskId = taskId; + this.userId = userId; + this.title = title; + this.content = content; + this.deviceCode = deviceCode; + this.isRead = isRead; + this.alarmTime = alarmTime; + } + + @Generated(hash = 1737519562) + public AlarmMessageLocaleBean() { + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getMessageId() { + return this.messageId; + } + + public void setMessageId(String messageId) { + this.messageId = messageId; + } + + public String getAppId() { + return this.appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public String getClientId() { + return this.clientId; + } + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public String getTaskId() { + return this.taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getUserId() { + return this.userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getTitle() { + return this.title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return this.content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getDeviceCode() { + return this.deviceCode; + } + + public void setDeviceCode(String deviceCode) { + this.deviceCode = deviceCode; + } + + public String getIsRead() { + return this.isRead; + } + + public void setIsRead(String isRead) { + this.isRead = isRead; + } + + public String getAlarmTime() { + return this.alarmTime; + } + + public void setAlarmTime(String alarmTime) { + this.alarmTime = alarmTime; + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt new file mode 100644 index 0000000..650e201 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class AlarmPageFragment: KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_alarm + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt new file mode 100644 index 0000000..deac8ac --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt @@ -0,0 +1,76 @@ +package com.casic.smart.town.sanxi.fragment + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.Fragment +import com.amap.api.maps.AMap +import com.amap.api.maps.AMapOptions +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.view.MonitorRecordActivity +import com.pengxh.kt.lite.extensions.navigatePageTo +import com.pengxh.kt.lite.extensions.show +import kotlinx.android.synthetic.main.fragment_monitor.view.* + +class MonitorPageFragment : Fragment() { + + private val kTag = "HomePageFragment" + private lateinit var monitorView: View + private lateinit var aMap: AMap + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? + ): View { + monitorView = inflater.inflate(R.layout.fragment_monitor, container, false) + //地图初始化 + initMap(savedInstanceState) + + monitorView.rightOperateView.setOnClickListener { + requireContext().navigatePageTo() + } + return monitorView + } + + private fun initMap(savedInstanceState: Bundle?) { + monitorView.mapView.onCreate(savedInstanceState) + aMap = monitorView.mapView.map + aMap.mapType = AMap.MAP_TYPE_NORMAL + val uiSettings = aMap.uiSettings + uiSettings.isCompassEnabled = true + uiSettings.zoomPosition = AMapOptions.ZOOM_POSITION_RIGHT_CENTER + uiSettings.isTiltGesturesEnabled = false//不许地图随手势倾斜角度 + + // 地图加载成功监听 +// aMap.addOnMapLoadedListener(this) + // 地图缩放监听 +// aMap.addOnCameraChangeListener(this) + // marker 点击事件监听 +// aMap.addOnMarkerClickListener(this) + // 点击marker弹出自定义popup +// aMap.setInfoWindowAdapter(this) + //信息窗点击事件 +// aMap.addOnInfoWindowClickListener(this) + } + + /***以下是地图生命周期管理************************************************************************/ + override fun onResume() { + super.onResume() + monitorView.mapView.onResume() + } + + override fun onPause() { + super.onPause() + monitorView.mapView.onPause() + } + + override fun onSaveInstanceState(outState: Bundle) { + super.onSaveInstanceState(outState) + monitorView.mapView.onSaveInstanceState(outState) + } + + override fun onDestroy() { + super.onDestroy() + monitorView.mapView.onDestroy() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt new file mode 100644 index 0000000..e84df12 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class StatisticsPageFragment : KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_statistics + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java new file mode 100644 index 0000000..68d7901 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java @@ -0,0 +1,255 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.database.Cursor; +import android.database.sqlite.SQLiteStatement; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.Property; +import org.greenrobot.greendao.internal.DaoConfig; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseStatement; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * DAO for table "ALARM_MESSAGE_LOCALE_BEAN". +*/ +public class AlarmMessageLocaleBeanDao extends AbstractDao { + + public static final String TABLENAME = "ALARM_MESSAGE_LOCALE_BEAN"; + + /** + * Properties of entity AlarmMessageLocaleBean.
+ * Can be used for QueryBuilder and for referencing column names. + */ + public static class Properties { + public final static Property Id = new Property(0, Long.class, "id", true, "_id"); + public final static Property MessageId = new Property(1, String.class, "messageId", false, "MESSAGE_ID"); + public final static Property AppId = new Property(2, String.class, "appId", false, "APP_ID"); + public final static Property ClientId = new Property(3, String.class, "clientId", false, "CLIENT_ID"); + public final static Property TaskId = new Property(4, String.class, "taskId", false, "TASK_ID"); + public final static Property UserId = new Property(5, String.class, "userId", false, "USER_ID"); + public final static Property Title = new Property(6, String.class, "title", false, "TITLE"); + public final static Property Content = new Property(7, String.class, "content", false, "CONTENT"); + public final static Property DeviceCode = new Property(8, String.class, "deviceCode", false, "DEVICE_CODE"); + public final static Property IsRead = new Property(9, String.class, "isRead", false, "IS_READ"); + public final static Property AlarmTime = new Property(10, String.class, "alarmTime", false, "ALARM_TIME"); + } + + + public AlarmMessageLocaleBeanDao(DaoConfig config) { + super(config); + } + + public AlarmMessageLocaleBeanDao(DaoConfig config, DaoSession daoSession) { + super(config, daoSession); + } + + /** Creates the underlying database table. */ + public static void createTable(Database db, boolean ifNotExists) { + String constraint = ifNotExists? "IF NOT EXISTS ": ""; + db.execSQL("CREATE TABLE " + constraint + "\"ALARM_MESSAGE_LOCALE_BEAN\" (" + // + "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id + "\"MESSAGE_ID\" TEXT UNIQUE ," + // 1: messageId + "\"APP_ID\" TEXT," + // 2: appId + "\"CLIENT_ID\" TEXT," + // 3: clientId + "\"TASK_ID\" TEXT," + // 4: taskId + "\"USER_ID\" TEXT," + // 5: userId + "\"TITLE\" TEXT," + // 6: title + "\"CONTENT\" TEXT," + // 7: content + "\"DEVICE_CODE\" TEXT," + // 8: deviceCode + "\"IS_READ\" TEXT," + // 9: isRead + "\"ALARM_TIME\" TEXT);"); // 10: alarmTime + } + + /** Drops the underlying database table. */ + public static void dropTable(Database db, boolean ifExists) { + String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"ALARM_MESSAGE_LOCALE_BEAN\""; + db.execSQL(sql); + } + + @Override + protected final void bindValues(DatabaseStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + protected final void bindValues(SQLiteStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + public Long readKey(Cursor cursor, int offset) { + return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); + } + + @Override + public AlarmMessageLocaleBean readEntity(Cursor cursor, int offset) { + AlarmMessageLocaleBean entity = new AlarmMessageLocaleBean( // + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // messageId + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // appId + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // clientId + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // taskId + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // userId + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // title + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // content + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // deviceCode + cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // isRead + cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10) // alarmTime + ); + return entity; + } + + @Override + public void readEntity(Cursor cursor, AlarmMessageLocaleBean entity, int offset) { + entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); + entity.setMessageId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setAppId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setClientId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setTaskId(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); + entity.setUserId(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setTitle(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setContent(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); + entity.setDeviceCode(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); + entity.setIsRead(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9)); + entity.setAlarmTime(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); + } + + @Override + protected final Long updateKeyAfterInsert(AlarmMessageLocaleBean entity, long rowId) { + entity.setId(rowId); + return rowId; + } + + @Override + public Long getKey(AlarmMessageLocaleBean entity) { + if(entity != null) { + return entity.getId(); + } else { + return null; + } + } + + @Override + public boolean hasKey(AlarmMessageLocaleBean entity) { + return entity.getId() != null; + } + + @Override + protected final boolean isEntityUpdateable() { + return true; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java new file mode 100644 index 0000000..4222c40 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java @@ -0,0 +1,96 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.content.Context; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteDatabase.CursorFactory; +import android.util.Log; + +import org.greenrobot.greendao.AbstractDaoMaster; +import org.greenrobot.greendao.database.StandardDatabase; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseOpenHelper; +import org.greenrobot.greendao.identityscope.IdentityScopeType; + + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * Master of DAO (schema version 1): knows all DAOs. + */ +public class DaoMaster extends AbstractDaoMaster { + public static final int SCHEMA_VERSION = 1; + + /** Creates underlying database table using DAOs. */ + public static void createAllTables(Database db, boolean ifNotExists) { + AlarmMessageLocaleBeanDao.createTable(db, ifNotExists); + } + + /** Drops underlying database table using DAOs. */ + public static void dropAllTables(Database db, boolean ifExists) { + AlarmMessageLocaleBeanDao.dropTable(db, ifExists); + } + + /** + * WARNING: Drops all table on Upgrade! Use only during development. + * Convenience method using a {@link DevOpenHelper}. + */ + public static DaoSession newDevSession(Context context, String name) { + Database db = new DevOpenHelper(context, name).getWritableDb(); + DaoMaster daoMaster = new DaoMaster(db); + return daoMaster.newSession(); + } + + public DaoMaster(SQLiteDatabase db) { + this(new StandardDatabase(db)); + } + + public DaoMaster(Database db) { + super(db, SCHEMA_VERSION); + registerDaoClass(AlarmMessageLocaleBeanDao.class); + } + + public DaoSession newSession() { + return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); + } + + public DaoSession newSession(IdentityScopeType type) { + return new DaoSession(db, type, daoConfigMap); + } + + /** + * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} - + */ + public static abstract class OpenHelper extends DatabaseOpenHelper { + public OpenHelper(Context context, String name) { + super(context, name, SCHEMA_VERSION); + } + + public OpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory, SCHEMA_VERSION); + } + + @Override + public void onCreate(Database db) { + Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); + createAllTables(db, false); + } + } + + /** WARNING: Drops all table on Upgrade! Use only during development. */ + public static class DevOpenHelper extends OpenHelper { + public DevOpenHelper(Context context, String name) { + super(context, name); + } + + public DevOpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory); + } + + @Override + public void onUpgrade(Database db, int oldVersion, int newVersion) { + Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); + dropAllTables(db, true); + onCreate(db); + } + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java new file mode 100644 index 0000000..480ed84 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java @@ -0,0 +1,48 @@ +package com.casic.smart.town.sanxi.greendao; + +import java.util.Map; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.AbstractDaoSession; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.identityscope.IdentityScopeType; +import org.greenrobot.greendao.internal.DaoConfig; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. + +/** + * {@inheritDoc} + * + * @see org.greenrobot.greendao.AbstractDaoSession + */ +public class DaoSession extends AbstractDaoSession { + + private final DaoConfig alarmMessageLocaleBeanDaoConfig; + + private final AlarmMessageLocaleBeanDao alarmMessageLocaleBeanDao; + + public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> + daoConfigMap) { + super(db); + + alarmMessageLocaleBeanDaoConfig = daoConfigMap.get(AlarmMessageLocaleBeanDao.class).clone(); + alarmMessageLocaleBeanDaoConfig.initIdentityScope(type); + + alarmMessageLocaleBeanDao = new AlarmMessageLocaleBeanDao(alarmMessageLocaleBeanDaoConfig, this); + + registerDao(AlarmMessageLocaleBean.class, alarmMessageLocaleBeanDao); + } + + public void clear() { + alarmMessageLocaleBeanDaoConfig.clearIdentityScope(); + } + + public AlarmMessageLocaleBeanDao getAlarmMessageLocaleBeanDao() { + return alarmMessageLocaleBeanDao; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt new file mode 100644 index 0000000..875cb8c --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt @@ -0,0 +1,5 @@ +package com.casic.smart.town.sanxi.service + +import com.igexin.sdk.PushService + +class ApplicationPushService : PushService() \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..10cfdbf --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*.iml +.gradle +/local.properties +/.idea +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..a4cd2ca --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,101 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'org.greenrobot.greendao' + +android { +// signingConfigs { +// release { +// storeFile file('/Users/a203/Desktop/AndroidProjects/CasicSmartWell/app/CasicSmartWell.jks') +// storePassword '123456789' +// keyAlias 'key0' +// keyPassword '123456789' +// } +// } + compileSdkVersion 31 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.smart.town.sanxi" + minSdkVersion 23 + targetSdkVersion 31 + versionCode 1 + versionName "1.0.0" + + manifestPlaceholders = [GETUI_APPID: "A9V4DvwLcdAqkFCQuFyhq6"] + } + + buildTypes { + release { + minifyEnabled false +// signingConfig signingConfigs.release + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + + ndk { abiFilters "armeabi", "armeabi-v7a", "arm64-v8" } + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlin { + experimental { + coroutines 'enable' + } + } + + greendao { + schemaVersion 1//数据库版本号 + targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 + daoPackage 'com.casic.smart.town.sanxi.greendao'//设置DaoMaster、DaoSession、Dao包名 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + //基础依赖库 + implementation files('libs/lite-release.aar') + implementation 'androidx.appcompat:appcompat:1.4.2' + implementation 'androidx.core:core-ktx:1.8.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:3.0.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' + //MVVM+LiveData + implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.1" + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0" + implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + //Kotlin协程 + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1' + //图片加载框架 + implementation 'com.github.bumptech.glide:glide:4.9.0' + //返回值转换器 + implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' + implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + //okhttp3日志拦截器 + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //网络请求和接口封装 + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.9.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.9.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' + //高德地图 + implementation 'com.amap.api:3dmap:latest.integration' + //推送SDK + implementation 'com.getui:gtsdk:3.2.10.0' //个推SDK + implementation 'com.getui:gtc:3.1.9.0' //个推核心组件 + //数据库框架 + implementation 'org.greenrobot:greendao:3.3.0' + //桌面角标 + implementation "me.leolin:ShortcutBadger:1.1.22@aar" +} \ No newline at end of file diff --git a/app/libs/lite-release.aar b/app/libs/lite-release.aar new file mode 100644 index 0000000..45da4df --- /dev/null +++ b/app/libs/lite-release.aar Binary files differ diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /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 \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..a83c28a --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/svg/monitor.svg b/app/src/main/assets/svg/monitor.svg new file mode 100644 index 0000000..c8d3e25 --- /dev/null +++ b/app/src/main/assets/svg/monitor.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/msg.svg b/app/src/main/assets/svg/msg.svg new file mode 100644 index 0000000..e864e48 --- /dev/null +++ b/app/src/main/assets/svg/msg.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/statistics.svg b/app/src/main/assets/svg/statistics.svg new file mode 100644 index 0000000..974000e --- /dev/null +++ b/app/src/main/assets/svg/statistics.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt new file mode 100644 index 0000000..6b9cce0 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.adapter + +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentManager +import androidx.fragment.app.FragmentPagerAdapter + +class ViewPagerAdapter(list: ArrayList, manager: FragmentManager) : + FragmentPagerAdapter(manager) { + + private var pageList: List = list + + override fun getItem(position: Int) = pageList[position] + + override fun getCount() = pageList.size +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt new file mode 100644 index 0000000..4e017b1 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt @@ -0,0 +1,40 @@ +package com.casic.smart.town.sanxi.base + +import android.app.Application +import android.util.Log +import com.casic.smart.town.sanxi.greendao.DaoMaster +import com.casic.smart.town.sanxi.greendao.DaoSession +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + private val kTag = "BaseApplication" + + companion object { + private var instance: BaseApplication by Delegates.notNull() + + fun obtainInstance() = instance + + private lateinit var daoSession: DaoSession + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences(this) + //推送 + PushManager.getInstance().initialize(this) + PushManager.getInstance().setDebugLogger(this) { + Log.d(kTag, it) + } + val devOpenHelper = DaoMaster.DevOpenHelper(this, "SmartTown.db", null) + val daoMaster = DaoMaster(devOpenHelper.writableDatabase) + daoSession = daoMaster.newSession() + } + + fun obtainDaoSession(): DaoSession { + return daoSession + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java new file mode 100644 index 0000000..b8f67dc --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java @@ -0,0 +1,133 @@ +package com.casic.smart.town.sanxi.bean; + +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Generated; +import org.greenrobot.greendao.annotation.Id; +import org.greenrobot.greendao.annotation.Unique; + +@Entity +public class AlarmMessageLocaleBean { + @Id(autoincrement = true) + private Long id;//主键自增 + + @Unique + private String messageId; + private String appId; + private String clientId; + private String taskId; + private String userId; + private String title; + private String content; + private String deviceCode; + private String isRead;//0-未读,1-已读 + private String alarmTime; + + @Generated(hash = 566950134) + public AlarmMessageLocaleBean(Long id, String messageId, String appId, + String clientId, String taskId, String userId, String title, + String content, String deviceCode, String isRead, String alarmTime) { + this.id = id; + this.messageId = messageId; + this.appId = appId; + this.clientId = clientId; + this.taskId = taskId; + this.userId = userId; + this.title = title; + this.content = content; + this.deviceCode = deviceCode; + this.isRead = isRead; + this.alarmTime = alarmTime; + } + + @Generated(hash = 1737519562) + public AlarmMessageLocaleBean() { + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getMessageId() { + return this.messageId; + } + + public void setMessageId(String messageId) { + this.messageId = messageId; + } + + public String getAppId() { + return this.appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public String getClientId() { + return this.clientId; + } + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public String getTaskId() { + return this.taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getUserId() { + return this.userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getTitle() { + return this.title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return this.content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getDeviceCode() { + return this.deviceCode; + } + + public void setDeviceCode(String deviceCode) { + this.deviceCode = deviceCode; + } + + public String getIsRead() { + return this.isRead; + } + + public void setIsRead(String isRead) { + this.isRead = isRead; + } + + public String getAlarmTime() { + return this.alarmTime; + } + + public void setAlarmTime(String alarmTime) { + this.alarmTime = alarmTime; + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt new file mode 100644 index 0000000..650e201 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class AlarmPageFragment: KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_alarm + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt new file mode 100644 index 0000000..deac8ac --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt @@ -0,0 +1,76 @@ +package com.casic.smart.town.sanxi.fragment + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.Fragment +import com.amap.api.maps.AMap +import com.amap.api.maps.AMapOptions +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.view.MonitorRecordActivity +import com.pengxh.kt.lite.extensions.navigatePageTo +import com.pengxh.kt.lite.extensions.show +import kotlinx.android.synthetic.main.fragment_monitor.view.* + +class MonitorPageFragment : Fragment() { + + private val kTag = "HomePageFragment" + private lateinit var monitorView: View + private lateinit var aMap: AMap + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? + ): View { + monitorView = inflater.inflate(R.layout.fragment_monitor, container, false) + //地图初始化 + initMap(savedInstanceState) + + monitorView.rightOperateView.setOnClickListener { + requireContext().navigatePageTo() + } + return monitorView + } + + private fun initMap(savedInstanceState: Bundle?) { + monitorView.mapView.onCreate(savedInstanceState) + aMap = monitorView.mapView.map + aMap.mapType = AMap.MAP_TYPE_NORMAL + val uiSettings = aMap.uiSettings + uiSettings.isCompassEnabled = true + uiSettings.zoomPosition = AMapOptions.ZOOM_POSITION_RIGHT_CENTER + uiSettings.isTiltGesturesEnabled = false//不许地图随手势倾斜角度 + + // 地图加载成功监听 +// aMap.addOnMapLoadedListener(this) + // 地图缩放监听 +// aMap.addOnCameraChangeListener(this) + // marker 点击事件监听 +// aMap.addOnMarkerClickListener(this) + // 点击marker弹出自定义popup +// aMap.setInfoWindowAdapter(this) + //信息窗点击事件 +// aMap.addOnInfoWindowClickListener(this) + } + + /***以下是地图生命周期管理************************************************************************/ + override fun onResume() { + super.onResume() + monitorView.mapView.onResume() + } + + override fun onPause() { + super.onPause() + monitorView.mapView.onPause() + } + + override fun onSaveInstanceState(outState: Bundle) { + super.onSaveInstanceState(outState) + monitorView.mapView.onSaveInstanceState(outState) + } + + override fun onDestroy() { + super.onDestroy() + monitorView.mapView.onDestroy() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt new file mode 100644 index 0000000..e84df12 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class StatisticsPageFragment : KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_statistics + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java new file mode 100644 index 0000000..68d7901 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java @@ -0,0 +1,255 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.database.Cursor; +import android.database.sqlite.SQLiteStatement; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.Property; +import org.greenrobot.greendao.internal.DaoConfig; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseStatement; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * DAO for table "ALARM_MESSAGE_LOCALE_BEAN". +*/ +public class AlarmMessageLocaleBeanDao extends AbstractDao { + + public static final String TABLENAME = "ALARM_MESSAGE_LOCALE_BEAN"; + + /** + * Properties of entity AlarmMessageLocaleBean.
+ * Can be used for QueryBuilder and for referencing column names. + */ + public static class Properties { + public final static Property Id = new Property(0, Long.class, "id", true, "_id"); + public final static Property MessageId = new Property(1, String.class, "messageId", false, "MESSAGE_ID"); + public final static Property AppId = new Property(2, String.class, "appId", false, "APP_ID"); + public final static Property ClientId = new Property(3, String.class, "clientId", false, "CLIENT_ID"); + public final static Property TaskId = new Property(4, String.class, "taskId", false, "TASK_ID"); + public final static Property UserId = new Property(5, String.class, "userId", false, "USER_ID"); + public final static Property Title = new Property(6, String.class, "title", false, "TITLE"); + public final static Property Content = new Property(7, String.class, "content", false, "CONTENT"); + public final static Property DeviceCode = new Property(8, String.class, "deviceCode", false, "DEVICE_CODE"); + public final static Property IsRead = new Property(9, String.class, "isRead", false, "IS_READ"); + public final static Property AlarmTime = new Property(10, String.class, "alarmTime", false, "ALARM_TIME"); + } + + + public AlarmMessageLocaleBeanDao(DaoConfig config) { + super(config); + } + + public AlarmMessageLocaleBeanDao(DaoConfig config, DaoSession daoSession) { + super(config, daoSession); + } + + /** Creates the underlying database table. */ + public static void createTable(Database db, boolean ifNotExists) { + String constraint = ifNotExists? "IF NOT EXISTS ": ""; + db.execSQL("CREATE TABLE " + constraint + "\"ALARM_MESSAGE_LOCALE_BEAN\" (" + // + "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id + "\"MESSAGE_ID\" TEXT UNIQUE ," + // 1: messageId + "\"APP_ID\" TEXT," + // 2: appId + "\"CLIENT_ID\" TEXT," + // 3: clientId + "\"TASK_ID\" TEXT," + // 4: taskId + "\"USER_ID\" TEXT," + // 5: userId + "\"TITLE\" TEXT," + // 6: title + "\"CONTENT\" TEXT," + // 7: content + "\"DEVICE_CODE\" TEXT," + // 8: deviceCode + "\"IS_READ\" TEXT," + // 9: isRead + "\"ALARM_TIME\" TEXT);"); // 10: alarmTime + } + + /** Drops the underlying database table. */ + public static void dropTable(Database db, boolean ifExists) { + String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"ALARM_MESSAGE_LOCALE_BEAN\""; + db.execSQL(sql); + } + + @Override + protected final void bindValues(DatabaseStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + protected final void bindValues(SQLiteStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + public Long readKey(Cursor cursor, int offset) { + return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); + } + + @Override + public AlarmMessageLocaleBean readEntity(Cursor cursor, int offset) { + AlarmMessageLocaleBean entity = new AlarmMessageLocaleBean( // + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // messageId + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // appId + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // clientId + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // taskId + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // userId + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // title + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // content + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // deviceCode + cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // isRead + cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10) // alarmTime + ); + return entity; + } + + @Override + public void readEntity(Cursor cursor, AlarmMessageLocaleBean entity, int offset) { + entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); + entity.setMessageId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setAppId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setClientId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setTaskId(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); + entity.setUserId(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setTitle(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setContent(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); + entity.setDeviceCode(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); + entity.setIsRead(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9)); + entity.setAlarmTime(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); + } + + @Override + protected final Long updateKeyAfterInsert(AlarmMessageLocaleBean entity, long rowId) { + entity.setId(rowId); + return rowId; + } + + @Override + public Long getKey(AlarmMessageLocaleBean entity) { + if(entity != null) { + return entity.getId(); + } else { + return null; + } + } + + @Override + public boolean hasKey(AlarmMessageLocaleBean entity) { + return entity.getId() != null; + } + + @Override + protected final boolean isEntityUpdateable() { + return true; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java new file mode 100644 index 0000000..4222c40 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java @@ -0,0 +1,96 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.content.Context; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteDatabase.CursorFactory; +import android.util.Log; + +import org.greenrobot.greendao.AbstractDaoMaster; +import org.greenrobot.greendao.database.StandardDatabase; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseOpenHelper; +import org.greenrobot.greendao.identityscope.IdentityScopeType; + + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * Master of DAO (schema version 1): knows all DAOs. + */ +public class DaoMaster extends AbstractDaoMaster { + public static final int SCHEMA_VERSION = 1; + + /** Creates underlying database table using DAOs. */ + public static void createAllTables(Database db, boolean ifNotExists) { + AlarmMessageLocaleBeanDao.createTable(db, ifNotExists); + } + + /** Drops underlying database table using DAOs. */ + public static void dropAllTables(Database db, boolean ifExists) { + AlarmMessageLocaleBeanDao.dropTable(db, ifExists); + } + + /** + * WARNING: Drops all table on Upgrade! Use only during development. + * Convenience method using a {@link DevOpenHelper}. + */ + public static DaoSession newDevSession(Context context, String name) { + Database db = new DevOpenHelper(context, name).getWritableDb(); + DaoMaster daoMaster = new DaoMaster(db); + return daoMaster.newSession(); + } + + public DaoMaster(SQLiteDatabase db) { + this(new StandardDatabase(db)); + } + + public DaoMaster(Database db) { + super(db, SCHEMA_VERSION); + registerDaoClass(AlarmMessageLocaleBeanDao.class); + } + + public DaoSession newSession() { + return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); + } + + public DaoSession newSession(IdentityScopeType type) { + return new DaoSession(db, type, daoConfigMap); + } + + /** + * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} - + */ + public static abstract class OpenHelper extends DatabaseOpenHelper { + public OpenHelper(Context context, String name) { + super(context, name, SCHEMA_VERSION); + } + + public OpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory, SCHEMA_VERSION); + } + + @Override + public void onCreate(Database db) { + Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); + createAllTables(db, false); + } + } + + /** WARNING: Drops all table on Upgrade! Use only during development. */ + public static class DevOpenHelper extends OpenHelper { + public DevOpenHelper(Context context, String name) { + super(context, name); + } + + public DevOpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory); + } + + @Override + public void onUpgrade(Database db, int oldVersion, int newVersion) { + Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); + dropAllTables(db, true); + onCreate(db); + } + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java new file mode 100644 index 0000000..480ed84 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java @@ -0,0 +1,48 @@ +package com.casic.smart.town.sanxi.greendao; + +import java.util.Map; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.AbstractDaoSession; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.identityscope.IdentityScopeType; +import org.greenrobot.greendao.internal.DaoConfig; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. + +/** + * {@inheritDoc} + * + * @see org.greenrobot.greendao.AbstractDaoSession + */ +public class DaoSession extends AbstractDaoSession { + + private final DaoConfig alarmMessageLocaleBeanDaoConfig; + + private final AlarmMessageLocaleBeanDao alarmMessageLocaleBeanDao; + + public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> + daoConfigMap) { + super(db); + + alarmMessageLocaleBeanDaoConfig = daoConfigMap.get(AlarmMessageLocaleBeanDao.class).clone(); + alarmMessageLocaleBeanDaoConfig.initIdentityScope(type); + + alarmMessageLocaleBeanDao = new AlarmMessageLocaleBeanDao(alarmMessageLocaleBeanDaoConfig, this); + + registerDao(AlarmMessageLocaleBean.class, alarmMessageLocaleBeanDao); + } + + public void clear() { + alarmMessageLocaleBeanDaoConfig.clearIdentityScope(); + } + + public AlarmMessageLocaleBeanDao getAlarmMessageLocaleBeanDao() { + return alarmMessageLocaleBeanDao; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt new file mode 100644 index 0000000..875cb8c --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt @@ -0,0 +1,5 @@ +package com.casic.smart.town.sanxi.service + +import com.igexin.sdk.PushService + +class ApplicationPushService : PushService() \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt new file mode 100644 index 0000000..396129f --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt @@ -0,0 +1,84 @@ +package com.casic.smart.town.sanxi.service + +import android.content.Context +import android.os.Message +import android.util.Log +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.casic.smart.town.sanxi.view.MainActivity +import com.igexin.sdk.GTIntentService +import com.igexin.sdk.message.GTCmdMessage +import com.igexin.sdk.message.GTNotificationMessage +import com.igexin.sdk.message.GTTransmitMessage +import com.pengxh.kt.lite.extensions.toJson + +class PushIntentService : GTIntentService() { + + private val kTag = "SmartWellIntentService" + + override fun onReceiveServicePid(context: Context?, pid: Int) { + + } + + // 透传消息 + override fun onReceiveMessageData(context: Context?, msg: GTTransmitMessage?) { + Log.d(kTag, "透传消息 -> msg = $msg") + } + + // 接收 cid + override fun onReceiveClientId(context: Context?, clientid: String?) { + Log.d(kTag, "onReceiveClientId -> $clientid") + //通知MainActivity注册个推服务 + val msg: Message = MainActivity.weakReferenceHandler.obtainMessage() + msg.what = LocaleConstant.PUSH_REGISTER + msg.obj = clientid + MainActivity.weakReferenceHandler.sendMessage(msg) + } + + // cid 离线上线通知 + override fun onReceiveOnlineState(context: Context?, online: Boolean) { + + } + + // 各种事件处理回执 + override fun onReceiveCommandResult(context: Context?, msg: GTCmdMessage?) { + + } + + // 通知到达 + override fun onNotificationMessageArrived(context: Context?, msg: GTNotificationMessage?) { + //报警 +// { +// "content": "设备编号[412022030361]发生井盖开盖报警", +// "messageId": "380abf9a79d34306a2683dc9bf96ee78", +// "taskId": "OSL-0830_4hmfimp3Vu684wo3SjXso9", +// "title": "告警提醒", +// "appid": "HKv8K9qARd6WckZ1o2Vbu4", +// "clientId": "e78beacc42e9a02ae6fb9087eb2b1171", +// "pkgName": "com.casic.app.smartwell" +// } + if (msg == null) { + return + } + Log.d(kTag, "通知到达 -> msg = ${msg.toJson()}") +// val userDetailJson = SaveKeyValues.getValue(LocaleConstant.USER_DETAIL_MODEL, "") as String +// var userId = "" +// if (userDetailJson.isNotBlank()) { +// val userDataModel = Gson().fromJson( +// userDetailJson, object : TypeToken() {}.type +// ) +// userId = userDataModel.id.toString() +// } +// //解析编号 +// val splitArray = msg.content.split("\\[|\\]".toRegex()) +// DataBaseManager.instance.insertNotice( +// msg.messageId, msg.appid, msg.clientId, msg.taskId, +// userId, msg.title, msg.content, splitArray[1], "0", +// System.currentTimeMillis().timestampToCompleteDate() +// ) + } + + // 通知点击 + override fun onNotificationMessageClicked(context: Context?, msg: GTNotificationMessage?) { + Log.d(kTag, "通知点击 -> msg = $msg") + } +} \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..10cfdbf --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*.iml +.gradle +/local.properties +/.idea +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..a4cd2ca --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,101 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'org.greenrobot.greendao' + +android { +// signingConfigs { +// release { +// storeFile file('/Users/a203/Desktop/AndroidProjects/CasicSmartWell/app/CasicSmartWell.jks') +// storePassword '123456789' +// keyAlias 'key0' +// keyPassword '123456789' +// } +// } + compileSdkVersion 31 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.smart.town.sanxi" + minSdkVersion 23 + targetSdkVersion 31 + versionCode 1 + versionName "1.0.0" + + manifestPlaceholders = [GETUI_APPID: "A9V4DvwLcdAqkFCQuFyhq6"] + } + + buildTypes { + release { + minifyEnabled false +// signingConfig signingConfigs.release + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + + ndk { abiFilters "armeabi", "armeabi-v7a", "arm64-v8" } + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlin { + experimental { + coroutines 'enable' + } + } + + greendao { + schemaVersion 1//数据库版本号 + targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 + daoPackage 'com.casic.smart.town.sanxi.greendao'//设置DaoMaster、DaoSession、Dao包名 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + //基础依赖库 + implementation files('libs/lite-release.aar') + implementation 'androidx.appcompat:appcompat:1.4.2' + implementation 'androidx.core:core-ktx:1.8.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:3.0.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' + //MVVM+LiveData + implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.1" + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0" + implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + //Kotlin协程 + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1' + //图片加载框架 + implementation 'com.github.bumptech.glide:glide:4.9.0' + //返回值转换器 + implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' + implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + //okhttp3日志拦截器 + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //网络请求和接口封装 + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.9.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.9.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' + //高德地图 + implementation 'com.amap.api:3dmap:latest.integration' + //推送SDK + implementation 'com.getui:gtsdk:3.2.10.0' //个推SDK + implementation 'com.getui:gtc:3.1.9.0' //个推核心组件 + //数据库框架 + implementation 'org.greenrobot:greendao:3.3.0' + //桌面角标 + implementation "me.leolin:ShortcutBadger:1.1.22@aar" +} \ No newline at end of file diff --git a/app/libs/lite-release.aar b/app/libs/lite-release.aar new file mode 100644 index 0000000..45da4df --- /dev/null +++ b/app/libs/lite-release.aar Binary files differ diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /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 \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..a83c28a --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/svg/monitor.svg b/app/src/main/assets/svg/monitor.svg new file mode 100644 index 0000000..c8d3e25 --- /dev/null +++ b/app/src/main/assets/svg/monitor.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/msg.svg b/app/src/main/assets/svg/msg.svg new file mode 100644 index 0000000..e864e48 --- /dev/null +++ b/app/src/main/assets/svg/msg.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/statistics.svg b/app/src/main/assets/svg/statistics.svg new file mode 100644 index 0000000..974000e --- /dev/null +++ b/app/src/main/assets/svg/statistics.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt new file mode 100644 index 0000000..6b9cce0 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.adapter + +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentManager +import androidx.fragment.app.FragmentPagerAdapter + +class ViewPagerAdapter(list: ArrayList, manager: FragmentManager) : + FragmentPagerAdapter(manager) { + + private var pageList: List = list + + override fun getItem(position: Int) = pageList[position] + + override fun getCount() = pageList.size +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt new file mode 100644 index 0000000..4e017b1 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt @@ -0,0 +1,40 @@ +package com.casic.smart.town.sanxi.base + +import android.app.Application +import android.util.Log +import com.casic.smart.town.sanxi.greendao.DaoMaster +import com.casic.smart.town.sanxi.greendao.DaoSession +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + private val kTag = "BaseApplication" + + companion object { + private var instance: BaseApplication by Delegates.notNull() + + fun obtainInstance() = instance + + private lateinit var daoSession: DaoSession + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences(this) + //推送 + PushManager.getInstance().initialize(this) + PushManager.getInstance().setDebugLogger(this) { + Log.d(kTag, it) + } + val devOpenHelper = DaoMaster.DevOpenHelper(this, "SmartTown.db", null) + val daoMaster = DaoMaster(devOpenHelper.writableDatabase) + daoSession = daoMaster.newSession() + } + + fun obtainDaoSession(): DaoSession { + return daoSession + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java new file mode 100644 index 0000000..b8f67dc --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java @@ -0,0 +1,133 @@ +package com.casic.smart.town.sanxi.bean; + +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Generated; +import org.greenrobot.greendao.annotation.Id; +import org.greenrobot.greendao.annotation.Unique; + +@Entity +public class AlarmMessageLocaleBean { + @Id(autoincrement = true) + private Long id;//主键自增 + + @Unique + private String messageId; + private String appId; + private String clientId; + private String taskId; + private String userId; + private String title; + private String content; + private String deviceCode; + private String isRead;//0-未读,1-已读 + private String alarmTime; + + @Generated(hash = 566950134) + public AlarmMessageLocaleBean(Long id, String messageId, String appId, + String clientId, String taskId, String userId, String title, + String content, String deviceCode, String isRead, String alarmTime) { + this.id = id; + this.messageId = messageId; + this.appId = appId; + this.clientId = clientId; + this.taskId = taskId; + this.userId = userId; + this.title = title; + this.content = content; + this.deviceCode = deviceCode; + this.isRead = isRead; + this.alarmTime = alarmTime; + } + + @Generated(hash = 1737519562) + public AlarmMessageLocaleBean() { + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getMessageId() { + return this.messageId; + } + + public void setMessageId(String messageId) { + this.messageId = messageId; + } + + public String getAppId() { + return this.appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public String getClientId() { + return this.clientId; + } + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public String getTaskId() { + return this.taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getUserId() { + return this.userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getTitle() { + return this.title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return this.content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getDeviceCode() { + return this.deviceCode; + } + + public void setDeviceCode(String deviceCode) { + this.deviceCode = deviceCode; + } + + public String getIsRead() { + return this.isRead; + } + + public void setIsRead(String isRead) { + this.isRead = isRead; + } + + public String getAlarmTime() { + return this.alarmTime; + } + + public void setAlarmTime(String alarmTime) { + this.alarmTime = alarmTime; + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt new file mode 100644 index 0000000..650e201 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class AlarmPageFragment: KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_alarm + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt new file mode 100644 index 0000000..deac8ac --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt @@ -0,0 +1,76 @@ +package com.casic.smart.town.sanxi.fragment + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.Fragment +import com.amap.api.maps.AMap +import com.amap.api.maps.AMapOptions +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.view.MonitorRecordActivity +import com.pengxh.kt.lite.extensions.navigatePageTo +import com.pengxh.kt.lite.extensions.show +import kotlinx.android.synthetic.main.fragment_monitor.view.* + +class MonitorPageFragment : Fragment() { + + private val kTag = "HomePageFragment" + private lateinit var monitorView: View + private lateinit var aMap: AMap + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? + ): View { + monitorView = inflater.inflate(R.layout.fragment_monitor, container, false) + //地图初始化 + initMap(savedInstanceState) + + monitorView.rightOperateView.setOnClickListener { + requireContext().navigatePageTo() + } + return monitorView + } + + private fun initMap(savedInstanceState: Bundle?) { + monitorView.mapView.onCreate(savedInstanceState) + aMap = monitorView.mapView.map + aMap.mapType = AMap.MAP_TYPE_NORMAL + val uiSettings = aMap.uiSettings + uiSettings.isCompassEnabled = true + uiSettings.zoomPosition = AMapOptions.ZOOM_POSITION_RIGHT_CENTER + uiSettings.isTiltGesturesEnabled = false//不许地图随手势倾斜角度 + + // 地图加载成功监听 +// aMap.addOnMapLoadedListener(this) + // 地图缩放监听 +// aMap.addOnCameraChangeListener(this) + // marker 点击事件监听 +// aMap.addOnMarkerClickListener(this) + // 点击marker弹出自定义popup +// aMap.setInfoWindowAdapter(this) + //信息窗点击事件 +// aMap.addOnInfoWindowClickListener(this) + } + + /***以下是地图生命周期管理************************************************************************/ + override fun onResume() { + super.onResume() + monitorView.mapView.onResume() + } + + override fun onPause() { + super.onPause() + monitorView.mapView.onPause() + } + + override fun onSaveInstanceState(outState: Bundle) { + super.onSaveInstanceState(outState) + monitorView.mapView.onSaveInstanceState(outState) + } + + override fun onDestroy() { + super.onDestroy() + monitorView.mapView.onDestroy() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt new file mode 100644 index 0000000..e84df12 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class StatisticsPageFragment : KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_statistics + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java new file mode 100644 index 0000000..68d7901 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java @@ -0,0 +1,255 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.database.Cursor; +import android.database.sqlite.SQLiteStatement; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.Property; +import org.greenrobot.greendao.internal.DaoConfig; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseStatement; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * DAO for table "ALARM_MESSAGE_LOCALE_BEAN". +*/ +public class AlarmMessageLocaleBeanDao extends AbstractDao { + + public static final String TABLENAME = "ALARM_MESSAGE_LOCALE_BEAN"; + + /** + * Properties of entity AlarmMessageLocaleBean.
+ * Can be used for QueryBuilder and for referencing column names. + */ + public static class Properties { + public final static Property Id = new Property(0, Long.class, "id", true, "_id"); + public final static Property MessageId = new Property(1, String.class, "messageId", false, "MESSAGE_ID"); + public final static Property AppId = new Property(2, String.class, "appId", false, "APP_ID"); + public final static Property ClientId = new Property(3, String.class, "clientId", false, "CLIENT_ID"); + public final static Property TaskId = new Property(4, String.class, "taskId", false, "TASK_ID"); + public final static Property UserId = new Property(5, String.class, "userId", false, "USER_ID"); + public final static Property Title = new Property(6, String.class, "title", false, "TITLE"); + public final static Property Content = new Property(7, String.class, "content", false, "CONTENT"); + public final static Property DeviceCode = new Property(8, String.class, "deviceCode", false, "DEVICE_CODE"); + public final static Property IsRead = new Property(9, String.class, "isRead", false, "IS_READ"); + public final static Property AlarmTime = new Property(10, String.class, "alarmTime", false, "ALARM_TIME"); + } + + + public AlarmMessageLocaleBeanDao(DaoConfig config) { + super(config); + } + + public AlarmMessageLocaleBeanDao(DaoConfig config, DaoSession daoSession) { + super(config, daoSession); + } + + /** Creates the underlying database table. */ + public static void createTable(Database db, boolean ifNotExists) { + String constraint = ifNotExists? "IF NOT EXISTS ": ""; + db.execSQL("CREATE TABLE " + constraint + "\"ALARM_MESSAGE_LOCALE_BEAN\" (" + // + "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id + "\"MESSAGE_ID\" TEXT UNIQUE ," + // 1: messageId + "\"APP_ID\" TEXT," + // 2: appId + "\"CLIENT_ID\" TEXT," + // 3: clientId + "\"TASK_ID\" TEXT," + // 4: taskId + "\"USER_ID\" TEXT," + // 5: userId + "\"TITLE\" TEXT," + // 6: title + "\"CONTENT\" TEXT," + // 7: content + "\"DEVICE_CODE\" TEXT," + // 8: deviceCode + "\"IS_READ\" TEXT," + // 9: isRead + "\"ALARM_TIME\" TEXT);"); // 10: alarmTime + } + + /** Drops the underlying database table. */ + public static void dropTable(Database db, boolean ifExists) { + String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"ALARM_MESSAGE_LOCALE_BEAN\""; + db.execSQL(sql); + } + + @Override + protected final void bindValues(DatabaseStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + protected final void bindValues(SQLiteStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + public Long readKey(Cursor cursor, int offset) { + return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); + } + + @Override + public AlarmMessageLocaleBean readEntity(Cursor cursor, int offset) { + AlarmMessageLocaleBean entity = new AlarmMessageLocaleBean( // + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // messageId + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // appId + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // clientId + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // taskId + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // userId + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // title + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // content + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // deviceCode + cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // isRead + cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10) // alarmTime + ); + return entity; + } + + @Override + public void readEntity(Cursor cursor, AlarmMessageLocaleBean entity, int offset) { + entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); + entity.setMessageId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setAppId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setClientId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setTaskId(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); + entity.setUserId(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setTitle(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setContent(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); + entity.setDeviceCode(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); + entity.setIsRead(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9)); + entity.setAlarmTime(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); + } + + @Override + protected final Long updateKeyAfterInsert(AlarmMessageLocaleBean entity, long rowId) { + entity.setId(rowId); + return rowId; + } + + @Override + public Long getKey(AlarmMessageLocaleBean entity) { + if(entity != null) { + return entity.getId(); + } else { + return null; + } + } + + @Override + public boolean hasKey(AlarmMessageLocaleBean entity) { + return entity.getId() != null; + } + + @Override + protected final boolean isEntityUpdateable() { + return true; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java new file mode 100644 index 0000000..4222c40 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java @@ -0,0 +1,96 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.content.Context; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteDatabase.CursorFactory; +import android.util.Log; + +import org.greenrobot.greendao.AbstractDaoMaster; +import org.greenrobot.greendao.database.StandardDatabase; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseOpenHelper; +import org.greenrobot.greendao.identityscope.IdentityScopeType; + + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * Master of DAO (schema version 1): knows all DAOs. + */ +public class DaoMaster extends AbstractDaoMaster { + public static final int SCHEMA_VERSION = 1; + + /** Creates underlying database table using DAOs. */ + public static void createAllTables(Database db, boolean ifNotExists) { + AlarmMessageLocaleBeanDao.createTable(db, ifNotExists); + } + + /** Drops underlying database table using DAOs. */ + public static void dropAllTables(Database db, boolean ifExists) { + AlarmMessageLocaleBeanDao.dropTable(db, ifExists); + } + + /** + * WARNING: Drops all table on Upgrade! Use only during development. + * Convenience method using a {@link DevOpenHelper}. + */ + public static DaoSession newDevSession(Context context, String name) { + Database db = new DevOpenHelper(context, name).getWritableDb(); + DaoMaster daoMaster = new DaoMaster(db); + return daoMaster.newSession(); + } + + public DaoMaster(SQLiteDatabase db) { + this(new StandardDatabase(db)); + } + + public DaoMaster(Database db) { + super(db, SCHEMA_VERSION); + registerDaoClass(AlarmMessageLocaleBeanDao.class); + } + + public DaoSession newSession() { + return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); + } + + public DaoSession newSession(IdentityScopeType type) { + return new DaoSession(db, type, daoConfigMap); + } + + /** + * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} - + */ + public static abstract class OpenHelper extends DatabaseOpenHelper { + public OpenHelper(Context context, String name) { + super(context, name, SCHEMA_VERSION); + } + + public OpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory, SCHEMA_VERSION); + } + + @Override + public void onCreate(Database db) { + Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); + createAllTables(db, false); + } + } + + /** WARNING: Drops all table on Upgrade! Use only during development. */ + public static class DevOpenHelper extends OpenHelper { + public DevOpenHelper(Context context, String name) { + super(context, name); + } + + public DevOpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory); + } + + @Override + public void onUpgrade(Database db, int oldVersion, int newVersion) { + Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); + dropAllTables(db, true); + onCreate(db); + } + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java new file mode 100644 index 0000000..480ed84 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java @@ -0,0 +1,48 @@ +package com.casic.smart.town.sanxi.greendao; + +import java.util.Map; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.AbstractDaoSession; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.identityscope.IdentityScopeType; +import org.greenrobot.greendao.internal.DaoConfig; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. + +/** + * {@inheritDoc} + * + * @see org.greenrobot.greendao.AbstractDaoSession + */ +public class DaoSession extends AbstractDaoSession { + + private final DaoConfig alarmMessageLocaleBeanDaoConfig; + + private final AlarmMessageLocaleBeanDao alarmMessageLocaleBeanDao; + + public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> + daoConfigMap) { + super(db); + + alarmMessageLocaleBeanDaoConfig = daoConfigMap.get(AlarmMessageLocaleBeanDao.class).clone(); + alarmMessageLocaleBeanDaoConfig.initIdentityScope(type); + + alarmMessageLocaleBeanDao = new AlarmMessageLocaleBeanDao(alarmMessageLocaleBeanDaoConfig, this); + + registerDao(AlarmMessageLocaleBean.class, alarmMessageLocaleBeanDao); + } + + public void clear() { + alarmMessageLocaleBeanDaoConfig.clearIdentityScope(); + } + + public AlarmMessageLocaleBeanDao getAlarmMessageLocaleBeanDao() { + return alarmMessageLocaleBeanDao; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt new file mode 100644 index 0000000..875cb8c --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt @@ -0,0 +1,5 @@ +package com.casic.smart.town.sanxi.service + +import com.igexin.sdk.PushService + +class ApplicationPushService : PushService() \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt new file mode 100644 index 0000000..396129f --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt @@ -0,0 +1,84 @@ +package com.casic.smart.town.sanxi.service + +import android.content.Context +import android.os.Message +import android.util.Log +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.casic.smart.town.sanxi.view.MainActivity +import com.igexin.sdk.GTIntentService +import com.igexin.sdk.message.GTCmdMessage +import com.igexin.sdk.message.GTNotificationMessage +import com.igexin.sdk.message.GTTransmitMessage +import com.pengxh.kt.lite.extensions.toJson + +class PushIntentService : GTIntentService() { + + private val kTag = "SmartWellIntentService" + + override fun onReceiveServicePid(context: Context?, pid: Int) { + + } + + // 透传消息 + override fun onReceiveMessageData(context: Context?, msg: GTTransmitMessage?) { + Log.d(kTag, "透传消息 -> msg = $msg") + } + + // 接收 cid + override fun onReceiveClientId(context: Context?, clientid: String?) { + Log.d(kTag, "onReceiveClientId -> $clientid") + //通知MainActivity注册个推服务 + val msg: Message = MainActivity.weakReferenceHandler.obtainMessage() + msg.what = LocaleConstant.PUSH_REGISTER + msg.obj = clientid + MainActivity.weakReferenceHandler.sendMessage(msg) + } + + // cid 离线上线通知 + override fun onReceiveOnlineState(context: Context?, online: Boolean) { + + } + + // 各种事件处理回执 + override fun onReceiveCommandResult(context: Context?, msg: GTCmdMessage?) { + + } + + // 通知到达 + override fun onNotificationMessageArrived(context: Context?, msg: GTNotificationMessage?) { + //报警 +// { +// "content": "设备编号[412022030361]发生井盖开盖报警", +// "messageId": "380abf9a79d34306a2683dc9bf96ee78", +// "taskId": "OSL-0830_4hmfimp3Vu684wo3SjXso9", +// "title": "告警提醒", +// "appid": "HKv8K9qARd6WckZ1o2Vbu4", +// "clientId": "e78beacc42e9a02ae6fb9087eb2b1171", +// "pkgName": "com.casic.app.smartwell" +// } + if (msg == null) { + return + } + Log.d(kTag, "通知到达 -> msg = ${msg.toJson()}") +// val userDetailJson = SaveKeyValues.getValue(LocaleConstant.USER_DETAIL_MODEL, "") as String +// var userId = "" +// if (userDetailJson.isNotBlank()) { +// val userDataModel = Gson().fromJson( +// userDetailJson, object : TypeToken() {}.type +// ) +// userId = userDataModel.id.toString() +// } +// //解析编号 +// val splitArray = msg.content.split("\\[|\\]".toRegex()) +// DataBaseManager.instance.insertNotice( +// msg.messageId, msg.appid, msg.clientId, msg.taskId, +// userId, msg.title, msg.content, splitArray[1], "0", +// System.currentTimeMillis().timestampToCompleteDate() +// ) + } + + // 通知点击 + override fun onNotificationMessageClicked(context: Context?, msg: GTNotificationMessage?) { + Log.d(kTag, "通知点击 -> msg = $msg") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt new file mode 100644 index 0000000..daa7c38 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt @@ -0,0 +1,14 @@ +package com.casic.smart.town.sanxi.util + +import android.content.Context +import me.leolin.shortcutbadger.ShortcutBadger + +object BadeHelper { + fun setBadgeNum(context: Context, badgeCount: Int) { + if (badgeCount == 0) { + ShortcutBadger.removeCount(context) + } else { + ShortcutBadger.applyCount(context, badgeCount) + } + } +} \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..10cfdbf --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*.iml +.gradle +/local.properties +/.idea +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..a4cd2ca --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,101 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'org.greenrobot.greendao' + +android { +// signingConfigs { +// release { +// storeFile file('/Users/a203/Desktop/AndroidProjects/CasicSmartWell/app/CasicSmartWell.jks') +// storePassword '123456789' +// keyAlias 'key0' +// keyPassword '123456789' +// } +// } + compileSdkVersion 31 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.smart.town.sanxi" + minSdkVersion 23 + targetSdkVersion 31 + versionCode 1 + versionName "1.0.0" + + manifestPlaceholders = [GETUI_APPID: "A9V4DvwLcdAqkFCQuFyhq6"] + } + + buildTypes { + release { + minifyEnabled false +// signingConfig signingConfigs.release + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + + ndk { abiFilters "armeabi", "armeabi-v7a", "arm64-v8" } + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlin { + experimental { + coroutines 'enable' + } + } + + greendao { + schemaVersion 1//数据库版本号 + targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 + daoPackage 'com.casic.smart.town.sanxi.greendao'//设置DaoMaster、DaoSession、Dao包名 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + //基础依赖库 + implementation files('libs/lite-release.aar') + implementation 'androidx.appcompat:appcompat:1.4.2' + implementation 'androidx.core:core-ktx:1.8.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:3.0.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' + //MVVM+LiveData + implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.1" + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0" + implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + //Kotlin协程 + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1' + //图片加载框架 + implementation 'com.github.bumptech.glide:glide:4.9.0' + //返回值转换器 + implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' + implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + //okhttp3日志拦截器 + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //网络请求和接口封装 + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.9.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.9.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' + //高德地图 + implementation 'com.amap.api:3dmap:latest.integration' + //推送SDK + implementation 'com.getui:gtsdk:3.2.10.0' //个推SDK + implementation 'com.getui:gtc:3.1.9.0' //个推核心组件 + //数据库框架 + implementation 'org.greenrobot:greendao:3.3.0' + //桌面角标 + implementation "me.leolin:ShortcutBadger:1.1.22@aar" +} \ No newline at end of file diff --git a/app/libs/lite-release.aar b/app/libs/lite-release.aar new file mode 100644 index 0000000..45da4df --- /dev/null +++ b/app/libs/lite-release.aar Binary files differ diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /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 \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..a83c28a --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/svg/monitor.svg b/app/src/main/assets/svg/monitor.svg new file mode 100644 index 0000000..c8d3e25 --- /dev/null +++ b/app/src/main/assets/svg/monitor.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/msg.svg b/app/src/main/assets/svg/msg.svg new file mode 100644 index 0000000..e864e48 --- /dev/null +++ b/app/src/main/assets/svg/msg.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/statistics.svg b/app/src/main/assets/svg/statistics.svg new file mode 100644 index 0000000..974000e --- /dev/null +++ b/app/src/main/assets/svg/statistics.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt new file mode 100644 index 0000000..6b9cce0 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.adapter + +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentManager +import androidx.fragment.app.FragmentPagerAdapter + +class ViewPagerAdapter(list: ArrayList, manager: FragmentManager) : + FragmentPagerAdapter(manager) { + + private var pageList: List = list + + override fun getItem(position: Int) = pageList[position] + + override fun getCount() = pageList.size +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt new file mode 100644 index 0000000..4e017b1 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt @@ -0,0 +1,40 @@ +package com.casic.smart.town.sanxi.base + +import android.app.Application +import android.util.Log +import com.casic.smart.town.sanxi.greendao.DaoMaster +import com.casic.smart.town.sanxi.greendao.DaoSession +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + private val kTag = "BaseApplication" + + companion object { + private var instance: BaseApplication by Delegates.notNull() + + fun obtainInstance() = instance + + private lateinit var daoSession: DaoSession + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences(this) + //推送 + PushManager.getInstance().initialize(this) + PushManager.getInstance().setDebugLogger(this) { + Log.d(kTag, it) + } + val devOpenHelper = DaoMaster.DevOpenHelper(this, "SmartTown.db", null) + val daoMaster = DaoMaster(devOpenHelper.writableDatabase) + daoSession = daoMaster.newSession() + } + + fun obtainDaoSession(): DaoSession { + return daoSession + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java new file mode 100644 index 0000000..b8f67dc --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java @@ -0,0 +1,133 @@ +package com.casic.smart.town.sanxi.bean; + +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Generated; +import org.greenrobot.greendao.annotation.Id; +import org.greenrobot.greendao.annotation.Unique; + +@Entity +public class AlarmMessageLocaleBean { + @Id(autoincrement = true) + private Long id;//主键自增 + + @Unique + private String messageId; + private String appId; + private String clientId; + private String taskId; + private String userId; + private String title; + private String content; + private String deviceCode; + private String isRead;//0-未读,1-已读 + private String alarmTime; + + @Generated(hash = 566950134) + public AlarmMessageLocaleBean(Long id, String messageId, String appId, + String clientId, String taskId, String userId, String title, + String content, String deviceCode, String isRead, String alarmTime) { + this.id = id; + this.messageId = messageId; + this.appId = appId; + this.clientId = clientId; + this.taskId = taskId; + this.userId = userId; + this.title = title; + this.content = content; + this.deviceCode = deviceCode; + this.isRead = isRead; + this.alarmTime = alarmTime; + } + + @Generated(hash = 1737519562) + public AlarmMessageLocaleBean() { + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getMessageId() { + return this.messageId; + } + + public void setMessageId(String messageId) { + this.messageId = messageId; + } + + public String getAppId() { + return this.appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public String getClientId() { + return this.clientId; + } + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public String getTaskId() { + return this.taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getUserId() { + return this.userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getTitle() { + return this.title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return this.content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getDeviceCode() { + return this.deviceCode; + } + + public void setDeviceCode(String deviceCode) { + this.deviceCode = deviceCode; + } + + public String getIsRead() { + return this.isRead; + } + + public void setIsRead(String isRead) { + this.isRead = isRead; + } + + public String getAlarmTime() { + return this.alarmTime; + } + + public void setAlarmTime(String alarmTime) { + this.alarmTime = alarmTime; + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt new file mode 100644 index 0000000..650e201 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class AlarmPageFragment: KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_alarm + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt new file mode 100644 index 0000000..deac8ac --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt @@ -0,0 +1,76 @@ +package com.casic.smart.town.sanxi.fragment + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.Fragment +import com.amap.api.maps.AMap +import com.amap.api.maps.AMapOptions +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.view.MonitorRecordActivity +import com.pengxh.kt.lite.extensions.navigatePageTo +import com.pengxh.kt.lite.extensions.show +import kotlinx.android.synthetic.main.fragment_monitor.view.* + +class MonitorPageFragment : Fragment() { + + private val kTag = "HomePageFragment" + private lateinit var monitorView: View + private lateinit var aMap: AMap + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? + ): View { + monitorView = inflater.inflate(R.layout.fragment_monitor, container, false) + //地图初始化 + initMap(savedInstanceState) + + monitorView.rightOperateView.setOnClickListener { + requireContext().navigatePageTo() + } + return monitorView + } + + private fun initMap(savedInstanceState: Bundle?) { + monitorView.mapView.onCreate(savedInstanceState) + aMap = monitorView.mapView.map + aMap.mapType = AMap.MAP_TYPE_NORMAL + val uiSettings = aMap.uiSettings + uiSettings.isCompassEnabled = true + uiSettings.zoomPosition = AMapOptions.ZOOM_POSITION_RIGHT_CENTER + uiSettings.isTiltGesturesEnabled = false//不许地图随手势倾斜角度 + + // 地图加载成功监听 +// aMap.addOnMapLoadedListener(this) + // 地图缩放监听 +// aMap.addOnCameraChangeListener(this) + // marker 点击事件监听 +// aMap.addOnMarkerClickListener(this) + // 点击marker弹出自定义popup +// aMap.setInfoWindowAdapter(this) + //信息窗点击事件 +// aMap.addOnInfoWindowClickListener(this) + } + + /***以下是地图生命周期管理************************************************************************/ + override fun onResume() { + super.onResume() + monitorView.mapView.onResume() + } + + override fun onPause() { + super.onPause() + monitorView.mapView.onPause() + } + + override fun onSaveInstanceState(outState: Bundle) { + super.onSaveInstanceState(outState) + monitorView.mapView.onSaveInstanceState(outState) + } + + override fun onDestroy() { + super.onDestroy() + monitorView.mapView.onDestroy() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt new file mode 100644 index 0000000..e84df12 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class StatisticsPageFragment : KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_statistics + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java new file mode 100644 index 0000000..68d7901 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java @@ -0,0 +1,255 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.database.Cursor; +import android.database.sqlite.SQLiteStatement; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.Property; +import org.greenrobot.greendao.internal.DaoConfig; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseStatement; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * DAO for table "ALARM_MESSAGE_LOCALE_BEAN". +*/ +public class AlarmMessageLocaleBeanDao extends AbstractDao { + + public static final String TABLENAME = "ALARM_MESSAGE_LOCALE_BEAN"; + + /** + * Properties of entity AlarmMessageLocaleBean.
+ * Can be used for QueryBuilder and for referencing column names. + */ + public static class Properties { + public final static Property Id = new Property(0, Long.class, "id", true, "_id"); + public final static Property MessageId = new Property(1, String.class, "messageId", false, "MESSAGE_ID"); + public final static Property AppId = new Property(2, String.class, "appId", false, "APP_ID"); + public final static Property ClientId = new Property(3, String.class, "clientId", false, "CLIENT_ID"); + public final static Property TaskId = new Property(4, String.class, "taskId", false, "TASK_ID"); + public final static Property UserId = new Property(5, String.class, "userId", false, "USER_ID"); + public final static Property Title = new Property(6, String.class, "title", false, "TITLE"); + public final static Property Content = new Property(7, String.class, "content", false, "CONTENT"); + public final static Property DeviceCode = new Property(8, String.class, "deviceCode", false, "DEVICE_CODE"); + public final static Property IsRead = new Property(9, String.class, "isRead", false, "IS_READ"); + public final static Property AlarmTime = new Property(10, String.class, "alarmTime", false, "ALARM_TIME"); + } + + + public AlarmMessageLocaleBeanDao(DaoConfig config) { + super(config); + } + + public AlarmMessageLocaleBeanDao(DaoConfig config, DaoSession daoSession) { + super(config, daoSession); + } + + /** Creates the underlying database table. */ + public static void createTable(Database db, boolean ifNotExists) { + String constraint = ifNotExists? "IF NOT EXISTS ": ""; + db.execSQL("CREATE TABLE " + constraint + "\"ALARM_MESSAGE_LOCALE_BEAN\" (" + // + "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id + "\"MESSAGE_ID\" TEXT UNIQUE ," + // 1: messageId + "\"APP_ID\" TEXT," + // 2: appId + "\"CLIENT_ID\" TEXT," + // 3: clientId + "\"TASK_ID\" TEXT," + // 4: taskId + "\"USER_ID\" TEXT," + // 5: userId + "\"TITLE\" TEXT," + // 6: title + "\"CONTENT\" TEXT," + // 7: content + "\"DEVICE_CODE\" TEXT," + // 8: deviceCode + "\"IS_READ\" TEXT," + // 9: isRead + "\"ALARM_TIME\" TEXT);"); // 10: alarmTime + } + + /** Drops the underlying database table. */ + public static void dropTable(Database db, boolean ifExists) { + String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"ALARM_MESSAGE_LOCALE_BEAN\""; + db.execSQL(sql); + } + + @Override + protected final void bindValues(DatabaseStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + protected final void bindValues(SQLiteStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + public Long readKey(Cursor cursor, int offset) { + return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); + } + + @Override + public AlarmMessageLocaleBean readEntity(Cursor cursor, int offset) { + AlarmMessageLocaleBean entity = new AlarmMessageLocaleBean( // + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // messageId + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // appId + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // clientId + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // taskId + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // userId + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // title + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // content + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // deviceCode + cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // isRead + cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10) // alarmTime + ); + return entity; + } + + @Override + public void readEntity(Cursor cursor, AlarmMessageLocaleBean entity, int offset) { + entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); + entity.setMessageId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setAppId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setClientId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setTaskId(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); + entity.setUserId(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setTitle(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setContent(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); + entity.setDeviceCode(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); + entity.setIsRead(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9)); + entity.setAlarmTime(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); + } + + @Override + protected final Long updateKeyAfterInsert(AlarmMessageLocaleBean entity, long rowId) { + entity.setId(rowId); + return rowId; + } + + @Override + public Long getKey(AlarmMessageLocaleBean entity) { + if(entity != null) { + return entity.getId(); + } else { + return null; + } + } + + @Override + public boolean hasKey(AlarmMessageLocaleBean entity) { + return entity.getId() != null; + } + + @Override + protected final boolean isEntityUpdateable() { + return true; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java new file mode 100644 index 0000000..4222c40 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java @@ -0,0 +1,96 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.content.Context; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteDatabase.CursorFactory; +import android.util.Log; + +import org.greenrobot.greendao.AbstractDaoMaster; +import org.greenrobot.greendao.database.StandardDatabase; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseOpenHelper; +import org.greenrobot.greendao.identityscope.IdentityScopeType; + + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * Master of DAO (schema version 1): knows all DAOs. + */ +public class DaoMaster extends AbstractDaoMaster { + public static final int SCHEMA_VERSION = 1; + + /** Creates underlying database table using DAOs. */ + public static void createAllTables(Database db, boolean ifNotExists) { + AlarmMessageLocaleBeanDao.createTable(db, ifNotExists); + } + + /** Drops underlying database table using DAOs. */ + public static void dropAllTables(Database db, boolean ifExists) { + AlarmMessageLocaleBeanDao.dropTable(db, ifExists); + } + + /** + * WARNING: Drops all table on Upgrade! Use only during development. + * Convenience method using a {@link DevOpenHelper}. + */ + public static DaoSession newDevSession(Context context, String name) { + Database db = new DevOpenHelper(context, name).getWritableDb(); + DaoMaster daoMaster = new DaoMaster(db); + return daoMaster.newSession(); + } + + public DaoMaster(SQLiteDatabase db) { + this(new StandardDatabase(db)); + } + + public DaoMaster(Database db) { + super(db, SCHEMA_VERSION); + registerDaoClass(AlarmMessageLocaleBeanDao.class); + } + + public DaoSession newSession() { + return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); + } + + public DaoSession newSession(IdentityScopeType type) { + return new DaoSession(db, type, daoConfigMap); + } + + /** + * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} - + */ + public static abstract class OpenHelper extends DatabaseOpenHelper { + public OpenHelper(Context context, String name) { + super(context, name, SCHEMA_VERSION); + } + + public OpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory, SCHEMA_VERSION); + } + + @Override + public void onCreate(Database db) { + Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); + createAllTables(db, false); + } + } + + /** WARNING: Drops all table on Upgrade! Use only during development. */ + public static class DevOpenHelper extends OpenHelper { + public DevOpenHelper(Context context, String name) { + super(context, name); + } + + public DevOpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory); + } + + @Override + public void onUpgrade(Database db, int oldVersion, int newVersion) { + Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); + dropAllTables(db, true); + onCreate(db); + } + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java new file mode 100644 index 0000000..480ed84 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java @@ -0,0 +1,48 @@ +package com.casic.smart.town.sanxi.greendao; + +import java.util.Map; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.AbstractDaoSession; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.identityscope.IdentityScopeType; +import org.greenrobot.greendao.internal.DaoConfig; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. + +/** + * {@inheritDoc} + * + * @see org.greenrobot.greendao.AbstractDaoSession + */ +public class DaoSession extends AbstractDaoSession { + + private final DaoConfig alarmMessageLocaleBeanDaoConfig; + + private final AlarmMessageLocaleBeanDao alarmMessageLocaleBeanDao; + + public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> + daoConfigMap) { + super(db); + + alarmMessageLocaleBeanDaoConfig = daoConfigMap.get(AlarmMessageLocaleBeanDao.class).clone(); + alarmMessageLocaleBeanDaoConfig.initIdentityScope(type); + + alarmMessageLocaleBeanDao = new AlarmMessageLocaleBeanDao(alarmMessageLocaleBeanDaoConfig, this); + + registerDao(AlarmMessageLocaleBean.class, alarmMessageLocaleBeanDao); + } + + public void clear() { + alarmMessageLocaleBeanDaoConfig.clearIdentityScope(); + } + + public AlarmMessageLocaleBeanDao getAlarmMessageLocaleBeanDao() { + return alarmMessageLocaleBeanDao; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt new file mode 100644 index 0000000..875cb8c --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt @@ -0,0 +1,5 @@ +package com.casic.smart.town.sanxi.service + +import com.igexin.sdk.PushService + +class ApplicationPushService : PushService() \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt new file mode 100644 index 0000000..396129f --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt @@ -0,0 +1,84 @@ +package com.casic.smart.town.sanxi.service + +import android.content.Context +import android.os.Message +import android.util.Log +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.casic.smart.town.sanxi.view.MainActivity +import com.igexin.sdk.GTIntentService +import com.igexin.sdk.message.GTCmdMessage +import com.igexin.sdk.message.GTNotificationMessage +import com.igexin.sdk.message.GTTransmitMessage +import com.pengxh.kt.lite.extensions.toJson + +class PushIntentService : GTIntentService() { + + private val kTag = "SmartWellIntentService" + + override fun onReceiveServicePid(context: Context?, pid: Int) { + + } + + // 透传消息 + override fun onReceiveMessageData(context: Context?, msg: GTTransmitMessage?) { + Log.d(kTag, "透传消息 -> msg = $msg") + } + + // 接收 cid + override fun onReceiveClientId(context: Context?, clientid: String?) { + Log.d(kTag, "onReceiveClientId -> $clientid") + //通知MainActivity注册个推服务 + val msg: Message = MainActivity.weakReferenceHandler.obtainMessage() + msg.what = LocaleConstant.PUSH_REGISTER + msg.obj = clientid + MainActivity.weakReferenceHandler.sendMessage(msg) + } + + // cid 离线上线通知 + override fun onReceiveOnlineState(context: Context?, online: Boolean) { + + } + + // 各种事件处理回执 + override fun onReceiveCommandResult(context: Context?, msg: GTCmdMessage?) { + + } + + // 通知到达 + override fun onNotificationMessageArrived(context: Context?, msg: GTNotificationMessage?) { + //报警 +// { +// "content": "设备编号[412022030361]发生井盖开盖报警", +// "messageId": "380abf9a79d34306a2683dc9bf96ee78", +// "taskId": "OSL-0830_4hmfimp3Vu684wo3SjXso9", +// "title": "告警提醒", +// "appid": "HKv8K9qARd6WckZ1o2Vbu4", +// "clientId": "e78beacc42e9a02ae6fb9087eb2b1171", +// "pkgName": "com.casic.app.smartwell" +// } + if (msg == null) { + return + } + Log.d(kTag, "通知到达 -> msg = ${msg.toJson()}") +// val userDetailJson = SaveKeyValues.getValue(LocaleConstant.USER_DETAIL_MODEL, "") as String +// var userId = "" +// if (userDetailJson.isNotBlank()) { +// val userDataModel = Gson().fromJson( +// userDetailJson, object : TypeToken() {}.type +// ) +// userId = userDataModel.id.toString() +// } +// //解析编号 +// val splitArray = msg.content.split("\\[|\\]".toRegex()) +// DataBaseManager.instance.insertNotice( +// msg.messageId, msg.appid, msg.clientId, msg.taskId, +// userId, msg.title, msg.content, splitArray[1], "0", +// System.currentTimeMillis().timestampToCompleteDate() +// ) + } + + // 通知点击 + override fun onNotificationMessageClicked(context: Context?, msg: GTNotificationMessage?) { + Log.d(kTag, "通知点击 -> msg = $msg") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt new file mode 100644 index 0000000..daa7c38 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt @@ -0,0 +1,14 @@ +package com.casic.smart.town.sanxi.util + +import android.content.Context +import me.leolin.shortcutbadger.ShortcutBadger + +object BadeHelper { + fun setBadgeNum(context: Context, badgeCount: Int) { + if (badgeCount == 0) { + ShortcutBadger.removeCount(context) + } else { + ShortcutBadger.applyCount(context, badgeCount) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt new file mode 100644 index 0000000..0a52ef2 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt @@ -0,0 +1,75 @@ +package com.casic.smart.town.sanxi.util + +import com.casic.smart.town.sanxi.base.BaseApplication +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao + +class DataBaseManager private constructor() { + + companion object { + //Kotlin委托模式双重锁单例 + val instance: DataBaseManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) { + DataBaseManager() + } + } + + private val beanDao = + BaseApplication.obtainInstance().obtainDaoSession().alarmMessageLocaleBeanDao + +// fun insertNotice( +// messageId: String, appid: String, clientId: String, +// taskId: String, userId: String, title: String, +// content: String, deviceCode: String, isRead: String, +// noticeTime: String +// ) { +// val noticeLocaleBean = NoticeLocaleBean() +// noticeLocaleBean.messageId = messageId +// noticeLocaleBean.appid = appid +// noticeLocaleBean.clientId = clientId +// noticeLocaleBean.taskId = taskId +// noticeLocaleBean.userId = userId +// noticeLocaleBean.title = title +// noticeLocaleBean.content = content +// noticeLocaleBean.deviceCode = deviceCode +// noticeLocaleBean.isRead = isRead +// noticeLocaleBean.noticeTime = noticeTime +// beanDao.insert(noticeLocaleBean) +// //角标设置 +// BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadNotice()) +// } + + fun deleteByMessageId(messageId: String) { + val result = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).list() + beanDao.deleteInTx(result) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun updateNoticeByMessageId(messageId: String) { + val noticeLocaleBean = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).unique() ?: return + noticeLocaleBean.isRead = "1" + beanDao.update(noticeLocaleBean) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun queryMessageByPage(userId: String, offset: Int): MutableList { + return BaseApplication.obtainInstance().obtainDaoSession() + .queryBuilder(AlarmMessageLocaleBean::class.java) + .where(AlarmMessageLocaleBeanDao.Properties.UserId.eq(userId)) + .offset(offset * LocaleConstant.PAGE_LIMIT) + .orderDesc(AlarmMessageLocaleBeanDao.Properties.AlarmTime) + .limit(LocaleConstant.PAGE_LIMIT) + .list() + } + + private fun queryUnReadMessage(): Int { + return beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.IsRead.eq("0") + ).list().size + } +} \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..10cfdbf --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*.iml +.gradle +/local.properties +/.idea +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..a4cd2ca --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,101 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'org.greenrobot.greendao' + +android { +// signingConfigs { +// release { +// storeFile file('/Users/a203/Desktop/AndroidProjects/CasicSmartWell/app/CasicSmartWell.jks') +// storePassword '123456789' +// keyAlias 'key0' +// keyPassword '123456789' +// } +// } + compileSdkVersion 31 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.smart.town.sanxi" + minSdkVersion 23 + targetSdkVersion 31 + versionCode 1 + versionName "1.0.0" + + manifestPlaceholders = [GETUI_APPID: "A9V4DvwLcdAqkFCQuFyhq6"] + } + + buildTypes { + release { + minifyEnabled false +// signingConfig signingConfigs.release + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + + ndk { abiFilters "armeabi", "armeabi-v7a", "arm64-v8" } + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlin { + experimental { + coroutines 'enable' + } + } + + greendao { + schemaVersion 1//数据库版本号 + targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 + daoPackage 'com.casic.smart.town.sanxi.greendao'//设置DaoMaster、DaoSession、Dao包名 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + //基础依赖库 + implementation files('libs/lite-release.aar') + implementation 'androidx.appcompat:appcompat:1.4.2' + implementation 'androidx.core:core-ktx:1.8.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:3.0.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' + //MVVM+LiveData + implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.1" + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0" + implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + //Kotlin协程 + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1' + //图片加载框架 + implementation 'com.github.bumptech.glide:glide:4.9.0' + //返回值转换器 + implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' + implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + //okhttp3日志拦截器 + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //网络请求和接口封装 + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.9.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.9.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' + //高德地图 + implementation 'com.amap.api:3dmap:latest.integration' + //推送SDK + implementation 'com.getui:gtsdk:3.2.10.0' //个推SDK + implementation 'com.getui:gtc:3.1.9.0' //个推核心组件 + //数据库框架 + implementation 'org.greenrobot:greendao:3.3.0' + //桌面角标 + implementation "me.leolin:ShortcutBadger:1.1.22@aar" +} \ No newline at end of file diff --git a/app/libs/lite-release.aar b/app/libs/lite-release.aar new file mode 100644 index 0000000..45da4df --- /dev/null +++ b/app/libs/lite-release.aar Binary files differ diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /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 \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..a83c28a --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/svg/monitor.svg b/app/src/main/assets/svg/monitor.svg new file mode 100644 index 0000000..c8d3e25 --- /dev/null +++ b/app/src/main/assets/svg/monitor.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/msg.svg b/app/src/main/assets/svg/msg.svg new file mode 100644 index 0000000..e864e48 --- /dev/null +++ b/app/src/main/assets/svg/msg.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/statistics.svg b/app/src/main/assets/svg/statistics.svg new file mode 100644 index 0000000..974000e --- /dev/null +++ b/app/src/main/assets/svg/statistics.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt new file mode 100644 index 0000000..6b9cce0 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.adapter + +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentManager +import androidx.fragment.app.FragmentPagerAdapter + +class ViewPagerAdapter(list: ArrayList, manager: FragmentManager) : + FragmentPagerAdapter(manager) { + + private var pageList: List = list + + override fun getItem(position: Int) = pageList[position] + + override fun getCount() = pageList.size +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt new file mode 100644 index 0000000..4e017b1 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt @@ -0,0 +1,40 @@ +package com.casic.smart.town.sanxi.base + +import android.app.Application +import android.util.Log +import com.casic.smart.town.sanxi.greendao.DaoMaster +import com.casic.smart.town.sanxi.greendao.DaoSession +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + private val kTag = "BaseApplication" + + companion object { + private var instance: BaseApplication by Delegates.notNull() + + fun obtainInstance() = instance + + private lateinit var daoSession: DaoSession + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences(this) + //推送 + PushManager.getInstance().initialize(this) + PushManager.getInstance().setDebugLogger(this) { + Log.d(kTag, it) + } + val devOpenHelper = DaoMaster.DevOpenHelper(this, "SmartTown.db", null) + val daoMaster = DaoMaster(devOpenHelper.writableDatabase) + daoSession = daoMaster.newSession() + } + + fun obtainDaoSession(): DaoSession { + return daoSession + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java new file mode 100644 index 0000000..b8f67dc --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java @@ -0,0 +1,133 @@ +package com.casic.smart.town.sanxi.bean; + +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Generated; +import org.greenrobot.greendao.annotation.Id; +import org.greenrobot.greendao.annotation.Unique; + +@Entity +public class AlarmMessageLocaleBean { + @Id(autoincrement = true) + private Long id;//主键自增 + + @Unique + private String messageId; + private String appId; + private String clientId; + private String taskId; + private String userId; + private String title; + private String content; + private String deviceCode; + private String isRead;//0-未读,1-已读 + private String alarmTime; + + @Generated(hash = 566950134) + public AlarmMessageLocaleBean(Long id, String messageId, String appId, + String clientId, String taskId, String userId, String title, + String content, String deviceCode, String isRead, String alarmTime) { + this.id = id; + this.messageId = messageId; + this.appId = appId; + this.clientId = clientId; + this.taskId = taskId; + this.userId = userId; + this.title = title; + this.content = content; + this.deviceCode = deviceCode; + this.isRead = isRead; + this.alarmTime = alarmTime; + } + + @Generated(hash = 1737519562) + public AlarmMessageLocaleBean() { + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getMessageId() { + return this.messageId; + } + + public void setMessageId(String messageId) { + this.messageId = messageId; + } + + public String getAppId() { + return this.appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public String getClientId() { + return this.clientId; + } + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public String getTaskId() { + return this.taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getUserId() { + return this.userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getTitle() { + return this.title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return this.content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getDeviceCode() { + return this.deviceCode; + } + + public void setDeviceCode(String deviceCode) { + this.deviceCode = deviceCode; + } + + public String getIsRead() { + return this.isRead; + } + + public void setIsRead(String isRead) { + this.isRead = isRead; + } + + public String getAlarmTime() { + return this.alarmTime; + } + + public void setAlarmTime(String alarmTime) { + this.alarmTime = alarmTime; + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt new file mode 100644 index 0000000..650e201 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class AlarmPageFragment: KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_alarm + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt new file mode 100644 index 0000000..deac8ac --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt @@ -0,0 +1,76 @@ +package com.casic.smart.town.sanxi.fragment + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.Fragment +import com.amap.api.maps.AMap +import com.amap.api.maps.AMapOptions +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.view.MonitorRecordActivity +import com.pengxh.kt.lite.extensions.navigatePageTo +import com.pengxh.kt.lite.extensions.show +import kotlinx.android.synthetic.main.fragment_monitor.view.* + +class MonitorPageFragment : Fragment() { + + private val kTag = "HomePageFragment" + private lateinit var monitorView: View + private lateinit var aMap: AMap + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? + ): View { + monitorView = inflater.inflate(R.layout.fragment_monitor, container, false) + //地图初始化 + initMap(savedInstanceState) + + monitorView.rightOperateView.setOnClickListener { + requireContext().navigatePageTo() + } + return monitorView + } + + private fun initMap(savedInstanceState: Bundle?) { + monitorView.mapView.onCreate(savedInstanceState) + aMap = monitorView.mapView.map + aMap.mapType = AMap.MAP_TYPE_NORMAL + val uiSettings = aMap.uiSettings + uiSettings.isCompassEnabled = true + uiSettings.zoomPosition = AMapOptions.ZOOM_POSITION_RIGHT_CENTER + uiSettings.isTiltGesturesEnabled = false//不许地图随手势倾斜角度 + + // 地图加载成功监听 +// aMap.addOnMapLoadedListener(this) + // 地图缩放监听 +// aMap.addOnCameraChangeListener(this) + // marker 点击事件监听 +// aMap.addOnMarkerClickListener(this) + // 点击marker弹出自定义popup +// aMap.setInfoWindowAdapter(this) + //信息窗点击事件 +// aMap.addOnInfoWindowClickListener(this) + } + + /***以下是地图生命周期管理************************************************************************/ + override fun onResume() { + super.onResume() + monitorView.mapView.onResume() + } + + override fun onPause() { + super.onPause() + monitorView.mapView.onPause() + } + + override fun onSaveInstanceState(outState: Bundle) { + super.onSaveInstanceState(outState) + monitorView.mapView.onSaveInstanceState(outState) + } + + override fun onDestroy() { + super.onDestroy() + monitorView.mapView.onDestroy() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt new file mode 100644 index 0000000..e84df12 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class StatisticsPageFragment : KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_statistics + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java new file mode 100644 index 0000000..68d7901 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java @@ -0,0 +1,255 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.database.Cursor; +import android.database.sqlite.SQLiteStatement; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.Property; +import org.greenrobot.greendao.internal.DaoConfig; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseStatement; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * DAO for table "ALARM_MESSAGE_LOCALE_BEAN". +*/ +public class AlarmMessageLocaleBeanDao extends AbstractDao { + + public static final String TABLENAME = "ALARM_MESSAGE_LOCALE_BEAN"; + + /** + * Properties of entity AlarmMessageLocaleBean.
+ * Can be used for QueryBuilder and for referencing column names. + */ + public static class Properties { + public final static Property Id = new Property(0, Long.class, "id", true, "_id"); + public final static Property MessageId = new Property(1, String.class, "messageId", false, "MESSAGE_ID"); + public final static Property AppId = new Property(2, String.class, "appId", false, "APP_ID"); + public final static Property ClientId = new Property(3, String.class, "clientId", false, "CLIENT_ID"); + public final static Property TaskId = new Property(4, String.class, "taskId", false, "TASK_ID"); + public final static Property UserId = new Property(5, String.class, "userId", false, "USER_ID"); + public final static Property Title = new Property(6, String.class, "title", false, "TITLE"); + public final static Property Content = new Property(7, String.class, "content", false, "CONTENT"); + public final static Property DeviceCode = new Property(8, String.class, "deviceCode", false, "DEVICE_CODE"); + public final static Property IsRead = new Property(9, String.class, "isRead", false, "IS_READ"); + public final static Property AlarmTime = new Property(10, String.class, "alarmTime", false, "ALARM_TIME"); + } + + + public AlarmMessageLocaleBeanDao(DaoConfig config) { + super(config); + } + + public AlarmMessageLocaleBeanDao(DaoConfig config, DaoSession daoSession) { + super(config, daoSession); + } + + /** Creates the underlying database table. */ + public static void createTable(Database db, boolean ifNotExists) { + String constraint = ifNotExists? "IF NOT EXISTS ": ""; + db.execSQL("CREATE TABLE " + constraint + "\"ALARM_MESSAGE_LOCALE_BEAN\" (" + // + "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id + "\"MESSAGE_ID\" TEXT UNIQUE ," + // 1: messageId + "\"APP_ID\" TEXT," + // 2: appId + "\"CLIENT_ID\" TEXT," + // 3: clientId + "\"TASK_ID\" TEXT," + // 4: taskId + "\"USER_ID\" TEXT," + // 5: userId + "\"TITLE\" TEXT," + // 6: title + "\"CONTENT\" TEXT," + // 7: content + "\"DEVICE_CODE\" TEXT," + // 8: deviceCode + "\"IS_READ\" TEXT," + // 9: isRead + "\"ALARM_TIME\" TEXT);"); // 10: alarmTime + } + + /** Drops the underlying database table. */ + public static void dropTable(Database db, boolean ifExists) { + String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"ALARM_MESSAGE_LOCALE_BEAN\""; + db.execSQL(sql); + } + + @Override + protected final void bindValues(DatabaseStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + protected final void bindValues(SQLiteStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + public Long readKey(Cursor cursor, int offset) { + return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); + } + + @Override + public AlarmMessageLocaleBean readEntity(Cursor cursor, int offset) { + AlarmMessageLocaleBean entity = new AlarmMessageLocaleBean( // + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // messageId + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // appId + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // clientId + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // taskId + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // userId + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // title + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // content + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // deviceCode + cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // isRead + cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10) // alarmTime + ); + return entity; + } + + @Override + public void readEntity(Cursor cursor, AlarmMessageLocaleBean entity, int offset) { + entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); + entity.setMessageId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setAppId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setClientId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setTaskId(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); + entity.setUserId(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setTitle(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setContent(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); + entity.setDeviceCode(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); + entity.setIsRead(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9)); + entity.setAlarmTime(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); + } + + @Override + protected final Long updateKeyAfterInsert(AlarmMessageLocaleBean entity, long rowId) { + entity.setId(rowId); + return rowId; + } + + @Override + public Long getKey(AlarmMessageLocaleBean entity) { + if(entity != null) { + return entity.getId(); + } else { + return null; + } + } + + @Override + public boolean hasKey(AlarmMessageLocaleBean entity) { + return entity.getId() != null; + } + + @Override + protected final boolean isEntityUpdateable() { + return true; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java new file mode 100644 index 0000000..4222c40 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java @@ -0,0 +1,96 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.content.Context; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteDatabase.CursorFactory; +import android.util.Log; + +import org.greenrobot.greendao.AbstractDaoMaster; +import org.greenrobot.greendao.database.StandardDatabase; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseOpenHelper; +import org.greenrobot.greendao.identityscope.IdentityScopeType; + + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * Master of DAO (schema version 1): knows all DAOs. + */ +public class DaoMaster extends AbstractDaoMaster { + public static final int SCHEMA_VERSION = 1; + + /** Creates underlying database table using DAOs. */ + public static void createAllTables(Database db, boolean ifNotExists) { + AlarmMessageLocaleBeanDao.createTable(db, ifNotExists); + } + + /** Drops underlying database table using DAOs. */ + public static void dropAllTables(Database db, boolean ifExists) { + AlarmMessageLocaleBeanDao.dropTable(db, ifExists); + } + + /** + * WARNING: Drops all table on Upgrade! Use only during development. + * Convenience method using a {@link DevOpenHelper}. + */ + public static DaoSession newDevSession(Context context, String name) { + Database db = new DevOpenHelper(context, name).getWritableDb(); + DaoMaster daoMaster = new DaoMaster(db); + return daoMaster.newSession(); + } + + public DaoMaster(SQLiteDatabase db) { + this(new StandardDatabase(db)); + } + + public DaoMaster(Database db) { + super(db, SCHEMA_VERSION); + registerDaoClass(AlarmMessageLocaleBeanDao.class); + } + + public DaoSession newSession() { + return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); + } + + public DaoSession newSession(IdentityScopeType type) { + return new DaoSession(db, type, daoConfigMap); + } + + /** + * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} - + */ + public static abstract class OpenHelper extends DatabaseOpenHelper { + public OpenHelper(Context context, String name) { + super(context, name, SCHEMA_VERSION); + } + + public OpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory, SCHEMA_VERSION); + } + + @Override + public void onCreate(Database db) { + Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); + createAllTables(db, false); + } + } + + /** WARNING: Drops all table on Upgrade! Use only during development. */ + public static class DevOpenHelper extends OpenHelper { + public DevOpenHelper(Context context, String name) { + super(context, name); + } + + public DevOpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory); + } + + @Override + public void onUpgrade(Database db, int oldVersion, int newVersion) { + Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); + dropAllTables(db, true); + onCreate(db); + } + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java new file mode 100644 index 0000000..480ed84 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java @@ -0,0 +1,48 @@ +package com.casic.smart.town.sanxi.greendao; + +import java.util.Map; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.AbstractDaoSession; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.identityscope.IdentityScopeType; +import org.greenrobot.greendao.internal.DaoConfig; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. + +/** + * {@inheritDoc} + * + * @see org.greenrobot.greendao.AbstractDaoSession + */ +public class DaoSession extends AbstractDaoSession { + + private final DaoConfig alarmMessageLocaleBeanDaoConfig; + + private final AlarmMessageLocaleBeanDao alarmMessageLocaleBeanDao; + + public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> + daoConfigMap) { + super(db); + + alarmMessageLocaleBeanDaoConfig = daoConfigMap.get(AlarmMessageLocaleBeanDao.class).clone(); + alarmMessageLocaleBeanDaoConfig.initIdentityScope(type); + + alarmMessageLocaleBeanDao = new AlarmMessageLocaleBeanDao(alarmMessageLocaleBeanDaoConfig, this); + + registerDao(AlarmMessageLocaleBean.class, alarmMessageLocaleBeanDao); + } + + public void clear() { + alarmMessageLocaleBeanDaoConfig.clearIdentityScope(); + } + + public AlarmMessageLocaleBeanDao getAlarmMessageLocaleBeanDao() { + return alarmMessageLocaleBeanDao; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt new file mode 100644 index 0000000..875cb8c --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt @@ -0,0 +1,5 @@ +package com.casic.smart.town.sanxi.service + +import com.igexin.sdk.PushService + +class ApplicationPushService : PushService() \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt new file mode 100644 index 0000000..396129f --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt @@ -0,0 +1,84 @@ +package com.casic.smart.town.sanxi.service + +import android.content.Context +import android.os.Message +import android.util.Log +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.casic.smart.town.sanxi.view.MainActivity +import com.igexin.sdk.GTIntentService +import com.igexin.sdk.message.GTCmdMessage +import com.igexin.sdk.message.GTNotificationMessage +import com.igexin.sdk.message.GTTransmitMessage +import com.pengxh.kt.lite.extensions.toJson + +class PushIntentService : GTIntentService() { + + private val kTag = "SmartWellIntentService" + + override fun onReceiveServicePid(context: Context?, pid: Int) { + + } + + // 透传消息 + override fun onReceiveMessageData(context: Context?, msg: GTTransmitMessage?) { + Log.d(kTag, "透传消息 -> msg = $msg") + } + + // 接收 cid + override fun onReceiveClientId(context: Context?, clientid: String?) { + Log.d(kTag, "onReceiveClientId -> $clientid") + //通知MainActivity注册个推服务 + val msg: Message = MainActivity.weakReferenceHandler.obtainMessage() + msg.what = LocaleConstant.PUSH_REGISTER + msg.obj = clientid + MainActivity.weakReferenceHandler.sendMessage(msg) + } + + // cid 离线上线通知 + override fun onReceiveOnlineState(context: Context?, online: Boolean) { + + } + + // 各种事件处理回执 + override fun onReceiveCommandResult(context: Context?, msg: GTCmdMessage?) { + + } + + // 通知到达 + override fun onNotificationMessageArrived(context: Context?, msg: GTNotificationMessage?) { + //报警 +// { +// "content": "设备编号[412022030361]发生井盖开盖报警", +// "messageId": "380abf9a79d34306a2683dc9bf96ee78", +// "taskId": "OSL-0830_4hmfimp3Vu684wo3SjXso9", +// "title": "告警提醒", +// "appid": "HKv8K9qARd6WckZ1o2Vbu4", +// "clientId": "e78beacc42e9a02ae6fb9087eb2b1171", +// "pkgName": "com.casic.app.smartwell" +// } + if (msg == null) { + return + } + Log.d(kTag, "通知到达 -> msg = ${msg.toJson()}") +// val userDetailJson = SaveKeyValues.getValue(LocaleConstant.USER_DETAIL_MODEL, "") as String +// var userId = "" +// if (userDetailJson.isNotBlank()) { +// val userDataModel = Gson().fromJson( +// userDetailJson, object : TypeToken() {}.type +// ) +// userId = userDataModel.id.toString() +// } +// //解析编号 +// val splitArray = msg.content.split("\\[|\\]".toRegex()) +// DataBaseManager.instance.insertNotice( +// msg.messageId, msg.appid, msg.clientId, msg.taskId, +// userId, msg.title, msg.content, splitArray[1], "0", +// System.currentTimeMillis().timestampToCompleteDate() +// ) + } + + // 通知点击 + override fun onNotificationMessageClicked(context: Context?, msg: GTNotificationMessage?) { + Log.d(kTag, "通知点击 -> msg = $msg") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt new file mode 100644 index 0000000..daa7c38 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt @@ -0,0 +1,14 @@ +package com.casic.smart.town.sanxi.util + +import android.content.Context +import me.leolin.shortcutbadger.ShortcutBadger + +object BadeHelper { + fun setBadgeNum(context: Context, badgeCount: Int) { + if (badgeCount == 0) { + ShortcutBadger.removeCount(context) + } else { + ShortcutBadger.applyCount(context, badgeCount) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt new file mode 100644 index 0000000..0a52ef2 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt @@ -0,0 +1,75 @@ +package com.casic.smart.town.sanxi.util + +import com.casic.smart.town.sanxi.base.BaseApplication +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao + +class DataBaseManager private constructor() { + + companion object { + //Kotlin委托模式双重锁单例 + val instance: DataBaseManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) { + DataBaseManager() + } + } + + private val beanDao = + BaseApplication.obtainInstance().obtainDaoSession().alarmMessageLocaleBeanDao + +// fun insertNotice( +// messageId: String, appid: String, clientId: String, +// taskId: String, userId: String, title: String, +// content: String, deviceCode: String, isRead: String, +// noticeTime: String +// ) { +// val noticeLocaleBean = NoticeLocaleBean() +// noticeLocaleBean.messageId = messageId +// noticeLocaleBean.appid = appid +// noticeLocaleBean.clientId = clientId +// noticeLocaleBean.taskId = taskId +// noticeLocaleBean.userId = userId +// noticeLocaleBean.title = title +// noticeLocaleBean.content = content +// noticeLocaleBean.deviceCode = deviceCode +// noticeLocaleBean.isRead = isRead +// noticeLocaleBean.noticeTime = noticeTime +// beanDao.insert(noticeLocaleBean) +// //角标设置 +// BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadNotice()) +// } + + fun deleteByMessageId(messageId: String) { + val result = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).list() + beanDao.deleteInTx(result) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun updateNoticeByMessageId(messageId: String) { + val noticeLocaleBean = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).unique() ?: return + noticeLocaleBean.isRead = "1" + beanDao.update(noticeLocaleBean) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun queryMessageByPage(userId: String, offset: Int): MutableList { + return BaseApplication.obtainInstance().obtainDaoSession() + .queryBuilder(AlarmMessageLocaleBean::class.java) + .where(AlarmMessageLocaleBeanDao.Properties.UserId.eq(userId)) + .offset(offset * LocaleConstant.PAGE_LIMIT) + .orderDesc(AlarmMessageLocaleBeanDao.Properties.AlarmTime) + .limit(LocaleConstant.PAGE_LIMIT) + .list() + } + + private fun queryUnReadMessage(): Int { + return beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.IsRead.eq("0") + ).list().size + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt new file mode 100644 index 0000000..52926a8 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt @@ -0,0 +1,31 @@ +package com.casic.smart.town.sanxi.util; + +import android.app.Activity +import android.view.WindowManager +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object LoadingDialogHub { + private lateinit var loadingDialog: QMUITipDialog + + fun show(activity: Activity, message: String) { + loadingDialog = QMUITipDialog + .Builder(activity) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_LOADING) + .setTipWord(message) + .create() + if (!activity.isDestroyed) { + try { + loadingDialog.show() + } catch (e: WindowManager.BadTokenException) { + e.printStackTrace() + } + } + } + + + fun dismiss() { + if (loadingDialog.isShowing) { + loadingDialog.dismiss() + } + } +} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..10cfdbf --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*.iml +.gradle +/local.properties +/.idea +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..a4cd2ca --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,101 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'org.greenrobot.greendao' + +android { +// signingConfigs { +// release { +// storeFile file('/Users/a203/Desktop/AndroidProjects/CasicSmartWell/app/CasicSmartWell.jks') +// storePassword '123456789' +// keyAlias 'key0' +// keyPassword '123456789' +// } +// } + compileSdkVersion 31 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.smart.town.sanxi" + minSdkVersion 23 + targetSdkVersion 31 + versionCode 1 + versionName "1.0.0" + + manifestPlaceholders = [GETUI_APPID: "A9V4DvwLcdAqkFCQuFyhq6"] + } + + buildTypes { + release { + minifyEnabled false +// signingConfig signingConfigs.release + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + + ndk { abiFilters "armeabi", "armeabi-v7a", "arm64-v8" } + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlin { + experimental { + coroutines 'enable' + } + } + + greendao { + schemaVersion 1//数据库版本号 + targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 + daoPackage 'com.casic.smart.town.sanxi.greendao'//设置DaoMaster、DaoSession、Dao包名 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + //基础依赖库 + implementation files('libs/lite-release.aar') + implementation 'androidx.appcompat:appcompat:1.4.2' + implementation 'androidx.core:core-ktx:1.8.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:3.0.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' + //MVVM+LiveData + implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.1" + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0" + implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + //Kotlin协程 + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1' + //图片加载框架 + implementation 'com.github.bumptech.glide:glide:4.9.0' + //返回值转换器 + implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' + implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + //okhttp3日志拦截器 + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //网络请求和接口封装 + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.9.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.9.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' + //高德地图 + implementation 'com.amap.api:3dmap:latest.integration' + //推送SDK + implementation 'com.getui:gtsdk:3.2.10.0' //个推SDK + implementation 'com.getui:gtc:3.1.9.0' //个推核心组件 + //数据库框架 + implementation 'org.greenrobot:greendao:3.3.0' + //桌面角标 + implementation "me.leolin:ShortcutBadger:1.1.22@aar" +} \ No newline at end of file diff --git a/app/libs/lite-release.aar b/app/libs/lite-release.aar new file mode 100644 index 0000000..45da4df --- /dev/null +++ b/app/libs/lite-release.aar Binary files differ diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /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 \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..a83c28a --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/svg/monitor.svg b/app/src/main/assets/svg/monitor.svg new file mode 100644 index 0000000..c8d3e25 --- /dev/null +++ b/app/src/main/assets/svg/monitor.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/msg.svg b/app/src/main/assets/svg/msg.svg new file mode 100644 index 0000000..e864e48 --- /dev/null +++ b/app/src/main/assets/svg/msg.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/statistics.svg b/app/src/main/assets/svg/statistics.svg new file mode 100644 index 0000000..974000e --- /dev/null +++ b/app/src/main/assets/svg/statistics.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt new file mode 100644 index 0000000..6b9cce0 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.adapter + +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentManager +import androidx.fragment.app.FragmentPagerAdapter + +class ViewPagerAdapter(list: ArrayList, manager: FragmentManager) : + FragmentPagerAdapter(manager) { + + private var pageList: List = list + + override fun getItem(position: Int) = pageList[position] + + override fun getCount() = pageList.size +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt new file mode 100644 index 0000000..4e017b1 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt @@ -0,0 +1,40 @@ +package com.casic.smart.town.sanxi.base + +import android.app.Application +import android.util.Log +import com.casic.smart.town.sanxi.greendao.DaoMaster +import com.casic.smart.town.sanxi.greendao.DaoSession +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + private val kTag = "BaseApplication" + + companion object { + private var instance: BaseApplication by Delegates.notNull() + + fun obtainInstance() = instance + + private lateinit var daoSession: DaoSession + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences(this) + //推送 + PushManager.getInstance().initialize(this) + PushManager.getInstance().setDebugLogger(this) { + Log.d(kTag, it) + } + val devOpenHelper = DaoMaster.DevOpenHelper(this, "SmartTown.db", null) + val daoMaster = DaoMaster(devOpenHelper.writableDatabase) + daoSession = daoMaster.newSession() + } + + fun obtainDaoSession(): DaoSession { + return daoSession + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java new file mode 100644 index 0000000..b8f67dc --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java @@ -0,0 +1,133 @@ +package com.casic.smart.town.sanxi.bean; + +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Generated; +import org.greenrobot.greendao.annotation.Id; +import org.greenrobot.greendao.annotation.Unique; + +@Entity +public class AlarmMessageLocaleBean { + @Id(autoincrement = true) + private Long id;//主键自增 + + @Unique + private String messageId; + private String appId; + private String clientId; + private String taskId; + private String userId; + private String title; + private String content; + private String deviceCode; + private String isRead;//0-未读,1-已读 + private String alarmTime; + + @Generated(hash = 566950134) + public AlarmMessageLocaleBean(Long id, String messageId, String appId, + String clientId, String taskId, String userId, String title, + String content, String deviceCode, String isRead, String alarmTime) { + this.id = id; + this.messageId = messageId; + this.appId = appId; + this.clientId = clientId; + this.taskId = taskId; + this.userId = userId; + this.title = title; + this.content = content; + this.deviceCode = deviceCode; + this.isRead = isRead; + this.alarmTime = alarmTime; + } + + @Generated(hash = 1737519562) + public AlarmMessageLocaleBean() { + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getMessageId() { + return this.messageId; + } + + public void setMessageId(String messageId) { + this.messageId = messageId; + } + + public String getAppId() { + return this.appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public String getClientId() { + return this.clientId; + } + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public String getTaskId() { + return this.taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getUserId() { + return this.userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getTitle() { + return this.title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return this.content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getDeviceCode() { + return this.deviceCode; + } + + public void setDeviceCode(String deviceCode) { + this.deviceCode = deviceCode; + } + + public String getIsRead() { + return this.isRead; + } + + public void setIsRead(String isRead) { + this.isRead = isRead; + } + + public String getAlarmTime() { + return this.alarmTime; + } + + public void setAlarmTime(String alarmTime) { + this.alarmTime = alarmTime; + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt new file mode 100644 index 0000000..650e201 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class AlarmPageFragment: KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_alarm + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt new file mode 100644 index 0000000..deac8ac --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt @@ -0,0 +1,76 @@ +package com.casic.smart.town.sanxi.fragment + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.Fragment +import com.amap.api.maps.AMap +import com.amap.api.maps.AMapOptions +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.view.MonitorRecordActivity +import com.pengxh.kt.lite.extensions.navigatePageTo +import com.pengxh.kt.lite.extensions.show +import kotlinx.android.synthetic.main.fragment_monitor.view.* + +class MonitorPageFragment : Fragment() { + + private val kTag = "HomePageFragment" + private lateinit var monitorView: View + private lateinit var aMap: AMap + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? + ): View { + monitorView = inflater.inflate(R.layout.fragment_monitor, container, false) + //地图初始化 + initMap(savedInstanceState) + + monitorView.rightOperateView.setOnClickListener { + requireContext().navigatePageTo() + } + return monitorView + } + + private fun initMap(savedInstanceState: Bundle?) { + monitorView.mapView.onCreate(savedInstanceState) + aMap = monitorView.mapView.map + aMap.mapType = AMap.MAP_TYPE_NORMAL + val uiSettings = aMap.uiSettings + uiSettings.isCompassEnabled = true + uiSettings.zoomPosition = AMapOptions.ZOOM_POSITION_RIGHT_CENTER + uiSettings.isTiltGesturesEnabled = false//不许地图随手势倾斜角度 + + // 地图加载成功监听 +// aMap.addOnMapLoadedListener(this) + // 地图缩放监听 +// aMap.addOnCameraChangeListener(this) + // marker 点击事件监听 +// aMap.addOnMarkerClickListener(this) + // 点击marker弹出自定义popup +// aMap.setInfoWindowAdapter(this) + //信息窗点击事件 +// aMap.addOnInfoWindowClickListener(this) + } + + /***以下是地图生命周期管理************************************************************************/ + override fun onResume() { + super.onResume() + monitorView.mapView.onResume() + } + + override fun onPause() { + super.onPause() + monitorView.mapView.onPause() + } + + override fun onSaveInstanceState(outState: Bundle) { + super.onSaveInstanceState(outState) + monitorView.mapView.onSaveInstanceState(outState) + } + + override fun onDestroy() { + super.onDestroy() + monitorView.mapView.onDestroy() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt new file mode 100644 index 0000000..e84df12 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class StatisticsPageFragment : KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_statistics + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java new file mode 100644 index 0000000..68d7901 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java @@ -0,0 +1,255 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.database.Cursor; +import android.database.sqlite.SQLiteStatement; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.Property; +import org.greenrobot.greendao.internal.DaoConfig; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseStatement; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * DAO for table "ALARM_MESSAGE_LOCALE_BEAN". +*/ +public class AlarmMessageLocaleBeanDao extends AbstractDao { + + public static final String TABLENAME = "ALARM_MESSAGE_LOCALE_BEAN"; + + /** + * Properties of entity AlarmMessageLocaleBean.
+ * Can be used for QueryBuilder and for referencing column names. + */ + public static class Properties { + public final static Property Id = new Property(0, Long.class, "id", true, "_id"); + public final static Property MessageId = new Property(1, String.class, "messageId", false, "MESSAGE_ID"); + public final static Property AppId = new Property(2, String.class, "appId", false, "APP_ID"); + public final static Property ClientId = new Property(3, String.class, "clientId", false, "CLIENT_ID"); + public final static Property TaskId = new Property(4, String.class, "taskId", false, "TASK_ID"); + public final static Property UserId = new Property(5, String.class, "userId", false, "USER_ID"); + public final static Property Title = new Property(6, String.class, "title", false, "TITLE"); + public final static Property Content = new Property(7, String.class, "content", false, "CONTENT"); + public final static Property DeviceCode = new Property(8, String.class, "deviceCode", false, "DEVICE_CODE"); + public final static Property IsRead = new Property(9, String.class, "isRead", false, "IS_READ"); + public final static Property AlarmTime = new Property(10, String.class, "alarmTime", false, "ALARM_TIME"); + } + + + public AlarmMessageLocaleBeanDao(DaoConfig config) { + super(config); + } + + public AlarmMessageLocaleBeanDao(DaoConfig config, DaoSession daoSession) { + super(config, daoSession); + } + + /** Creates the underlying database table. */ + public static void createTable(Database db, boolean ifNotExists) { + String constraint = ifNotExists? "IF NOT EXISTS ": ""; + db.execSQL("CREATE TABLE " + constraint + "\"ALARM_MESSAGE_LOCALE_BEAN\" (" + // + "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id + "\"MESSAGE_ID\" TEXT UNIQUE ," + // 1: messageId + "\"APP_ID\" TEXT," + // 2: appId + "\"CLIENT_ID\" TEXT," + // 3: clientId + "\"TASK_ID\" TEXT," + // 4: taskId + "\"USER_ID\" TEXT," + // 5: userId + "\"TITLE\" TEXT," + // 6: title + "\"CONTENT\" TEXT," + // 7: content + "\"DEVICE_CODE\" TEXT," + // 8: deviceCode + "\"IS_READ\" TEXT," + // 9: isRead + "\"ALARM_TIME\" TEXT);"); // 10: alarmTime + } + + /** Drops the underlying database table. */ + public static void dropTable(Database db, boolean ifExists) { + String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"ALARM_MESSAGE_LOCALE_BEAN\""; + db.execSQL(sql); + } + + @Override + protected final void bindValues(DatabaseStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + protected final void bindValues(SQLiteStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + public Long readKey(Cursor cursor, int offset) { + return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); + } + + @Override + public AlarmMessageLocaleBean readEntity(Cursor cursor, int offset) { + AlarmMessageLocaleBean entity = new AlarmMessageLocaleBean( // + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // messageId + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // appId + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // clientId + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // taskId + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // userId + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // title + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // content + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // deviceCode + cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // isRead + cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10) // alarmTime + ); + return entity; + } + + @Override + public void readEntity(Cursor cursor, AlarmMessageLocaleBean entity, int offset) { + entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); + entity.setMessageId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setAppId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setClientId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setTaskId(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); + entity.setUserId(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setTitle(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setContent(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); + entity.setDeviceCode(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); + entity.setIsRead(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9)); + entity.setAlarmTime(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); + } + + @Override + protected final Long updateKeyAfterInsert(AlarmMessageLocaleBean entity, long rowId) { + entity.setId(rowId); + return rowId; + } + + @Override + public Long getKey(AlarmMessageLocaleBean entity) { + if(entity != null) { + return entity.getId(); + } else { + return null; + } + } + + @Override + public boolean hasKey(AlarmMessageLocaleBean entity) { + return entity.getId() != null; + } + + @Override + protected final boolean isEntityUpdateable() { + return true; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java new file mode 100644 index 0000000..4222c40 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java @@ -0,0 +1,96 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.content.Context; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteDatabase.CursorFactory; +import android.util.Log; + +import org.greenrobot.greendao.AbstractDaoMaster; +import org.greenrobot.greendao.database.StandardDatabase; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseOpenHelper; +import org.greenrobot.greendao.identityscope.IdentityScopeType; + + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * Master of DAO (schema version 1): knows all DAOs. + */ +public class DaoMaster extends AbstractDaoMaster { + public static final int SCHEMA_VERSION = 1; + + /** Creates underlying database table using DAOs. */ + public static void createAllTables(Database db, boolean ifNotExists) { + AlarmMessageLocaleBeanDao.createTable(db, ifNotExists); + } + + /** Drops underlying database table using DAOs. */ + public static void dropAllTables(Database db, boolean ifExists) { + AlarmMessageLocaleBeanDao.dropTable(db, ifExists); + } + + /** + * WARNING: Drops all table on Upgrade! Use only during development. + * Convenience method using a {@link DevOpenHelper}. + */ + public static DaoSession newDevSession(Context context, String name) { + Database db = new DevOpenHelper(context, name).getWritableDb(); + DaoMaster daoMaster = new DaoMaster(db); + return daoMaster.newSession(); + } + + public DaoMaster(SQLiteDatabase db) { + this(new StandardDatabase(db)); + } + + public DaoMaster(Database db) { + super(db, SCHEMA_VERSION); + registerDaoClass(AlarmMessageLocaleBeanDao.class); + } + + public DaoSession newSession() { + return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); + } + + public DaoSession newSession(IdentityScopeType type) { + return new DaoSession(db, type, daoConfigMap); + } + + /** + * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} - + */ + public static abstract class OpenHelper extends DatabaseOpenHelper { + public OpenHelper(Context context, String name) { + super(context, name, SCHEMA_VERSION); + } + + public OpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory, SCHEMA_VERSION); + } + + @Override + public void onCreate(Database db) { + Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); + createAllTables(db, false); + } + } + + /** WARNING: Drops all table on Upgrade! Use only during development. */ + public static class DevOpenHelper extends OpenHelper { + public DevOpenHelper(Context context, String name) { + super(context, name); + } + + public DevOpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory); + } + + @Override + public void onUpgrade(Database db, int oldVersion, int newVersion) { + Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); + dropAllTables(db, true); + onCreate(db); + } + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java new file mode 100644 index 0000000..480ed84 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java @@ -0,0 +1,48 @@ +package com.casic.smart.town.sanxi.greendao; + +import java.util.Map; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.AbstractDaoSession; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.identityscope.IdentityScopeType; +import org.greenrobot.greendao.internal.DaoConfig; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. + +/** + * {@inheritDoc} + * + * @see org.greenrobot.greendao.AbstractDaoSession + */ +public class DaoSession extends AbstractDaoSession { + + private final DaoConfig alarmMessageLocaleBeanDaoConfig; + + private final AlarmMessageLocaleBeanDao alarmMessageLocaleBeanDao; + + public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> + daoConfigMap) { + super(db); + + alarmMessageLocaleBeanDaoConfig = daoConfigMap.get(AlarmMessageLocaleBeanDao.class).clone(); + alarmMessageLocaleBeanDaoConfig.initIdentityScope(type); + + alarmMessageLocaleBeanDao = new AlarmMessageLocaleBeanDao(alarmMessageLocaleBeanDaoConfig, this); + + registerDao(AlarmMessageLocaleBean.class, alarmMessageLocaleBeanDao); + } + + public void clear() { + alarmMessageLocaleBeanDaoConfig.clearIdentityScope(); + } + + public AlarmMessageLocaleBeanDao getAlarmMessageLocaleBeanDao() { + return alarmMessageLocaleBeanDao; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt new file mode 100644 index 0000000..875cb8c --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt @@ -0,0 +1,5 @@ +package com.casic.smart.town.sanxi.service + +import com.igexin.sdk.PushService + +class ApplicationPushService : PushService() \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt new file mode 100644 index 0000000..396129f --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt @@ -0,0 +1,84 @@ +package com.casic.smart.town.sanxi.service + +import android.content.Context +import android.os.Message +import android.util.Log +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.casic.smart.town.sanxi.view.MainActivity +import com.igexin.sdk.GTIntentService +import com.igexin.sdk.message.GTCmdMessage +import com.igexin.sdk.message.GTNotificationMessage +import com.igexin.sdk.message.GTTransmitMessage +import com.pengxh.kt.lite.extensions.toJson + +class PushIntentService : GTIntentService() { + + private val kTag = "SmartWellIntentService" + + override fun onReceiveServicePid(context: Context?, pid: Int) { + + } + + // 透传消息 + override fun onReceiveMessageData(context: Context?, msg: GTTransmitMessage?) { + Log.d(kTag, "透传消息 -> msg = $msg") + } + + // 接收 cid + override fun onReceiveClientId(context: Context?, clientid: String?) { + Log.d(kTag, "onReceiveClientId -> $clientid") + //通知MainActivity注册个推服务 + val msg: Message = MainActivity.weakReferenceHandler.obtainMessage() + msg.what = LocaleConstant.PUSH_REGISTER + msg.obj = clientid + MainActivity.weakReferenceHandler.sendMessage(msg) + } + + // cid 离线上线通知 + override fun onReceiveOnlineState(context: Context?, online: Boolean) { + + } + + // 各种事件处理回执 + override fun onReceiveCommandResult(context: Context?, msg: GTCmdMessage?) { + + } + + // 通知到达 + override fun onNotificationMessageArrived(context: Context?, msg: GTNotificationMessage?) { + //报警 +// { +// "content": "设备编号[412022030361]发生井盖开盖报警", +// "messageId": "380abf9a79d34306a2683dc9bf96ee78", +// "taskId": "OSL-0830_4hmfimp3Vu684wo3SjXso9", +// "title": "告警提醒", +// "appid": "HKv8K9qARd6WckZ1o2Vbu4", +// "clientId": "e78beacc42e9a02ae6fb9087eb2b1171", +// "pkgName": "com.casic.app.smartwell" +// } + if (msg == null) { + return + } + Log.d(kTag, "通知到达 -> msg = ${msg.toJson()}") +// val userDetailJson = SaveKeyValues.getValue(LocaleConstant.USER_DETAIL_MODEL, "") as String +// var userId = "" +// if (userDetailJson.isNotBlank()) { +// val userDataModel = Gson().fromJson( +// userDetailJson, object : TypeToken() {}.type +// ) +// userId = userDataModel.id.toString() +// } +// //解析编号 +// val splitArray = msg.content.split("\\[|\\]".toRegex()) +// DataBaseManager.instance.insertNotice( +// msg.messageId, msg.appid, msg.clientId, msg.taskId, +// userId, msg.title, msg.content, splitArray[1], "0", +// System.currentTimeMillis().timestampToCompleteDate() +// ) + } + + // 通知点击 + override fun onNotificationMessageClicked(context: Context?, msg: GTNotificationMessage?) { + Log.d(kTag, "通知点击 -> msg = $msg") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt new file mode 100644 index 0000000..daa7c38 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt @@ -0,0 +1,14 @@ +package com.casic.smart.town.sanxi.util + +import android.content.Context +import me.leolin.shortcutbadger.ShortcutBadger + +object BadeHelper { + fun setBadgeNum(context: Context, badgeCount: Int) { + if (badgeCount == 0) { + ShortcutBadger.removeCount(context) + } else { + ShortcutBadger.applyCount(context, badgeCount) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt new file mode 100644 index 0000000..0a52ef2 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt @@ -0,0 +1,75 @@ +package com.casic.smart.town.sanxi.util + +import com.casic.smart.town.sanxi.base.BaseApplication +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao + +class DataBaseManager private constructor() { + + companion object { + //Kotlin委托模式双重锁单例 + val instance: DataBaseManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) { + DataBaseManager() + } + } + + private val beanDao = + BaseApplication.obtainInstance().obtainDaoSession().alarmMessageLocaleBeanDao + +// fun insertNotice( +// messageId: String, appid: String, clientId: String, +// taskId: String, userId: String, title: String, +// content: String, deviceCode: String, isRead: String, +// noticeTime: String +// ) { +// val noticeLocaleBean = NoticeLocaleBean() +// noticeLocaleBean.messageId = messageId +// noticeLocaleBean.appid = appid +// noticeLocaleBean.clientId = clientId +// noticeLocaleBean.taskId = taskId +// noticeLocaleBean.userId = userId +// noticeLocaleBean.title = title +// noticeLocaleBean.content = content +// noticeLocaleBean.deviceCode = deviceCode +// noticeLocaleBean.isRead = isRead +// noticeLocaleBean.noticeTime = noticeTime +// beanDao.insert(noticeLocaleBean) +// //角标设置 +// BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadNotice()) +// } + + fun deleteByMessageId(messageId: String) { + val result = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).list() + beanDao.deleteInTx(result) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun updateNoticeByMessageId(messageId: String) { + val noticeLocaleBean = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).unique() ?: return + noticeLocaleBean.isRead = "1" + beanDao.update(noticeLocaleBean) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun queryMessageByPage(userId: String, offset: Int): MutableList { + return BaseApplication.obtainInstance().obtainDaoSession() + .queryBuilder(AlarmMessageLocaleBean::class.java) + .where(AlarmMessageLocaleBeanDao.Properties.UserId.eq(userId)) + .offset(offset * LocaleConstant.PAGE_LIMIT) + .orderDesc(AlarmMessageLocaleBeanDao.Properties.AlarmTime) + .limit(LocaleConstant.PAGE_LIMIT) + .list() + } + + private fun queryUnReadMessage(): Int { + return beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.IsRead.eq("0") + ).list().size + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt new file mode 100644 index 0000000..52926a8 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt @@ -0,0 +1,31 @@ +package com.casic.smart.town.sanxi.util; + +import android.app.Activity +import android.view.WindowManager +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object LoadingDialogHub { + private lateinit var loadingDialog: QMUITipDialog + + fun show(activity: Activity, message: String) { + loadingDialog = QMUITipDialog + .Builder(activity) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_LOADING) + .setTipWord(message) + .create() + if (!activity.isDestroyed) { + try { + loadingDialog.show() + } catch (e: WindowManager.BadTokenException) { + e.printStackTrace() + } + } + } + + + fun dismiss() { + if (loadingDialog.isShowing) { + loadingDialog.dismiss() + } + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt new file mode 100644 index 0000000..de61c9a --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.util + +import android.Manifest + +object LocaleConstant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.READ_PHONE_STATE, + Manifest.permission.ACCESS_COARSE_LOCATION, + Manifest.permission.READ_EXTERNAL_STORAGE + ) + + const val PERMISSIONS_CODE = 999 + const val PUSH_REGISTER = 2022100101 + const val PAGE_LIMIT = 20 +} \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..10cfdbf --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*.iml +.gradle +/local.properties +/.idea +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..a4cd2ca --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,101 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'org.greenrobot.greendao' + +android { +// signingConfigs { +// release { +// storeFile file('/Users/a203/Desktop/AndroidProjects/CasicSmartWell/app/CasicSmartWell.jks') +// storePassword '123456789' +// keyAlias 'key0' +// keyPassword '123456789' +// } +// } + compileSdkVersion 31 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.smart.town.sanxi" + minSdkVersion 23 + targetSdkVersion 31 + versionCode 1 + versionName "1.0.0" + + manifestPlaceholders = [GETUI_APPID: "A9V4DvwLcdAqkFCQuFyhq6"] + } + + buildTypes { + release { + minifyEnabled false +// signingConfig signingConfigs.release + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + + ndk { abiFilters "armeabi", "armeabi-v7a", "arm64-v8" } + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlin { + experimental { + coroutines 'enable' + } + } + + greendao { + schemaVersion 1//数据库版本号 + targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 + daoPackage 'com.casic.smart.town.sanxi.greendao'//设置DaoMaster、DaoSession、Dao包名 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + //基础依赖库 + implementation files('libs/lite-release.aar') + implementation 'androidx.appcompat:appcompat:1.4.2' + implementation 'androidx.core:core-ktx:1.8.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:3.0.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' + //MVVM+LiveData + implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.1" + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0" + implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + //Kotlin协程 + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1' + //图片加载框架 + implementation 'com.github.bumptech.glide:glide:4.9.0' + //返回值转换器 + implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' + implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + //okhttp3日志拦截器 + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //网络请求和接口封装 + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.9.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.9.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' + //高德地图 + implementation 'com.amap.api:3dmap:latest.integration' + //推送SDK + implementation 'com.getui:gtsdk:3.2.10.0' //个推SDK + implementation 'com.getui:gtc:3.1.9.0' //个推核心组件 + //数据库框架 + implementation 'org.greenrobot:greendao:3.3.0' + //桌面角标 + implementation "me.leolin:ShortcutBadger:1.1.22@aar" +} \ No newline at end of file diff --git a/app/libs/lite-release.aar b/app/libs/lite-release.aar new file mode 100644 index 0000000..45da4df --- /dev/null +++ b/app/libs/lite-release.aar Binary files differ diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /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 \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..a83c28a --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/svg/monitor.svg b/app/src/main/assets/svg/monitor.svg new file mode 100644 index 0000000..c8d3e25 --- /dev/null +++ b/app/src/main/assets/svg/monitor.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/msg.svg b/app/src/main/assets/svg/msg.svg new file mode 100644 index 0000000..e864e48 --- /dev/null +++ b/app/src/main/assets/svg/msg.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/statistics.svg b/app/src/main/assets/svg/statistics.svg new file mode 100644 index 0000000..974000e --- /dev/null +++ b/app/src/main/assets/svg/statistics.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt new file mode 100644 index 0000000..6b9cce0 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.adapter + +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentManager +import androidx.fragment.app.FragmentPagerAdapter + +class ViewPagerAdapter(list: ArrayList, manager: FragmentManager) : + FragmentPagerAdapter(manager) { + + private var pageList: List = list + + override fun getItem(position: Int) = pageList[position] + + override fun getCount() = pageList.size +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt new file mode 100644 index 0000000..4e017b1 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt @@ -0,0 +1,40 @@ +package com.casic.smart.town.sanxi.base + +import android.app.Application +import android.util.Log +import com.casic.smart.town.sanxi.greendao.DaoMaster +import com.casic.smart.town.sanxi.greendao.DaoSession +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + private val kTag = "BaseApplication" + + companion object { + private var instance: BaseApplication by Delegates.notNull() + + fun obtainInstance() = instance + + private lateinit var daoSession: DaoSession + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences(this) + //推送 + PushManager.getInstance().initialize(this) + PushManager.getInstance().setDebugLogger(this) { + Log.d(kTag, it) + } + val devOpenHelper = DaoMaster.DevOpenHelper(this, "SmartTown.db", null) + val daoMaster = DaoMaster(devOpenHelper.writableDatabase) + daoSession = daoMaster.newSession() + } + + fun obtainDaoSession(): DaoSession { + return daoSession + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java new file mode 100644 index 0000000..b8f67dc --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java @@ -0,0 +1,133 @@ +package com.casic.smart.town.sanxi.bean; + +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Generated; +import org.greenrobot.greendao.annotation.Id; +import org.greenrobot.greendao.annotation.Unique; + +@Entity +public class AlarmMessageLocaleBean { + @Id(autoincrement = true) + private Long id;//主键自增 + + @Unique + private String messageId; + private String appId; + private String clientId; + private String taskId; + private String userId; + private String title; + private String content; + private String deviceCode; + private String isRead;//0-未读,1-已读 + private String alarmTime; + + @Generated(hash = 566950134) + public AlarmMessageLocaleBean(Long id, String messageId, String appId, + String clientId, String taskId, String userId, String title, + String content, String deviceCode, String isRead, String alarmTime) { + this.id = id; + this.messageId = messageId; + this.appId = appId; + this.clientId = clientId; + this.taskId = taskId; + this.userId = userId; + this.title = title; + this.content = content; + this.deviceCode = deviceCode; + this.isRead = isRead; + this.alarmTime = alarmTime; + } + + @Generated(hash = 1737519562) + public AlarmMessageLocaleBean() { + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getMessageId() { + return this.messageId; + } + + public void setMessageId(String messageId) { + this.messageId = messageId; + } + + public String getAppId() { + return this.appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public String getClientId() { + return this.clientId; + } + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public String getTaskId() { + return this.taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getUserId() { + return this.userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getTitle() { + return this.title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return this.content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getDeviceCode() { + return this.deviceCode; + } + + public void setDeviceCode(String deviceCode) { + this.deviceCode = deviceCode; + } + + public String getIsRead() { + return this.isRead; + } + + public void setIsRead(String isRead) { + this.isRead = isRead; + } + + public String getAlarmTime() { + return this.alarmTime; + } + + public void setAlarmTime(String alarmTime) { + this.alarmTime = alarmTime; + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt new file mode 100644 index 0000000..650e201 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class AlarmPageFragment: KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_alarm + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt new file mode 100644 index 0000000..deac8ac --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt @@ -0,0 +1,76 @@ +package com.casic.smart.town.sanxi.fragment + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.Fragment +import com.amap.api.maps.AMap +import com.amap.api.maps.AMapOptions +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.view.MonitorRecordActivity +import com.pengxh.kt.lite.extensions.navigatePageTo +import com.pengxh.kt.lite.extensions.show +import kotlinx.android.synthetic.main.fragment_monitor.view.* + +class MonitorPageFragment : Fragment() { + + private val kTag = "HomePageFragment" + private lateinit var monitorView: View + private lateinit var aMap: AMap + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? + ): View { + monitorView = inflater.inflate(R.layout.fragment_monitor, container, false) + //地图初始化 + initMap(savedInstanceState) + + monitorView.rightOperateView.setOnClickListener { + requireContext().navigatePageTo() + } + return monitorView + } + + private fun initMap(savedInstanceState: Bundle?) { + monitorView.mapView.onCreate(savedInstanceState) + aMap = monitorView.mapView.map + aMap.mapType = AMap.MAP_TYPE_NORMAL + val uiSettings = aMap.uiSettings + uiSettings.isCompassEnabled = true + uiSettings.zoomPosition = AMapOptions.ZOOM_POSITION_RIGHT_CENTER + uiSettings.isTiltGesturesEnabled = false//不许地图随手势倾斜角度 + + // 地图加载成功监听 +// aMap.addOnMapLoadedListener(this) + // 地图缩放监听 +// aMap.addOnCameraChangeListener(this) + // marker 点击事件监听 +// aMap.addOnMarkerClickListener(this) + // 点击marker弹出自定义popup +// aMap.setInfoWindowAdapter(this) + //信息窗点击事件 +// aMap.addOnInfoWindowClickListener(this) + } + + /***以下是地图生命周期管理************************************************************************/ + override fun onResume() { + super.onResume() + monitorView.mapView.onResume() + } + + override fun onPause() { + super.onPause() + monitorView.mapView.onPause() + } + + override fun onSaveInstanceState(outState: Bundle) { + super.onSaveInstanceState(outState) + monitorView.mapView.onSaveInstanceState(outState) + } + + override fun onDestroy() { + super.onDestroy() + monitorView.mapView.onDestroy() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt new file mode 100644 index 0000000..e84df12 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class StatisticsPageFragment : KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_statistics + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java new file mode 100644 index 0000000..68d7901 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java @@ -0,0 +1,255 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.database.Cursor; +import android.database.sqlite.SQLiteStatement; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.Property; +import org.greenrobot.greendao.internal.DaoConfig; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseStatement; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * DAO for table "ALARM_MESSAGE_LOCALE_BEAN". +*/ +public class AlarmMessageLocaleBeanDao extends AbstractDao { + + public static final String TABLENAME = "ALARM_MESSAGE_LOCALE_BEAN"; + + /** + * Properties of entity AlarmMessageLocaleBean.
+ * Can be used for QueryBuilder and for referencing column names. + */ + public static class Properties { + public final static Property Id = new Property(0, Long.class, "id", true, "_id"); + public final static Property MessageId = new Property(1, String.class, "messageId", false, "MESSAGE_ID"); + public final static Property AppId = new Property(2, String.class, "appId", false, "APP_ID"); + public final static Property ClientId = new Property(3, String.class, "clientId", false, "CLIENT_ID"); + public final static Property TaskId = new Property(4, String.class, "taskId", false, "TASK_ID"); + public final static Property UserId = new Property(5, String.class, "userId", false, "USER_ID"); + public final static Property Title = new Property(6, String.class, "title", false, "TITLE"); + public final static Property Content = new Property(7, String.class, "content", false, "CONTENT"); + public final static Property DeviceCode = new Property(8, String.class, "deviceCode", false, "DEVICE_CODE"); + public final static Property IsRead = new Property(9, String.class, "isRead", false, "IS_READ"); + public final static Property AlarmTime = new Property(10, String.class, "alarmTime", false, "ALARM_TIME"); + } + + + public AlarmMessageLocaleBeanDao(DaoConfig config) { + super(config); + } + + public AlarmMessageLocaleBeanDao(DaoConfig config, DaoSession daoSession) { + super(config, daoSession); + } + + /** Creates the underlying database table. */ + public static void createTable(Database db, boolean ifNotExists) { + String constraint = ifNotExists? "IF NOT EXISTS ": ""; + db.execSQL("CREATE TABLE " + constraint + "\"ALARM_MESSAGE_LOCALE_BEAN\" (" + // + "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id + "\"MESSAGE_ID\" TEXT UNIQUE ," + // 1: messageId + "\"APP_ID\" TEXT," + // 2: appId + "\"CLIENT_ID\" TEXT," + // 3: clientId + "\"TASK_ID\" TEXT," + // 4: taskId + "\"USER_ID\" TEXT," + // 5: userId + "\"TITLE\" TEXT," + // 6: title + "\"CONTENT\" TEXT," + // 7: content + "\"DEVICE_CODE\" TEXT," + // 8: deviceCode + "\"IS_READ\" TEXT," + // 9: isRead + "\"ALARM_TIME\" TEXT);"); // 10: alarmTime + } + + /** Drops the underlying database table. */ + public static void dropTable(Database db, boolean ifExists) { + String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"ALARM_MESSAGE_LOCALE_BEAN\""; + db.execSQL(sql); + } + + @Override + protected final void bindValues(DatabaseStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + protected final void bindValues(SQLiteStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + public Long readKey(Cursor cursor, int offset) { + return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); + } + + @Override + public AlarmMessageLocaleBean readEntity(Cursor cursor, int offset) { + AlarmMessageLocaleBean entity = new AlarmMessageLocaleBean( // + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // messageId + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // appId + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // clientId + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // taskId + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // userId + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // title + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // content + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // deviceCode + cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // isRead + cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10) // alarmTime + ); + return entity; + } + + @Override + public void readEntity(Cursor cursor, AlarmMessageLocaleBean entity, int offset) { + entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); + entity.setMessageId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setAppId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setClientId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setTaskId(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); + entity.setUserId(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setTitle(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setContent(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); + entity.setDeviceCode(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); + entity.setIsRead(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9)); + entity.setAlarmTime(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); + } + + @Override + protected final Long updateKeyAfterInsert(AlarmMessageLocaleBean entity, long rowId) { + entity.setId(rowId); + return rowId; + } + + @Override + public Long getKey(AlarmMessageLocaleBean entity) { + if(entity != null) { + return entity.getId(); + } else { + return null; + } + } + + @Override + public boolean hasKey(AlarmMessageLocaleBean entity) { + return entity.getId() != null; + } + + @Override + protected final boolean isEntityUpdateable() { + return true; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java new file mode 100644 index 0000000..4222c40 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java @@ -0,0 +1,96 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.content.Context; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteDatabase.CursorFactory; +import android.util.Log; + +import org.greenrobot.greendao.AbstractDaoMaster; +import org.greenrobot.greendao.database.StandardDatabase; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseOpenHelper; +import org.greenrobot.greendao.identityscope.IdentityScopeType; + + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * Master of DAO (schema version 1): knows all DAOs. + */ +public class DaoMaster extends AbstractDaoMaster { + public static final int SCHEMA_VERSION = 1; + + /** Creates underlying database table using DAOs. */ + public static void createAllTables(Database db, boolean ifNotExists) { + AlarmMessageLocaleBeanDao.createTable(db, ifNotExists); + } + + /** Drops underlying database table using DAOs. */ + public static void dropAllTables(Database db, boolean ifExists) { + AlarmMessageLocaleBeanDao.dropTable(db, ifExists); + } + + /** + * WARNING: Drops all table on Upgrade! Use only during development. + * Convenience method using a {@link DevOpenHelper}. + */ + public static DaoSession newDevSession(Context context, String name) { + Database db = new DevOpenHelper(context, name).getWritableDb(); + DaoMaster daoMaster = new DaoMaster(db); + return daoMaster.newSession(); + } + + public DaoMaster(SQLiteDatabase db) { + this(new StandardDatabase(db)); + } + + public DaoMaster(Database db) { + super(db, SCHEMA_VERSION); + registerDaoClass(AlarmMessageLocaleBeanDao.class); + } + + public DaoSession newSession() { + return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); + } + + public DaoSession newSession(IdentityScopeType type) { + return new DaoSession(db, type, daoConfigMap); + } + + /** + * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} - + */ + public static abstract class OpenHelper extends DatabaseOpenHelper { + public OpenHelper(Context context, String name) { + super(context, name, SCHEMA_VERSION); + } + + public OpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory, SCHEMA_VERSION); + } + + @Override + public void onCreate(Database db) { + Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); + createAllTables(db, false); + } + } + + /** WARNING: Drops all table on Upgrade! Use only during development. */ + public static class DevOpenHelper extends OpenHelper { + public DevOpenHelper(Context context, String name) { + super(context, name); + } + + public DevOpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory); + } + + @Override + public void onUpgrade(Database db, int oldVersion, int newVersion) { + Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); + dropAllTables(db, true); + onCreate(db); + } + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java new file mode 100644 index 0000000..480ed84 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java @@ -0,0 +1,48 @@ +package com.casic.smart.town.sanxi.greendao; + +import java.util.Map; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.AbstractDaoSession; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.identityscope.IdentityScopeType; +import org.greenrobot.greendao.internal.DaoConfig; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. + +/** + * {@inheritDoc} + * + * @see org.greenrobot.greendao.AbstractDaoSession + */ +public class DaoSession extends AbstractDaoSession { + + private final DaoConfig alarmMessageLocaleBeanDaoConfig; + + private final AlarmMessageLocaleBeanDao alarmMessageLocaleBeanDao; + + public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> + daoConfigMap) { + super(db); + + alarmMessageLocaleBeanDaoConfig = daoConfigMap.get(AlarmMessageLocaleBeanDao.class).clone(); + alarmMessageLocaleBeanDaoConfig.initIdentityScope(type); + + alarmMessageLocaleBeanDao = new AlarmMessageLocaleBeanDao(alarmMessageLocaleBeanDaoConfig, this); + + registerDao(AlarmMessageLocaleBean.class, alarmMessageLocaleBeanDao); + } + + public void clear() { + alarmMessageLocaleBeanDaoConfig.clearIdentityScope(); + } + + public AlarmMessageLocaleBeanDao getAlarmMessageLocaleBeanDao() { + return alarmMessageLocaleBeanDao; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt new file mode 100644 index 0000000..875cb8c --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt @@ -0,0 +1,5 @@ +package com.casic.smart.town.sanxi.service + +import com.igexin.sdk.PushService + +class ApplicationPushService : PushService() \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt new file mode 100644 index 0000000..396129f --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt @@ -0,0 +1,84 @@ +package com.casic.smart.town.sanxi.service + +import android.content.Context +import android.os.Message +import android.util.Log +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.casic.smart.town.sanxi.view.MainActivity +import com.igexin.sdk.GTIntentService +import com.igexin.sdk.message.GTCmdMessage +import com.igexin.sdk.message.GTNotificationMessage +import com.igexin.sdk.message.GTTransmitMessage +import com.pengxh.kt.lite.extensions.toJson + +class PushIntentService : GTIntentService() { + + private val kTag = "SmartWellIntentService" + + override fun onReceiveServicePid(context: Context?, pid: Int) { + + } + + // 透传消息 + override fun onReceiveMessageData(context: Context?, msg: GTTransmitMessage?) { + Log.d(kTag, "透传消息 -> msg = $msg") + } + + // 接收 cid + override fun onReceiveClientId(context: Context?, clientid: String?) { + Log.d(kTag, "onReceiveClientId -> $clientid") + //通知MainActivity注册个推服务 + val msg: Message = MainActivity.weakReferenceHandler.obtainMessage() + msg.what = LocaleConstant.PUSH_REGISTER + msg.obj = clientid + MainActivity.weakReferenceHandler.sendMessage(msg) + } + + // cid 离线上线通知 + override fun onReceiveOnlineState(context: Context?, online: Boolean) { + + } + + // 各种事件处理回执 + override fun onReceiveCommandResult(context: Context?, msg: GTCmdMessage?) { + + } + + // 通知到达 + override fun onNotificationMessageArrived(context: Context?, msg: GTNotificationMessage?) { + //报警 +// { +// "content": "设备编号[412022030361]发生井盖开盖报警", +// "messageId": "380abf9a79d34306a2683dc9bf96ee78", +// "taskId": "OSL-0830_4hmfimp3Vu684wo3SjXso9", +// "title": "告警提醒", +// "appid": "HKv8K9qARd6WckZ1o2Vbu4", +// "clientId": "e78beacc42e9a02ae6fb9087eb2b1171", +// "pkgName": "com.casic.app.smartwell" +// } + if (msg == null) { + return + } + Log.d(kTag, "通知到达 -> msg = ${msg.toJson()}") +// val userDetailJson = SaveKeyValues.getValue(LocaleConstant.USER_DETAIL_MODEL, "") as String +// var userId = "" +// if (userDetailJson.isNotBlank()) { +// val userDataModel = Gson().fromJson( +// userDetailJson, object : TypeToken() {}.type +// ) +// userId = userDataModel.id.toString() +// } +// //解析编号 +// val splitArray = msg.content.split("\\[|\\]".toRegex()) +// DataBaseManager.instance.insertNotice( +// msg.messageId, msg.appid, msg.clientId, msg.taskId, +// userId, msg.title, msg.content, splitArray[1], "0", +// System.currentTimeMillis().timestampToCompleteDate() +// ) + } + + // 通知点击 + override fun onNotificationMessageClicked(context: Context?, msg: GTNotificationMessage?) { + Log.d(kTag, "通知点击 -> msg = $msg") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt new file mode 100644 index 0000000..daa7c38 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt @@ -0,0 +1,14 @@ +package com.casic.smart.town.sanxi.util + +import android.content.Context +import me.leolin.shortcutbadger.ShortcutBadger + +object BadeHelper { + fun setBadgeNum(context: Context, badgeCount: Int) { + if (badgeCount == 0) { + ShortcutBadger.removeCount(context) + } else { + ShortcutBadger.applyCount(context, badgeCount) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt new file mode 100644 index 0000000..0a52ef2 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt @@ -0,0 +1,75 @@ +package com.casic.smart.town.sanxi.util + +import com.casic.smart.town.sanxi.base.BaseApplication +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao + +class DataBaseManager private constructor() { + + companion object { + //Kotlin委托模式双重锁单例 + val instance: DataBaseManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) { + DataBaseManager() + } + } + + private val beanDao = + BaseApplication.obtainInstance().obtainDaoSession().alarmMessageLocaleBeanDao + +// fun insertNotice( +// messageId: String, appid: String, clientId: String, +// taskId: String, userId: String, title: String, +// content: String, deviceCode: String, isRead: String, +// noticeTime: String +// ) { +// val noticeLocaleBean = NoticeLocaleBean() +// noticeLocaleBean.messageId = messageId +// noticeLocaleBean.appid = appid +// noticeLocaleBean.clientId = clientId +// noticeLocaleBean.taskId = taskId +// noticeLocaleBean.userId = userId +// noticeLocaleBean.title = title +// noticeLocaleBean.content = content +// noticeLocaleBean.deviceCode = deviceCode +// noticeLocaleBean.isRead = isRead +// noticeLocaleBean.noticeTime = noticeTime +// beanDao.insert(noticeLocaleBean) +// //角标设置 +// BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadNotice()) +// } + + fun deleteByMessageId(messageId: String) { + val result = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).list() + beanDao.deleteInTx(result) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun updateNoticeByMessageId(messageId: String) { + val noticeLocaleBean = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).unique() ?: return + noticeLocaleBean.isRead = "1" + beanDao.update(noticeLocaleBean) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun queryMessageByPage(userId: String, offset: Int): MutableList { + return BaseApplication.obtainInstance().obtainDaoSession() + .queryBuilder(AlarmMessageLocaleBean::class.java) + .where(AlarmMessageLocaleBeanDao.Properties.UserId.eq(userId)) + .offset(offset * LocaleConstant.PAGE_LIMIT) + .orderDesc(AlarmMessageLocaleBeanDao.Properties.AlarmTime) + .limit(LocaleConstant.PAGE_LIMIT) + .list() + } + + private fun queryUnReadMessage(): Int { + return beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.IsRead.eq("0") + ).list().size + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt new file mode 100644 index 0000000..52926a8 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt @@ -0,0 +1,31 @@ +package com.casic.smart.town.sanxi.util; + +import android.app.Activity +import android.view.WindowManager +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object LoadingDialogHub { + private lateinit var loadingDialog: QMUITipDialog + + fun show(activity: Activity, message: String) { + loadingDialog = QMUITipDialog + .Builder(activity) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_LOADING) + .setTipWord(message) + .create() + if (!activity.isDestroyed) { + try { + loadingDialog.show() + } catch (e: WindowManager.BadTokenException) { + e.printStackTrace() + } + } + } + + + fun dismiss() { + if (loadingDialog.isShowing) { + loadingDialog.dismiss() + } + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt new file mode 100644 index 0000000..de61c9a --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.util + +import android.Manifest + +object LocaleConstant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.READ_PHONE_STATE, + Manifest.permission.ACCESS_COARSE_LOCATION, + Manifest.permission.READ_EXTERNAL_STORAGE + ) + + const val PERMISSIONS_CODE = 999 + const val PUSH_REGISTER = 2022100101 + const val PAGE_LIMIT = 20 +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt new file mode 100644 index 0000000..3bea1c9 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt @@ -0,0 +1,112 @@ +package com.casic.smart.town.sanxi.view + +import android.view.KeyEvent +import android.view.MenuItem +import androidx.fragment.app.Fragment +import androidx.viewpager.widget.ViewPager +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.adapter.ViewPagerAdapter +import com.casic.smart.town.sanxi.fragment.AlarmPageFragment +import com.casic.smart.town.sanxi.fragment.MonitorPageFragment +import com.casic.smart.town.sanxi.fragment.StatisticsPageFragment +import com.gyf.immersionbar.ImmersionBar +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.base.KotlinBaseActivity +import com.pengxh.kt.lite.extensions.convertColor +import com.pengxh.kt.lite.extensions.show +import com.pengxh.kt.lite.utils.ImmerseStatusBarUtil +import com.pengxh.kt.lite.utils.WeakReferenceHandler +import kotlinx.android.synthetic.main.activity_main.* + +class MainActivity : KotlinBaseActivity() { + + companion object { + lateinit var weakReferenceHandler: WeakReferenceHandler + } + + private val kTag = "MainActivity" + private var menuItem: MenuItem? = null + private var fragmentPages: ArrayList = ArrayList() + private var clickTime: Long = 0 + + init { + fragmentPages.add(StatisticsPageFragment()) + fragmentPages.add(MonitorPageFragment()) + fragmentPages.add(AlarmPageFragment()) + } + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + ImmersionBar.with(this).statusBarDarkFont(false).init() + ImmerseStatusBarUtil.setColor(this, R.color.mainThemeColor.convertColor(this)) + } + + override fun initData() { + //推送,多次调用 SDK 初始化并无影响。 + PushManager.getInstance().initialize(this) + weakReferenceHandler = WeakReferenceHandler { + + true + } + } + + override fun observeRequestState() { + + } + + override fun initEvent() { + bottomNavigation.itemIconTintList = null + bottomNavigation.setOnNavigationItemSelectedListener { menuItem -> + when (menuItem.itemId) { + R.id.nav_statistics -> { + mainViewPager.currentItem = 0 + } + R.id.nav_monitor -> { + mainViewPager.currentItem = 1 + } + R.id.nav_alarm -> { + mainViewPager.currentItem = 2 + } + } + false + } + mainViewPager.adapter = ViewPagerAdapter(fragmentPages, supportFragmentManager) + mainViewPager.offscreenPageLimit = fragmentPages.size //缓存页数 + mainViewPager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener { + override fun onPageScrollStateChanged(state: Int) { + + } + + override fun onPageScrolled( + position: Int, + positionOffset: Float, + positionOffsetPixels: Int + ) { + + } + + override fun onPageSelected(position: Int) { + if (menuItem != null) { + menuItem!!.isChecked = false + } else { + bottomNavigation.menu.getItem(0).isChecked = false + } + menuItem = bottomNavigation.menu.getItem(position) + menuItem!!.isChecked = true + } + }) + } + + override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean { + return if (keyCode == KeyEvent.KEYCODE_BACK) { + if (System.currentTimeMillis() - clickTime > 2000) { + "再按一次退出程序".show(this) + clickTime = System.currentTimeMillis() + true + } else { + super.onKeyDown(keyCode, event) + } + } else super.onKeyDown(keyCode, event) + } +} \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..10cfdbf --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*.iml +.gradle +/local.properties +/.idea +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..a4cd2ca --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,101 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'org.greenrobot.greendao' + +android { +// signingConfigs { +// release { +// storeFile file('/Users/a203/Desktop/AndroidProjects/CasicSmartWell/app/CasicSmartWell.jks') +// storePassword '123456789' +// keyAlias 'key0' +// keyPassword '123456789' +// } +// } + compileSdkVersion 31 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.smart.town.sanxi" + minSdkVersion 23 + targetSdkVersion 31 + versionCode 1 + versionName "1.0.0" + + manifestPlaceholders = [GETUI_APPID: "A9V4DvwLcdAqkFCQuFyhq6"] + } + + buildTypes { + release { + minifyEnabled false +// signingConfig signingConfigs.release + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + + ndk { abiFilters "armeabi", "armeabi-v7a", "arm64-v8" } + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlin { + experimental { + coroutines 'enable' + } + } + + greendao { + schemaVersion 1//数据库版本号 + targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 + daoPackage 'com.casic.smart.town.sanxi.greendao'//设置DaoMaster、DaoSession、Dao包名 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + //基础依赖库 + implementation files('libs/lite-release.aar') + implementation 'androidx.appcompat:appcompat:1.4.2' + implementation 'androidx.core:core-ktx:1.8.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:3.0.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' + //MVVM+LiveData + implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.1" + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0" + implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + //Kotlin协程 + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1' + //图片加载框架 + implementation 'com.github.bumptech.glide:glide:4.9.0' + //返回值转换器 + implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' + implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + //okhttp3日志拦截器 + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //网络请求和接口封装 + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.9.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.9.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' + //高德地图 + implementation 'com.amap.api:3dmap:latest.integration' + //推送SDK + implementation 'com.getui:gtsdk:3.2.10.0' //个推SDK + implementation 'com.getui:gtc:3.1.9.0' //个推核心组件 + //数据库框架 + implementation 'org.greenrobot:greendao:3.3.0' + //桌面角标 + implementation "me.leolin:ShortcutBadger:1.1.22@aar" +} \ No newline at end of file diff --git a/app/libs/lite-release.aar b/app/libs/lite-release.aar new file mode 100644 index 0000000..45da4df --- /dev/null +++ b/app/libs/lite-release.aar Binary files differ diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /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 \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..a83c28a --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/svg/monitor.svg b/app/src/main/assets/svg/monitor.svg new file mode 100644 index 0000000..c8d3e25 --- /dev/null +++ b/app/src/main/assets/svg/monitor.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/msg.svg b/app/src/main/assets/svg/msg.svg new file mode 100644 index 0000000..e864e48 --- /dev/null +++ b/app/src/main/assets/svg/msg.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/statistics.svg b/app/src/main/assets/svg/statistics.svg new file mode 100644 index 0000000..974000e --- /dev/null +++ b/app/src/main/assets/svg/statistics.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt new file mode 100644 index 0000000..6b9cce0 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.adapter + +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentManager +import androidx.fragment.app.FragmentPagerAdapter + +class ViewPagerAdapter(list: ArrayList, manager: FragmentManager) : + FragmentPagerAdapter(manager) { + + private var pageList: List = list + + override fun getItem(position: Int) = pageList[position] + + override fun getCount() = pageList.size +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt new file mode 100644 index 0000000..4e017b1 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt @@ -0,0 +1,40 @@ +package com.casic.smart.town.sanxi.base + +import android.app.Application +import android.util.Log +import com.casic.smart.town.sanxi.greendao.DaoMaster +import com.casic.smart.town.sanxi.greendao.DaoSession +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + private val kTag = "BaseApplication" + + companion object { + private var instance: BaseApplication by Delegates.notNull() + + fun obtainInstance() = instance + + private lateinit var daoSession: DaoSession + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences(this) + //推送 + PushManager.getInstance().initialize(this) + PushManager.getInstance().setDebugLogger(this) { + Log.d(kTag, it) + } + val devOpenHelper = DaoMaster.DevOpenHelper(this, "SmartTown.db", null) + val daoMaster = DaoMaster(devOpenHelper.writableDatabase) + daoSession = daoMaster.newSession() + } + + fun obtainDaoSession(): DaoSession { + return daoSession + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java new file mode 100644 index 0000000..b8f67dc --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java @@ -0,0 +1,133 @@ +package com.casic.smart.town.sanxi.bean; + +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Generated; +import org.greenrobot.greendao.annotation.Id; +import org.greenrobot.greendao.annotation.Unique; + +@Entity +public class AlarmMessageLocaleBean { + @Id(autoincrement = true) + private Long id;//主键自增 + + @Unique + private String messageId; + private String appId; + private String clientId; + private String taskId; + private String userId; + private String title; + private String content; + private String deviceCode; + private String isRead;//0-未读,1-已读 + private String alarmTime; + + @Generated(hash = 566950134) + public AlarmMessageLocaleBean(Long id, String messageId, String appId, + String clientId, String taskId, String userId, String title, + String content, String deviceCode, String isRead, String alarmTime) { + this.id = id; + this.messageId = messageId; + this.appId = appId; + this.clientId = clientId; + this.taskId = taskId; + this.userId = userId; + this.title = title; + this.content = content; + this.deviceCode = deviceCode; + this.isRead = isRead; + this.alarmTime = alarmTime; + } + + @Generated(hash = 1737519562) + public AlarmMessageLocaleBean() { + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getMessageId() { + return this.messageId; + } + + public void setMessageId(String messageId) { + this.messageId = messageId; + } + + public String getAppId() { + return this.appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public String getClientId() { + return this.clientId; + } + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public String getTaskId() { + return this.taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getUserId() { + return this.userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getTitle() { + return this.title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return this.content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getDeviceCode() { + return this.deviceCode; + } + + public void setDeviceCode(String deviceCode) { + this.deviceCode = deviceCode; + } + + public String getIsRead() { + return this.isRead; + } + + public void setIsRead(String isRead) { + this.isRead = isRead; + } + + public String getAlarmTime() { + return this.alarmTime; + } + + public void setAlarmTime(String alarmTime) { + this.alarmTime = alarmTime; + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt new file mode 100644 index 0000000..650e201 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class AlarmPageFragment: KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_alarm + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt new file mode 100644 index 0000000..deac8ac --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt @@ -0,0 +1,76 @@ +package com.casic.smart.town.sanxi.fragment + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.Fragment +import com.amap.api.maps.AMap +import com.amap.api.maps.AMapOptions +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.view.MonitorRecordActivity +import com.pengxh.kt.lite.extensions.navigatePageTo +import com.pengxh.kt.lite.extensions.show +import kotlinx.android.synthetic.main.fragment_monitor.view.* + +class MonitorPageFragment : Fragment() { + + private val kTag = "HomePageFragment" + private lateinit var monitorView: View + private lateinit var aMap: AMap + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? + ): View { + monitorView = inflater.inflate(R.layout.fragment_monitor, container, false) + //地图初始化 + initMap(savedInstanceState) + + monitorView.rightOperateView.setOnClickListener { + requireContext().navigatePageTo() + } + return monitorView + } + + private fun initMap(savedInstanceState: Bundle?) { + monitorView.mapView.onCreate(savedInstanceState) + aMap = monitorView.mapView.map + aMap.mapType = AMap.MAP_TYPE_NORMAL + val uiSettings = aMap.uiSettings + uiSettings.isCompassEnabled = true + uiSettings.zoomPosition = AMapOptions.ZOOM_POSITION_RIGHT_CENTER + uiSettings.isTiltGesturesEnabled = false//不许地图随手势倾斜角度 + + // 地图加载成功监听 +// aMap.addOnMapLoadedListener(this) + // 地图缩放监听 +// aMap.addOnCameraChangeListener(this) + // marker 点击事件监听 +// aMap.addOnMarkerClickListener(this) + // 点击marker弹出自定义popup +// aMap.setInfoWindowAdapter(this) + //信息窗点击事件 +// aMap.addOnInfoWindowClickListener(this) + } + + /***以下是地图生命周期管理************************************************************************/ + override fun onResume() { + super.onResume() + monitorView.mapView.onResume() + } + + override fun onPause() { + super.onPause() + monitorView.mapView.onPause() + } + + override fun onSaveInstanceState(outState: Bundle) { + super.onSaveInstanceState(outState) + monitorView.mapView.onSaveInstanceState(outState) + } + + override fun onDestroy() { + super.onDestroy() + monitorView.mapView.onDestroy() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt new file mode 100644 index 0000000..e84df12 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class StatisticsPageFragment : KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_statistics + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java new file mode 100644 index 0000000..68d7901 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java @@ -0,0 +1,255 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.database.Cursor; +import android.database.sqlite.SQLiteStatement; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.Property; +import org.greenrobot.greendao.internal.DaoConfig; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseStatement; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * DAO for table "ALARM_MESSAGE_LOCALE_BEAN". +*/ +public class AlarmMessageLocaleBeanDao extends AbstractDao { + + public static final String TABLENAME = "ALARM_MESSAGE_LOCALE_BEAN"; + + /** + * Properties of entity AlarmMessageLocaleBean.
+ * Can be used for QueryBuilder and for referencing column names. + */ + public static class Properties { + public final static Property Id = new Property(0, Long.class, "id", true, "_id"); + public final static Property MessageId = new Property(1, String.class, "messageId", false, "MESSAGE_ID"); + public final static Property AppId = new Property(2, String.class, "appId", false, "APP_ID"); + public final static Property ClientId = new Property(3, String.class, "clientId", false, "CLIENT_ID"); + public final static Property TaskId = new Property(4, String.class, "taskId", false, "TASK_ID"); + public final static Property UserId = new Property(5, String.class, "userId", false, "USER_ID"); + public final static Property Title = new Property(6, String.class, "title", false, "TITLE"); + public final static Property Content = new Property(7, String.class, "content", false, "CONTENT"); + public final static Property DeviceCode = new Property(8, String.class, "deviceCode", false, "DEVICE_CODE"); + public final static Property IsRead = new Property(9, String.class, "isRead", false, "IS_READ"); + public final static Property AlarmTime = new Property(10, String.class, "alarmTime", false, "ALARM_TIME"); + } + + + public AlarmMessageLocaleBeanDao(DaoConfig config) { + super(config); + } + + public AlarmMessageLocaleBeanDao(DaoConfig config, DaoSession daoSession) { + super(config, daoSession); + } + + /** Creates the underlying database table. */ + public static void createTable(Database db, boolean ifNotExists) { + String constraint = ifNotExists? "IF NOT EXISTS ": ""; + db.execSQL("CREATE TABLE " + constraint + "\"ALARM_MESSAGE_LOCALE_BEAN\" (" + // + "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id + "\"MESSAGE_ID\" TEXT UNIQUE ," + // 1: messageId + "\"APP_ID\" TEXT," + // 2: appId + "\"CLIENT_ID\" TEXT," + // 3: clientId + "\"TASK_ID\" TEXT," + // 4: taskId + "\"USER_ID\" TEXT," + // 5: userId + "\"TITLE\" TEXT," + // 6: title + "\"CONTENT\" TEXT," + // 7: content + "\"DEVICE_CODE\" TEXT," + // 8: deviceCode + "\"IS_READ\" TEXT," + // 9: isRead + "\"ALARM_TIME\" TEXT);"); // 10: alarmTime + } + + /** Drops the underlying database table. */ + public static void dropTable(Database db, boolean ifExists) { + String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"ALARM_MESSAGE_LOCALE_BEAN\""; + db.execSQL(sql); + } + + @Override + protected final void bindValues(DatabaseStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + protected final void bindValues(SQLiteStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + public Long readKey(Cursor cursor, int offset) { + return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); + } + + @Override + public AlarmMessageLocaleBean readEntity(Cursor cursor, int offset) { + AlarmMessageLocaleBean entity = new AlarmMessageLocaleBean( // + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // messageId + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // appId + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // clientId + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // taskId + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // userId + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // title + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // content + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // deviceCode + cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // isRead + cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10) // alarmTime + ); + return entity; + } + + @Override + public void readEntity(Cursor cursor, AlarmMessageLocaleBean entity, int offset) { + entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); + entity.setMessageId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setAppId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setClientId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setTaskId(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); + entity.setUserId(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setTitle(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setContent(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); + entity.setDeviceCode(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); + entity.setIsRead(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9)); + entity.setAlarmTime(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); + } + + @Override + protected final Long updateKeyAfterInsert(AlarmMessageLocaleBean entity, long rowId) { + entity.setId(rowId); + return rowId; + } + + @Override + public Long getKey(AlarmMessageLocaleBean entity) { + if(entity != null) { + return entity.getId(); + } else { + return null; + } + } + + @Override + public boolean hasKey(AlarmMessageLocaleBean entity) { + return entity.getId() != null; + } + + @Override + protected final boolean isEntityUpdateable() { + return true; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java new file mode 100644 index 0000000..4222c40 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java @@ -0,0 +1,96 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.content.Context; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteDatabase.CursorFactory; +import android.util.Log; + +import org.greenrobot.greendao.AbstractDaoMaster; +import org.greenrobot.greendao.database.StandardDatabase; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseOpenHelper; +import org.greenrobot.greendao.identityscope.IdentityScopeType; + + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * Master of DAO (schema version 1): knows all DAOs. + */ +public class DaoMaster extends AbstractDaoMaster { + public static final int SCHEMA_VERSION = 1; + + /** Creates underlying database table using DAOs. */ + public static void createAllTables(Database db, boolean ifNotExists) { + AlarmMessageLocaleBeanDao.createTable(db, ifNotExists); + } + + /** Drops underlying database table using DAOs. */ + public static void dropAllTables(Database db, boolean ifExists) { + AlarmMessageLocaleBeanDao.dropTable(db, ifExists); + } + + /** + * WARNING: Drops all table on Upgrade! Use only during development. + * Convenience method using a {@link DevOpenHelper}. + */ + public static DaoSession newDevSession(Context context, String name) { + Database db = new DevOpenHelper(context, name).getWritableDb(); + DaoMaster daoMaster = new DaoMaster(db); + return daoMaster.newSession(); + } + + public DaoMaster(SQLiteDatabase db) { + this(new StandardDatabase(db)); + } + + public DaoMaster(Database db) { + super(db, SCHEMA_VERSION); + registerDaoClass(AlarmMessageLocaleBeanDao.class); + } + + public DaoSession newSession() { + return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); + } + + public DaoSession newSession(IdentityScopeType type) { + return new DaoSession(db, type, daoConfigMap); + } + + /** + * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} - + */ + public static abstract class OpenHelper extends DatabaseOpenHelper { + public OpenHelper(Context context, String name) { + super(context, name, SCHEMA_VERSION); + } + + public OpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory, SCHEMA_VERSION); + } + + @Override + public void onCreate(Database db) { + Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); + createAllTables(db, false); + } + } + + /** WARNING: Drops all table on Upgrade! Use only during development. */ + public static class DevOpenHelper extends OpenHelper { + public DevOpenHelper(Context context, String name) { + super(context, name); + } + + public DevOpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory); + } + + @Override + public void onUpgrade(Database db, int oldVersion, int newVersion) { + Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); + dropAllTables(db, true); + onCreate(db); + } + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java new file mode 100644 index 0000000..480ed84 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java @@ -0,0 +1,48 @@ +package com.casic.smart.town.sanxi.greendao; + +import java.util.Map; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.AbstractDaoSession; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.identityscope.IdentityScopeType; +import org.greenrobot.greendao.internal.DaoConfig; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. + +/** + * {@inheritDoc} + * + * @see org.greenrobot.greendao.AbstractDaoSession + */ +public class DaoSession extends AbstractDaoSession { + + private final DaoConfig alarmMessageLocaleBeanDaoConfig; + + private final AlarmMessageLocaleBeanDao alarmMessageLocaleBeanDao; + + public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> + daoConfigMap) { + super(db); + + alarmMessageLocaleBeanDaoConfig = daoConfigMap.get(AlarmMessageLocaleBeanDao.class).clone(); + alarmMessageLocaleBeanDaoConfig.initIdentityScope(type); + + alarmMessageLocaleBeanDao = new AlarmMessageLocaleBeanDao(alarmMessageLocaleBeanDaoConfig, this); + + registerDao(AlarmMessageLocaleBean.class, alarmMessageLocaleBeanDao); + } + + public void clear() { + alarmMessageLocaleBeanDaoConfig.clearIdentityScope(); + } + + public AlarmMessageLocaleBeanDao getAlarmMessageLocaleBeanDao() { + return alarmMessageLocaleBeanDao; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt new file mode 100644 index 0000000..875cb8c --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt @@ -0,0 +1,5 @@ +package com.casic.smart.town.sanxi.service + +import com.igexin.sdk.PushService + +class ApplicationPushService : PushService() \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt new file mode 100644 index 0000000..396129f --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt @@ -0,0 +1,84 @@ +package com.casic.smart.town.sanxi.service + +import android.content.Context +import android.os.Message +import android.util.Log +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.casic.smart.town.sanxi.view.MainActivity +import com.igexin.sdk.GTIntentService +import com.igexin.sdk.message.GTCmdMessage +import com.igexin.sdk.message.GTNotificationMessage +import com.igexin.sdk.message.GTTransmitMessage +import com.pengxh.kt.lite.extensions.toJson + +class PushIntentService : GTIntentService() { + + private val kTag = "SmartWellIntentService" + + override fun onReceiveServicePid(context: Context?, pid: Int) { + + } + + // 透传消息 + override fun onReceiveMessageData(context: Context?, msg: GTTransmitMessage?) { + Log.d(kTag, "透传消息 -> msg = $msg") + } + + // 接收 cid + override fun onReceiveClientId(context: Context?, clientid: String?) { + Log.d(kTag, "onReceiveClientId -> $clientid") + //通知MainActivity注册个推服务 + val msg: Message = MainActivity.weakReferenceHandler.obtainMessage() + msg.what = LocaleConstant.PUSH_REGISTER + msg.obj = clientid + MainActivity.weakReferenceHandler.sendMessage(msg) + } + + // cid 离线上线通知 + override fun onReceiveOnlineState(context: Context?, online: Boolean) { + + } + + // 各种事件处理回执 + override fun onReceiveCommandResult(context: Context?, msg: GTCmdMessage?) { + + } + + // 通知到达 + override fun onNotificationMessageArrived(context: Context?, msg: GTNotificationMessage?) { + //报警 +// { +// "content": "设备编号[412022030361]发生井盖开盖报警", +// "messageId": "380abf9a79d34306a2683dc9bf96ee78", +// "taskId": "OSL-0830_4hmfimp3Vu684wo3SjXso9", +// "title": "告警提醒", +// "appid": "HKv8K9qARd6WckZ1o2Vbu4", +// "clientId": "e78beacc42e9a02ae6fb9087eb2b1171", +// "pkgName": "com.casic.app.smartwell" +// } + if (msg == null) { + return + } + Log.d(kTag, "通知到达 -> msg = ${msg.toJson()}") +// val userDetailJson = SaveKeyValues.getValue(LocaleConstant.USER_DETAIL_MODEL, "") as String +// var userId = "" +// if (userDetailJson.isNotBlank()) { +// val userDataModel = Gson().fromJson( +// userDetailJson, object : TypeToken() {}.type +// ) +// userId = userDataModel.id.toString() +// } +// //解析编号 +// val splitArray = msg.content.split("\\[|\\]".toRegex()) +// DataBaseManager.instance.insertNotice( +// msg.messageId, msg.appid, msg.clientId, msg.taskId, +// userId, msg.title, msg.content, splitArray[1], "0", +// System.currentTimeMillis().timestampToCompleteDate() +// ) + } + + // 通知点击 + override fun onNotificationMessageClicked(context: Context?, msg: GTNotificationMessage?) { + Log.d(kTag, "通知点击 -> msg = $msg") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt new file mode 100644 index 0000000..daa7c38 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt @@ -0,0 +1,14 @@ +package com.casic.smart.town.sanxi.util + +import android.content.Context +import me.leolin.shortcutbadger.ShortcutBadger + +object BadeHelper { + fun setBadgeNum(context: Context, badgeCount: Int) { + if (badgeCount == 0) { + ShortcutBadger.removeCount(context) + } else { + ShortcutBadger.applyCount(context, badgeCount) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt new file mode 100644 index 0000000..0a52ef2 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt @@ -0,0 +1,75 @@ +package com.casic.smart.town.sanxi.util + +import com.casic.smart.town.sanxi.base.BaseApplication +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao + +class DataBaseManager private constructor() { + + companion object { + //Kotlin委托模式双重锁单例 + val instance: DataBaseManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) { + DataBaseManager() + } + } + + private val beanDao = + BaseApplication.obtainInstance().obtainDaoSession().alarmMessageLocaleBeanDao + +// fun insertNotice( +// messageId: String, appid: String, clientId: String, +// taskId: String, userId: String, title: String, +// content: String, deviceCode: String, isRead: String, +// noticeTime: String +// ) { +// val noticeLocaleBean = NoticeLocaleBean() +// noticeLocaleBean.messageId = messageId +// noticeLocaleBean.appid = appid +// noticeLocaleBean.clientId = clientId +// noticeLocaleBean.taskId = taskId +// noticeLocaleBean.userId = userId +// noticeLocaleBean.title = title +// noticeLocaleBean.content = content +// noticeLocaleBean.deviceCode = deviceCode +// noticeLocaleBean.isRead = isRead +// noticeLocaleBean.noticeTime = noticeTime +// beanDao.insert(noticeLocaleBean) +// //角标设置 +// BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadNotice()) +// } + + fun deleteByMessageId(messageId: String) { + val result = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).list() + beanDao.deleteInTx(result) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun updateNoticeByMessageId(messageId: String) { + val noticeLocaleBean = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).unique() ?: return + noticeLocaleBean.isRead = "1" + beanDao.update(noticeLocaleBean) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun queryMessageByPage(userId: String, offset: Int): MutableList { + return BaseApplication.obtainInstance().obtainDaoSession() + .queryBuilder(AlarmMessageLocaleBean::class.java) + .where(AlarmMessageLocaleBeanDao.Properties.UserId.eq(userId)) + .offset(offset * LocaleConstant.PAGE_LIMIT) + .orderDesc(AlarmMessageLocaleBeanDao.Properties.AlarmTime) + .limit(LocaleConstant.PAGE_LIMIT) + .list() + } + + private fun queryUnReadMessage(): Int { + return beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.IsRead.eq("0") + ).list().size + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt new file mode 100644 index 0000000..52926a8 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt @@ -0,0 +1,31 @@ +package com.casic.smart.town.sanxi.util; + +import android.app.Activity +import android.view.WindowManager +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object LoadingDialogHub { + private lateinit var loadingDialog: QMUITipDialog + + fun show(activity: Activity, message: String) { + loadingDialog = QMUITipDialog + .Builder(activity) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_LOADING) + .setTipWord(message) + .create() + if (!activity.isDestroyed) { + try { + loadingDialog.show() + } catch (e: WindowManager.BadTokenException) { + e.printStackTrace() + } + } + } + + + fun dismiss() { + if (loadingDialog.isShowing) { + loadingDialog.dismiss() + } + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt new file mode 100644 index 0000000..de61c9a --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.util + +import android.Manifest + +object LocaleConstant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.READ_PHONE_STATE, + Manifest.permission.ACCESS_COARSE_LOCATION, + Manifest.permission.READ_EXTERNAL_STORAGE + ) + + const val PERMISSIONS_CODE = 999 + const val PUSH_REGISTER = 2022100101 + const val PAGE_LIMIT = 20 +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt new file mode 100644 index 0000000..3bea1c9 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt @@ -0,0 +1,112 @@ +package com.casic.smart.town.sanxi.view + +import android.view.KeyEvent +import android.view.MenuItem +import androidx.fragment.app.Fragment +import androidx.viewpager.widget.ViewPager +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.adapter.ViewPagerAdapter +import com.casic.smart.town.sanxi.fragment.AlarmPageFragment +import com.casic.smart.town.sanxi.fragment.MonitorPageFragment +import com.casic.smart.town.sanxi.fragment.StatisticsPageFragment +import com.gyf.immersionbar.ImmersionBar +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.base.KotlinBaseActivity +import com.pengxh.kt.lite.extensions.convertColor +import com.pengxh.kt.lite.extensions.show +import com.pengxh.kt.lite.utils.ImmerseStatusBarUtil +import com.pengxh.kt.lite.utils.WeakReferenceHandler +import kotlinx.android.synthetic.main.activity_main.* + +class MainActivity : KotlinBaseActivity() { + + companion object { + lateinit var weakReferenceHandler: WeakReferenceHandler + } + + private val kTag = "MainActivity" + private var menuItem: MenuItem? = null + private var fragmentPages: ArrayList = ArrayList() + private var clickTime: Long = 0 + + init { + fragmentPages.add(StatisticsPageFragment()) + fragmentPages.add(MonitorPageFragment()) + fragmentPages.add(AlarmPageFragment()) + } + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + ImmersionBar.with(this).statusBarDarkFont(false).init() + ImmerseStatusBarUtil.setColor(this, R.color.mainThemeColor.convertColor(this)) + } + + override fun initData() { + //推送,多次调用 SDK 初始化并无影响。 + PushManager.getInstance().initialize(this) + weakReferenceHandler = WeakReferenceHandler { + + true + } + } + + override fun observeRequestState() { + + } + + override fun initEvent() { + bottomNavigation.itemIconTintList = null + bottomNavigation.setOnNavigationItemSelectedListener { menuItem -> + when (menuItem.itemId) { + R.id.nav_statistics -> { + mainViewPager.currentItem = 0 + } + R.id.nav_monitor -> { + mainViewPager.currentItem = 1 + } + R.id.nav_alarm -> { + mainViewPager.currentItem = 2 + } + } + false + } + mainViewPager.adapter = ViewPagerAdapter(fragmentPages, supportFragmentManager) + mainViewPager.offscreenPageLimit = fragmentPages.size //缓存页数 + mainViewPager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener { + override fun onPageScrollStateChanged(state: Int) { + + } + + override fun onPageScrolled( + position: Int, + positionOffset: Float, + positionOffsetPixels: Int + ) { + + } + + override fun onPageSelected(position: Int) { + if (menuItem != null) { + menuItem!!.isChecked = false + } else { + bottomNavigation.menu.getItem(0).isChecked = false + } + menuItem = bottomNavigation.menu.getItem(position) + menuItem!!.isChecked = true + } + }) + } + + override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean { + return if (keyCode == KeyEvent.KEYCODE_BACK) { + if (System.currentTimeMillis() - clickTime > 2000) { + "再按一次退出程序".show(this) + clickTime = System.currentTimeMillis() + true + } else { + super.onKeyDown(keyCode, event) + } + } else super.onKeyDown(keyCode, event) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt new file mode 100644 index 0000000..c5d8b22 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.view + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseActivity + +class MonitorRecordActivity : KotlinBaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_monitor_record + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..10cfdbf --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*.iml +.gradle +/local.properties +/.idea +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..a4cd2ca --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,101 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'org.greenrobot.greendao' + +android { +// signingConfigs { +// release { +// storeFile file('/Users/a203/Desktop/AndroidProjects/CasicSmartWell/app/CasicSmartWell.jks') +// storePassword '123456789' +// keyAlias 'key0' +// keyPassword '123456789' +// } +// } + compileSdkVersion 31 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.smart.town.sanxi" + minSdkVersion 23 + targetSdkVersion 31 + versionCode 1 + versionName "1.0.0" + + manifestPlaceholders = [GETUI_APPID: "A9V4DvwLcdAqkFCQuFyhq6"] + } + + buildTypes { + release { + minifyEnabled false +// signingConfig signingConfigs.release + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + + ndk { abiFilters "armeabi", "armeabi-v7a", "arm64-v8" } + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlin { + experimental { + coroutines 'enable' + } + } + + greendao { + schemaVersion 1//数据库版本号 + targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 + daoPackage 'com.casic.smart.town.sanxi.greendao'//设置DaoMaster、DaoSession、Dao包名 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + //基础依赖库 + implementation files('libs/lite-release.aar') + implementation 'androidx.appcompat:appcompat:1.4.2' + implementation 'androidx.core:core-ktx:1.8.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:3.0.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' + //MVVM+LiveData + implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.1" + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0" + implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + //Kotlin协程 + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1' + //图片加载框架 + implementation 'com.github.bumptech.glide:glide:4.9.0' + //返回值转换器 + implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' + implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + //okhttp3日志拦截器 + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //网络请求和接口封装 + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.9.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.9.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' + //高德地图 + implementation 'com.amap.api:3dmap:latest.integration' + //推送SDK + implementation 'com.getui:gtsdk:3.2.10.0' //个推SDK + implementation 'com.getui:gtc:3.1.9.0' //个推核心组件 + //数据库框架 + implementation 'org.greenrobot:greendao:3.3.0' + //桌面角标 + implementation "me.leolin:ShortcutBadger:1.1.22@aar" +} \ No newline at end of file diff --git a/app/libs/lite-release.aar b/app/libs/lite-release.aar new file mode 100644 index 0000000..45da4df --- /dev/null +++ b/app/libs/lite-release.aar Binary files differ diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /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 \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..a83c28a --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/svg/monitor.svg b/app/src/main/assets/svg/monitor.svg new file mode 100644 index 0000000..c8d3e25 --- /dev/null +++ b/app/src/main/assets/svg/monitor.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/msg.svg b/app/src/main/assets/svg/msg.svg new file mode 100644 index 0000000..e864e48 --- /dev/null +++ b/app/src/main/assets/svg/msg.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/statistics.svg b/app/src/main/assets/svg/statistics.svg new file mode 100644 index 0000000..974000e --- /dev/null +++ b/app/src/main/assets/svg/statistics.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt new file mode 100644 index 0000000..6b9cce0 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.adapter + +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentManager +import androidx.fragment.app.FragmentPagerAdapter + +class ViewPagerAdapter(list: ArrayList, manager: FragmentManager) : + FragmentPagerAdapter(manager) { + + private var pageList: List = list + + override fun getItem(position: Int) = pageList[position] + + override fun getCount() = pageList.size +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt new file mode 100644 index 0000000..4e017b1 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt @@ -0,0 +1,40 @@ +package com.casic.smart.town.sanxi.base + +import android.app.Application +import android.util.Log +import com.casic.smart.town.sanxi.greendao.DaoMaster +import com.casic.smart.town.sanxi.greendao.DaoSession +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + private val kTag = "BaseApplication" + + companion object { + private var instance: BaseApplication by Delegates.notNull() + + fun obtainInstance() = instance + + private lateinit var daoSession: DaoSession + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences(this) + //推送 + PushManager.getInstance().initialize(this) + PushManager.getInstance().setDebugLogger(this) { + Log.d(kTag, it) + } + val devOpenHelper = DaoMaster.DevOpenHelper(this, "SmartTown.db", null) + val daoMaster = DaoMaster(devOpenHelper.writableDatabase) + daoSession = daoMaster.newSession() + } + + fun obtainDaoSession(): DaoSession { + return daoSession + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java new file mode 100644 index 0000000..b8f67dc --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java @@ -0,0 +1,133 @@ +package com.casic.smart.town.sanxi.bean; + +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Generated; +import org.greenrobot.greendao.annotation.Id; +import org.greenrobot.greendao.annotation.Unique; + +@Entity +public class AlarmMessageLocaleBean { + @Id(autoincrement = true) + private Long id;//主键自增 + + @Unique + private String messageId; + private String appId; + private String clientId; + private String taskId; + private String userId; + private String title; + private String content; + private String deviceCode; + private String isRead;//0-未读,1-已读 + private String alarmTime; + + @Generated(hash = 566950134) + public AlarmMessageLocaleBean(Long id, String messageId, String appId, + String clientId, String taskId, String userId, String title, + String content, String deviceCode, String isRead, String alarmTime) { + this.id = id; + this.messageId = messageId; + this.appId = appId; + this.clientId = clientId; + this.taskId = taskId; + this.userId = userId; + this.title = title; + this.content = content; + this.deviceCode = deviceCode; + this.isRead = isRead; + this.alarmTime = alarmTime; + } + + @Generated(hash = 1737519562) + public AlarmMessageLocaleBean() { + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getMessageId() { + return this.messageId; + } + + public void setMessageId(String messageId) { + this.messageId = messageId; + } + + public String getAppId() { + return this.appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public String getClientId() { + return this.clientId; + } + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public String getTaskId() { + return this.taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getUserId() { + return this.userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getTitle() { + return this.title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return this.content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getDeviceCode() { + return this.deviceCode; + } + + public void setDeviceCode(String deviceCode) { + this.deviceCode = deviceCode; + } + + public String getIsRead() { + return this.isRead; + } + + public void setIsRead(String isRead) { + this.isRead = isRead; + } + + public String getAlarmTime() { + return this.alarmTime; + } + + public void setAlarmTime(String alarmTime) { + this.alarmTime = alarmTime; + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt new file mode 100644 index 0000000..650e201 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class AlarmPageFragment: KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_alarm + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt new file mode 100644 index 0000000..deac8ac --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt @@ -0,0 +1,76 @@ +package com.casic.smart.town.sanxi.fragment + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.Fragment +import com.amap.api.maps.AMap +import com.amap.api.maps.AMapOptions +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.view.MonitorRecordActivity +import com.pengxh.kt.lite.extensions.navigatePageTo +import com.pengxh.kt.lite.extensions.show +import kotlinx.android.synthetic.main.fragment_monitor.view.* + +class MonitorPageFragment : Fragment() { + + private val kTag = "HomePageFragment" + private lateinit var monitorView: View + private lateinit var aMap: AMap + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? + ): View { + monitorView = inflater.inflate(R.layout.fragment_monitor, container, false) + //地图初始化 + initMap(savedInstanceState) + + monitorView.rightOperateView.setOnClickListener { + requireContext().navigatePageTo() + } + return monitorView + } + + private fun initMap(savedInstanceState: Bundle?) { + monitorView.mapView.onCreate(savedInstanceState) + aMap = monitorView.mapView.map + aMap.mapType = AMap.MAP_TYPE_NORMAL + val uiSettings = aMap.uiSettings + uiSettings.isCompassEnabled = true + uiSettings.zoomPosition = AMapOptions.ZOOM_POSITION_RIGHT_CENTER + uiSettings.isTiltGesturesEnabled = false//不许地图随手势倾斜角度 + + // 地图加载成功监听 +// aMap.addOnMapLoadedListener(this) + // 地图缩放监听 +// aMap.addOnCameraChangeListener(this) + // marker 点击事件监听 +// aMap.addOnMarkerClickListener(this) + // 点击marker弹出自定义popup +// aMap.setInfoWindowAdapter(this) + //信息窗点击事件 +// aMap.addOnInfoWindowClickListener(this) + } + + /***以下是地图生命周期管理************************************************************************/ + override fun onResume() { + super.onResume() + monitorView.mapView.onResume() + } + + override fun onPause() { + super.onPause() + monitorView.mapView.onPause() + } + + override fun onSaveInstanceState(outState: Bundle) { + super.onSaveInstanceState(outState) + monitorView.mapView.onSaveInstanceState(outState) + } + + override fun onDestroy() { + super.onDestroy() + monitorView.mapView.onDestroy() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt new file mode 100644 index 0000000..e84df12 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class StatisticsPageFragment : KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_statistics + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java new file mode 100644 index 0000000..68d7901 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java @@ -0,0 +1,255 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.database.Cursor; +import android.database.sqlite.SQLiteStatement; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.Property; +import org.greenrobot.greendao.internal.DaoConfig; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseStatement; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * DAO for table "ALARM_MESSAGE_LOCALE_BEAN". +*/ +public class AlarmMessageLocaleBeanDao extends AbstractDao { + + public static final String TABLENAME = "ALARM_MESSAGE_LOCALE_BEAN"; + + /** + * Properties of entity AlarmMessageLocaleBean.
+ * Can be used for QueryBuilder and for referencing column names. + */ + public static class Properties { + public final static Property Id = new Property(0, Long.class, "id", true, "_id"); + public final static Property MessageId = new Property(1, String.class, "messageId", false, "MESSAGE_ID"); + public final static Property AppId = new Property(2, String.class, "appId", false, "APP_ID"); + public final static Property ClientId = new Property(3, String.class, "clientId", false, "CLIENT_ID"); + public final static Property TaskId = new Property(4, String.class, "taskId", false, "TASK_ID"); + public final static Property UserId = new Property(5, String.class, "userId", false, "USER_ID"); + public final static Property Title = new Property(6, String.class, "title", false, "TITLE"); + public final static Property Content = new Property(7, String.class, "content", false, "CONTENT"); + public final static Property DeviceCode = new Property(8, String.class, "deviceCode", false, "DEVICE_CODE"); + public final static Property IsRead = new Property(9, String.class, "isRead", false, "IS_READ"); + public final static Property AlarmTime = new Property(10, String.class, "alarmTime", false, "ALARM_TIME"); + } + + + public AlarmMessageLocaleBeanDao(DaoConfig config) { + super(config); + } + + public AlarmMessageLocaleBeanDao(DaoConfig config, DaoSession daoSession) { + super(config, daoSession); + } + + /** Creates the underlying database table. */ + public static void createTable(Database db, boolean ifNotExists) { + String constraint = ifNotExists? "IF NOT EXISTS ": ""; + db.execSQL("CREATE TABLE " + constraint + "\"ALARM_MESSAGE_LOCALE_BEAN\" (" + // + "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id + "\"MESSAGE_ID\" TEXT UNIQUE ," + // 1: messageId + "\"APP_ID\" TEXT," + // 2: appId + "\"CLIENT_ID\" TEXT," + // 3: clientId + "\"TASK_ID\" TEXT," + // 4: taskId + "\"USER_ID\" TEXT," + // 5: userId + "\"TITLE\" TEXT," + // 6: title + "\"CONTENT\" TEXT," + // 7: content + "\"DEVICE_CODE\" TEXT," + // 8: deviceCode + "\"IS_READ\" TEXT," + // 9: isRead + "\"ALARM_TIME\" TEXT);"); // 10: alarmTime + } + + /** Drops the underlying database table. */ + public static void dropTable(Database db, boolean ifExists) { + String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"ALARM_MESSAGE_LOCALE_BEAN\""; + db.execSQL(sql); + } + + @Override + protected final void bindValues(DatabaseStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + protected final void bindValues(SQLiteStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + public Long readKey(Cursor cursor, int offset) { + return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); + } + + @Override + public AlarmMessageLocaleBean readEntity(Cursor cursor, int offset) { + AlarmMessageLocaleBean entity = new AlarmMessageLocaleBean( // + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // messageId + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // appId + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // clientId + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // taskId + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // userId + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // title + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // content + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // deviceCode + cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // isRead + cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10) // alarmTime + ); + return entity; + } + + @Override + public void readEntity(Cursor cursor, AlarmMessageLocaleBean entity, int offset) { + entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); + entity.setMessageId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setAppId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setClientId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setTaskId(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); + entity.setUserId(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setTitle(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setContent(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); + entity.setDeviceCode(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); + entity.setIsRead(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9)); + entity.setAlarmTime(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); + } + + @Override + protected final Long updateKeyAfterInsert(AlarmMessageLocaleBean entity, long rowId) { + entity.setId(rowId); + return rowId; + } + + @Override + public Long getKey(AlarmMessageLocaleBean entity) { + if(entity != null) { + return entity.getId(); + } else { + return null; + } + } + + @Override + public boolean hasKey(AlarmMessageLocaleBean entity) { + return entity.getId() != null; + } + + @Override + protected final boolean isEntityUpdateable() { + return true; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java new file mode 100644 index 0000000..4222c40 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java @@ -0,0 +1,96 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.content.Context; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteDatabase.CursorFactory; +import android.util.Log; + +import org.greenrobot.greendao.AbstractDaoMaster; +import org.greenrobot.greendao.database.StandardDatabase; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseOpenHelper; +import org.greenrobot.greendao.identityscope.IdentityScopeType; + + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * Master of DAO (schema version 1): knows all DAOs. + */ +public class DaoMaster extends AbstractDaoMaster { + public static final int SCHEMA_VERSION = 1; + + /** Creates underlying database table using DAOs. */ + public static void createAllTables(Database db, boolean ifNotExists) { + AlarmMessageLocaleBeanDao.createTable(db, ifNotExists); + } + + /** Drops underlying database table using DAOs. */ + public static void dropAllTables(Database db, boolean ifExists) { + AlarmMessageLocaleBeanDao.dropTable(db, ifExists); + } + + /** + * WARNING: Drops all table on Upgrade! Use only during development. + * Convenience method using a {@link DevOpenHelper}. + */ + public static DaoSession newDevSession(Context context, String name) { + Database db = new DevOpenHelper(context, name).getWritableDb(); + DaoMaster daoMaster = new DaoMaster(db); + return daoMaster.newSession(); + } + + public DaoMaster(SQLiteDatabase db) { + this(new StandardDatabase(db)); + } + + public DaoMaster(Database db) { + super(db, SCHEMA_VERSION); + registerDaoClass(AlarmMessageLocaleBeanDao.class); + } + + public DaoSession newSession() { + return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); + } + + public DaoSession newSession(IdentityScopeType type) { + return new DaoSession(db, type, daoConfigMap); + } + + /** + * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} - + */ + public static abstract class OpenHelper extends DatabaseOpenHelper { + public OpenHelper(Context context, String name) { + super(context, name, SCHEMA_VERSION); + } + + public OpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory, SCHEMA_VERSION); + } + + @Override + public void onCreate(Database db) { + Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); + createAllTables(db, false); + } + } + + /** WARNING: Drops all table on Upgrade! Use only during development. */ + public static class DevOpenHelper extends OpenHelper { + public DevOpenHelper(Context context, String name) { + super(context, name); + } + + public DevOpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory); + } + + @Override + public void onUpgrade(Database db, int oldVersion, int newVersion) { + Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); + dropAllTables(db, true); + onCreate(db); + } + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java new file mode 100644 index 0000000..480ed84 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java @@ -0,0 +1,48 @@ +package com.casic.smart.town.sanxi.greendao; + +import java.util.Map; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.AbstractDaoSession; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.identityscope.IdentityScopeType; +import org.greenrobot.greendao.internal.DaoConfig; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. + +/** + * {@inheritDoc} + * + * @see org.greenrobot.greendao.AbstractDaoSession + */ +public class DaoSession extends AbstractDaoSession { + + private final DaoConfig alarmMessageLocaleBeanDaoConfig; + + private final AlarmMessageLocaleBeanDao alarmMessageLocaleBeanDao; + + public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> + daoConfigMap) { + super(db); + + alarmMessageLocaleBeanDaoConfig = daoConfigMap.get(AlarmMessageLocaleBeanDao.class).clone(); + alarmMessageLocaleBeanDaoConfig.initIdentityScope(type); + + alarmMessageLocaleBeanDao = new AlarmMessageLocaleBeanDao(alarmMessageLocaleBeanDaoConfig, this); + + registerDao(AlarmMessageLocaleBean.class, alarmMessageLocaleBeanDao); + } + + public void clear() { + alarmMessageLocaleBeanDaoConfig.clearIdentityScope(); + } + + public AlarmMessageLocaleBeanDao getAlarmMessageLocaleBeanDao() { + return alarmMessageLocaleBeanDao; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt new file mode 100644 index 0000000..875cb8c --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt @@ -0,0 +1,5 @@ +package com.casic.smart.town.sanxi.service + +import com.igexin.sdk.PushService + +class ApplicationPushService : PushService() \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt new file mode 100644 index 0000000..396129f --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt @@ -0,0 +1,84 @@ +package com.casic.smart.town.sanxi.service + +import android.content.Context +import android.os.Message +import android.util.Log +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.casic.smart.town.sanxi.view.MainActivity +import com.igexin.sdk.GTIntentService +import com.igexin.sdk.message.GTCmdMessage +import com.igexin.sdk.message.GTNotificationMessage +import com.igexin.sdk.message.GTTransmitMessage +import com.pengxh.kt.lite.extensions.toJson + +class PushIntentService : GTIntentService() { + + private val kTag = "SmartWellIntentService" + + override fun onReceiveServicePid(context: Context?, pid: Int) { + + } + + // 透传消息 + override fun onReceiveMessageData(context: Context?, msg: GTTransmitMessage?) { + Log.d(kTag, "透传消息 -> msg = $msg") + } + + // 接收 cid + override fun onReceiveClientId(context: Context?, clientid: String?) { + Log.d(kTag, "onReceiveClientId -> $clientid") + //通知MainActivity注册个推服务 + val msg: Message = MainActivity.weakReferenceHandler.obtainMessage() + msg.what = LocaleConstant.PUSH_REGISTER + msg.obj = clientid + MainActivity.weakReferenceHandler.sendMessage(msg) + } + + // cid 离线上线通知 + override fun onReceiveOnlineState(context: Context?, online: Boolean) { + + } + + // 各种事件处理回执 + override fun onReceiveCommandResult(context: Context?, msg: GTCmdMessage?) { + + } + + // 通知到达 + override fun onNotificationMessageArrived(context: Context?, msg: GTNotificationMessage?) { + //报警 +// { +// "content": "设备编号[412022030361]发生井盖开盖报警", +// "messageId": "380abf9a79d34306a2683dc9bf96ee78", +// "taskId": "OSL-0830_4hmfimp3Vu684wo3SjXso9", +// "title": "告警提醒", +// "appid": "HKv8K9qARd6WckZ1o2Vbu4", +// "clientId": "e78beacc42e9a02ae6fb9087eb2b1171", +// "pkgName": "com.casic.app.smartwell" +// } + if (msg == null) { + return + } + Log.d(kTag, "通知到达 -> msg = ${msg.toJson()}") +// val userDetailJson = SaveKeyValues.getValue(LocaleConstant.USER_DETAIL_MODEL, "") as String +// var userId = "" +// if (userDetailJson.isNotBlank()) { +// val userDataModel = Gson().fromJson( +// userDetailJson, object : TypeToken() {}.type +// ) +// userId = userDataModel.id.toString() +// } +// //解析编号 +// val splitArray = msg.content.split("\\[|\\]".toRegex()) +// DataBaseManager.instance.insertNotice( +// msg.messageId, msg.appid, msg.clientId, msg.taskId, +// userId, msg.title, msg.content, splitArray[1], "0", +// System.currentTimeMillis().timestampToCompleteDate() +// ) + } + + // 通知点击 + override fun onNotificationMessageClicked(context: Context?, msg: GTNotificationMessage?) { + Log.d(kTag, "通知点击 -> msg = $msg") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt new file mode 100644 index 0000000..daa7c38 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt @@ -0,0 +1,14 @@ +package com.casic.smart.town.sanxi.util + +import android.content.Context +import me.leolin.shortcutbadger.ShortcutBadger + +object BadeHelper { + fun setBadgeNum(context: Context, badgeCount: Int) { + if (badgeCount == 0) { + ShortcutBadger.removeCount(context) + } else { + ShortcutBadger.applyCount(context, badgeCount) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt new file mode 100644 index 0000000..0a52ef2 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt @@ -0,0 +1,75 @@ +package com.casic.smart.town.sanxi.util + +import com.casic.smart.town.sanxi.base.BaseApplication +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao + +class DataBaseManager private constructor() { + + companion object { + //Kotlin委托模式双重锁单例 + val instance: DataBaseManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) { + DataBaseManager() + } + } + + private val beanDao = + BaseApplication.obtainInstance().obtainDaoSession().alarmMessageLocaleBeanDao + +// fun insertNotice( +// messageId: String, appid: String, clientId: String, +// taskId: String, userId: String, title: String, +// content: String, deviceCode: String, isRead: String, +// noticeTime: String +// ) { +// val noticeLocaleBean = NoticeLocaleBean() +// noticeLocaleBean.messageId = messageId +// noticeLocaleBean.appid = appid +// noticeLocaleBean.clientId = clientId +// noticeLocaleBean.taskId = taskId +// noticeLocaleBean.userId = userId +// noticeLocaleBean.title = title +// noticeLocaleBean.content = content +// noticeLocaleBean.deviceCode = deviceCode +// noticeLocaleBean.isRead = isRead +// noticeLocaleBean.noticeTime = noticeTime +// beanDao.insert(noticeLocaleBean) +// //角标设置 +// BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadNotice()) +// } + + fun deleteByMessageId(messageId: String) { + val result = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).list() + beanDao.deleteInTx(result) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun updateNoticeByMessageId(messageId: String) { + val noticeLocaleBean = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).unique() ?: return + noticeLocaleBean.isRead = "1" + beanDao.update(noticeLocaleBean) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun queryMessageByPage(userId: String, offset: Int): MutableList { + return BaseApplication.obtainInstance().obtainDaoSession() + .queryBuilder(AlarmMessageLocaleBean::class.java) + .where(AlarmMessageLocaleBeanDao.Properties.UserId.eq(userId)) + .offset(offset * LocaleConstant.PAGE_LIMIT) + .orderDesc(AlarmMessageLocaleBeanDao.Properties.AlarmTime) + .limit(LocaleConstant.PAGE_LIMIT) + .list() + } + + private fun queryUnReadMessage(): Int { + return beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.IsRead.eq("0") + ).list().size + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt new file mode 100644 index 0000000..52926a8 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt @@ -0,0 +1,31 @@ +package com.casic.smart.town.sanxi.util; + +import android.app.Activity +import android.view.WindowManager +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object LoadingDialogHub { + private lateinit var loadingDialog: QMUITipDialog + + fun show(activity: Activity, message: String) { + loadingDialog = QMUITipDialog + .Builder(activity) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_LOADING) + .setTipWord(message) + .create() + if (!activity.isDestroyed) { + try { + loadingDialog.show() + } catch (e: WindowManager.BadTokenException) { + e.printStackTrace() + } + } + } + + + fun dismiss() { + if (loadingDialog.isShowing) { + loadingDialog.dismiss() + } + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt new file mode 100644 index 0000000..de61c9a --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.util + +import android.Manifest + +object LocaleConstant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.READ_PHONE_STATE, + Manifest.permission.ACCESS_COARSE_LOCATION, + Manifest.permission.READ_EXTERNAL_STORAGE + ) + + const val PERMISSIONS_CODE = 999 + const val PUSH_REGISTER = 2022100101 + const val PAGE_LIMIT = 20 +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt new file mode 100644 index 0000000..3bea1c9 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt @@ -0,0 +1,112 @@ +package com.casic.smart.town.sanxi.view + +import android.view.KeyEvent +import android.view.MenuItem +import androidx.fragment.app.Fragment +import androidx.viewpager.widget.ViewPager +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.adapter.ViewPagerAdapter +import com.casic.smart.town.sanxi.fragment.AlarmPageFragment +import com.casic.smart.town.sanxi.fragment.MonitorPageFragment +import com.casic.smart.town.sanxi.fragment.StatisticsPageFragment +import com.gyf.immersionbar.ImmersionBar +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.base.KotlinBaseActivity +import com.pengxh.kt.lite.extensions.convertColor +import com.pengxh.kt.lite.extensions.show +import com.pengxh.kt.lite.utils.ImmerseStatusBarUtil +import com.pengxh.kt.lite.utils.WeakReferenceHandler +import kotlinx.android.synthetic.main.activity_main.* + +class MainActivity : KotlinBaseActivity() { + + companion object { + lateinit var weakReferenceHandler: WeakReferenceHandler + } + + private val kTag = "MainActivity" + private var menuItem: MenuItem? = null + private var fragmentPages: ArrayList = ArrayList() + private var clickTime: Long = 0 + + init { + fragmentPages.add(StatisticsPageFragment()) + fragmentPages.add(MonitorPageFragment()) + fragmentPages.add(AlarmPageFragment()) + } + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + ImmersionBar.with(this).statusBarDarkFont(false).init() + ImmerseStatusBarUtil.setColor(this, R.color.mainThemeColor.convertColor(this)) + } + + override fun initData() { + //推送,多次调用 SDK 初始化并无影响。 + PushManager.getInstance().initialize(this) + weakReferenceHandler = WeakReferenceHandler { + + true + } + } + + override fun observeRequestState() { + + } + + override fun initEvent() { + bottomNavigation.itemIconTintList = null + bottomNavigation.setOnNavigationItemSelectedListener { menuItem -> + when (menuItem.itemId) { + R.id.nav_statistics -> { + mainViewPager.currentItem = 0 + } + R.id.nav_monitor -> { + mainViewPager.currentItem = 1 + } + R.id.nav_alarm -> { + mainViewPager.currentItem = 2 + } + } + false + } + mainViewPager.adapter = ViewPagerAdapter(fragmentPages, supportFragmentManager) + mainViewPager.offscreenPageLimit = fragmentPages.size //缓存页数 + mainViewPager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener { + override fun onPageScrollStateChanged(state: Int) { + + } + + override fun onPageScrolled( + position: Int, + positionOffset: Float, + positionOffsetPixels: Int + ) { + + } + + override fun onPageSelected(position: Int) { + if (menuItem != null) { + menuItem!!.isChecked = false + } else { + bottomNavigation.menu.getItem(0).isChecked = false + } + menuItem = bottomNavigation.menu.getItem(position) + menuItem!!.isChecked = true + } + }) + } + + override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean { + return if (keyCode == KeyEvent.KEYCODE_BACK) { + if (System.currentTimeMillis() - clickTime > 2000) { + "再按一次退出程序".show(this) + clickTime = System.currentTimeMillis() + true + } else { + super.onKeyDown(keyCode, event) + } + } else super.onKeyDown(keyCode, event) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt new file mode 100644 index 0000000..c5d8b22 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.view + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseActivity + +class MonitorRecordActivity : KotlinBaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_monitor_record + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt new file mode 100644 index 0000000..c478d83 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt @@ -0,0 +1,55 @@ +package com.casic.smart.town.sanxi.view + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.amap.api.maps.MapsInitializer +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.gyf.immersionbar.ImmersionBar +import com.pengxh.kt.lite.extensions.navigatePageTo +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + ImmersionBar.with(this).statusBarDarkFont(true).init() + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (EasyPermissions.hasPermissions(this, *LocaleConstant.USER_PERMISSIONS)) { + startSplashScreenActivity() + } else { + EasyPermissions.requestPermissions( + this@PermissionActivity, + resources.getString(R.string.app_name) + "需要获取相关权限", + LocaleConstant.PERMISSIONS_CODE, + *LocaleConstant.USER_PERMISSIONS + ) + } + } + + private fun startSplashScreenActivity() { + //先把导航隐私政策声明,后面导航会用到 + MapsInitializer.updatePrivacyAgree(this, true) + MapsInitializer.updatePrivacyShow(this, true, true) + this.navigatePageTo() + 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) { + startSplashScreenActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + + } +} \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..10cfdbf --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*.iml +.gradle +/local.properties +/.idea +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..a4cd2ca --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,101 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'org.greenrobot.greendao' + +android { +// signingConfigs { +// release { +// storeFile file('/Users/a203/Desktop/AndroidProjects/CasicSmartWell/app/CasicSmartWell.jks') +// storePassword '123456789' +// keyAlias 'key0' +// keyPassword '123456789' +// } +// } + compileSdkVersion 31 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.smart.town.sanxi" + minSdkVersion 23 + targetSdkVersion 31 + versionCode 1 + versionName "1.0.0" + + manifestPlaceholders = [GETUI_APPID: "A9V4DvwLcdAqkFCQuFyhq6"] + } + + buildTypes { + release { + minifyEnabled false +// signingConfig signingConfigs.release + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + + ndk { abiFilters "armeabi", "armeabi-v7a", "arm64-v8" } + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlin { + experimental { + coroutines 'enable' + } + } + + greendao { + schemaVersion 1//数据库版本号 + targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 + daoPackage 'com.casic.smart.town.sanxi.greendao'//设置DaoMaster、DaoSession、Dao包名 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + //基础依赖库 + implementation files('libs/lite-release.aar') + implementation 'androidx.appcompat:appcompat:1.4.2' + implementation 'androidx.core:core-ktx:1.8.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:3.0.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' + //MVVM+LiveData + implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.1" + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0" + implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + //Kotlin协程 + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1' + //图片加载框架 + implementation 'com.github.bumptech.glide:glide:4.9.0' + //返回值转换器 + implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' + implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + //okhttp3日志拦截器 + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //网络请求和接口封装 + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.9.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.9.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' + //高德地图 + implementation 'com.amap.api:3dmap:latest.integration' + //推送SDK + implementation 'com.getui:gtsdk:3.2.10.0' //个推SDK + implementation 'com.getui:gtc:3.1.9.0' //个推核心组件 + //数据库框架 + implementation 'org.greenrobot:greendao:3.3.0' + //桌面角标 + implementation "me.leolin:ShortcutBadger:1.1.22@aar" +} \ No newline at end of file diff --git a/app/libs/lite-release.aar b/app/libs/lite-release.aar new file mode 100644 index 0000000..45da4df --- /dev/null +++ b/app/libs/lite-release.aar Binary files differ diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /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 \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..a83c28a --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/svg/monitor.svg b/app/src/main/assets/svg/monitor.svg new file mode 100644 index 0000000..c8d3e25 --- /dev/null +++ b/app/src/main/assets/svg/monitor.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/msg.svg b/app/src/main/assets/svg/msg.svg new file mode 100644 index 0000000..e864e48 --- /dev/null +++ b/app/src/main/assets/svg/msg.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/statistics.svg b/app/src/main/assets/svg/statistics.svg new file mode 100644 index 0000000..974000e --- /dev/null +++ b/app/src/main/assets/svg/statistics.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt new file mode 100644 index 0000000..6b9cce0 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.adapter + +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentManager +import androidx.fragment.app.FragmentPagerAdapter + +class ViewPagerAdapter(list: ArrayList, manager: FragmentManager) : + FragmentPagerAdapter(manager) { + + private var pageList: List = list + + override fun getItem(position: Int) = pageList[position] + + override fun getCount() = pageList.size +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt new file mode 100644 index 0000000..4e017b1 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt @@ -0,0 +1,40 @@ +package com.casic.smart.town.sanxi.base + +import android.app.Application +import android.util.Log +import com.casic.smart.town.sanxi.greendao.DaoMaster +import com.casic.smart.town.sanxi.greendao.DaoSession +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + private val kTag = "BaseApplication" + + companion object { + private var instance: BaseApplication by Delegates.notNull() + + fun obtainInstance() = instance + + private lateinit var daoSession: DaoSession + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences(this) + //推送 + PushManager.getInstance().initialize(this) + PushManager.getInstance().setDebugLogger(this) { + Log.d(kTag, it) + } + val devOpenHelper = DaoMaster.DevOpenHelper(this, "SmartTown.db", null) + val daoMaster = DaoMaster(devOpenHelper.writableDatabase) + daoSession = daoMaster.newSession() + } + + fun obtainDaoSession(): DaoSession { + return daoSession + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java new file mode 100644 index 0000000..b8f67dc --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java @@ -0,0 +1,133 @@ +package com.casic.smart.town.sanxi.bean; + +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Generated; +import org.greenrobot.greendao.annotation.Id; +import org.greenrobot.greendao.annotation.Unique; + +@Entity +public class AlarmMessageLocaleBean { + @Id(autoincrement = true) + private Long id;//主键自增 + + @Unique + private String messageId; + private String appId; + private String clientId; + private String taskId; + private String userId; + private String title; + private String content; + private String deviceCode; + private String isRead;//0-未读,1-已读 + private String alarmTime; + + @Generated(hash = 566950134) + public AlarmMessageLocaleBean(Long id, String messageId, String appId, + String clientId, String taskId, String userId, String title, + String content, String deviceCode, String isRead, String alarmTime) { + this.id = id; + this.messageId = messageId; + this.appId = appId; + this.clientId = clientId; + this.taskId = taskId; + this.userId = userId; + this.title = title; + this.content = content; + this.deviceCode = deviceCode; + this.isRead = isRead; + this.alarmTime = alarmTime; + } + + @Generated(hash = 1737519562) + public AlarmMessageLocaleBean() { + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getMessageId() { + return this.messageId; + } + + public void setMessageId(String messageId) { + this.messageId = messageId; + } + + public String getAppId() { + return this.appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public String getClientId() { + return this.clientId; + } + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public String getTaskId() { + return this.taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getUserId() { + return this.userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getTitle() { + return this.title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return this.content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getDeviceCode() { + return this.deviceCode; + } + + public void setDeviceCode(String deviceCode) { + this.deviceCode = deviceCode; + } + + public String getIsRead() { + return this.isRead; + } + + public void setIsRead(String isRead) { + this.isRead = isRead; + } + + public String getAlarmTime() { + return this.alarmTime; + } + + public void setAlarmTime(String alarmTime) { + this.alarmTime = alarmTime; + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt new file mode 100644 index 0000000..650e201 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class AlarmPageFragment: KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_alarm + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt new file mode 100644 index 0000000..deac8ac --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt @@ -0,0 +1,76 @@ +package com.casic.smart.town.sanxi.fragment + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.Fragment +import com.amap.api.maps.AMap +import com.amap.api.maps.AMapOptions +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.view.MonitorRecordActivity +import com.pengxh.kt.lite.extensions.navigatePageTo +import com.pengxh.kt.lite.extensions.show +import kotlinx.android.synthetic.main.fragment_monitor.view.* + +class MonitorPageFragment : Fragment() { + + private val kTag = "HomePageFragment" + private lateinit var monitorView: View + private lateinit var aMap: AMap + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? + ): View { + monitorView = inflater.inflate(R.layout.fragment_monitor, container, false) + //地图初始化 + initMap(savedInstanceState) + + monitorView.rightOperateView.setOnClickListener { + requireContext().navigatePageTo() + } + return monitorView + } + + private fun initMap(savedInstanceState: Bundle?) { + monitorView.mapView.onCreate(savedInstanceState) + aMap = monitorView.mapView.map + aMap.mapType = AMap.MAP_TYPE_NORMAL + val uiSettings = aMap.uiSettings + uiSettings.isCompassEnabled = true + uiSettings.zoomPosition = AMapOptions.ZOOM_POSITION_RIGHT_CENTER + uiSettings.isTiltGesturesEnabled = false//不许地图随手势倾斜角度 + + // 地图加载成功监听 +// aMap.addOnMapLoadedListener(this) + // 地图缩放监听 +// aMap.addOnCameraChangeListener(this) + // marker 点击事件监听 +// aMap.addOnMarkerClickListener(this) + // 点击marker弹出自定义popup +// aMap.setInfoWindowAdapter(this) + //信息窗点击事件 +// aMap.addOnInfoWindowClickListener(this) + } + + /***以下是地图生命周期管理************************************************************************/ + override fun onResume() { + super.onResume() + monitorView.mapView.onResume() + } + + override fun onPause() { + super.onPause() + monitorView.mapView.onPause() + } + + override fun onSaveInstanceState(outState: Bundle) { + super.onSaveInstanceState(outState) + monitorView.mapView.onSaveInstanceState(outState) + } + + override fun onDestroy() { + super.onDestroy() + monitorView.mapView.onDestroy() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt new file mode 100644 index 0000000..e84df12 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class StatisticsPageFragment : KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_statistics + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java new file mode 100644 index 0000000..68d7901 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java @@ -0,0 +1,255 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.database.Cursor; +import android.database.sqlite.SQLiteStatement; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.Property; +import org.greenrobot.greendao.internal.DaoConfig; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseStatement; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * DAO for table "ALARM_MESSAGE_LOCALE_BEAN". +*/ +public class AlarmMessageLocaleBeanDao extends AbstractDao { + + public static final String TABLENAME = "ALARM_MESSAGE_LOCALE_BEAN"; + + /** + * Properties of entity AlarmMessageLocaleBean.
+ * Can be used for QueryBuilder and for referencing column names. + */ + public static class Properties { + public final static Property Id = new Property(0, Long.class, "id", true, "_id"); + public final static Property MessageId = new Property(1, String.class, "messageId", false, "MESSAGE_ID"); + public final static Property AppId = new Property(2, String.class, "appId", false, "APP_ID"); + public final static Property ClientId = new Property(3, String.class, "clientId", false, "CLIENT_ID"); + public final static Property TaskId = new Property(4, String.class, "taskId", false, "TASK_ID"); + public final static Property UserId = new Property(5, String.class, "userId", false, "USER_ID"); + public final static Property Title = new Property(6, String.class, "title", false, "TITLE"); + public final static Property Content = new Property(7, String.class, "content", false, "CONTENT"); + public final static Property DeviceCode = new Property(8, String.class, "deviceCode", false, "DEVICE_CODE"); + public final static Property IsRead = new Property(9, String.class, "isRead", false, "IS_READ"); + public final static Property AlarmTime = new Property(10, String.class, "alarmTime", false, "ALARM_TIME"); + } + + + public AlarmMessageLocaleBeanDao(DaoConfig config) { + super(config); + } + + public AlarmMessageLocaleBeanDao(DaoConfig config, DaoSession daoSession) { + super(config, daoSession); + } + + /** Creates the underlying database table. */ + public static void createTable(Database db, boolean ifNotExists) { + String constraint = ifNotExists? "IF NOT EXISTS ": ""; + db.execSQL("CREATE TABLE " + constraint + "\"ALARM_MESSAGE_LOCALE_BEAN\" (" + // + "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id + "\"MESSAGE_ID\" TEXT UNIQUE ," + // 1: messageId + "\"APP_ID\" TEXT," + // 2: appId + "\"CLIENT_ID\" TEXT," + // 3: clientId + "\"TASK_ID\" TEXT," + // 4: taskId + "\"USER_ID\" TEXT," + // 5: userId + "\"TITLE\" TEXT," + // 6: title + "\"CONTENT\" TEXT," + // 7: content + "\"DEVICE_CODE\" TEXT," + // 8: deviceCode + "\"IS_READ\" TEXT," + // 9: isRead + "\"ALARM_TIME\" TEXT);"); // 10: alarmTime + } + + /** Drops the underlying database table. */ + public static void dropTable(Database db, boolean ifExists) { + String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"ALARM_MESSAGE_LOCALE_BEAN\""; + db.execSQL(sql); + } + + @Override + protected final void bindValues(DatabaseStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + protected final void bindValues(SQLiteStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + public Long readKey(Cursor cursor, int offset) { + return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); + } + + @Override + public AlarmMessageLocaleBean readEntity(Cursor cursor, int offset) { + AlarmMessageLocaleBean entity = new AlarmMessageLocaleBean( // + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // messageId + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // appId + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // clientId + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // taskId + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // userId + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // title + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // content + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // deviceCode + cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // isRead + cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10) // alarmTime + ); + return entity; + } + + @Override + public void readEntity(Cursor cursor, AlarmMessageLocaleBean entity, int offset) { + entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); + entity.setMessageId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setAppId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setClientId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setTaskId(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); + entity.setUserId(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setTitle(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setContent(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); + entity.setDeviceCode(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); + entity.setIsRead(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9)); + entity.setAlarmTime(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); + } + + @Override + protected final Long updateKeyAfterInsert(AlarmMessageLocaleBean entity, long rowId) { + entity.setId(rowId); + return rowId; + } + + @Override + public Long getKey(AlarmMessageLocaleBean entity) { + if(entity != null) { + return entity.getId(); + } else { + return null; + } + } + + @Override + public boolean hasKey(AlarmMessageLocaleBean entity) { + return entity.getId() != null; + } + + @Override + protected final boolean isEntityUpdateable() { + return true; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java new file mode 100644 index 0000000..4222c40 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java @@ -0,0 +1,96 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.content.Context; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteDatabase.CursorFactory; +import android.util.Log; + +import org.greenrobot.greendao.AbstractDaoMaster; +import org.greenrobot.greendao.database.StandardDatabase; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseOpenHelper; +import org.greenrobot.greendao.identityscope.IdentityScopeType; + + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * Master of DAO (schema version 1): knows all DAOs. + */ +public class DaoMaster extends AbstractDaoMaster { + public static final int SCHEMA_VERSION = 1; + + /** Creates underlying database table using DAOs. */ + public static void createAllTables(Database db, boolean ifNotExists) { + AlarmMessageLocaleBeanDao.createTable(db, ifNotExists); + } + + /** Drops underlying database table using DAOs. */ + public static void dropAllTables(Database db, boolean ifExists) { + AlarmMessageLocaleBeanDao.dropTable(db, ifExists); + } + + /** + * WARNING: Drops all table on Upgrade! Use only during development. + * Convenience method using a {@link DevOpenHelper}. + */ + public static DaoSession newDevSession(Context context, String name) { + Database db = new DevOpenHelper(context, name).getWritableDb(); + DaoMaster daoMaster = new DaoMaster(db); + return daoMaster.newSession(); + } + + public DaoMaster(SQLiteDatabase db) { + this(new StandardDatabase(db)); + } + + public DaoMaster(Database db) { + super(db, SCHEMA_VERSION); + registerDaoClass(AlarmMessageLocaleBeanDao.class); + } + + public DaoSession newSession() { + return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); + } + + public DaoSession newSession(IdentityScopeType type) { + return new DaoSession(db, type, daoConfigMap); + } + + /** + * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} - + */ + public static abstract class OpenHelper extends DatabaseOpenHelper { + public OpenHelper(Context context, String name) { + super(context, name, SCHEMA_VERSION); + } + + public OpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory, SCHEMA_VERSION); + } + + @Override + public void onCreate(Database db) { + Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); + createAllTables(db, false); + } + } + + /** WARNING: Drops all table on Upgrade! Use only during development. */ + public static class DevOpenHelper extends OpenHelper { + public DevOpenHelper(Context context, String name) { + super(context, name); + } + + public DevOpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory); + } + + @Override + public void onUpgrade(Database db, int oldVersion, int newVersion) { + Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); + dropAllTables(db, true); + onCreate(db); + } + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java new file mode 100644 index 0000000..480ed84 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java @@ -0,0 +1,48 @@ +package com.casic.smart.town.sanxi.greendao; + +import java.util.Map; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.AbstractDaoSession; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.identityscope.IdentityScopeType; +import org.greenrobot.greendao.internal.DaoConfig; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. + +/** + * {@inheritDoc} + * + * @see org.greenrobot.greendao.AbstractDaoSession + */ +public class DaoSession extends AbstractDaoSession { + + private final DaoConfig alarmMessageLocaleBeanDaoConfig; + + private final AlarmMessageLocaleBeanDao alarmMessageLocaleBeanDao; + + public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> + daoConfigMap) { + super(db); + + alarmMessageLocaleBeanDaoConfig = daoConfigMap.get(AlarmMessageLocaleBeanDao.class).clone(); + alarmMessageLocaleBeanDaoConfig.initIdentityScope(type); + + alarmMessageLocaleBeanDao = new AlarmMessageLocaleBeanDao(alarmMessageLocaleBeanDaoConfig, this); + + registerDao(AlarmMessageLocaleBean.class, alarmMessageLocaleBeanDao); + } + + public void clear() { + alarmMessageLocaleBeanDaoConfig.clearIdentityScope(); + } + + public AlarmMessageLocaleBeanDao getAlarmMessageLocaleBeanDao() { + return alarmMessageLocaleBeanDao; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt new file mode 100644 index 0000000..875cb8c --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt @@ -0,0 +1,5 @@ +package com.casic.smart.town.sanxi.service + +import com.igexin.sdk.PushService + +class ApplicationPushService : PushService() \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt new file mode 100644 index 0000000..396129f --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt @@ -0,0 +1,84 @@ +package com.casic.smart.town.sanxi.service + +import android.content.Context +import android.os.Message +import android.util.Log +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.casic.smart.town.sanxi.view.MainActivity +import com.igexin.sdk.GTIntentService +import com.igexin.sdk.message.GTCmdMessage +import com.igexin.sdk.message.GTNotificationMessage +import com.igexin.sdk.message.GTTransmitMessage +import com.pengxh.kt.lite.extensions.toJson + +class PushIntentService : GTIntentService() { + + private val kTag = "SmartWellIntentService" + + override fun onReceiveServicePid(context: Context?, pid: Int) { + + } + + // 透传消息 + override fun onReceiveMessageData(context: Context?, msg: GTTransmitMessage?) { + Log.d(kTag, "透传消息 -> msg = $msg") + } + + // 接收 cid + override fun onReceiveClientId(context: Context?, clientid: String?) { + Log.d(kTag, "onReceiveClientId -> $clientid") + //通知MainActivity注册个推服务 + val msg: Message = MainActivity.weakReferenceHandler.obtainMessage() + msg.what = LocaleConstant.PUSH_REGISTER + msg.obj = clientid + MainActivity.weakReferenceHandler.sendMessage(msg) + } + + // cid 离线上线通知 + override fun onReceiveOnlineState(context: Context?, online: Boolean) { + + } + + // 各种事件处理回执 + override fun onReceiveCommandResult(context: Context?, msg: GTCmdMessage?) { + + } + + // 通知到达 + override fun onNotificationMessageArrived(context: Context?, msg: GTNotificationMessage?) { + //报警 +// { +// "content": "设备编号[412022030361]发生井盖开盖报警", +// "messageId": "380abf9a79d34306a2683dc9bf96ee78", +// "taskId": "OSL-0830_4hmfimp3Vu684wo3SjXso9", +// "title": "告警提醒", +// "appid": "HKv8K9qARd6WckZ1o2Vbu4", +// "clientId": "e78beacc42e9a02ae6fb9087eb2b1171", +// "pkgName": "com.casic.app.smartwell" +// } + if (msg == null) { + return + } + Log.d(kTag, "通知到达 -> msg = ${msg.toJson()}") +// val userDetailJson = SaveKeyValues.getValue(LocaleConstant.USER_DETAIL_MODEL, "") as String +// var userId = "" +// if (userDetailJson.isNotBlank()) { +// val userDataModel = Gson().fromJson( +// userDetailJson, object : TypeToken() {}.type +// ) +// userId = userDataModel.id.toString() +// } +// //解析编号 +// val splitArray = msg.content.split("\\[|\\]".toRegex()) +// DataBaseManager.instance.insertNotice( +// msg.messageId, msg.appid, msg.clientId, msg.taskId, +// userId, msg.title, msg.content, splitArray[1], "0", +// System.currentTimeMillis().timestampToCompleteDate() +// ) + } + + // 通知点击 + override fun onNotificationMessageClicked(context: Context?, msg: GTNotificationMessage?) { + Log.d(kTag, "通知点击 -> msg = $msg") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt new file mode 100644 index 0000000..daa7c38 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt @@ -0,0 +1,14 @@ +package com.casic.smart.town.sanxi.util + +import android.content.Context +import me.leolin.shortcutbadger.ShortcutBadger + +object BadeHelper { + fun setBadgeNum(context: Context, badgeCount: Int) { + if (badgeCount == 0) { + ShortcutBadger.removeCount(context) + } else { + ShortcutBadger.applyCount(context, badgeCount) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt new file mode 100644 index 0000000..0a52ef2 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt @@ -0,0 +1,75 @@ +package com.casic.smart.town.sanxi.util + +import com.casic.smart.town.sanxi.base.BaseApplication +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao + +class DataBaseManager private constructor() { + + companion object { + //Kotlin委托模式双重锁单例 + val instance: DataBaseManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) { + DataBaseManager() + } + } + + private val beanDao = + BaseApplication.obtainInstance().obtainDaoSession().alarmMessageLocaleBeanDao + +// fun insertNotice( +// messageId: String, appid: String, clientId: String, +// taskId: String, userId: String, title: String, +// content: String, deviceCode: String, isRead: String, +// noticeTime: String +// ) { +// val noticeLocaleBean = NoticeLocaleBean() +// noticeLocaleBean.messageId = messageId +// noticeLocaleBean.appid = appid +// noticeLocaleBean.clientId = clientId +// noticeLocaleBean.taskId = taskId +// noticeLocaleBean.userId = userId +// noticeLocaleBean.title = title +// noticeLocaleBean.content = content +// noticeLocaleBean.deviceCode = deviceCode +// noticeLocaleBean.isRead = isRead +// noticeLocaleBean.noticeTime = noticeTime +// beanDao.insert(noticeLocaleBean) +// //角标设置 +// BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadNotice()) +// } + + fun deleteByMessageId(messageId: String) { + val result = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).list() + beanDao.deleteInTx(result) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun updateNoticeByMessageId(messageId: String) { + val noticeLocaleBean = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).unique() ?: return + noticeLocaleBean.isRead = "1" + beanDao.update(noticeLocaleBean) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun queryMessageByPage(userId: String, offset: Int): MutableList { + return BaseApplication.obtainInstance().obtainDaoSession() + .queryBuilder(AlarmMessageLocaleBean::class.java) + .where(AlarmMessageLocaleBeanDao.Properties.UserId.eq(userId)) + .offset(offset * LocaleConstant.PAGE_LIMIT) + .orderDesc(AlarmMessageLocaleBeanDao.Properties.AlarmTime) + .limit(LocaleConstant.PAGE_LIMIT) + .list() + } + + private fun queryUnReadMessage(): Int { + return beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.IsRead.eq("0") + ).list().size + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt new file mode 100644 index 0000000..52926a8 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt @@ -0,0 +1,31 @@ +package com.casic.smart.town.sanxi.util; + +import android.app.Activity +import android.view.WindowManager +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object LoadingDialogHub { + private lateinit var loadingDialog: QMUITipDialog + + fun show(activity: Activity, message: String) { + loadingDialog = QMUITipDialog + .Builder(activity) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_LOADING) + .setTipWord(message) + .create() + if (!activity.isDestroyed) { + try { + loadingDialog.show() + } catch (e: WindowManager.BadTokenException) { + e.printStackTrace() + } + } + } + + + fun dismiss() { + if (loadingDialog.isShowing) { + loadingDialog.dismiss() + } + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt new file mode 100644 index 0000000..de61c9a --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.util + +import android.Manifest + +object LocaleConstant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.READ_PHONE_STATE, + Manifest.permission.ACCESS_COARSE_LOCATION, + Manifest.permission.READ_EXTERNAL_STORAGE + ) + + const val PERMISSIONS_CODE = 999 + const val PUSH_REGISTER = 2022100101 + const val PAGE_LIMIT = 20 +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt new file mode 100644 index 0000000..3bea1c9 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt @@ -0,0 +1,112 @@ +package com.casic.smart.town.sanxi.view + +import android.view.KeyEvent +import android.view.MenuItem +import androidx.fragment.app.Fragment +import androidx.viewpager.widget.ViewPager +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.adapter.ViewPagerAdapter +import com.casic.smart.town.sanxi.fragment.AlarmPageFragment +import com.casic.smart.town.sanxi.fragment.MonitorPageFragment +import com.casic.smart.town.sanxi.fragment.StatisticsPageFragment +import com.gyf.immersionbar.ImmersionBar +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.base.KotlinBaseActivity +import com.pengxh.kt.lite.extensions.convertColor +import com.pengxh.kt.lite.extensions.show +import com.pengxh.kt.lite.utils.ImmerseStatusBarUtil +import com.pengxh.kt.lite.utils.WeakReferenceHandler +import kotlinx.android.synthetic.main.activity_main.* + +class MainActivity : KotlinBaseActivity() { + + companion object { + lateinit var weakReferenceHandler: WeakReferenceHandler + } + + private val kTag = "MainActivity" + private var menuItem: MenuItem? = null + private var fragmentPages: ArrayList = ArrayList() + private var clickTime: Long = 0 + + init { + fragmentPages.add(StatisticsPageFragment()) + fragmentPages.add(MonitorPageFragment()) + fragmentPages.add(AlarmPageFragment()) + } + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + ImmersionBar.with(this).statusBarDarkFont(false).init() + ImmerseStatusBarUtil.setColor(this, R.color.mainThemeColor.convertColor(this)) + } + + override fun initData() { + //推送,多次调用 SDK 初始化并无影响。 + PushManager.getInstance().initialize(this) + weakReferenceHandler = WeakReferenceHandler { + + true + } + } + + override fun observeRequestState() { + + } + + override fun initEvent() { + bottomNavigation.itemIconTintList = null + bottomNavigation.setOnNavigationItemSelectedListener { menuItem -> + when (menuItem.itemId) { + R.id.nav_statistics -> { + mainViewPager.currentItem = 0 + } + R.id.nav_monitor -> { + mainViewPager.currentItem = 1 + } + R.id.nav_alarm -> { + mainViewPager.currentItem = 2 + } + } + false + } + mainViewPager.adapter = ViewPagerAdapter(fragmentPages, supportFragmentManager) + mainViewPager.offscreenPageLimit = fragmentPages.size //缓存页数 + mainViewPager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener { + override fun onPageScrollStateChanged(state: Int) { + + } + + override fun onPageScrolled( + position: Int, + positionOffset: Float, + positionOffsetPixels: Int + ) { + + } + + override fun onPageSelected(position: Int) { + if (menuItem != null) { + menuItem!!.isChecked = false + } else { + bottomNavigation.menu.getItem(0).isChecked = false + } + menuItem = bottomNavigation.menu.getItem(position) + menuItem!!.isChecked = true + } + }) + } + + override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean { + return if (keyCode == KeyEvent.KEYCODE_BACK) { + if (System.currentTimeMillis() - clickTime > 2000) { + "再按一次退出程序".show(this) + clickTime = System.currentTimeMillis() + true + } else { + super.onKeyDown(keyCode, event) + } + } else super.onKeyDown(keyCode, event) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt new file mode 100644 index 0000000..c5d8b22 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.view + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseActivity + +class MonitorRecordActivity : KotlinBaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_monitor_record + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt new file mode 100644 index 0000000..c478d83 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt @@ -0,0 +1,55 @@ +package com.casic.smart.town.sanxi.view + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.amap.api.maps.MapsInitializer +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.gyf.immersionbar.ImmersionBar +import com.pengxh.kt.lite.extensions.navigatePageTo +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + ImmersionBar.with(this).statusBarDarkFont(true).init() + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (EasyPermissions.hasPermissions(this, *LocaleConstant.USER_PERMISSIONS)) { + startSplashScreenActivity() + } else { + EasyPermissions.requestPermissions( + this@PermissionActivity, + resources.getString(R.string.app_name) + "需要获取相关权限", + LocaleConstant.PERMISSIONS_CODE, + *LocaleConstant.USER_PERMISSIONS + ) + } + } + + private fun startSplashScreenActivity() { + //先把导航隐私政策声明,后面导航会用到 + MapsInitializer.updatePrivacyAgree(this, true) + MapsInitializer.updatePrivacyShow(this, true, true) + this.navigatePageTo() + 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) { + startSplashScreenActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable/alarm_selector.xml b/app/src/main/res/drawable/alarm_selector.xml new file mode 100644 index 0000000..39b2595 --- /dev/null +++ b/app/src/main/res/drawable/alarm_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..10cfdbf --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*.iml +.gradle +/local.properties +/.idea +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..a4cd2ca --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,101 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'org.greenrobot.greendao' + +android { +// signingConfigs { +// release { +// storeFile file('/Users/a203/Desktop/AndroidProjects/CasicSmartWell/app/CasicSmartWell.jks') +// storePassword '123456789' +// keyAlias 'key0' +// keyPassword '123456789' +// } +// } + compileSdkVersion 31 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.smart.town.sanxi" + minSdkVersion 23 + targetSdkVersion 31 + versionCode 1 + versionName "1.0.0" + + manifestPlaceholders = [GETUI_APPID: "A9V4DvwLcdAqkFCQuFyhq6"] + } + + buildTypes { + release { + minifyEnabled false +// signingConfig signingConfigs.release + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + + ndk { abiFilters "armeabi", "armeabi-v7a", "arm64-v8" } + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlin { + experimental { + coroutines 'enable' + } + } + + greendao { + schemaVersion 1//数据库版本号 + targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 + daoPackage 'com.casic.smart.town.sanxi.greendao'//设置DaoMaster、DaoSession、Dao包名 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + //基础依赖库 + implementation files('libs/lite-release.aar') + implementation 'androidx.appcompat:appcompat:1.4.2' + implementation 'androidx.core:core-ktx:1.8.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:3.0.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' + //MVVM+LiveData + implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.1" + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0" + implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + //Kotlin协程 + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1' + //图片加载框架 + implementation 'com.github.bumptech.glide:glide:4.9.0' + //返回值转换器 + implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' + implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + //okhttp3日志拦截器 + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //网络请求和接口封装 + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.9.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.9.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' + //高德地图 + implementation 'com.amap.api:3dmap:latest.integration' + //推送SDK + implementation 'com.getui:gtsdk:3.2.10.0' //个推SDK + implementation 'com.getui:gtc:3.1.9.0' //个推核心组件 + //数据库框架 + implementation 'org.greenrobot:greendao:3.3.0' + //桌面角标 + implementation "me.leolin:ShortcutBadger:1.1.22@aar" +} \ No newline at end of file diff --git a/app/libs/lite-release.aar b/app/libs/lite-release.aar new file mode 100644 index 0000000..45da4df --- /dev/null +++ b/app/libs/lite-release.aar Binary files differ diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /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 \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..a83c28a --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/svg/monitor.svg b/app/src/main/assets/svg/monitor.svg new file mode 100644 index 0000000..c8d3e25 --- /dev/null +++ b/app/src/main/assets/svg/monitor.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/msg.svg b/app/src/main/assets/svg/msg.svg new file mode 100644 index 0000000..e864e48 --- /dev/null +++ b/app/src/main/assets/svg/msg.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/statistics.svg b/app/src/main/assets/svg/statistics.svg new file mode 100644 index 0000000..974000e --- /dev/null +++ b/app/src/main/assets/svg/statistics.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt new file mode 100644 index 0000000..6b9cce0 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.adapter + +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentManager +import androidx.fragment.app.FragmentPagerAdapter + +class ViewPagerAdapter(list: ArrayList, manager: FragmentManager) : + FragmentPagerAdapter(manager) { + + private var pageList: List = list + + override fun getItem(position: Int) = pageList[position] + + override fun getCount() = pageList.size +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt new file mode 100644 index 0000000..4e017b1 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt @@ -0,0 +1,40 @@ +package com.casic.smart.town.sanxi.base + +import android.app.Application +import android.util.Log +import com.casic.smart.town.sanxi.greendao.DaoMaster +import com.casic.smart.town.sanxi.greendao.DaoSession +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + private val kTag = "BaseApplication" + + companion object { + private var instance: BaseApplication by Delegates.notNull() + + fun obtainInstance() = instance + + private lateinit var daoSession: DaoSession + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences(this) + //推送 + PushManager.getInstance().initialize(this) + PushManager.getInstance().setDebugLogger(this) { + Log.d(kTag, it) + } + val devOpenHelper = DaoMaster.DevOpenHelper(this, "SmartTown.db", null) + val daoMaster = DaoMaster(devOpenHelper.writableDatabase) + daoSession = daoMaster.newSession() + } + + fun obtainDaoSession(): DaoSession { + return daoSession + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java new file mode 100644 index 0000000..b8f67dc --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java @@ -0,0 +1,133 @@ +package com.casic.smart.town.sanxi.bean; + +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Generated; +import org.greenrobot.greendao.annotation.Id; +import org.greenrobot.greendao.annotation.Unique; + +@Entity +public class AlarmMessageLocaleBean { + @Id(autoincrement = true) + private Long id;//主键自增 + + @Unique + private String messageId; + private String appId; + private String clientId; + private String taskId; + private String userId; + private String title; + private String content; + private String deviceCode; + private String isRead;//0-未读,1-已读 + private String alarmTime; + + @Generated(hash = 566950134) + public AlarmMessageLocaleBean(Long id, String messageId, String appId, + String clientId, String taskId, String userId, String title, + String content, String deviceCode, String isRead, String alarmTime) { + this.id = id; + this.messageId = messageId; + this.appId = appId; + this.clientId = clientId; + this.taskId = taskId; + this.userId = userId; + this.title = title; + this.content = content; + this.deviceCode = deviceCode; + this.isRead = isRead; + this.alarmTime = alarmTime; + } + + @Generated(hash = 1737519562) + public AlarmMessageLocaleBean() { + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getMessageId() { + return this.messageId; + } + + public void setMessageId(String messageId) { + this.messageId = messageId; + } + + public String getAppId() { + return this.appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public String getClientId() { + return this.clientId; + } + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public String getTaskId() { + return this.taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getUserId() { + return this.userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getTitle() { + return this.title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return this.content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getDeviceCode() { + return this.deviceCode; + } + + public void setDeviceCode(String deviceCode) { + this.deviceCode = deviceCode; + } + + public String getIsRead() { + return this.isRead; + } + + public void setIsRead(String isRead) { + this.isRead = isRead; + } + + public String getAlarmTime() { + return this.alarmTime; + } + + public void setAlarmTime(String alarmTime) { + this.alarmTime = alarmTime; + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt new file mode 100644 index 0000000..650e201 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class AlarmPageFragment: KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_alarm + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt new file mode 100644 index 0000000..deac8ac --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt @@ -0,0 +1,76 @@ +package com.casic.smart.town.sanxi.fragment + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.Fragment +import com.amap.api.maps.AMap +import com.amap.api.maps.AMapOptions +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.view.MonitorRecordActivity +import com.pengxh.kt.lite.extensions.navigatePageTo +import com.pengxh.kt.lite.extensions.show +import kotlinx.android.synthetic.main.fragment_monitor.view.* + +class MonitorPageFragment : Fragment() { + + private val kTag = "HomePageFragment" + private lateinit var monitorView: View + private lateinit var aMap: AMap + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? + ): View { + monitorView = inflater.inflate(R.layout.fragment_monitor, container, false) + //地图初始化 + initMap(savedInstanceState) + + monitorView.rightOperateView.setOnClickListener { + requireContext().navigatePageTo() + } + return monitorView + } + + private fun initMap(savedInstanceState: Bundle?) { + monitorView.mapView.onCreate(savedInstanceState) + aMap = monitorView.mapView.map + aMap.mapType = AMap.MAP_TYPE_NORMAL + val uiSettings = aMap.uiSettings + uiSettings.isCompassEnabled = true + uiSettings.zoomPosition = AMapOptions.ZOOM_POSITION_RIGHT_CENTER + uiSettings.isTiltGesturesEnabled = false//不许地图随手势倾斜角度 + + // 地图加载成功监听 +// aMap.addOnMapLoadedListener(this) + // 地图缩放监听 +// aMap.addOnCameraChangeListener(this) + // marker 点击事件监听 +// aMap.addOnMarkerClickListener(this) + // 点击marker弹出自定义popup +// aMap.setInfoWindowAdapter(this) + //信息窗点击事件 +// aMap.addOnInfoWindowClickListener(this) + } + + /***以下是地图生命周期管理************************************************************************/ + override fun onResume() { + super.onResume() + monitorView.mapView.onResume() + } + + override fun onPause() { + super.onPause() + monitorView.mapView.onPause() + } + + override fun onSaveInstanceState(outState: Bundle) { + super.onSaveInstanceState(outState) + monitorView.mapView.onSaveInstanceState(outState) + } + + override fun onDestroy() { + super.onDestroy() + monitorView.mapView.onDestroy() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt new file mode 100644 index 0000000..e84df12 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class StatisticsPageFragment : KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_statistics + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java new file mode 100644 index 0000000..68d7901 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java @@ -0,0 +1,255 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.database.Cursor; +import android.database.sqlite.SQLiteStatement; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.Property; +import org.greenrobot.greendao.internal.DaoConfig; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseStatement; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * DAO for table "ALARM_MESSAGE_LOCALE_BEAN". +*/ +public class AlarmMessageLocaleBeanDao extends AbstractDao { + + public static final String TABLENAME = "ALARM_MESSAGE_LOCALE_BEAN"; + + /** + * Properties of entity AlarmMessageLocaleBean.
+ * Can be used for QueryBuilder and for referencing column names. + */ + public static class Properties { + public final static Property Id = new Property(0, Long.class, "id", true, "_id"); + public final static Property MessageId = new Property(1, String.class, "messageId", false, "MESSAGE_ID"); + public final static Property AppId = new Property(2, String.class, "appId", false, "APP_ID"); + public final static Property ClientId = new Property(3, String.class, "clientId", false, "CLIENT_ID"); + public final static Property TaskId = new Property(4, String.class, "taskId", false, "TASK_ID"); + public final static Property UserId = new Property(5, String.class, "userId", false, "USER_ID"); + public final static Property Title = new Property(6, String.class, "title", false, "TITLE"); + public final static Property Content = new Property(7, String.class, "content", false, "CONTENT"); + public final static Property DeviceCode = new Property(8, String.class, "deviceCode", false, "DEVICE_CODE"); + public final static Property IsRead = new Property(9, String.class, "isRead", false, "IS_READ"); + public final static Property AlarmTime = new Property(10, String.class, "alarmTime", false, "ALARM_TIME"); + } + + + public AlarmMessageLocaleBeanDao(DaoConfig config) { + super(config); + } + + public AlarmMessageLocaleBeanDao(DaoConfig config, DaoSession daoSession) { + super(config, daoSession); + } + + /** Creates the underlying database table. */ + public static void createTable(Database db, boolean ifNotExists) { + String constraint = ifNotExists? "IF NOT EXISTS ": ""; + db.execSQL("CREATE TABLE " + constraint + "\"ALARM_MESSAGE_LOCALE_BEAN\" (" + // + "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id + "\"MESSAGE_ID\" TEXT UNIQUE ," + // 1: messageId + "\"APP_ID\" TEXT," + // 2: appId + "\"CLIENT_ID\" TEXT," + // 3: clientId + "\"TASK_ID\" TEXT," + // 4: taskId + "\"USER_ID\" TEXT," + // 5: userId + "\"TITLE\" TEXT," + // 6: title + "\"CONTENT\" TEXT," + // 7: content + "\"DEVICE_CODE\" TEXT," + // 8: deviceCode + "\"IS_READ\" TEXT," + // 9: isRead + "\"ALARM_TIME\" TEXT);"); // 10: alarmTime + } + + /** Drops the underlying database table. */ + public static void dropTable(Database db, boolean ifExists) { + String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"ALARM_MESSAGE_LOCALE_BEAN\""; + db.execSQL(sql); + } + + @Override + protected final void bindValues(DatabaseStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + protected final void bindValues(SQLiteStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + public Long readKey(Cursor cursor, int offset) { + return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); + } + + @Override + public AlarmMessageLocaleBean readEntity(Cursor cursor, int offset) { + AlarmMessageLocaleBean entity = new AlarmMessageLocaleBean( // + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // messageId + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // appId + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // clientId + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // taskId + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // userId + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // title + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // content + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // deviceCode + cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // isRead + cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10) // alarmTime + ); + return entity; + } + + @Override + public void readEntity(Cursor cursor, AlarmMessageLocaleBean entity, int offset) { + entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); + entity.setMessageId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setAppId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setClientId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setTaskId(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); + entity.setUserId(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setTitle(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setContent(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); + entity.setDeviceCode(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); + entity.setIsRead(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9)); + entity.setAlarmTime(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); + } + + @Override + protected final Long updateKeyAfterInsert(AlarmMessageLocaleBean entity, long rowId) { + entity.setId(rowId); + return rowId; + } + + @Override + public Long getKey(AlarmMessageLocaleBean entity) { + if(entity != null) { + return entity.getId(); + } else { + return null; + } + } + + @Override + public boolean hasKey(AlarmMessageLocaleBean entity) { + return entity.getId() != null; + } + + @Override + protected final boolean isEntityUpdateable() { + return true; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java new file mode 100644 index 0000000..4222c40 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java @@ -0,0 +1,96 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.content.Context; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteDatabase.CursorFactory; +import android.util.Log; + +import org.greenrobot.greendao.AbstractDaoMaster; +import org.greenrobot.greendao.database.StandardDatabase; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseOpenHelper; +import org.greenrobot.greendao.identityscope.IdentityScopeType; + + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * Master of DAO (schema version 1): knows all DAOs. + */ +public class DaoMaster extends AbstractDaoMaster { + public static final int SCHEMA_VERSION = 1; + + /** Creates underlying database table using DAOs. */ + public static void createAllTables(Database db, boolean ifNotExists) { + AlarmMessageLocaleBeanDao.createTable(db, ifNotExists); + } + + /** Drops underlying database table using DAOs. */ + public static void dropAllTables(Database db, boolean ifExists) { + AlarmMessageLocaleBeanDao.dropTable(db, ifExists); + } + + /** + * WARNING: Drops all table on Upgrade! Use only during development. + * Convenience method using a {@link DevOpenHelper}. + */ + public static DaoSession newDevSession(Context context, String name) { + Database db = new DevOpenHelper(context, name).getWritableDb(); + DaoMaster daoMaster = new DaoMaster(db); + return daoMaster.newSession(); + } + + public DaoMaster(SQLiteDatabase db) { + this(new StandardDatabase(db)); + } + + public DaoMaster(Database db) { + super(db, SCHEMA_VERSION); + registerDaoClass(AlarmMessageLocaleBeanDao.class); + } + + public DaoSession newSession() { + return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); + } + + public DaoSession newSession(IdentityScopeType type) { + return new DaoSession(db, type, daoConfigMap); + } + + /** + * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} - + */ + public static abstract class OpenHelper extends DatabaseOpenHelper { + public OpenHelper(Context context, String name) { + super(context, name, SCHEMA_VERSION); + } + + public OpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory, SCHEMA_VERSION); + } + + @Override + public void onCreate(Database db) { + Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); + createAllTables(db, false); + } + } + + /** WARNING: Drops all table on Upgrade! Use only during development. */ + public static class DevOpenHelper extends OpenHelper { + public DevOpenHelper(Context context, String name) { + super(context, name); + } + + public DevOpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory); + } + + @Override + public void onUpgrade(Database db, int oldVersion, int newVersion) { + Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); + dropAllTables(db, true); + onCreate(db); + } + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java new file mode 100644 index 0000000..480ed84 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java @@ -0,0 +1,48 @@ +package com.casic.smart.town.sanxi.greendao; + +import java.util.Map; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.AbstractDaoSession; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.identityscope.IdentityScopeType; +import org.greenrobot.greendao.internal.DaoConfig; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. + +/** + * {@inheritDoc} + * + * @see org.greenrobot.greendao.AbstractDaoSession + */ +public class DaoSession extends AbstractDaoSession { + + private final DaoConfig alarmMessageLocaleBeanDaoConfig; + + private final AlarmMessageLocaleBeanDao alarmMessageLocaleBeanDao; + + public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> + daoConfigMap) { + super(db); + + alarmMessageLocaleBeanDaoConfig = daoConfigMap.get(AlarmMessageLocaleBeanDao.class).clone(); + alarmMessageLocaleBeanDaoConfig.initIdentityScope(type); + + alarmMessageLocaleBeanDao = new AlarmMessageLocaleBeanDao(alarmMessageLocaleBeanDaoConfig, this); + + registerDao(AlarmMessageLocaleBean.class, alarmMessageLocaleBeanDao); + } + + public void clear() { + alarmMessageLocaleBeanDaoConfig.clearIdentityScope(); + } + + public AlarmMessageLocaleBeanDao getAlarmMessageLocaleBeanDao() { + return alarmMessageLocaleBeanDao; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt new file mode 100644 index 0000000..875cb8c --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt @@ -0,0 +1,5 @@ +package com.casic.smart.town.sanxi.service + +import com.igexin.sdk.PushService + +class ApplicationPushService : PushService() \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt new file mode 100644 index 0000000..396129f --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt @@ -0,0 +1,84 @@ +package com.casic.smart.town.sanxi.service + +import android.content.Context +import android.os.Message +import android.util.Log +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.casic.smart.town.sanxi.view.MainActivity +import com.igexin.sdk.GTIntentService +import com.igexin.sdk.message.GTCmdMessage +import com.igexin.sdk.message.GTNotificationMessage +import com.igexin.sdk.message.GTTransmitMessage +import com.pengxh.kt.lite.extensions.toJson + +class PushIntentService : GTIntentService() { + + private val kTag = "SmartWellIntentService" + + override fun onReceiveServicePid(context: Context?, pid: Int) { + + } + + // 透传消息 + override fun onReceiveMessageData(context: Context?, msg: GTTransmitMessage?) { + Log.d(kTag, "透传消息 -> msg = $msg") + } + + // 接收 cid + override fun onReceiveClientId(context: Context?, clientid: String?) { + Log.d(kTag, "onReceiveClientId -> $clientid") + //通知MainActivity注册个推服务 + val msg: Message = MainActivity.weakReferenceHandler.obtainMessage() + msg.what = LocaleConstant.PUSH_REGISTER + msg.obj = clientid + MainActivity.weakReferenceHandler.sendMessage(msg) + } + + // cid 离线上线通知 + override fun onReceiveOnlineState(context: Context?, online: Boolean) { + + } + + // 各种事件处理回执 + override fun onReceiveCommandResult(context: Context?, msg: GTCmdMessage?) { + + } + + // 通知到达 + override fun onNotificationMessageArrived(context: Context?, msg: GTNotificationMessage?) { + //报警 +// { +// "content": "设备编号[412022030361]发生井盖开盖报警", +// "messageId": "380abf9a79d34306a2683dc9bf96ee78", +// "taskId": "OSL-0830_4hmfimp3Vu684wo3SjXso9", +// "title": "告警提醒", +// "appid": "HKv8K9qARd6WckZ1o2Vbu4", +// "clientId": "e78beacc42e9a02ae6fb9087eb2b1171", +// "pkgName": "com.casic.app.smartwell" +// } + if (msg == null) { + return + } + Log.d(kTag, "通知到达 -> msg = ${msg.toJson()}") +// val userDetailJson = SaveKeyValues.getValue(LocaleConstant.USER_DETAIL_MODEL, "") as String +// var userId = "" +// if (userDetailJson.isNotBlank()) { +// val userDataModel = Gson().fromJson( +// userDetailJson, object : TypeToken() {}.type +// ) +// userId = userDataModel.id.toString() +// } +// //解析编号 +// val splitArray = msg.content.split("\\[|\\]".toRegex()) +// DataBaseManager.instance.insertNotice( +// msg.messageId, msg.appid, msg.clientId, msg.taskId, +// userId, msg.title, msg.content, splitArray[1], "0", +// System.currentTimeMillis().timestampToCompleteDate() +// ) + } + + // 通知点击 + override fun onNotificationMessageClicked(context: Context?, msg: GTNotificationMessage?) { + Log.d(kTag, "通知点击 -> msg = $msg") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt new file mode 100644 index 0000000..daa7c38 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt @@ -0,0 +1,14 @@ +package com.casic.smart.town.sanxi.util + +import android.content.Context +import me.leolin.shortcutbadger.ShortcutBadger + +object BadeHelper { + fun setBadgeNum(context: Context, badgeCount: Int) { + if (badgeCount == 0) { + ShortcutBadger.removeCount(context) + } else { + ShortcutBadger.applyCount(context, badgeCount) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt new file mode 100644 index 0000000..0a52ef2 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt @@ -0,0 +1,75 @@ +package com.casic.smart.town.sanxi.util + +import com.casic.smart.town.sanxi.base.BaseApplication +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao + +class DataBaseManager private constructor() { + + companion object { + //Kotlin委托模式双重锁单例 + val instance: DataBaseManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) { + DataBaseManager() + } + } + + private val beanDao = + BaseApplication.obtainInstance().obtainDaoSession().alarmMessageLocaleBeanDao + +// fun insertNotice( +// messageId: String, appid: String, clientId: String, +// taskId: String, userId: String, title: String, +// content: String, deviceCode: String, isRead: String, +// noticeTime: String +// ) { +// val noticeLocaleBean = NoticeLocaleBean() +// noticeLocaleBean.messageId = messageId +// noticeLocaleBean.appid = appid +// noticeLocaleBean.clientId = clientId +// noticeLocaleBean.taskId = taskId +// noticeLocaleBean.userId = userId +// noticeLocaleBean.title = title +// noticeLocaleBean.content = content +// noticeLocaleBean.deviceCode = deviceCode +// noticeLocaleBean.isRead = isRead +// noticeLocaleBean.noticeTime = noticeTime +// beanDao.insert(noticeLocaleBean) +// //角标设置 +// BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadNotice()) +// } + + fun deleteByMessageId(messageId: String) { + val result = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).list() + beanDao.deleteInTx(result) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun updateNoticeByMessageId(messageId: String) { + val noticeLocaleBean = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).unique() ?: return + noticeLocaleBean.isRead = "1" + beanDao.update(noticeLocaleBean) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun queryMessageByPage(userId: String, offset: Int): MutableList { + return BaseApplication.obtainInstance().obtainDaoSession() + .queryBuilder(AlarmMessageLocaleBean::class.java) + .where(AlarmMessageLocaleBeanDao.Properties.UserId.eq(userId)) + .offset(offset * LocaleConstant.PAGE_LIMIT) + .orderDesc(AlarmMessageLocaleBeanDao.Properties.AlarmTime) + .limit(LocaleConstant.PAGE_LIMIT) + .list() + } + + private fun queryUnReadMessage(): Int { + return beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.IsRead.eq("0") + ).list().size + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt new file mode 100644 index 0000000..52926a8 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt @@ -0,0 +1,31 @@ +package com.casic.smart.town.sanxi.util; + +import android.app.Activity +import android.view.WindowManager +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object LoadingDialogHub { + private lateinit var loadingDialog: QMUITipDialog + + fun show(activity: Activity, message: String) { + loadingDialog = QMUITipDialog + .Builder(activity) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_LOADING) + .setTipWord(message) + .create() + if (!activity.isDestroyed) { + try { + loadingDialog.show() + } catch (e: WindowManager.BadTokenException) { + e.printStackTrace() + } + } + } + + + fun dismiss() { + if (loadingDialog.isShowing) { + loadingDialog.dismiss() + } + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt new file mode 100644 index 0000000..de61c9a --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.util + +import android.Manifest + +object LocaleConstant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.READ_PHONE_STATE, + Manifest.permission.ACCESS_COARSE_LOCATION, + Manifest.permission.READ_EXTERNAL_STORAGE + ) + + const val PERMISSIONS_CODE = 999 + const val PUSH_REGISTER = 2022100101 + const val PAGE_LIMIT = 20 +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt new file mode 100644 index 0000000..3bea1c9 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt @@ -0,0 +1,112 @@ +package com.casic.smart.town.sanxi.view + +import android.view.KeyEvent +import android.view.MenuItem +import androidx.fragment.app.Fragment +import androidx.viewpager.widget.ViewPager +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.adapter.ViewPagerAdapter +import com.casic.smart.town.sanxi.fragment.AlarmPageFragment +import com.casic.smart.town.sanxi.fragment.MonitorPageFragment +import com.casic.smart.town.sanxi.fragment.StatisticsPageFragment +import com.gyf.immersionbar.ImmersionBar +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.base.KotlinBaseActivity +import com.pengxh.kt.lite.extensions.convertColor +import com.pengxh.kt.lite.extensions.show +import com.pengxh.kt.lite.utils.ImmerseStatusBarUtil +import com.pengxh.kt.lite.utils.WeakReferenceHandler +import kotlinx.android.synthetic.main.activity_main.* + +class MainActivity : KotlinBaseActivity() { + + companion object { + lateinit var weakReferenceHandler: WeakReferenceHandler + } + + private val kTag = "MainActivity" + private var menuItem: MenuItem? = null + private var fragmentPages: ArrayList = ArrayList() + private var clickTime: Long = 0 + + init { + fragmentPages.add(StatisticsPageFragment()) + fragmentPages.add(MonitorPageFragment()) + fragmentPages.add(AlarmPageFragment()) + } + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + ImmersionBar.with(this).statusBarDarkFont(false).init() + ImmerseStatusBarUtil.setColor(this, R.color.mainThemeColor.convertColor(this)) + } + + override fun initData() { + //推送,多次调用 SDK 初始化并无影响。 + PushManager.getInstance().initialize(this) + weakReferenceHandler = WeakReferenceHandler { + + true + } + } + + override fun observeRequestState() { + + } + + override fun initEvent() { + bottomNavigation.itemIconTintList = null + bottomNavigation.setOnNavigationItemSelectedListener { menuItem -> + when (menuItem.itemId) { + R.id.nav_statistics -> { + mainViewPager.currentItem = 0 + } + R.id.nav_monitor -> { + mainViewPager.currentItem = 1 + } + R.id.nav_alarm -> { + mainViewPager.currentItem = 2 + } + } + false + } + mainViewPager.adapter = ViewPagerAdapter(fragmentPages, supportFragmentManager) + mainViewPager.offscreenPageLimit = fragmentPages.size //缓存页数 + mainViewPager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener { + override fun onPageScrollStateChanged(state: Int) { + + } + + override fun onPageScrolled( + position: Int, + positionOffset: Float, + positionOffsetPixels: Int + ) { + + } + + override fun onPageSelected(position: Int) { + if (menuItem != null) { + menuItem!!.isChecked = false + } else { + bottomNavigation.menu.getItem(0).isChecked = false + } + menuItem = bottomNavigation.menu.getItem(position) + menuItem!!.isChecked = true + } + }) + } + + override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean { + return if (keyCode == KeyEvent.KEYCODE_BACK) { + if (System.currentTimeMillis() - clickTime > 2000) { + "再按一次退出程序".show(this) + clickTime = System.currentTimeMillis() + true + } else { + super.onKeyDown(keyCode, event) + } + } else super.onKeyDown(keyCode, event) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt new file mode 100644 index 0000000..c5d8b22 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.view + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseActivity + +class MonitorRecordActivity : KotlinBaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_monitor_record + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt new file mode 100644 index 0000000..c478d83 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt @@ -0,0 +1,55 @@ +package com.casic.smart.town.sanxi.view + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.amap.api.maps.MapsInitializer +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.gyf.immersionbar.ImmersionBar +import com.pengxh.kt.lite.extensions.navigatePageTo +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + ImmersionBar.with(this).statusBarDarkFont(true).init() + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (EasyPermissions.hasPermissions(this, *LocaleConstant.USER_PERMISSIONS)) { + startSplashScreenActivity() + } else { + EasyPermissions.requestPermissions( + this@PermissionActivity, + resources.getString(R.string.app_name) + "需要获取相关权限", + LocaleConstant.PERMISSIONS_CODE, + *LocaleConstant.USER_PERMISSIONS + ) + } + } + + private fun startSplashScreenActivity() { + //先把导航隐私政策声明,后面导航会用到 + MapsInitializer.updatePrivacyAgree(this, true) + MapsInitializer.updatePrivacyShow(this, true, true) + this.navigatePageTo() + 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) { + startSplashScreenActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable/alarm_selector.xml b/app/src/main/res/drawable/alarm_selector.xml new file mode 100644 index 0000000..39b2595 --- /dev/null +++ b/app/src/main/res/drawable/alarm_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bottom_text_color.xml b/app/src/main/res/drawable/bottom_text_color.xml new file mode 100644 index 0000000..b284ea3 --- /dev/null +++ b/app/src/main/res/drawable/bottom_text_color.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..10cfdbf --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*.iml +.gradle +/local.properties +/.idea +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..a4cd2ca --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,101 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'org.greenrobot.greendao' + +android { +// signingConfigs { +// release { +// storeFile file('/Users/a203/Desktop/AndroidProjects/CasicSmartWell/app/CasicSmartWell.jks') +// storePassword '123456789' +// keyAlias 'key0' +// keyPassword '123456789' +// } +// } + compileSdkVersion 31 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.smart.town.sanxi" + minSdkVersion 23 + targetSdkVersion 31 + versionCode 1 + versionName "1.0.0" + + manifestPlaceholders = [GETUI_APPID: "A9V4DvwLcdAqkFCQuFyhq6"] + } + + buildTypes { + release { + minifyEnabled false +// signingConfig signingConfigs.release + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + + ndk { abiFilters "armeabi", "armeabi-v7a", "arm64-v8" } + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlin { + experimental { + coroutines 'enable' + } + } + + greendao { + schemaVersion 1//数据库版本号 + targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 + daoPackage 'com.casic.smart.town.sanxi.greendao'//设置DaoMaster、DaoSession、Dao包名 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + //基础依赖库 + implementation files('libs/lite-release.aar') + implementation 'androidx.appcompat:appcompat:1.4.2' + implementation 'androidx.core:core-ktx:1.8.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:3.0.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' + //MVVM+LiveData + implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.1" + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0" + implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + //Kotlin协程 + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1' + //图片加载框架 + implementation 'com.github.bumptech.glide:glide:4.9.0' + //返回值转换器 + implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' + implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + //okhttp3日志拦截器 + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //网络请求和接口封装 + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.9.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.9.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' + //高德地图 + implementation 'com.amap.api:3dmap:latest.integration' + //推送SDK + implementation 'com.getui:gtsdk:3.2.10.0' //个推SDK + implementation 'com.getui:gtc:3.1.9.0' //个推核心组件 + //数据库框架 + implementation 'org.greenrobot:greendao:3.3.0' + //桌面角标 + implementation "me.leolin:ShortcutBadger:1.1.22@aar" +} \ No newline at end of file diff --git a/app/libs/lite-release.aar b/app/libs/lite-release.aar new file mode 100644 index 0000000..45da4df --- /dev/null +++ b/app/libs/lite-release.aar Binary files differ diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /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 \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..a83c28a --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/svg/monitor.svg b/app/src/main/assets/svg/monitor.svg new file mode 100644 index 0000000..c8d3e25 --- /dev/null +++ b/app/src/main/assets/svg/monitor.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/msg.svg b/app/src/main/assets/svg/msg.svg new file mode 100644 index 0000000..e864e48 --- /dev/null +++ b/app/src/main/assets/svg/msg.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/statistics.svg b/app/src/main/assets/svg/statistics.svg new file mode 100644 index 0000000..974000e --- /dev/null +++ b/app/src/main/assets/svg/statistics.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt new file mode 100644 index 0000000..6b9cce0 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.adapter + +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentManager +import androidx.fragment.app.FragmentPagerAdapter + +class ViewPagerAdapter(list: ArrayList, manager: FragmentManager) : + FragmentPagerAdapter(manager) { + + private var pageList: List = list + + override fun getItem(position: Int) = pageList[position] + + override fun getCount() = pageList.size +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt new file mode 100644 index 0000000..4e017b1 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt @@ -0,0 +1,40 @@ +package com.casic.smart.town.sanxi.base + +import android.app.Application +import android.util.Log +import com.casic.smart.town.sanxi.greendao.DaoMaster +import com.casic.smart.town.sanxi.greendao.DaoSession +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + private val kTag = "BaseApplication" + + companion object { + private var instance: BaseApplication by Delegates.notNull() + + fun obtainInstance() = instance + + private lateinit var daoSession: DaoSession + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences(this) + //推送 + PushManager.getInstance().initialize(this) + PushManager.getInstance().setDebugLogger(this) { + Log.d(kTag, it) + } + val devOpenHelper = DaoMaster.DevOpenHelper(this, "SmartTown.db", null) + val daoMaster = DaoMaster(devOpenHelper.writableDatabase) + daoSession = daoMaster.newSession() + } + + fun obtainDaoSession(): DaoSession { + return daoSession + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java new file mode 100644 index 0000000..b8f67dc --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java @@ -0,0 +1,133 @@ +package com.casic.smart.town.sanxi.bean; + +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Generated; +import org.greenrobot.greendao.annotation.Id; +import org.greenrobot.greendao.annotation.Unique; + +@Entity +public class AlarmMessageLocaleBean { + @Id(autoincrement = true) + private Long id;//主键自增 + + @Unique + private String messageId; + private String appId; + private String clientId; + private String taskId; + private String userId; + private String title; + private String content; + private String deviceCode; + private String isRead;//0-未读,1-已读 + private String alarmTime; + + @Generated(hash = 566950134) + public AlarmMessageLocaleBean(Long id, String messageId, String appId, + String clientId, String taskId, String userId, String title, + String content, String deviceCode, String isRead, String alarmTime) { + this.id = id; + this.messageId = messageId; + this.appId = appId; + this.clientId = clientId; + this.taskId = taskId; + this.userId = userId; + this.title = title; + this.content = content; + this.deviceCode = deviceCode; + this.isRead = isRead; + this.alarmTime = alarmTime; + } + + @Generated(hash = 1737519562) + public AlarmMessageLocaleBean() { + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getMessageId() { + return this.messageId; + } + + public void setMessageId(String messageId) { + this.messageId = messageId; + } + + public String getAppId() { + return this.appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public String getClientId() { + return this.clientId; + } + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public String getTaskId() { + return this.taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getUserId() { + return this.userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getTitle() { + return this.title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return this.content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getDeviceCode() { + return this.deviceCode; + } + + public void setDeviceCode(String deviceCode) { + this.deviceCode = deviceCode; + } + + public String getIsRead() { + return this.isRead; + } + + public void setIsRead(String isRead) { + this.isRead = isRead; + } + + public String getAlarmTime() { + return this.alarmTime; + } + + public void setAlarmTime(String alarmTime) { + this.alarmTime = alarmTime; + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt new file mode 100644 index 0000000..650e201 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class AlarmPageFragment: KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_alarm + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt new file mode 100644 index 0000000..deac8ac --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt @@ -0,0 +1,76 @@ +package com.casic.smart.town.sanxi.fragment + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.Fragment +import com.amap.api.maps.AMap +import com.amap.api.maps.AMapOptions +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.view.MonitorRecordActivity +import com.pengxh.kt.lite.extensions.navigatePageTo +import com.pengxh.kt.lite.extensions.show +import kotlinx.android.synthetic.main.fragment_monitor.view.* + +class MonitorPageFragment : Fragment() { + + private val kTag = "HomePageFragment" + private lateinit var monitorView: View + private lateinit var aMap: AMap + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? + ): View { + monitorView = inflater.inflate(R.layout.fragment_monitor, container, false) + //地图初始化 + initMap(savedInstanceState) + + monitorView.rightOperateView.setOnClickListener { + requireContext().navigatePageTo() + } + return monitorView + } + + private fun initMap(savedInstanceState: Bundle?) { + monitorView.mapView.onCreate(savedInstanceState) + aMap = monitorView.mapView.map + aMap.mapType = AMap.MAP_TYPE_NORMAL + val uiSettings = aMap.uiSettings + uiSettings.isCompassEnabled = true + uiSettings.zoomPosition = AMapOptions.ZOOM_POSITION_RIGHT_CENTER + uiSettings.isTiltGesturesEnabled = false//不许地图随手势倾斜角度 + + // 地图加载成功监听 +// aMap.addOnMapLoadedListener(this) + // 地图缩放监听 +// aMap.addOnCameraChangeListener(this) + // marker 点击事件监听 +// aMap.addOnMarkerClickListener(this) + // 点击marker弹出自定义popup +// aMap.setInfoWindowAdapter(this) + //信息窗点击事件 +// aMap.addOnInfoWindowClickListener(this) + } + + /***以下是地图生命周期管理************************************************************************/ + override fun onResume() { + super.onResume() + monitorView.mapView.onResume() + } + + override fun onPause() { + super.onPause() + monitorView.mapView.onPause() + } + + override fun onSaveInstanceState(outState: Bundle) { + super.onSaveInstanceState(outState) + monitorView.mapView.onSaveInstanceState(outState) + } + + override fun onDestroy() { + super.onDestroy() + monitorView.mapView.onDestroy() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt new file mode 100644 index 0000000..e84df12 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class StatisticsPageFragment : KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_statistics + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java new file mode 100644 index 0000000..68d7901 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java @@ -0,0 +1,255 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.database.Cursor; +import android.database.sqlite.SQLiteStatement; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.Property; +import org.greenrobot.greendao.internal.DaoConfig; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseStatement; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * DAO for table "ALARM_MESSAGE_LOCALE_BEAN". +*/ +public class AlarmMessageLocaleBeanDao extends AbstractDao { + + public static final String TABLENAME = "ALARM_MESSAGE_LOCALE_BEAN"; + + /** + * Properties of entity AlarmMessageLocaleBean.
+ * Can be used for QueryBuilder and for referencing column names. + */ + public static class Properties { + public final static Property Id = new Property(0, Long.class, "id", true, "_id"); + public final static Property MessageId = new Property(1, String.class, "messageId", false, "MESSAGE_ID"); + public final static Property AppId = new Property(2, String.class, "appId", false, "APP_ID"); + public final static Property ClientId = new Property(3, String.class, "clientId", false, "CLIENT_ID"); + public final static Property TaskId = new Property(4, String.class, "taskId", false, "TASK_ID"); + public final static Property UserId = new Property(5, String.class, "userId", false, "USER_ID"); + public final static Property Title = new Property(6, String.class, "title", false, "TITLE"); + public final static Property Content = new Property(7, String.class, "content", false, "CONTENT"); + public final static Property DeviceCode = new Property(8, String.class, "deviceCode", false, "DEVICE_CODE"); + public final static Property IsRead = new Property(9, String.class, "isRead", false, "IS_READ"); + public final static Property AlarmTime = new Property(10, String.class, "alarmTime", false, "ALARM_TIME"); + } + + + public AlarmMessageLocaleBeanDao(DaoConfig config) { + super(config); + } + + public AlarmMessageLocaleBeanDao(DaoConfig config, DaoSession daoSession) { + super(config, daoSession); + } + + /** Creates the underlying database table. */ + public static void createTable(Database db, boolean ifNotExists) { + String constraint = ifNotExists? "IF NOT EXISTS ": ""; + db.execSQL("CREATE TABLE " + constraint + "\"ALARM_MESSAGE_LOCALE_BEAN\" (" + // + "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id + "\"MESSAGE_ID\" TEXT UNIQUE ," + // 1: messageId + "\"APP_ID\" TEXT," + // 2: appId + "\"CLIENT_ID\" TEXT," + // 3: clientId + "\"TASK_ID\" TEXT," + // 4: taskId + "\"USER_ID\" TEXT," + // 5: userId + "\"TITLE\" TEXT," + // 6: title + "\"CONTENT\" TEXT," + // 7: content + "\"DEVICE_CODE\" TEXT," + // 8: deviceCode + "\"IS_READ\" TEXT," + // 9: isRead + "\"ALARM_TIME\" TEXT);"); // 10: alarmTime + } + + /** Drops the underlying database table. */ + public static void dropTable(Database db, boolean ifExists) { + String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"ALARM_MESSAGE_LOCALE_BEAN\""; + db.execSQL(sql); + } + + @Override + protected final void bindValues(DatabaseStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + protected final void bindValues(SQLiteStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + public Long readKey(Cursor cursor, int offset) { + return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); + } + + @Override + public AlarmMessageLocaleBean readEntity(Cursor cursor, int offset) { + AlarmMessageLocaleBean entity = new AlarmMessageLocaleBean( // + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // messageId + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // appId + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // clientId + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // taskId + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // userId + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // title + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // content + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // deviceCode + cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // isRead + cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10) // alarmTime + ); + return entity; + } + + @Override + public void readEntity(Cursor cursor, AlarmMessageLocaleBean entity, int offset) { + entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); + entity.setMessageId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setAppId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setClientId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setTaskId(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); + entity.setUserId(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setTitle(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setContent(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); + entity.setDeviceCode(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); + entity.setIsRead(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9)); + entity.setAlarmTime(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); + } + + @Override + protected final Long updateKeyAfterInsert(AlarmMessageLocaleBean entity, long rowId) { + entity.setId(rowId); + return rowId; + } + + @Override + public Long getKey(AlarmMessageLocaleBean entity) { + if(entity != null) { + return entity.getId(); + } else { + return null; + } + } + + @Override + public boolean hasKey(AlarmMessageLocaleBean entity) { + return entity.getId() != null; + } + + @Override + protected final boolean isEntityUpdateable() { + return true; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java new file mode 100644 index 0000000..4222c40 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java @@ -0,0 +1,96 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.content.Context; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteDatabase.CursorFactory; +import android.util.Log; + +import org.greenrobot.greendao.AbstractDaoMaster; +import org.greenrobot.greendao.database.StandardDatabase; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseOpenHelper; +import org.greenrobot.greendao.identityscope.IdentityScopeType; + + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * Master of DAO (schema version 1): knows all DAOs. + */ +public class DaoMaster extends AbstractDaoMaster { + public static final int SCHEMA_VERSION = 1; + + /** Creates underlying database table using DAOs. */ + public static void createAllTables(Database db, boolean ifNotExists) { + AlarmMessageLocaleBeanDao.createTable(db, ifNotExists); + } + + /** Drops underlying database table using DAOs. */ + public static void dropAllTables(Database db, boolean ifExists) { + AlarmMessageLocaleBeanDao.dropTable(db, ifExists); + } + + /** + * WARNING: Drops all table on Upgrade! Use only during development. + * Convenience method using a {@link DevOpenHelper}. + */ + public static DaoSession newDevSession(Context context, String name) { + Database db = new DevOpenHelper(context, name).getWritableDb(); + DaoMaster daoMaster = new DaoMaster(db); + return daoMaster.newSession(); + } + + public DaoMaster(SQLiteDatabase db) { + this(new StandardDatabase(db)); + } + + public DaoMaster(Database db) { + super(db, SCHEMA_VERSION); + registerDaoClass(AlarmMessageLocaleBeanDao.class); + } + + public DaoSession newSession() { + return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); + } + + public DaoSession newSession(IdentityScopeType type) { + return new DaoSession(db, type, daoConfigMap); + } + + /** + * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} - + */ + public static abstract class OpenHelper extends DatabaseOpenHelper { + public OpenHelper(Context context, String name) { + super(context, name, SCHEMA_VERSION); + } + + public OpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory, SCHEMA_VERSION); + } + + @Override + public void onCreate(Database db) { + Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); + createAllTables(db, false); + } + } + + /** WARNING: Drops all table on Upgrade! Use only during development. */ + public static class DevOpenHelper extends OpenHelper { + public DevOpenHelper(Context context, String name) { + super(context, name); + } + + public DevOpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory); + } + + @Override + public void onUpgrade(Database db, int oldVersion, int newVersion) { + Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); + dropAllTables(db, true); + onCreate(db); + } + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java new file mode 100644 index 0000000..480ed84 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java @@ -0,0 +1,48 @@ +package com.casic.smart.town.sanxi.greendao; + +import java.util.Map; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.AbstractDaoSession; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.identityscope.IdentityScopeType; +import org.greenrobot.greendao.internal.DaoConfig; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. + +/** + * {@inheritDoc} + * + * @see org.greenrobot.greendao.AbstractDaoSession + */ +public class DaoSession extends AbstractDaoSession { + + private final DaoConfig alarmMessageLocaleBeanDaoConfig; + + private final AlarmMessageLocaleBeanDao alarmMessageLocaleBeanDao; + + public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> + daoConfigMap) { + super(db); + + alarmMessageLocaleBeanDaoConfig = daoConfigMap.get(AlarmMessageLocaleBeanDao.class).clone(); + alarmMessageLocaleBeanDaoConfig.initIdentityScope(type); + + alarmMessageLocaleBeanDao = new AlarmMessageLocaleBeanDao(alarmMessageLocaleBeanDaoConfig, this); + + registerDao(AlarmMessageLocaleBean.class, alarmMessageLocaleBeanDao); + } + + public void clear() { + alarmMessageLocaleBeanDaoConfig.clearIdentityScope(); + } + + public AlarmMessageLocaleBeanDao getAlarmMessageLocaleBeanDao() { + return alarmMessageLocaleBeanDao; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt new file mode 100644 index 0000000..875cb8c --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt @@ -0,0 +1,5 @@ +package com.casic.smart.town.sanxi.service + +import com.igexin.sdk.PushService + +class ApplicationPushService : PushService() \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt new file mode 100644 index 0000000..396129f --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt @@ -0,0 +1,84 @@ +package com.casic.smart.town.sanxi.service + +import android.content.Context +import android.os.Message +import android.util.Log +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.casic.smart.town.sanxi.view.MainActivity +import com.igexin.sdk.GTIntentService +import com.igexin.sdk.message.GTCmdMessage +import com.igexin.sdk.message.GTNotificationMessage +import com.igexin.sdk.message.GTTransmitMessage +import com.pengxh.kt.lite.extensions.toJson + +class PushIntentService : GTIntentService() { + + private val kTag = "SmartWellIntentService" + + override fun onReceiveServicePid(context: Context?, pid: Int) { + + } + + // 透传消息 + override fun onReceiveMessageData(context: Context?, msg: GTTransmitMessage?) { + Log.d(kTag, "透传消息 -> msg = $msg") + } + + // 接收 cid + override fun onReceiveClientId(context: Context?, clientid: String?) { + Log.d(kTag, "onReceiveClientId -> $clientid") + //通知MainActivity注册个推服务 + val msg: Message = MainActivity.weakReferenceHandler.obtainMessage() + msg.what = LocaleConstant.PUSH_REGISTER + msg.obj = clientid + MainActivity.weakReferenceHandler.sendMessage(msg) + } + + // cid 离线上线通知 + override fun onReceiveOnlineState(context: Context?, online: Boolean) { + + } + + // 各种事件处理回执 + override fun onReceiveCommandResult(context: Context?, msg: GTCmdMessage?) { + + } + + // 通知到达 + override fun onNotificationMessageArrived(context: Context?, msg: GTNotificationMessage?) { + //报警 +// { +// "content": "设备编号[412022030361]发生井盖开盖报警", +// "messageId": "380abf9a79d34306a2683dc9bf96ee78", +// "taskId": "OSL-0830_4hmfimp3Vu684wo3SjXso9", +// "title": "告警提醒", +// "appid": "HKv8K9qARd6WckZ1o2Vbu4", +// "clientId": "e78beacc42e9a02ae6fb9087eb2b1171", +// "pkgName": "com.casic.app.smartwell" +// } + if (msg == null) { + return + } + Log.d(kTag, "通知到达 -> msg = ${msg.toJson()}") +// val userDetailJson = SaveKeyValues.getValue(LocaleConstant.USER_DETAIL_MODEL, "") as String +// var userId = "" +// if (userDetailJson.isNotBlank()) { +// val userDataModel = Gson().fromJson( +// userDetailJson, object : TypeToken() {}.type +// ) +// userId = userDataModel.id.toString() +// } +// //解析编号 +// val splitArray = msg.content.split("\\[|\\]".toRegex()) +// DataBaseManager.instance.insertNotice( +// msg.messageId, msg.appid, msg.clientId, msg.taskId, +// userId, msg.title, msg.content, splitArray[1], "0", +// System.currentTimeMillis().timestampToCompleteDate() +// ) + } + + // 通知点击 + override fun onNotificationMessageClicked(context: Context?, msg: GTNotificationMessage?) { + Log.d(kTag, "通知点击 -> msg = $msg") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt new file mode 100644 index 0000000..daa7c38 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt @@ -0,0 +1,14 @@ +package com.casic.smart.town.sanxi.util + +import android.content.Context +import me.leolin.shortcutbadger.ShortcutBadger + +object BadeHelper { + fun setBadgeNum(context: Context, badgeCount: Int) { + if (badgeCount == 0) { + ShortcutBadger.removeCount(context) + } else { + ShortcutBadger.applyCount(context, badgeCount) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt new file mode 100644 index 0000000..0a52ef2 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt @@ -0,0 +1,75 @@ +package com.casic.smart.town.sanxi.util + +import com.casic.smart.town.sanxi.base.BaseApplication +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao + +class DataBaseManager private constructor() { + + companion object { + //Kotlin委托模式双重锁单例 + val instance: DataBaseManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) { + DataBaseManager() + } + } + + private val beanDao = + BaseApplication.obtainInstance().obtainDaoSession().alarmMessageLocaleBeanDao + +// fun insertNotice( +// messageId: String, appid: String, clientId: String, +// taskId: String, userId: String, title: String, +// content: String, deviceCode: String, isRead: String, +// noticeTime: String +// ) { +// val noticeLocaleBean = NoticeLocaleBean() +// noticeLocaleBean.messageId = messageId +// noticeLocaleBean.appid = appid +// noticeLocaleBean.clientId = clientId +// noticeLocaleBean.taskId = taskId +// noticeLocaleBean.userId = userId +// noticeLocaleBean.title = title +// noticeLocaleBean.content = content +// noticeLocaleBean.deviceCode = deviceCode +// noticeLocaleBean.isRead = isRead +// noticeLocaleBean.noticeTime = noticeTime +// beanDao.insert(noticeLocaleBean) +// //角标设置 +// BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadNotice()) +// } + + fun deleteByMessageId(messageId: String) { + val result = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).list() + beanDao.deleteInTx(result) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun updateNoticeByMessageId(messageId: String) { + val noticeLocaleBean = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).unique() ?: return + noticeLocaleBean.isRead = "1" + beanDao.update(noticeLocaleBean) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun queryMessageByPage(userId: String, offset: Int): MutableList { + return BaseApplication.obtainInstance().obtainDaoSession() + .queryBuilder(AlarmMessageLocaleBean::class.java) + .where(AlarmMessageLocaleBeanDao.Properties.UserId.eq(userId)) + .offset(offset * LocaleConstant.PAGE_LIMIT) + .orderDesc(AlarmMessageLocaleBeanDao.Properties.AlarmTime) + .limit(LocaleConstant.PAGE_LIMIT) + .list() + } + + private fun queryUnReadMessage(): Int { + return beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.IsRead.eq("0") + ).list().size + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt new file mode 100644 index 0000000..52926a8 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt @@ -0,0 +1,31 @@ +package com.casic.smart.town.sanxi.util; + +import android.app.Activity +import android.view.WindowManager +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object LoadingDialogHub { + private lateinit var loadingDialog: QMUITipDialog + + fun show(activity: Activity, message: String) { + loadingDialog = QMUITipDialog + .Builder(activity) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_LOADING) + .setTipWord(message) + .create() + if (!activity.isDestroyed) { + try { + loadingDialog.show() + } catch (e: WindowManager.BadTokenException) { + e.printStackTrace() + } + } + } + + + fun dismiss() { + if (loadingDialog.isShowing) { + loadingDialog.dismiss() + } + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt new file mode 100644 index 0000000..de61c9a --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.util + +import android.Manifest + +object LocaleConstant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.READ_PHONE_STATE, + Manifest.permission.ACCESS_COARSE_LOCATION, + Manifest.permission.READ_EXTERNAL_STORAGE + ) + + const val PERMISSIONS_CODE = 999 + const val PUSH_REGISTER = 2022100101 + const val PAGE_LIMIT = 20 +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt new file mode 100644 index 0000000..3bea1c9 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt @@ -0,0 +1,112 @@ +package com.casic.smart.town.sanxi.view + +import android.view.KeyEvent +import android.view.MenuItem +import androidx.fragment.app.Fragment +import androidx.viewpager.widget.ViewPager +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.adapter.ViewPagerAdapter +import com.casic.smart.town.sanxi.fragment.AlarmPageFragment +import com.casic.smart.town.sanxi.fragment.MonitorPageFragment +import com.casic.smart.town.sanxi.fragment.StatisticsPageFragment +import com.gyf.immersionbar.ImmersionBar +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.base.KotlinBaseActivity +import com.pengxh.kt.lite.extensions.convertColor +import com.pengxh.kt.lite.extensions.show +import com.pengxh.kt.lite.utils.ImmerseStatusBarUtil +import com.pengxh.kt.lite.utils.WeakReferenceHandler +import kotlinx.android.synthetic.main.activity_main.* + +class MainActivity : KotlinBaseActivity() { + + companion object { + lateinit var weakReferenceHandler: WeakReferenceHandler + } + + private val kTag = "MainActivity" + private var menuItem: MenuItem? = null + private var fragmentPages: ArrayList = ArrayList() + private var clickTime: Long = 0 + + init { + fragmentPages.add(StatisticsPageFragment()) + fragmentPages.add(MonitorPageFragment()) + fragmentPages.add(AlarmPageFragment()) + } + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + ImmersionBar.with(this).statusBarDarkFont(false).init() + ImmerseStatusBarUtil.setColor(this, R.color.mainThemeColor.convertColor(this)) + } + + override fun initData() { + //推送,多次调用 SDK 初始化并无影响。 + PushManager.getInstance().initialize(this) + weakReferenceHandler = WeakReferenceHandler { + + true + } + } + + override fun observeRequestState() { + + } + + override fun initEvent() { + bottomNavigation.itemIconTintList = null + bottomNavigation.setOnNavigationItemSelectedListener { menuItem -> + when (menuItem.itemId) { + R.id.nav_statistics -> { + mainViewPager.currentItem = 0 + } + R.id.nav_monitor -> { + mainViewPager.currentItem = 1 + } + R.id.nav_alarm -> { + mainViewPager.currentItem = 2 + } + } + false + } + mainViewPager.adapter = ViewPagerAdapter(fragmentPages, supportFragmentManager) + mainViewPager.offscreenPageLimit = fragmentPages.size //缓存页数 + mainViewPager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener { + override fun onPageScrollStateChanged(state: Int) { + + } + + override fun onPageScrolled( + position: Int, + positionOffset: Float, + positionOffsetPixels: Int + ) { + + } + + override fun onPageSelected(position: Int) { + if (menuItem != null) { + menuItem!!.isChecked = false + } else { + bottomNavigation.menu.getItem(0).isChecked = false + } + menuItem = bottomNavigation.menu.getItem(position) + menuItem!!.isChecked = true + } + }) + } + + override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean { + return if (keyCode == KeyEvent.KEYCODE_BACK) { + if (System.currentTimeMillis() - clickTime > 2000) { + "再按一次退出程序".show(this) + clickTime = System.currentTimeMillis() + true + } else { + super.onKeyDown(keyCode, event) + } + } else super.onKeyDown(keyCode, event) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt new file mode 100644 index 0000000..c5d8b22 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.view + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseActivity + +class MonitorRecordActivity : KotlinBaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_monitor_record + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt new file mode 100644 index 0000000..c478d83 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt @@ -0,0 +1,55 @@ +package com.casic.smart.town.sanxi.view + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.amap.api.maps.MapsInitializer +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.gyf.immersionbar.ImmersionBar +import com.pengxh.kt.lite.extensions.navigatePageTo +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + ImmersionBar.with(this).statusBarDarkFont(true).init() + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (EasyPermissions.hasPermissions(this, *LocaleConstant.USER_PERMISSIONS)) { + startSplashScreenActivity() + } else { + EasyPermissions.requestPermissions( + this@PermissionActivity, + resources.getString(R.string.app_name) + "需要获取相关权限", + LocaleConstant.PERMISSIONS_CODE, + *LocaleConstant.USER_PERMISSIONS + ) + } + } + + private fun startSplashScreenActivity() { + //先把导航隐私政策声明,后面导航会用到 + MapsInitializer.updatePrivacyAgree(this, true) + MapsInitializer.updatePrivacyShow(this, true, true) + this.navigatePageTo() + 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) { + startSplashScreenActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable/alarm_selector.xml b/app/src/main/res/drawable/alarm_selector.xml new file mode 100644 index 0000000..39b2595 --- /dev/null +++ b/app/src/main/res/drawable/alarm_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bottom_text_color.xml b/app/src/main/res/drawable/bottom_text_color.xml new file mode 100644 index 0000000..b284ea3 --- /dev/null +++ b/app/src/main/res/drawable/bottom_text_color.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_alarm.xml b/app/src/main/res/drawable/ic_alarm.xml new file mode 100644 index 0000000..dc33aab --- /dev/null +++ b/app/src/main/res/drawable/ic_alarm.xml @@ -0,0 +1,9 @@ + + + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..10cfdbf --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*.iml +.gradle +/local.properties +/.idea +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..a4cd2ca --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,101 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'org.greenrobot.greendao' + +android { +// signingConfigs { +// release { +// storeFile file('/Users/a203/Desktop/AndroidProjects/CasicSmartWell/app/CasicSmartWell.jks') +// storePassword '123456789' +// keyAlias 'key0' +// keyPassword '123456789' +// } +// } + compileSdkVersion 31 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.smart.town.sanxi" + minSdkVersion 23 + targetSdkVersion 31 + versionCode 1 + versionName "1.0.0" + + manifestPlaceholders = [GETUI_APPID: "A9V4DvwLcdAqkFCQuFyhq6"] + } + + buildTypes { + release { + minifyEnabled false +// signingConfig signingConfigs.release + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + + ndk { abiFilters "armeabi", "armeabi-v7a", "arm64-v8" } + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlin { + experimental { + coroutines 'enable' + } + } + + greendao { + schemaVersion 1//数据库版本号 + targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 + daoPackage 'com.casic.smart.town.sanxi.greendao'//设置DaoMaster、DaoSession、Dao包名 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + //基础依赖库 + implementation files('libs/lite-release.aar') + implementation 'androidx.appcompat:appcompat:1.4.2' + implementation 'androidx.core:core-ktx:1.8.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:3.0.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' + //MVVM+LiveData + implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.1" + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0" + implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + //Kotlin协程 + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1' + //图片加载框架 + implementation 'com.github.bumptech.glide:glide:4.9.0' + //返回值转换器 + implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' + implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + //okhttp3日志拦截器 + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //网络请求和接口封装 + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.9.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.9.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' + //高德地图 + implementation 'com.amap.api:3dmap:latest.integration' + //推送SDK + implementation 'com.getui:gtsdk:3.2.10.0' //个推SDK + implementation 'com.getui:gtc:3.1.9.0' //个推核心组件 + //数据库框架 + implementation 'org.greenrobot:greendao:3.3.0' + //桌面角标 + implementation "me.leolin:ShortcutBadger:1.1.22@aar" +} \ No newline at end of file diff --git a/app/libs/lite-release.aar b/app/libs/lite-release.aar new file mode 100644 index 0000000..45da4df --- /dev/null +++ b/app/libs/lite-release.aar Binary files differ diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /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 \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..a83c28a --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/svg/monitor.svg b/app/src/main/assets/svg/monitor.svg new file mode 100644 index 0000000..c8d3e25 --- /dev/null +++ b/app/src/main/assets/svg/monitor.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/msg.svg b/app/src/main/assets/svg/msg.svg new file mode 100644 index 0000000..e864e48 --- /dev/null +++ b/app/src/main/assets/svg/msg.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/statistics.svg b/app/src/main/assets/svg/statistics.svg new file mode 100644 index 0000000..974000e --- /dev/null +++ b/app/src/main/assets/svg/statistics.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt new file mode 100644 index 0000000..6b9cce0 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.adapter + +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentManager +import androidx.fragment.app.FragmentPagerAdapter + +class ViewPagerAdapter(list: ArrayList, manager: FragmentManager) : + FragmentPagerAdapter(manager) { + + private var pageList: List = list + + override fun getItem(position: Int) = pageList[position] + + override fun getCount() = pageList.size +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt new file mode 100644 index 0000000..4e017b1 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt @@ -0,0 +1,40 @@ +package com.casic.smart.town.sanxi.base + +import android.app.Application +import android.util.Log +import com.casic.smart.town.sanxi.greendao.DaoMaster +import com.casic.smart.town.sanxi.greendao.DaoSession +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + private val kTag = "BaseApplication" + + companion object { + private var instance: BaseApplication by Delegates.notNull() + + fun obtainInstance() = instance + + private lateinit var daoSession: DaoSession + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences(this) + //推送 + PushManager.getInstance().initialize(this) + PushManager.getInstance().setDebugLogger(this) { + Log.d(kTag, it) + } + val devOpenHelper = DaoMaster.DevOpenHelper(this, "SmartTown.db", null) + val daoMaster = DaoMaster(devOpenHelper.writableDatabase) + daoSession = daoMaster.newSession() + } + + fun obtainDaoSession(): DaoSession { + return daoSession + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java new file mode 100644 index 0000000..b8f67dc --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java @@ -0,0 +1,133 @@ +package com.casic.smart.town.sanxi.bean; + +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Generated; +import org.greenrobot.greendao.annotation.Id; +import org.greenrobot.greendao.annotation.Unique; + +@Entity +public class AlarmMessageLocaleBean { + @Id(autoincrement = true) + private Long id;//主键自增 + + @Unique + private String messageId; + private String appId; + private String clientId; + private String taskId; + private String userId; + private String title; + private String content; + private String deviceCode; + private String isRead;//0-未读,1-已读 + private String alarmTime; + + @Generated(hash = 566950134) + public AlarmMessageLocaleBean(Long id, String messageId, String appId, + String clientId, String taskId, String userId, String title, + String content, String deviceCode, String isRead, String alarmTime) { + this.id = id; + this.messageId = messageId; + this.appId = appId; + this.clientId = clientId; + this.taskId = taskId; + this.userId = userId; + this.title = title; + this.content = content; + this.deviceCode = deviceCode; + this.isRead = isRead; + this.alarmTime = alarmTime; + } + + @Generated(hash = 1737519562) + public AlarmMessageLocaleBean() { + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getMessageId() { + return this.messageId; + } + + public void setMessageId(String messageId) { + this.messageId = messageId; + } + + public String getAppId() { + return this.appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public String getClientId() { + return this.clientId; + } + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public String getTaskId() { + return this.taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getUserId() { + return this.userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getTitle() { + return this.title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return this.content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getDeviceCode() { + return this.deviceCode; + } + + public void setDeviceCode(String deviceCode) { + this.deviceCode = deviceCode; + } + + public String getIsRead() { + return this.isRead; + } + + public void setIsRead(String isRead) { + this.isRead = isRead; + } + + public String getAlarmTime() { + return this.alarmTime; + } + + public void setAlarmTime(String alarmTime) { + this.alarmTime = alarmTime; + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt new file mode 100644 index 0000000..650e201 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class AlarmPageFragment: KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_alarm + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt new file mode 100644 index 0000000..deac8ac --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt @@ -0,0 +1,76 @@ +package com.casic.smart.town.sanxi.fragment + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.Fragment +import com.amap.api.maps.AMap +import com.amap.api.maps.AMapOptions +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.view.MonitorRecordActivity +import com.pengxh.kt.lite.extensions.navigatePageTo +import com.pengxh.kt.lite.extensions.show +import kotlinx.android.synthetic.main.fragment_monitor.view.* + +class MonitorPageFragment : Fragment() { + + private val kTag = "HomePageFragment" + private lateinit var monitorView: View + private lateinit var aMap: AMap + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? + ): View { + monitorView = inflater.inflate(R.layout.fragment_monitor, container, false) + //地图初始化 + initMap(savedInstanceState) + + monitorView.rightOperateView.setOnClickListener { + requireContext().navigatePageTo() + } + return monitorView + } + + private fun initMap(savedInstanceState: Bundle?) { + monitorView.mapView.onCreate(savedInstanceState) + aMap = monitorView.mapView.map + aMap.mapType = AMap.MAP_TYPE_NORMAL + val uiSettings = aMap.uiSettings + uiSettings.isCompassEnabled = true + uiSettings.zoomPosition = AMapOptions.ZOOM_POSITION_RIGHT_CENTER + uiSettings.isTiltGesturesEnabled = false//不许地图随手势倾斜角度 + + // 地图加载成功监听 +// aMap.addOnMapLoadedListener(this) + // 地图缩放监听 +// aMap.addOnCameraChangeListener(this) + // marker 点击事件监听 +// aMap.addOnMarkerClickListener(this) + // 点击marker弹出自定义popup +// aMap.setInfoWindowAdapter(this) + //信息窗点击事件 +// aMap.addOnInfoWindowClickListener(this) + } + + /***以下是地图生命周期管理************************************************************************/ + override fun onResume() { + super.onResume() + monitorView.mapView.onResume() + } + + override fun onPause() { + super.onPause() + monitorView.mapView.onPause() + } + + override fun onSaveInstanceState(outState: Bundle) { + super.onSaveInstanceState(outState) + monitorView.mapView.onSaveInstanceState(outState) + } + + override fun onDestroy() { + super.onDestroy() + monitorView.mapView.onDestroy() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt new file mode 100644 index 0000000..e84df12 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class StatisticsPageFragment : KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_statistics + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java new file mode 100644 index 0000000..68d7901 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java @@ -0,0 +1,255 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.database.Cursor; +import android.database.sqlite.SQLiteStatement; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.Property; +import org.greenrobot.greendao.internal.DaoConfig; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseStatement; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * DAO for table "ALARM_MESSAGE_LOCALE_BEAN". +*/ +public class AlarmMessageLocaleBeanDao extends AbstractDao { + + public static final String TABLENAME = "ALARM_MESSAGE_LOCALE_BEAN"; + + /** + * Properties of entity AlarmMessageLocaleBean.
+ * Can be used for QueryBuilder and for referencing column names. + */ + public static class Properties { + public final static Property Id = new Property(0, Long.class, "id", true, "_id"); + public final static Property MessageId = new Property(1, String.class, "messageId", false, "MESSAGE_ID"); + public final static Property AppId = new Property(2, String.class, "appId", false, "APP_ID"); + public final static Property ClientId = new Property(3, String.class, "clientId", false, "CLIENT_ID"); + public final static Property TaskId = new Property(4, String.class, "taskId", false, "TASK_ID"); + public final static Property UserId = new Property(5, String.class, "userId", false, "USER_ID"); + public final static Property Title = new Property(6, String.class, "title", false, "TITLE"); + public final static Property Content = new Property(7, String.class, "content", false, "CONTENT"); + public final static Property DeviceCode = new Property(8, String.class, "deviceCode", false, "DEVICE_CODE"); + public final static Property IsRead = new Property(9, String.class, "isRead", false, "IS_READ"); + public final static Property AlarmTime = new Property(10, String.class, "alarmTime", false, "ALARM_TIME"); + } + + + public AlarmMessageLocaleBeanDao(DaoConfig config) { + super(config); + } + + public AlarmMessageLocaleBeanDao(DaoConfig config, DaoSession daoSession) { + super(config, daoSession); + } + + /** Creates the underlying database table. */ + public static void createTable(Database db, boolean ifNotExists) { + String constraint = ifNotExists? "IF NOT EXISTS ": ""; + db.execSQL("CREATE TABLE " + constraint + "\"ALARM_MESSAGE_LOCALE_BEAN\" (" + // + "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id + "\"MESSAGE_ID\" TEXT UNIQUE ," + // 1: messageId + "\"APP_ID\" TEXT," + // 2: appId + "\"CLIENT_ID\" TEXT," + // 3: clientId + "\"TASK_ID\" TEXT," + // 4: taskId + "\"USER_ID\" TEXT," + // 5: userId + "\"TITLE\" TEXT," + // 6: title + "\"CONTENT\" TEXT," + // 7: content + "\"DEVICE_CODE\" TEXT," + // 8: deviceCode + "\"IS_READ\" TEXT," + // 9: isRead + "\"ALARM_TIME\" TEXT);"); // 10: alarmTime + } + + /** Drops the underlying database table. */ + public static void dropTable(Database db, boolean ifExists) { + String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"ALARM_MESSAGE_LOCALE_BEAN\""; + db.execSQL(sql); + } + + @Override + protected final void bindValues(DatabaseStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + protected final void bindValues(SQLiteStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + public Long readKey(Cursor cursor, int offset) { + return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); + } + + @Override + public AlarmMessageLocaleBean readEntity(Cursor cursor, int offset) { + AlarmMessageLocaleBean entity = new AlarmMessageLocaleBean( // + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // messageId + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // appId + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // clientId + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // taskId + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // userId + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // title + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // content + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // deviceCode + cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // isRead + cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10) // alarmTime + ); + return entity; + } + + @Override + public void readEntity(Cursor cursor, AlarmMessageLocaleBean entity, int offset) { + entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); + entity.setMessageId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setAppId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setClientId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setTaskId(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); + entity.setUserId(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setTitle(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setContent(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); + entity.setDeviceCode(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); + entity.setIsRead(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9)); + entity.setAlarmTime(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); + } + + @Override + protected final Long updateKeyAfterInsert(AlarmMessageLocaleBean entity, long rowId) { + entity.setId(rowId); + return rowId; + } + + @Override + public Long getKey(AlarmMessageLocaleBean entity) { + if(entity != null) { + return entity.getId(); + } else { + return null; + } + } + + @Override + public boolean hasKey(AlarmMessageLocaleBean entity) { + return entity.getId() != null; + } + + @Override + protected final boolean isEntityUpdateable() { + return true; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java new file mode 100644 index 0000000..4222c40 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java @@ -0,0 +1,96 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.content.Context; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteDatabase.CursorFactory; +import android.util.Log; + +import org.greenrobot.greendao.AbstractDaoMaster; +import org.greenrobot.greendao.database.StandardDatabase; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseOpenHelper; +import org.greenrobot.greendao.identityscope.IdentityScopeType; + + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * Master of DAO (schema version 1): knows all DAOs. + */ +public class DaoMaster extends AbstractDaoMaster { + public static final int SCHEMA_VERSION = 1; + + /** Creates underlying database table using DAOs. */ + public static void createAllTables(Database db, boolean ifNotExists) { + AlarmMessageLocaleBeanDao.createTable(db, ifNotExists); + } + + /** Drops underlying database table using DAOs. */ + public static void dropAllTables(Database db, boolean ifExists) { + AlarmMessageLocaleBeanDao.dropTable(db, ifExists); + } + + /** + * WARNING: Drops all table on Upgrade! Use only during development. + * Convenience method using a {@link DevOpenHelper}. + */ + public static DaoSession newDevSession(Context context, String name) { + Database db = new DevOpenHelper(context, name).getWritableDb(); + DaoMaster daoMaster = new DaoMaster(db); + return daoMaster.newSession(); + } + + public DaoMaster(SQLiteDatabase db) { + this(new StandardDatabase(db)); + } + + public DaoMaster(Database db) { + super(db, SCHEMA_VERSION); + registerDaoClass(AlarmMessageLocaleBeanDao.class); + } + + public DaoSession newSession() { + return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); + } + + public DaoSession newSession(IdentityScopeType type) { + return new DaoSession(db, type, daoConfigMap); + } + + /** + * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} - + */ + public static abstract class OpenHelper extends DatabaseOpenHelper { + public OpenHelper(Context context, String name) { + super(context, name, SCHEMA_VERSION); + } + + public OpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory, SCHEMA_VERSION); + } + + @Override + public void onCreate(Database db) { + Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); + createAllTables(db, false); + } + } + + /** WARNING: Drops all table on Upgrade! Use only during development. */ + public static class DevOpenHelper extends OpenHelper { + public DevOpenHelper(Context context, String name) { + super(context, name); + } + + public DevOpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory); + } + + @Override + public void onUpgrade(Database db, int oldVersion, int newVersion) { + Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); + dropAllTables(db, true); + onCreate(db); + } + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java new file mode 100644 index 0000000..480ed84 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java @@ -0,0 +1,48 @@ +package com.casic.smart.town.sanxi.greendao; + +import java.util.Map; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.AbstractDaoSession; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.identityscope.IdentityScopeType; +import org.greenrobot.greendao.internal.DaoConfig; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. + +/** + * {@inheritDoc} + * + * @see org.greenrobot.greendao.AbstractDaoSession + */ +public class DaoSession extends AbstractDaoSession { + + private final DaoConfig alarmMessageLocaleBeanDaoConfig; + + private final AlarmMessageLocaleBeanDao alarmMessageLocaleBeanDao; + + public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> + daoConfigMap) { + super(db); + + alarmMessageLocaleBeanDaoConfig = daoConfigMap.get(AlarmMessageLocaleBeanDao.class).clone(); + alarmMessageLocaleBeanDaoConfig.initIdentityScope(type); + + alarmMessageLocaleBeanDao = new AlarmMessageLocaleBeanDao(alarmMessageLocaleBeanDaoConfig, this); + + registerDao(AlarmMessageLocaleBean.class, alarmMessageLocaleBeanDao); + } + + public void clear() { + alarmMessageLocaleBeanDaoConfig.clearIdentityScope(); + } + + public AlarmMessageLocaleBeanDao getAlarmMessageLocaleBeanDao() { + return alarmMessageLocaleBeanDao; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt new file mode 100644 index 0000000..875cb8c --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt @@ -0,0 +1,5 @@ +package com.casic.smart.town.sanxi.service + +import com.igexin.sdk.PushService + +class ApplicationPushService : PushService() \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt new file mode 100644 index 0000000..396129f --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt @@ -0,0 +1,84 @@ +package com.casic.smart.town.sanxi.service + +import android.content.Context +import android.os.Message +import android.util.Log +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.casic.smart.town.sanxi.view.MainActivity +import com.igexin.sdk.GTIntentService +import com.igexin.sdk.message.GTCmdMessage +import com.igexin.sdk.message.GTNotificationMessage +import com.igexin.sdk.message.GTTransmitMessage +import com.pengxh.kt.lite.extensions.toJson + +class PushIntentService : GTIntentService() { + + private val kTag = "SmartWellIntentService" + + override fun onReceiveServicePid(context: Context?, pid: Int) { + + } + + // 透传消息 + override fun onReceiveMessageData(context: Context?, msg: GTTransmitMessage?) { + Log.d(kTag, "透传消息 -> msg = $msg") + } + + // 接收 cid + override fun onReceiveClientId(context: Context?, clientid: String?) { + Log.d(kTag, "onReceiveClientId -> $clientid") + //通知MainActivity注册个推服务 + val msg: Message = MainActivity.weakReferenceHandler.obtainMessage() + msg.what = LocaleConstant.PUSH_REGISTER + msg.obj = clientid + MainActivity.weakReferenceHandler.sendMessage(msg) + } + + // cid 离线上线通知 + override fun onReceiveOnlineState(context: Context?, online: Boolean) { + + } + + // 各种事件处理回执 + override fun onReceiveCommandResult(context: Context?, msg: GTCmdMessage?) { + + } + + // 通知到达 + override fun onNotificationMessageArrived(context: Context?, msg: GTNotificationMessage?) { + //报警 +// { +// "content": "设备编号[412022030361]发生井盖开盖报警", +// "messageId": "380abf9a79d34306a2683dc9bf96ee78", +// "taskId": "OSL-0830_4hmfimp3Vu684wo3SjXso9", +// "title": "告警提醒", +// "appid": "HKv8K9qARd6WckZ1o2Vbu4", +// "clientId": "e78beacc42e9a02ae6fb9087eb2b1171", +// "pkgName": "com.casic.app.smartwell" +// } + if (msg == null) { + return + } + Log.d(kTag, "通知到达 -> msg = ${msg.toJson()}") +// val userDetailJson = SaveKeyValues.getValue(LocaleConstant.USER_DETAIL_MODEL, "") as String +// var userId = "" +// if (userDetailJson.isNotBlank()) { +// val userDataModel = Gson().fromJson( +// userDetailJson, object : TypeToken() {}.type +// ) +// userId = userDataModel.id.toString() +// } +// //解析编号 +// val splitArray = msg.content.split("\\[|\\]".toRegex()) +// DataBaseManager.instance.insertNotice( +// msg.messageId, msg.appid, msg.clientId, msg.taskId, +// userId, msg.title, msg.content, splitArray[1], "0", +// System.currentTimeMillis().timestampToCompleteDate() +// ) + } + + // 通知点击 + override fun onNotificationMessageClicked(context: Context?, msg: GTNotificationMessage?) { + Log.d(kTag, "通知点击 -> msg = $msg") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt new file mode 100644 index 0000000..daa7c38 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt @@ -0,0 +1,14 @@ +package com.casic.smart.town.sanxi.util + +import android.content.Context +import me.leolin.shortcutbadger.ShortcutBadger + +object BadeHelper { + fun setBadgeNum(context: Context, badgeCount: Int) { + if (badgeCount == 0) { + ShortcutBadger.removeCount(context) + } else { + ShortcutBadger.applyCount(context, badgeCount) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt new file mode 100644 index 0000000..0a52ef2 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt @@ -0,0 +1,75 @@ +package com.casic.smart.town.sanxi.util + +import com.casic.smart.town.sanxi.base.BaseApplication +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao + +class DataBaseManager private constructor() { + + companion object { + //Kotlin委托模式双重锁单例 + val instance: DataBaseManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) { + DataBaseManager() + } + } + + private val beanDao = + BaseApplication.obtainInstance().obtainDaoSession().alarmMessageLocaleBeanDao + +// fun insertNotice( +// messageId: String, appid: String, clientId: String, +// taskId: String, userId: String, title: String, +// content: String, deviceCode: String, isRead: String, +// noticeTime: String +// ) { +// val noticeLocaleBean = NoticeLocaleBean() +// noticeLocaleBean.messageId = messageId +// noticeLocaleBean.appid = appid +// noticeLocaleBean.clientId = clientId +// noticeLocaleBean.taskId = taskId +// noticeLocaleBean.userId = userId +// noticeLocaleBean.title = title +// noticeLocaleBean.content = content +// noticeLocaleBean.deviceCode = deviceCode +// noticeLocaleBean.isRead = isRead +// noticeLocaleBean.noticeTime = noticeTime +// beanDao.insert(noticeLocaleBean) +// //角标设置 +// BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadNotice()) +// } + + fun deleteByMessageId(messageId: String) { + val result = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).list() + beanDao.deleteInTx(result) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun updateNoticeByMessageId(messageId: String) { + val noticeLocaleBean = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).unique() ?: return + noticeLocaleBean.isRead = "1" + beanDao.update(noticeLocaleBean) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun queryMessageByPage(userId: String, offset: Int): MutableList { + return BaseApplication.obtainInstance().obtainDaoSession() + .queryBuilder(AlarmMessageLocaleBean::class.java) + .where(AlarmMessageLocaleBeanDao.Properties.UserId.eq(userId)) + .offset(offset * LocaleConstant.PAGE_LIMIT) + .orderDesc(AlarmMessageLocaleBeanDao.Properties.AlarmTime) + .limit(LocaleConstant.PAGE_LIMIT) + .list() + } + + private fun queryUnReadMessage(): Int { + return beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.IsRead.eq("0") + ).list().size + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt new file mode 100644 index 0000000..52926a8 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt @@ -0,0 +1,31 @@ +package com.casic.smart.town.sanxi.util; + +import android.app.Activity +import android.view.WindowManager +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object LoadingDialogHub { + private lateinit var loadingDialog: QMUITipDialog + + fun show(activity: Activity, message: String) { + loadingDialog = QMUITipDialog + .Builder(activity) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_LOADING) + .setTipWord(message) + .create() + if (!activity.isDestroyed) { + try { + loadingDialog.show() + } catch (e: WindowManager.BadTokenException) { + e.printStackTrace() + } + } + } + + + fun dismiss() { + if (loadingDialog.isShowing) { + loadingDialog.dismiss() + } + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt new file mode 100644 index 0000000..de61c9a --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.util + +import android.Manifest + +object LocaleConstant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.READ_PHONE_STATE, + Manifest.permission.ACCESS_COARSE_LOCATION, + Manifest.permission.READ_EXTERNAL_STORAGE + ) + + const val PERMISSIONS_CODE = 999 + const val PUSH_REGISTER = 2022100101 + const val PAGE_LIMIT = 20 +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt new file mode 100644 index 0000000..3bea1c9 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt @@ -0,0 +1,112 @@ +package com.casic.smart.town.sanxi.view + +import android.view.KeyEvent +import android.view.MenuItem +import androidx.fragment.app.Fragment +import androidx.viewpager.widget.ViewPager +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.adapter.ViewPagerAdapter +import com.casic.smart.town.sanxi.fragment.AlarmPageFragment +import com.casic.smart.town.sanxi.fragment.MonitorPageFragment +import com.casic.smart.town.sanxi.fragment.StatisticsPageFragment +import com.gyf.immersionbar.ImmersionBar +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.base.KotlinBaseActivity +import com.pengxh.kt.lite.extensions.convertColor +import com.pengxh.kt.lite.extensions.show +import com.pengxh.kt.lite.utils.ImmerseStatusBarUtil +import com.pengxh.kt.lite.utils.WeakReferenceHandler +import kotlinx.android.synthetic.main.activity_main.* + +class MainActivity : KotlinBaseActivity() { + + companion object { + lateinit var weakReferenceHandler: WeakReferenceHandler + } + + private val kTag = "MainActivity" + private var menuItem: MenuItem? = null + private var fragmentPages: ArrayList = ArrayList() + private var clickTime: Long = 0 + + init { + fragmentPages.add(StatisticsPageFragment()) + fragmentPages.add(MonitorPageFragment()) + fragmentPages.add(AlarmPageFragment()) + } + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + ImmersionBar.with(this).statusBarDarkFont(false).init() + ImmerseStatusBarUtil.setColor(this, R.color.mainThemeColor.convertColor(this)) + } + + override fun initData() { + //推送,多次调用 SDK 初始化并无影响。 + PushManager.getInstance().initialize(this) + weakReferenceHandler = WeakReferenceHandler { + + true + } + } + + override fun observeRequestState() { + + } + + override fun initEvent() { + bottomNavigation.itemIconTintList = null + bottomNavigation.setOnNavigationItemSelectedListener { menuItem -> + when (menuItem.itemId) { + R.id.nav_statistics -> { + mainViewPager.currentItem = 0 + } + R.id.nav_monitor -> { + mainViewPager.currentItem = 1 + } + R.id.nav_alarm -> { + mainViewPager.currentItem = 2 + } + } + false + } + mainViewPager.adapter = ViewPagerAdapter(fragmentPages, supportFragmentManager) + mainViewPager.offscreenPageLimit = fragmentPages.size //缓存页数 + mainViewPager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener { + override fun onPageScrollStateChanged(state: Int) { + + } + + override fun onPageScrolled( + position: Int, + positionOffset: Float, + positionOffsetPixels: Int + ) { + + } + + override fun onPageSelected(position: Int) { + if (menuItem != null) { + menuItem!!.isChecked = false + } else { + bottomNavigation.menu.getItem(0).isChecked = false + } + menuItem = bottomNavigation.menu.getItem(position) + menuItem!!.isChecked = true + } + }) + } + + override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean { + return if (keyCode == KeyEvent.KEYCODE_BACK) { + if (System.currentTimeMillis() - clickTime > 2000) { + "再按一次退出程序".show(this) + clickTime = System.currentTimeMillis() + true + } else { + super.onKeyDown(keyCode, event) + } + } else super.onKeyDown(keyCode, event) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt new file mode 100644 index 0000000..c5d8b22 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.view + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseActivity + +class MonitorRecordActivity : KotlinBaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_monitor_record + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt new file mode 100644 index 0000000..c478d83 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt @@ -0,0 +1,55 @@ +package com.casic.smart.town.sanxi.view + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.amap.api.maps.MapsInitializer +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.gyf.immersionbar.ImmersionBar +import com.pengxh.kt.lite.extensions.navigatePageTo +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + ImmersionBar.with(this).statusBarDarkFont(true).init() + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (EasyPermissions.hasPermissions(this, *LocaleConstant.USER_PERMISSIONS)) { + startSplashScreenActivity() + } else { + EasyPermissions.requestPermissions( + this@PermissionActivity, + resources.getString(R.string.app_name) + "需要获取相关权限", + LocaleConstant.PERMISSIONS_CODE, + *LocaleConstant.USER_PERMISSIONS + ) + } + } + + private fun startSplashScreenActivity() { + //先把导航隐私政策声明,后面导航会用到 + MapsInitializer.updatePrivacyAgree(this, true) + MapsInitializer.updatePrivacyShow(this, true, true) + this.navigatePageTo() + 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) { + startSplashScreenActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable/alarm_selector.xml b/app/src/main/res/drawable/alarm_selector.xml new file mode 100644 index 0000000..39b2595 --- /dev/null +++ b/app/src/main/res/drawable/alarm_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bottom_text_color.xml b/app/src/main/res/drawable/bottom_text_color.xml new file mode 100644 index 0000000..b284ea3 --- /dev/null +++ b/app/src/main/res/drawable/bottom_text_color.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_alarm.xml b/app/src/main/res/drawable/ic_alarm.xml new file mode 100644 index 0000000..dc33aab --- /dev/null +++ b/app/src/main/res/drawable/ic_alarm.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_alarm_selected.xml b/app/src/main/res/drawable/ic_alarm_selected.xml new file mode 100644 index 0000000..993fea6 --- /dev/null +++ b/app/src/main/res/drawable/ic_alarm_selected.xml @@ -0,0 +1,9 @@ + + + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..10cfdbf --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*.iml +.gradle +/local.properties +/.idea +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..a4cd2ca --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,101 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'org.greenrobot.greendao' + +android { +// signingConfigs { +// release { +// storeFile file('/Users/a203/Desktop/AndroidProjects/CasicSmartWell/app/CasicSmartWell.jks') +// storePassword '123456789' +// keyAlias 'key0' +// keyPassword '123456789' +// } +// } + compileSdkVersion 31 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.smart.town.sanxi" + minSdkVersion 23 + targetSdkVersion 31 + versionCode 1 + versionName "1.0.0" + + manifestPlaceholders = [GETUI_APPID: "A9V4DvwLcdAqkFCQuFyhq6"] + } + + buildTypes { + release { + minifyEnabled false +// signingConfig signingConfigs.release + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + + ndk { abiFilters "armeabi", "armeabi-v7a", "arm64-v8" } + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlin { + experimental { + coroutines 'enable' + } + } + + greendao { + schemaVersion 1//数据库版本号 + targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 + daoPackage 'com.casic.smart.town.sanxi.greendao'//设置DaoMaster、DaoSession、Dao包名 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + //基础依赖库 + implementation files('libs/lite-release.aar') + implementation 'androidx.appcompat:appcompat:1.4.2' + implementation 'androidx.core:core-ktx:1.8.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:3.0.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' + //MVVM+LiveData + implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.1" + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0" + implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + //Kotlin协程 + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1' + //图片加载框架 + implementation 'com.github.bumptech.glide:glide:4.9.0' + //返回值转换器 + implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' + implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + //okhttp3日志拦截器 + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //网络请求和接口封装 + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.9.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.9.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' + //高德地图 + implementation 'com.amap.api:3dmap:latest.integration' + //推送SDK + implementation 'com.getui:gtsdk:3.2.10.0' //个推SDK + implementation 'com.getui:gtc:3.1.9.0' //个推核心组件 + //数据库框架 + implementation 'org.greenrobot:greendao:3.3.0' + //桌面角标 + implementation "me.leolin:ShortcutBadger:1.1.22@aar" +} \ No newline at end of file diff --git a/app/libs/lite-release.aar b/app/libs/lite-release.aar new file mode 100644 index 0000000..45da4df --- /dev/null +++ b/app/libs/lite-release.aar Binary files differ diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /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 \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..a83c28a --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/svg/monitor.svg b/app/src/main/assets/svg/monitor.svg new file mode 100644 index 0000000..c8d3e25 --- /dev/null +++ b/app/src/main/assets/svg/monitor.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/msg.svg b/app/src/main/assets/svg/msg.svg new file mode 100644 index 0000000..e864e48 --- /dev/null +++ b/app/src/main/assets/svg/msg.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/statistics.svg b/app/src/main/assets/svg/statistics.svg new file mode 100644 index 0000000..974000e --- /dev/null +++ b/app/src/main/assets/svg/statistics.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt new file mode 100644 index 0000000..6b9cce0 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.adapter + +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentManager +import androidx.fragment.app.FragmentPagerAdapter + +class ViewPagerAdapter(list: ArrayList, manager: FragmentManager) : + FragmentPagerAdapter(manager) { + + private var pageList: List = list + + override fun getItem(position: Int) = pageList[position] + + override fun getCount() = pageList.size +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt new file mode 100644 index 0000000..4e017b1 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt @@ -0,0 +1,40 @@ +package com.casic.smart.town.sanxi.base + +import android.app.Application +import android.util.Log +import com.casic.smart.town.sanxi.greendao.DaoMaster +import com.casic.smart.town.sanxi.greendao.DaoSession +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + private val kTag = "BaseApplication" + + companion object { + private var instance: BaseApplication by Delegates.notNull() + + fun obtainInstance() = instance + + private lateinit var daoSession: DaoSession + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences(this) + //推送 + PushManager.getInstance().initialize(this) + PushManager.getInstance().setDebugLogger(this) { + Log.d(kTag, it) + } + val devOpenHelper = DaoMaster.DevOpenHelper(this, "SmartTown.db", null) + val daoMaster = DaoMaster(devOpenHelper.writableDatabase) + daoSession = daoMaster.newSession() + } + + fun obtainDaoSession(): DaoSession { + return daoSession + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java new file mode 100644 index 0000000..b8f67dc --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java @@ -0,0 +1,133 @@ +package com.casic.smart.town.sanxi.bean; + +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Generated; +import org.greenrobot.greendao.annotation.Id; +import org.greenrobot.greendao.annotation.Unique; + +@Entity +public class AlarmMessageLocaleBean { + @Id(autoincrement = true) + private Long id;//主键自增 + + @Unique + private String messageId; + private String appId; + private String clientId; + private String taskId; + private String userId; + private String title; + private String content; + private String deviceCode; + private String isRead;//0-未读,1-已读 + private String alarmTime; + + @Generated(hash = 566950134) + public AlarmMessageLocaleBean(Long id, String messageId, String appId, + String clientId, String taskId, String userId, String title, + String content, String deviceCode, String isRead, String alarmTime) { + this.id = id; + this.messageId = messageId; + this.appId = appId; + this.clientId = clientId; + this.taskId = taskId; + this.userId = userId; + this.title = title; + this.content = content; + this.deviceCode = deviceCode; + this.isRead = isRead; + this.alarmTime = alarmTime; + } + + @Generated(hash = 1737519562) + public AlarmMessageLocaleBean() { + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getMessageId() { + return this.messageId; + } + + public void setMessageId(String messageId) { + this.messageId = messageId; + } + + public String getAppId() { + return this.appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public String getClientId() { + return this.clientId; + } + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public String getTaskId() { + return this.taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getUserId() { + return this.userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getTitle() { + return this.title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return this.content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getDeviceCode() { + return this.deviceCode; + } + + public void setDeviceCode(String deviceCode) { + this.deviceCode = deviceCode; + } + + public String getIsRead() { + return this.isRead; + } + + public void setIsRead(String isRead) { + this.isRead = isRead; + } + + public String getAlarmTime() { + return this.alarmTime; + } + + public void setAlarmTime(String alarmTime) { + this.alarmTime = alarmTime; + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt new file mode 100644 index 0000000..650e201 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class AlarmPageFragment: KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_alarm + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt new file mode 100644 index 0000000..deac8ac --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt @@ -0,0 +1,76 @@ +package com.casic.smart.town.sanxi.fragment + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.Fragment +import com.amap.api.maps.AMap +import com.amap.api.maps.AMapOptions +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.view.MonitorRecordActivity +import com.pengxh.kt.lite.extensions.navigatePageTo +import com.pengxh.kt.lite.extensions.show +import kotlinx.android.synthetic.main.fragment_monitor.view.* + +class MonitorPageFragment : Fragment() { + + private val kTag = "HomePageFragment" + private lateinit var monitorView: View + private lateinit var aMap: AMap + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? + ): View { + monitorView = inflater.inflate(R.layout.fragment_monitor, container, false) + //地图初始化 + initMap(savedInstanceState) + + monitorView.rightOperateView.setOnClickListener { + requireContext().navigatePageTo() + } + return monitorView + } + + private fun initMap(savedInstanceState: Bundle?) { + monitorView.mapView.onCreate(savedInstanceState) + aMap = monitorView.mapView.map + aMap.mapType = AMap.MAP_TYPE_NORMAL + val uiSettings = aMap.uiSettings + uiSettings.isCompassEnabled = true + uiSettings.zoomPosition = AMapOptions.ZOOM_POSITION_RIGHT_CENTER + uiSettings.isTiltGesturesEnabled = false//不许地图随手势倾斜角度 + + // 地图加载成功监听 +// aMap.addOnMapLoadedListener(this) + // 地图缩放监听 +// aMap.addOnCameraChangeListener(this) + // marker 点击事件监听 +// aMap.addOnMarkerClickListener(this) + // 点击marker弹出自定义popup +// aMap.setInfoWindowAdapter(this) + //信息窗点击事件 +// aMap.addOnInfoWindowClickListener(this) + } + + /***以下是地图生命周期管理************************************************************************/ + override fun onResume() { + super.onResume() + monitorView.mapView.onResume() + } + + override fun onPause() { + super.onPause() + monitorView.mapView.onPause() + } + + override fun onSaveInstanceState(outState: Bundle) { + super.onSaveInstanceState(outState) + monitorView.mapView.onSaveInstanceState(outState) + } + + override fun onDestroy() { + super.onDestroy() + monitorView.mapView.onDestroy() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt new file mode 100644 index 0000000..e84df12 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class StatisticsPageFragment : KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_statistics + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java new file mode 100644 index 0000000..68d7901 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java @@ -0,0 +1,255 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.database.Cursor; +import android.database.sqlite.SQLiteStatement; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.Property; +import org.greenrobot.greendao.internal.DaoConfig; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseStatement; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * DAO for table "ALARM_MESSAGE_LOCALE_BEAN". +*/ +public class AlarmMessageLocaleBeanDao extends AbstractDao { + + public static final String TABLENAME = "ALARM_MESSAGE_LOCALE_BEAN"; + + /** + * Properties of entity AlarmMessageLocaleBean.
+ * Can be used for QueryBuilder and for referencing column names. + */ + public static class Properties { + public final static Property Id = new Property(0, Long.class, "id", true, "_id"); + public final static Property MessageId = new Property(1, String.class, "messageId", false, "MESSAGE_ID"); + public final static Property AppId = new Property(2, String.class, "appId", false, "APP_ID"); + public final static Property ClientId = new Property(3, String.class, "clientId", false, "CLIENT_ID"); + public final static Property TaskId = new Property(4, String.class, "taskId", false, "TASK_ID"); + public final static Property UserId = new Property(5, String.class, "userId", false, "USER_ID"); + public final static Property Title = new Property(6, String.class, "title", false, "TITLE"); + public final static Property Content = new Property(7, String.class, "content", false, "CONTENT"); + public final static Property DeviceCode = new Property(8, String.class, "deviceCode", false, "DEVICE_CODE"); + public final static Property IsRead = new Property(9, String.class, "isRead", false, "IS_READ"); + public final static Property AlarmTime = new Property(10, String.class, "alarmTime", false, "ALARM_TIME"); + } + + + public AlarmMessageLocaleBeanDao(DaoConfig config) { + super(config); + } + + public AlarmMessageLocaleBeanDao(DaoConfig config, DaoSession daoSession) { + super(config, daoSession); + } + + /** Creates the underlying database table. */ + public static void createTable(Database db, boolean ifNotExists) { + String constraint = ifNotExists? "IF NOT EXISTS ": ""; + db.execSQL("CREATE TABLE " + constraint + "\"ALARM_MESSAGE_LOCALE_BEAN\" (" + // + "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id + "\"MESSAGE_ID\" TEXT UNIQUE ," + // 1: messageId + "\"APP_ID\" TEXT," + // 2: appId + "\"CLIENT_ID\" TEXT," + // 3: clientId + "\"TASK_ID\" TEXT," + // 4: taskId + "\"USER_ID\" TEXT," + // 5: userId + "\"TITLE\" TEXT," + // 6: title + "\"CONTENT\" TEXT," + // 7: content + "\"DEVICE_CODE\" TEXT," + // 8: deviceCode + "\"IS_READ\" TEXT," + // 9: isRead + "\"ALARM_TIME\" TEXT);"); // 10: alarmTime + } + + /** Drops the underlying database table. */ + public static void dropTable(Database db, boolean ifExists) { + String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"ALARM_MESSAGE_LOCALE_BEAN\""; + db.execSQL(sql); + } + + @Override + protected final void bindValues(DatabaseStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + protected final void bindValues(SQLiteStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + public Long readKey(Cursor cursor, int offset) { + return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); + } + + @Override + public AlarmMessageLocaleBean readEntity(Cursor cursor, int offset) { + AlarmMessageLocaleBean entity = new AlarmMessageLocaleBean( // + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // messageId + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // appId + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // clientId + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // taskId + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // userId + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // title + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // content + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // deviceCode + cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // isRead + cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10) // alarmTime + ); + return entity; + } + + @Override + public void readEntity(Cursor cursor, AlarmMessageLocaleBean entity, int offset) { + entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); + entity.setMessageId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setAppId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setClientId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setTaskId(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); + entity.setUserId(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setTitle(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setContent(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); + entity.setDeviceCode(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); + entity.setIsRead(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9)); + entity.setAlarmTime(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); + } + + @Override + protected final Long updateKeyAfterInsert(AlarmMessageLocaleBean entity, long rowId) { + entity.setId(rowId); + return rowId; + } + + @Override + public Long getKey(AlarmMessageLocaleBean entity) { + if(entity != null) { + return entity.getId(); + } else { + return null; + } + } + + @Override + public boolean hasKey(AlarmMessageLocaleBean entity) { + return entity.getId() != null; + } + + @Override + protected final boolean isEntityUpdateable() { + return true; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java new file mode 100644 index 0000000..4222c40 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java @@ -0,0 +1,96 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.content.Context; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteDatabase.CursorFactory; +import android.util.Log; + +import org.greenrobot.greendao.AbstractDaoMaster; +import org.greenrobot.greendao.database.StandardDatabase; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseOpenHelper; +import org.greenrobot.greendao.identityscope.IdentityScopeType; + + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * Master of DAO (schema version 1): knows all DAOs. + */ +public class DaoMaster extends AbstractDaoMaster { + public static final int SCHEMA_VERSION = 1; + + /** Creates underlying database table using DAOs. */ + public static void createAllTables(Database db, boolean ifNotExists) { + AlarmMessageLocaleBeanDao.createTable(db, ifNotExists); + } + + /** Drops underlying database table using DAOs. */ + public static void dropAllTables(Database db, boolean ifExists) { + AlarmMessageLocaleBeanDao.dropTable(db, ifExists); + } + + /** + * WARNING: Drops all table on Upgrade! Use only during development. + * Convenience method using a {@link DevOpenHelper}. + */ + public static DaoSession newDevSession(Context context, String name) { + Database db = new DevOpenHelper(context, name).getWritableDb(); + DaoMaster daoMaster = new DaoMaster(db); + return daoMaster.newSession(); + } + + public DaoMaster(SQLiteDatabase db) { + this(new StandardDatabase(db)); + } + + public DaoMaster(Database db) { + super(db, SCHEMA_VERSION); + registerDaoClass(AlarmMessageLocaleBeanDao.class); + } + + public DaoSession newSession() { + return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); + } + + public DaoSession newSession(IdentityScopeType type) { + return new DaoSession(db, type, daoConfigMap); + } + + /** + * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} - + */ + public static abstract class OpenHelper extends DatabaseOpenHelper { + public OpenHelper(Context context, String name) { + super(context, name, SCHEMA_VERSION); + } + + public OpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory, SCHEMA_VERSION); + } + + @Override + public void onCreate(Database db) { + Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); + createAllTables(db, false); + } + } + + /** WARNING: Drops all table on Upgrade! Use only during development. */ + public static class DevOpenHelper extends OpenHelper { + public DevOpenHelper(Context context, String name) { + super(context, name); + } + + public DevOpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory); + } + + @Override + public void onUpgrade(Database db, int oldVersion, int newVersion) { + Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); + dropAllTables(db, true); + onCreate(db); + } + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java new file mode 100644 index 0000000..480ed84 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java @@ -0,0 +1,48 @@ +package com.casic.smart.town.sanxi.greendao; + +import java.util.Map; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.AbstractDaoSession; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.identityscope.IdentityScopeType; +import org.greenrobot.greendao.internal.DaoConfig; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. + +/** + * {@inheritDoc} + * + * @see org.greenrobot.greendao.AbstractDaoSession + */ +public class DaoSession extends AbstractDaoSession { + + private final DaoConfig alarmMessageLocaleBeanDaoConfig; + + private final AlarmMessageLocaleBeanDao alarmMessageLocaleBeanDao; + + public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> + daoConfigMap) { + super(db); + + alarmMessageLocaleBeanDaoConfig = daoConfigMap.get(AlarmMessageLocaleBeanDao.class).clone(); + alarmMessageLocaleBeanDaoConfig.initIdentityScope(type); + + alarmMessageLocaleBeanDao = new AlarmMessageLocaleBeanDao(alarmMessageLocaleBeanDaoConfig, this); + + registerDao(AlarmMessageLocaleBean.class, alarmMessageLocaleBeanDao); + } + + public void clear() { + alarmMessageLocaleBeanDaoConfig.clearIdentityScope(); + } + + public AlarmMessageLocaleBeanDao getAlarmMessageLocaleBeanDao() { + return alarmMessageLocaleBeanDao; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt new file mode 100644 index 0000000..875cb8c --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt @@ -0,0 +1,5 @@ +package com.casic.smart.town.sanxi.service + +import com.igexin.sdk.PushService + +class ApplicationPushService : PushService() \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt new file mode 100644 index 0000000..396129f --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt @@ -0,0 +1,84 @@ +package com.casic.smart.town.sanxi.service + +import android.content.Context +import android.os.Message +import android.util.Log +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.casic.smart.town.sanxi.view.MainActivity +import com.igexin.sdk.GTIntentService +import com.igexin.sdk.message.GTCmdMessage +import com.igexin.sdk.message.GTNotificationMessage +import com.igexin.sdk.message.GTTransmitMessage +import com.pengxh.kt.lite.extensions.toJson + +class PushIntentService : GTIntentService() { + + private val kTag = "SmartWellIntentService" + + override fun onReceiveServicePid(context: Context?, pid: Int) { + + } + + // 透传消息 + override fun onReceiveMessageData(context: Context?, msg: GTTransmitMessage?) { + Log.d(kTag, "透传消息 -> msg = $msg") + } + + // 接收 cid + override fun onReceiveClientId(context: Context?, clientid: String?) { + Log.d(kTag, "onReceiveClientId -> $clientid") + //通知MainActivity注册个推服务 + val msg: Message = MainActivity.weakReferenceHandler.obtainMessage() + msg.what = LocaleConstant.PUSH_REGISTER + msg.obj = clientid + MainActivity.weakReferenceHandler.sendMessage(msg) + } + + // cid 离线上线通知 + override fun onReceiveOnlineState(context: Context?, online: Boolean) { + + } + + // 各种事件处理回执 + override fun onReceiveCommandResult(context: Context?, msg: GTCmdMessage?) { + + } + + // 通知到达 + override fun onNotificationMessageArrived(context: Context?, msg: GTNotificationMessage?) { + //报警 +// { +// "content": "设备编号[412022030361]发生井盖开盖报警", +// "messageId": "380abf9a79d34306a2683dc9bf96ee78", +// "taskId": "OSL-0830_4hmfimp3Vu684wo3SjXso9", +// "title": "告警提醒", +// "appid": "HKv8K9qARd6WckZ1o2Vbu4", +// "clientId": "e78beacc42e9a02ae6fb9087eb2b1171", +// "pkgName": "com.casic.app.smartwell" +// } + if (msg == null) { + return + } + Log.d(kTag, "通知到达 -> msg = ${msg.toJson()}") +// val userDetailJson = SaveKeyValues.getValue(LocaleConstant.USER_DETAIL_MODEL, "") as String +// var userId = "" +// if (userDetailJson.isNotBlank()) { +// val userDataModel = Gson().fromJson( +// userDetailJson, object : TypeToken() {}.type +// ) +// userId = userDataModel.id.toString() +// } +// //解析编号 +// val splitArray = msg.content.split("\\[|\\]".toRegex()) +// DataBaseManager.instance.insertNotice( +// msg.messageId, msg.appid, msg.clientId, msg.taskId, +// userId, msg.title, msg.content, splitArray[1], "0", +// System.currentTimeMillis().timestampToCompleteDate() +// ) + } + + // 通知点击 + override fun onNotificationMessageClicked(context: Context?, msg: GTNotificationMessage?) { + Log.d(kTag, "通知点击 -> msg = $msg") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt new file mode 100644 index 0000000..daa7c38 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt @@ -0,0 +1,14 @@ +package com.casic.smart.town.sanxi.util + +import android.content.Context +import me.leolin.shortcutbadger.ShortcutBadger + +object BadeHelper { + fun setBadgeNum(context: Context, badgeCount: Int) { + if (badgeCount == 0) { + ShortcutBadger.removeCount(context) + } else { + ShortcutBadger.applyCount(context, badgeCount) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt new file mode 100644 index 0000000..0a52ef2 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt @@ -0,0 +1,75 @@ +package com.casic.smart.town.sanxi.util + +import com.casic.smart.town.sanxi.base.BaseApplication +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao + +class DataBaseManager private constructor() { + + companion object { + //Kotlin委托模式双重锁单例 + val instance: DataBaseManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) { + DataBaseManager() + } + } + + private val beanDao = + BaseApplication.obtainInstance().obtainDaoSession().alarmMessageLocaleBeanDao + +// fun insertNotice( +// messageId: String, appid: String, clientId: String, +// taskId: String, userId: String, title: String, +// content: String, deviceCode: String, isRead: String, +// noticeTime: String +// ) { +// val noticeLocaleBean = NoticeLocaleBean() +// noticeLocaleBean.messageId = messageId +// noticeLocaleBean.appid = appid +// noticeLocaleBean.clientId = clientId +// noticeLocaleBean.taskId = taskId +// noticeLocaleBean.userId = userId +// noticeLocaleBean.title = title +// noticeLocaleBean.content = content +// noticeLocaleBean.deviceCode = deviceCode +// noticeLocaleBean.isRead = isRead +// noticeLocaleBean.noticeTime = noticeTime +// beanDao.insert(noticeLocaleBean) +// //角标设置 +// BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadNotice()) +// } + + fun deleteByMessageId(messageId: String) { + val result = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).list() + beanDao.deleteInTx(result) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun updateNoticeByMessageId(messageId: String) { + val noticeLocaleBean = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).unique() ?: return + noticeLocaleBean.isRead = "1" + beanDao.update(noticeLocaleBean) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun queryMessageByPage(userId: String, offset: Int): MutableList { + return BaseApplication.obtainInstance().obtainDaoSession() + .queryBuilder(AlarmMessageLocaleBean::class.java) + .where(AlarmMessageLocaleBeanDao.Properties.UserId.eq(userId)) + .offset(offset * LocaleConstant.PAGE_LIMIT) + .orderDesc(AlarmMessageLocaleBeanDao.Properties.AlarmTime) + .limit(LocaleConstant.PAGE_LIMIT) + .list() + } + + private fun queryUnReadMessage(): Int { + return beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.IsRead.eq("0") + ).list().size + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt new file mode 100644 index 0000000..52926a8 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt @@ -0,0 +1,31 @@ +package com.casic.smart.town.sanxi.util; + +import android.app.Activity +import android.view.WindowManager +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object LoadingDialogHub { + private lateinit var loadingDialog: QMUITipDialog + + fun show(activity: Activity, message: String) { + loadingDialog = QMUITipDialog + .Builder(activity) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_LOADING) + .setTipWord(message) + .create() + if (!activity.isDestroyed) { + try { + loadingDialog.show() + } catch (e: WindowManager.BadTokenException) { + e.printStackTrace() + } + } + } + + + fun dismiss() { + if (loadingDialog.isShowing) { + loadingDialog.dismiss() + } + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt new file mode 100644 index 0000000..de61c9a --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.util + +import android.Manifest + +object LocaleConstant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.READ_PHONE_STATE, + Manifest.permission.ACCESS_COARSE_LOCATION, + Manifest.permission.READ_EXTERNAL_STORAGE + ) + + const val PERMISSIONS_CODE = 999 + const val PUSH_REGISTER = 2022100101 + const val PAGE_LIMIT = 20 +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt new file mode 100644 index 0000000..3bea1c9 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt @@ -0,0 +1,112 @@ +package com.casic.smart.town.sanxi.view + +import android.view.KeyEvent +import android.view.MenuItem +import androidx.fragment.app.Fragment +import androidx.viewpager.widget.ViewPager +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.adapter.ViewPagerAdapter +import com.casic.smart.town.sanxi.fragment.AlarmPageFragment +import com.casic.smart.town.sanxi.fragment.MonitorPageFragment +import com.casic.smart.town.sanxi.fragment.StatisticsPageFragment +import com.gyf.immersionbar.ImmersionBar +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.base.KotlinBaseActivity +import com.pengxh.kt.lite.extensions.convertColor +import com.pengxh.kt.lite.extensions.show +import com.pengxh.kt.lite.utils.ImmerseStatusBarUtil +import com.pengxh.kt.lite.utils.WeakReferenceHandler +import kotlinx.android.synthetic.main.activity_main.* + +class MainActivity : KotlinBaseActivity() { + + companion object { + lateinit var weakReferenceHandler: WeakReferenceHandler + } + + private val kTag = "MainActivity" + private var menuItem: MenuItem? = null + private var fragmentPages: ArrayList = ArrayList() + private var clickTime: Long = 0 + + init { + fragmentPages.add(StatisticsPageFragment()) + fragmentPages.add(MonitorPageFragment()) + fragmentPages.add(AlarmPageFragment()) + } + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + ImmersionBar.with(this).statusBarDarkFont(false).init() + ImmerseStatusBarUtil.setColor(this, R.color.mainThemeColor.convertColor(this)) + } + + override fun initData() { + //推送,多次调用 SDK 初始化并无影响。 + PushManager.getInstance().initialize(this) + weakReferenceHandler = WeakReferenceHandler { + + true + } + } + + override fun observeRequestState() { + + } + + override fun initEvent() { + bottomNavigation.itemIconTintList = null + bottomNavigation.setOnNavigationItemSelectedListener { menuItem -> + when (menuItem.itemId) { + R.id.nav_statistics -> { + mainViewPager.currentItem = 0 + } + R.id.nav_monitor -> { + mainViewPager.currentItem = 1 + } + R.id.nav_alarm -> { + mainViewPager.currentItem = 2 + } + } + false + } + mainViewPager.adapter = ViewPagerAdapter(fragmentPages, supportFragmentManager) + mainViewPager.offscreenPageLimit = fragmentPages.size //缓存页数 + mainViewPager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener { + override fun onPageScrollStateChanged(state: Int) { + + } + + override fun onPageScrolled( + position: Int, + positionOffset: Float, + positionOffsetPixels: Int + ) { + + } + + override fun onPageSelected(position: Int) { + if (menuItem != null) { + menuItem!!.isChecked = false + } else { + bottomNavigation.menu.getItem(0).isChecked = false + } + menuItem = bottomNavigation.menu.getItem(position) + menuItem!!.isChecked = true + } + }) + } + + override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean { + return if (keyCode == KeyEvent.KEYCODE_BACK) { + if (System.currentTimeMillis() - clickTime > 2000) { + "再按一次退出程序".show(this) + clickTime = System.currentTimeMillis() + true + } else { + super.onKeyDown(keyCode, event) + } + } else super.onKeyDown(keyCode, event) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt new file mode 100644 index 0000000..c5d8b22 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.view + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseActivity + +class MonitorRecordActivity : KotlinBaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_monitor_record + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt new file mode 100644 index 0000000..c478d83 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt @@ -0,0 +1,55 @@ +package com.casic.smart.town.sanxi.view + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.amap.api.maps.MapsInitializer +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.gyf.immersionbar.ImmersionBar +import com.pengxh.kt.lite.extensions.navigatePageTo +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + ImmersionBar.with(this).statusBarDarkFont(true).init() + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (EasyPermissions.hasPermissions(this, *LocaleConstant.USER_PERMISSIONS)) { + startSplashScreenActivity() + } else { + EasyPermissions.requestPermissions( + this@PermissionActivity, + resources.getString(R.string.app_name) + "需要获取相关权限", + LocaleConstant.PERMISSIONS_CODE, + *LocaleConstant.USER_PERMISSIONS + ) + } + } + + private fun startSplashScreenActivity() { + //先把导航隐私政策声明,后面导航会用到 + MapsInitializer.updatePrivacyAgree(this, true) + MapsInitializer.updatePrivacyShow(this, true, true) + this.navigatePageTo() + 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) { + startSplashScreenActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable/alarm_selector.xml b/app/src/main/res/drawable/alarm_selector.xml new file mode 100644 index 0000000..39b2595 --- /dev/null +++ b/app/src/main/res/drawable/alarm_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bottom_text_color.xml b/app/src/main/res/drawable/bottom_text_color.xml new file mode 100644 index 0000000..b284ea3 --- /dev/null +++ b/app/src/main/res/drawable/bottom_text_color.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_alarm.xml b/app/src/main/res/drawable/ic_alarm.xml new file mode 100644 index 0000000..dc33aab --- /dev/null +++ b/app/src/main/res/drawable/ic_alarm.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_alarm_selected.xml b/app/src/main/res/drawable/ic_alarm_selected.xml new file mode 100644 index 0000000..993fea6 --- /dev/null +++ b/app/src/main/res/drawable/ic_alarm_selected.xml @@ -0,0 +1,9 @@ + + + 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..10cfdbf --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*.iml +.gradle +/local.properties +/.idea +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..a4cd2ca --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,101 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'org.greenrobot.greendao' + +android { +// signingConfigs { +// release { +// storeFile file('/Users/a203/Desktop/AndroidProjects/CasicSmartWell/app/CasicSmartWell.jks') +// storePassword '123456789' +// keyAlias 'key0' +// keyPassword '123456789' +// } +// } + compileSdkVersion 31 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.smart.town.sanxi" + minSdkVersion 23 + targetSdkVersion 31 + versionCode 1 + versionName "1.0.0" + + manifestPlaceholders = [GETUI_APPID: "A9V4DvwLcdAqkFCQuFyhq6"] + } + + buildTypes { + release { + minifyEnabled false +// signingConfig signingConfigs.release + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + + ndk { abiFilters "armeabi", "armeabi-v7a", "arm64-v8" } + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlin { + experimental { + coroutines 'enable' + } + } + + greendao { + schemaVersion 1//数据库版本号 + targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 + daoPackage 'com.casic.smart.town.sanxi.greendao'//设置DaoMaster、DaoSession、Dao包名 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + //基础依赖库 + implementation files('libs/lite-release.aar') + implementation 'androidx.appcompat:appcompat:1.4.2' + implementation 'androidx.core:core-ktx:1.8.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:3.0.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' + //MVVM+LiveData + implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.1" + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0" + implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + //Kotlin协程 + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1' + //图片加载框架 + implementation 'com.github.bumptech.glide:glide:4.9.0' + //返回值转换器 + implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' + implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + //okhttp3日志拦截器 + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //网络请求和接口封装 + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.9.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.9.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' + //高德地图 + implementation 'com.amap.api:3dmap:latest.integration' + //推送SDK + implementation 'com.getui:gtsdk:3.2.10.0' //个推SDK + implementation 'com.getui:gtc:3.1.9.0' //个推核心组件 + //数据库框架 + implementation 'org.greenrobot:greendao:3.3.0' + //桌面角标 + implementation "me.leolin:ShortcutBadger:1.1.22@aar" +} \ No newline at end of file diff --git a/app/libs/lite-release.aar b/app/libs/lite-release.aar new file mode 100644 index 0000000..45da4df --- /dev/null +++ b/app/libs/lite-release.aar Binary files differ diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /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 \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..a83c28a --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/svg/monitor.svg b/app/src/main/assets/svg/monitor.svg new file mode 100644 index 0000000..c8d3e25 --- /dev/null +++ b/app/src/main/assets/svg/monitor.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/msg.svg b/app/src/main/assets/svg/msg.svg new file mode 100644 index 0000000..e864e48 --- /dev/null +++ b/app/src/main/assets/svg/msg.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/statistics.svg b/app/src/main/assets/svg/statistics.svg new file mode 100644 index 0000000..974000e --- /dev/null +++ b/app/src/main/assets/svg/statistics.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt new file mode 100644 index 0000000..6b9cce0 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.adapter + +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentManager +import androidx.fragment.app.FragmentPagerAdapter + +class ViewPagerAdapter(list: ArrayList, manager: FragmentManager) : + FragmentPagerAdapter(manager) { + + private var pageList: List = list + + override fun getItem(position: Int) = pageList[position] + + override fun getCount() = pageList.size +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt new file mode 100644 index 0000000..4e017b1 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt @@ -0,0 +1,40 @@ +package com.casic.smart.town.sanxi.base + +import android.app.Application +import android.util.Log +import com.casic.smart.town.sanxi.greendao.DaoMaster +import com.casic.smart.town.sanxi.greendao.DaoSession +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + private val kTag = "BaseApplication" + + companion object { + private var instance: BaseApplication by Delegates.notNull() + + fun obtainInstance() = instance + + private lateinit var daoSession: DaoSession + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences(this) + //推送 + PushManager.getInstance().initialize(this) + PushManager.getInstance().setDebugLogger(this) { + Log.d(kTag, it) + } + val devOpenHelper = DaoMaster.DevOpenHelper(this, "SmartTown.db", null) + val daoMaster = DaoMaster(devOpenHelper.writableDatabase) + daoSession = daoMaster.newSession() + } + + fun obtainDaoSession(): DaoSession { + return daoSession + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java new file mode 100644 index 0000000..b8f67dc --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java @@ -0,0 +1,133 @@ +package com.casic.smart.town.sanxi.bean; + +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Generated; +import org.greenrobot.greendao.annotation.Id; +import org.greenrobot.greendao.annotation.Unique; + +@Entity +public class AlarmMessageLocaleBean { + @Id(autoincrement = true) + private Long id;//主键自增 + + @Unique + private String messageId; + private String appId; + private String clientId; + private String taskId; + private String userId; + private String title; + private String content; + private String deviceCode; + private String isRead;//0-未读,1-已读 + private String alarmTime; + + @Generated(hash = 566950134) + public AlarmMessageLocaleBean(Long id, String messageId, String appId, + String clientId, String taskId, String userId, String title, + String content, String deviceCode, String isRead, String alarmTime) { + this.id = id; + this.messageId = messageId; + this.appId = appId; + this.clientId = clientId; + this.taskId = taskId; + this.userId = userId; + this.title = title; + this.content = content; + this.deviceCode = deviceCode; + this.isRead = isRead; + this.alarmTime = alarmTime; + } + + @Generated(hash = 1737519562) + public AlarmMessageLocaleBean() { + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getMessageId() { + return this.messageId; + } + + public void setMessageId(String messageId) { + this.messageId = messageId; + } + + public String getAppId() { + return this.appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public String getClientId() { + return this.clientId; + } + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public String getTaskId() { + return this.taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getUserId() { + return this.userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getTitle() { + return this.title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return this.content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getDeviceCode() { + return this.deviceCode; + } + + public void setDeviceCode(String deviceCode) { + this.deviceCode = deviceCode; + } + + public String getIsRead() { + return this.isRead; + } + + public void setIsRead(String isRead) { + this.isRead = isRead; + } + + public String getAlarmTime() { + return this.alarmTime; + } + + public void setAlarmTime(String alarmTime) { + this.alarmTime = alarmTime; + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt new file mode 100644 index 0000000..650e201 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class AlarmPageFragment: KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_alarm + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt new file mode 100644 index 0000000..deac8ac --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt @@ -0,0 +1,76 @@ +package com.casic.smart.town.sanxi.fragment + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.Fragment +import com.amap.api.maps.AMap +import com.amap.api.maps.AMapOptions +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.view.MonitorRecordActivity +import com.pengxh.kt.lite.extensions.navigatePageTo +import com.pengxh.kt.lite.extensions.show +import kotlinx.android.synthetic.main.fragment_monitor.view.* + +class MonitorPageFragment : Fragment() { + + private val kTag = "HomePageFragment" + private lateinit var monitorView: View + private lateinit var aMap: AMap + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? + ): View { + monitorView = inflater.inflate(R.layout.fragment_monitor, container, false) + //地图初始化 + initMap(savedInstanceState) + + monitorView.rightOperateView.setOnClickListener { + requireContext().navigatePageTo() + } + return monitorView + } + + private fun initMap(savedInstanceState: Bundle?) { + monitorView.mapView.onCreate(savedInstanceState) + aMap = monitorView.mapView.map + aMap.mapType = AMap.MAP_TYPE_NORMAL + val uiSettings = aMap.uiSettings + uiSettings.isCompassEnabled = true + uiSettings.zoomPosition = AMapOptions.ZOOM_POSITION_RIGHT_CENTER + uiSettings.isTiltGesturesEnabled = false//不许地图随手势倾斜角度 + + // 地图加载成功监听 +// aMap.addOnMapLoadedListener(this) + // 地图缩放监听 +// aMap.addOnCameraChangeListener(this) + // marker 点击事件监听 +// aMap.addOnMarkerClickListener(this) + // 点击marker弹出自定义popup +// aMap.setInfoWindowAdapter(this) + //信息窗点击事件 +// aMap.addOnInfoWindowClickListener(this) + } + + /***以下是地图生命周期管理************************************************************************/ + override fun onResume() { + super.onResume() + monitorView.mapView.onResume() + } + + override fun onPause() { + super.onPause() + monitorView.mapView.onPause() + } + + override fun onSaveInstanceState(outState: Bundle) { + super.onSaveInstanceState(outState) + monitorView.mapView.onSaveInstanceState(outState) + } + + override fun onDestroy() { + super.onDestroy() + monitorView.mapView.onDestroy() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt new file mode 100644 index 0000000..e84df12 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class StatisticsPageFragment : KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_statistics + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java new file mode 100644 index 0000000..68d7901 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java @@ -0,0 +1,255 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.database.Cursor; +import android.database.sqlite.SQLiteStatement; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.Property; +import org.greenrobot.greendao.internal.DaoConfig; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseStatement; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * DAO for table "ALARM_MESSAGE_LOCALE_BEAN". +*/ +public class AlarmMessageLocaleBeanDao extends AbstractDao { + + public static final String TABLENAME = "ALARM_MESSAGE_LOCALE_BEAN"; + + /** + * Properties of entity AlarmMessageLocaleBean.
+ * Can be used for QueryBuilder and for referencing column names. + */ + public static class Properties { + public final static Property Id = new Property(0, Long.class, "id", true, "_id"); + public final static Property MessageId = new Property(1, String.class, "messageId", false, "MESSAGE_ID"); + public final static Property AppId = new Property(2, String.class, "appId", false, "APP_ID"); + public final static Property ClientId = new Property(3, String.class, "clientId", false, "CLIENT_ID"); + public final static Property TaskId = new Property(4, String.class, "taskId", false, "TASK_ID"); + public final static Property UserId = new Property(5, String.class, "userId", false, "USER_ID"); + public final static Property Title = new Property(6, String.class, "title", false, "TITLE"); + public final static Property Content = new Property(7, String.class, "content", false, "CONTENT"); + public final static Property DeviceCode = new Property(8, String.class, "deviceCode", false, "DEVICE_CODE"); + public final static Property IsRead = new Property(9, String.class, "isRead", false, "IS_READ"); + public final static Property AlarmTime = new Property(10, String.class, "alarmTime", false, "ALARM_TIME"); + } + + + public AlarmMessageLocaleBeanDao(DaoConfig config) { + super(config); + } + + public AlarmMessageLocaleBeanDao(DaoConfig config, DaoSession daoSession) { + super(config, daoSession); + } + + /** Creates the underlying database table. */ + public static void createTable(Database db, boolean ifNotExists) { + String constraint = ifNotExists? "IF NOT EXISTS ": ""; + db.execSQL("CREATE TABLE " + constraint + "\"ALARM_MESSAGE_LOCALE_BEAN\" (" + // + "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id + "\"MESSAGE_ID\" TEXT UNIQUE ," + // 1: messageId + "\"APP_ID\" TEXT," + // 2: appId + "\"CLIENT_ID\" TEXT," + // 3: clientId + "\"TASK_ID\" TEXT," + // 4: taskId + "\"USER_ID\" TEXT," + // 5: userId + "\"TITLE\" TEXT," + // 6: title + "\"CONTENT\" TEXT," + // 7: content + "\"DEVICE_CODE\" TEXT," + // 8: deviceCode + "\"IS_READ\" TEXT," + // 9: isRead + "\"ALARM_TIME\" TEXT);"); // 10: alarmTime + } + + /** Drops the underlying database table. */ + public static void dropTable(Database db, boolean ifExists) { + String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"ALARM_MESSAGE_LOCALE_BEAN\""; + db.execSQL(sql); + } + + @Override + protected final void bindValues(DatabaseStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + protected final void bindValues(SQLiteStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + public Long readKey(Cursor cursor, int offset) { + return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); + } + + @Override + public AlarmMessageLocaleBean readEntity(Cursor cursor, int offset) { + AlarmMessageLocaleBean entity = new AlarmMessageLocaleBean( // + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // messageId + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // appId + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // clientId + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // taskId + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // userId + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // title + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // content + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // deviceCode + cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // isRead + cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10) // alarmTime + ); + return entity; + } + + @Override + public void readEntity(Cursor cursor, AlarmMessageLocaleBean entity, int offset) { + entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); + entity.setMessageId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setAppId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setClientId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setTaskId(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); + entity.setUserId(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setTitle(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setContent(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); + entity.setDeviceCode(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); + entity.setIsRead(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9)); + entity.setAlarmTime(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); + } + + @Override + protected final Long updateKeyAfterInsert(AlarmMessageLocaleBean entity, long rowId) { + entity.setId(rowId); + return rowId; + } + + @Override + public Long getKey(AlarmMessageLocaleBean entity) { + if(entity != null) { + return entity.getId(); + } else { + return null; + } + } + + @Override + public boolean hasKey(AlarmMessageLocaleBean entity) { + return entity.getId() != null; + } + + @Override + protected final boolean isEntityUpdateable() { + return true; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java new file mode 100644 index 0000000..4222c40 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java @@ -0,0 +1,96 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.content.Context; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteDatabase.CursorFactory; +import android.util.Log; + +import org.greenrobot.greendao.AbstractDaoMaster; +import org.greenrobot.greendao.database.StandardDatabase; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseOpenHelper; +import org.greenrobot.greendao.identityscope.IdentityScopeType; + + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * Master of DAO (schema version 1): knows all DAOs. + */ +public class DaoMaster extends AbstractDaoMaster { + public static final int SCHEMA_VERSION = 1; + + /** Creates underlying database table using DAOs. */ + public static void createAllTables(Database db, boolean ifNotExists) { + AlarmMessageLocaleBeanDao.createTable(db, ifNotExists); + } + + /** Drops underlying database table using DAOs. */ + public static void dropAllTables(Database db, boolean ifExists) { + AlarmMessageLocaleBeanDao.dropTable(db, ifExists); + } + + /** + * WARNING: Drops all table on Upgrade! Use only during development. + * Convenience method using a {@link DevOpenHelper}. + */ + public static DaoSession newDevSession(Context context, String name) { + Database db = new DevOpenHelper(context, name).getWritableDb(); + DaoMaster daoMaster = new DaoMaster(db); + return daoMaster.newSession(); + } + + public DaoMaster(SQLiteDatabase db) { + this(new StandardDatabase(db)); + } + + public DaoMaster(Database db) { + super(db, SCHEMA_VERSION); + registerDaoClass(AlarmMessageLocaleBeanDao.class); + } + + public DaoSession newSession() { + return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); + } + + public DaoSession newSession(IdentityScopeType type) { + return new DaoSession(db, type, daoConfigMap); + } + + /** + * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} - + */ + public static abstract class OpenHelper extends DatabaseOpenHelper { + public OpenHelper(Context context, String name) { + super(context, name, SCHEMA_VERSION); + } + + public OpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory, SCHEMA_VERSION); + } + + @Override + public void onCreate(Database db) { + Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); + createAllTables(db, false); + } + } + + /** WARNING: Drops all table on Upgrade! Use only during development. */ + public static class DevOpenHelper extends OpenHelper { + public DevOpenHelper(Context context, String name) { + super(context, name); + } + + public DevOpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory); + } + + @Override + public void onUpgrade(Database db, int oldVersion, int newVersion) { + Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); + dropAllTables(db, true); + onCreate(db); + } + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java new file mode 100644 index 0000000..480ed84 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java @@ -0,0 +1,48 @@ +package com.casic.smart.town.sanxi.greendao; + +import java.util.Map; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.AbstractDaoSession; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.identityscope.IdentityScopeType; +import org.greenrobot.greendao.internal.DaoConfig; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. + +/** + * {@inheritDoc} + * + * @see org.greenrobot.greendao.AbstractDaoSession + */ +public class DaoSession extends AbstractDaoSession { + + private final DaoConfig alarmMessageLocaleBeanDaoConfig; + + private final AlarmMessageLocaleBeanDao alarmMessageLocaleBeanDao; + + public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> + daoConfigMap) { + super(db); + + alarmMessageLocaleBeanDaoConfig = daoConfigMap.get(AlarmMessageLocaleBeanDao.class).clone(); + alarmMessageLocaleBeanDaoConfig.initIdentityScope(type); + + alarmMessageLocaleBeanDao = new AlarmMessageLocaleBeanDao(alarmMessageLocaleBeanDaoConfig, this); + + registerDao(AlarmMessageLocaleBean.class, alarmMessageLocaleBeanDao); + } + + public void clear() { + alarmMessageLocaleBeanDaoConfig.clearIdentityScope(); + } + + public AlarmMessageLocaleBeanDao getAlarmMessageLocaleBeanDao() { + return alarmMessageLocaleBeanDao; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt new file mode 100644 index 0000000..875cb8c --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt @@ -0,0 +1,5 @@ +package com.casic.smart.town.sanxi.service + +import com.igexin.sdk.PushService + +class ApplicationPushService : PushService() \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt new file mode 100644 index 0000000..396129f --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt @@ -0,0 +1,84 @@ +package com.casic.smart.town.sanxi.service + +import android.content.Context +import android.os.Message +import android.util.Log +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.casic.smart.town.sanxi.view.MainActivity +import com.igexin.sdk.GTIntentService +import com.igexin.sdk.message.GTCmdMessage +import com.igexin.sdk.message.GTNotificationMessage +import com.igexin.sdk.message.GTTransmitMessage +import com.pengxh.kt.lite.extensions.toJson + +class PushIntentService : GTIntentService() { + + private val kTag = "SmartWellIntentService" + + override fun onReceiveServicePid(context: Context?, pid: Int) { + + } + + // 透传消息 + override fun onReceiveMessageData(context: Context?, msg: GTTransmitMessage?) { + Log.d(kTag, "透传消息 -> msg = $msg") + } + + // 接收 cid + override fun onReceiveClientId(context: Context?, clientid: String?) { + Log.d(kTag, "onReceiveClientId -> $clientid") + //通知MainActivity注册个推服务 + val msg: Message = MainActivity.weakReferenceHandler.obtainMessage() + msg.what = LocaleConstant.PUSH_REGISTER + msg.obj = clientid + MainActivity.weakReferenceHandler.sendMessage(msg) + } + + // cid 离线上线通知 + override fun onReceiveOnlineState(context: Context?, online: Boolean) { + + } + + // 各种事件处理回执 + override fun onReceiveCommandResult(context: Context?, msg: GTCmdMessage?) { + + } + + // 通知到达 + override fun onNotificationMessageArrived(context: Context?, msg: GTNotificationMessage?) { + //报警 +// { +// "content": "设备编号[412022030361]发生井盖开盖报警", +// "messageId": "380abf9a79d34306a2683dc9bf96ee78", +// "taskId": "OSL-0830_4hmfimp3Vu684wo3SjXso9", +// "title": "告警提醒", +// "appid": "HKv8K9qARd6WckZ1o2Vbu4", +// "clientId": "e78beacc42e9a02ae6fb9087eb2b1171", +// "pkgName": "com.casic.app.smartwell" +// } + if (msg == null) { + return + } + Log.d(kTag, "通知到达 -> msg = ${msg.toJson()}") +// val userDetailJson = SaveKeyValues.getValue(LocaleConstant.USER_DETAIL_MODEL, "") as String +// var userId = "" +// if (userDetailJson.isNotBlank()) { +// val userDataModel = Gson().fromJson( +// userDetailJson, object : TypeToken() {}.type +// ) +// userId = userDataModel.id.toString() +// } +// //解析编号 +// val splitArray = msg.content.split("\\[|\\]".toRegex()) +// DataBaseManager.instance.insertNotice( +// msg.messageId, msg.appid, msg.clientId, msg.taskId, +// userId, msg.title, msg.content, splitArray[1], "0", +// System.currentTimeMillis().timestampToCompleteDate() +// ) + } + + // 通知点击 + override fun onNotificationMessageClicked(context: Context?, msg: GTNotificationMessage?) { + Log.d(kTag, "通知点击 -> msg = $msg") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt new file mode 100644 index 0000000..daa7c38 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt @@ -0,0 +1,14 @@ +package com.casic.smart.town.sanxi.util + +import android.content.Context +import me.leolin.shortcutbadger.ShortcutBadger + +object BadeHelper { + fun setBadgeNum(context: Context, badgeCount: Int) { + if (badgeCount == 0) { + ShortcutBadger.removeCount(context) + } else { + ShortcutBadger.applyCount(context, badgeCount) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt new file mode 100644 index 0000000..0a52ef2 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt @@ -0,0 +1,75 @@ +package com.casic.smart.town.sanxi.util + +import com.casic.smart.town.sanxi.base.BaseApplication +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao + +class DataBaseManager private constructor() { + + companion object { + //Kotlin委托模式双重锁单例 + val instance: DataBaseManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) { + DataBaseManager() + } + } + + private val beanDao = + BaseApplication.obtainInstance().obtainDaoSession().alarmMessageLocaleBeanDao + +// fun insertNotice( +// messageId: String, appid: String, clientId: String, +// taskId: String, userId: String, title: String, +// content: String, deviceCode: String, isRead: String, +// noticeTime: String +// ) { +// val noticeLocaleBean = NoticeLocaleBean() +// noticeLocaleBean.messageId = messageId +// noticeLocaleBean.appid = appid +// noticeLocaleBean.clientId = clientId +// noticeLocaleBean.taskId = taskId +// noticeLocaleBean.userId = userId +// noticeLocaleBean.title = title +// noticeLocaleBean.content = content +// noticeLocaleBean.deviceCode = deviceCode +// noticeLocaleBean.isRead = isRead +// noticeLocaleBean.noticeTime = noticeTime +// beanDao.insert(noticeLocaleBean) +// //角标设置 +// BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadNotice()) +// } + + fun deleteByMessageId(messageId: String) { + val result = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).list() + beanDao.deleteInTx(result) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun updateNoticeByMessageId(messageId: String) { + val noticeLocaleBean = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).unique() ?: return + noticeLocaleBean.isRead = "1" + beanDao.update(noticeLocaleBean) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun queryMessageByPage(userId: String, offset: Int): MutableList { + return BaseApplication.obtainInstance().obtainDaoSession() + .queryBuilder(AlarmMessageLocaleBean::class.java) + .where(AlarmMessageLocaleBeanDao.Properties.UserId.eq(userId)) + .offset(offset * LocaleConstant.PAGE_LIMIT) + .orderDesc(AlarmMessageLocaleBeanDao.Properties.AlarmTime) + .limit(LocaleConstant.PAGE_LIMIT) + .list() + } + + private fun queryUnReadMessage(): Int { + return beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.IsRead.eq("0") + ).list().size + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt new file mode 100644 index 0000000..52926a8 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt @@ -0,0 +1,31 @@ +package com.casic.smart.town.sanxi.util; + +import android.app.Activity +import android.view.WindowManager +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object LoadingDialogHub { + private lateinit var loadingDialog: QMUITipDialog + + fun show(activity: Activity, message: String) { + loadingDialog = QMUITipDialog + .Builder(activity) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_LOADING) + .setTipWord(message) + .create() + if (!activity.isDestroyed) { + try { + loadingDialog.show() + } catch (e: WindowManager.BadTokenException) { + e.printStackTrace() + } + } + } + + + fun dismiss() { + if (loadingDialog.isShowing) { + loadingDialog.dismiss() + } + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt new file mode 100644 index 0000000..de61c9a --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.util + +import android.Manifest + +object LocaleConstant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.READ_PHONE_STATE, + Manifest.permission.ACCESS_COARSE_LOCATION, + Manifest.permission.READ_EXTERNAL_STORAGE + ) + + const val PERMISSIONS_CODE = 999 + const val PUSH_REGISTER = 2022100101 + const val PAGE_LIMIT = 20 +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt new file mode 100644 index 0000000..3bea1c9 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt @@ -0,0 +1,112 @@ +package com.casic.smart.town.sanxi.view + +import android.view.KeyEvent +import android.view.MenuItem +import androidx.fragment.app.Fragment +import androidx.viewpager.widget.ViewPager +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.adapter.ViewPagerAdapter +import com.casic.smart.town.sanxi.fragment.AlarmPageFragment +import com.casic.smart.town.sanxi.fragment.MonitorPageFragment +import com.casic.smart.town.sanxi.fragment.StatisticsPageFragment +import com.gyf.immersionbar.ImmersionBar +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.base.KotlinBaseActivity +import com.pengxh.kt.lite.extensions.convertColor +import com.pengxh.kt.lite.extensions.show +import com.pengxh.kt.lite.utils.ImmerseStatusBarUtil +import com.pengxh.kt.lite.utils.WeakReferenceHandler +import kotlinx.android.synthetic.main.activity_main.* + +class MainActivity : KotlinBaseActivity() { + + companion object { + lateinit var weakReferenceHandler: WeakReferenceHandler + } + + private val kTag = "MainActivity" + private var menuItem: MenuItem? = null + private var fragmentPages: ArrayList = ArrayList() + private var clickTime: Long = 0 + + init { + fragmentPages.add(StatisticsPageFragment()) + fragmentPages.add(MonitorPageFragment()) + fragmentPages.add(AlarmPageFragment()) + } + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + ImmersionBar.with(this).statusBarDarkFont(false).init() + ImmerseStatusBarUtil.setColor(this, R.color.mainThemeColor.convertColor(this)) + } + + override fun initData() { + //推送,多次调用 SDK 初始化并无影响。 + PushManager.getInstance().initialize(this) + weakReferenceHandler = WeakReferenceHandler { + + true + } + } + + override fun observeRequestState() { + + } + + override fun initEvent() { + bottomNavigation.itemIconTintList = null + bottomNavigation.setOnNavigationItemSelectedListener { menuItem -> + when (menuItem.itemId) { + R.id.nav_statistics -> { + mainViewPager.currentItem = 0 + } + R.id.nav_monitor -> { + mainViewPager.currentItem = 1 + } + R.id.nav_alarm -> { + mainViewPager.currentItem = 2 + } + } + false + } + mainViewPager.adapter = ViewPagerAdapter(fragmentPages, supportFragmentManager) + mainViewPager.offscreenPageLimit = fragmentPages.size //缓存页数 + mainViewPager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener { + override fun onPageScrollStateChanged(state: Int) { + + } + + override fun onPageScrolled( + position: Int, + positionOffset: Float, + positionOffsetPixels: Int + ) { + + } + + override fun onPageSelected(position: Int) { + if (menuItem != null) { + menuItem!!.isChecked = false + } else { + bottomNavigation.menu.getItem(0).isChecked = false + } + menuItem = bottomNavigation.menu.getItem(position) + menuItem!!.isChecked = true + } + }) + } + + override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean { + return if (keyCode == KeyEvent.KEYCODE_BACK) { + if (System.currentTimeMillis() - clickTime > 2000) { + "再按一次退出程序".show(this) + clickTime = System.currentTimeMillis() + true + } else { + super.onKeyDown(keyCode, event) + } + } else super.onKeyDown(keyCode, event) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt new file mode 100644 index 0000000..c5d8b22 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.view + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseActivity + +class MonitorRecordActivity : KotlinBaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_monitor_record + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt new file mode 100644 index 0000000..c478d83 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt @@ -0,0 +1,55 @@ +package com.casic.smart.town.sanxi.view + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.amap.api.maps.MapsInitializer +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.gyf.immersionbar.ImmersionBar +import com.pengxh.kt.lite.extensions.navigatePageTo +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + ImmersionBar.with(this).statusBarDarkFont(true).init() + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (EasyPermissions.hasPermissions(this, *LocaleConstant.USER_PERMISSIONS)) { + startSplashScreenActivity() + } else { + EasyPermissions.requestPermissions( + this@PermissionActivity, + resources.getString(R.string.app_name) + "需要获取相关权限", + LocaleConstant.PERMISSIONS_CODE, + *LocaleConstant.USER_PERMISSIONS + ) + } + } + + private fun startSplashScreenActivity() { + //先把导航隐私政策声明,后面导航会用到 + MapsInitializer.updatePrivacyAgree(this, true) + MapsInitializer.updatePrivacyShow(this, true, true) + this.navigatePageTo() + 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) { + startSplashScreenActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable/alarm_selector.xml b/app/src/main/res/drawable/alarm_selector.xml new file mode 100644 index 0000000..39b2595 --- /dev/null +++ b/app/src/main/res/drawable/alarm_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bottom_text_color.xml b/app/src/main/res/drawable/bottom_text_color.xml new file mode 100644 index 0000000..b284ea3 --- /dev/null +++ b/app/src/main/res/drawable/bottom_text_color.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_alarm.xml b/app/src/main/res/drawable/ic_alarm.xml new file mode 100644 index 0000000..dc33aab --- /dev/null +++ b/app/src/main/res/drawable/ic_alarm.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_alarm_selected.xml b/app/src/main/res/drawable/ic_alarm_selected.xml new file mode 100644 index 0000000..993fea6 --- /dev/null +++ b/app/src/main/res/drawable/ic_alarm_selected.xml @@ -0,0 +1,9 @@ + + + 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_monitor.xml b/app/src/main/res/drawable/ic_monitor.xml new file mode 100644 index 0000000..271f5b4 --- /dev/null +++ b/app/src/main/res/drawable/ic_monitor.xml @@ -0,0 +1,9 @@ + + + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..10cfdbf --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*.iml +.gradle +/local.properties +/.idea +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..a4cd2ca --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,101 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'org.greenrobot.greendao' + +android { +// signingConfigs { +// release { +// storeFile file('/Users/a203/Desktop/AndroidProjects/CasicSmartWell/app/CasicSmartWell.jks') +// storePassword '123456789' +// keyAlias 'key0' +// keyPassword '123456789' +// } +// } + compileSdkVersion 31 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.smart.town.sanxi" + minSdkVersion 23 + targetSdkVersion 31 + versionCode 1 + versionName "1.0.0" + + manifestPlaceholders = [GETUI_APPID: "A9V4DvwLcdAqkFCQuFyhq6"] + } + + buildTypes { + release { + minifyEnabled false +// signingConfig signingConfigs.release + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + + ndk { abiFilters "armeabi", "armeabi-v7a", "arm64-v8" } + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlin { + experimental { + coroutines 'enable' + } + } + + greendao { + schemaVersion 1//数据库版本号 + targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 + daoPackage 'com.casic.smart.town.sanxi.greendao'//设置DaoMaster、DaoSession、Dao包名 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + //基础依赖库 + implementation files('libs/lite-release.aar') + implementation 'androidx.appcompat:appcompat:1.4.2' + implementation 'androidx.core:core-ktx:1.8.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:3.0.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' + //MVVM+LiveData + implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.1" + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0" + implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + //Kotlin协程 + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1' + //图片加载框架 + implementation 'com.github.bumptech.glide:glide:4.9.0' + //返回值转换器 + implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' + implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + //okhttp3日志拦截器 + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //网络请求和接口封装 + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.9.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.9.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' + //高德地图 + implementation 'com.amap.api:3dmap:latest.integration' + //推送SDK + implementation 'com.getui:gtsdk:3.2.10.0' //个推SDK + implementation 'com.getui:gtc:3.1.9.0' //个推核心组件 + //数据库框架 + implementation 'org.greenrobot:greendao:3.3.0' + //桌面角标 + implementation "me.leolin:ShortcutBadger:1.1.22@aar" +} \ No newline at end of file diff --git a/app/libs/lite-release.aar b/app/libs/lite-release.aar new file mode 100644 index 0000000..45da4df --- /dev/null +++ b/app/libs/lite-release.aar Binary files differ diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /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 \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..a83c28a --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/svg/monitor.svg b/app/src/main/assets/svg/monitor.svg new file mode 100644 index 0000000..c8d3e25 --- /dev/null +++ b/app/src/main/assets/svg/monitor.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/msg.svg b/app/src/main/assets/svg/msg.svg new file mode 100644 index 0000000..e864e48 --- /dev/null +++ b/app/src/main/assets/svg/msg.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/statistics.svg b/app/src/main/assets/svg/statistics.svg new file mode 100644 index 0000000..974000e --- /dev/null +++ b/app/src/main/assets/svg/statistics.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt new file mode 100644 index 0000000..6b9cce0 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.adapter + +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentManager +import androidx.fragment.app.FragmentPagerAdapter + +class ViewPagerAdapter(list: ArrayList, manager: FragmentManager) : + FragmentPagerAdapter(manager) { + + private var pageList: List = list + + override fun getItem(position: Int) = pageList[position] + + override fun getCount() = pageList.size +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt new file mode 100644 index 0000000..4e017b1 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt @@ -0,0 +1,40 @@ +package com.casic.smart.town.sanxi.base + +import android.app.Application +import android.util.Log +import com.casic.smart.town.sanxi.greendao.DaoMaster +import com.casic.smart.town.sanxi.greendao.DaoSession +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + private val kTag = "BaseApplication" + + companion object { + private var instance: BaseApplication by Delegates.notNull() + + fun obtainInstance() = instance + + private lateinit var daoSession: DaoSession + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences(this) + //推送 + PushManager.getInstance().initialize(this) + PushManager.getInstance().setDebugLogger(this) { + Log.d(kTag, it) + } + val devOpenHelper = DaoMaster.DevOpenHelper(this, "SmartTown.db", null) + val daoMaster = DaoMaster(devOpenHelper.writableDatabase) + daoSession = daoMaster.newSession() + } + + fun obtainDaoSession(): DaoSession { + return daoSession + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java new file mode 100644 index 0000000..b8f67dc --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java @@ -0,0 +1,133 @@ +package com.casic.smart.town.sanxi.bean; + +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Generated; +import org.greenrobot.greendao.annotation.Id; +import org.greenrobot.greendao.annotation.Unique; + +@Entity +public class AlarmMessageLocaleBean { + @Id(autoincrement = true) + private Long id;//主键自增 + + @Unique + private String messageId; + private String appId; + private String clientId; + private String taskId; + private String userId; + private String title; + private String content; + private String deviceCode; + private String isRead;//0-未读,1-已读 + private String alarmTime; + + @Generated(hash = 566950134) + public AlarmMessageLocaleBean(Long id, String messageId, String appId, + String clientId, String taskId, String userId, String title, + String content, String deviceCode, String isRead, String alarmTime) { + this.id = id; + this.messageId = messageId; + this.appId = appId; + this.clientId = clientId; + this.taskId = taskId; + this.userId = userId; + this.title = title; + this.content = content; + this.deviceCode = deviceCode; + this.isRead = isRead; + this.alarmTime = alarmTime; + } + + @Generated(hash = 1737519562) + public AlarmMessageLocaleBean() { + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getMessageId() { + return this.messageId; + } + + public void setMessageId(String messageId) { + this.messageId = messageId; + } + + public String getAppId() { + return this.appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public String getClientId() { + return this.clientId; + } + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public String getTaskId() { + return this.taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getUserId() { + return this.userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getTitle() { + return this.title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return this.content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getDeviceCode() { + return this.deviceCode; + } + + public void setDeviceCode(String deviceCode) { + this.deviceCode = deviceCode; + } + + public String getIsRead() { + return this.isRead; + } + + public void setIsRead(String isRead) { + this.isRead = isRead; + } + + public String getAlarmTime() { + return this.alarmTime; + } + + public void setAlarmTime(String alarmTime) { + this.alarmTime = alarmTime; + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt new file mode 100644 index 0000000..650e201 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class AlarmPageFragment: KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_alarm + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt new file mode 100644 index 0000000..deac8ac --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt @@ -0,0 +1,76 @@ +package com.casic.smart.town.sanxi.fragment + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.Fragment +import com.amap.api.maps.AMap +import com.amap.api.maps.AMapOptions +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.view.MonitorRecordActivity +import com.pengxh.kt.lite.extensions.navigatePageTo +import com.pengxh.kt.lite.extensions.show +import kotlinx.android.synthetic.main.fragment_monitor.view.* + +class MonitorPageFragment : Fragment() { + + private val kTag = "HomePageFragment" + private lateinit var monitorView: View + private lateinit var aMap: AMap + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? + ): View { + monitorView = inflater.inflate(R.layout.fragment_monitor, container, false) + //地图初始化 + initMap(savedInstanceState) + + monitorView.rightOperateView.setOnClickListener { + requireContext().navigatePageTo() + } + return monitorView + } + + private fun initMap(savedInstanceState: Bundle?) { + monitorView.mapView.onCreate(savedInstanceState) + aMap = monitorView.mapView.map + aMap.mapType = AMap.MAP_TYPE_NORMAL + val uiSettings = aMap.uiSettings + uiSettings.isCompassEnabled = true + uiSettings.zoomPosition = AMapOptions.ZOOM_POSITION_RIGHT_CENTER + uiSettings.isTiltGesturesEnabled = false//不许地图随手势倾斜角度 + + // 地图加载成功监听 +// aMap.addOnMapLoadedListener(this) + // 地图缩放监听 +// aMap.addOnCameraChangeListener(this) + // marker 点击事件监听 +// aMap.addOnMarkerClickListener(this) + // 点击marker弹出自定义popup +// aMap.setInfoWindowAdapter(this) + //信息窗点击事件 +// aMap.addOnInfoWindowClickListener(this) + } + + /***以下是地图生命周期管理************************************************************************/ + override fun onResume() { + super.onResume() + monitorView.mapView.onResume() + } + + override fun onPause() { + super.onPause() + monitorView.mapView.onPause() + } + + override fun onSaveInstanceState(outState: Bundle) { + super.onSaveInstanceState(outState) + monitorView.mapView.onSaveInstanceState(outState) + } + + override fun onDestroy() { + super.onDestroy() + monitorView.mapView.onDestroy() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt new file mode 100644 index 0000000..e84df12 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class StatisticsPageFragment : KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_statistics + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java new file mode 100644 index 0000000..68d7901 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java @@ -0,0 +1,255 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.database.Cursor; +import android.database.sqlite.SQLiteStatement; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.Property; +import org.greenrobot.greendao.internal.DaoConfig; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseStatement; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * DAO for table "ALARM_MESSAGE_LOCALE_BEAN". +*/ +public class AlarmMessageLocaleBeanDao extends AbstractDao { + + public static final String TABLENAME = "ALARM_MESSAGE_LOCALE_BEAN"; + + /** + * Properties of entity AlarmMessageLocaleBean.
+ * Can be used for QueryBuilder and for referencing column names. + */ + public static class Properties { + public final static Property Id = new Property(0, Long.class, "id", true, "_id"); + public final static Property MessageId = new Property(1, String.class, "messageId", false, "MESSAGE_ID"); + public final static Property AppId = new Property(2, String.class, "appId", false, "APP_ID"); + public final static Property ClientId = new Property(3, String.class, "clientId", false, "CLIENT_ID"); + public final static Property TaskId = new Property(4, String.class, "taskId", false, "TASK_ID"); + public final static Property UserId = new Property(5, String.class, "userId", false, "USER_ID"); + public final static Property Title = new Property(6, String.class, "title", false, "TITLE"); + public final static Property Content = new Property(7, String.class, "content", false, "CONTENT"); + public final static Property DeviceCode = new Property(8, String.class, "deviceCode", false, "DEVICE_CODE"); + public final static Property IsRead = new Property(9, String.class, "isRead", false, "IS_READ"); + public final static Property AlarmTime = new Property(10, String.class, "alarmTime", false, "ALARM_TIME"); + } + + + public AlarmMessageLocaleBeanDao(DaoConfig config) { + super(config); + } + + public AlarmMessageLocaleBeanDao(DaoConfig config, DaoSession daoSession) { + super(config, daoSession); + } + + /** Creates the underlying database table. */ + public static void createTable(Database db, boolean ifNotExists) { + String constraint = ifNotExists? "IF NOT EXISTS ": ""; + db.execSQL("CREATE TABLE " + constraint + "\"ALARM_MESSAGE_LOCALE_BEAN\" (" + // + "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id + "\"MESSAGE_ID\" TEXT UNIQUE ," + // 1: messageId + "\"APP_ID\" TEXT," + // 2: appId + "\"CLIENT_ID\" TEXT," + // 3: clientId + "\"TASK_ID\" TEXT," + // 4: taskId + "\"USER_ID\" TEXT," + // 5: userId + "\"TITLE\" TEXT," + // 6: title + "\"CONTENT\" TEXT," + // 7: content + "\"DEVICE_CODE\" TEXT," + // 8: deviceCode + "\"IS_READ\" TEXT," + // 9: isRead + "\"ALARM_TIME\" TEXT);"); // 10: alarmTime + } + + /** Drops the underlying database table. */ + public static void dropTable(Database db, boolean ifExists) { + String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"ALARM_MESSAGE_LOCALE_BEAN\""; + db.execSQL(sql); + } + + @Override + protected final void bindValues(DatabaseStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + protected final void bindValues(SQLiteStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + public Long readKey(Cursor cursor, int offset) { + return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); + } + + @Override + public AlarmMessageLocaleBean readEntity(Cursor cursor, int offset) { + AlarmMessageLocaleBean entity = new AlarmMessageLocaleBean( // + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // messageId + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // appId + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // clientId + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // taskId + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // userId + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // title + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // content + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // deviceCode + cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // isRead + cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10) // alarmTime + ); + return entity; + } + + @Override + public void readEntity(Cursor cursor, AlarmMessageLocaleBean entity, int offset) { + entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); + entity.setMessageId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setAppId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setClientId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setTaskId(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); + entity.setUserId(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setTitle(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setContent(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); + entity.setDeviceCode(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); + entity.setIsRead(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9)); + entity.setAlarmTime(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); + } + + @Override + protected final Long updateKeyAfterInsert(AlarmMessageLocaleBean entity, long rowId) { + entity.setId(rowId); + return rowId; + } + + @Override + public Long getKey(AlarmMessageLocaleBean entity) { + if(entity != null) { + return entity.getId(); + } else { + return null; + } + } + + @Override + public boolean hasKey(AlarmMessageLocaleBean entity) { + return entity.getId() != null; + } + + @Override + protected final boolean isEntityUpdateable() { + return true; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java new file mode 100644 index 0000000..4222c40 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java @@ -0,0 +1,96 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.content.Context; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteDatabase.CursorFactory; +import android.util.Log; + +import org.greenrobot.greendao.AbstractDaoMaster; +import org.greenrobot.greendao.database.StandardDatabase; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseOpenHelper; +import org.greenrobot.greendao.identityscope.IdentityScopeType; + + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * Master of DAO (schema version 1): knows all DAOs. + */ +public class DaoMaster extends AbstractDaoMaster { + public static final int SCHEMA_VERSION = 1; + + /** Creates underlying database table using DAOs. */ + public static void createAllTables(Database db, boolean ifNotExists) { + AlarmMessageLocaleBeanDao.createTable(db, ifNotExists); + } + + /** Drops underlying database table using DAOs. */ + public static void dropAllTables(Database db, boolean ifExists) { + AlarmMessageLocaleBeanDao.dropTable(db, ifExists); + } + + /** + * WARNING: Drops all table on Upgrade! Use only during development. + * Convenience method using a {@link DevOpenHelper}. + */ + public static DaoSession newDevSession(Context context, String name) { + Database db = new DevOpenHelper(context, name).getWritableDb(); + DaoMaster daoMaster = new DaoMaster(db); + return daoMaster.newSession(); + } + + public DaoMaster(SQLiteDatabase db) { + this(new StandardDatabase(db)); + } + + public DaoMaster(Database db) { + super(db, SCHEMA_VERSION); + registerDaoClass(AlarmMessageLocaleBeanDao.class); + } + + public DaoSession newSession() { + return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); + } + + public DaoSession newSession(IdentityScopeType type) { + return new DaoSession(db, type, daoConfigMap); + } + + /** + * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} - + */ + public static abstract class OpenHelper extends DatabaseOpenHelper { + public OpenHelper(Context context, String name) { + super(context, name, SCHEMA_VERSION); + } + + public OpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory, SCHEMA_VERSION); + } + + @Override + public void onCreate(Database db) { + Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); + createAllTables(db, false); + } + } + + /** WARNING: Drops all table on Upgrade! Use only during development. */ + public static class DevOpenHelper extends OpenHelper { + public DevOpenHelper(Context context, String name) { + super(context, name); + } + + public DevOpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory); + } + + @Override + public void onUpgrade(Database db, int oldVersion, int newVersion) { + Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); + dropAllTables(db, true); + onCreate(db); + } + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java new file mode 100644 index 0000000..480ed84 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java @@ -0,0 +1,48 @@ +package com.casic.smart.town.sanxi.greendao; + +import java.util.Map; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.AbstractDaoSession; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.identityscope.IdentityScopeType; +import org.greenrobot.greendao.internal.DaoConfig; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. + +/** + * {@inheritDoc} + * + * @see org.greenrobot.greendao.AbstractDaoSession + */ +public class DaoSession extends AbstractDaoSession { + + private final DaoConfig alarmMessageLocaleBeanDaoConfig; + + private final AlarmMessageLocaleBeanDao alarmMessageLocaleBeanDao; + + public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> + daoConfigMap) { + super(db); + + alarmMessageLocaleBeanDaoConfig = daoConfigMap.get(AlarmMessageLocaleBeanDao.class).clone(); + alarmMessageLocaleBeanDaoConfig.initIdentityScope(type); + + alarmMessageLocaleBeanDao = new AlarmMessageLocaleBeanDao(alarmMessageLocaleBeanDaoConfig, this); + + registerDao(AlarmMessageLocaleBean.class, alarmMessageLocaleBeanDao); + } + + public void clear() { + alarmMessageLocaleBeanDaoConfig.clearIdentityScope(); + } + + public AlarmMessageLocaleBeanDao getAlarmMessageLocaleBeanDao() { + return alarmMessageLocaleBeanDao; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt new file mode 100644 index 0000000..875cb8c --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt @@ -0,0 +1,5 @@ +package com.casic.smart.town.sanxi.service + +import com.igexin.sdk.PushService + +class ApplicationPushService : PushService() \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt new file mode 100644 index 0000000..396129f --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt @@ -0,0 +1,84 @@ +package com.casic.smart.town.sanxi.service + +import android.content.Context +import android.os.Message +import android.util.Log +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.casic.smart.town.sanxi.view.MainActivity +import com.igexin.sdk.GTIntentService +import com.igexin.sdk.message.GTCmdMessage +import com.igexin.sdk.message.GTNotificationMessage +import com.igexin.sdk.message.GTTransmitMessage +import com.pengxh.kt.lite.extensions.toJson + +class PushIntentService : GTIntentService() { + + private val kTag = "SmartWellIntentService" + + override fun onReceiveServicePid(context: Context?, pid: Int) { + + } + + // 透传消息 + override fun onReceiveMessageData(context: Context?, msg: GTTransmitMessage?) { + Log.d(kTag, "透传消息 -> msg = $msg") + } + + // 接收 cid + override fun onReceiveClientId(context: Context?, clientid: String?) { + Log.d(kTag, "onReceiveClientId -> $clientid") + //通知MainActivity注册个推服务 + val msg: Message = MainActivity.weakReferenceHandler.obtainMessage() + msg.what = LocaleConstant.PUSH_REGISTER + msg.obj = clientid + MainActivity.weakReferenceHandler.sendMessage(msg) + } + + // cid 离线上线通知 + override fun onReceiveOnlineState(context: Context?, online: Boolean) { + + } + + // 各种事件处理回执 + override fun onReceiveCommandResult(context: Context?, msg: GTCmdMessage?) { + + } + + // 通知到达 + override fun onNotificationMessageArrived(context: Context?, msg: GTNotificationMessage?) { + //报警 +// { +// "content": "设备编号[412022030361]发生井盖开盖报警", +// "messageId": "380abf9a79d34306a2683dc9bf96ee78", +// "taskId": "OSL-0830_4hmfimp3Vu684wo3SjXso9", +// "title": "告警提醒", +// "appid": "HKv8K9qARd6WckZ1o2Vbu4", +// "clientId": "e78beacc42e9a02ae6fb9087eb2b1171", +// "pkgName": "com.casic.app.smartwell" +// } + if (msg == null) { + return + } + Log.d(kTag, "通知到达 -> msg = ${msg.toJson()}") +// val userDetailJson = SaveKeyValues.getValue(LocaleConstant.USER_DETAIL_MODEL, "") as String +// var userId = "" +// if (userDetailJson.isNotBlank()) { +// val userDataModel = Gson().fromJson( +// userDetailJson, object : TypeToken() {}.type +// ) +// userId = userDataModel.id.toString() +// } +// //解析编号 +// val splitArray = msg.content.split("\\[|\\]".toRegex()) +// DataBaseManager.instance.insertNotice( +// msg.messageId, msg.appid, msg.clientId, msg.taskId, +// userId, msg.title, msg.content, splitArray[1], "0", +// System.currentTimeMillis().timestampToCompleteDate() +// ) + } + + // 通知点击 + override fun onNotificationMessageClicked(context: Context?, msg: GTNotificationMessage?) { + Log.d(kTag, "通知点击 -> msg = $msg") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt new file mode 100644 index 0000000..daa7c38 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt @@ -0,0 +1,14 @@ +package com.casic.smart.town.sanxi.util + +import android.content.Context +import me.leolin.shortcutbadger.ShortcutBadger + +object BadeHelper { + fun setBadgeNum(context: Context, badgeCount: Int) { + if (badgeCount == 0) { + ShortcutBadger.removeCount(context) + } else { + ShortcutBadger.applyCount(context, badgeCount) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt new file mode 100644 index 0000000..0a52ef2 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt @@ -0,0 +1,75 @@ +package com.casic.smart.town.sanxi.util + +import com.casic.smart.town.sanxi.base.BaseApplication +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao + +class DataBaseManager private constructor() { + + companion object { + //Kotlin委托模式双重锁单例 + val instance: DataBaseManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) { + DataBaseManager() + } + } + + private val beanDao = + BaseApplication.obtainInstance().obtainDaoSession().alarmMessageLocaleBeanDao + +// fun insertNotice( +// messageId: String, appid: String, clientId: String, +// taskId: String, userId: String, title: String, +// content: String, deviceCode: String, isRead: String, +// noticeTime: String +// ) { +// val noticeLocaleBean = NoticeLocaleBean() +// noticeLocaleBean.messageId = messageId +// noticeLocaleBean.appid = appid +// noticeLocaleBean.clientId = clientId +// noticeLocaleBean.taskId = taskId +// noticeLocaleBean.userId = userId +// noticeLocaleBean.title = title +// noticeLocaleBean.content = content +// noticeLocaleBean.deviceCode = deviceCode +// noticeLocaleBean.isRead = isRead +// noticeLocaleBean.noticeTime = noticeTime +// beanDao.insert(noticeLocaleBean) +// //角标设置 +// BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadNotice()) +// } + + fun deleteByMessageId(messageId: String) { + val result = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).list() + beanDao.deleteInTx(result) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun updateNoticeByMessageId(messageId: String) { + val noticeLocaleBean = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).unique() ?: return + noticeLocaleBean.isRead = "1" + beanDao.update(noticeLocaleBean) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun queryMessageByPage(userId: String, offset: Int): MutableList { + return BaseApplication.obtainInstance().obtainDaoSession() + .queryBuilder(AlarmMessageLocaleBean::class.java) + .where(AlarmMessageLocaleBeanDao.Properties.UserId.eq(userId)) + .offset(offset * LocaleConstant.PAGE_LIMIT) + .orderDesc(AlarmMessageLocaleBeanDao.Properties.AlarmTime) + .limit(LocaleConstant.PAGE_LIMIT) + .list() + } + + private fun queryUnReadMessage(): Int { + return beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.IsRead.eq("0") + ).list().size + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt new file mode 100644 index 0000000..52926a8 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt @@ -0,0 +1,31 @@ +package com.casic.smart.town.sanxi.util; + +import android.app.Activity +import android.view.WindowManager +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object LoadingDialogHub { + private lateinit var loadingDialog: QMUITipDialog + + fun show(activity: Activity, message: String) { + loadingDialog = QMUITipDialog + .Builder(activity) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_LOADING) + .setTipWord(message) + .create() + if (!activity.isDestroyed) { + try { + loadingDialog.show() + } catch (e: WindowManager.BadTokenException) { + e.printStackTrace() + } + } + } + + + fun dismiss() { + if (loadingDialog.isShowing) { + loadingDialog.dismiss() + } + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt new file mode 100644 index 0000000..de61c9a --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.util + +import android.Manifest + +object LocaleConstant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.READ_PHONE_STATE, + Manifest.permission.ACCESS_COARSE_LOCATION, + Manifest.permission.READ_EXTERNAL_STORAGE + ) + + const val PERMISSIONS_CODE = 999 + const val PUSH_REGISTER = 2022100101 + const val PAGE_LIMIT = 20 +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt new file mode 100644 index 0000000..3bea1c9 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt @@ -0,0 +1,112 @@ +package com.casic.smart.town.sanxi.view + +import android.view.KeyEvent +import android.view.MenuItem +import androidx.fragment.app.Fragment +import androidx.viewpager.widget.ViewPager +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.adapter.ViewPagerAdapter +import com.casic.smart.town.sanxi.fragment.AlarmPageFragment +import com.casic.smart.town.sanxi.fragment.MonitorPageFragment +import com.casic.smart.town.sanxi.fragment.StatisticsPageFragment +import com.gyf.immersionbar.ImmersionBar +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.base.KotlinBaseActivity +import com.pengxh.kt.lite.extensions.convertColor +import com.pengxh.kt.lite.extensions.show +import com.pengxh.kt.lite.utils.ImmerseStatusBarUtil +import com.pengxh.kt.lite.utils.WeakReferenceHandler +import kotlinx.android.synthetic.main.activity_main.* + +class MainActivity : KotlinBaseActivity() { + + companion object { + lateinit var weakReferenceHandler: WeakReferenceHandler + } + + private val kTag = "MainActivity" + private var menuItem: MenuItem? = null + private var fragmentPages: ArrayList = ArrayList() + private var clickTime: Long = 0 + + init { + fragmentPages.add(StatisticsPageFragment()) + fragmentPages.add(MonitorPageFragment()) + fragmentPages.add(AlarmPageFragment()) + } + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + ImmersionBar.with(this).statusBarDarkFont(false).init() + ImmerseStatusBarUtil.setColor(this, R.color.mainThemeColor.convertColor(this)) + } + + override fun initData() { + //推送,多次调用 SDK 初始化并无影响。 + PushManager.getInstance().initialize(this) + weakReferenceHandler = WeakReferenceHandler { + + true + } + } + + override fun observeRequestState() { + + } + + override fun initEvent() { + bottomNavigation.itemIconTintList = null + bottomNavigation.setOnNavigationItemSelectedListener { menuItem -> + when (menuItem.itemId) { + R.id.nav_statistics -> { + mainViewPager.currentItem = 0 + } + R.id.nav_monitor -> { + mainViewPager.currentItem = 1 + } + R.id.nav_alarm -> { + mainViewPager.currentItem = 2 + } + } + false + } + mainViewPager.adapter = ViewPagerAdapter(fragmentPages, supportFragmentManager) + mainViewPager.offscreenPageLimit = fragmentPages.size //缓存页数 + mainViewPager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener { + override fun onPageScrollStateChanged(state: Int) { + + } + + override fun onPageScrolled( + position: Int, + positionOffset: Float, + positionOffsetPixels: Int + ) { + + } + + override fun onPageSelected(position: Int) { + if (menuItem != null) { + menuItem!!.isChecked = false + } else { + bottomNavigation.menu.getItem(0).isChecked = false + } + menuItem = bottomNavigation.menu.getItem(position) + menuItem!!.isChecked = true + } + }) + } + + override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean { + return if (keyCode == KeyEvent.KEYCODE_BACK) { + if (System.currentTimeMillis() - clickTime > 2000) { + "再按一次退出程序".show(this) + clickTime = System.currentTimeMillis() + true + } else { + super.onKeyDown(keyCode, event) + } + } else super.onKeyDown(keyCode, event) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt new file mode 100644 index 0000000..c5d8b22 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.view + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseActivity + +class MonitorRecordActivity : KotlinBaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_monitor_record + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt new file mode 100644 index 0000000..c478d83 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt @@ -0,0 +1,55 @@ +package com.casic.smart.town.sanxi.view + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.amap.api.maps.MapsInitializer +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.gyf.immersionbar.ImmersionBar +import com.pengxh.kt.lite.extensions.navigatePageTo +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + ImmersionBar.with(this).statusBarDarkFont(true).init() + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (EasyPermissions.hasPermissions(this, *LocaleConstant.USER_PERMISSIONS)) { + startSplashScreenActivity() + } else { + EasyPermissions.requestPermissions( + this@PermissionActivity, + resources.getString(R.string.app_name) + "需要获取相关权限", + LocaleConstant.PERMISSIONS_CODE, + *LocaleConstant.USER_PERMISSIONS + ) + } + } + + private fun startSplashScreenActivity() { + //先把导航隐私政策声明,后面导航会用到 + MapsInitializer.updatePrivacyAgree(this, true) + MapsInitializer.updatePrivacyShow(this, true, true) + this.navigatePageTo() + 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) { + startSplashScreenActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable/alarm_selector.xml b/app/src/main/res/drawable/alarm_selector.xml new file mode 100644 index 0000000..39b2595 --- /dev/null +++ b/app/src/main/res/drawable/alarm_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bottom_text_color.xml b/app/src/main/res/drawable/bottom_text_color.xml new file mode 100644 index 0000000..b284ea3 --- /dev/null +++ b/app/src/main/res/drawable/bottom_text_color.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_alarm.xml b/app/src/main/res/drawable/ic_alarm.xml new file mode 100644 index 0000000..dc33aab --- /dev/null +++ b/app/src/main/res/drawable/ic_alarm.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_alarm_selected.xml b/app/src/main/res/drawable/ic_alarm_selected.xml new file mode 100644 index 0000000..993fea6 --- /dev/null +++ b/app/src/main/res/drawable/ic_alarm_selected.xml @@ -0,0 +1,9 @@ + + + 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_monitor.xml b/app/src/main/res/drawable/ic_monitor.xml new file mode 100644 index 0000000..271f5b4 --- /dev/null +++ b/app/src/main/res/drawable/ic_monitor.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_monitor_selected.xml b/app/src/main/res/drawable/ic_monitor_selected.xml new file mode 100644 index 0000000..ee62d84 --- /dev/null +++ b/app/src/main/res/drawable/ic_monitor_selected.xml @@ -0,0 +1,9 @@ + + + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..10cfdbf --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*.iml +.gradle +/local.properties +/.idea +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..a4cd2ca --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,101 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'org.greenrobot.greendao' + +android { +// signingConfigs { +// release { +// storeFile file('/Users/a203/Desktop/AndroidProjects/CasicSmartWell/app/CasicSmartWell.jks') +// storePassword '123456789' +// keyAlias 'key0' +// keyPassword '123456789' +// } +// } + compileSdkVersion 31 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.smart.town.sanxi" + minSdkVersion 23 + targetSdkVersion 31 + versionCode 1 + versionName "1.0.0" + + manifestPlaceholders = [GETUI_APPID: "A9V4DvwLcdAqkFCQuFyhq6"] + } + + buildTypes { + release { + minifyEnabled false +// signingConfig signingConfigs.release + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + + ndk { abiFilters "armeabi", "armeabi-v7a", "arm64-v8" } + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlin { + experimental { + coroutines 'enable' + } + } + + greendao { + schemaVersion 1//数据库版本号 + targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 + daoPackage 'com.casic.smart.town.sanxi.greendao'//设置DaoMaster、DaoSession、Dao包名 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + //基础依赖库 + implementation files('libs/lite-release.aar') + implementation 'androidx.appcompat:appcompat:1.4.2' + implementation 'androidx.core:core-ktx:1.8.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:3.0.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' + //MVVM+LiveData + implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.1" + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0" + implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + //Kotlin协程 + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1' + //图片加载框架 + implementation 'com.github.bumptech.glide:glide:4.9.0' + //返回值转换器 + implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' + implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + //okhttp3日志拦截器 + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //网络请求和接口封装 + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.9.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.9.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' + //高德地图 + implementation 'com.amap.api:3dmap:latest.integration' + //推送SDK + implementation 'com.getui:gtsdk:3.2.10.0' //个推SDK + implementation 'com.getui:gtc:3.1.9.0' //个推核心组件 + //数据库框架 + implementation 'org.greenrobot:greendao:3.3.0' + //桌面角标 + implementation "me.leolin:ShortcutBadger:1.1.22@aar" +} \ No newline at end of file diff --git a/app/libs/lite-release.aar b/app/libs/lite-release.aar new file mode 100644 index 0000000..45da4df --- /dev/null +++ b/app/libs/lite-release.aar Binary files differ diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /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 \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..a83c28a --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/svg/monitor.svg b/app/src/main/assets/svg/monitor.svg new file mode 100644 index 0000000..c8d3e25 --- /dev/null +++ b/app/src/main/assets/svg/monitor.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/msg.svg b/app/src/main/assets/svg/msg.svg new file mode 100644 index 0000000..e864e48 --- /dev/null +++ b/app/src/main/assets/svg/msg.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/statistics.svg b/app/src/main/assets/svg/statistics.svg new file mode 100644 index 0000000..974000e --- /dev/null +++ b/app/src/main/assets/svg/statistics.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt new file mode 100644 index 0000000..6b9cce0 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.adapter + +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentManager +import androidx.fragment.app.FragmentPagerAdapter + +class ViewPagerAdapter(list: ArrayList, manager: FragmentManager) : + FragmentPagerAdapter(manager) { + + private var pageList: List = list + + override fun getItem(position: Int) = pageList[position] + + override fun getCount() = pageList.size +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt new file mode 100644 index 0000000..4e017b1 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt @@ -0,0 +1,40 @@ +package com.casic.smart.town.sanxi.base + +import android.app.Application +import android.util.Log +import com.casic.smart.town.sanxi.greendao.DaoMaster +import com.casic.smart.town.sanxi.greendao.DaoSession +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + private val kTag = "BaseApplication" + + companion object { + private var instance: BaseApplication by Delegates.notNull() + + fun obtainInstance() = instance + + private lateinit var daoSession: DaoSession + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences(this) + //推送 + PushManager.getInstance().initialize(this) + PushManager.getInstance().setDebugLogger(this) { + Log.d(kTag, it) + } + val devOpenHelper = DaoMaster.DevOpenHelper(this, "SmartTown.db", null) + val daoMaster = DaoMaster(devOpenHelper.writableDatabase) + daoSession = daoMaster.newSession() + } + + fun obtainDaoSession(): DaoSession { + return daoSession + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java new file mode 100644 index 0000000..b8f67dc --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java @@ -0,0 +1,133 @@ +package com.casic.smart.town.sanxi.bean; + +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Generated; +import org.greenrobot.greendao.annotation.Id; +import org.greenrobot.greendao.annotation.Unique; + +@Entity +public class AlarmMessageLocaleBean { + @Id(autoincrement = true) + private Long id;//主键自增 + + @Unique + private String messageId; + private String appId; + private String clientId; + private String taskId; + private String userId; + private String title; + private String content; + private String deviceCode; + private String isRead;//0-未读,1-已读 + private String alarmTime; + + @Generated(hash = 566950134) + public AlarmMessageLocaleBean(Long id, String messageId, String appId, + String clientId, String taskId, String userId, String title, + String content, String deviceCode, String isRead, String alarmTime) { + this.id = id; + this.messageId = messageId; + this.appId = appId; + this.clientId = clientId; + this.taskId = taskId; + this.userId = userId; + this.title = title; + this.content = content; + this.deviceCode = deviceCode; + this.isRead = isRead; + this.alarmTime = alarmTime; + } + + @Generated(hash = 1737519562) + public AlarmMessageLocaleBean() { + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getMessageId() { + return this.messageId; + } + + public void setMessageId(String messageId) { + this.messageId = messageId; + } + + public String getAppId() { + return this.appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public String getClientId() { + return this.clientId; + } + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public String getTaskId() { + return this.taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getUserId() { + return this.userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getTitle() { + return this.title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return this.content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getDeviceCode() { + return this.deviceCode; + } + + public void setDeviceCode(String deviceCode) { + this.deviceCode = deviceCode; + } + + public String getIsRead() { + return this.isRead; + } + + public void setIsRead(String isRead) { + this.isRead = isRead; + } + + public String getAlarmTime() { + return this.alarmTime; + } + + public void setAlarmTime(String alarmTime) { + this.alarmTime = alarmTime; + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt new file mode 100644 index 0000000..650e201 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class AlarmPageFragment: KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_alarm + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt new file mode 100644 index 0000000..deac8ac --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt @@ -0,0 +1,76 @@ +package com.casic.smart.town.sanxi.fragment + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.Fragment +import com.amap.api.maps.AMap +import com.amap.api.maps.AMapOptions +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.view.MonitorRecordActivity +import com.pengxh.kt.lite.extensions.navigatePageTo +import com.pengxh.kt.lite.extensions.show +import kotlinx.android.synthetic.main.fragment_monitor.view.* + +class MonitorPageFragment : Fragment() { + + private val kTag = "HomePageFragment" + private lateinit var monitorView: View + private lateinit var aMap: AMap + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? + ): View { + monitorView = inflater.inflate(R.layout.fragment_monitor, container, false) + //地图初始化 + initMap(savedInstanceState) + + monitorView.rightOperateView.setOnClickListener { + requireContext().navigatePageTo() + } + return monitorView + } + + private fun initMap(savedInstanceState: Bundle?) { + monitorView.mapView.onCreate(savedInstanceState) + aMap = monitorView.mapView.map + aMap.mapType = AMap.MAP_TYPE_NORMAL + val uiSettings = aMap.uiSettings + uiSettings.isCompassEnabled = true + uiSettings.zoomPosition = AMapOptions.ZOOM_POSITION_RIGHT_CENTER + uiSettings.isTiltGesturesEnabled = false//不许地图随手势倾斜角度 + + // 地图加载成功监听 +// aMap.addOnMapLoadedListener(this) + // 地图缩放监听 +// aMap.addOnCameraChangeListener(this) + // marker 点击事件监听 +// aMap.addOnMarkerClickListener(this) + // 点击marker弹出自定义popup +// aMap.setInfoWindowAdapter(this) + //信息窗点击事件 +// aMap.addOnInfoWindowClickListener(this) + } + + /***以下是地图生命周期管理************************************************************************/ + override fun onResume() { + super.onResume() + monitorView.mapView.onResume() + } + + override fun onPause() { + super.onPause() + monitorView.mapView.onPause() + } + + override fun onSaveInstanceState(outState: Bundle) { + super.onSaveInstanceState(outState) + monitorView.mapView.onSaveInstanceState(outState) + } + + override fun onDestroy() { + super.onDestroy() + monitorView.mapView.onDestroy() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt new file mode 100644 index 0000000..e84df12 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class StatisticsPageFragment : KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_statistics + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java new file mode 100644 index 0000000..68d7901 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java @@ -0,0 +1,255 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.database.Cursor; +import android.database.sqlite.SQLiteStatement; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.Property; +import org.greenrobot.greendao.internal.DaoConfig; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseStatement; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * DAO for table "ALARM_MESSAGE_LOCALE_BEAN". +*/ +public class AlarmMessageLocaleBeanDao extends AbstractDao { + + public static final String TABLENAME = "ALARM_MESSAGE_LOCALE_BEAN"; + + /** + * Properties of entity AlarmMessageLocaleBean.
+ * Can be used for QueryBuilder and for referencing column names. + */ + public static class Properties { + public final static Property Id = new Property(0, Long.class, "id", true, "_id"); + public final static Property MessageId = new Property(1, String.class, "messageId", false, "MESSAGE_ID"); + public final static Property AppId = new Property(2, String.class, "appId", false, "APP_ID"); + public final static Property ClientId = new Property(3, String.class, "clientId", false, "CLIENT_ID"); + public final static Property TaskId = new Property(4, String.class, "taskId", false, "TASK_ID"); + public final static Property UserId = new Property(5, String.class, "userId", false, "USER_ID"); + public final static Property Title = new Property(6, String.class, "title", false, "TITLE"); + public final static Property Content = new Property(7, String.class, "content", false, "CONTENT"); + public final static Property DeviceCode = new Property(8, String.class, "deviceCode", false, "DEVICE_CODE"); + public final static Property IsRead = new Property(9, String.class, "isRead", false, "IS_READ"); + public final static Property AlarmTime = new Property(10, String.class, "alarmTime", false, "ALARM_TIME"); + } + + + public AlarmMessageLocaleBeanDao(DaoConfig config) { + super(config); + } + + public AlarmMessageLocaleBeanDao(DaoConfig config, DaoSession daoSession) { + super(config, daoSession); + } + + /** Creates the underlying database table. */ + public static void createTable(Database db, boolean ifNotExists) { + String constraint = ifNotExists? "IF NOT EXISTS ": ""; + db.execSQL("CREATE TABLE " + constraint + "\"ALARM_MESSAGE_LOCALE_BEAN\" (" + // + "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id + "\"MESSAGE_ID\" TEXT UNIQUE ," + // 1: messageId + "\"APP_ID\" TEXT," + // 2: appId + "\"CLIENT_ID\" TEXT," + // 3: clientId + "\"TASK_ID\" TEXT," + // 4: taskId + "\"USER_ID\" TEXT," + // 5: userId + "\"TITLE\" TEXT," + // 6: title + "\"CONTENT\" TEXT," + // 7: content + "\"DEVICE_CODE\" TEXT," + // 8: deviceCode + "\"IS_READ\" TEXT," + // 9: isRead + "\"ALARM_TIME\" TEXT);"); // 10: alarmTime + } + + /** Drops the underlying database table. */ + public static void dropTable(Database db, boolean ifExists) { + String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"ALARM_MESSAGE_LOCALE_BEAN\""; + db.execSQL(sql); + } + + @Override + protected final void bindValues(DatabaseStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + protected final void bindValues(SQLiteStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + public Long readKey(Cursor cursor, int offset) { + return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); + } + + @Override + public AlarmMessageLocaleBean readEntity(Cursor cursor, int offset) { + AlarmMessageLocaleBean entity = new AlarmMessageLocaleBean( // + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // messageId + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // appId + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // clientId + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // taskId + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // userId + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // title + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // content + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // deviceCode + cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // isRead + cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10) // alarmTime + ); + return entity; + } + + @Override + public void readEntity(Cursor cursor, AlarmMessageLocaleBean entity, int offset) { + entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); + entity.setMessageId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setAppId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setClientId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setTaskId(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); + entity.setUserId(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setTitle(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setContent(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); + entity.setDeviceCode(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); + entity.setIsRead(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9)); + entity.setAlarmTime(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); + } + + @Override + protected final Long updateKeyAfterInsert(AlarmMessageLocaleBean entity, long rowId) { + entity.setId(rowId); + return rowId; + } + + @Override + public Long getKey(AlarmMessageLocaleBean entity) { + if(entity != null) { + return entity.getId(); + } else { + return null; + } + } + + @Override + public boolean hasKey(AlarmMessageLocaleBean entity) { + return entity.getId() != null; + } + + @Override + protected final boolean isEntityUpdateable() { + return true; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java new file mode 100644 index 0000000..4222c40 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java @@ -0,0 +1,96 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.content.Context; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteDatabase.CursorFactory; +import android.util.Log; + +import org.greenrobot.greendao.AbstractDaoMaster; +import org.greenrobot.greendao.database.StandardDatabase; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseOpenHelper; +import org.greenrobot.greendao.identityscope.IdentityScopeType; + + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * Master of DAO (schema version 1): knows all DAOs. + */ +public class DaoMaster extends AbstractDaoMaster { + public static final int SCHEMA_VERSION = 1; + + /** Creates underlying database table using DAOs. */ + public static void createAllTables(Database db, boolean ifNotExists) { + AlarmMessageLocaleBeanDao.createTable(db, ifNotExists); + } + + /** Drops underlying database table using DAOs. */ + public static void dropAllTables(Database db, boolean ifExists) { + AlarmMessageLocaleBeanDao.dropTable(db, ifExists); + } + + /** + * WARNING: Drops all table on Upgrade! Use only during development. + * Convenience method using a {@link DevOpenHelper}. + */ + public static DaoSession newDevSession(Context context, String name) { + Database db = new DevOpenHelper(context, name).getWritableDb(); + DaoMaster daoMaster = new DaoMaster(db); + return daoMaster.newSession(); + } + + public DaoMaster(SQLiteDatabase db) { + this(new StandardDatabase(db)); + } + + public DaoMaster(Database db) { + super(db, SCHEMA_VERSION); + registerDaoClass(AlarmMessageLocaleBeanDao.class); + } + + public DaoSession newSession() { + return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); + } + + public DaoSession newSession(IdentityScopeType type) { + return new DaoSession(db, type, daoConfigMap); + } + + /** + * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} - + */ + public static abstract class OpenHelper extends DatabaseOpenHelper { + public OpenHelper(Context context, String name) { + super(context, name, SCHEMA_VERSION); + } + + public OpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory, SCHEMA_VERSION); + } + + @Override + public void onCreate(Database db) { + Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); + createAllTables(db, false); + } + } + + /** WARNING: Drops all table on Upgrade! Use only during development. */ + public static class DevOpenHelper extends OpenHelper { + public DevOpenHelper(Context context, String name) { + super(context, name); + } + + public DevOpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory); + } + + @Override + public void onUpgrade(Database db, int oldVersion, int newVersion) { + Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); + dropAllTables(db, true); + onCreate(db); + } + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java new file mode 100644 index 0000000..480ed84 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java @@ -0,0 +1,48 @@ +package com.casic.smart.town.sanxi.greendao; + +import java.util.Map; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.AbstractDaoSession; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.identityscope.IdentityScopeType; +import org.greenrobot.greendao.internal.DaoConfig; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. + +/** + * {@inheritDoc} + * + * @see org.greenrobot.greendao.AbstractDaoSession + */ +public class DaoSession extends AbstractDaoSession { + + private final DaoConfig alarmMessageLocaleBeanDaoConfig; + + private final AlarmMessageLocaleBeanDao alarmMessageLocaleBeanDao; + + public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> + daoConfigMap) { + super(db); + + alarmMessageLocaleBeanDaoConfig = daoConfigMap.get(AlarmMessageLocaleBeanDao.class).clone(); + alarmMessageLocaleBeanDaoConfig.initIdentityScope(type); + + alarmMessageLocaleBeanDao = new AlarmMessageLocaleBeanDao(alarmMessageLocaleBeanDaoConfig, this); + + registerDao(AlarmMessageLocaleBean.class, alarmMessageLocaleBeanDao); + } + + public void clear() { + alarmMessageLocaleBeanDaoConfig.clearIdentityScope(); + } + + public AlarmMessageLocaleBeanDao getAlarmMessageLocaleBeanDao() { + return alarmMessageLocaleBeanDao; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt new file mode 100644 index 0000000..875cb8c --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt @@ -0,0 +1,5 @@ +package com.casic.smart.town.sanxi.service + +import com.igexin.sdk.PushService + +class ApplicationPushService : PushService() \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt new file mode 100644 index 0000000..396129f --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt @@ -0,0 +1,84 @@ +package com.casic.smart.town.sanxi.service + +import android.content.Context +import android.os.Message +import android.util.Log +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.casic.smart.town.sanxi.view.MainActivity +import com.igexin.sdk.GTIntentService +import com.igexin.sdk.message.GTCmdMessage +import com.igexin.sdk.message.GTNotificationMessage +import com.igexin.sdk.message.GTTransmitMessage +import com.pengxh.kt.lite.extensions.toJson + +class PushIntentService : GTIntentService() { + + private val kTag = "SmartWellIntentService" + + override fun onReceiveServicePid(context: Context?, pid: Int) { + + } + + // 透传消息 + override fun onReceiveMessageData(context: Context?, msg: GTTransmitMessage?) { + Log.d(kTag, "透传消息 -> msg = $msg") + } + + // 接收 cid + override fun onReceiveClientId(context: Context?, clientid: String?) { + Log.d(kTag, "onReceiveClientId -> $clientid") + //通知MainActivity注册个推服务 + val msg: Message = MainActivity.weakReferenceHandler.obtainMessage() + msg.what = LocaleConstant.PUSH_REGISTER + msg.obj = clientid + MainActivity.weakReferenceHandler.sendMessage(msg) + } + + // cid 离线上线通知 + override fun onReceiveOnlineState(context: Context?, online: Boolean) { + + } + + // 各种事件处理回执 + override fun onReceiveCommandResult(context: Context?, msg: GTCmdMessage?) { + + } + + // 通知到达 + override fun onNotificationMessageArrived(context: Context?, msg: GTNotificationMessage?) { + //报警 +// { +// "content": "设备编号[412022030361]发生井盖开盖报警", +// "messageId": "380abf9a79d34306a2683dc9bf96ee78", +// "taskId": "OSL-0830_4hmfimp3Vu684wo3SjXso9", +// "title": "告警提醒", +// "appid": "HKv8K9qARd6WckZ1o2Vbu4", +// "clientId": "e78beacc42e9a02ae6fb9087eb2b1171", +// "pkgName": "com.casic.app.smartwell" +// } + if (msg == null) { + return + } + Log.d(kTag, "通知到达 -> msg = ${msg.toJson()}") +// val userDetailJson = SaveKeyValues.getValue(LocaleConstant.USER_DETAIL_MODEL, "") as String +// var userId = "" +// if (userDetailJson.isNotBlank()) { +// val userDataModel = Gson().fromJson( +// userDetailJson, object : TypeToken() {}.type +// ) +// userId = userDataModel.id.toString() +// } +// //解析编号 +// val splitArray = msg.content.split("\\[|\\]".toRegex()) +// DataBaseManager.instance.insertNotice( +// msg.messageId, msg.appid, msg.clientId, msg.taskId, +// userId, msg.title, msg.content, splitArray[1], "0", +// System.currentTimeMillis().timestampToCompleteDate() +// ) + } + + // 通知点击 + override fun onNotificationMessageClicked(context: Context?, msg: GTNotificationMessage?) { + Log.d(kTag, "通知点击 -> msg = $msg") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt new file mode 100644 index 0000000..daa7c38 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt @@ -0,0 +1,14 @@ +package com.casic.smart.town.sanxi.util + +import android.content.Context +import me.leolin.shortcutbadger.ShortcutBadger + +object BadeHelper { + fun setBadgeNum(context: Context, badgeCount: Int) { + if (badgeCount == 0) { + ShortcutBadger.removeCount(context) + } else { + ShortcutBadger.applyCount(context, badgeCount) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt new file mode 100644 index 0000000..0a52ef2 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt @@ -0,0 +1,75 @@ +package com.casic.smart.town.sanxi.util + +import com.casic.smart.town.sanxi.base.BaseApplication +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao + +class DataBaseManager private constructor() { + + companion object { + //Kotlin委托模式双重锁单例 + val instance: DataBaseManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) { + DataBaseManager() + } + } + + private val beanDao = + BaseApplication.obtainInstance().obtainDaoSession().alarmMessageLocaleBeanDao + +// fun insertNotice( +// messageId: String, appid: String, clientId: String, +// taskId: String, userId: String, title: String, +// content: String, deviceCode: String, isRead: String, +// noticeTime: String +// ) { +// val noticeLocaleBean = NoticeLocaleBean() +// noticeLocaleBean.messageId = messageId +// noticeLocaleBean.appid = appid +// noticeLocaleBean.clientId = clientId +// noticeLocaleBean.taskId = taskId +// noticeLocaleBean.userId = userId +// noticeLocaleBean.title = title +// noticeLocaleBean.content = content +// noticeLocaleBean.deviceCode = deviceCode +// noticeLocaleBean.isRead = isRead +// noticeLocaleBean.noticeTime = noticeTime +// beanDao.insert(noticeLocaleBean) +// //角标设置 +// BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadNotice()) +// } + + fun deleteByMessageId(messageId: String) { + val result = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).list() + beanDao.deleteInTx(result) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun updateNoticeByMessageId(messageId: String) { + val noticeLocaleBean = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).unique() ?: return + noticeLocaleBean.isRead = "1" + beanDao.update(noticeLocaleBean) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun queryMessageByPage(userId: String, offset: Int): MutableList { + return BaseApplication.obtainInstance().obtainDaoSession() + .queryBuilder(AlarmMessageLocaleBean::class.java) + .where(AlarmMessageLocaleBeanDao.Properties.UserId.eq(userId)) + .offset(offset * LocaleConstant.PAGE_LIMIT) + .orderDesc(AlarmMessageLocaleBeanDao.Properties.AlarmTime) + .limit(LocaleConstant.PAGE_LIMIT) + .list() + } + + private fun queryUnReadMessage(): Int { + return beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.IsRead.eq("0") + ).list().size + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt new file mode 100644 index 0000000..52926a8 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt @@ -0,0 +1,31 @@ +package com.casic.smart.town.sanxi.util; + +import android.app.Activity +import android.view.WindowManager +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object LoadingDialogHub { + private lateinit var loadingDialog: QMUITipDialog + + fun show(activity: Activity, message: String) { + loadingDialog = QMUITipDialog + .Builder(activity) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_LOADING) + .setTipWord(message) + .create() + if (!activity.isDestroyed) { + try { + loadingDialog.show() + } catch (e: WindowManager.BadTokenException) { + e.printStackTrace() + } + } + } + + + fun dismiss() { + if (loadingDialog.isShowing) { + loadingDialog.dismiss() + } + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt new file mode 100644 index 0000000..de61c9a --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.util + +import android.Manifest + +object LocaleConstant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.READ_PHONE_STATE, + Manifest.permission.ACCESS_COARSE_LOCATION, + Manifest.permission.READ_EXTERNAL_STORAGE + ) + + const val PERMISSIONS_CODE = 999 + const val PUSH_REGISTER = 2022100101 + const val PAGE_LIMIT = 20 +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt new file mode 100644 index 0000000..3bea1c9 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt @@ -0,0 +1,112 @@ +package com.casic.smart.town.sanxi.view + +import android.view.KeyEvent +import android.view.MenuItem +import androidx.fragment.app.Fragment +import androidx.viewpager.widget.ViewPager +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.adapter.ViewPagerAdapter +import com.casic.smart.town.sanxi.fragment.AlarmPageFragment +import com.casic.smart.town.sanxi.fragment.MonitorPageFragment +import com.casic.smart.town.sanxi.fragment.StatisticsPageFragment +import com.gyf.immersionbar.ImmersionBar +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.base.KotlinBaseActivity +import com.pengxh.kt.lite.extensions.convertColor +import com.pengxh.kt.lite.extensions.show +import com.pengxh.kt.lite.utils.ImmerseStatusBarUtil +import com.pengxh.kt.lite.utils.WeakReferenceHandler +import kotlinx.android.synthetic.main.activity_main.* + +class MainActivity : KotlinBaseActivity() { + + companion object { + lateinit var weakReferenceHandler: WeakReferenceHandler + } + + private val kTag = "MainActivity" + private var menuItem: MenuItem? = null + private var fragmentPages: ArrayList = ArrayList() + private var clickTime: Long = 0 + + init { + fragmentPages.add(StatisticsPageFragment()) + fragmentPages.add(MonitorPageFragment()) + fragmentPages.add(AlarmPageFragment()) + } + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + ImmersionBar.with(this).statusBarDarkFont(false).init() + ImmerseStatusBarUtil.setColor(this, R.color.mainThemeColor.convertColor(this)) + } + + override fun initData() { + //推送,多次调用 SDK 初始化并无影响。 + PushManager.getInstance().initialize(this) + weakReferenceHandler = WeakReferenceHandler { + + true + } + } + + override fun observeRequestState() { + + } + + override fun initEvent() { + bottomNavigation.itemIconTintList = null + bottomNavigation.setOnNavigationItemSelectedListener { menuItem -> + when (menuItem.itemId) { + R.id.nav_statistics -> { + mainViewPager.currentItem = 0 + } + R.id.nav_monitor -> { + mainViewPager.currentItem = 1 + } + R.id.nav_alarm -> { + mainViewPager.currentItem = 2 + } + } + false + } + mainViewPager.adapter = ViewPagerAdapter(fragmentPages, supportFragmentManager) + mainViewPager.offscreenPageLimit = fragmentPages.size //缓存页数 + mainViewPager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener { + override fun onPageScrollStateChanged(state: Int) { + + } + + override fun onPageScrolled( + position: Int, + positionOffset: Float, + positionOffsetPixels: Int + ) { + + } + + override fun onPageSelected(position: Int) { + if (menuItem != null) { + menuItem!!.isChecked = false + } else { + bottomNavigation.menu.getItem(0).isChecked = false + } + menuItem = bottomNavigation.menu.getItem(position) + menuItem!!.isChecked = true + } + }) + } + + override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean { + return if (keyCode == KeyEvent.KEYCODE_BACK) { + if (System.currentTimeMillis() - clickTime > 2000) { + "再按一次退出程序".show(this) + clickTime = System.currentTimeMillis() + true + } else { + super.onKeyDown(keyCode, event) + } + } else super.onKeyDown(keyCode, event) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt new file mode 100644 index 0000000..c5d8b22 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.view + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseActivity + +class MonitorRecordActivity : KotlinBaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_monitor_record + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt new file mode 100644 index 0000000..c478d83 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt @@ -0,0 +1,55 @@ +package com.casic.smart.town.sanxi.view + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.amap.api.maps.MapsInitializer +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.gyf.immersionbar.ImmersionBar +import com.pengxh.kt.lite.extensions.navigatePageTo +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + ImmersionBar.with(this).statusBarDarkFont(true).init() + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (EasyPermissions.hasPermissions(this, *LocaleConstant.USER_PERMISSIONS)) { + startSplashScreenActivity() + } else { + EasyPermissions.requestPermissions( + this@PermissionActivity, + resources.getString(R.string.app_name) + "需要获取相关权限", + LocaleConstant.PERMISSIONS_CODE, + *LocaleConstant.USER_PERMISSIONS + ) + } + } + + private fun startSplashScreenActivity() { + //先把导航隐私政策声明,后面导航会用到 + MapsInitializer.updatePrivacyAgree(this, true) + MapsInitializer.updatePrivacyShow(this, true, true) + this.navigatePageTo() + 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) { + startSplashScreenActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable/alarm_selector.xml b/app/src/main/res/drawable/alarm_selector.xml new file mode 100644 index 0000000..39b2595 --- /dev/null +++ b/app/src/main/res/drawable/alarm_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bottom_text_color.xml b/app/src/main/res/drawable/bottom_text_color.xml new file mode 100644 index 0000000..b284ea3 --- /dev/null +++ b/app/src/main/res/drawable/bottom_text_color.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_alarm.xml b/app/src/main/res/drawable/ic_alarm.xml new file mode 100644 index 0000000..dc33aab --- /dev/null +++ b/app/src/main/res/drawable/ic_alarm.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_alarm_selected.xml b/app/src/main/res/drawable/ic_alarm_selected.xml new file mode 100644 index 0000000..993fea6 --- /dev/null +++ b/app/src/main/res/drawable/ic_alarm_selected.xml @@ -0,0 +1,9 @@ + + + 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_monitor.xml b/app/src/main/res/drawable/ic_monitor.xml new file mode 100644 index 0000000..271f5b4 --- /dev/null +++ b/app/src/main/res/drawable/ic_monitor.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_monitor_selected.xml b/app/src/main/res/drawable/ic_monitor_selected.xml new file mode 100644 index 0000000..ee62d84 --- /dev/null +++ b/app/src/main/res/drawable/ic_monitor_selected.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_statistics.xml b/app/src/main/res/drawable/ic_statistics.xml new file mode 100644 index 0000000..7fde8ec --- /dev/null +++ b/app/src/main/res/drawable/ic_statistics.xml @@ -0,0 +1,9 @@ + + + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..10cfdbf --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*.iml +.gradle +/local.properties +/.idea +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..a4cd2ca --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,101 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'org.greenrobot.greendao' + +android { +// signingConfigs { +// release { +// storeFile file('/Users/a203/Desktop/AndroidProjects/CasicSmartWell/app/CasicSmartWell.jks') +// storePassword '123456789' +// keyAlias 'key0' +// keyPassword '123456789' +// } +// } + compileSdkVersion 31 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.smart.town.sanxi" + minSdkVersion 23 + targetSdkVersion 31 + versionCode 1 + versionName "1.0.0" + + manifestPlaceholders = [GETUI_APPID: "A9V4DvwLcdAqkFCQuFyhq6"] + } + + buildTypes { + release { + minifyEnabled false +// signingConfig signingConfigs.release + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + + ndk { abiFilters "armeabi", "armeabi-v7a", "arm64-v8" } + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlin { + experimental { + coroutines 'enable' + } + } + + greendao { + schemaVersion 1//数据库版本号 + targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 + daoPackage 'com.casic.smart.town.sanxi.greendao'//设置DaoMaster、DaoSession、Dao包名 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + //基础依赖库 + implementation files('libs/lite-release.aar') + implementation 'androidx.appcompat:appcompat:1.4.2' + implementation 'androidx.core:core-ktx:1.8.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:3.0.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' + //MVVM+LiveData + implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.1" + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0" + implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + //Kotlin协程 + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1' + //图片加载框架 + implementation 'com.github.bumptech.glide:glide:4.9.0' + //返回值转换器 + implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' + implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + //okhttp3日志拦截器 + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //网络请求和接口封装 + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.9.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.9.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' + //高德地图 + implementation 'com.amap.api:3dmap:latest.integration' + //推送SDK + implementation 'com.getui:gtsdk:3.2.10.0' //个推SDK + implementation 'com.getui:gtc:3.1.9.0' //个推核心组件 + //数据库框架 + implementation 'org.greenrobot:greendao:3.3.0' + //桌面角标 + implementation "me.leolin:ShortcutBadger:1.1.22@aar" +} \ No newline at end of file diff --git a/app/libs/lite-release.aar b/app/libs/lite-release.aar new file mode 100644 index 0000000..45da4df --- /dev/null +++ b/app/libs/lite-release.aar Binary files differ diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /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 \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..a83c28a --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/svg/monitor.svg b/app/src/main/assets/svg/monitor.svg new file mode 100644 index 0000000..c8d3e25 --- /dev/null +++ b/app/src/main/assets/svg/monitor.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/msg.svg b/app/src/main/assets/svg/msg.svg new file mode 100644 index 0000000..e864e48 --- /dev/null +++ b/app/src/main/assets/svg/msg.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/statistics.svg b/app/src/main/assets/svg/statistics.svg new file mode 100644 index 0000000..974000e --- /dev/null +++ b/app/src/main/assets/svg/statistics.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt new file mode 100644 index 0000000..6b9cce0 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.adapter + +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentManager +import androidx.fragment.app.FragmentPagerAdapter + +class ViewPagerAdapter(list: ArrayList, manager: FragmentManager) : + FragmentPagerAdapter(manager) { + + private var pageList: List = list + + override fun getItem(position: Int) = pageList[position] + + override fun getCount() = pageList.size +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt new file mode 100644 index 0000000..4e017b1 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt @@ -0,0 +1,40 @@ +package com.casic.smart.town.sanxi.base + +import android.app.Application +import android.util.Log +import com.casic.smart.town.sanxi.greendao.DaoMaster +import com.casic.smart.town.sanxi.greendao.DaoSession +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + private val kTag = "BaseApplication" + + companion object { + private var instance: BaseApplication by Delegates.notNull() + + fun obtainInstance() = instance + + private lateinit var daoSession: DaoSession + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences(this) + //推送 + PushManager.getInstance().initialize(this) + PushManager.getInstance().setDebugLogger(this) { + Log.d(kTag, it) + } + val devOpenHelper = DaoMaster.DevOpenHelper(this, "SmartTown.db", null) + val daoMaster = DaoMaster(devOpenHelper.writableDatabase) + daoSession = daoMaster.newSession() + } + + fun obtainDaoSession(): DaoSession { + return daoSession + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java new file mode 100644 index 0000000..b8f67dc --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java @@ -0,0 +1,133 @@ +package com.casic.smart.town.sanxi.bean; + +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Generated; +import org.greenrobot.greendao.annotation.Id; +import org.greenrobot.greendao.annotation.Unique; + +@Entity +public class AlarmMessageLocaleBean { + @Id(autoincrement = true) + private Long id;//主键自增 + + @Unique + private String messageId; + private String appId; + private String clientId; + private String taskId; + private String userId; + private String title; + private String content; + private String deviceCode; + private String isRead;//0-未读,1-已读 + private String alarmTime; + + @Generated(hash = 566950134) + public AlarmMessageLocaleBean(Long id, String messageId, String appId, + String clientId, String taskId, String userId, String title, + String content, String deviceCode, String isRead, String alarmTime) { + this.id = id; + this.messageId = messageId; + this.appId = appId; + this.clientId = clientId; + this.taskId = taskId; + this.userId = userId; + this.title = title; + this.content = content; + this.deviceCode = deviceCode; + this.isRead = isRead; + this.alarmTime = alarmTime; + } + + @Generated(hash = 1737519562) + public AlarmMessageLocaleBean() { + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getMessageId() { + return this.messageId; + } + + public void setMessageId(String messageId) { + this.messageId = messageId; + } + + public String getAppId() { + return this.appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public String getClientId() { + return this.clientId; + } + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public String getTaskId() { + return this.taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getUserId() { + return this.userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getTitle() { + return this.title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return this.content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getDeviceCode() { + return this.deviceCode; + } + + public void setDeviceCode(String deviceCode) { + this.deviceCode = deviceCode; + } + + public String getIsRead() { + return this.isRead; + } + + public void setIsRead(String isRead) { + this.isRead = isRead; + } + + public String getAlarmTime() { + return this.alarmTime; + } + + public void setAlarmTime(String alarmTime) { + this.alarmTime = alarmTime; + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt new file mode 100644 index 0000000..650e201 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class AlarmPageFragment: KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_alarm + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt new file mode 100644 index 0000000..deac8ac --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt @@ -0,0 +1,76 @@ +package com.casic.smart.town.sanxi.fragment + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.Fragment +import com.amap.api.maps.AMap +import com.amap.api.maps.AMapOptions +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.view.MonitorRecordActivity +import com.pengxh.kt.lite.extensions.navigatePageTo +import com.pengxh.kt.lite.extensions.show +import kotlinx.android.synthetic.main.fragment_monitor.view.* + +class MonitorPageFragment : Fragment() { + + private val kTag = "HomePageFragment" + private lateinit var monitorView: View + private lateinit var aMap: AMap + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? + ): View { + monitorView = inflater.inflate(R.layout.fragment_monitor, container, false) + //地图初始化 + initMap(savedInstanceState) + + monitorView.rightOperateView.setOnClickListener { + requireContext().navigatePageTo() + } + return monitorView + } + + private fun initMap(savedInstanceState: Bundle?) { + monitorView.mapView.onCreate(savedInstanceState) + aMap = monitorView.mapView.map + aMap.mapType = AMap.MAP_TYPE_NORMAL + val uiSettings = aMap.uiSettings + uiSettings.isCompassEnabled = true + uiSettings.zoomPosition = AMapOptions.ZOOM_POSITION_RIGHT_CENTER + uiSettings.isTiltGesturesEnabled = false//不许地图随手势倾斜角度 + + // 地图加载成功监听 +// aMap.addOnMapLoadedListener(this) + // 地图缩放监听 +// aMap.addOnCameraChangeListener(this) + // marker 点击事件监听 +// aMap.addOnMarkerClickListener(this) + // 点击marker弹出自定义popup +// aMap.setInfoWindowAdapter(this) + //信息窗点击事件 +// aMap.addOnInfoWindowClickListener(this) + } + + /***以下是地图生命周期管理************************************************************************/ + override fun onResume() { + super.onResume() + monitorView.mapView.onResume() + } + + override fun onPause() { + super.onPause() + monitorView.mapView.onPause() + } + + override fun onSaveInstanceState(outState: Bundle) { + super.onSaveInstanceState(outState) + monitorView.mapView.onSaveInstanceState(outState) + } + + override fun onDestroy() { + super.onDestroy() + monitorView.mapView.onDestroy() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt new file mode 100644 index 0000000..e84df12 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class StatisticsPageFragment : KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_statistics + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java new file mode 100644 index 0000000..68d7901 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java @@ -0,0 +1,255 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.database.Cursor; +import android.database.sqlite.SQLiteStatement; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.Property; +import org.greenrobot.greendao.internal.DaoConfig; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseStatement; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * DAO for table "ALARM_MESSAGE_LOCALE_BEAN". +*/ +public class AlarmMessageLocaleBeanDao extends AbstractDao { + + public static final String TABLENAME = "ALARM_MESSAGE_LOCALE_BEAN"; + + /** + * Properties of entity AlarmMessageLocaleBean.
+ * Can be used for QueryBuilder and for referencing column names. + */ + public static class Properties { + public final static Property Id = new Property(0, Long.class, "id", true, "_id"); + public final static Property MessageId = new Property(1, String.class, "messageId", false, "MESSAGE_ID"); + public final static Property AppId = new Property(2, String.class, "appId", false, "APP_ID"); + public final static Property ClientId = new Property(3, String.class, "clientId", false, "CLIENT_ID"); + public final static Property TaskId = new Property(4, String.class, "taskId", false, "TASK_ID"); + public final static Property UserId = new Property(5, String.class, "userId", false, "USER_ID"); + public final static Property Title = new Property(6, String.class, "title", false, "TITLE"); + public final static Property Content = new Property(7, String.class, "content", false, "CONTENT"); + public final static Property DeviceCode = new Property(8, String.class, "deviceCode", false, "DEVICE_CODE"); + public final static Property IsRead = new Property(9, String.class, "isRead", false, "IS_READ"); + public final static Property AlarmTime = new Property(10, String.class, "alarmTime", false, "ALARM_TIME"); + } + + + public AlarmMessageLocaleBeanDao(DaoConfig config) { + super(config); + } + + public AlarmMessageLocaleBeanDao(DaoConfig config, DaoSession daoSession) { + super(config, daoSession); + } + + /** Creates the underlying database table. */ + public static void createTable(Database db, boolean ifNotExists) { + String constraint = ifNotExists? "IF NOT EXISTS ": ""; + db.execSQL("CREATE TABLE " + constraint + "\"ALARM_MESSAGE_LOCALE_BEAN\" (" + // + "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id + "\"MESSAGE_ID\" TEXT UNIQUE ," + // 1: messageId + "\"APP_ID\" TEXT," + // 2: appId + "\"CLIENT_ID\" TEXT," + // 3: clientId + "\"TASK_ID\" TEXT," + // 4: taskId + "\"USER_ID\" TEXT," + // 5: userId + "\"TITLE\" TEXT," + // 6: title + "\"CONTENT\" TEXT," + // 7: content + "\"DEVICE_CODE\" TEXT," + // 8: deviceCode + "\"IS_READ\" TEXT," + // 9: isRead + "\"ALARM_TIME\" TEXT);"); // 10: alarmTime + } + + /** Drops the underlying database table. */ + public static void dropTable(Database db, boolean ifExists) { + String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"ALARM_MESSAGE_LOCALE_BEAN\""; + db.execSQL(sql); + } + + @Override + protected final void bindValues(DatabaseStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + protected final void bindValues(SQLiteStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + public Long readKey(Cursor cursor, int offset) { + return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); + } + + @Override + public AlarmMessageLocaleBean readEntity(Cursor cursor, int offset) { + AlarmMessageLocaleBean entity = new AlarmMessageLocaleBean( // + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // messageId + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // appId + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // clientId + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // taskId + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // userId + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // title + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // content + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // deviceCode + cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // isRead + cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10) // alarmTime + ); + return entity; + } + + @Override + public void readEntity(Cursor cursor, AlarmMessageLocaleBean entity, int offset) { + entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); + entity.setMessageId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setAppId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setClientId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setTaskId(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); + entity.setUserId(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setTitle(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setContent(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); + entity.setDeviceCode(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); + entity.setIsRead(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9)); + entity.setAlarmTime(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); + } + + @Override + protected final Long updateKeyAfterInsert(AlarmMessageLocaleBean entity, long rowId) { + entity.setId(rowId); + return rowId; + } + + @Override + public Long getKey(AlarmMessageLocaleBean entity) { + if(entity != null) { + return entity.getId(); + } else { + return null; + } + } + + @Override + public boolean hasKey(AlarmMessageLocaleBean entity) { + return entity.getId() != null; + } + + @Override + protected final boolean isEntityUpdateable() { + return true; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java new file mode 100644 index 0000000..4222c40 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java @@ -0,0 +1,96 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.content.Context; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteDatabase.CursorFactory; +import android.util.Log; + +import org.greenrobot.greendao.AbstractDaoMaster; +import org.greenrobot.greendao.database.StandardDatabase; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseOpenHelper; +import org.greenrobot.greendao.identityscope.IdentityScopeType; + + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * Master of DAO (schema version 1): knows all DAOs. + */ +public class DaoMaster extends AbstractDaoMaster { + public static final int SCHEMA_VERSION = 1; + + /** Creates underlying database table using DAOs. */ + public static void createAllTables(Database db, boolean ifNotExists) { + AlarmMessageLocaleBeanDao.createTable(db, ifNotExists); + } + + /** Drops underlying database table using DAOs. */ + public static void dropAllTables(Database db, boolean ifExists) { + AlarmMessageLocaleBeanDao.dropTable(db, ifExists); + } + + /** + * WARNING: Drops all table on Upgrade! Use only during development. + * Convenience method using a {@link DevOpenHelper}. + */ + public static DaoSession newDevSession(Context context, String name) { + Database db = new DevOpenHelper(context, name).getWritableDb(); + DaoMaster daoMaster = new DaoMaster(db); + return daoMaster.newSession(); + } + + public DaoMaster(SQLiteDatabase db) { + this(new StandardDatabase(db)); + } + + public DaoMaster(Database db) { + super(db, SCHEMA_VERSION); + registerDaoClass(AlarmMessageLocaleBeanDao.class); + } + + public DaoSession newSession() { + return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); + } + + public DaoSession newSession(IdentityScopeType type) { + return new DaoSession(db, type, daoConfigMap); + } + + /** + * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} - + */ + public static abstract class OpenHelper extends DatabaseOpenHelper { + public OpenHelper(Context context, String name) { + super(context, name, SCHEMA_VERSION); + } + + public OpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory, SCHEMA_VERSION); + } + + @Override + public void onCreate(Database db) { + Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); + createAllTables(db, false); + } + } + + /** WARNING: Drops all table on Upgrade! Use only during development. */ + public static class DevOpenHelper extends OpenHelper { + public DevOpenHelper(Context context, String name) { + super(context, name); + } + + public DevOpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory); + } + + @Override + public void onUpgrade(Database db, int oldVersion, int newVersion) { + Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); + dropAllTables(db, true); + onCreate(db); + } + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java new file mode 100644 index 0000000..480ed84 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java @@ -0,0 +1,48 @@ +package com.casic.smart.town.sanxi.greendao; + +import java.util.Map; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.AbstractDaoSession; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.identityscope.IdentityScopeType; +import org.greenrobot.greendao.internal.DaoConfig; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. + +/** + * {@inheritDoc} + * + * @see org.greenrobot.greendao.AbstractDaoSession + */ +public class DaoSession extends AbstractDaoSession { + + private final DaoConfig alarmMessageLocaleBeanDaoConfig; + + private final AlarmMessageLocaleBeanDao alarmMessageLocaleBeanDao; + + public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> + daoConfigMap) { + super(db); + + alarmMessageLocaleBeanDaoConfig = daoConfigMap.get(AlarmMessageLocaleBeanDao.class).clone(); + alarmMessageLocaleBeanDaoConfig.initIdentityScope(type); + + alarmMessageLocaleBeanDao = new AlarmMessageLocaleBeanDao(alarmMessageLocaleBeanDaoConfig, this); + + registerDao(AlarmMessageLocaleBean.class, alarmMessageLocaleBeanDao); + } + + public void clear() { + alarmMessageLocaleBeanDaoConfig.clearIdentityScope(); + } + + public AlarmMessageLocaleBeanDao getAlarmMessageLocaleBeanDao() { + return alarmMessageLocaleBeanDao; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt new file mode 100644 index 0000000..875cb8c --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt @@ -0,0 +1,5 @@ +package com.casic.smart.town.sanxi.service + +import com.igexin.sdk.PushService + +class ApplicationPushService : PushService() \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt new file mode 100644 index 0000000..396129f --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt @@ -0,0 +1,84 @@ +package com.casic.smart.town.sanxi.service + +import android.content.Context +import android.os.Message +import android.util.Log +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.casic.smart.town.sanxi.view.MainActivity +import com.igexin.sdk.GTIntentService +import com.igexin.sdk.message.GTCmdMessage +import com.igexin.sdk.message.GTNotificationMessage +import com.igexin.sdk.message.GTTransmitMessage +import com.pengxh.kt.lite.extensions.toJson + +class PushIntentService : GTIntentService() { + + private val kTag = "SmartWellIntentService" + + override fun onReceiveServicePid(context: Context?, pid: Int) { + + } + + // 透传消息 + override fun onReceiveMessageData(context: Context?, msg: GTTransmitMessage?) { + Log.d(kTag, "透传消息 -> msg = $msg") + } + + // 接收 cid + override fun onReceiveClientId(context: Context?, clientid: String?) { + Log.d(kTag, "onReceiveClientId -> $clientid") + //通知MainActivity注册个推服务 + val msg: Message = MainActivity.weakReferenceHandler.obtainMessage() + msg.what = LocaleConstant.PUSH_REGISTER + msg.obj = clientid + MainActivity.weakReferenceHandler.sendMessage(msg) + } + + // cid 离线上线通知 + override fun onReceiveOnlineState(context: Context?, online: Boolean) { + + } + + // 各种事件处理回执 + override fun onReceiveCommandResult(context: Context?, msg: GTCmdMessage?) { + + } + + // 通知到达 + override fun onNotificationMessageArrived(context: Context?, msg: GTNotificationMessage?) { + //报警 +// { +// "content": "设备编号[412022030361]发生井盖开盖报警", +// "messageId": "380abf9a79d34306a2683dc9bf96ee78", +// "taskId": "OSL-0830_4hmfimp3Vu684wo3SjXso9", +// "title": "告警提醒", +// "appid": "HKv8K9qARd6WckZ1o2Vbu4", +// "clientId": "e78beacc42e9a02ae6fb9087eb2b1171", +// "pkgName": "com.casic.app.smartwell" +// } + if (msg == null) { + return + } + Log.d(kTag, "通知到达 -> msg = ${msg.toJson()}") +// val userDetailJson = SaveKeyValues.getValue(LocaleConstant.USER_DETAIL_MODEL, "") as String +// var userId = "" +// if (userDetailJson.isNotBlank()) { +// val userDataModel = Gson().fromJson( +// userDetailJson, object : TypeToken() {}.type +// ) +// userId = userDataModel.id.toString() +// } +// //解析编号 +// val splitArray = msg.content.split("\\[|\\]".toRegex()) +// DataBaseManager.instance.insertNotice( +// msg.messageId, msg.appid, msg.clientId, msg.taskId, +// userId, msg.title, msg.content, splitArray[1], "0", +// System.currentTimeMillis().timestampToCompleteDate() +// ) + } + + // 通知点击 + override fun onNotificationMessageClicked(context: Context?, msg: GTNotificationMessage?) { + Log.d(kTag, "通知点击 -> msg = $msg") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt new file mode 100644 index 0000000..daa7c38 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt @@ -0,0 +1,14 @@ +package com.casic.smart.town.sanxi.util + +import android.content.Context +import me.leolin.shortcutbadger.ShortcutBadger + +object BadeHelper { + fun setBadgeNum(context: Context, badgeCount: Int) { + if (badgeCount == 0) { + ShortcutBadger.removeCount(context) + } else { + ShortcutBadger.applyCount(context, badgeCount) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt new file mode 100644 index 0000000..0a52ef2 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt @@ -0,0 +1,75 @@ +package com.casic.smart.town.sanxi.util + +import com.casic.smart.town.sanxi.base.BaseApplication +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao + +class DataBaseManager private constructor() { + + companion object { + //Kotlin委托模式双重锁单例 + val instance: DataBaseManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) { + DataBaseManager() + } + } + + private val beanDao = + BaseApplication.obtainInstance().obtainDaoSession().alarmMessageLocaleBeanDao + +// fun insertNotice( +// messageId: String, appid: String, clientId: String, +// taskId: String, userId: String, title: String, +// content: String, deviceCode: String, isRead: String, +// noticeTime: String +// ) { +// val noticeLocaleBean = NoticeLocaleBean() +// noticeLocaleBean.messageId = messageId +// noticeLocaleBean.appid = appid +// noticeLocaleBean.clientId = clientId +// noticeLocaleBean.taskId = taskId +// noticeLocaleBean.userId = userId +// noticeLocaleBean.title = title +// noticeLocaleBean.content = content +// noticeLocaleBean.deviceCode = deviceCode +// noticeLocaleBean.isRead = isRead +// noticeLocaleBean.noticeTime = noticeTime +// beanDao.insert(noticeLocaleBean) +// //角标设置 +// BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadNotice()) +// } + + fun deleteByMessageId(messageId: String) { + val result = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).list() + beanDao.deleteInTx(result) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun updateNoticeByMessageId(messageId: String) { + val noticeLocaleBean = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).unique() ?: return + noticeLocaleBean.isRead = "1" + beanDao.update(noticeLocaleBean) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun queryMessageByPage(userId: String, offset: Int): MutableList { + return BaseApplication.obtainInstance().obtainDaoSession() + .queryBuilder(AlarmMessageLocaleBean::class.java) + .where(AlarmMessageLocaleBeanDao.Properties.UserId.eq(userId)) + .offset(offset * LocaleConstant.PAGE_LIMIT) + .orderDesc(AlarmMessageLocaleBeanDao.Properties.AlarmTime) + .limit(LocaleConstant.PAGE_LIMIT) + .list() + } + + private fun queryUnReadMessage(): Int { + return beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.IsRead.eq("0") + ).list().size + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt new file mode 100644 index 0000000..52926a8 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt @@ -0,0 +1,31 @@ +package com.casic.smart.town.sanxi.util; + +import android.app.Activity +import android.view.WindowManager +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object LoadingDialogHub { + private lateinit var loadingDialog: QMUITipDialog + + fun show(activity: Activity, message: String) { + loadingDialog = QMUITipDialog + .Builder(activity) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_LOADING) + .setTipWord(message) + .create() + if (!activity.isDestroyed) { + try { + loadingDialog.show() + } catch (e: WindowManager.BadTokenException) { + e.printStackTrace() + } + } + } + + + fun dismiss() { + if (loadingDialog.isShowing) { + loadingDialog.dismiss() + } + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt new file mode 100644 index 0000000..de61c9a --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.util + +import android.Manifest + +object LocaleConstant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.READ_PHONE_STATE, + Manifest.permission.ACCESS_COARSE_LOCATION, + Manifest.permission.READ_EXTERNAL_STORAGE + ) + + const val PERMISSIONS_CODE = 999 + const val PUSH_REGISTER = 2022100101 + const val PAGE_LIMIT = 20 +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt new file mode 100644 index 0000000..3bea1c9 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt @@ -0,0 +1,112 @@ +package com.casic.smart.town.sanxi.view + +import android.view.KeyEvent +import android.view.MenuItem +import androidx.fragment.app.Fragment +import androidx.viewpager.widget.ViewPager +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.adapter.ViewPagerAdapter +import com.casic.smart.town.sanxi.fragment.AlarmPageFragment +import com.casic.smart.town.sanxi.fragment.MonitorPageFragment +import com.casic.smart.town.sanxi.fragment.StatisticsPageFragment +import com.gyf.immersionbar.ImmersionBar +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.base.KotlinBaseActivity +import com.pengxh.kt.lite.extensions.convertColor +import com.pengxh.kt.lite.extensions.show +import com.pengxh.kt.lite.utils.ImmerseStatusBarUtil +import com.pengxh.kt.lite.utils.WeakReferenceHandler +import kotlinx.android.synthetic.main.activity_main.* + +class MainActivity : KotlinBaseActivity() { + + companion object { + lateinit var weakReferenceHandler: WeakReferenceHandler + } + + private val kTag = "MainActivity" + private var menuItem: MenuItem? = null + private var fragmentPages: ArrayList = ArrayList() + private var clickTime: Long = 0 + + init { + fragmentPages.add(StatisticsPageFragment()) + fragmentPages.add(MonitorPageFragment()) + fragmentPages.add(AlarmPageFragment()) + } + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + ImmersionBar.with(this).statusBarDarkFont(false).init() + ImmerseStatusBarUtil.setColor(this, R.color.mainThemeColor.convertColor(this)) + } + + override fun initData() { + //推送,多次调用 SDK 初始化并无影响。 + PushManager.getInstance().initialize(this) + weakReferenceHandler = WeakReferenceHandler { + + true + } + } + + override fun observeRequestState() { + + } + + override fun initEvent() { + bottomNavigation.itemIconTintList = null + bottomNavigation.setOnNavigationItemSelectedListener { menuItem -> + when (menuItem.itemId) { + R.id.nav_statistics -> { + mainViewPager.currentItem = 0 + } + R.id.nav_monitor -> { + mainViewPager.currentItem = 1 + } + R.id.nav_alarm -> { + mainViewPager.currentItem = 2 + } + } + false + } + mainViewPager.adapter = ViewPagerAdapter(fragmentPages, supportFragmentManager) + mainViewPager.offscreenPageLimit = fragmentPages.size //缓存页数 + mainViewPager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener { + override fun onPageScrollStateChanged(state: Int) { + + } + + override fun onPageScrolled( + position: Int, + positionOffset: Float, + positionOffsetPixels: Int + ) { + + } + + override fun onPageSelected(position: Int) { + if (menuItem != null) { + menuItem!!.isChecked = false + } else { + bottomNavigation.menu.getItem(0).isChecked = false + } + menuItem = bottomNavigation.menu.getItem(position) + menuItem!!.isChecked = true + } + }) + } + + override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean { + return if (keyCode == KeyEvent.KEYCODE_BACK) { + if (System.currentTimeMillis() - clickTime > 2000) { + "再按一次退出程序".show(this) + clickTime = System.currentTimeMillis() + true + } else { + super.onKeyDown(keyCode, event) + } + } else super.onKeyDown(keyCode, event) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt new file mode 100644 index 0000000..c5d8b22 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.view + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseActivity + +class MonitorRecordActivity : KotlinBaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_monitor_record + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt new file mode 100644 index 0000000..c478d83 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt @@ -0,0 +1,55 @@ +package com.casic.smart.town.sanxi.view + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.amap.api.maps.MapsInitializer +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.gyf.immersionbar.ImmersionBar +import com.pengxh.kt.lite.extensions.navigatePageTo +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + ImmersionBar.with(this).statusBarDarkFont(true).init() + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (EasyPermissions.hasPermissions(this, *LocaleConstant.USER_PERMISSIONS)) { + startSplashScreenActivity() + } else { + EasyPermissions.requestPermissions( + this@PermissionActivity, + resources.getString(R.string.app_name) + "需要获取相关权限", + LocaleConstant.PERMISSIONS_CODE, + *LocaleConstant.USER_PERMISSIONS + ) + } + } + + private fun startSplashScreenActivity() { + //先把导航隐私政策声明,后面导航会用到 + MapsInitializer.updatePrivacyAgree(this, true) + MapsInitializer.updatePrivacyShow(this, true, true) + this.navigatePageTo() + 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) { + startSplashScreenActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable/alarm_selector.xml b/app/src/main/res/drawable/alarm_selector.xml new file mode 100644 index 0000000..39b2595 --- /dev/null +++ b/app/src/main/res/drawable/alarm_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bottom_text_color.xml b/app/src/main/res/drawable/bottom_text_color.xml new file mode 100644 index 0000000..b284ea3 --- /dev/null +++ b/app/src/main/res/drawable/bottom_text_color.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_alarm.xml b/app/src/main/res/drawable/ic_alarm.xml new file mode 100644 index 0000000..dc33aab --- /dev/null +++ b/app/src/main/res/drawable/ic_alarm.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_alarm_selected.xml b/app/src/main/res/drawable/ic_alarm_selected.xml new file mode 100644 index 0000000..993fea6 --- /dev/null +++ b/app/src/main/res/drawable/ic_alarm_selected.xml @@ -0,0 +1,9 @@ + + + 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_monitor.xml b/app/src/main/res/drawable/ic_monitor.xml new file mode 100644 index 0000000..271f5b4 --- /dev/null +++ b/app/src/main/res/drawable/ic_monitor.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_monitor_selected.xml b/app/src/main/res/drawable/ic_monitor_selected.xml new file mode 100644 index 0000000..ee62d84 --- /dev/null +++ b/app/src/main/res/drawable/ic_monitor_selected.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_statistics.xml b/app/src/main/res/drawable/ic_statistics.xml new file mode 100644 index 0000000..7fde8ec --- /dev/null +++ b/app/src/main/res/drawable/ic_statistics.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_statistics_selected.xml b/app/src/main/res/drawable/ic_statistics_selected.xml new file mode 100644 index 0000000..49b6fcd --- /dev/null +++ b/app/src/main/res/drawable/ic_statistics_selected.xml @@ -0,0 +1,9 @@ + + + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..10cfdbf --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*.iml +.gradle +/local.properties +/.idea +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..a4cd2ca --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,101 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'org.greenrobot.greendao' + +android { +// signingConfigs { +// release { +// storeFile file('/Users/a203/Desktop/AndroidProjects/CasicSmartWell/app/CasicSmartWell.jks') +// storePassword '123456789' +// keyAlias 'key0' +// keyPassword '123456789' +// } +// } + compileSdkVersion 31 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.smart.town.sanxi" + minSdkVersion 23 + targetSdkVersion 31 + versionCode 1 + versionName "1.0.0" + + manifestPlaceholders = [GETUI_APPID: "A9V4DvwLcdAqkFCQuFyhq6"] + } + + buildTypes { + release { + minifyEnabled false +// signingConfig signingConfigs.release + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + + ndk { abiFilters "armeabi", "armeabi-v7a", "arm64-v8" } + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlin { + experimental { + coroutines 'enable' + } + } + + greendao { + schemaVersion 1//数据库版本号 + targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 + daoPackage 'com.casic.smart.town.sanxi.greendao'//设置DaoMaster、DaoSession、Dao包名 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + //基础依赖库 + implementation files('libs/lite-release.aar') + implementation 'androidx.appcompat:appcompat:1.4.2' + implementation 'androidx.core:core-ktx:1.8.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:3.0.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' + //MVVM+LiveData + implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.1" + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0" + implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + //Kotlin协程 + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1' + //图片加载框架 + implementation 'com.github.bumptech.glide:glide:4.9.0' + //返回值转换器 + implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' + implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + //okhttp3日志拦截器 + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //网络请求和接口封装 + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.9.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.9.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' + //高德地图 + implementation 'com.amap.api:3dmap:latest.integration' + //推送SDK + implementation 'com.getui:gtsdk:3.2.10.0' //个推SDK + implementation 'com.getui:gtc:3.1.9.0' //个推核心组件 + //数据库框架 + implementation 'org.greenrobot:greendao:3.3.0' + //桌面角标 + implementation "me.leolin:ShortcutBadger:1.1.22@aar" +} \ No newline at end of file diff --git a/app/libs/lite-release.aar b/app/libs/lite-release.aar new file mode 100644 index 0000000..45da4df --- /dev/null +++ b/app/libs/lite-release.aar Binary files differ diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /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 \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..a83c28a --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/svg/monitor.svg b/app/src/main/assets/svg/monitor.svg new file mode 100644 index 0000000..c8d3e25 --- /dev/null +++ b/app/src/main/assets/svg/monitor.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/msg.svg b/app/src/main/assets/svg/msg.svg new file mode 100644 index 0000000..e864e48 --- /dev/null +++ b/app/src/main/assets/svg/msg.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/statistics.svg b/app/src/main/assets/svg/statistics.svg new file mode 100644 index 0000000..974000e --- /dev/null +++ b/app/src/main/assets/svg/statistics.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt new file mode 100644 index 0000000..6b9cce0 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.adapter + +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentManager +import androidx.fragment.app.FragmentPagerAdapter + +class ViewPagerAdapter(list: ArrayList, manager: FragmentManager) : + FragmentPagerAdapter(manager) { + + private var pageList: List = list + + override fun getItem(position: Int) = pageList[position] + + override fun getCount() = pageList.size +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt new file mode 100644 index 0000000..4e017b1 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt @@ -0,0 +1,40 @@ +package com.casic.smart.town.sanxi.base + +import android.app.Application +import android.util.Log +import com.casic.smart.town.sanxi.greendao.DaoMaster +import com.casic.smart.town.sanxi.greendao.DaoSession +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + private val kTag = "BaseApplication" + + companion object { + private var instance: BaseApplication by Delegates.notNull() + + fun obtainInstance() = instance + + private lateinit var daoSession: DaoSession + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences(this) + //推送 + PushManager.getInstance().initialize(this) + PushManager.getInstance().setDebugLogger(this) { + Log.d(kTag, it) + } + val devOpenHelper = DaoMaster.DevOpenHelper(this, "SmartTown.db", null) + val daoMaster = DaoMaster(devOpenHelper.writableDatabase) + daoSession = daoMaster.newSession() + } + + fun obtainDaoSession(): DaoSession { + return daoSession + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java new file mode 100644 index 0000000..b8f67dc --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java @@ -0,0 +1,133 @@ +package com.casic.smart.town.sanxi.bean; + +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Generated; +import org.greenrobot.greendao.annotation.Id; +import org.greenrobot.greendao.annotation.Unique; + +@Entity +public class AlarmMessageLocaleBean { + @Id(autoincrement = true) + private Long id;//主键自增 + + @Unique + private String messageId; + private String appId; + private String clientId; + private String taskId; + private String userId; + private String title; + private String content; + private String deviceCode; + private String isRead;//0-未读,1-已读 + private String alarmTime; + + @Generated(hash = 566950134) + public AlarmMessageLocaleBean(Long id, String messageId, String appId, + String clientId, String taskId, String userId, String title, + String content, String deviceCode, String isRead, String alarmTime) { + this.id = id; + this.messageId = messageId; + this.appId = appId; + this.clientId = clientId; + this.taskId = taskId; + this.userId = userId; + this.title = title; + this.content = content; + this.deviceCode = deviceCode; + this.isRead = isRead; + this.alarmTime = alarmTime; + } + + @Generated(hash = 1737519562) + public AlarmMessageLocaleBean() { + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getMessageId() { + return this.messageId; + } + + public void setMessageId(String messageId) { + this.messageId = messageId; + } + + public String getAppId() { + return this.appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public String getClientId() { + return this.clientId; + } + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public String getTaskId() { + return this.taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getUserId() { + return this.userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getTitle() { + return this.title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return this.content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getDeviceCode() { + return this.deviceCode; + } + + public void setDeviceCode(String deviceCode) { + this.deviceCode = deviceCode; + } + + public String getIsRead() { + return this.isRead; + } + + public void setIsRead(String isRead) { + this.isRead = isRead; + } + + public String getAlarmTime() { + return this.alarmTime; + } + + public void setAlarmTime(String alarmTime) { + this.alarmTime = alarmTime; + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt new file mode 100644 index 0000000..650e201 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class AlarmPageFragment: KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_alarm + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt new file mode 100644 index 0000000..deac8ac --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt @@ -0,0 +1,76 @@ +package com.casic.smart.town.sanxi.fragment + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.Fragment +import com.amap.api.maps.AMap +import com.amap.api.maps.AMapOptions +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.view.MonitorRecordActivity +import com.pengxh.kt.lite.extensions.navigatePageTo +import com.pengxh.kt.lite.extensions.show +import kotlinx.android.synthetic.main.fragment_monitor.view.* + +class MonitorPageFragment : Fragment() { + + private val kTag = "HomePageFragment" + private lateinit var monitorView: View + private lateinit var aMap: AMap + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? + ): View { + monitorView = inflater.inflate(R.layout.fragment_monitor, container, false) + //地图初始化 + initMap(savedInstanceState) + + monitorView.rightOperateView.setOnClickListener { + requireContext().navigatePageTo() + } + return monitorView + } + + private fun initMap(savedInstanceState: Bundle?) { + monitorView.mapView.onCreate(savedInstanceState) + aMap = monitorView.mapView.map + aMap.mapType = AMap.MAP_TYPE_NORMAL + val uiSettings = aMap.uiSettings + uiSettings.isCompassEnabled = true + uiSettings.zoomPosition = AMapOptions.ZOOM_POSITION_RIGHT_CENTER + uiSettings.isTiltGesturesEnabled = false//不许地图随手势倾斜角度 + + // 地图加载成功监听 +// aMap.addOnMapLoadedListener(this) + // 地图缩放监听 +// aMap.addOnCameraChangeListener(this) + // marker 点击事件监听 +// aMap.addOnMarkerClickListener(this) + // 点击marker弹出自定义popup +// aMap.setInfoWindowAdapter(this) + //信息窗点击事件 +// aMap.addOnInfoWindowClickListener(this) + } + + /***以下是地图生命周期管理************************************************************************/ + override fun onResume() { + super.onResume() + monitorView.mapView.onResume() + } + + override fun onPause() { + super.onPause() + monitorView.mapView.onPause() + } + + override fun onSaveInstanceState(outState: Bundle) { + super.onSaveInstanceState(outState) + monitorView.mapView.onSaveInstanceState(outState) + } + + override fun onDestroy() { + super.onDestroy() + monitorView.mapView.onDestroy() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt new file mode 100644 index 0000000..e84df12 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class StatisticsPageFragment : KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_statistics + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java new file mode 100644 index 0000000..68d7901 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java @@ -0,0 +1,255 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.database.Cursor; +import android.database.sqlite.SQLiteStatement; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.Property; +import org.greenrobot.greendao.internal.DaoConfig; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseStatement; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * DAO for table "ALARM_MESSAGE_LOCALE_BEAN". +*/ +public class AlarmMessageLocaleBeanDao extends AbstractDao { + + public static final String TABLENAME = "ALARM_MESSAGE_LOCALE_BEAN"; + + /** + * Properties of entity AlarmMessageLocaleBean.
+ * Can be used for QueryBuilder and for referencing column names. + */ + public static class Properties { + public final static Property Id = new Property(0, Long.class, "id", true, "_id"); + public final static Property MessageId = new Property(1, String.class, "messageId", false, "MESSAGE_ID"); + public final static Property AppId = new Property(2, String.class, "appId", false, "APP_ID"); + public final static Property ClientId = new Property(3, String.class, "clientId", false, "CLIENT_ID"); + public final static Property TaskId = new Property(4, String.class, "taskId", false, "TASK_ID"); + public final static Property UserId = new Property(5, String.class, "userId", false, "USER_ID"); + public final static Property Title = new Property(6, String.class, "title", false, "TITLE"); + public final static Property Content = new Property(7, String.class, "content", false, "CONTENT"); + public final static Property DeviceCode = new Property(8, String.class, "deviceCode", false, "DEVICE_CODE"); + public final static Property IsRead = new Property(9, String.class, "isRead", false, "IS_READ"); + public final static Property AlarmTime = new Property(10, String.class, "alarmTime", false, "ALARM_TIME"); + } + + + public AlarmMessageLocaleBeanDao(DaoConfig config) { + super(config); + } + + public AlarmMessageLocaleBeanDao(DaoConfig config, DaoSession daoSession) { + super(config, daoSession); + } + + /** Creates the underlying database table. */ + public static void createTable(Database db, boolean ifNotExists) { + String constraint = ifNotExists? "IF NOT EXISTS ": ""; + db.execSQL("CREATE TABLE " + constraint + "\"ALARM_MESSAGE_LOCALE_BEAN\" (" + // + "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id + "\"MESSAGE_ID\" TEXT UNIQUE ," + // 1: messageId + "\"APP_ID\" TEXT," + // 2: appId + "\"CLIENT_ID\" TEXT," + // 3: clientId + "\"TASK_ID\" TEXT," + // 4: taskId + "\"USER_ID\" TEXT," + // 5: userId + "\"TITLE\" TEXT," + // 6: title + "\"CONTENT\" TEXT," + // 7: content + "\"DEVICE_CODE\" TEXT," + // 8: deviceCode + "\"IS_READ\" TEXT," + // 9: isRead + "\"ALARM_TIME\" TEXT);"); // 10: alarmTime + } + + /** Drops the underlying database table. */ + public static void dropTable(Database db, boolean ifExists) { + String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"ALARM_MESSAGE_LOCALE_BEAN\""; + db.execSQL(sql); + } + + @Override + protected final void bindValues(DatabaseStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + protected final void bindValues(SQLiteStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + public Long readKey(Cursor cursor, int offset) { + return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); + } + + @Override + public AlarmMessageLocaleBean readEntity(Cursor cursor, int offset) { + AlarmMessageLocaleBean entity = new AlarmMessageLocaleBean( // + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // messageId + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // appId + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // clientId + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // taskId + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // userId + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // title + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // content + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // deviceCode + cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // isRead + cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10) // alarmTime + ); + return entity; + } + + @Override + public void readEntity(Cursor cursor, AlarmMessageLocaleBean entity, int offset) { + entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); + entity.setMessageId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setAppId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setClientId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setTaskId(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); + entity.setUserId(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setTitle(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setContent(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); + entity.setDeviceCode(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); + entity.setIsRead(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9)); + entity.setAlarmTime(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); + } + + @Override + protected final Long updateKeyAfterInsert(AlarmMessageLocaleBean entity, long rowId) { + entity.setId(rowId); + return rowId; + } + + @Override + public Long getKey(AlarmMessageLocaleBean entity) { + if(entity != null) { + return entity.getId(); + } else { + return null; + } + } + + @Override + public boolean hasKey(AlarmMessageLocaleBean entity) { + return entity.getId() != null; + } + + @Override + protected final boolean isEntityUpdateable() { + return true; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java new file mode 100644 index 0000000..4222c40 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java @@ -0,0 +1,96 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.content.Context; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteDatabase.CursorFactory; +import android.util.Log; + +import org.greenrobot.greendao.AbstractDaoMaster; +import org.greenrobot.greendao.database.StandardDatabase; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseOpenHelper; +import org.greenrobot.greendao.identityscope.IdentityScopeType; + + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * Master of DAO (schema version 1): knows all DAOs. + */ +public class DaoMaster extends AbstractDaoMaster { + public static final int SCHEMA_VERSION = 1; + + /** Creates underlying database table using DAOs. */ + public static void createAllTables(Database db, boolean ifNotExists) { + AlarmMessageLocaleBeanDao.createTable(db, ifNotExists); + } + + /** Drops underlying database table using DAOs. */ + public static void dropAllTables(Database db, boolean ifExists) { + AlarmMessageLocaleBeanDao.dropTable(db, ifExists); + } + + /** + * WARNING: Drops all table on Upgrade! Use only during development. + * Convenience method using a {@link DevOpenHelper}. + */ + public static DaoSession newDevSession(Context context, String name) { + Database db = new DevOpenHelper(context, name).getWritableDb(); + DaoMaster daoMaster = new DaoMaster(db); + return daoMaster.newSession(); + } + + public DaoMaster(SQLiteDatabase db) { + this(new StandardDatabase(db)); + } + + public DaoMaster(Database db) { + super(db, SCHEMA_VERSION); + registerDaoClass(AlarmMessageLocaleBeanDao.class); + } + + public DaoSession newSession() { + return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); + } + + public DaoSession newSession(IdentityScopeType type) { + return new DaoSession(db, type, daoConfigMap); + } + + /** + * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} - + */ + public static abstract class OpenHelper extends DatabaseOpenHelper { + public OpenHelper(Context context, String name) { + super(context, name, SCHEMA_VERSION); + } + + public OpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory, SCHEMA_VERSION); + } + + @Override + public void onCreate(Database db) { + Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); + createAllTables(db, false); + } + } + + /** WARNING: Drops all table on Upgrade! Use only during development. */ + public static class DevOpenHelper extends OpenHelper { + public DevOpenHelper(Context context, String name) { + super(context, name); + } + + public DevOpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory); + } + + @Override + public void onUpgrade(Database db, int oldVersion, int newVersion) { + Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); + dropAllTables(db, true); + onCreate(db); + } + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java new file mode 100644 index 0000000..480ed84 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java @@ -0,0 +1,48 @@ +package com.casic.smart.town.sanxi.greendao; + +import java.util.Map; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.AbstractDaoSession; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.identityscope.IdentityScopeType; +import org.greenrobot.greendao.internal.DaoConfig; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. + +/** + * {@inheritDoc} + * + * @see org.greenrobot.greendao.AbstractDaoSession + */ +public class DaoSession extends AbstractDaoSession { + + private final DaoConfig alarmMessageLocaleBeanDaoConfig; + + private final AlarmMessageLocaleBeanDao alarmMessageLocaleBeanDao; + + public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> + daoConfigMap) { + super(db); + + alarmMessageLocaleBeanDaoConfig = daoConfigMap.get(AlarmMessageLocaleBeanDao.class).clone(); + alarmMessageLocaleBeanDaoConfig.initIdentityScope(type); + + alarmMessageLocaleBeanDao = new AlarmMessageLocaleBeanDao(alarmMessageLocaleBeanDaoConfig, this); + + registerDao(AlarmMessageLocaleBean.class, alarmMessageLocaleBeanDao); + } + + public void clear() { + alarmMessageLocaleBeanDaoConfig.clearIdentityScope(); + } + + public AlarmMessageLocaleBeanDao getAlarmMessageLocaleBeanDao() { + return alarmMessageLocaleBeanDao; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt new file mode 100644 index 0000000..875cb8c --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt @@ -0,0 +1,5 @@ +package com.casic.smart.town.sanxi.service + +import com.igexin.sdk.PushService + +class ApplicationPushService : PushService() \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt new file mode 100644 index 0000000..396129f --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt @@ -0,0 +1,84 @@ +package com.casic.smart.town.sanxi.service + +import android.content.Context +import android.os.Message +import android.util.Log +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.casic.smart.town.sanxi.view.MainActivity +import com.igexin.sdk.GTIntentService +import com.igexin.sdk.message.GTCmdMessage +import com.igexin.sdk.message.GTNotificationMessage +import com.igexin.sdk.message.GTTransmitMessage +import com.pengxh.kt.lite.extensions.toJson + +class PushIntentService : GTIntentService() { + + private val kTag = "SmartWellIntentService" + + override fun onReceiveServicePid(context: Context?, pid: Int) { + + } + + // 透传消息 + override fun onReceiveMessageData(context: Context?, msg: GTTransmitMessage?) { + Log.d(kTag, "透传消息 -> msg = $msg") + } + + // 接收 cid + override fun onReceiveClientId(context: Context?, clientid: String?) { + Log.d(kTag, "onReceiveClientId -> $clientid") + //通知MainActivity注册个推服务 + val msg: Message = MainActivity.weakReferenceHandler.obtainMessage() + msg.what = LocaleConstant.PUSH_REGISTER + msg.obj = clientid + MainActivity.weakReferenceHandler.sendMessage(msg) + } + + // cid 离线上线通知 + override fun onReceiveOnlineState(context: Context?, online: Boolean) { + + } + + // 各种事件处理回执 + override fun onReceiveCommandResult(context: Context?, msg: GTCmdMessage?) { + + } + + // 通知到达 + override fun onNotificationMessageArrived(context: Context?, msg: GTNotificationMessage?) { + //报警 +// { +// "content": "设备编号[412022030361]发生井盖开盖报警", +// "messageId": "380abf9a79d34306a2683dc9bf96ee78", +// "taskId": "OSL-0830_4hmfimp3Vu684wo3SjXso9", +// "title": "告警提醒", +// "appid": "HKv8K9qARd6WckZ1o2Vbu4", +// "clientId": "e78beacc42e9a02ae6fb9087eb2b1171", +// "pkgName": "com.casic.app.smartwell" +// } + if (msg == null) { + return + } + Log.d(kTag, "通知到达 -> msg = ${msg.toJson()}") +// val userDetailJson = SaveKeyValues.getValue(LocaleConstant.USER_DETAIL_MODEL, "") as String +// var userId = "" +// if (userDetailJson.isNotBlank()) { +// val userDataModel = Gson().fromJson( +// userDetailJson, object : TypeToken() {}.type +// ) +// userId = userDataModel.id.toString() +// } +// //解析编号 +// val splitArray = msg.content.split("\\[|\\]".toRegex()) +// DataBaseManager.instance.insertNotice( +// msg.messageId, msg.appid, msg.clientId, msg.taskId, +// userId, msg.title, msg.content, splitArray[1], "0", +// System.currentTimeMillis().timestampToCompleteDate() +// ) + } + + // 通知点击 + override fun onNotificationMessageClicked(context: Context?, msg: GTNotificationMessage?) { + Log.d(kTag, "通知点击 -> msg = $msg") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt new file mode 100644 index 0000000..daa7c38 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt @@ -0,0 +1,14 @@ +package com.casic.smart.town.sanxi.util + +import android.content.Context +import me.leolin.shortcutbadger.ShortcutBadger + +object BadeHelper { + fun setBadgeNum(context: Context, badgeCount: Int) { + if (badgeCount == 0) { + ShortcutBadger.removeCount(context) + } else { + ShortcutBadger.applyCount(context, badgeCount) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt new file mode 100644 index 0000000..0a52ef2 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt @@ -0,0 +1,75 @@ +package com.casic.smart.town.sanxi.util + +import com.casic.smart.town.sanxi.base.BaseApplication +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao + +class DataBaseManager private constructor() { + + companion object { + //Kotlin委托模式双重锁单例 + val instance: DataBaseManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) { + DataBaseManager() + } + } + + private val beanDao = + BaseApplication.obtainInstance().obtainDaoSession().alarmMessageLocaleBeanDao + +// fun insertNotice( +// messageId: String, appid: String, clientId: String, +// taskId: String, userId: String, title: String, +// content: String, deviceCode: String, isRead: String, +// noticeTime: String +// ) { +// val noticeLocaleBean = NoticeLocaleBean() +// noticeLocaleBean.messageId = messageId +// noticeLocaleBean.appid = appid +// noticeLocaleBean.clientId = clientId +// noticeLocaleBean.taskId = taskId +// noticeLocaleBean.userId = userId +// noticeLocaleBean.title = title +// noticeLocaleBean.content = content +// noticeLocaleBean.deviceCode = deviceCode +// noticeLocaleBean.isRead = isRead +// noticeLocaleBean.noticeTime = noticeTime +// beanDao.insert(noticeLocaleBean) +// //角标设置 +// BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadNotice()) +// } + + fun deleteByMessageId(messageId: String) { + val result = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).list() + beanDao.deleteInTx(result) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun updateNoticeByMessageId(messageId: String) { + val noticeLocaleBean = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).unique() ?: return + noticeLocaleBean.isRead = "1" + beanDao.update(noticeLocaleBean) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun queryMessageByPage(userId: String, offset: Int): MutableList { + return BaseApplication.obtainInstance().obtainDaoSession() + .queryBuilder(AlarmMessageLocaleBean::class.java) + .where(AlarmMessageLocaleBeanDao.Properties.UserId.eq(userId)) + .offset(offset * LocaleConstant.PAGE_LIMIT) + .orderDesc(AlarmMessageLocaleBeanDao.Properties.AlarmTime) + .limit(LocaleConstant.PAGE_LIMIT) + .list() + } + + private fun queryUnReadMessage(): Int { + return beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.IsRead.eq("0") + ).list().size + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt new file mode 100644 index 0000000..52926a8 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt @@ -0,0 +1,31 @@ +package com.casic.smart.town.sanxi.util; + +import android.app.Activity +import android.view.WindowManager +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object LoadingDialogHub { + private lateinit var loadingDialog: QMUITipDialog + + fun show(activity: Activity, message: String) { + loadingDialog = QMUITipDialog + .Builder(activity) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_LOADING) + .setTipWord(message) + .create() + if (!activity.isDestroyed) { + try { + loadingDialog.show() + } catch (e: WindowManager.BadTokenException) { + e.printStackTrace() + } + } + } + + + fun dismiss() { + if (loadingDialog.isShowing) { + loadingDialog.dismiss() + } + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt new file mode 100644 index 0000000..de61c9a --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.util + +import android.Manifest + +object LocaleConstant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.READ_PHONE_STATE, + Manifest.permission.ACCESS_COARSE_LOCATION, + Manifest.permission.READ_EXTERNAL_STORAGE + ) + + const val PERMISSIONS_CODE = 999 + const val PUSH_REGISTER = 2022100101 + const val PAGE_LIMIT = 20 +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt new file mode 100644 index 0000000..3bea1c9 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt @@ -0,0 +1,112 @@ +package com.casic.smart.town.sanxi.view + +import android.view.KeyEvent +import android.view.MenuItem +import androidx.fragment.app.Fragment +import androidx.viewpager.widget.ViewPager +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.adapter.ViewPagerAdapter +import com.casic.smart.town.sanxi.fragment.AlarmPageFragment +import com.casic.smart.town.sanxi.fragment.MonitorPageFragment +import com.casic.smart.town.sanxi.fragment.StatisticsPageFragment +import com.gyf.immersionbar.ImmersionBar +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.base.KotlinBaseActivity +import com.pengxh.kt.lite.extensions.convertColor +import com.pengxh.kt.lite.extensions.show +import com.pengxh.kt.lite.utils.ImmerseStatusBarUtil +import com.pengxh.kt.lite.utils.WeakReferenceHandler +import kotlinx.android.synthetic.main.activity_main.* + +class MainActivity : KotlinBaseActivity() { + + companion object { + lateinit var weakReferenceHandler: WeakReferenceHandler + } + + private val kTag = "MainActivity" + private var menuItem: MenuItem? = null + private var fragmentPages: ArrayList = ArrayList() + private var clickTime: Long = 0 + + init { + fragmentPages.add(StatisticsPageFragment()) + fragmentPages.add(MonitorPageFragment()) + fragmentPages.add(AlarmPageFragment()) + } + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + ImmersionBar.with(this).statusBarDarkFont(false).init() + ImmerseStatusBarUtil.setColor(this, R.color.mainThemeColor.convertColor(this)) + } + + override fun initData() { + //推送,多次调用 SDK 初始化并无影响。 + PushManager.getInstance().initialize(this) + weakReferenceHandler = WeakReferenceHandler { + + true + } + } + + override fun observeRequestState() { + + } + + override fun initEvent() { + bottomNavigation.itemIconTintList = null + bottomNavigation.setOnNavigationItemSelectedListener { menuItem -> + when (menuItem.itemId) { + R.id.nav_statistics -> { + mainViewPager.currentItem = 0 + } + R.id.nav_monitor -> { + mainViewPager.currentItem = 1 + } + R.id.nav_alarm -> { + mainViewPager.currentItem = 2 + } + } + false + } + mainViewPager.adapter = ViewPagerAdapter(fragmentPages, supportFragmentManager) + mainViewPager.offscreenPageLimit = fragmentPages.size //缓存页数 + mainViewPager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener { + override fun onPageScrollStateChanged(state: Int) { + + } + + override fun onPageScrolled( + position: Int, + positionOffset: Float, + positionOffsetPixels: Int + ) { + + } + + override fun onPageSelected(position: Int) { + if (menuItem != null) { + menuItem!!.isChecked = false + } else { + bottomNavigation.menu.getItem(0).isChecked = false + } + menuItem = bottomNavigation.menu.getItem(position) + menuItem!!.isChecked = true + } + }) + } + + override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean { + return if (keyCode == KeyEvent.KEYCODE_BACK) { + if (System.currentTimeMillis() - clickTime > 2000) { + "再按一次退出程序".show(this) + clickTime = System.currentTimeMillis() + true + } else { + super.onKeyDown(keyCode, event) + } + } else super.onKeyDown(keyCode, event) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt new file mode 100644 index 0000000..c5d8b22 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.view + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseActivity + +class MonitorRecordActivity : KotlinBaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_monitor_record + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt new file mode 100644 index 0000000..c478d83 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt @@ -0,0 +1,55 @@ +package com.casic.smart.town.sanxi.view + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.amap.api.maps.MapsInitializer +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.gyf.immersionbar.ImmersionBar +import com.pengxh.kt.lite.extensions.navigatePageTo +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + ImmersionBar.with(this).statusBarDarkFont(true).init() + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (EasyPermissions.hasPermissions(this, *LocaleConstant.USER_PERMISSIONS)) { + startSplashScreenActivity() + } else { + EasyPermissions.requestPermissions( + this@PermissionActivity, + resources.getString(R.string.app_name) + "需要获取相关权限", + LocaleConstant.PERMISSIONS_CODE, + *LocaleConstant.USER_PERMISSIONS + ) + } + } + + private fun startSplashScreenActivity() { + //先把导航隐私政策声明,后面导航会用到 + MapsInitializer.updatePrivacyAgree(this, true) + MapsInitializer.updatePrivacyShow(this, true, true) + this.navigatePageTo() + 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) { + startSplashScreenActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable/alarm_selector.xml b/app/src/main/res/drawable/alarm_selector.xml new file mode 100644 index 0000000..39b2595 --- /dev/null +++ b/app/src/main/res/drawable/alarm_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bottom_text_color.xml b/app/src/main/res/drawable/bottom_text_color.xml new file mode 100644 index 0000000..b284ea3 --- /dev/null +++ b/app/src/main/res/drawable/bottom_text_color.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_alarm.xml b/app/src/main/res/drawable/ic_alarm.xml new file mode 100644 index 0000000..dc33aab --- /dev/null +++ b/app/src/main/res/drawable/ic_alarm.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_alarm_selected.xml b/app/src/main/res/drawable/ic_alarm_selected.xml new file mode 100644 index 0000000..993fea6 --- /dev/null +++ b/app/src/main/res/drawable/ic_alarm_selected.xml @@ -0,0 +1,9 @@ + + + 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_monitor.xml b/app/src/main/res/drawable/ic_monitor.xml new file mode 100644 index 0000000..271f5b4 --- /dev/null +++ b/app/src/main/res/drawable/ic_monitor.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_monitor_selected.xml b/app/src/main/res/drawable/ic_monitor_selected.xml new file mode 100644 index 0000000..ee62d84 --- /dev/null +++ b/app/src/main/res/drawable/ic_monitor_selected.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_statistics.xml b/app/src/main/res/drawable/ic_statistics.xml new file mode 100644 index 0000000..7fde8ec --- /dev/null +++ b/app/src/main/res/drawable/ic_statistics.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_statistics_selected.xml b/app/src/main/res/drawable/ic_statistics_selected.xml new file mode 100644 index 0000000..49b6fcd --- /dev/null +++ b/app/src/main/res/drawable/ic_statistics_selected.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/monitor_selector.xml b/app/src/main/res/drawable/monitor_selector.xml new file mode 100644 index 0000000..fe11e9a --- /dev/null +++ b/app/src/main/res/drawable/monitor_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..10cfdbf --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*.iml +.gradle +/local.properties +/.idea +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..a4cd2ca --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,101 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'org.greenrobot.greendao' + +android { +// signingConfigs { +// release { +// storeFile file('/Users/a203/Desktop/AndroidProjects/CasicSmartWell/app/CasicSmartWell.jks') +// storePassword '123456789' +// keyAlias 'key0' +// keyPassword '123456789' +// } +// } + compileSdkVersion 31 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.smart.town.sanxi" + minSdkVersion 23 + targetSdkVersion 31 + versionCode 1 + versionName "1.0.0" + + manifestPlaceholders = [GETUI_APPID: "A9V4DvwLcdAqkFCQuFyhq6"] + } + + buildTypes { + release { + minifyEnabled false +// signingConfig signingConfigs.release + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + + ndk { abiFilters "armeabi", "armeabi-v7a", "arm64-v8" } + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlin { + experimental { + coroutines 'enable' + } + } + + greendao { + schemaVersion 1//数据库版本号 + targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 + daoPackage 'com.casic.smart.town.sanxi.greendao'//设置DaoMaster、DaoSession、Dao包名 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + //基础依赖库 + implementation files('libs/lite-release.aar') + implementation 'androidx.appcompat:appcompat:1.4.2' + implementation 'androidx.core:core-ktx:1.8.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:3.0.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' + //MVVM+LiveData + implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.1" + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0" + implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + //Kotlin协程 + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1' + //图片加载框架 + implementation 'com.github.bumptech.glide:glide:4.9.0' + //返回值转换器 + implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' + implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + //okhttp3日志拦截器 + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //网络请求和接口封装 + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.9.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.9.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' + //高德地图 + implementation 'com.amap.api:3dmap:latest.integration' + //推送SDK + implementation 'com.getui:gtsdk:3.2.10.0' //个推SDK + implementation 'com.getui:gtc:3.1.9.0' //个推核心组件 + //数据库框架 + implementation 'org.greenrobot:greendao:3.3.0' + //桌面角标 + implementation "me.leolin:ShortcutBadger:1.1.22@aar" +} \ No newline at end of file diff --git a/app/libs/lite-release.aar b/app/libs/lite-release.aar new file mode 100644 index 0000000..45da4df --- /dev/null +++ b/app/libs/lite-release.aar Binary files differ diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /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 \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..a83c28a --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/svg/monitor.svg b/app/src/main/assets/svg/monitor.svg new file mode 100644 index 0000000..c8d3e25 --- /dev/null +++ b/app/src/main/assets/svg/monitor.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/msg.svg b/app/src/main/assets/svg/msg.svg new file mode 100644 index 0000000..e864e48 --- /dev/null +++ b/app/src/main/assets/svg/msg.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/statistics.svg b/app/src/main/assets/svg/statistics.svg new file mode 100644 index 0000000..974000e --- /dev/null +++ b/app/src/main/assets/svg/statistics.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt new file mode 100644 index 0000000..6b9cce0 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.adapter + +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentManager +import androidx.fragment.app.FragmentPagerAdapter + +class ViewPagerAdapter(list: ArrayList, manager: FragmentManager) : + FragmentPagerAdapter(manager) { + + private var pageList: List = list + + override fun getItem(position: Int) = pageList[position] + + override fun getCount() = pageList.size +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt new file mode 100644 index 0000000..4e017b1 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt @@ -0,0 +1,40 @@ +package com.casic.smart.town.sanxi.base + +import android.app.Application +import android.util.Log +import com.casic.smart.town.sanxi.greendao.DaoMaster +import com.casic.smart.town.sanxi.greendao.DaoSession +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + private val kTag = "BaseApplication" + + companion object { + private var instance: BaseApplication by Delegates.notNull() + + fun obtainInstance() = instance + + private lateinit var daoSession: DaoSession + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences(this) + //推送 + PushManager.getInstance().initialize(this) + PushManager.getInstance().setDebugLogger(this) { + Log.d(kTag, it) + } + val devOpenHelper = DaoMaster.DevOpenHelper(this, "SmartTown.db", null) + val daoMaster = DaoMaster(devOpenHelper.writableDatabase) + daoSession = daoMaster.newSession() + } + + fun obtainDaoSession(): DaoSession { + return daoSession + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java new file mode 100644 index 0000000..b8f67dc --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java @@ -0,0 +1,133 @@ +package com.casic.smart.town.sanxi.bean; + +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Generated; +import org.greenrobot.greendao.annotation.Id; +import org.greenrobot.greendao.annotation.Unique; + +@Entity +public class AlarmMessageLocaleBean { + @Id(autoincrement = true) + private Long id;//主键自增 + + @Unique + private String messageId; + private String appId; + private String clientId; + private String taskId; + private String userId; + private String title; + private String content; + private String deviceCode; + private String isRead;//0-未读,1-已读 + private String alarmTime; + + @Generated(hash = 566950134) + public AlarmMessageLocaleBean(Long id, String messageId, String appId, + String clientId, String taskId, String userId, String title, + String content, String deviceCode, String isRead, String alarmTime) { + this.id = id; + this.messageId = messageId; + this.appId = appId; + this.clientId = clientId; + this.taskId = taskId; + this.userId = userId; + this.title = title; + this.content = content; + this.deviceCode = deviceCode; + this.isRead = isRead; + this.alarmTime = alarmTime; + } + + @Generated(hash = 1737519562) + public AlarmMessageLocaleBean() { + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getMessageId() { + return this.messageId; + } + + public void setMessageId(String messageId) { + this.messageId = messageId; + } + + public String getAppId() { + return this.appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public String getClientId() { + return this.clientId; + } + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public String getTaskId() { + return this.taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getUserId() { + return this.userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getTitle() { + return this.title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return this.content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getDeviceCode() { + return this.deviceCode; + } + + public void setDeviceCode(String deviceCode) { + this.deviceCode = deviceCode; + } + + public String getIsRead() { + return this.isRead; + } + + public void setIsRead(String isRead) { + this.isRead = isRead; + } + + public String getAlarmTime() { + return this.alarmTime; + } + + public void setAlarmTime(String alarmTime) { + this.alarmTime = alarmTime; + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt new file mode 100644 index 0000000..650e201 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class AlarmPageFragment: KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_alarm + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt new file mode 100644 index 0000000..deac8ac --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt @@ -0,0 +1,76 @@ +package com.casic.smart.town.sanxi.fragment + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.Fragment +import com.amap.api.maps.AMap +import com.amap.api.maps.AMapOptions +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.view.MonitorRecordActivity +import com.pengxh.kt.lite.extensions.navigatePageTo +import com.pengxh.kt.lite.extensions.show +import kotlinx.android.synthetic.main.fragment_monitor.view.* + +class MonitorPageFragment : Fragment() { + + private val kTag = "HomePageFragment" + private lateinit var monitorView: View + private lateinit var aMap: AMap + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? + ): View { + monitorView = inflater.inflate(R.layout.fragment_monitor, container, false) + //地图初始化 + initMap(savedInstanceState) + + monitorView.rightOperateView.setOnClickListener { + requireContext().navigatePageTo() + } + return monitorView + } + + private fun initMap(savedInstanceState: Bundle?) { + monitorView.mapView.onCreate(savedInstanceState) + aMap = monitorView.mapView.map + aMap.mapType = AMap.MAP_TYPE_NORMAL + val uiSettings = aMap.uiSettings + uiSettings.isCompassEnabled = true + uiSettings.zoomPosition = AMapOptions.ZOOM_POSITION_RIGHT_CENTER + uiSettings.isTiltGesturesEnabled = false//不许地图随手势倾斜角度 + + // 地图加载成功监听 +// aMap.addOnMapLoadedListener(this) + // 地图缩放监听 +// aMap.addOnCameraChangeListener(this) + // marker 点击事件监听 +// aMap.addOnMarkerClickListener(this) + // 点击marker弹出自定义popup +// aMap.setInfoWindowAdapter(this) + //信息窗点击事件 +// aMap.addOnInfoWindowClickListener(this) + } + + /***以下是地图生命周期管理************************************************************************/ + override fun onResume() { + super.onResume() + monitorView.mapView.onResume() + } + + override fun onPause() { + super.onPause() + monitorView.mapView.onPause() + } + + override fun onSaveInstanceState(outState: Bundle) { + super.onSaveInstanceState(outState) + monitorView.mapView.onSaveInstanceState(outState) + } + + override fun onDestroy() { + super.onDestroy() + monitorView.mapView.onDestroy() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt new file mode 100644 index 0000000..e84df12 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class StatisticsPageFragment : KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_statistics + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java new file mode 100644 index 0000000..68d7901 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java @@ -0,0 +1,255 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.database.Cursor; +import android.database.sqlite.SQLiteStatement; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.Property; +import org.greenrobot.greendao.internal.DaoConfig; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseStatement; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * DAO for table "ALARM_MESSAGE_LOCALE_BEAN". +*/ +public class AlarmMessageLocaleBeanDao extends AbstractDao { + + public static final String TABLENAME = "ALARM_MESSAGE_LOCALE_BEAN"; + + /** + * Properties of entity AlarmMessageLocaleBean.
+ * Can be used for QueryBuilder and for referencing column names. + */ + public static class Properties { + public final static Property Id = new Property(0, Long.class, "id", true, "_id"); + public final static Property MessageId = new Property(1, String.class, "messageId", false, "MESSAGE_ID"); + public final static Property AppId = new Property(2, String.class, "appId", false, "APP_ID"); + public final static Property ClientId = new Property(3, String.class, "clientId", false, "CLIENT_ID"); + public final static Property TaskId = new Property(4, String.class, "taskId", false, "TASK_ID"); + public final static Property UserId = new Property(5, String.class, "userId", false, "USER_ID"); + public final static Property Title = new Property(6, String.class, "title", false, "TITLE"); + public final static Property Content = new Property(7, String.class, "content", false, "CONTENT"); + public final static Property DeviceCode = new Property(8, String.class, "deviceCode", false, "DEVICE_CODE"); + public final static Property IsRead = new Property(9, String.class, "isRead", false, "IS_READ"); + public final static Property AlarmTime = new Property(10, String.class, "alarmTime", false, "ALARM_TIME"); + } + + + public AlarmMessageLocaleBeanDao(DaoConfig config) { + super(config); + } + + public AlarmMessageLocaleBeanDao(DaoConfig config, DaoSession daoSession) { + super(config, daoSession); + } + + /** Creates the underlying database table. */ + public static void createTable(Database db, boolean ifNotExists) { + String constraint = ifNotExists? "IF NOT EXISTS ": ""; + db.execSQL("CREATE TABLE " + constraint + "\"ALARM_MESSAGE_LOCALE_BEAN\" (" + // + "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id + "\"MESSAGE_ID\" TEXT UNIQUE ," + // 1: messageId + "\"APP_ID\" TEXT," + // 2: appId + "\"CLIENT_ID\" TEXT," + // 3: clientId + "\"TASK_ID\" TEXT," + // 4: taskId + "\"USER_ID\" TEXT," + // 5: userId + "\"TITLE\" TEXT," + // 6: title + "\"CONTENT\" TEXT," + // 7: content + "\"DEVICE_CODE\" TEXT," + // 8: deviceCode + "\"IS_READ\" TEXT," + // 9: isRead + "\"ALARM_TIME\" TEXT);"); // 10: alarmTime + } + + /** Drops the underlying database table. */ + public static void dropTable(Database db, boolean ifExists) { + String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"ALARM_MESSAGE_LOCALE_BEAN\""; + db.execSQL(sql); + } + + @Override + protected final void bindValues(DatabaseStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + protected final void bindValues(SQLiteStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + public Long readKey(Cursor cursor, int offset) { + return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); + } + + @Override + public AlarmMessageLocaleBean readEntity(Cursor cursor, int offset) { + AlarmMessageLocaleBean entity = new AlarmMessageLocaleBean( // + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // messageId + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // appId + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // clientId + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // taskId + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // userId + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // title + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // content + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // deviceCode + cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // isRead + cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10) // alarmTime + ); + return entity; + } + + @Override + public void readEntity(Cursor cursor, AlarmMessageLocaleBean entity, int offset) { + entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); + entity.setMessageId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setAppId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setClientId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setTaskId(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); + entity.setUserId(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setTitle(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setContent(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); + entity.setDeviceCode(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); + entity.setIsRead(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9)); + entity.setAlarmTime(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); + } + + @Override + protected final Long updateKeyAfterInsert(AlarmMessageLocaleBean entity, long rowId) { + entity.setId(rowId); + return rowId; + } + + @Override + public Long getKey(AlarmMessageLocaleBean entity) { + if(entity != null) { + return entity.getId(); + } else { + return null; + } + } + + @Override + public boolean hasKey(AlarmMessageLocaleBean entity) { + return entity.getId() != null; + } + + @Override + protected final boolean isEntityUpdateable() { + return true; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java new file mode 100644 index 0000000..4222c40 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java @@ -0,0 +1,96 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.content.Context; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteDatabase.CursorFactory; +import android.util.Log; + +import org.greenrobot.greendao.AbstractDaoMaster; +import org.greenrobot.greendao.database.StandardDatabase; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseOpenHelper; +import org.greenrobot.greendao.identityscope.IdentityScopeType; + + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * Master of DAO (schema version 1): knows all DAOs. + */ +public class DaoMaster extends AbstractDaoMaster { + public static final int SCHEMA_VERSION = 1; + + /** Creates underlying database table using DAOs. */ + public static void createAllTables(Database db, boolean ifNotExists) { + AlarmMessageLocaleBeanDao.createTable(db, ifNotExists); + } + + /** Drops underlying database table using DAOs. */ + public static void dropAllTables(Database db, boolean ifExists) { + AlarmMessageLocaleBeanDao.dropTable(db, ifExists); + } + + /** + * WARNING: Drops all table on Upgrade! Use only during development. + * Convenience method using a {@link DevOpenHelper}. + */ + public static DaoSession newDevSession(Context context, String name) { + Database db = new DevOpenHelper(context, name).getWritableDb(); + DaoMaster daoMaster = new DaoMaster(db); + return daoMaster.newSession(); + } + + public DaoMaster(SQLiteDatabase db) { + this(new StandardDatabase(db)); + } + + public DaoMaster(Database db) { + super(db, SCHEMA_VERSION); + registerDaoClass(AlarmMessageLocaleBeanDao.class); + } + + public DaoSession newSession() { + return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); + } + + public DaoSession newSession(IdentityScopeType type) { + return new DaoSession(db, type, daoConfigMap); + } + + /** + * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} - + */ + public static abstract class OpenHelper extends DatabaseOpenHelper { + public OpenHelper(Context context, String name) { + super(context, name, SCHEMA_VERSION); + } + + public OpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory, SCHEMA_VERSION); + } + + @Override + public void onCreate(Database db) { + Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); + createAllTables(db, false); + } + } + + /** WARNING: Drops all table on Upgrade! Use only during development. */ + public static class DevOpenHelper extends OpenHelper { + public DevOpenHelper(Context context, String name) { + super(context, name); + } + + public DevOpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory); + } + + @Override + public void onUpgrade(Database db, int oldVersion, int newVersion) { + Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); + dropAllTables(db, true); + onCreate(db); + } + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java new file mode 100644 index 0000000..480ed84 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java @@ -0,0 +1,48 @@ +package com.casic.smart.town.sanxi.greendao; + +import java.util.Map; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.AbstractDaoSession; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.identityscope.IdentityScopeType; +import org.greenrobot.greendao.internal.DaoConfig; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. + +/** + * {@inheritDoc} + * + * @see org.greenrobot.greendao.AbstractDaoSession + */ +public class DaoSession extends AbstractDaoSession { + + private final DaoConfig alarmMessageLocaleBeanDaoConfig; + + private final AlarmMessageLocaleBeanDao alarmMessageLocaleBeanDao; + + public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> + daoConfigMap) { + super(db); + + alarmMessageLocaleBeanDaoConfig = daoConfigMap.get(AlarmMessageLocaleBeanDao.class).clone(); + alarmMessageLocaleBeanDaoConfig.initIdentityScope(type); + + alarmMessageLocaleBeanDao = new AlarmMessageLocaleBeanDao(alarmMessageLocaleBeanDaoConfig, this); + + registerDao(AlarmMessageLocaleBean.class, alarmMessageLocaleBeanDao); + } + + public void clear() { + alarmMessageLocaleBeanDaoConfig.clearIdentityScope(); + } + + public AlarmMessageLocaleBeanDao getAlarmMessageLocaleBeanDao() { + return alarmMessageLocaleBeanDao; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt new file mode 100644 index 0000000..875cb8c --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt @@ -0,0 +1,5 @@ +package com.casic.smart.town.sanxi.service + +import com.igexin.sdk.PushService + +class ApplicationPushService : PushService() \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt new file mode 100644 index 0000000..396129f --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt @@ -0,0 +1,84 @@ +package com.casic.smart.town.sanxi.service + +import android.content.Context +import android.os.Message +import android.util.Log +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.casic.smart.town.sanxi.view.MainActivity +import com.igexin.sdk.GTIntentService +import com.igexin.sdk.message.GTCmdMessage +import com.igexin.sdk.message.GTNotificationMessage +import com.igexin.sdk.message.GTTransmitMessage +import com.pengxh.kt.lite.extensions.toJson + +class PushIntentService : GTIntentService() { + + private val kTag = "SmartWellIntentService" + + override fun onReceiveServicePid(context: Context?, pid: Int) { + + } + + // 透传消息 + override fun onReceiveMessageData(context: Context?, msg: GTTransmitMessage?) { + Log.d(kTag, "透传消息 -> msg = $msg") + } + + // 接收 cid + override fun onReceiveClientId(context: Context?, clientid: String?) { + Log.d(kTag, "onReceiveClientId -> $clientid") + //通知MainActivity注册个推服务 + val msg: Message = MainActivity.weakReferenceHandler.obtainMessage() + msg.what = LocaleConstant.PUSH_REGISTER + msg.obj = clientid + MainActivity.weakReferenceHandler.sendMessage(msg) + } + + // cid 离线上线通知 + override fun onReceiveOnlineState(context: Context?, online: Boolean) { + + } + + // 各种事件处理回执 + override fun onReceiveCommandResult(context: Context?, msg: GTCmdMessage?) { + + } + + // 通知到达 + override fun onNotificationMessageArrived(context: Context?, msg: GTNotificationMessage?) { + //报警 +// { +// "content": "设备编号[412022030361]发生井盖开盖报警", +// "messageId": "380abf9a79d34306a2683dc9bf96ee78", +// "taskId": "OSL-0830_4hmfimp3Vu684wo3SjXso9", +// "title": "告警提醒", +// "appid": "HKv8K9qARd6WckZ1o2Vbu4", +// "clientId": "e78beacc42e9a02ae6fb9087eb2b1171", +// "pkgName": "com.casic.app.smartwell" +// } + if (msg == null) { + return + } + Log.d(kTag, "通知到达 -> msg = ${msg.toJson()}") +// val userDetailJson = SaveKeyValues.getValue(LocaleConstant.USER_DETAIL_MODEL, "") as String +// var userId = "" +// if (userDetailJson.isNotBlank()) { +// val userDataModel = Gson().fromJson( +// userDetailJson, object : TypeToken() {}.type +// ) +// userId = userDataModel.id.toString() +// } +// //解析编号 +// val splitArray = msg.content.split("\\[|\\]".toRegex()) +// DataBaseManager.instance.insertNotice( +// msg.messageId, msg.appid, msg.clientId, msg.taskId, +// userId, msg.title, msg.content, splitArray[1], "0", +// System.currentTimeMillis().timestampToCompleteDate() +// ) + } + + // 通知点击 + override fun onNotificationMessageClicked(context: Context?, msg: GTNotificationMessage?) { + Log.d(kTag, "通知点击 -> msg = $msg") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt new file mode 100644 index 0000000..daa7c38 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt @@ -0,0 +1,14 @@ +package com.casic.smart.town.sanxi.util + +import android.content.Context +import me.leolin.shortcutbadger.ShortcutBadger + +object BadeHelper { + fun setBadgeNum(context: Context, badgeCount: Int) { + if (badgeCount == 0) { + ShortcutBadger.removeCount(context) + } else { + ShortcutBadger.applyCount(context, badgeCount) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt new file mode 100644 index 0000000..0a52ef2 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt @@ -0,0 +1,75 @@ +package com.casic.smart.town.sanxi.util + +import com.casic.smart.town.sanxi.base.BaseApplication +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao + +class DataBaseManager private constructor() { + + companion object { + //Kotlin委托模式双重锁单例 + val instance: DataBaseManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) { + DataBaseManager() + } + } + + private val beanDao = + BaseApplication.obtainInstance().obtainDaoSession().alarmMessageLocaleBeanDao + +// fun insertNotice( +// messageId: String, appid: String, clientId: String, +// taskId: String, userId: String, title: String, +// content: String, deviceCode: String, isRead: String, +// noticeTime: String +// ) { +// val noticeLocaleBean = NoticeLocaleBean() +// noticeLocaleBean.messageId = messageId +// noticeLocaleBean.appid = appid +// noticeLocaleBean.clientId = clientId +// noticeLocaleBean.taskId = taskId +// noticeLocaleBean.userId = userId +// noticeLocaleBean.title = title +// noticeLocaleBean.content = content +// noticeLocaleBean.deviceCode = deviceCode +// noticeLocaleBean.isRead = isRead +// noticeLocaleBean.noticeTime = noticeTime +// beanDao.insert(noticeLocaleBean) +// //角标设置 +// BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadNotice()) +// } + + fun deleteByMessageId(messageId: String) { + val result = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).list() + beanDao.deleteInTx(result) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun updateNoticeByMessageId(messageId: String) { + val noticeLocaleBean = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).unique() ?: return + noticeLocaleBean.isRead = "1" + beanDao.update(noticeLocaleBean) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun queryMessageByPage(userId: String, offset: Int): MutableList { + return BaseApplication.obtainInstance().obtainDaoSession() + .queryBuilder(AlarmMessageLocaleBean::class.java) + .where(AlarmMessageLocaleBeanDao.Properties.UserId.eq(userId)) + .offset(offset * LocaleConstant.PAGE_LIMIT) + .orderDesc(AlarmMessageLocaleBeanDao.Properties.AlarmTime) + .limit(LocaleConstant.PAGE_LIMIT) + .list() + } + + private fun queryUnReadMessage(): Int { + return beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.IsRead.eq("0") + ).list().size + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt new file mode 100644 index 0000000..52926a8 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt @@ -0,0 +1,31 @@ +package com.casic.smart.town.sanxi.util; + +import android.app.Activity +import android.view.WindowManager +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object LoadingDialogHub { + private lateinit var loadingDialog: QMUITipDialog + + fun show(activity: Activity, message: String) { + loadingDialog = QMUITipDialog + .Builder(activity) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_LOADING) + .setTipWord(message) + .create() + if (!activity.isDestroyed) { + try { + loadingDialog.show() + } catch (e: WindowManager.BadTokenException) { + e.printStackTrace() + } + } + } + + + fun dismiss() { + if (loadingDialog.isShowing) { + loadingDialog.dismiss() + } + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt new file mode 100644 index 0000000..de61c9a --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.util + +import android.Manifest + +object LocaleConstant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.READ_PHONE_STATE, + Manifest.permission.ACCESS_COARSE_LOCATION, + Manifest.permission.READ_EXTERNAL_STORAGE + ) + + const val PERMISSIONS_CODE = 999 + const val PUSH_REGISTER = 2022100101 + const val PAGE_LIMIT = 20 +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt new file mode 100644 index 0000000..3bea1c9 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt @@ -0,0 +1,112 @@ +package com.casic.smart.town.sanxi.view + +import android.view.KeyEvent +import android.view.MenuItem +import androidx.fragment.app.Fragment +import androidx.viewpager.widget.ViewPager +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.adapter.ViewPagerAdapter +import com.casic.smart.town.sanxi.fragment.AlarmPageFragment +import com.casic.smart.town.sanxi.fragment.MonitorPageFragment +import com.casic.smart.town.sanxi.fragment.StatisticsPageFragment +import com.gyf.immersionbar.ImmersionBar +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.base.KotlinBaseActivity +import com.pengxh.kt.lite.extensions.convertColor +import com.pengxh.kt.lite.extensions.show +import com.pengxh.kt.lite.utils.ImmerseStatusBarUtil +import com.pengxh.kt.lite.utils.WeakReferenceHandler +import kotlinx.android.synthetic.main.activity_main.* + +class MainActivity : KotlinBaseActivity() { + + companion object { + lateinit var weakReferenceHandler: WeakReferenceHandler + } + + private val kTag = "MainActivity" + private var menuItem: MenuItem? = null + private var fragmentPages: ArrayList = ArrayList() + private var clickTime: Long = 0 + + init { + fragmentPages.add(StatisticsPageFragment()) + fragmentPages.add(MonitorPageFragment()) + fragmentPages.add(AlarmPageFragment()) + } + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + ImmersionBar.with(this).statusBarDarkFont(false).init() + ImmerseStatusBarUtil.setColor(this, R.color.mainThemeColor.convertColor(this)) + } + + override fun initData() { + //推送,多次调用 SDK 初始化并无影响。 + PushManager.getInstance().initialize(this) + weakReferenceHandler = WeakReferenceHandler { + + true + } + } + + override fun observeRequestState() { + + } + + override fun initEvent() { + bottomNavigation.itemIconTintList = null + bottomNavigation.setOnNavigationItemSelectedListener { menuItem -> + when (menuItem.itemId) { + R.id.nav_statistics -> { + mainViewPager.currentItem = 0 + } + R.id.nav_monitor -> { + mainViewPager.currentItem = 1 + } + R.id.nav_alarm -> { + mainViewPager.currentItem = 2 + } + } + false + } + mainViewPager.adapter = ViewPagerAdapter(fragmentPages, supportFragmentManager) + mainViewPager.offscreenPageLimit = fragmentPages.size //缓存页数 + mainViewPager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener { + override fun onPageScrollStateChanged(state: Int) { + + } + + override fun onPageScrolled( + position: Int, + positionOffset: Float, + positionOffsetPixels: Int + ) { + + } + + override fun onPageSelected(position: Int) { + if (menuItem != null) { + menuItem!!.isChecked = false + } else { + bottomNavigation.menu.getItem(0).isChecked = false + } + menuItem = bottomNavigation.menu.getItem(position) + menuItem!!.isChecked = true + } + }) + } + + override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean { + return if (keyCode == KeyEvent.KEYCODE_BACK) { + if (System.currentTimeMillis() - clickTime > 2000) { + "再按一次退出程序".show(this) + clickTime = System.currentTimeMillis() + true + } else { + super.onKeyDown(keyCode, event) + } + } else super.onKeyDown(keyCode, event) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt new file mode 100644 index 0000000..c5d8b22 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.view + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseActivity + +class MonitorRecordActivity : KotlinBaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_monitor_record + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt new file mode 100644 index 0000000..c478d83 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt @@ -0,0 +1,55 @@ +package com.casic.smart.town.sanxi.view + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.amap.api.maps.MapsInitializer +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.gyf.immersionbar.ImmersionBar +import com.pengxh.kt.lite.extensions.navigatePageTo +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + ImmersionBar.with(this).statusBarDarkFont(true).init() + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (EasyPermissions.hasPermissions(this, *LocaleConstant.USER_PERMISSIONS)) { + startSplashScreenActivity() + } else { + EasyPermissions.requestPermissions( + this@PermissionActivity, + resources.getString(R.string.app_name) + "需要获取相关权限", + LocaleConstant.PERMISSIONS_CODE, + *LocaleConstant.USER_PERMISSIONS + ) + } + } + + private fun startSplashScreenActivity() { + //先把导航隐私政策声明,后面导航会用到 + MapsInitializer.updatePrivacyAgree(this, true) + MapsInitializer.updatePrivacyShow(this, true, true) + this.navigatePageTo() + 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) { + startSplashScreenActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable/alarm_selector.xml b/app/src/main/res/drawable/alarm_selector.xml new file mode 100644 index 0000000..39b2595 --- /dev/null +++ b/app/src/main/res/drawable/alarm_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bottom_text_color.xml b/app/src/main/res/drawable/bottom_text_color.xml new file mode 100644 index 0000000..b284ea3 --- /dev/null +++ b/app/src/main/res/drawable/bottom_text_color.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_alarm.xml b/app/src/main/res/drawable/ic_alarm.xml new file mode 100644 index 0000000..dc33aab --- /dev/null +++ b/app/src/main/res/drawable/ic_alarm.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_alarm_selected.xml b/app/src/main/res/drawable/ic_alarm_selected.xml new file mode 100644 index 0000000..993fea6 --- /dev/null +++ b/app/src/main/res/drawable/ic_alarm_selected.xml @@ -0,0 +1,9 @@ + + + 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_monitor.xml b/app/src/main/res/drawable/ic_monitor.xml new file mode 100644 index 0000000..271f5b4 --- /dev/null +++ b/app/src/main/res/drawable/ic_monitor.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_monitor_selected.xml b/app/src/main/res/drawable/ic_monitor_selected.xml new file mode 100644 index 0000000..ee62d84 --- /dev/null +++ b/app/src/main/res/drawable/ic_monitor_selected.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_statistics.xml b/app/src/main/res/drawable/ic_statistics.xml new file mode 100644 index 0000000..7fde8ec --- /dev/null +++ b/app/src/main/res/drawable/ic_statistics.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_statistics_selected.xml b/app/src/main/res/drawable/ic_statistics_selected.xml new file mode 100644 index 0000000..49b6fcd --- /dev/null +++ b/app/src/main/res/drawable/ic_statistics_selected.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/monitor_selector.xml b/app/src/main/res/drawable/monitor_selector.xml new file mode 100644 index 0000000..fe11e9a --- /dev/null +++ b/app/src/main/res/drawable/monitor_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/statistics_selector.xml b/app/src/main/res/drawable/statistics_selector.xml new file mode 100644 index 0000000..2156cff --- /dev/null +++ b/app/src/main/res/drawable/statistics_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..10cfdbf --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*.iml +.gradle +/local.properties +/.idea +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..a4cd2ca --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,101 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'org.greenrobot.greendao' + +android { +// signingConfigs { +// release { +// storeFile file('/Users/a203/Desktop/AndroidProjects/CasicSmartWell/app/CasicSmartWell.jks') +// storePassword '123456789' +// keyAlias 'key0' +// keyPassword '123456789' +// } +// } + compileSdkVersion 31 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.smart.town.sanxi" + minSdkVersion 23 + targetSdkVersion 31 + versionCode 1 + versionName "1.0.0" + + manifestPlaceholders = [GETUI_APPID: "A9V4DvwLcdAqkFCQuFyhq6"] + } + + buildTypes { + release { + minifyEnabled false +// signingConfig signingConfigs.release + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + + ndk { abiFilters "armeabi", "armeabi-v7a", "arm64-v8" } + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlin { + experimental { + coroutines 'enable' + } + } + + greendao { + schemaVersion 1//数据库版本号 + targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 + daoPackage 'com.casic.smart.town.sanxi.greendao'//设置DaoMaster、DaoSession、Dao包名 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + //基础依赖库 + implementation files('libs/lite-release.aar') + implementation 'androidx.appcompat:appcompat:1.4.2' + implementation 'androidx.core:core-ktx:1.8.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:3.0.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' + //MVVM+LiveData + implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.1" + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0" + implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + //Kotlin协程 + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1' + //图片加载框架 + implementation 'com.github.bumptech.glide:glide:4.9.0' + //返回值转换器 + implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' + implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + //okhttp3日志拦截器 + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //网络请求和接口封装 + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.9.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.9.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' + //高德地图 + implementation 'com.amap.api:3dmap:latest.integration' + //推送SDK + implementation 'com.getui:gtsdk:3.2.10.0' //个推SDK + implementation 'com.getui:gtc:3.1.9.0' //个推核心组件 + //数据库框架 + implementation 'org.greenrobot:greendao:3.3.0' + //桌面角标 + implementation "me.leolin:ShortcutBadger:1.1.22@aar" +} \ No newline at end of file diff --git a/app/libs/lite-release.aar b/app/libs/lite-release.aar new file mode 100644 index 0000000..45da4df --- /dev/null +++ b/app/libs/lite-release.aar Binary files differ diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /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 \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..a83c28a --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/svg/monitor.svg b/app/src/main/assets/svg/monitor.svg new file mode 100644 index 0000000..c8d3e25 --- /dev/null +++ b/app/src/main/assets/svg/monitor.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/msg.svg b/app/src/main/assets/svg/msg.svg new file mode 100644 index 0000000..e864e48 --- /dev/null +++ b/app/src/main/assets/svg/msg.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/statistics.svg b/app/src/main/assets/svg/statistics.svg new file mode 100644 index 0000000..974000e --- /dev/null +++ b/app/src/main/assets/svg/statistics.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt new file mode 100644 index 0000000..6b9cce0 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.adapter + +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentManager +import androidx.fragment.app.FragmentPagerAdapter + +class ViewPagerAdapter(list: ArrayList, manager: FragmentManager) : + FragmentPagerAdapter(manager) { + + private var pageList: List = list + + override fun getItem(position: Int) = pageList[position] + + override fun getCount() = pageList.size +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt new file mode 100644 index 0000000..4e017b1 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt @@ -0,0 +1,40 @@ +package com.casic.smart.town.sanxi.base + +import android.app.Application +import android.util.Log +import com.casic.smart.town.sanxi.greendao.DaoMaster +import com.casic.smart.town.sanxi.greendao.DaoSession +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + private val kTag = "BaseApplication" + + companion object { + private var instance: BaseApplication by Delegates.notNull() + + fun obtainInstance() = instance + + private lateinit var daoSession: DaoSession + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences(this) + //推送 + PushManager.getInstance().initialize(this) + PushManager.getInstance().setDebugLogger(this) { + Log.d(kTag, it) + } + val devOpenHelper = DaoMaster.DevOpenHelper(this, "SmartTown.db", null) + val daoMaster = DaoMaster(devOpenHelper.writableDatabase) + daoSession = daoMaster.newSession() + } + + fun obtainDaoSession(): DaoSession { + return daoSession + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java new file mode 100644 index 0000000..b8f67dc --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java @@ -0,0 +1,133 @@ +package com.casic.smart.town.sanxi.bean; + +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Generated; +import org.greenrobot.greendao.annotation.Id; +import org.greenrobot.greendao.annotation.Unique; + +@Entity +public class AlarmMessageLocaleBean { + @Id(autoincrement = true) + private Long id;//主键自增 + + @Unique + private String messageId; + private String appId; + private String clientId; + private String taskId; + private String userId; + private String title; + private String content; + private String deviceCode; + private String isRead;//0-未读,1-已读 + private String alarmTime; + + @Generated(hash = 566950134) + public AlarmMessageLocaleBean(Long id, String messageId, String appId, + String clientId, String taskId, String userId, String title, + String content, String deviceCode, String isRead, String alarmTime) { + this.id = id; + this.messageId = messageId; + this.appId = appId; + this.clientId = clientId; + this.taskId = taskId; + this.userId = userId; + this.title = title; + this.content = content; + this.deviceCode = deviceCode; + this.isRead = isRead; + this.alarmTime = alarmTime; + } + + @Generated(hash = 1737519562) + public AlarmMessageLocaleBean() { + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getMessageId() { + return this.messageId; + } + + public void setMessageId(String messageId) { + this.messageId = messageId; + } + + public String getAppId() { + return this.appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public String getClientId() { + return this.clientId; + } + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public String getTaskId() { + return this.taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getUserId() { + return this.userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getTitle() { + return this.title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return this.content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getDeviceCode() { + return this.deviceCode; + } + + public void setDeviceCode(String deviceCode) { + this.deviceCode = deviceCode; + } + + public String getIsRead() { + return this.isRead; + } + + public void setIsRead(String isRead) { + this.isRead = isRead; + } + + public String getAlarmTime() { + return this.alarmTime; + } + + public void setAlarmTime(String alarmTime) { + this.alarmTime = alarmTime; + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt new file mode 100644 index 0000000..650e201 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class AlarmPageFragment: KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_alarm + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt new file mode 100644 index 0000000..deac8ac --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt @@ -0,0 +1,76 @@ +package com.casic.smart.town.sanxi.fragment + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.Fragment +import com.amap.api.maps.AMap +import com.amap.api.maps.AMapOptions +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.view.MonitorRecordActivity +import com.pengxh.kt.lite.extensions.navigatePageTo +import com.pengxh.kt.lite.extensions.show +import kotlinx.android.synthetic.main.fragment_monitor.view.* + +class MonitorPageFragment : Fragment() { + + private val kTag = "HomePageFragment" + private lateinit var monitorView: View + private lateinit var aMap: AMap + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? + ): View { + monitorView = inflater.inflate(R.layout.fragment_monitor, container, false) + //地图初始化 + initMap(savedInstanceState) + + monitorView.rightOperateView.setOnClickListener { + requireContext().navigatePageTo() + } + return monitorView + } + + private fun initMap(savedInstanceState: Bundle?) { + monitorView.mapView.onCreate(savedInstanceState) + aMap = monitorView.mapView.map + aMap.mapType = AMap.MAP_TYPE_NORMAL + val uiSettings = aMap.uiSettings + uiSettings.isCompassEnabled = true + uiSettings.zoomPosition = AMapOptions.ZOOM_POSITION_RIGHT_CENTER + uiSettings.isTiltGesturesEnabled = false//不许地图随手势倾斜角度 + + // 地图加载成功监听 +// aMap.addOnMapLoadedListener(this) + // 地图缩放监听 +// aMap.addOnCameraChangeListener(this) + // marker 点击事件监听 +// aMap.addOnMarkerClickListener(this) + // 点击marker弹出自定义popup +// aMap.setInfoWindowAdapter(this) + //信息窗点击事件 +// aMap.addOnInfoWindowClickListener(this) + } + + /***以下是地图生命周期管理************************************************************************/ + override fun onResume() { + super.onResume() + monitorView.mapView.onResume() + } + + override fun onPause() { + super.onPause() + monitorView.mapView.onPause() + } + + override fun onSaveInstanceState(outState: Bundle) { + super.onSaveInstanceState(outState) + monitorView.mapView.onSaveInstanceState(outState) + } + + override fun onDestroy() { + super.onDestroy() + monitorView.mapView.onDestroy() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt new file mode 100644 index 0000000..e84df12 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class StatisticsPageFragment : KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_statistics + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java new file mode 100644 index 0000000..68d7901 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java @@ -0,0 +1,255 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.database.Cursor; +import android.database.sqlite.SQLiteStatement; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.Property; +import org.greenrobot.greendao.internal.DaoConfig; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseStatement; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * DAO for table "ALARM_MESSAGE_LOCALE_BEAN". +*/ +public class AlarmMessageLocaleBeanDao extends AbstractDao { + + public static final String TABLENAME = "ALARM_MESSAGE_LOCALE_BEAN"; + + /** + * Properties of entity AlarmMessageLocaleBean.
+ * Can be used for QueryBuilder and for referencing column names. + */ + public static class Properties { + public final static Property Id = new Property(0, Long.class, "id", true, "_id"); + public final static Property MessageId = new Property(1, String.class, "messageId", false, "MESSAGE_ID"); + public final static Property AppId = new Property(2, String.class, "appId", false, "APP_ID"); + public final static Property ClientId = new Property(3, String.class, "clientId", false, "CLIENT_ID"); + public final static Property TaskId = new Property(4, String.class, "taskId", false, "TASK_ID"); + public final static Property UserId = new Property(5, String.class, "userId", false, "USER_ID"); + public final static Property Title = new Property(6, String.class, "title", false, "TITLE"); + public final static Property Content = new Property(7, String.class, "content", false, "CONTENT"); + public final static Property DeviceCode = new Property(8, String.class, "deviceCode", false, "DEVICE_CODE"); + public final static Property IsRead = new Property(9, String.class, "isRead", false, "IS_READ"); + public final static Property AlarmTime = new Property(10, String.class, "alarmTime", false, "ALARM_TIME"); + } + + + public AlarmMessageLocaleBeanDao(DaoConfig config) { + super(config); + } + + public AlarmMessageLocaleBeanDao(DaoConfig config, DaoSession daoSession) { + super(config, daoSession); + } + + /** Creates the underlying database table. */ + public static void createTable(Database db, boolean ifNotExists) { + String constraint = ifNotExists? "IF NOT EXISTS ": ""; + db.execSQL("CREATE TABLE " + constraint + "\"ALARM_MESSAGE_LOCALE_BEAN\" (" + // + "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id + "\"MESSAGE_ID\" TEXT UNIQUE ," + // 1: messageId + "\"APP_ID\" TEXT," + // 2: appId + "\"CLIENT_ID\" TEXT," + // 3: clientId + "\"TASK_ID\" TEXT," + // 4: taskId + "\"USER_ID\" TEXT," + // 5: userId + "\"TITLE\" TEXT," + // 6: title + "\"CONTENT\" TEXT," + // 7: content + "\"DEVICE_CODE\" TEXT," + // 8: deviceCode + "\"IS_READ\" TEXT," + // 9: isRead + "\"ALARM_TIME\" TEXT);"); // 10: alarmTime + } + + /** Drops the underlying database table. */ + public static void dropTable(Database db, boolean ifExists) { + String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"ALARM_MESSAGE_LOCALE_BEAN\""; + db.execSQL(sql); + } + + @Override + protected final void bindValues(DatabaseStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + protected final void bindValues(SQLiteStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + public Long readKey(Cursor cursor, int offset) { + return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); + } + + @Override + public AlarmMessageLocaleBean readEntity(Cursor cursor, int offset) { + AlarmMessageLocaleBean entity = new AlarmMessageLocaleBean( // + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // messageId + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // appId + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // clientId + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // taskId + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // userId + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // title + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // content + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // deviceCode + cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // isRead + cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10) // alarmTime + ); + return entity; + } + + @Override + public void readEntity(Cursor cursor, AlarmMessageLocaleBean entity, int offset) { + entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); + entity.setMessageId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setAppId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setClientId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setTaskId(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); + entity.setUserId(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setTitle(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setContent(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); + entity.setDeviceCode(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); + entity.setIsRead(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9)); + entity.setAlarmTime(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); + } + + @Override + protected final Long updateKeyAfterInsert(AlarmMessageLocaleBean entity, long rowId) { + entity.setId(rowId); + return rowId; + } + + @Override + public Long getKey(AlarmMessageLocaleBean entity) { + if(entity != null) { + return entity.getId(); + } else { + return null; + } + } + + @Override + public boolean hasKey(AlarmMessageLocaleBean entity) { + return entity.getId() != null; + } + + @Override + protected final boolean isEntityUpdateable() { + return true; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java new file mode 100644 index 0000000..4222c40 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java @@ -0,0 +1,96 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.content.Context; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteDatabase.CursorFactory; +import android.util.Log; + +import org.greenrobot.greendao.AbstractDaoMaster; +import org.greenrobot.greendao.database.StandardDatabase; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseOpenHelper; +import org.greenrobot.greendao.identityscope.IdentityScopeType; + + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * Master of DAO (schema version 1): knows all DAOs. + */ +public class DaoMaster extends AbstractDaoMaster { + public static final int SCHEMA_VERSION = 1; + + /** Creates underlying database table using DAOs. */ + public static void createAllTables(Database db, boolean ifNotExists) { + AlarmMessageLocaleBeanDao.createTable(db, ifNotExists); + } + + /** Drops underlying database table using DAOs. */ + public static void dropAllTables(Database db, boolean ifExists) { + AlarmMessageLocaleBeanDao.dropTable(db, ifExists); + } + + /** + * WARNING: Drops all table on Upgrade! Use only during development. + * Convenience method using a {@link DevOpenHelper}. + */ + public static DaoSession newDevSession(Context context, String name) { + Database db = new DevOpenHelper(context, name).getWritableDb(); + DaoMaster daoMaster = new DaoMaster(db); + return daoMaster.newSession(); + } + + public DaoMaster(SQLiteDatabase db) { + this(new StandardDatabase(db)); + } + + public DaoMaster(Database db) { + super(db, SCHEMA_VERSION); + registerDaoClass(AlarmMessageLocaleBeanDao.class); + } + + public DaoSession newSession() { + return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); + } + + public DaoSession newSession(IdentityScopeType type) { + return new DaoSession(db, type, daoConfigMap); + } + + /** + * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} - + */ + public static abstract class OpenHelper extends DatabaseOpenHelper { + public OpenHelper(Context context, String name) { + super(context, name, SCHEMA_VERSION); + } + + public OpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory, SCHEMA_VERSION); + } + + @Override + public void onCreate(Database db) { + Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); + createAllTables(db, false); + } + } + + /** WARNING: Drops all table on Upgrade! Use only during development. */ + public static class DevOpenHelper extends OpenHelper { + public DevOpenHelper(Context context, String name) { + super(context, name); + } + + public DevOpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory); + } + + @Override + public void onUpgrade(Database db, int oldVersion, int newVersion) { + Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); + dropAllTables(db, true); + onCreate(db); + } + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java new file mode 100644 index 0000000..480ed84 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java @@ -0,0 +1,48 @@ +package com.casic.smart.town.sanxi.greendao; + +import java.util.Map; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.AbstractDaoSession; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.identityscope.IdentityScopeType; +import org.greenrobot.greendao.internal.DaoConfig; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. + +/** + * {@inheritDoc} + * + * @see org.greenrobot.greendao.AbstractDaoSession + */ +public class DaoSession extends AbstractDaoSession { + + private final DaoConfig alarmMessageLocaleBeanDaoConfig; + + private final AlarmMessageLocaleBeanDao alarmMessageLocaleBeanDao; + + public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> + daoConfigMap) { + super(db); + + alarmMessageLocaleBeanDaoConfig = daoConfigMap.get(AlarmMessageLocaleBeanDao.class).clone(); + alarmMessageLocaleBeanDaoConfig.initIdentityScope(type); + + alarmMessageLocaleBeanDao = new AlarmMessageLocaleBeanDao(alarmMessageLocaleBeanDaoConfig, this); + + registerDao(AlarmMessageLocaleBean.class, alarmMessageLocaleBeanDao); + } + + public void clear() { + alarmMessageLocaleBeanDaoConfig.clearIdentityScope(); + } + + public AlarmMessageLocaleBeanDao getAlarmMessageLocaleBeanDao() { + return alarmMessageLocaleBeanDao; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt new file mode 100644 index 0000000..875cb8c --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt @@ -0,0 +1,5 @@ +package com.casic.smart.town.sanxi.service + +import com.igexin.sdk.PushService + +class ApplicationPushService : PushService() \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt new file mode 100644 index 0000000..396129f --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt @@ -0,0 +1,84 @@ +package com.casic.smart.town.sanxi.service + +import android.content.Context +import android.os.Message +import android.util.Log +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.casic.smart.town.sanxi.view.MainActivity +import com.igexin.sdk.GTIntentService +import com.igexin.sdk.message.GTCmdMessage +import com.igexin.sdk.message.GTNotificationMessage +import com.igexin.sdk.message.GTTransmitMessage +import com.pengxh.kt.lite.extensions.toJson + +class PushIntentService : GTIntentService() { + + private val kTag = "SmartWellIntentService" + + override fun onReceiveServicePid(context: Context?, pid: Int) { + + } + + // 透传消息 + override fun onReceiveMessageData(context: Context?, msg: GTTransmitMessage?) { + Log.d(kTag, "透传消息 -> msg = $msg") + } + + // 接收 cid + override fun onReceiveClientId(context: Context?, clientid: String?) { + Log.d(kTag, "onReceiveClientId -> $clientid") + //通知MainActivity注册个推服务 + val msg: Message = MainActivity.weakReferenceHandler.obtainMessage() + msg.what = LocaleConstant.PUSH_REGISTER + msg.obj = clientid + MainActivity.weakReferenceHandler.sendMessage(msg) + } + + // cid 离线上线通知 + override fun onReceiveOnlineState(context: Context?, online: Boolean) { + + } + + // 各种事件处理回执 + override fun onReceiveCommandResult(context: Context?, msg: GTCmdMessage?) { + + } + + // 通知到达 + override fun onNotificationMessageArrived(context: Context?, msg: GTNotificationMessage?) { + //报警 +// { +// "content": "设备编号[412022030361]发生井盖开盖报警", +// "messageId": "380abf9a79d34306a2683dc9bf96ee78", +// "taskId": "OSL-0830_4hmfimp3Vu684wo3SjXso9", +// "title": "告警提醒", +// "appid": "HKv8K9qARd6WckZ1o2Vbu4", +// "clientId": "e78beacc42e9a02ae6fb9087eb2b1171", +// "pkgName": "com.casic.app.smartwell" +// } + if (msg == null) { + return + } + Log.d(kTag, "通知到达 -> msg = ${msg.toJson()}") +// val userDetailJson = SaveKeyValues.getValue(LocaleConstant.USER_DETAIL_MODEL, "") as String +// var userId = "" +// if (userDetailJson.isNotBlank()) { +// val userDataModel = Gson().fromJson( +// userDetailJson, object : TypeToken() {}.type +// ) +// userId = userDataModel.id.toString() +// } +// //解析编号 +// val splitArray = msg.content.split("\\[|\\]".toRegex()) +// DataBaseManager.instance.insertNotice( +// msg.messageId, msg.appid, msg.clientId, msg.taskId, +// userId, msg.title, msg.content, splitArray[1], "0", +// System.currentTimeMillis().timestampToCompleteDate() +// ) + } + + // 通知点击 + override fun onNotificationMessageClicked(context: Context?, msg: GTNotificationMessage?) { + Log.d(kTag, "通知点击 -> msg = $msg") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt new file mode 100644 index 0000000..daa7c38 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt @@ -0,0 +1,14 @@ +package com.casic.smart.town.sanxi.util + +import android.content.Context +import me.leolin.shortcutbadger.ShortcutBadger + +object BadeHelper { + fun setBadgeNum(context: Context, badgeCount: Int) { + if (badgeCount == 0) { + ShortcutBadger.removeCount(context) + } else { + ShortcutBadger.applyCount(context, badgeCount) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt new file mode 100644 index 0000000..0a52ef2 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt @@ -0,0 +1,75 @@ +package com.casic.smart.town.sanxi.util + +import com.casic.smart.town.sanxi.base.BaseApplication +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao + +class DataBaseManager private constructor() { + + companion object { + //Kotlin委托模式双重锁单例 + val instance: DataBaseManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) { + DataBaseManager() + } + } + + private val beanDao = + BaseApplication.obtainInstance().obtainDaoSession().alarmMessageLocaleBeanDao + +// fun insertNotice( +// messageId: String, appid: String, clientId: String, +// taskId: String, userId: String, title: String, +// content: String, deviceCode: String, isRead: String, +// noticeTime: String +// ) { +// val noticeLocaleBean = NoticeLocaleBean() +// noticeLocaleBean.messageId = messageId +// noticeLocaleBean.appid = appid +// noticeLocaleBean.clientId = clientId +// noticeLocaleBean.taskId = taskId +// noticeLocaleBean.userId = userId +// noticeLocaleBean.title = title +// noticeLocaleBean.content = content +// noticeLocaleBean.deviceCode = deviceCode +// noticeLocaleBean.isRead = isRead +// noticeLocaleBean.noticeTime = noticeTime +// beanDao.insert(noticeLocaleBean) +// //角标设置 +// BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadNotice()) +// } + + fun deleteByMessageId(messageId: String) { + val result = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).list() + beanDao.deleteInTx(result) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun updateNoticeByMessageId(messageId: String) { + val noticeLocaleBean = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).unique() ?: return + noticeLocaleBean.isRead = "1" + beanDao.update(noticeLocaleBean) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun queryMessageByPage(userId: String, offset: Int): MutableList { + return BaseApplication.obtainInstance().obtainDaoSession() + .queryBuilder(AlarmMessageLocaleBean::class.java) + .where(AlarmMessageLocaleBeanDao.Properties.UserId.eq(userId)) + .offset(offset * LocaleConstant.PAGE_LIMIT) + .orderDesc(AlarmMessageLocaleBeanDao.Properties.AlarmTime) + .limit(LocaleConstant.PAGE_LIMIT) + .list() + } + + private fun queryUnReadMessage(): Int { + return beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.IsRead.eq("0") + ).list().size + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt new file mode 100644 index 0000000..52926a8 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt @@ -0,0 +1,31 @@ +package com.casic.smart.town.sanxi.util; + +import android.app.Activity +import android.view.WindowManager +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object LoadingDialogHub { + private lateinit var loadingDialog: QMUITipDialog + + fun show(activity: Activity, message: String) { + loadingDialog = QMUITipDialog + .Builder(activity) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_LOADING) + .setTipWord(message) + .create() + if (!activity.isDestroyed) { + try { + loadingDialog.show() + } catch (e: WindowManager.BadTokenException) { + e.printStackTrace() + } + } + } + + + fun dismiss() { + if (loadingDialog.isShowing) { + loadingDialog.dismiss() + } + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt new file mode 100644 index 0000000..de61c9a --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.util + +import android.Manifest + +object LocaleConstant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.READ_PHONE_STATE, + Manifest.permission.ACCESS_COARSE_LOCATION, + Manifest.permission.READ_EXTERNAL_STORAGE + ) + + const val PERMISSIONS_CODE = 999 + const val PUSH_REGISTER = 2022100101 + const val PAGE_LIMIT = 20 +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt new file mode 100644 index 0000000..3bea1c9 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt @@ -0,0 +1,112 @@ +package com.casic.smart.town.sanxi.view + +import android.view.KeyEvent +import android.view.MenuItem +import androidx.fragment.app.Fragment +import androidx.viewpager.widget.ViewPager +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.adapter.ViewPagerAdapter +import com.casic.smart.town.sanxi.fragment.AlarmPageFragment +import com.casic.smart.town.sanxi.fragment.MonitorPageFragment +import com.casic.smart.town.sanxi.fragment.StatisticsPageFragment +import com.gyf.immersionbar.ImmersionBar +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.base.KotlinBaseActivity +import com.pengxh.kt.lite.extensions.convertColor +import com.pengxh.kt.lite.extensions.show +import com.pengxh.kt.lite.utils.ImmerseStatusBarUtil +import com.pengxh.kt.lite.utils.WeakReferenceHandler +import kotlinx.android.synthetic.main.activity_main.* + +class MainActivity : KotlinBaseActivity() { + + companion object { + lateinit var weakReferenceHandler: WeakReferenceHandler + } + + private val kTag = "MainActivity" + private var menuItem: MenuItem? = null + private var fragmentPages: ArrayList = ArrayList() + private var clickTime: Long = 0 + + init { + fragmentPages.add(StatisticsPageFragment()) + fragmentPages.add(MonitorPageFragment()) + fragmentPages.add(AlarmPageFragment()) + } + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + ImmersionBar.with(this).statusBarDarkFont(false).init() + ImmerseStatusBarUtil.setColor(this, R.color.mainThemeColor.convertColor(this)) + } + + override fun initData() { + //推送,多次调用 SDK 初始化并无影响。 + PushManager.getInstance().initialize(this) + weakReferenceHandler = WeakReferenceHandler { + + true + } + } + + override fun observeRequestState() { + + } + + override fun initEvent() { + bottomNavigation.itemIconTintList = null + bottomNavigation.setOnNavigationItemSelectedListener { menuItem -> + when (menuItem.itemId) { + R.id.nav_statistics -> { + mainViewPager.currentItem = 0 + } + R.id.nav_monitor -> { + mainViewPager.currentItem = 1 + } + R.id.nav_alarm -> { + mainViewPager.currentItem = 2 + } + } + false + } + mainViewPager.adapter = ViewPagerAdapter(fragmentPages, supportFragmentManager) + mainViewPager.offscreenPageLimit = fragmentPages.size //缓存页数 + mainViewPager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener { + override fun onPageScrollStateChanged(state: Int) { + + } + + override fun onPageScrolled( + position: Int, + positionOffset: Float, + positionOffsetPixels: Int + ) { + + } + + override fun onPageSelected(position: Int) { + if (menuItem != null) { + menuItem!!.isChecked = false + } else { + bottomNavigation.menu.getItem(0).isChecked = false + } + menuItem = bottomNavigation.menu.getItem(position) + menuItem!!.isChecked = true + } + }) + } + + override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean { + return if (keyCode == KeyEvent.KEYCODE_BACK) { + if (System.currentTimeMillis() - clickTime > 2000) { + "再按一次退出程序".show(this) + clickTime = System.currentTimeMillis() + true + } else { + super.onKeyDown(keyCode, event) + } + } else super.onKeyDown(keyCode, event) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt new file mode 100644 index 0000000..c5d8b22 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.view + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseActivity + +class MonitorRecordActivity : KotlinBaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_monitor_record + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt new file mode 100644 index 0000000..c478d83 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt @@ -0,0 +1,55 @@ +package com.casic.smart.town.sanxi.view + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.amap.api.maps.MapsInitializer +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.gyf.immersionbar.ImmersionBar +import com.pengxh.kt.lite.extensions.navigatePageTo +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + ImmersionBar.with(this).statusBarDarkFont(true).init() + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (EasyPermissions.hasPermissions(this, *LocaleConstant.USER_PERMISSIONS)) { + startSplashScreenActivity() + } else { + EasyPermissions.requestPermissions( + this@PermissionActivity, + resources.getString(R.string.app_name) + "需要获取相关权限", + LocaleConstant.PERMISSIONS_CODE, + *LocaleConstant.USER_PERMISSIONS + ) + } + } + + private fun startSplashScreenActivity() { + //先把导航隐私政策声明,后面导航会用到 + MapsInitializer.updatePrivacyAgree(this, true) + MapsInitializer.updatePrivacyShow(this, true, true) + this.navigatePageTo() + 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) { + startSplashScreenActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable/alarm_selector.xml b/app/src/main/res/drawable/alarm_selector.xml new file mode 100644 index 0000000..39b2595 --- /dev/null +++ b/app/src/main/res/drawable/alarm_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bottom_text_color.xml b/app/src/main/res/drawable/bottom_text_color.xml new file mode 100644 index 0000000..b284ea3 --- /dev/null +++ b/app/src/main/res/drawable/bottom_text_color.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_alarm.xml b/app/src/main/res/drawable/ic_alarm.xml new file mode 100644 index 0000000..dc33aab --- /dev/null +++ b/app/src/main/res/drawable/ic_alarm.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_alarm_selected.xml b/app/src/main/res/drawable/ic_alarm_selected.xml new file mode 100644 index 0000000..993fea6 --- /dev/null +++ b/app/src/main/res/drawable/ic_alarm_selected.xml @@ -0,0 +1,9 @@ + + + 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_monitor.xml b/app/src/main/res/drawable/ic_monitor.xml new file mode 100644 index 0000000..271f5b4 --- /dev/null +++ b/app/src/main/res/drawable/ic_monitor.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_monitor_selected.xml b/app/src/main/res/drawable/ic_monitor_selected.xml new file mode 100644 index 0000000..ee62d84 --- /dev/null +++ b/app/src/main/res/drawable/ic_monitor_selected.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_statistics.xml b/app/src/main/res/drawable/ic_statistics.xml new file mode 100644 index 0000000..7fde8ec --- /dev/null +++ b/app/src/main/res/drawable/ic_statistics.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_statistics_selected.xml b/app/src/main/res/drawable/ic_statistics_selected.xml new file mode 100644 index 0000000..49b6fcd --- /dev/null +++ b/app/src/main/res/drawable/ic_statistics_selected.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/monitor_selector.xml b/app/src/main/res/drawable/monitor_selector.xml new file mode 100644 index 0000000..fe11e9a --- /dev/null +++ b/app/src/main/res/drawable/monitor_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/statistics_selector.xml b/app/src/main/res/drawable/statistics_selector.xml new file mode 100644 index 0000000..2156cff --- /dev/null +++ b/app/src/main/res/drawable/statistics_selector.xml @@ -0,0 +1,5 @@ + + + + + \ 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..78a4a94 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,27 @@ + + + + + + + + \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..10cfdbf --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*.iml +.gradle +/local.properties +/.idea +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..a4cd2ca --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,101 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'org.greenrobot.greendao' + +android { +// signingConfigs { +// release { +// storeFile file('/Users/a203/Desktop/AndroidProjects/CasicSmartWell/app/CasicSmartWell.jks') +// storePassword '123456789' +// keyAlias 'key0' +// keyPassword '123456789' +// } +// } + compileSdkVersion 31 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.smart.town.sanxi" + minSdkVersion 23 + targetSdkVersion 31 + versionCode 1 + versionName "1.0.0" + + manifestPlaceholders = [GETUI_APPID: "A9V4DvwLcdAqkFCQuFyhq6"] + } + + buildTypes { + release { + minifyEnabled false +// signingConfig signingConfigs.release + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + + ndk { abiFilters "armeabi", "armeabi-v7a", "arm64-v8" } + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlin { + experimental { + coroutines 'enable' + } + } + + greendao { + schemaVersion 1//数据库版本号 + targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 + daoPackage 'com.casic.smart.town.sanxi.greendao'//设置DaoMaster、DaoSession、Dao包名 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + //基础依赖库 + implementation files('libs/lite-release.aar') + implementation 'androidx.appcompat:appcompat:1.4.2' + implementation 'androidx.core:core-ktx:1.8.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:3.0.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' + //MVVM+LiveData + implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.1" + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0" + implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + //Kotlin协程 + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1' + //图片加载框架 + implementation 'com.github.bumptech.glide:glide:4.9.0' + //返回值转换器 + implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' + implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + //okhttp3日志拦截器 + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //网络请求和接口封装 + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.9.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.9.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' + //高德地图 + implementation 'com.amap.api:3dmap:latest.integration' + //推送SDK + implementation 'com.getui:gtsdk:3.2.10.0' //个推SDK + implementation 'com.getui:gtc:3.1.9.0' //个推核心组件 + //数据库框架 + implementation 'org.greenrobot:greendao:3.3.0' + //桌面角标 + implementation "me.leolin:ShortcutBadger:1.1.22@aar" +} \ No newline at end of file diff --git a/app/libs/lite-release.aar b/app/libs/lite-release.aar new file mode 100644 index 0000000..45da4df --- /dev/null +++ b/app/libs/lite-release.aar Binary files differ diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /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 \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..a83c28a --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/svg/monitor.svg b/app/src/main/assets/svg/monitor.svg new file mode 100644 index 0000000..c8d3e25 --- /dev/null +++ b/app/src/main/assets/svg/monitor.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/msg.svg b/app/src/main/assets/svg/msg.svg new file mode 100644 index 0000000..e864e48 --- /dev/null +++ b/app/src/main/assets/svg/msg.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/statistics.svg b/app/src/main/assets/svg/statistics.svg new file mode 100644 index 0000000..974000e --- /dev/null +++ b/app/src/main/assets/svg/statistics.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt new file mode 100644 index 0000000..6b9cce0 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.adapter + +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentManager +import androidx.fragment.app.FragmentPagerAdapter + +class ViewPagerAdapter(list: ArrayList, manager: FragmentManager) : + FragmentPagerAdapter(manager) { + + private var pageList: List = list + + override fun getItem(position: Int) = pageList[position] + + override fun getCount() = pageList.size +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt new file mode 100644 index 0000000..4e017b1 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt @@ -0,0 +1,40 @@ +package com.casic.smart.town.sanxi.base + +import android.app.Application +import android.util.Log +import com.casic.smart.town.sanxi.greendao.DaoMaster +import com.casic.smart.town.sanxi.greendao.DaoSession +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + private val kTag = "BaseApplication" + + companion object { + private var instance: BaseApplication by Delegates.notNull() + + fun obtainInstance() = instance + + private lateinit var daoSession: DaoSession + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences(this) + //推送 + PushManager.getInstance().initialize(this) + PushManager.getInstance().setDebugLogger(this) { + Log.d(kTag, it) + } + val devOpenHelper = DaoMaster.DevOpenHelper(this, "SmartTown.db", null) + val daoMaster = DaoMaster(devOpenHelper.writableDatabase) + daoSession = daoMaster.newSession() + } + + fun obtainDaoSession(): DaoSession { + return daoSession + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java new file mode 100644 index 0000000..b8f67dc --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java @@ -0,0 +1,133 @@ +package com.casic.smart.town.sanxi.bean; + +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Generated; +import org.greenrobot.greendao.annotation.Id; +import org.greenrobot.greendao.annotation.Unique; + +@Entity +public class AlarmMessageLocaleBean { + @Id(autoincrement = true) + private Long id;//主键自增 + + @Unique + private String messageId; + private String appId; + private String clientId; + private String taskId; + private String userId; + private String title; + private String content; + private String deviceCode; + private String isRead;//0-未读,1-已读 + private String alarmTime; + + @Generated(hash = 566950134) + public AlarmMessageLocaleBean(Long id, String messageId, String appId, + String clientId, String taskId, String userId, String title, + String content, String deviceCode, String isRead, String alarmTime) { + this.id = id; + this.messageId = messageId; + this.appId = appId; + this.clientId = clientId; + this.taskId = taskId; + this.userId = userId; + this.title = title; + this.content = content; + this.deviceCode = deviceCode; + this.isRead = isRead; + this.alarmTime = alarmTime; + } + + @Generated(hash = 1737519562) + public AlarmMessageLocaleBean() { + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getMessageId() { + return this.messageId; + } + + public void setMessageId(String messageId) { + this.messageId = messageId; + } + + public String getAppId() { + return this.appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public String getClientId() { + return this.clientId; + } + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public String getTaskId() { + return this.taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getUserId() { + return this.userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getTitle() { + return this.title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return this.content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getDeviceCode() { + return this.deviceCode; + } + + public void setDeviceCode(String deviceCode) { + this.deviceCode = deviceCode; + } + + public String getIsRead() { + return this.isRead; + } + + public void setIsRead(String isRead) { + this.isRead = isRead; + } + + public String getAlarmTime() { + return this.alarmTime; + } + + public void setAlarmTime(String alarmTime) { + this.alarmTime = alarmTime; + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt new file mode 100644 index 0000000..650e201 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class AlarmPageFragment: KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_alarm + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt new file mode 100644 index 0000000..deac8ac --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt @@ -0,0 +1,76 @@ +package com.casic.smart.town.sanxi.fragment + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.Fragment +import com.amap.api.maps.AMap +import com.amap.api.maps.AMapOptions +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.view.MonitorRecordActivity +import com.pengxh.kt.lite.extensions.navigatePageTo +import com.pengxh.kt.lite.extensions.show +import kotlinx.android.synthetic.main.fragment_monitor.view.* + +class MonitorPageFragment : Fragment() { + + private val kTag = "HomePageFragment" + private lateinit var monitorView: View + private lateinit var aMap: AMap + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? + ): View { + monitorView = inflater.inflate(R.layout.fragment_monitor, container, false) + //地图初始化 + initMap(savedInstanceState) + + monitorView.rightOperateView.setOnClickListener { + requireContext().navigatePageTo() + } + return monitorView + } + + private fun initMap(savedInstanceState: Bundle?) { + monitorView.mapView.onCreate(savedInstanceState) + aMap = monitorView.mapView.map + aMap.mapType = AMap.MAP_TYPE_NORMAL + val uiSettings = aMap.uiSettings + uiSettings.isCompassEnabled = true + uiSettings.zoomPosition = AMapOptions.ZOOM_POSITION_RIGHT_CENTER + uiSettings.isTiltGesturesEnabled = false//不许地图随手势倾斜角度 + + // 地图加载成功监听 +// aMap.addOnMapLoadedListener(this) + // 地图缩放监听 +// aMap.addOnCameraChangeListener(this) + // marker 点击事件监听 +// aMap.addOnMarkerClickListener(this) + // 点击marker弹出自定义popup +// aMap.setInfoWindowAdapter(this) + //信息窗点击事件 +// aMap.addOnInfoWindowClickListener(this) + } + + /***以下是地图生命周期管理************************************************************************/ + override fun onResume() { + super.onResume() + monitorView.mapView.onResume() + } + + override fun onPause() { + super.onPause() + monitorView.mapView.onPause() + } + + override fun onSaveInstanceState(outState: Bundle) { + super.onSaveInstanceState(outState) + monitorView.mapView.onSaveInstanceState(outState) + } + + override fun onDestroy() { + super.onDestroy() + monitorView.mapView.onDestroy() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt new file mode 100644 index 0000000..e84df12 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class StatisticsPageFragment : KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_statistics + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java new file mode 100644 index 0000000..68d7901 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java @@ -0,0 +1,255 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.database.Cursor; +import android.database.sqlite.SQLiteStatement; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.Property; +import org.greenrobot.greendao.internal.DaoConfig; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseStatement; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * DAO for table "ALARM_MESSAGE_LOCALE_BEAN". +*/ +public class AlarmMessageLocaleBeanDao extends AbstractDao { + + public static final String TABLENAME = "ALARM_MESSAGE_LOCALE_BEAN"; + + /** + * Properties of entity AlarmMessageLocaleBean.
+ * Can be used for QueryBuilder and for referencing column names. + */ + public static class Properties { + public final static Property Id = new Property(0, Long.class, "id", true, "_id"); + public final static Property MessageId = new Property(1, String.class, "messageId", false, "MESSAGE_ID"); + public final static Property AppId = new Property(2, String.class, "appId", false, "APP_ID"); + public final static Property ClientId = new Property(3, String.class, "clientId", false, "CLIENT_ID"); + public final static Property TaskId = new Property(4, String.class, "taskId", false, "TASK_ID"); + public final static Property UserId = new Property(5, String.class, "userId", false, "USER_ID"); + public final static Property Title = new Property(6, String.class, "title", false, "TITLE"); + public final static Property Content = new Property(7, String.class, "content", false, "CONTENT"); + public final static Property DeviceCode = new Property(8, String.class, "deviceCode", false, "DEVICE_CODE"); + public final static Property IsRead = new Property(9, String.class, "isRead", false, "IS_READ"); + public final static Property AlarmTime = new Property(10, String.class, "alarmTime", false, "ALARM_TIME"); + } + + + public AlarmMessageLocaleBeanDao(DaoConfig config) { + super(config); + } + + public AlarmMessageLocaleBeanDao(DaoConfig config, DaoSession daoSession) { + super(config, daoSession); + } + + /** Creates the underlying database table. */ + public static void createTable(Database db, boolean ifNotExists) { + String constraint = ifNotExists? "IF NOT EXISTS ": ""; + db.execSQL("CREATE TABLE " + constraint + "\"ALARM_MESSAGE_LOCALE_BEAN\" (" + // + "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id + "\"MESSAGE_ID\" TEXT UNIQUE ," + // 1: messageId + "\"APP_ID\" TEXT," + // 2: appId + "\"CLIENT_ID\" TEXT," + // 3: clientId + "\"TASK_ID\" TEXT," + // 4: taskId + "\"USER_ID\" TEXT," + // 5: userId + "\"TITLE\" TEXT," + // 6: title + "\"CONTENT\" TEXT," + // 7: content + "\"DEVICE_CODE\" TEXT," + // 8: deviceCode + "\"IS_READ\" TEXT," + // 9: isRead + "\"ALARM_TIME\" TEXT);"); // 10: alarmTime + } + + /** Drops the underlying database table. */ + public static void dropTable(Database db, boolean ifExists) { + String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"ALARM_MESSAGE_LOCALE_BEAN\""; + db.execSQL(sql); + } + + @Override + protected final void bindValues(DatabaseStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + protected final void bindValues(SQLiteStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + public Long readKey(Cursor cursor, int offset) { + return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); + } + + @Override + public AlarmMessageLocaleBean readEntity(Cursor cursor, int offset) { + AlarmMessageLocaleBean entity = new AlarmMessageLocaleBean( // + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // messageId + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // appId + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // clientId + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // taskId + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // userId + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // title + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // content + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // deviceCode + cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // isRead + cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10) // alarmTime + ); + return entity; + } + + @Override + public void readEntity(Cursor cursor, AlarmMessageLocaleBean entity, int offset) { + entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); + entity.setMessageId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setAppId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setClientId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setTaskId(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); + entity.setUserId(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setTitle(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setContent(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); + entity.setDeviceCode(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); + entity.setIsRead(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9)); + entity.setAlarmTime(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); + } + + @Override + protected final Long updateKeyAfterInsert(AlarmMessageLocaleBean entity, long rowId) { + entity.setId(rowId); + return rowId; + } + + @Override + public Long getKey(AlarmMessageLocaleBean entity) { + if(entity != null) { + return entity.getId(); + } else { + return null; + } + } + + @Override + public boolean hasKey(AlarmMessageLocaleBean entity) { + return entity.getId() != null; + } + + @Override + protected final boolean isEntityUpdateable() { + return true; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java new file mode 100644 index 0000000..4222c40 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java @@ -0,0 +1,96 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.content.Context; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteDatabase.CursorFactory; +import android.util.Log; + +import org.greenrobot.greendao.AbstractDaoMaster; +import org.greenrobot.greendao.database.StandardDatabase; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseOpenHelper; +import org.greenrobot.greendao.identityscope.IdentityScopeType; + + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * Master of DAO (schema version 1): knows all DAOs. + */ +public class DaoMaster extends AbstractDaoMaster { + public static final int SCHEMA_VERSION = 1; + + /** Creates underlying database table using DAOs. */ + public static void createAllTables(Database db, boolean ifNotExists) { + AlarmMessageLocaleBeanDao.createTable(db, ifNotExists); + } + + /** Drops underlying database table using DAOs. */ + public static void dropAllTables(Database db, boolean ifExists) { + AlarmMessageLocaleBeanDao.dropTable(db, ifExists); + } + + /** + * WARNING: Drops all table on Upgrade! Use only during development. + * Convenience method using a {@link DevOpenHelper}. + */ + public static DaoSession newDevSession(Context context, String name) { + Database db = new DevOpenHelper(context, name).getWritableDb(); + DaoMaster daoMaster = new DaoMaster(db); + return daoMaster.newSession(); + } + + public DaoMaster(SQLiteDatabase db) { + this(new StandardDatabase(db)); + } + + public DaoMaster(Database db) { + super(db, SCHEMA_VERSION); + registerDaoClass(AlarmMessageLocaleBeanDao.class); + } + + public DaoSession newSession() { + return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); + } + + public DaoSession newSession(IdentityScopeType type) { + return new DaoSession(db, type, daoConfigMap); + } + + /** + * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} - + */ + public static abstract class OpenHelper extends DatabaseOpenHelper { + public OpenHelper(Context context, String name) { + super(context, name, SCHEMA_VERSION); + } + + public OpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory, SCHEMA_VERSION); + } + + @Override + public void onCreate(Database db) { + Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); + createAllTables(db, false); + } + } + + /** WARNING: Drops all table on Upgrade! Use only during development. */ + public static class DevOpenHelper extends OpenHelper { + public DevOpenHelper(Context context, String name) { + super(context, name); + } + + public DevOpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory); + } + + @Override + public void onUpgrade(Database db, int oldVersion, int newVersion) { + Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); + dropAllTables(db, true); + onCreate(db); + } + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java new file mode 100644 index 0000000..480ed84 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java @@ -0,0 +1,48 @@ +package com.casic.smart.town.sanxi.greendao; + +import java.util.Map; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.AbstractDaoSession; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.identityscope.IdentityScopeType; +import org.greenrobot.greendao.internal.DaoConfig; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. + +/** + * {@inheritDoc} + * + * @see org.greenrobot.greendao.AbstractDaoSession + */ +public class DaoSession extends AbstractDaoSession { + + private final DaoConfig alarmMessageLocaleBeanDaoConfig; + + private final AlarmMessageLocaleBeanDao alarmMessageLocaleBeanDao; + + public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> + daoConfigMap) { + super(db); + + alarmMessageLocaleBeanDaoConfig = daoConfigMap.get(AlarmMessageLocaleBeanDao.class).clone(); + alarmMessageLocaleBeanDaoConfig.initIdentityScope(type); + + alarmMessageLocaleBeanDao = new AlarmMessageLocaleBeanDao(alarmMessageLocaleBeanDaoConfig, this); + + registerDao(AlarmMessageLocaleBean.class, alarmMessageLocaleBeanDao); + } + + public void clear() { + alarmMessageLocaleBeanDaoConfig.clearIdentityScope(); + } + + public AlarmMessageLocaleBeanDao getAlarmMessageLocaleBeanDao() { + return alarmMessageLocaleBeanDao; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt new file mode 100644 index 0000000..875cb8c --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt @@ -0,0 +1,5 @@ +package com.casic.smart.town.sanxi.service + +import com.igexin.sdk.PushService + +class ApplicationPushService : PushService() \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt new file mode 100644 index 0000000..396129f --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt @@ -0,0 +1,84 @@ +package com.casic.smart.town.sanxi.service + +import android.content.Context +import android.os.Message +import android.util.Log +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.casic.smart.town.sanxi.view.MainActivity +import com.igexin.sdk.GTIntentService +import com.igexin.sdk.message.GTCmdMessage +import com.igexin.sdk.message.GTNotificationMessage +import com.igexin.sdk.message.GTTransmitMessage +import com.pengxh.kt.lite.extensions.toJson + +class PushIntentService : GTIntentService() { + + private val kTag = "SmartWellIntentService" + + override fun onReceiveServicePid(context: Context?, pid: Int) { + + } + + // 透传消息 + override fun onReceiveMessageData(context: Context?, msg: GTTransmitMessage?) { + Log.d(kTag, "透传消息 -> msg = $msg") + } + + // 接收 cid + override fun onReceiveClientId(context: Context?, clientid: String?) { + Log.d(kTag, "onReceiveClientId -> $clientid") + //通知MainActivity注册个推服务 + val msg: Message = MainActivity.weakReferenceHandler.obtainMessage() + msg.what = LocaleConstant.PUSH_REGISTER + msg.obj = clientid + MainActivity.weakReferenceHandler.sendMessage(msg) + } + + // cid 离线上线通知 + override fun onReceiveOnlineState(context: Context?, online: Boolean) { + + } + + // 各种事件处理回执 + override fun onReceiveCommandResult(context: Context?, msg: GTCmdMessage?) { + + } + + // 通知到达 + override fun onNotificationMessageArrived(context: Context?, msg: GTNotificationMessage?) { + //报警 +// { +// "content": "设备编号[412022030361]发生井盖开盖报警", +// "messageId": "380abf9a79d34306a2683dc9bf96ee78", +// "taskId": "OSL-0830_4hmfimp3Vu684wo3SjXso9", +// "title": "告警提醒", +// "appid": "HKv8K9qARd6WckZ1o2Vbu4", +// "clientId": "e78beacc42e9a02ae6fb9087eb2b1171", +// "pkgName": "com.casic.app.smartwell" +// } + if (msg == null) { + return + } + Log.d(kTag, "通知到达 -> msg = ${msg.toJson()}") +// val userDetailJson = SaveKeyValues.getValue(LocaleConstant.USER_DETAIL_MODEL, "") as String +// var userId = "" +// if (userDetailJson.isNotBlank()) { +// val userDataModel = Gson().fromJson( +// userDetailJson, object : TypeToken() {}.type +// ) +// userId = userDataModel.id.toString() +// } +// //解析编号 +// val splitArray = msg.content.split("\\[|\\]".toRegex()) +// DataBaseManager.instance.insertNotice( +// msg.messageId, msg.appid, msg.clientId, msg.taskId, +// userId, msg.title, msg.content, splitArray[1], "0", +// System.currentTimeMillis().timestampToCompleteDate() +// ) + } + + // 通知点击 + override fun onNotificationMessageClicked(context: Context?, msg: GTNotificationMessage?) { + Log.d(kTag, "通知点击 -> msg = $msg") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt new file mode 100644 index 0000000..daa7c38 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt @@ -0,0 +1,14 @@ +package com.casic.smart.town.sanxi.util + +import android.content.Context +import me.leolin.shortcutbadger.ShortcutBadger + +object BadeHelper { + fun setBadgeNum(context: Context, badgeCount: Int) { + if (badgeCount == 0) { + ShortcutBadger.removeCount(context) + } else { + ShortcutBadger.applyCount(context, badgeCount) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt new file mode 100644 index 0000000..0a52ef2 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt @@ -0,0 +1,75 @@ +package com.casic.smart.town.sanxi.util + +import com.casic.smart.town.sanxi.base.BaseApplication +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao + +class DataBaseManager private constructor() { + + companion object { + //Kotlin委托模式双重锁单例 + val instance: DataBaseManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) { + DataBaseManager() + } + } + + private val beanDao = + BaseApplication.obtainInstance().obtainDaoSession().alarmMessageLocaleBeanDao + +// fun insertNotice( +// messageId: String, appid: String, clientId: String, +// taskId: String, userId: String, title: String, +// content: String, deviceCode: String, isRead: String, +// noticeTime: String +// ) { +// val noticeLocaleBean = NoticeLocaleBean() +// noticeLocaleBean.messageId = messageId +// noticeLocaleBean.appid = appid +// noticeLocaleBean.clientId = clientId +// noticeLocaleBean.taskId = taskId +// noticeLocaleBean.userId = userId +// noticeLocaleBean.title = title +// noticeLocaleBean.content = content +// noticeLocaleBean.deviceCode = deviceCode +// noticeLocaleBean.isRead = isRead +// noticeLocaleBean.noticeTime = noticeTime +// beanDao.insert(noticeLocaleBean) +// //角标设置 +// BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadNotice()) +// } + + fun deleteByMessageId(messageId: String) { + val result = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).list() + beanDao.deleteInTx(result) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun updateNoticeByMessageId(messageId: String) { + val noticeLocaleBean = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).unique() ?: return + noticeLocaleBean.isRead = "1" + beanDao.update(noticeLocaleBean) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun queryMessageByPage(userId: String, offset: Int): MutableList { + return BaseApplication.obtainInstance().obtainDaoSession() + .queryBuilder(AlarmMessageLocaleBean::class.java) + .where(AlarmMessageLocaleBeanDao.Properties.UserId.eq(userId)) + .offset(offset * LocaleConstant.PAGE_LIMIT) + .orderDesc(AlarmMessageLocaleBeanDao.Properties.AlarmTime) + .limit(LocaleConstant.PAGE_LIMIT) + .list() + } + + private fun queryUnReadMessage(): Int { + return beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.IsRead.eq("0") + ).list().size + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt new file mode 100644 index 0000000..52926a8 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt @@ -0,0 +1,31 @@ +package com.casic.smart.town.sanxi.util; + +import android.app.Activity +import android.view.WindowManager +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object LoadingDialogHub { + private lateinit var loadingDialog: QMUITipDialog + + fun show(activity: Activity, message: String) { + loadingDialog = QMUITipDialog + .Builder(activity) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_LOADING) + .setTipWord(message) + .create() + if (!activity.isDestroyed) { + try { + loadingDialog.show() + } catch (e: WindowManager.BadTokenException) { + e.printStackTrace() + } + } + } + + + fun dismiss() { + if (loadingDialog.isShowing) { + loadingDialog.dismiss() + } + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt new file mode 100644 index 0000000..de61c9a --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.util + +import android.Manifest + +object LocaleConstant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.READ_PHONE_STATE, + Manifest.permission.ACCESS_COARSE_LOCATION, + Manifest.permission.READ_EXTERNAL_STORAGE + ) + + const val PERMISSIONS_CODE = 999 + const val PUSH_REGISTER = 2022100101 + const val PAGE_LIMIT = 20 +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt new file mode 100644 index 0000000..3bea1c9 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt @@ -0,0 +1,112 @@ +package com.casic.smart.town.sanxi.view + +import android.view.KeyEvent +import android.view.MenuItem +import androidx.fragment.app.Fragment +import androidx.viewpager.widget.ViewPager +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.adapter.ViewPagerAdapter +import com.casic.smart.town.sanxi.fragment.AlarmPageFragment +import com.casic.smart.town.sanxi.fragment.MonitorPageFragment +import com.casic.smart.town.sanxi.fragment.StatisticsPageFragment +import com.gyf.immersionbar.ImmersionBar +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.base.KotlinBaseActivity +import com.pengxh.kt.lite.extensions.convertColor +import com.pengxh.kt.lite.extensions.show +import com.pengxh.kt.lite.utils.ImmerseStatusBarUtil +import com.pengxh.kt.lite.utils.WeakReferenceHandler +import kotlinx.android.synthetic.main.activity_main.* + +class MainActivity : KotlinBaseActivity() { + + companion object { + lateinit var weakReferenceHandler: WeakReferenceHandler + } + + private val kTag = "MainActivity" + private var menuItem: MenuItem? = null + private var fragmentPages: ArrayList = ArrayList() + private var clickTime: Long = 0 + + init { + fragmentPages.add(StatisticsPageFragment()) + fragmentPages.add(MonitorPageFragment()) + fragmentPages.add(AlarmPageFragment()) + } + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + ImmersionBar.with(this).statusBarDarkFont(false).init() + ImmerseStatusBarUtil.setColor(this, R.color.mainThemeColor.convertColor(this)) + } + + override fun initData() { + //推送,多次调用 SDK 初始化并无影响。 + PushManager.getInstance().initialize(this) + weakReferenceHandler = WeakReferenceHandler { + + true + } + } + + override fun observeRequestState() { + + } + + override fun initEvent() { + bottomNavigation.itemIconTintList = null + bottomNavigation.setOnNavigationItemSelectedListener { menuItem -> + when (menuItem.itemId) { + R.id.nav_statistics -> { + mainViewPager.currentItem = 0 + } + R.id.nav_monitor -> { + mainViewPager.currentItem = 1 + } + R.id.nav_alarm -> { + mainViewPager.currentItem = 2 + } + } + false + } + mainViewPager.adapter = ViewPagerAdapter(fragmentPages, supportFragmentManager) + mainViewPager.offscreenPageLimit = fragmentPages.size //缓存页数 + mainViewPager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener { + override fun onPageScrollStateChanged(state: Int) { + + } + + override fun onPageScrolled( + position: Int, + positionOffset: Float, + positionOffsetPixels: Int + ) { + + } + + override fun onPageSelected(position: Int) { + if (menuItem != null) { + menuItem!!.isChecked = false + } else { + bottomNavigation.menu.getItem(0).isChecked = false + } + menuItem = bottomNavigation.menu.getItem(position) + menuItem!!.isChecked = true + } + }) + } + + override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean { + return if (keyCode == KeyEvent.KEYCODE_BACK) { + if (System.currentTimeMillis() - clickTime > 2000) { + "再按一次退出程序".show(this) + clickTime = System.currentTimeMillis() + true + } else { + super.onKeyDown(keyCode, event) + } + } else super.onKeyDown(keyCode, event) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt new file mode 100644 index 0000000..c5d8b22 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.view + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseActivity + +class MonitorRecordActivity : KotlinBaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_monitor_record + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt new file mode 100644 index 0000000..c478d83 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt @@ -0,0 +1,55 @@ +package com.casic.smart.town.sanxi.view + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.amap.api.maps.MapsInitializer +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.gyf.immersionbar.ImmersionBar +import com.pengxh.kt.lite.extensions.navigatePageTo +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + ImmersionBar.with(this).statusBarDarkFont(true).init() + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (EasyPermissions.hasPermissions(this, *LocaleConstant.USER_PERMISSIONS)) { + startSplashScreenActivity() + } else { + EasyPermissions.requestPermissions( + this@PermissionActivity, + resources.getString(R.string.app_name) + "需要获取相关权限", + LocaleConstant.PERMISSIONS_CODE, + *LocaleConstant.USER_PERMISSIONS + ) + } + } + + private fun startSplashScreenActivity() { + //先把导航隐私政策声明,后面导航会用到 + MapsInitializer.updatePrivacyAgree(this, true) + MapsInitializer.updatePrivacyShow(this, true, true) + this.navigatePageTo() + 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) { + startSplashScreenActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable/alarm_selector.xml b/app/src/main/res/drawable/alarm_selector.xml new file mode 100644 index 0000000..39b2595 --- /dev/null +++ b/app/src/main/res/drawable/alarm_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bottom_text_color.xml b/app/src/main/res/drawable/bottom_text_color.xml new file mode 100644 index 0000000..b284ea3 --- /dev/null +++ b/app/src/main/res/drawable/bottom_text_color.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_alarm.xml b/app/src/main/res/drawable/ic_alarm.xml new file mode 100644 index 0000000..dc33aab --- /dev/null +++ b/app/src/main/res/drawable/ic_alarm.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_alarm_selected.xml b/app/src/main/res/drawable/ic_alarm_selected.xml new file mode 100644 index 0000000..993fea6 --- /dev/null +++ b/app/src/main/res/drawable/ic_alarm_selected.xml @@ -0,0 +1,9 @@ + + + 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_monitor.xml b/app/src/main/res/drawable/ic_monitor.xml new file mode 100644 index 0000000..271f5b4 --- /dev/null +++ b/app/src/main/res/drawable/ic_monitor.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_monitor_selected.xml b/app/src/main/res/drawable/ic_monitor_selected.xml new file mode 100644 index 0000000..ee62d84 --- /dev/null +++ b/app/src/main/res/drawable/ic_monitor_selected.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_statistics.xml b/app/src/main/res/drawable/ic_statistics.xml new file mode 100644 index 0000000..7fde8ec --- /dev/null +++ b/app/src/main/res/drawable/ic_statistics.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_statistics_selected.xml b/app/src/main/res/drawable/ic_statistics_selected.xml new file mode 100644 index 0000000..49b6fcd --- /dev/null +++ b/app/src/main/res/drawable/ic_statistics_selected.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/monitor_selector.xml b/app/src/main/res/drawable/monitor_selector.xml new file mode 100644 index 0000000..fe11e9a --- /dev/null +++ b/app/src/main/res/drawable/monitor_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/statistics_selector.xml b/app/src/main/res/drawable/statistics_selector.xml new file mode 100644 index 0000000..2156cff --- /dev/null +++ b/app/src/main/res/drawable/statistics_selector.xml @@ -0,0 +1,5 @@ + + + + + \ 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..78a4a94 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,27 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_monitor_record.xml b/app/src/main/res/layout/activity_monitor_record.xml new file mode 100644 index 0000000..77d9ef6 --- /dev/null +++ b/app/src/main/res/layout/activity_monitor_record.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..10cfdbf --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*.iml +.gradle +/local.properties +/.idea +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..a4cd2ca --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,101 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'org.greenrobot.greendao' + +android { +// signingConfigs { +// release { +// storeFile file('/Users/a203/Desktop/AndroidProjects/CasicSmartWell/app/CasicSmartWell.jks') +// storePassword '123456789' +// keyAlias 'key0' +// keyPassword '123456789' +// } +// } + compileSdkVersion 31 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.smart.town.sanxi" + minSdkVersion 23 + targetSdkVersion 31 + versionCode 1 + versionName "1.0.0" + + manifestPlaceholders = [GETUI_APPID: "A9V4DvwLcdAqkFCQuFyhq6"] + } + + buildTypes { + release { + minifyEnabled false +// signingConfig signingConfigs.release + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + + ndk { abiFilters "armeabi", "armeabi-v7a", "arm64-v8" } + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlin { + experimental { + coroutines 'enable' + } + } + + greendao { + schemaVersion 1//数据库版本号 + targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 + daoPackage 'com.casic.smart.town.sanxi.greendao'//设置DaoMaster、DaoSession、Dao包名 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + //基础依赖库 + implementation files('libs/lite-release.aar') + implementation 'androidx.appcompat:appcompat:1.4.2' + implementation 'androidx.core:core-ktx:1.8.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:3.0.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' + //MVVM+LiveData + implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.1" + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0" + implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + //Kotlin协程 + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1' + //图片加载框架 + implementation 'com.github.bumptech.glide:glide:4.9.0' + //返回值转换器 + implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' + implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + //okhttp3日志拦截器 + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //网络请求和接口封装 + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.9.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.9.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' + //高德地图 + implementation 'com.amap.api:3dmap:latest.integration' + //推送SDK + implementation 'com.getui:gtsdk:3.2.10.0' //个推SDK + implementation 'com.getui:gtc:3.1.9.0' //个推核心组件 + //数据库框架 + implementation 'org.greenrobot:greendao:3.3.0' + //桌面角标 + implementation "me.leolin:ShortcutBadger:1.1.22@aar" +} \ No newline at end of file diff --git a/app/libs/lite-release.aar b/app/libs/lite-release.aar new file mode 100644 index 0000000..45da4df --- /dev/null +++ b/app/libs/lite-release.aar Binary files differ diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /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 \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..a83c28a --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/svg/monitor.svg b/app/src/main/assets/svg/monitor.svg new file mode 100644 index 0000000..c8d3e25 --- /dev/null +++ b/app/src/main/assets/svg/monitor.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/msg.svg b/app/src/main/assets/svg/msg.svg new file mode 100644 index 0000000..e864e48 --- /dev/null +++ b/app/src/main/assets/svg/msg.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/statistics.svg b/app/src/main/assets/svg/statistics.svg new file mode 100644 index 0000000..974000e --- /dev/null +++ b/app/src/main/assets/svg/statistics.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt new file mode 100644 index 0000000..6b9cce0 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.adapter + +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentManager +import androidx.fragment.app.FragmentPagerAdapter + +class ViewPagerAdapter(list: ArrayList, manager: FragmentManager) : + FragmentPagerAdapter(manager) { + + private var pageList: List = list + + override fun getItem(position: Int) = pageList[position] + + override fun getCount() = pageList.size +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt new file mode 100644 index 0000000..4e017b1 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt @@ -0,0 +1,40 @@ +package com.casic.smart.town.sanxi.base + +import android.app.Application +import android.util.Log +import com.casic.smart.town.sanxi.greendao.DaoMaster +import com.casic.smart.town.sanxi.greendao.DaoSession +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + private val kTag = "BaseApplication" + + companion object { + private var instance: BaseApplication by Delegates.notNull() + + fun obtainInstance() = instance + + private lateinit var daoSession: DaoSession + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences(this) + //推送 + PushManager.getInstance().initialize(this) + PushManager.getInstance().setDebugLogger(this) { + Log.d(kTag, it) + } + val devOpenHelper = DaoMaster.DevOpenHelper(this, "SmartTown.db", null) + val daoMaster = DaoMaster(devOpenHelper.writableDatabase) + daoSession = daoMaster.newSession() + } + + fun obtainDaoSession(): DaoSession { + return daoSession + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java new file mode 100644 index 0000000..b8f67dc --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java @@ -0,0 +1,133 @@ +package com.casic.smart.town.sanxi.bean; + +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Generated; +import org.greenrobot.greendao.annotation.Id; +import org.greenrobot.greendao.annotation.Unique; + +@Entity +public class AlarmMessageLocaleBean { + @Id(autoincrement = true) + private Long id;//主键自增 + + @Unique + private String messageId; + private String appId; + private String clientId; + private String taskId; + private String userId; + private String title; + private String content; + private String deviceCode; + private String isRead;//0-未读,1-已读 + private String alarmTime; + + @Generated(hash = 566950134) + public AlarmMessageLocaleBean(Long id, String messageId, String appId, + String clientId, String taskId, String userId, String title, + String content, String deviceCode, String isRead, String alarmTime) { + this.id = id; + this.messageId = messageId; + this.appId = appId; + this.clientId = clientId; + this.taskId = taskId; + this.userId = userId; + this.title = title; + this.content = content; + this.deviceCode = deviceCode; + this.isRead = isRead; + this.alarmTime = alarmTime; + } + + @Generated(hash = 1737519562) + public AlarmMessageLocaleBean() { + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getMessageId() { + return this.messageId; + } + + public void setMessageId(String messageId) { + this.messageId = messageId; + } + + public String getAppId() { + return this.appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public String getClientId() { + return this.clientId; + } + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public String getTaskId() { + return this.taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getUserId() { + return this.userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getTitle() { + return this.title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return this.content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getDeviceCode() { + return this.deviceCode; + } + + public void setDeviceCode(String deviceCode) { + this.deviceCode = deviceCode; + } + + public String getIsRead() { + return this.isRead; + } + + public void setIsRead(String isRead) { + this.isRead = isRead; + } + + public String getAlarmTime() { + return this.alarmTime; + } + + public void setAlarmTime(String alarmTime) { + this.alarmTime = alarmTime; + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt new file mode 100644 index 0000000..650e201 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class AlarmPageFragment: KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_alarm + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt new file mode 100644 index 0000000..deac8ac --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt @@ -0,0 +1,76 @@ +package com.casic.smart.town.sanxi.fragment + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.Fragment +import com.amap.api.maps.AMap +import com.amap.api.maps.AMapOptions +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.view.MonitorRecordActivity +import com.pengxh.kt.lite.extensions.navigatePageTo +import com.pengxh.kt.lite.extensions.show +import kotlinx.android.synthetic.main.fragment_monitor.view.* + +class MonitorPageFragment : Fragment() { + + private val kTag = "HomePageFragment" + private lateinit var monitorView: View + private lateinit var aMap: AMap + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? + ): View { + monitorView = inflater.inflate(R.layout.fragment_monitor, container, false) + //地图初始化 + initMap(savedInstanceState) + + monitorView.rightOperateView.setOnClickListener { + requireContext().navigatePageTo() + } + return monitorView + } + + private fun initMap(savedInstanceState: Bundle?) { + monitorView.mapView.onCreate(savedInstanceState) + aMap = monitorView.mapView.map + aMap.mapType = AMap.MAP_TYPE_NORMAL + val uiSettings = aMap.uiSettings + uiSettings.isCompassEnabled = true + uiSettings.zoomPosition = AMapOptions.ZOOM_POSITION_RIGHT_CENTER + uiSettings.isTiltGesturesEnabled = false//不许地图随手势倾斜角度 + + // 地图加载成功监听 +// aMap.addOnMapLoadedListener(this) + // 地图缩放监听 +// aMap.addOnCameraChangeListener(this) + // marker 点击事件监听 +// aMap.addOnMarkerClickListener(this) + // 点击marker弹出自定义popup +// aMap.setInfoWindowAdapter(this) + //信息窗点击事件 +// aMap.addOnInfoWindowClickListener(this) + } + + /***以下是地图生命周期管理************************************************************************/ + override fun onResume() { + super.onResume() + monitorView.mapView.onResume() + } + + override fun onPause() { + super.onPause() + monitorView.mapView.onPause() + } + + override fun onSaveInstanceState(outState: Bundle) { + super.onSaveInstanceState(outState) + monitorView.mapView.onSaveInstanceState(outState) + } + + override fun onDestroy() { + super.onDestroy() + monitorView.mapView.onDestroy() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt new file mode 100644 index 0000000..e84df12 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class StatisticsPageFragment : KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_statistics + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java new file mode 100644 index 0000000..68d7901 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java @@ -0,0 +1,255 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.database.Cursor; +import android.database.sqlite.SQLiteStatement; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.Property; +import org.greenrobot.greendao.internal.DaoConfig; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseStatement; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * DAO for table "ALARM_MESSAGE_LOCALE_BEAN". +*/ +public class AlarmMessageLocaleBeanDao extends AbstractDao { + + public static final String TABLENAME = "ALARM_MESSAGE_LOCALE_BEAN"; + + /** + * Properties of entity AlarmMessageLocaleBean.
+ * Can be used for QueryBuilder and for referencing column names. + */ + public static class Properties { + public final static Property Id = new Property(0, Long.class, "id", true, "_id"); + public final static Property MessageId = new Property(1, String.class, "messageId", false, "MESSAGE_ID"); + public final static Property AppId = new Property(2, String.class, "appId", false, "APP_ID"); + public final static Property ClientId = new Property(3, String.class, "clientId", false, "CLIENT_ID"); + public final static Property TaskId = new Property(4, String.class, "taskId", false, "TASK_ID"); + public final static Property UserId = new Property(5, String.class, "userId", false, "USER_ID"); + public final static Property Title = new Property(6, String.class, "title", false, "TITLE"); + public final static Property Content = new Property(7, String.class, "content", false, "CONTENT"); + public final static Property DeviceCode = new Property(8, String.class, "deviceCode", false, "DEVICE_CODE"); + public final static Property IsRead = new Property(9, String.class, "isRead", false, "IS_READ"); + public final static Property AlarmTime = new Property(10, String.class, "alarmTime", false, "ALARM_TIME"); + } + + + public AlarmMessageLocaleBeanDao(DaoConfig config) { + super(config); + } + + public AlarmMessageLocaleBeanDao(DaoConfig config, DaoSession daoSession) { + super(config, daoSession); + } + + /** Creates the underlying database table. */ + public static void createTable(Database db, boolean ifNotExists) { + String constraint = ifNotExists? "IF NOT EXISTS ": ""; + db.execSQL("CREATE TABLE " + constraint + "\"ALARM_MESSAGE_LOCALE_BEAN\" (" + // + "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id + "\"MESSAGE_ID\" TEXT UNIQUE ," + // 1: messageId + "\"APP_ID\" TEXT," + // 2: appId + "\"CLIENT_ID\" TEXT," + // 3: clientId + "\"TASK_ID\" TEXT," + // 4: taskId + "\"USER_ID\" TEXT," + // 5: userId + "\"TITLE\" TEXT," + // 6: title + "\"CONTENT\" TEXT," + // 7: content + "\"DEVICE_CODE\" TEXT," + // 8: deviceCode + "\"IS_READ\" TEXT," + // 9: isRead + "\"ALARM_TIME\" TEXT);"); // 10: alarmTime + } + + /** Drops the underlying database table. */ + public static void dropTable(Database db, boolean ifExists) { + String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"ALARM_MESSAGE_LOCALE_BEAN\""; + db.execSQL(sql); + } + + @Override + protected final void bindValues(DatabaseStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + protected final void bindValues(SQLiteStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + public Long readKey(Cursor cursor, int offset) { + return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); + } + + @Override + public AlarmMessageLocaleBean readEntity(Cursor cursor, int offset) { + AlarmMessageLocaleBean entity = new AlarmMessageLocaleBean( // + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // messageId + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // appId + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // clientId + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // taskId + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // userId + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // title + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // content + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // deviceCode + cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // isRead + cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10) // alarmTime + ); + return entity; + } + + @Override + public void readEntity(Cursor cursor, AlarmMessageLocaleBean entity, int offset) { + entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); + entity.setMessageId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setAppId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setClientId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setTaskId(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); + entity.setUserId(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setTitle(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setContent(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); + entity.setDeviceCode(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); + entity.setIsRead(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9)); + entity.setAlarmTime(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); + } + + @Override + protected final Long updateKeyAfterInsert(AlarmMessageLocaleBean entity, long rowId) { + entity.setId(rowId); + return rowId; + } + + @Override + public Long getKey(AlarmMessageLocaleBean entity) { + if(entity != null) { + return entity.getId(); + } else { + return null; + } + } + + @Override + public boolean hasKey(AlarmMessageLocaleBean entity) { + return entity.getId() != null; + } + + @Override + protected final boolean isEntityUpdateable() { + return true; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java new file mode 100644 index 0000000..4222c40 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java @@ -0,0 +1,96 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.content.Context; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteDatabase.CursorFactory; +import android.util.Log; + +import org.greenrobot.greendao.AbstractDaoMaster; +import org.greenrobot.greendao.database.StandardDatabase; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseOpenHelper; +import org.greenrobot.greendao.identityscope.IdentityScopeType; + + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * Master of DAO (schema version 1): knows all DAOs. + */ +public class DaoMaster extends AbstractDaoMaster { + public static final int SCHEMA_VERSION = 1; + + /** Creates underlying database table using DAOs. */ + public static void createAllTables(Database db, boolean ifNotExists) { + AlarmMessageLocaleBeanDao.createTable(db, ifNotExists); + } + + /** Drops underlying database table using DAOs. */ + public static void dropAllTables(Database db, boolean ifExists) { + AlarmMessageLocaleBeanDao.dropTable(db, ifExists); + } + + /** + * WARNING: Drops all table on Upgrade! Use only during development. + * Convenience method using a {@link DevOpenHelper}. + */ + public static DaoSession newDevSession(Context context, String name) { + Database db = new DevOpenHelper(context, name).getWritableDb(); + DaoMaster daoMaster = new DaoMaster(db); + return daoMaster.newSession(); + } + + public DaoMaster(SQLiteDatabase db) { + this(new StandardDatabase(db)); + } + + public DaoMaster(Database db) { + super(db, SCHEMA_VERSION); + registerDaoClass(AlarmMessageLocaleBeanDao.class); + } + + public DaoSession newSession() { + return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); + } + + public DaoSession newSession(IdentityScopeType type) { + return new DaoSession(db, type, daoConfigMap); + } + + /** + * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} - + */ + public static abstract class OpenHelper extends DatabaseOpenHelper { + public OpenHelper(Context context, String name) { + super(context, name, SCHEMA_VERSION); + } + + public OpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory, SCHEMA_VERSION); + } + + @Override + public void onCreate(Database db) { + Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); + createAllTables(db, false); + } + } + + /** WARNING: Drops all table on Upgrade! Use only during development. */ + public static class DevOpenHelper extends OpenHelper { + public DevOpenHelper(Context context, String name) { + super(context, name); + } + + public DevOpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory); + } + + @Override + public void onUpgrade(Database db, int oldVersion, int newVersion) { + Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); + dropAllTables(db, true); + onCreate(db); + } + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java new file mode 100644 index 0000000..480ed84 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java @@ -0,0 +1,48 @@ +package com.casic.smart.town.sanxi.greendao; + +import java.util.Map; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.AbstractDaoSession; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.identityscope.IdentityScopeType; +import org.greenrobot.greendao.internal.DaoConfig; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. + +/** + * {@inheritDoc} + * + * @see org.greenrobot.greendao.AbstractDaoSession + */ +public class DaoSession extends AbstractDaoSession { + + private final DaoConfig alarmMessageLocaleBeanDaoConfig; + + private final AlarmMessageLocaleBeanDao alarmMessageLocaleBeanDao; + + public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> + daoConfigMap) { + super(db); + + alarmMessageLocaleBeanDaoConfig = daoConfigMap.get(AlarmMessageLocaleBeanDao.class).clone(); + alarmMessageLocaleBeanDaoConfig.initIdentityScope(type); + + alarmMessageLocaleBeanDao = new AlarmMessageLocaleBeanDao(alarmMessageLocaleBeanDaoConfig, this); + + registerDao(AlarmMessageLocaleBean.class, alarmMessageLocaleBeanDao); + } + + public void clear() { + alarmMessageLocaleBeanDaoConfig.clearIdentityScope(); + } + + public AlarmMessageLocaleBeanDao getAlarmMessageLocaleBeanDao() { + return alarmMessageLocaleBeanDao; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt new file mode 100644 index 0000000..875cb8c --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt @@ -0,0 +1,5 @@ +package com.casic.smart.town.sanxi.service + +import com.igexin.sdk.PushService + +class ApplicationPushService : PushService() \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt new file mode 100644 index 0000000..396129f --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt @@ -0,0 +1,84 @@ +package com.casic.smart.town.sanxi.service + +import android.content.Context +import android.os.Message +import android.util.Log +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.casic.smart.town.sanxi.view.MainActivity +import com.igexin.sdk.GTIntentService +import com.igexin.sdk.message.GTCmdMessage +import com.igexin.sdk.message.GTNotificationMessage +import com.igexin.sdk.message.GTTransmitMessage +import com.pengxh.kt.lite.extensions.toJson + +class PushIntentService : GTIntentService() { + + private val kTag = "SmartWellIntentService" + + override fun onReceiveServicePid(context: Context?, pid: Int) { + + } + + // 透传消息 + override fun onReceiveMessageData(context: Context?, msg: GTTransmitMessage?) { + Log.d(kTag, "透传消息 -> msg = $msg") + } + + // 接收 cid + override fun onReceiveClientId(context: Context?, clientid: String?) { + Log.d(kTag, "onReceiveClientId -> $clientid") + //通知MainActivity注册个推服务 + val msg: Message = MainActivity.weakReferenceHandler.obtainMessage() + msg.what = LocaleConstant.PUSH_REGISTER + msg.obj = clientid + MainActivity.weakReferenceHandler.sendMessage(msg) + } + + // cid 离线上线通知 + override fun onReceiveOnlineState(context: Context?, online: Boolean) { + + } + + // 各种事件处理回执 + override fun onReceiveCommandResult(context: Context?, msg: GTCmdMessage?) { + + } + + // 通知到达 + override fun onNotificationMessageArrived(context: Context?, msg: GTNotificationMessage?) { + //报警 +// { +// "content": "设备编号[412022030361]发生井盖开盖报警", +// "messageId": "380abf9a79d34306a2683dc9bf96ee78", +// "taskId": "OSL-0830_4hmfimp3Vu684wo3SjXso9", +// "title": "告警提醒", +// "appid": "HKv8K9qARd6WckZ1o2Vbu4", +// "clientId": "e78beacc42e9a02ae6fb9087eb2b1171", +// "pkgName": "com.casic.app.smartwell" +// } + if (msg == null) { + return + } + Log.d(kTag, "通知到达 -> msg = ${msg.toJson()}") +// val userDetailJson = SaveKeyValues.getValue(LocaleConstant.USER_DETAIL_MODEL, "") as String +// var userId = "" +// if (userDetailJson.isNotBlank()) { +// val userDataModel = Gson().fromJson( +// userDetailJson, object : TypeToken() {}.type +// ) +// userId = userDataModel.id.toString() +// } +// //解析编号 +// val splitArray = msg.content.split("\\[|\\]".toRegex()) +// DataBaseManager.instance.insertNotice( +// msg.messageId, msg.appid, msg.clientId, msg.taskId, +// userId, msg.title, msg.content, splitArray[1], "0", +// System.currentTimeMillis().timestampToCompleteDate() +// ) + } + + // 通知点击 + override fun onNotificationMessageClicked(context: Context?, msg: GTNotificationMessage?) { + Log.d(kTag, "通知点击 -> msg = $msg") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt new file mode 100644 index 0000000..daa7c38 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt @@ -0,0 +1,14 @@ +package com.casic.smart.town.sanxi.util + +import android.content.Context +import me.leolin.shortcutbadger.ShortcutBadger + +object BadeHelper { + fun setBadgeNum(context: Context, badgeCount: Int) { + if (badgeCount == 0) { + ShortcutBadger.removeCount(context) + } else { + ShortcutBadger.applyCount(context, badgeCount) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt new file mode 100644 index 0000000..0a52ef2 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt @@ -0,0 +1,75 @@ +package com.casic.smart.town.sanxi.util + +import com.casic.smart.town.sanxi.base.BaseApplication +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao + +class DataBaseManager private constructor() { + + companion object { + //Kotlin委托模式双重锁单例 + val instance: DataBaseManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) { + DataBaseManager() + } + } + + private val beanDao = + BaseApplication.obtainInstance().obtainDaoSession().alarmMessageLocaleBeanDao + +// fun insertNotice( +// messageId: String, appid: String, clientId: String, +// taskId: String, userId: String, title: String, +// content: String, deviceCode: String, isRead: String, +// noticeTime: String +// ) { +// val noticeLocaleBean = NoticeLocaleBean() +// noticeLocaleBean.messageId = messageId +// noticeLocaleBean.appid = appid +// noticeLocaleBean.clientId = clientId +// noticeLocaleBean.taskId = taskId +// noticeLocaleBean.userId = userId +// noticeLocaleBean.title = title +// noticeLocaleBean.content = content +// noticeLocaleBean.deviceCode = deviceCode +// noticeLocaleBean.isRead = isRead +// noticeLocaleBean.noticeTime = noticeTime +// beanDao.insert(noticeLocaleBean) +// //角标设置 +// BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadNotice()) +// } + + fun deleteByMessageId(messageId: String) { + val result = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).list() + beanDao.deleteInTx(result) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun updateNoticeByMessageId(messageId: String) { + val noticeLocaleBean = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).unique() ?: return + noticeLocaleBean.isRead = "1" + beanDao.update(noticeLocaleBean) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun queryMessageByPage(userId: String, offset: Int): MutableList { + return BaseApplication.obtainInstance().obtainDaoSession() + .queryBuilder(AlarmMessageLocaleBean::class.java) + .where(AlarmMessageLocaleBeanDao.Properties.UserId.eq(userId)) + .offset(offset * LocaleConstant.PAGE_LIMIT) + .orderDesc(AlarmMessageLocaleBeanDao.Properties.AlarmTime) + .limit(LocaleConstant.PAGE_LIMIT) + .list() + } + + private fun queryUnReadMessage(): Int { + return beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.IsRead.eq("0") + ).list().size + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt new file mode 100644 index 0000000..52926a8 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt @@ -0,0 +1,31 @@ +package com.casic.smart.town.sanxi.util; + +import android.app.Activity +import android.view.WindowManager +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object LoadingDialogHub { + private lateinit var loadingDialog: QMUITipDialog + + fun show(activity: Activity, message: String) { + loadingDialog = QMUITipDialog + .Builder(activity) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_LOADING) + .setTipWord(message) + .create() + if (!activity.isDestroyed) { + try { + loadingDialog.show() + } catch (e: WindowManager.BadTokenException) { + e.printStackTrace() + } + } + } + + + fun dismiss() { + if (loadingDialog.isShowing) { + loadingDialog.dismiss() + } + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt new file mode 100644 index 0000000..de61c9a --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.util + +import android.Manifest + +object LocaleConstant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.READ_PHONE_STATE, + Manifest.permission.ACCESS_COARSE_LOCATION, + Manifest.permission.READ_EXTERNAL_STORAGE + ) + + const val PERMISSIONS_CODE = 999 + const val PUSH_REGISTER = 2022100101 + const val PAGE_LIMIT = 20 +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt new file mode 100644 index 0000000..3bea1c9 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt @@ -0,0 +1,112 @@ +package com.casic.smart.town.sanxi.view + +import android.view.KeyEvent +import android.view.MenuItem +import androidx.fragment.app.Fragment +import androidx.viewpager.widget.ViewPager +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.adapter.ViewPagerAdapter +import com.casic.smart.town.sanxi.fragment.AlarmPageFragment +import com.casic.smart.town.sanxi.fragment.MonitorPageFragment +import com.casic.smart.town.sanxi.fragment.StatisticsPageFragment +import com.gyf.immersionbar.ImmersionBar +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.base.KotlinBaseActivity +import com.pengxh.kt.lite.extensions.convertColor +import com.pengxh.kt.lite.extensions.show +import com.pengxh.kt.lite.utils.ImmerseStatusBarUtil +import com.pengxh.kt.lite.utils.WeakReferenceHandler +import kotlinx.android.synthetic.main.activity_main.* + +class MainActivity : KotlinBaseActivity() { + + companion object { + lateinit var weakReferenceHandler: WeakReferenceHandler + } + + private val kTag = "MainActivity" + private var menuItem: MenuItem? = null + private var fragmentPages: ArrayList = ArrayList() + private var clickTime: Long = 0 + + init { + fragmentPages.add(StatisticsPageFragment()) + fragmentPages.add(MonitorPageFragment()) + fragmentPages.add(AlarmPageFragment()) + } + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + ImmersionBar.with(this).statusBarDarkFont(false).init() + ImmerseStatusBarUtil.setColor(this, R.color.mainThemeColor.convertColor(this)) + } + + override fun initData() { + //推送,多次调用 SDK 初始化并无影响。 + PushManager.getInstance().initialize(this) + weakReferenceHandler = WeakReferenceHandler { + + true + } + } + + override fun observeRequestState() { + + } + + override fun initEvent() { + bottomNavigation.itemIconTintList = null + bottomNavigation.setOnNavigationItemSelectedListener { menuItem -> + when (menuItem.itemId) { + R.id.nav_statistics -> { + mainViewPager.currentItem = 0 + } + R.id.nav_monitor -> { + mainViewPager.currentItem = 1 + } + R.id.nav_alarm -> { + mainViewPager.currentItem = 2 + } + } + false + } + mainViewPager.adapter = ViewPagerAdapter(fragmentPages, supportFragmentManager) + mainViewPager.offscreenPageLimit = fragmentPages.size //缓存页数 + mainViewPager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener { + override fun onPageScrollStateChanged(state: Int) { + + } + + override fun onPageScrolled( + position: Int, + positionOffset: Float, + positionOffsetPixels: Int + ) { + + } + + override fun onPageSelected(position: Int) { + if (menuItem != null) { + menuItem!!.isChecked = false + } else { + bottomNavigation.menu.getItem(0).isChecked = false + } + menuItem = bottomNavigation.menu.getItem(position) + menuItem!!.isChecked = true + } + }) + } + + override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean { + return if (keyCode == KeyEvent.KEYCODE_BACK) { + if (System.currentTimeMillis() - clickTime > 2000) { + "再按一次退出程序".show(this) + clickTime = System.currentTimeMillis() + true + } else { + super.onKeyDown(keyCode, event) + } + } else super.onKeyDown(keyCode, event) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt new file mode 100644 index 0000000..c5d8b22 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.view + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseActivity + +class MonitorRecordActivity : KotlinBaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_monitor_record + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt new file mode 100644 index 0000000..c478d83 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt @@ -0,0 +1,55 @@ +package com.casic.smart.town.sanxi.view + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.amap.api.maps.MapsInitializer +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.gyf.immersionbar.ImmersionBar +import com.pengxh.kt.lite.extensions.navigatePageTo +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + ImmersionBar.with(this).statusBarDarkFont(true).init() + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (EasyPermissions.hasPermissions(this, *LocaleConstant.USER_PERMISSIONS)) { + startSplashScreenActivity() + } else { + EasyPermissions.requestPermissions( + this@PermissionActivity, + resources.getString(R.string.app_name) + "需要获取相关权限", + LocaleConstant.PERMISSIONS_CODE, + *LocaleConstant.USER_PERMISSIONS + ) + } + } + + private fun startSplashScreenActivity() { + //先把导航隐私政策声明,后面导航会用到 + MapsInitializer.updatePrivacyAgree(this, true) + MapsInitializer.updatePrivacyShow(this, true, true) + this.navigatePageTo() + 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) { + startSplashScreenActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable/alarm_selector.xml b/app/src/main/res/drawable/alarm_selector.xml new file mode 100644 index 0000000..39b2595 --- /dev/null +++ b/app/src/main/res/drawable/alarm_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bottom_text_color.xml b/app/src/main/res/drawable/bottom_text_color.xml new file mode 100644 index 0000000..b284ea3 --- /dev/null +++ b/app/src/main/res/drawable/bottom_text_color.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_alarm.xml b/app/src/main/res/drawable/ic_alarm.xml new file mode 100644 index 0000000..dc33aab --- /dev/null +++ b/app/src/main/res/drawable/ic_alarm.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_alarm_selected.xml b/app/src/main/res/drawable/ic_alarm_selected.xml new file mode 100644 index 0000000..993fea6 --- /dev/null +++ b/app/src/main/res/drawable/ic_alarm_selected.xml @@ -0,0 +1,9 @@ + + + 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_monitor.xml b/app/src/main/res/drawable/ic_monitor.xml new file mode 100644 index 0000000..271f5b4 --- /dev/null +++ b/app/src/main/res/drawable/ic_monitor.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_monitor_selected.xml b/app/src/main/res/drawable/ic_monitor_selected.xml new file mode 100644 index 0000000..ee62d84 --- /dev/null +++ b/app/src/main/res/drawable/ic_monitor_selected.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_statistics.xml b/app/src/main/res/drawable/ic_statistics.xml new file mode 100644 index 0000000..7fde8ec --- /dev/null +++ b/app/src/main/res/drawable/ic_statistics.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_statistics_selected.xml b/app/src/main/res/drawable/ic_statistics_selected.xml new file mode 100644 index 0000000..49b6fcd --- /dev/null +++ b/app/src/main/res/drawable/ic_statistics_selected.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/monitor_selector.xml b/app/src/main/res/drawable/monitor_selector.xml new file mode 100644 index 0000000..fe11e9a --- /dev/null +++ b/app/src/main/res/drawable/monitor_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/statistics_selector.xml b/app/src/main/res/drawable/statistics_selector.xml new file mode 100644 index 0000000..2156cff --- /dev/null +++ b/app/src/main/res/drawable/statistics_selector.xml @@ -0,0 +1,5 @@ + + + + + \ 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..78a4a94 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,27 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_monitor_record.xml b/app/src/main/res/layout/activity_monitor_record.xml new file mode 100644 index 0000000..77d9ef6 --- /dev/null +++ b/app/src/main/res/layout/activity_monitor_record.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_alarm.xml b/app/src/main/res/layout/fragment_alarm.xml new file mode 100644 index 0000000..77d9ef6 --- /dev/null +++ b/app/src/main/res/layout/fragment_alarm.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..10cfdbf --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*.iml +.gradle +/local.properties +/.idea +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..a4cd2ca --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,101 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'org.greenrobot.greendao' + +android { +// signingConfigs { +// release { +// storeFile file('/Users/a203/Desktop/AndroidProjects/CasicSmartWell/app/CasicSmartWell.jks') +// storePassword '123456789' +// keyAlias 'key0' +// keyPassword '123456789' +// } +// } + compileSdkVersion 31 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.smart.town.sanxi" + minSdkVersion 23 + targetSdkVersion 31 + versionCode 1 + versionName "1.0.0" + + manifestPlaceholders = [GETUI_APPID: "A9V4DvwLcdAqkFCQuFyhq6"] + } + + buildTypes { + release { + minifyEnabled false +// signingConfig signingConfigs.release + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + + ndk { abiFilters "armeabi", "armeabi-v7a", "arm64-v8" } + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlin { + experimental { + coroutines 'enable' + } + } + + greendao { + schemaVersion 1//数据库版本号 + targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 + daoPackage 'com.casic.smart.town.sanxi.greendao'//设置DaoMaster、DaoSession、Dao包名 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + //基础依赖库 + implementation files('libs/lite-release.aar') + implementation 'androidx.appcompat:appcompat:1.4.2' + implementation 'androidx.core:core-ktx:1.8.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:3.0.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' + //MVVM+LiveData + implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.1" + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0" + implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + //Kotlin协程 + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1' + //图片加载框架 + implementation 'com.github.bumptech.glide:glide:4.9.0' + //返回值转换器 + implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' + implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + //okhttp3日志拦截器 + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //网络请求和接口封装 + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.9.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.9.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' + //高德地图 + implementation 'com.amap.api:3dmap:latest.integration' + //推送SDK + implementation 'com.getui:gtsdk:3.2.10.0' //个推SDK + implementation 'com.getui:gtc:3.1.9.0' //个推核心组件 + //数据库框架 + implementation 'org.greenrobot:greendao:3.3.0' + //桌面角标 + implementation "me.leolin:ShortcutBadger:1.1.22@aar" +} \ No newline at end of file diff --git a/app/libs/lite-release.aar b/app/libs/lite-release.aar new file mode 100644 index 0000000..45da4df --- /dev/null +++ b/app/libs/lite-release.aar Binary files differ diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /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 \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..a83c28a --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/svg/monitor.svg b/app/src/main/assets/svg/monitor.svg new file mode 100644 index 0000000..c8d3e25 --- /dev/null +++ b/app/src/main/assets/svg/monitor.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/msg.svg b/app/src/main/assets/svg/msg.svg new file mode 100644 index 0000000..e864e48 --- /dev/null +++ b/app/src/main/assets/svg/msg.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/statistics.svg b/app/src/main/assets/svg/statistics.svg new file mode 100644 index 0000000..974000e --- /dev/null +++ b/app/src/main/assets/svg/statistics.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt new file mode 100644 index 0000000..6b9cce0 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.adapter + +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentManager +import androidx.fragment.app.FragmentPagerAdapter + +class ViewPagerAdapter(list: ArrayList, manager: FragmentManager) : + FragmentPagerAdapter(manager) { + + private var pageList: List = list + + override fun getItem(position: Int) = pageList[position] + + override fun getCount() = pageList.size +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt new file mode 100644 index 0000000..4e017b1 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt @@ -0,0 +1,40 @@ +package com.casic.smart.town.sanxi.base + +import android.app.Application +import android.util.Log +import com.casic.smart.town.sanxi.greendao.DaoMaster +import com.casic.smart.town.sanxi.greendao.DaoSession +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + private val kTag = "BaseApplication" + + companion object { + private var instance: BaseApplication by Delegates.notNull() + + fun obtainInstance() = instance + + private lateinit var daoSession: DaoSession + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences(this) + //推送 + PushManager.getInstance().initialize(this) + PushManager.getInstance().setDebugLogger(this) { + Log.d(kTag, it) + } + val devOpenHelper = DaoMaster.DevOpenHelper(this, "SmartTown.db", null) + val daoMaster = DaoMaster(devOpenHelper.writableDatabase) + daoSession = daoMaster.newSession() + } + + fun obtainDaoSession(): DaoSession { + return daoSession + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java new file mode 100644 index 0000000..b8f67dc --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java @@ -0,0 +1,133 @@ +package com.casic.smart.town.sanxi.bean; + +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Generated; +import org.greenrobot.greendao.annotation.Id; +import org.greenrobot.greendao.annotation.Unique; + +@Entity +public class AlarmMessageLocaleBean { + @Id(autoincrement = true) + private Long id;//主键自增 + + @Unique + private String messageId; + private String appId; + private String clientId; + private String taskId; + private String userId; + private String title; + private String content; + private String deviceCode; + private String isRead;//0-未读,1-已读 + private String alarmTime; + + @Generated(hash = 566950134) + public AlarmMessageLocaleBean(Long id, String messageId, String appId, + String clientId, String taskId, String userId, String title, + String content, String deviceCode, String isRead, String alarmTime) { + this.id = id; + this.messageId = messageId; + this.appId = appId; + this.clientId = clientId; + this.taskId = taskId; + this.userId = userId; + this.title = title; + this.content = content; + this.deviceCode = deviceCode; + this.isRead = isRead; + this.alarmTime = alarmTime; + } + + @Generated(hash = 1737519562) + public AlarmMessageLocaleBean() { + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getMessageId() { + return this.messageId; + } + + public void setMessageId(String messageId) { + this.messageId = messageId; + } + + public String getAppId() { + return this.appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public String getClientId() { + return this.clientId; + } + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public String getTaskId() { + return this.taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getUserId() { + return this.userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getTitle() { + return this.title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return this.content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getDeviceCode() { + return this.deviceCode; + } + + public void setDeviceCode(String deviceCode) { + this.deviceCode = deviceCode; + } + + public String getIsRead() { + return this.isRead; + } + + public void setIsRead(String isRead) { + this.isRead = isRead; + } + + public String getAlarmTime() { + return this.alarmTime; + } + + public void setAlarmTime(String alarmTime) { + this.alarmTime = alarmTime; + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt new file mode 100644 index 0000000..650e201 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class AlarmPageFragment: KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_alarm + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt new file mode 100644 index 0000000..deac8ac --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt @@ -0,0 +1,76 @@ +package com.casic.smart.town.sanxi.fragment + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.Fragment +import com.amap.api.maps.AMap +import com.amap.api.maps.AMapOptions +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.view.MonitorRecordActivity +import com.pengxh.kt.lite.extensions.navigatePageTo +import com.pengxh.kt.lite.extensions.show +import kotlinx.android.synthetic.main.fragment_monitor.view.* + +class MonitorPageFragment : Fragment() { + + private val kTag = "HomePageFragment" + private lateinit var monitorView: View + private lateinit var aMap: AMap + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? + ): View { + monitorView = inflater.inflate(R.layout.fragment_monitor, container, false) + //地图初始化 + initMap(savedInstanceState) + + monitorView.rightOperateView.setOnClickListener { + requireContext().navigatePageTo() + } + return monitorView + } + + private fun initMap(savedInstanceState: Bundle?) { + monitorView.mapView.onCreate(savedInstanceState) + aMap = monitorView.mapView.map + aMap.mapType = AMap.MAP_TYPE_NORMAL + val uiSettings = aMap.uiSettings + uiSettings.isCompassEnabled = true + uiSettings.zoomPosition = AMapOptions.ZOOM_POSITION_RIGHT_CENTER + uiSettings.isTiltGesturesEnabled = false//不许地图随手势倾斜角度 + + // 地图加载成功监听 +// aMap.addOnMapLoadedListener(this) + // 地图缩放监听 +// aMap.addOnCameraChangeListener(this) + // marker 点击事件监听 +// aMap.addOnMarkerClickListener(this) + // 点击marker弹出自定义popup +// aMap.setInfoWindowAdapter(this) + //信息窗点击事件 +// aMap.addOnInfoWindowClickListener(this) + } + + /***以下是地图生命周期管理************************************************************************/ + override fun onResume() { + super.onResume() + monitorView.mapView.onResume() + } + + override fun onPause() { + super.onPause() + monitorView.mapView.onPause() + } + + override fun onSaveInstanceState(outState: Bundle) { + super.onSaveInstanceState(outState) + monitorView.mapView.onSaveInstanceState(outState) + } + + override fun onDestroy() { + super.onDestroy() + monitorView.mapView.onDestroy() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt new file mode 100644 index 0000000..e84df12 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class StatisticsPageFragment : KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_statistics + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java new file mode 100644 index 0000000..68d7901 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java @@ -0,0 +1,255 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.database.Cursor; +import android.database.sqlite.SQLiteStatement; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.Property; +import org.greenrobot.greendao.internal.DaoConfig; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseStatement; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * DAO for table "ALARM_MESSAGE_LOCALE_BEAN". +*/ +public class AlarmMessageLocaleBeanDao extends AbstractDao { + + public static final String TABLENAME = "ALARM_MESSAGE_LOCALE_BEAN"; + + /** + * Properties of entity AlarmMessageLocaleBean.
+ * Can be used for QueryBuilder and for referencing column names. + */ + public static class Properties { + public final static Property Id = new Property(0, Long.class, "id", true, "_id"); + public final static Property MessageId = new Property(1, String.class, "messageId", false, "MESSAGE_ID"); + public final static Property AppId = new Property(2, String.class, "appId", false, "APP_ID"); + public final static Property ClientId = new Property(3, String.class, "clientId", false, "CLIENT_ID"); + public final static Property TaskId = new Property(4, String.class, "taskId", false, "TASK_ID"); + public final static Property UserId = new Property(5, String.class, "userId", false, "USER_ID"); + public final static Property Title = new Property(6, String.class, "title", false, "TITLE"); + public final static Property Content = new Property(7, String.class, "content", false, "CONTENT"); + public final static Property DeviceCode = new Property(8, String.class, "deviceCode", false, "DEVICE_CODE"); + public final static Property IsRead = new Property(9, String.class, "isRead", false, "IS_READ"); + public final static Property AlarmTime = new Property(10, String.class, "alarmTime", false, "ALARM_TIME"); + } + + + public AlarmMessageLocaleBeanDao(DaoConfig config) { + super(config); + } + + public AlarmMessageLocaleBeanDao(DaoConfig config, DaoSession daoSession) { + super(config, daoSession); + } + + /** Creates the underlying database table. */ + public static void createTable(Database db, boolean ifNotExists) { + String constraint = ifNotExists? "IF NOT EXISTS ": ""; + db.execSQL("CREATE TABLE " + constraint + "\"ALARM_MESSAGE_LOCALE_BEAN\" (" + // + "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id + "\"MESSAGE_ID\" TEXT UNIQUE ," + // 1: messageId + "\"APP_ID\" TEXT," + // 2: appId + "\"CLIENT_ID\" TEXT," + // 3: clientId + "\"TASK_ID\" TEXT," + // 4: taskId + "\"USER_ID\" TEXT," + // 5: userId + "\"TITLE\" TEXT," + // 6: title + "\"CONTENT\" TEXT," + // 7: content + "\"DEVICE_CODE\" TEXT," + // 8: deviceCode + "\"IS_READ\" TEXT," + // 9: isRead + "\"ALARM_TIME\" TEXT);"); // 10: alarmTime + } + + /** Drops the underlying database table. */ + public static void dropTable(Database db, boolean ifExists) { + String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"ALARM_MESSAGE_LOCALE_BEAN\""; + db.execSQL(sql); + } + + @Override + protected final void bindValues(DatabaseStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + protected final void bindValues(SQLiteStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + public Long readKey(Cursor cursor, int offset) { + return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); + } + + @Override + public AlarmMessageLocaleBean readEntity(Cursor cursor, int offset) { + AlarmMessageLocaleBean entity = new AlarmMessageLocaleBean( // + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // messageId + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // appId + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // clientId + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // taskId + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // userId + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // title + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // content + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // deviceCode + cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // isRead + cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10) // alarmTime + ); + return entity; + } + + @Override + public void readEntity(Cursor cursor, AlarmMessageLocaleBean entity, int offset) { + entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); + entity.setMessageId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setAppId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setClientId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setTaskId(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); + entity.setUserId(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setTitle(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setContent(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); + entity.setDeviceCode(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); + entity.setIsRead(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9)); + entity.setAlarmTime(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); + } + + @Override + protected final Long updateKeyAfterInsert(AlarmMessageLocaleBean entity, long rowId) { + entity.setId(rowId); + return rowId; + } + + @Override + public Long getKey(AlarmMessageLocaleBean entity) { + if(entity != null) { + return entity.getId(); + } else { + return null; + } + } + + @Override + public boolean hasKey(AlarmMessageLocaleBean entity) { + return entity.getId() != null; + } + + @Override + protected final boolean isEntityUpdateable() { + return true; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java new file mode 100644 index 0000000..4222c40 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java @@ -0,0 +1,96 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.content.Context; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteDatabase.CursorFactory; +import android.util.Log; + +import org.greenrobot.greendao.AbstractDaoMaster; +import org.greenrobot.greendao.database.StandardDatabase; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseOpenHelper; +import org.greenrobot.greendao.identityscope.IdentityScopeType; + + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * Master of DAO (schema version 1): knows all DAOs. + */ +public class DaoMaster extends AbstractDaoMaster { + public static final int SCHEMA_VERSION = 1; + + /** Creates underlying database table using DAOs. */ + public static void createAllTables(Database db, boolean ifNotExists) { + AlarmMessageLocaleBeanDao.createTable(db, ifNotExists); + } + + /** Drops underlying database table using DAOs. */ + public static void dropAllTables(Database db, boolean ifExists) { + AlarmMessageLocaleBeanDao.dropTable(db, ifExists); + } + + /** + * WARNING: Drops all table on Upgrade! Use only during development. + * Convenience method using a {@link DevOpenHelper}. + */ + public static DaoSession newDevSession(Context context, String name) { + Database db = new DevOpenHelper(context, name).getWritableDb(); + DaoMaster daoMaster = new DaoMaster(db); + return daoMaster.newSession(); + } + + public DaoMaster(SQLiteDatabase db) { + this(new StandardDatabase(db)); + } + + public DaoMaster(Database db) { + super(db, SCHEMA_VERSION); + registerDaoClass(AlarmMessageLocaleBeanDao.class); + } + + public DaoSession newSession() { + return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); + } + + public DaoSession newSession(IdentityScopeType type) { + return new DaoSession(db, type, daoConfigMap); + } + + /** + * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} - + */ + public static abstract class OpenHelper extends DatabaseOpenHelper { + public OpenHelper(Context context, String name) { + super(context, name, SCHEMA_VERSION); + } + + public OpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory, SCHEMA_VERSION); + } + + @Override + public void onCreate(Database db) { + Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); + createAllTables(db, false); + } + } + + /** WARNING: Drops all table on Upgrade! Use only during development. */ + public static class DevOpenHelper extends OpenHelper { + public DevOpenHelper(Context context, String name) { + super(context, name); + } + + public DevOpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory); + } + + @Override + public void onUpgrade(Database db, int oldVersion, int newVersion) { + Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); + dropAllTables(db, true); + onCreate(db); + } + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java new file mode 100644 index 0000000..480ed84 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java @@ -0,0 +1,48 @@ +package com.casic.smart.town.sanxi.greendao; + +import java.util.Map; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.AbstractDaoSession; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.identityscope.IdentityScopeType; +import org.greenrobot.greendao.internal.DaoConfig; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. + +/** + * {@inheritDoc} + * + * @see org.greenrobot.greendao.AbstractDaoSession + */ +public class DaoSession extends AbstractDaoSession { + + private final DaoConfig alarmMessageLocaleBeanDaoConfig; + + private final AlarmMessageLocaleBeanDao alarmMessageLocaleBeanDao; + + public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> + daoConfigMap) { + super(db); + + alarmMessageLocaleBeanDaoConfig = daoConfigMap.get(AlarmMessageLocaleBeanDao.class).clone(); + alarmMessageLocaleBeanDaoConfig.initIdentityScope(type); + + alarmMessageLocaleBeanDao = new AlarmMessageLocaleBeanDao(alarmMessageLocaleBeanDaoConfig, this); + + registerDao(AlarmMessageLocaleBean.class, alarmMessageLocaleBeanDao); + } + + public void clear() { + alarmMessageLocaleBeanDaoConfig.clearIdentityScope(); + } + + public AlarmMessageLocaleBeanDao getAlarmMessageLocaleBeanDao() { + return alarmMessageLocaleBeanDao; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt new file mode 100644 index 0000000..875cb8c --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt @@ -0,0 +1,5 @@ +package com.casic.smart.town.sanxi.service + +import com.igexin.sdk.PushService + +class ApplicationPushService : PushService() \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt new file mode 100644 index 0000000..396129f --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt @@ -0,0 +1,84 @@ +package com.casic.smart.town.sanxi.service + +import android.content.Context +import android.os.Message +import android.util.Log +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.casic.smart.town.sanxi.view.MainActivity +import com.igexin.sdk.GTIntentService +import com.igexin.sdk.message.GTCmdMessage +import com.igexin.sdk.message.GTNotificationMessage +import com.igexin.sdk.message.GTTransmitMessage +import com.pengxh.kt.lite.extensions.toJson + +class PushIntentService : GTIntentService() { + + private val kTag = "SmartWellIntentService" + + override fun onReceiveServicePid(context: Context?, pid: Int) { + + } + + // 透传消息 + override fun onReceiveMessageData(context: Context?, msg: GTTransmitMessage?) { + Log.d(kTag, "透传消息 -> msg = $msg") + } + + // 接收 cid + override fun onReceiveClientId(context: Context?, clientid: String?) { + Log.d(kTag, "onReceiveClientId -> $clientid") + //通知MainActivity注册个推服务 + val msg: Message = MainActivity.weakReferenceHandler.obtainMessage() + msg.what = LocaleConstant.PUSH_REGISTER + msg.obj = clientid + MainActivity.weakReferenceHandler.sendMessage(msg) + } + + // cid 离线上线通知 + override fun onReceiveOnlineState(context: Context?, online: Boolean) { + + } + + // 各种事件处理回执 + override fun onReceiveCommandResult(context: Context?, msg: GTCmdMessage?) { + + } + + // 通知到达 + override fun onNotificationMessageArrived(context: Context?, msg: GTNotificationMessage?) { + //报警 +// { +// "content": "设备编号[412022030361]发生井盖开盖报警", +// "messageId": "380abf9a79d34306a2683dc9bf96ee78", +// "taskId": "OSL-0830_4hmfimp3Vu684wo3SjXso9", +// "title": "告警提醒", +// "appid": "HKv8K9qARd6WckZ1o2Vbu4", +// "clientId": "e78beacc42e9a02ae6fb9087eb2b1171", +// "pkgName": "com.casic.app.smartwell" +// } + if (msg == null) { + return + } + Log.d(kTag, "通知到达 -> msg = ${msg.toJson()}") +// val userDetailJson = SaveKeyValues.getValue(LocaleConstant.USER_DETAIL_MODEL, "") as String +// var userId = "" +// if (userDetailJson.isNotBlank()) { +// val userDataModel = Gson().fromJson( +// userDetailJson, object : TypeToken() {}.type +// ) +// userId = userDataModel.id.toString() +// } +// //解析编号 +// val splitArray = msg.content.split("\\[|\\]".toRegex()) +// DataBaseManager.instance.insertNotice( +// msg.messageId, msg.appid, msg.clientId, msg.taskId, +// userId, msg.title, msg.content, splitArray[1], "0", +// System.currentTimeMillis().timestampToCompleteDate() +// ) + } + + // 通知点击 + override fun onNotificationMessageClicked(context: Context?, msg: GTNotificationMessage?) { + Log.d(kTag, "通知点击 -> msg = $msg") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt new file mode 100644 index 0000000..daa7c38 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt @@ -0,0 +1,14 @@ +package com.casic.smart.town.sanxi.util + +import android.content.Context +import me.leolin.shortcutbadger.ShortcutBadger + +object BadeHelper { + fun setBadgeNum(context: Context, badgeCount: Int) { + if (badgeCount == 0) { + ShortcutBadger.removeCount(context) + } else { + ShortcutBadger.applyCount(context, badgeCount) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt new file mode 100644 index 0000000..0a52ef2 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt @@ -0,0 +1,75 @@ +package com.casic.smart.town.sanxi.util + +import com.casic.smart.town.sanxi.base.BaseApplication +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao + +class DataBaseManager private constructor() { + + companion object { + //Kotlin委托模式双重锁单例 + val instance: DataBaseManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) { + DataBaseManager() + } + } + + private val beanDao = + BaseApplication.obtainInstance().obtainDaoSession().alarmMessageLocaleBeanDao + +// fun insertNotice( +// messageId: String, appid: String, clientId: String, +// taskId: String, userId: String, title: String, +// content: String, deviceCode: String, isRead: String, +// noticeTime: String +// ) { +// val noticeLocaleBean = NoticeLocaleBean() +// noticeLocaleBean.messageId = messageId +// noticeLocaleBean.appid = appid +// noticeLocaleBean.clientId = clientId +// noticeLocaleBean.taskId = taskId +// noticeLocaleBean.userId = userId +// noticeLocaleBean.title = title +// noticeLocaleBean.content = content +// noticeLocaleBean.deviceCode = deviceCode +// noticeLocaleBean.isRead = isRead +// noticeLocaleBean.noticeTime = noticeTime +// beanDao.insert(noticeLocaleBean) +// //角标设置 +// BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadNotice()) +// } + + fun deleteByMessageId(messageId: String) { + val result = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).list() + beanDao.deleteInTx(result) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun updateNoticeByMessageId(messageId: String) { + val noticeLocaleBean = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).unique() ?: return + noticeLocaleBean.isRead = "1" + beanDao.update(noticeLocaleBean) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun queryMessageByPage(userId: String, offset: Int): MutableList { + return BaseApplication.obtainInstance().obtainDaoSession() + .queryBuilder(AlarmMessageLocaleBean::class.java) + .where(AlarmMessageLocaleBeanDao.Properties.UserId.eq(userId)) + .offset(offset * LocaleConstant.PAGE_LIMIT) + .orderDesc(AlarmMessageLocaleBeanDao.Properties.AlarmTime) + .limit(LocaleConstant.PAGE_LIMIT) + .list() + } + + private fun queryUnReadMessage(): Int { + return beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.IsRead.eq("0") + ).list().size + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt new file mode 100644 index 0000000..52926a8 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt @@ -0,0 +1,31 @@ +package com.casic.smart.town.sanxi.util; + +import android.app.Activity +import android.view.WindowManager +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object LoadingDialogHub { + private lateinit var loadingDialog: QMUITipDialog + + fun show(activity: Activity, message: String) { + loadingDialog = QMUITipDialog + .Builder(activity) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_LOADING) + .setTipWord(message) + .create() + if (!activity.isDestroyed) { + try { + loadingDialog.show() + } catch (e: WindowManager.BadTokenException) { + e.printStackTrace() + } + } + } + + + fun dismiss() { + if (loadingDialog.isShowing) { + loadingDialog.dismiss() + } + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt new file mode 100644 index 0000000..de61c9a --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.util + +import android.Manifest + +object LocaleConstant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.READ_PHONE_STATE, + Manifest.permission.ACCESS_COARSE_LOCATION, + Manifest.permission.READ_EXTERNAL_STORAGE + ) + + const val PERMISSIONS_CODE = 999 + const val PUSH_REGISTER = 2022100101 + const val PAGE_LIMIT = 20 +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt new file mode 100644 index 0000000..3bea1c9 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt @@ -0,0 +1,112 @@ +package com.casic.smart.town.sanxi.view + +import android.view.KeyEvent +import android.view.MenuItem +import androidx.fragment.app.Fragment +import androidx.viewpager.widget.ViewPager +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.adapter.ViewPagerAdapter +import com.casic.smart.town.sanxi.fragment.AlarmPageFragment +import com.casic.smart.town.sanxi.fragment.MonitorPageFragment +import com.casic.smart.town.sanxi.fragment.StatisticsPageFragment +import com.gyf.immersionbar.ImmersionBar +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.base.KotlinBaseActivity +import com.pengxh.kt.lite.extensions.convertColor +import com.pengxh.kt.lite.extensions.show +import com.pengxh.kt.lite.utils.ImmerseStatusBarUtil +import com.pengxh.kt.lite.utils.WeakReferenceHandler +import kotlinx.android.synthetic.main.activity_main.* + +class MainActivity : KotlinBaseActivity() { + + companion object { + lateinit var weakReferenceHandler: WeakReferenceHandler + } + + private val kTag = "MainActivity" + private var menuItem: MenuItem? = null + private var fragmentPages: ArrayList = ArrayList() + private var clickTime: Long = 0 + + init { + fragmentPages.add(StatisticsPageFragment()) + fragmentPages.add(MonitorPageFragment()) + fragmentPages.add(AlarmPageFragment()) + } + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + ImmersionBar.with(this).statusBarDarkFont(false).init() + ImmerseStatusBarUtil.setColor(this, R.color.mainThemeColor.convertColor(this)) + } + + override fun initData() { + //推送,多次调用 SDK 初始化并无影响。 + PushManager.getInstance().initialize(this) + weakReferenceHandler = WeakReferenceHandler { + + true + } + } + + override fun observeRequestState() { + + } + + override fun initEvent() { + bottomNavigation.itemIconTintList = null + bottomNavigation.setOnNavigationItemSelectedListener { menuItem -> + when (menuItem.itemId) { + R.id.nav_statistics -> { + mainViewPager.currentItem = 0 + } + R.id.nav_monitor -> { + mainViewPager.currentItem = 1 + } + R.id.nav_alarm -> { + mainViewPager.currentItem = 2 + } + } + false + } + mainViewPager.adapter = ViewPagerAdapter(fragmentPages, supportFragmentManager) + mainViewPager.offscreenPageLimit = fragmentPages.size //缓存页数 + mainViewPager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener { + override fun onPageScrollStateChanged(state: Int) { + + } + + override fun onPageScrolled( + position: Int, + positionOffset: Float, + positionOffsetPixels: Int + ) { + + } + + override fun onPageSelected(position: Int) { + if (menuItem != null) { + menuItem!!.isChecked = false + } else { + bottomNavigation.menu.getItem(0).isChecked = false + } + menuItem = bottomNavigation.menu.getItem(position) + menuItem!!.isChecked = true + } + }) + } + + override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean { + return if (keyCode == KeyEvent.KEYCODE_BACK) { + if (System.currentTimeMillis() - clickTime > 2000) { + "再按一次退出程序".show(this) + clickTime = System.currentTimeMillis() + true + } else { + super.onKeyDown(keyCode, event) + } + } else super.onKeyDown(keyCode, event) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt new file mode 100644 index 0000000..c5d8b22 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.view + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseActivity + +class MonitorRecordActivity : KotlinBaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_monitor_record + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt new file mode 100644 index 0000000..c478d83 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt @@ -0,0 +1,55 @@ +package com.casic.smart.town.sanxi.view + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.amap.api.maps.MapsInitializer +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.gyf.immersionbar.ImmersionBar +import com.pengxh.kt.lite.extensions.navigatePageTo +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + ImmersionBar.with(this).statusBarDarkFont(true).init() + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (EasyPermissions.hasPermissions(this, *LocaleConstant.USER_PERMISSIONS)) { + startSplashScreenActivity() + } else { + EasyPermissions.requestPermissions( + this@PermissionActivity, + resources.getString(R.string.app_name) + "需要获取相关权限", + LocaleConstant.PERMISSIONS_CODE, + *LocaleConstant.USER_PERMISSIONS + ) + } + } + + private fun startSplashScreenActivity() { + //先把导航隐私政策声明,后面导航会用到 + MapsInitializer.updatePrivacyAgree(this, true) + MapsInitializer.updatePrivacyShow(this, true, true) + this.navigatePageTo() + 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) { + startSplashScreenActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable/alarm_selector.xml b/app/src/main/res/drawable/alarm_selector.xml new file mode 100644 index 0000000..39b2595 --- /dev/null +++ b/app/src/main/res/drawable/alarm_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bottom_text_color.xml b/app/src/main/res/drawable/bottom_text_color.xml new file mode 100644 index 0000000..b284ea3 --- /dev/null +++ b/app/src/main/res/drawable/bottom_text_color.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_alarm.xml b/app/src/main/res/drawable/ic_alarm.xml new file mode 100644 index 0000000..dc33aab --- /dev/null +++ b/app/src/main/res/drawable/ic_alarm.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_alarm_selected.xml b/app/src/main/res/drawable/ic_alarm_selected.xml new file mode 100644 index 0000000..993fea6 --- /dev/null +++ b/app/src/main/res/drawable/ic_alarm_selected.xml @@ -0,0 +1,9 @@ + + + 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_monitor.xml b/app/src/main/res/drawable/ic_monitor.xml new file mode 100644 index 0000000..271f5b4 --- /dev/null +++ b/app/src/main/res/drawable/ic_monitor.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_monitor_selected.xml b/app/src/main/res/drawable/ic_monitor_selected.xml new file mode 100644 index 0000000..ee62d84 --- /dev/null +++ b/app/src/main/res/drawable/ic_monitor_selected.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_statistics.xml b/app/src/main/res/drawable/ic_statistics.xml new file mode 100644 index 0000000..7fde8ec --- /dev/null +++ b/app/src/main/res/drawable/ic_statistics.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_statistics_selected.xml b/app/src/main/res/drawable/ic_statistics_selected.xml new file mode 100644 index 0000000..49b6fcd --- /dev/null +++ b/app/src/main/res/drawable/ic_statistics_selected.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/monitor_selector.xml b/app/src/main/res/drawable/monitor_selector.xml new file mode 100644 index 0000000..fe11e9a --- /dev/null +++ b/app/src/main/res/drawable/monitor_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/statistics_selector.xml b/app/src/main/res/drawable/statistics_selector.xml new file mode 100644 index 0000000..2156cff --- /dev/null +++ b/app/src/main/res/drawable/statistics_selector.xml @@ -0,0 +1,5 @@ + + + + + \ 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..78a4a94 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,27 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_monitor_record.xml b/app/src/main/res/layout/activity_monitor_record.xml new file mode 100644 index 0000000..77d9ef6 --- /dev/null +++ b/app/src/main/res/layout/activity_monitor_record.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_alarm.xml b/app/src/main/res/layout/fragment_alarm.xml new file mode 100644 index 0000000..77d9ef6 --- /dev/null +++ b/app/src/main/res/layout/fragment_alarm.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_monitor.xml b/app/src/main/res/layout/fragment_monitor.xml new file mode 100644 index 0000000..19789c1 --- /dev/null +++ b/app/src/main/res/layout/fragment_monitor.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..10cfdbf --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*.iml +.gradle +/local.properties +/.idea +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..a4cd2ca --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,101 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'org.greenrobot.greendao' + +android { +// signingConfigs { +// release { +// storeFile file('/Users/a203/Desktop/AndroidProjects/CasicSmartWell/app/CasicSmartWell.jks') +// storePassword '123456789' +// keyAlias 'key0' +// keyPassword '123456789' +// } +// } + compileSdkVersion 31 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.smart.town.sanxi" + minSdkVersion 23 + targetSdkVersion 31 + versionCode 1 + versionName "1.0.0" + + manifestPlaceholders = [GETUI_APPID: "A9V4DvwLcdAqkFCQuFyhq6"] + } + + buildTypes { + release { + minifyEnabled false +// signingConfig signingConfigs.release + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + + ndk { abiFilters "armeabi", "armeabi-v7a", "arm64-v8" } + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlin { + experimental { + coroutines 'enable' + } + } + + greendao { + schemaVersion 1//数据库版本号 + targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 + daoPackage 'com.casic.smart.town.sanxi.greendao'//设置DaoMaster、DaoSession、Dao包名 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + //基础依赖库 + implementation files('libs/lite-release.aar') + implementation 'androidx.appcompat:appcompat:1.4.2' + implementation 'androidx.core:core-ktx:1.8.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:3.0.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' + //MVVM+LiveData + implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.1" + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0" + implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + //Kotlin协程 + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1' + //图片加载框架 + implementation 'com.github.bumptech.glide:glide:4.9.0' + //返回值转换器 + implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' + implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + //okhttp3日志拦截器 + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //网络请求和接口封装 + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.9.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.9.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' + //高德地图 + implementation 'com.amap.api:3dmap:latest.integration' + //推送SDK + implementation 'com.getui:gtsdk:3.2.10.0' //个推SDK + implementation 'com.getui:gtc:3.1.9.0' //个推核心组件 + //数据库框架 + implementation 'org.greenrobot:greendao:3.3.0' + //桌面角标 + implementation "me.leolin:ShortcutBadger:1.1.22@aar" +} \ No newline at end of file diff --git a/app/libs/lite-release.aar b/app/libs/lite-release.aar new file mode 100644 index 0000000..45da4df --- /dev/null +++ b/app/libs/lite-release.aar Binary files differ diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /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 \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..a83c28a --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/svg/monitor.svg b/app/src/main/assets/svg/monitor.svg new file mode 100644 index 0000000..c8d3e25 --- /dev/null +++ b/app/src/main/assets/svg/monitor.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/msg.svg b/app/src/main/assets/svg/msg.svg new file mode 100644 index 0000000..e864e48 --- /dev/null +++ b/app/src/main/assets/svg/msg.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/statistics.svg b/app/src/main/assets/svg/statistics.svg new file mode 100644 index 0000000..974000e --- /dev/null +++ b/app/src/main/assets/svg/statistics.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt new file mode 100644 index 0000000..6b9cce0 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.adapter + +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentManager +import androidx.fragment.app.FragmentPagerAdapter + +class ViewPagerAdapter(list: ArrayList, manager: FragmentManager) : + FragmentPagerAdapter(manager) { + + private var pageList: List = list + + override fun getItem(position: Int) = pageList[position] + + override fun getCount() = pageList.size +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt new file mode 100644 index 0000000..4e017b1 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt @@ -0,0 +1,40 @@ +package com.casic.smart.town.sanxi.base + +import android.app.Application +import android.util.Log +import com.casic.smart.town.sanxi.greendao.DaoMaster +import com.casic.smart.town.sanxi.greendao.DaoSession +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + private val kTag = "BaseApplication" + + companion object { + private var instance: BaseApplication by Delegates.notNull() + + fun obtainInstance() = instance + + private lateinit var daoSession: DaoSession + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences(this) + //推送 + PushManager.getInstance().initialize(this) + PushManager.getInstance().setDebugLogger(this) { + Log.d(kTag, it) + } + val devOpenHelper = DaoMaster.DevOpenHelper(this, "SmartTown.db", null) + val daoMaster = DaoMaster(devOpenHelper.writableDatabase) + daoSession = daoMaster.newSession() + } + + fun obtainDaoSession(): DaoSession { + return daoSession + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java new file mode 100644 index 0000000..b8f67dc --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java @@ -0,0 +1,133 @@ +package com.casic.smart.town.sanxi.bean; + +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Generated; +import org.greenrobot.greendao.annotation.Id; +import org.greenrobot.greendao.annotation.Unique; + +@Entity +public class AlarmMessageLocaleBean { + @Id(autoincrement = true) + private Long id;//主键自增 + + @Unique + private String messageId; + private String appId; + private String clientId; + private String taskId; + private String userId; + private String title; + private String content; + private String deviceCode; + private String isRead;//0-未读,1-已读 + private String alarmTime; + + @Generated(hash = 566950134) + public AlarmMessageLocaleBean(Long id, String messageId, String appId, + String clientId, String taskId, String userId, String title, + String content, String deviceCode, String isRead, String alarmTime) { + this.id = id; + this.messageId = messageId; + this.appId = appId; + this.clientId = clientId; + this.taskId = taskId; + this.userId = userId; + this.title = title; + this.content = content; + this.deviceCode = deviceCode; + this.isRead = isRead; + this.alarmTime = alarmTime; + } + + @Generated(hash = 1737519562) + public AlarmMessageLocaleBean() { + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getMessageId() { + return this.messageId; + } + + public void setMessageId(String messageId) { + this.messageId = messageId; + } + + public String getAppId() { + return this.appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public String getClientId() { + return this.clientId; + } + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public String getTaskId() { + return this.taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getUserId() { + return this.userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getTitle() { + return this.title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return this.content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getDeviceCode() { + return this.deviceCode; + } + + public void setDeviceCode(String deviceCode) { + this.deviceCode = deviceCode; + } + + public String getIsRead() { + return this.isRead; + } + + public void setIsRead(String isRead) { + this.isRead = isRead; + } + + public String getAlarmTime() { + return this.alarmTime; + } + + public void setAlarmTime(String alarmTime) { + this.alarmTime = alarmTime; + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt new file mode 100644 index 0000000..650e201 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class AlarmPageFragment: KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_alarm + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt new file mode 100644 index 0000000..deac8ac --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt @@ -0,0 +1,76 @@ +package com.casic.smart.town.sanxi.fragment + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.Fragment +import com.amap.api.maps.AMap +import com.amap.api.maps.AMapOptions +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.view.MonitorRecordActivity +import com.pengxh.kt.lite.extensions.navigatePageTo +import com.pengxh.kt.lite.extensions.show +import kotlinx.android.synthetic.main.fragment_monitor.view.* + +class MonitorPageFragment : Fragment() { + + private val kTag = "HomePageFragment" + private lateinit var monitorView: View + private lateinit var aMap: AMap + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? + ): View { + monitorView = inflater.inflate(R.layout.fragment_monitor, container, false) + //地图初始化 + initMap(savedInstanceState) + + monitorView.rightOperateView.setOnClickListener { + requireContext().navigatePageTo() + } + return monitorView + } + + private fun initMap(savedInstanceState: Bundle?) { + monitorView.mapView.onCreate(savedInstanceState) + aMap = monitorView.mapView.map + aMap.mapType = AMap.MAP_TYPE_NORMAL + val uiSettings = aMap.uiSettings + uiSettings.isCompassEnabled = true + uiSettings.zoomPosition = AMapOptions.ZOOM_POSITION_RIGHT_CENTER + uiSettings.isTiltGesturesEnabled = false//不许地图随手势倾斜角度 + + // 地图加载成功监听 +// aMap.addOnMapLoadedListener(this) + // 地图缩放监听 +// aMap.addOnCameraChangeListener(this) + // marker 点击事件监听 +// aMap.addOnMarkerClickListener(this) + // 点击marker弹出自定义popup +// aMap.setInfoWindowAdapter(this) + //信息窗点击事件 +// aMap.addOnInfoWindowClickListener(this) + } + + /***以下是地图生命周期管理************************************************************************/ + override fun onResume() { + super.onResume() + monitorView.mapView.onResume() + } + + override fun onPause() { + super.onPause() + monitorView.mapView.onPause() + } + + override fun onSaveInstanceState(outState: Bundle) { + super.onSaveInstanceState(outState) + monitorView.mapView.onSaveInstanceState(outState) + } + + override fun onDestroy() { + super.onDestroy() + monitorView.mapView.onDestroy() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt new file mode 100644 index 0000000..e84df12 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class StatisticsPageFragment : KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_statistics + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java new file mode 100644 index 0000000..68d7901 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java @@ -0,0 +1,255 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.database.Cursor; +import android.database.sqlite.SQLiteStatement; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.Property; +import org.greenrobot.greendao.internal.DaoConfig; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseStatement; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * DAO for table "ALARM_MESSAGE_LOCALE_BEAN". +*/ +public class AlarmMessageLocaleBeanDao extends AbstractDao { + + public static final String TABLENAME = "ALARM_MESSAGE_LOCALE_BEAN"; + + /** + * Properties of entity AlarmMessageLocaleBean.
+ * Can be used for QueryBuilder and for referencing column names. + */ + public static class Properties { + public final static Property Id = new Property(0, Long.class, "id", true, "_id"); + public final static Property MessageId = new Property(1, String.class, "messageId", false, "MESSAGE_ID"); + public final static Property AppId = new Property(2, String.class, "appId", false, "APP_ID"); + public final static Property ClientId = new Property(3, String.class, "clientId", false, "CLIENT_ID"); + public final static Property TaskId = new Property(4, String.class, "taskId", false, "TASK_ID"); + public final static Property UserId = new Property(5, String.class, "userId", false, "USER_ID"); + public final static Property Title = new Property(6, String.class, "title", false, "TITLE"); + public final static Property Content = new Property(7, String.class, "content", false, "CONTENT"); + public final static Property DeviceCode = new Property(8, String.class, "deviceCode", false, "DEVICE_CODE"); + public final static Property IsRead = new Property(9, String.class, "isRead", false, "IS_READ"); + public final static Property AlarmTime = new Property(10, String.class, "alarmTime", false, "ALARM_TIME"); + } + + + public AlarmMessageLocaleBeanDao(DaoConfig config) { + super(config); + } + + public AlarmMessageLocaleBeanDao(DaoConfig config, DaoSession daoSession) { + super(config, daoSession); + } + + /** Creates the underlying database table. */ + public static void createTable(Database db, boolean ifNotExists) { + String constraint = ifNotExists? "IF NOT EXISTS ": ""; + db.execSQL("CREATE TABLE " + constraint + "\"ALARM_MESSAGE_LOCALE_BEAN\" (" + // + "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id + "\"MESSAGE_ID\" TEXT UNIQUE ," + // 1: messageId + "\"APP_ID\" TEXT," + // 2: appId + "\"CLIENT_ID\" TEXT," + // 3: clientId + "\"TASK_ID\" TEXT," + // 4: taskId + "\"USER_ID\" TEXT," + // 5: userId + "\"TITLE\" TEXT," + // 6: title + "\"CONTENT\" TEXT," + // 7: content + "\"DEVICE_CODE\" TEXT," + // 8: deviceCode + "\"IS_READ\" TEXT," + // 9: isRead + "\"ALARM_TIME\" TEXT);"); // 10: alarmTime + } + + /** Drops the underlying database table. */ + public static void dropTable(Database db, boolean ifExists) { + String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"ALARM_MESSAGE_LOCALE_BEAN\""; + db.execSQL(sql); + } + + @Override + protected final void bindValues(DatabaseStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + protected final void bindValues(SQLiteStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + public Long readKey(Cursor cursor, int offset) { + return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); + } + + @Override + public AlarmMessageLocaleBean readEntity(Cursor cursor, int offset) { + AlarmMessageLocaleBean entity = new AlarmMessageLocaleBean( // + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // messageId + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // appId + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // clientId + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // taskId + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // userId + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // title + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // content + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // deviceCode + cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // isRead + cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10) // alarmTime + ); + return entity; + } + + @Override + public void readEntity(Cursor cursor, AlarmMessageLocaleBean entity, int offset) { + entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); + entity.setMessageId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setAppId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setClientId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setTaskId(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); + entity.setUserId(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setTitle(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setContent(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); + entity.setDeviceCode(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); + entity.setIsRead(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9)); + entity.setAlarmTime(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); + } + + @Override + protected final Long updateKeyAfterInsert(AlarmMessageLocaleBean entity, long rowId) { + entity.setId(rowId); + return rowId; + } + + @Override + public Long getKey(AlarmMessageLocaleBean entity) { + if(entity != null) { + return entity.getId(); + } else { + return null; + } + } + + @Override + public boolean hasKey(AlarmMessageLocaleBean entity) { + return entity.getId() != null; + } + + @Override + protected final boolean isEntityUpdateable() { + return true; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java new file mode 100644 index 0000000..4222c40 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java @@ -0,0 +1,96 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.content.Context; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteDatabase.CursorFactory; +import android.util.Log; + +import org.greenrobot.greendao.AbstractDaoMaster; +import org.greenrobot.greendao.database.StandardDatabase; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseOpenHelper; +import org.greenrobot.greendao.identityscope.IdentityScopeType; + + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * Master of DAO (schema version 1): knows all DAOs. + */ +public class DaoMaster extends AbstractDaoMaster { + public static final int SCHEMA_VERSION = 1; + + /** Creates underlying database table using DAOs. */ + public static void createAllTables(Database db, boolean ifNotExists) { + AlarmMessageLocaleBeanDao.createTable(db, ifNotExists); + } + + /** Drops underlying database table using DAOs. */ + public static void dropAllTables(Database db, boolean ifExists) { + AlarmMessageLocaleBeanDao.dropTable(db, ifExists); + } + + /** + * WARNING: Drops all table on Upgrade! Use only during development. + * Convenience method using a {@link DevOpenHelper}. + */ + public static DaoSession newDevSession(Context context, String name) { + Database db = new DevOpenHelper(context, name).getWritableDb(); + DaoMaster daoMaster = new DaoMaster(db); + return daoMaster.newSession(); + } + + public DaoMaster(SQLiteDatabase db) { + this(new StandardDatabase(db)); + } + + public DaoMaster(Database db) { + super(db, SCHEMA_VERSION); + registerDaoClass(AlarmMessageLocaleBeanDao.class); + } + + public DaoSession newSession() { + return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); + } + + public DaoSession newSession(IdentityScopeType type) { + return new DaoSession(db, type, daoConfigMap); + } + + /** + * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} - + */ + public static abstract class OpenHelper extends DatabaseOpenHelper { + public OpenHelper(Context context, String name) { + super(context, name, SCHEMA_VERSION); + } + + public OpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory, SCHEMA_VERSION); + } + + @Override + public void onCreate(Database db) { + Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); + createAllTables(db, false); + } + } + + /** WARNING: Drops all table on Upgrade! Use only during development. */ + public static class DevOpenHelper extends OpenHelper { + public DevOpenHelper(Context context, String name) { + super(context, name); + } + + public DevOpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory); + } + + @Override + public void onUpgrade(Database db, int oldVersion, int newVersion) { + Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); + dropAllTables(db, true); + onCreate(db); + } + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java new file mode 100644 index 0000000..480ed84 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java @@ -0,0 +1,48 @@ +package com.casic.smart.town.sanxi.greendao; + +import java.util.Map; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.AbstractDaoSession; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.identityscope.IdentityScopeType; +import org.greenrobot.greendao.internal.DaoConfig; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. + +/** + * {@inheritDoc} + * + * @see org.greenrobot.greendao.AbstractDaoSession + */ +public class DaoSession extends AbstractDaoSession { + + private final DaoConfig alarmMessageLocaleBeanDaoConfig; + + private final AlarmMessageLocaleBeanDao alarmMessageLocaleBeanDao; + + public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> + daoConfigMap) { + super(db); + + alarmMessageLocaleBeanDaoConfig = daoConfigMap.get(AlarmMessageLocaleBeanDao.class).clone(); + alarmMessageLocaleBeanDaoConfig.initIdentityScope(type); + + alarmMessageLocaleBeanDao = new AlarmMessageLocaleBeanDao(alarmMessageLocaleBeanDaoConfig, this); + + registerDao(AlarmMessageLocaleBean.class, alarmMessageLocaleBeanDao); + } + + public void clear() { + alarmMessageLocaleBeanDaoConfig.clearIdentityScope(); + } + + public AlarmMessageLocaleBeanDao getAlarmMessageLocaleBeanDao() { + return alarmMessageLocaleBeanDao; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt new file mode 100644 index 0000000..875cb8c --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt @@ -0,0 +1,5 @@ +package com.casic.smart.town.sanxi.service + +import com.igexin.sdk.PushService + +class ApplicationPushService : PushService() \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt new file mode 100644 index 0000000..396129f --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt @@ -0,0 +1,84 @@ +package com.casic.smart.town.sanxi.service + +import android.content.Context +import android.os.Message +import android.util.Log +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.casic.smart.town.sanxi.view.MainActivity +import com.igexin.sdk.GTIntentService +import com.igexin.sdk.message.GTCmdMessage +import com.igexin.sdk.message.GTNotificationMessage +import com.igexin.sdk.message.GTTransmitMessage +import com.pengxh.kt.lite.extensions.toJson + +class PushIntentService : GTIntentService() { + + private val kTag = "SmartWellIntentService" + + override fun onReceiveServicePid(context: Context?, pid: Int) { + + } + + // 透传消息 + override fun onReceiveMessageData(context: Context?, msg: GTTransmitMessage?) { + Log.d(kTag, "透传消息 -> msg = $msg") + } + + // 接收 cid + override fun onReceiveClientId(context: Context?, clientid: String?) { + Log.d(kTag, "onReceiveClientId -> $clientid") + //通知MainActivity注册个推服务 + val msg: Message = MainActivity.weakReferenceHandler.obtainMessage() + msg.what = LocaleConstant.PUSH_REGISTER + msg.obj = clientid + MainActivity.weakReferenceHandler.sendMessage(msg) + } + + // cid 离线上线通知 + override fun onReceiveOnlineState(context: Context?, online: Boolean) { + + } + + // 各种事件处理回执 + override fun onReceiveCommandResult(context: Context?, msg: GTCmdMessage?) { + + } + + // 通知到达 + override fun onNotificationMessageArrived(context: Context?, msg: GTNotificationMessage?) { + //报警 +// { +// "content": "设备编号[412022030361]发生井盖开盖报警", +// "messageId": "380abf9a79d34306a2683dc9bf96ee78", +// "taskId": "OSL-0830_4hmfimp3Vu684wo3SjXso9", +// "title": "告警提醒", +// "appid": "HKv8K9qARd6WckZ1o2Vbu4", +// "clientId": "e78beacc42e9a02ae6fb9087eb2b1171", +// "pkgName": "com.casic.app.smartwell" +// } + if (msg == null) { + return + } + Log.d(kTag, "通知到达 -> msg = ${msg.toJson()}") +// val userDetailJson = SaveKeyValues.getValue(LocaleConstant.USER_DETAIL_MODEL, "") as String +// var userId = "" +// if (userDetailJson.isNotBlank()) { +// val userDataModel = Gson().fromJson( +// userDetailJson, object : TypeToken() {}.type +// ) +// userId = userDataModel.id.toString() +// } +// //解析编号 +// val splitArray = msg.content.split("\\[|\\]".toRegex()) +// DataBaseManager.instance.insertNotice( +// msg.messageId, msg.appid, msg.clientId, msg.taskId, +// userId, msg.title, msg.content, splitArray[1], "0", +// System.currentTimeMillis().timestampToCompleteDate() +// ) + } + + // 通知点击 + override fun onNotificationMessageClicked(context: Context?, msg: GTNotificationMessage?) { + Log.d(kTag, "通知点击 -> msg = $msg") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt new file mode 100644 index 0000000..daa7c38 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt @@ -0,0 +1,14 @@ +package com.casic.smart.town.sanxi.util + +import android.content.Context +import me.leolin.shortcutbadger.ShortcutBadger + +object BadeHelper { + fun setBadgeNum(context: Context, badgeCount: Int) { + if (badgeCount == 0) { + ShortcutBadger.removeCount(context) + } else { + ShortcutBadger.applyCount(context, badgeCount) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt new file mode 100644 index 0000000..0a52ef2 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt @@ -0,0 +1,75 @@ +package com.casic.smart.town.sanxi.util + +import com.casic.smart.town.sanxi.base.BaseApplication +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao + +class DataBaseManager private constructor() { + + companion object { + //Kotlin委托模式双重锁单例 + val instance: DataBaseManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) { + DataBaseManager() + } + } + + private val beanDao = + BaseApplication.obtainInstance().obtainDaoSession().alarmMessageLocaleBeanDao + +// fun insertNotice( +// messageId: String, appid: String, clientId: String, +// taskId: String, userId: String, title: String, +// content: String, deviceCode: String, isRead: String, +// noticeTime: String +// ) { +// val noticeLocaleBean = NoticeLocaleBean() +// noticeLocaleBean.messageId = messageId +// noticeLocaleBean.appid = appid +// noticeLocaleBean.clientId = clientId +// noticeLocaleBean.taskId = taskId +// noticeLocaleBean.userId = userId +// noticeLocaleBean.title = title +// noticeLocaleBean.content = content +// noticeLocaleBean.deviceCode = deviceCode +// noticeLocaleBean.isRead = isRead +// noticeLocaleBean.noticeTime = noticeTime +// beanDao.insert(noticeLocaleBean) +// //角标设置 +// BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadNotice()) +// } + + fun deleteByMessageId(messageId: String) { + val result = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).list() + beanDao.deleteInTx(result) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun updateNoticeByMessageId(messageId: String) { + val noticeLocaleBean = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).unique() ?: return + noticeLocaleBean.isRead = "1" + beanDao.update(noticeLocaleBean) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun queryMessageByPage(userId: String, offset: Int): MutableList { + return BaseApplication.obtainInstance().obtainDaoSession() + .queryBuilder(AlarmMessageLocaleBean::class.java) + .where(AlarmMessageLocaleBeanDao.Properties.UserId.eq(userId)) + .offset(offset * LocaleConstant.PAGE_LIMIT) + .orderDesc(AlarmMessageLocaleBeanDao.Properties.AlarmTime) + .limit(LocaleConstant.PAGE_LIMIT) + .list() + } + + private fun queryUnReadMessage(): Int { + return beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.IsRead.eq("0") + ).list().size + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt new file mode 100644 index 0000000..52926a8 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt @@ -0,0 +1,31 @@ +package com.casic.smart.town.sanxi.util; + +import android.app.Activity +import android.view.WindowManager +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object LoadingDialogHub { + private lateinit var loadingDialog: QMUITipDialog + + fun show(activity: Activity, message: String) { + loadingDialog = QMUITipDialog + .Builder(activity) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_LOADING) + .setTipWord(message) + .create() + if (!activity.isDestroyed) { + try { + loadingDialog.show() + } catch (e: WindowManager.BadTokenException) { + e.printStackTrace() + } + } + } + + + fun dismiss() { + if (loadingDialog.isShowing) { + loadingDialog.dismiss() + } + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt new file mode 100644 index 0000000..de61c9a --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.util + +import android.Manifest + +object LocaleConstant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.READ_PHONE_STATE, + Manifest.permission.ACCESS_COARSE_LOCATION, + Manifest.permission.READ_EXTERNAL_STORAGE + ) + + const val PERMISSIONS_CODE = 999 + const val PUSH_REGISTER = 2022100101 + const val PAGE_LIMIT = 20 +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt new file mode 100644 index 0000000..3bea1c9 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt @@ -0,0 +1,112 @@ +package com.casic.smart.town.sanxi.view + +import android.view.KeyEvent +import android.view.MenuItem +import androidx.fragment.app.Fragment +import androidx.viewpager.widget.ViewPager +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.adapter.ViewPagerAdapter +import com.casic.smart.town.sanxi.fragment.AlarmPageFragment +import com.casic.smart.town.sanxi.fragment.MonitorPageFragment +import com.casic.smart.town.sanxi.fragment.StatisticsPageFragment +import com.gyf.immersionbar.ImmersionBar +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.base.KotlinBaseActivity +import com.pengxh.kt.lite.extensions.convertColor +import com.pengxh.kt.lite.extensions.show +import com.pengxh.kt.lite.utils.ImmerseStatusBarUtil +import com.pengxh.kt.lite.utils.WeakReferenceHandler +import kotlinx.android.synthetic.main.activity_main.* + +class MainActivity : KotlinBaseActivity() { + + companion object { + lateinit var weakReferenceHandler: WeakReferenceHandler + } + + private val kTag = "MainActivity" + private var menuItem: MenuItem? = null + private var fragmentPages: ArrayList = ArrayList() + private var clickTime: Long = 0 + + init { + fragmentPages.add(StatisticsPageFragment()) + fragmentPages.add(MonitorPageFragment()) + fragmentPages.add(AlarmPageFragment()) + } + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + ImmersionBar.with(this).statusBarDarkFont(false).init() + ImmerseStatusBarUtil.setColor(this, R.color.mainThemeColor.convertColor(this)) + } + + override fun initData() { + //推送,多次调用 SDK 初始化并无影响。 + PushManager.getInstance().initialize(this) + weakReferenceHandler = WeakReferenceHandler { + + true + } + } + + override fun observeRequestState() { + + } + + override fun initEvent() { + bottomNavigation.itemIconTintList = null + bottomNavigation.setOnNavigationItemSelectedListener { menuItem -> + when (menuItem.itemId) { + R.id.nav_statistics -> { + mainViewPager.currentItem = 0 + } + R.id.nav_monitor -> { + mainViewPager.currentItem = 1 + } + R.id.nav_alarm -> { + mainViewPager.currentItem = 2 + } + } + false + } + mainViewPager.adapter = ViewPagerAdapter(fragmentPages, supportFragmentManager) + mainViewPager.offscreenPageLimit = fragmentPages.size //缓存页数 + mainViewPager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener { + override fun onPageScrollStateChanged(state: Int) { + + } + + override fun onPageScrolled( + position: Int, + positionOffset: Float, + positionOffsetPixels: Int + ) { + + } + + override fun onPageSelected(position: Int) { + if (menuItem != null) { + menuItem!!.isChecked = false + } else { + bottomNavigation.menu.getItem(0).isChecked = false + } + menuItem = bottomNavigation.menu.getItem(position) + menuItem!!.isChecked = true + } + }) + } + + override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean { + return if (keyCode == KeyEvent.KEYCODE_BACK) { + if (System.currentTimeMillis() - clickTime > 2000) { + "再按一次退出程序".show(this) + clickTime = System.currentTimeMillis() + true + } else { + super.onKeyDown(keyCode, event) + } + } else super.onKeyDown(keyCode, event) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt new file mode 100644 index 0000000..c5d8b22 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.view + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseActivity + +class MonitorRecordActivity : KotlinBaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_monitor_record + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt new file mode 100644 index 0000000..c478d83 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt @@ -0,0 +1,55 @@ +package com.casic.smart.town.sanxi.view + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.amap.api.maps.MapsInitializer +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.gyf.immersionbar.ImmersionBar +import com.pengxh.kt.lite.extensions.navigatePageTo +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + ImmersionBar.with(this).statusBarDarkFont(true).init() + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (EasyPermissions.hasPermissions(this, *LocaleConstant.USER_PERMISSIONS)) { + startSplashScreenActivity() + } else { + EasyPermissions.requestPermissions( + this@PermissionActivity, + resources.getString(R.string.app_name) + "需要获取相关权限", + LocaleConstant.PERMISSIONS_CODE, + *LocaleConstant.USER_PERMISSIONS + ) + } + } + + private fun startSplashScreenActivity() { + //先把导航隐私政策声明,后面导航会用到 + MapsInitializer.updatePrivacyAgree(this, true) + MapsInitializer.updatePrivacyShow(this, true, true) + this.navigatePageTo() + 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) { + startSplashScreenActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable/alarm_selector.xml b/app/src/main/res/drawable/alarm_selector.xml new file mode 100644 index 0000000..39b2595 --- /dev/null +++ b/app/src/main/res/drawable/alarm_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bottom_text_color.xml b/app/src/main/res/drawable/bottom_text_color.xml new file mode 100644 index 0000000..b284ea3 --- /dev/null +++ b/app/src/main/res/drawable/bottom_text_color.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_alarm.xml b/app/src/main/res/drawable/ic_alarm.xml new file mode 100644 index 0000000..dc33aab --- /dev/null +++ b/app/src/main/res/drawable/ic_alarm.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_alarm_selected.xml b/app/src/main/res/drawable/ic_alarm_selected.xml new file mode 100644 index 0000000..993fea6 --- /dev/null +++ b/app/src/main/res/drawable/ic_alarm_selected.xml @@ -0,0 +1,9 @@ + + + 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_monitor.xml b/app/src/main/res/drawable/ic_monitor.xml new file mode 100644 index 0000000..271f5b4 --- /dev/null +++ b/app/src/main/res/drawable/ic_monitor.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_monitor_selected.xml b/app/src/main/res/drawable/ic_monitor_selected.xml new file mode 100644 index 0000000..ee62d84 --- /dev/null +++ b/app/src/main/res/drawable/ic_monitor_selected.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_statistics.xml b/app/src/main/res/drawable/ic_statistics.xml new file mode 100644 index 0000000..7fde8ec --- /dev/null +++ b/app/src/main/res/drawable/ic_statistics.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_statistics_selected.xml b/app/src/main/res/drawable/ic_statistics_selected.xml new file mode 100644 index 0000000..49b6fcd --- /dev/null +++ b/app/src/main/res/drawable/ic_statistics_selected.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/monitor_selector.xml b/app/src/main/res/drawable/monitor_selector.xml new file mode 100644 index 0000000..fe11e9a --- /dev/null +++ b/app/src/main/res/drawable/monitor_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/statistics_selector.xml b/app/src/main/res/drawable/statistics_selector.xml new file mode 100644 index 0000000..2156cff --- /dev/null +++ b/app/src/main/res/drawable/statistics_selector.xml @@ -0,0 +1,5 @@ + + + + + \ 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..78a4a94 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,27 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_monitor_record.xml b/app/src/main/res/layout/activity_monitor_record.xml new file mode 100644 index 0000000..77d9ef6 --- /dev/null +++ b/app/src/main/res/layout/activity_monitor_record.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_alarm.xml b/app/src/main/res/layout/fragment_alarm.xml new file mode 100644 index 0000000..77d9ef6 --- /dev/null +++ b/app/src/main/res/layout/fragment_alarm.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_monitor.xml b/app/src/main/res/layout/fragment_monitor.xml new file mode 100644 index 0000000..19789c1 --- /dev/null +++ b/app/src/main/res/layout/fragment_monitor.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_statistics.xml b/app/src/main/res/layout/fragment_statistics.xml new file mode 100644 index 0000000..77d9ef6 --- /dev/null +++ b/app/src/main/res/layout/fragment_statistics.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..10cfdbf --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*.iml +.gradle +/local.properties +/.idea +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..a4cd2ca --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,101 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'org.greenrobot.greendao' + +android { +// signingConfigs { +// release { +// storeFile file('/Users/a203/Desktop/AndroidProjects/CasicSmartWell/app/CasicSmartWell.jks') +// storePassword '123456789' +// keyAlias 'key0' +// keyPassword '123456789' +// } +// } + compileSdkVersion 31 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.smart.town.sanxi" + minSdkVersion 23 + targetSdkVersion 31 + versionCode 1 + versionName "1.0.0" + + manifestPlaceholders = [GETUI_APPID: "A9V4DvwLcdAqkFCQuFyhq6"] + } + + buildTypes { + release { + minifyEnabled false +// signingConfig signingConfigs.release + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + + ndk { abiFilters "armeabi", "armeabi-v7a", "arm64-v8" } + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlin { + experimental { + coroutines 'enable' + } + } + + greendao { + schemaVersion 1//数据库版本号 + targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 + daoPackage 'com.casic.smart.town.sanxi.greendao'//设置DaoMaster、DaoSession、Dao包名 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + //基础依赖库 + implementation files('libs/lite-release.aar') + implementation 'androidx.appcompat:appcompat:1.4.2' + implementation 'androidx.core:core-ktx:1.8.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:3.0.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' + //MVVM+LiveData + implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.1" + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0" + implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + //Kotlin协程 + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1' + //图片加载框架 + implementation 'com.github.bumptech.glide:glide:4.9.0' + //返回值转换器 + implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' + implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + //okhttp3日志拦截器 + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //网络请求和接口封装 + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.9.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.9.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' + //高德地图 + implementation 'com.amap.api:3dmap:latest.integration' + //推送SDK + implementation 'com.getui:gtsdk:3.2.10.0' //个推SDK + implementation 'com.getui:gtc:3.1.9.0' //个推核心组件 + //数据库框架 + implementation 'org.greenrobot:greendao:3.3.0' + //桌面角标 + implementation "me.leolin:ShortcutBadger:1.1.22@aar" +} \ No newline at end of file diff --git a/app/libs/lite-release.aar b/app/libs/lite-release.aar new file mode 100644 index 0000000..45da4df --- /dev/null +++ b/app/libs/lite-release.aar Binary files differ diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /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 \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..a83c28a --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/svg/monitor.svg b/app/src/main/assets/svg/monitor.svg new file mode 100644 index 0000000..c8d3e25 --- /dev/null +++ b/app/src/main/assets/svg/monitor.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/msg.svg b/app/src/main/assets/svg/msg.svg new file mode 100644 index 0000000..e864e48 --- /dev/null +++ b/app/src/main/assets/svg/msg.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/statistics.svg b/app/src/main/assets/svg/statistics.svg new file mode 100644 index 0000000..974000e --- /dev/null +++ b/app/src/main/assets/svg/statistics.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt new file mode 100644 index 0000000..6b9cce0 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.adapter + +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentManager +import androidx.fragment.app.FragmentPagerAdapter + +class ViewPagerAdapter(list: ArrayList, manager: FragmentManager) : + FragmentPagerAdapter(manager) { + + private var pageList: List = list + + override fun getItem(position: Int) = pageList[position] + + override fun getCount() = pageList.size +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt new file mode 100644 index 0000000..4e017b1 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt @@ -0,0 +1,40 @@ +package com.casic.smart.town.sanxi.base + +import android.app.Application +import android.util.Log +import com.casic.smart.town.sanxi.greendao.DaoMaster +import com.casic.smart.town.sanxi.greendao.DaoSession +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + private val kTag = "BaseApplication" + + companion object { + private var instance: BaseApplication by Delegates.notNull() + + fun obtainInstance() = instance + + private lateinit var daoSession: DaoSession + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences(this) + //推送 + PushManager.getInstance().initialize(this) + PushManager.getInstance().setDebugLogger(this) { + Log.d(kTag, it) + } + val devOpenHelper = DaoMaster.DevOpenHelper(this, "SmartTown.db", null) + val daoMaster = DaoMaster(devOpenHelper.writableDatabase) + daoSession = daoMaster.newSession() + } + + fun obtainDaoSession(): DaoSession { + return daoSession + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java new file mode 100644 index 0000000..b8f67dc --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java @@ -0,0 +1,133 @@ +package com.casic.smart.town.sanxi.bean; + +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Generated; +import org.greenrobot.greendao.annotation.Id; +import org.greenrobot.greendao.annotation.Unique; + +@Entity +public class AlarmMessageLocaleBean { + @Id(autoincrement = true) + private Long id;//主键自增 + + @Unique + private String messageId; + private String appId; + private String clientId; + private String taskId; + private String userId; + private String title; + private String content; + private String deviceCode; + private String isRead;//0-未读,1-已读 + private String alarmTime; + + @Generated(hash = 566950134) + public AlarmMessageLocaleBean(Long id, String messageId, String appId, + String clientId, String taskId, String userId, String title, + String content, String deviceCode, String isRead, String alarmTime) { + this.id = id; + this.messageId = messageId; + this.appId = appId; + this.clientId = clientId; + this.taskId = taskId; + this.userId = userId; + this.title = title; + this.content = content; + this.deviceCode = deviceCode; + this.isRead = isRead; + this.alarmTime = alarmTime; + } + + @Generated(hash = 1737519562) + public AlarmMessageLocaleBean() { + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getMessageId() { + return this.messageId; + } + + public void setMessageId(String messageId) { + this.messageId = messageId; + } + + public String getAppId() { + return this.appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public String getClientId() { + return this.clientId; + } + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public String getTaskId() { + return this.taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getUserId() { + return this.userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getTitle() { + return this.title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return this.content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getDeviceCode() { + return this.deviceCode; + } + + public void setDeviceCode(String deviceCode) { + this.deviceCode = deviceCode; + } + + public String getIsRead() { + return this.isRead; + } + + public void setIsRead(String isRead) { + this.isRead = isRead; + } + + public String getAlarmTime() { + return this.alarmTime; + } + + public void setAlarmTime(String alarmTime) { + this.alarmTime = alarmTime; + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt new file mode 100644 index 0000000..650e201 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class AlarmPageFragment: KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_alarm + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt new file mode 100644 index 0000000..deac8ac --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt @@ -0,0 +1,76 @@ +package com.casic.smart.town.sanxi.fragment + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.Fragment +import com.amap.api.maps.AMap +import com.amap.api.maps.AMapOptions +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.view.MonitorRecordActivity +import com.pengxh.kt.lite.extensions.navigatePageTo +import com.pengxh.kt.lite.extensions.show +import kotlinx.android.synthetic.main.fragment_monitor.view.* + +class MonitorPageFragment : Fragment() { + + private val kTag = "HomePageFragment" + private lateinit var monitorView: View + private lateinit var aMap: AMap + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? + ): View { + monitorView = inflater.inflate(R.layout.fragment_monitor, container, false) + //地图初始化 + initMap(savedInstanceState) + + monitorView.rightOperateView.setOnClickListener { + requireContext().navigatePageTo() + } + return monitorView + } + + private fun initMap(savedInstanceState: Bundle?) { + monitorView.mapView.onCreate(savedInstanceState) + aMap = monitorView.mapView.map + aMap.mapType = AMap.MAP_TYPE_NORMAL + val uiSettings = aMap.uiSettings + uiSettings.isCompassEnabled = true + uiSettings.zoomPosition = AMapOptions.ZOOM_POSITION_RIGHT_CENTER + uiSettings.isTiltGesturesEnabled = false//不许地图随手势倾斜角度 + + // 地图加载成功监听 +// aMap.addOnMapLoadedListener(this) + // 地图缩放监听 +// aMap.addOnCameraChangeListener(this) + // marker 点击事件监听 +// aMap.addOnMarkerClickListener(this) + // 点击marker弹出自定义popup +// aMap.setInfoWindowAdapter(this) + //信息窗点击事件 +// aMap.addOnInfoWindowClickListener(this) + } + + /***以下是地图生命周期管理************************************************************************/ + override fun onResume() { + super.onResume() + monitorView.mapView.onResume() + } + + override fun onPause() { + super.onPause() + monitorView.mapView.onPause() + } + + override fun onSaveInstanceState(outState: Bundle) { + super.onSaveInstanceState(outState) + monitorView.mapView.onSaveInstanceState(outState) + } + + override fun onDestroy() { + super.onDestroy() + monitorView.mapView.onDestroy() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt new file mode 100644 index 0000000..e84df12 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class StatisticsPageFragment : KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_statistics + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java new file mode 100644 index 0000000..68d7901 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java @@ -0,0 +1,255 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.database.Cursor; +import android.database.sqlite.SQLiteStatement; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.Property; +import org.greenrobot.greendao.internal.DaoConfig; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseStatement; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * DAO for table "ALARM_MESSAGE_LOCALE_BEAN". +*/ +public class AlarmMessageLocaleBeanDao extends AbstractDao { + + public static final String TABLENAME = "ALARM_MESSAGE_LOCALE_BEAN"; + + /** + * Properties of entity AlarmMessageLocaleBean.
+ * Can be used for QueryBuilder and for referencing column names. + */ + public static class Properties { + public final static Property Id = new Property(0, Long.class, "id", true, "_id"); + public final static Property MessageId = new Property(1, String.class, "messageId", false, "MESSAGE_ID"); + public final static Property AppId = new Property(2, String.class, "appId", false, "APP_ID"); + public final static Property ClientId = new Property(3, String.class, "clientId", false, "CLIENT_ID"); + public final static Property TaskId = new Property(4, String.class, "taskId", false, "TASK_ID"); + public final static Property UserId = new Property(5, String.class, "userId", false, "USER_ID"); + public final static Property Title = new Property(6, String.class, "title", false, "TITLE"); + public final static Property Content = new Property(7, String.class, "content", false, "CONTENT"); + public final static Property DeviceCode = new Property(8, String.class, "deviceCode", false, "DEVICE_CODE"); + public final static Property IsRead = new Property(9, String.class, "isRead", false, "IS_READ"); + public final static Property AlarmTime = new Property(10, String.class, "alarmTime", false, "ALARM_TIME"); + } + + + public AlarmMessageLocaleBeanDao(DaoConfig config) { + super(config); + } + + public AlarmMessageLocaleBeanDao(DaoConfig config, DaoSession daoSession) { + super(config, daoSession); + } + + /** Creates the underlying database table. */ + public static void createTable(Database db, boolean ifNotExists) { + String constraint = ifNotExists? "IF NOT EXISTS ": ""; + db.execSQL("CREATE TABLE " + constraint + "\"ALARM_MESSAGE_LOCALE_BEAN\" (" + // + "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id + "\"MESSAGE_ID\" TEXT UNIQUE ," + // 1: messageId + "\"APP_ID\" TEXT," + // 2: appId + "\"CLIENT_ID\" TEXT," + // 3: clientId + "\"TASK_ID\" TEXT," + // 4: taskId + "\"USER_ID\" TEXT," + // 5: userId + "\"TITLE\" TEXT," + // 6: title + "\"CONTENT\" TEXT," + // 7: content + "\"DEVICE_CODE\" TEXT," + // 8: deviceCode + "\"IS_READ\" TEXT," + // 9: isRead + "\"ALARM_TIME\" TEXT);"); // 10: alarmTime + } + + /** Drops the underlying database table. */ + public static void dropTable(Database db, boolean ifExists) { + String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"ALARM_MESSAGE_LOCALE_BEAN\""; + db.execSQL(sql); + } + + @Override + protected final void bindValues(DatabaseStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + protected final void bindValues(SQLiteStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + public Long readKey(Cursor cursor, int offset) { + return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); + } + + @Override + public AlarmMessageLocaleBean readEntity(Cursor cursor, int offset) { + AlarmMessageLocaleBean entity = new AlarmMessageLocaleBean( // + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // messageId + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // appId + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // clientId + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // taskId + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // userId + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // title + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // content + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // deviceCode + cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // isRead + cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10) // alarmTime + ); + return entity; + } + + @Override + public void readEntity(Cursor cursor, AlarmMessageLocaleBean entity, int offset) { + entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); + entity.setMessageId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setAppId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setClientId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setTaskId(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); + entity.setUserId(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setTitle(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setContent(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); + entity.setDeviceCode(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); + entity.setIsRead(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9)); + entity.setAlarmTime(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); + } + + @Override + protected final Long updateKeyAfterInsert(AlarmMessageLocaleBean entity, long rowId) { + entity.setId(rowId); + return rowId; + } + + @Override + public Long getKey(AlarmMessageLocaleBean entity) { + if(entity != null) { + return entity.getId(); + } else { + return null; + } + } + + @Override + public boolean hasKey(AlarmMessageLocaleBean entity) { + return entity.getId() != null; + } + + @Override + protected final boolean isEntityUpdateable() { + return true; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java new file mode 100644 index 0000000..4222c40 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java @@ -0,0 +1,96 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.content.Context; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteDatabase.CursorFactory; +import android.util.Log; + +import org.greenrobot.greendao.AbstractDaoMaster; +import org.greenrobot.greendao.database.StandardDatabase; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseOpenHelper; +import org.greenrobot.greendao.identityscope.IdentityScopeType; + + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * Master of DAO (schema version 1): knows all DAOs. + */ +public class DaoMaster extends AbstractDaoMaster { + public static final int SCHEMA_VERSION = 1; + + /** Creates underlying database table using DAOs. */ + public static void createAllTables(Database db, boolean ifNotExists) { + AlarmMessageLocaleBeanDao.createTable(db, ifNotExists); + } + + /** Drops underlying database table using DAOs. */ + public static void dropAllTables(Database db, boolean ifExists) { + AlarmMessageLocaleBeanDao.dropTable(db, ifExists); + } + + /** + * WARNING: Drops all table on Upgrade! Use only during development. + * Convenience method using a {@link DevOpenHelper}. + */ + public static DaoSession newDevSession(Context context, String name) { + Database db = new DevOpenHelper(context, name).getWritableDb(); + DaoMaster daoMaster = new DaoMaster(db); + return daoMaster.newSession(); + } + + public DaoMaster(SQLiteDatabase db) { + this(new StandardDatabase(db)); + } + + public DaoMaster(Database db) { + super(db, SCHEMA_VERSION); + registerDaoClass(AlarmMessageLocaleBeanDao.class); + } + + public DaoSession newSession() { + return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); + } + + public DaoSession newSession(IdentityScopeType type) { + return new DaoSession(db, type, daoConfigMap); + } + + /** + * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} - + */ + public static abstract class OpenHelper extends DatabaseOpenHelper { + public OpenHelper(Context context, String name) { + super(context, name, SCHEMA_VERSION); + } + + public OpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory, SCHEMA_VERSION); + } + + @Override + public void onCreate(Database db) { + Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); + createAllTables(db, false); + } + } + + /** WARNING: Drops all table on Upgrade! Use only during development. */ + public static class DevOpenHelper extends OpenHelper { + public DevOpenHelper(Context context, String name) { + super(context, name); + } + + public DevOpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory); + } + + @Override + public void onUpgrade(Database db, int oldVersion, int newVersion) { + Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); + dropAllTables(db, true); + onCreate(db); + } + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java new file mode 100644 index 0000000..480ed84 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java @@ -0,0 +1,48 @@ +package com.casic.smart.town.sanxi.greendao; + +import java.util.Map; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.AbstractDaoSession; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.identityscope.IdentityScopeType; +import org.greenrobot.greendao.internal.DaoConfig; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. + +/** + * {@inheritDoc} + * + * @see org.greenrobot.greendao.AbstractDaoSession + */ +public class DaoSession extends AbstractDaoSession { + + private final DaoConfig alarmMessageLocaleBeanDaoConfig; + + private final AlarmMessageLocaleBeanDao alarmMessageLocaleBeanDao; + + public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> + daoConfigMap) { + super(db); + + alarmMessageLocaleBeanDaoConfig = daoConfigMap.get(AlarmMessageLocaleBeanDao.class).clone(); + alarmMessageLocaleBeanDaoConfig.initIdentityScope(type); + + alarmMessageLocaleBeanDao = new AlarmMessageLocaleBeanDao(alarmMessageLocaleBeanDaoConfig, this); + + registerDao(AlarmMessageLocaleBean.class, alarmMessageLocaleBeanDao); + } + + public void clear() { + alarmMessageLocaleBeanDaoConfig.clearIdentityScope(); + } + + public AlarmMessageLocaleBeanDao getAlarmMessageLocaleBeanDao() { + return alarmMessageLocaleBeanDao; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt new file mode 100644 index 0000000..875cb8c --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt @@ -0,0 +1,5 @@ +package com.casic.smart.town.sanxi.service + +import com.igexin.sdk.PushService + +class ApplicationPushService : PushService() \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt new file mode 100644 index 0000000..396129f --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt @@ -0,0 +1,84 @@ +package com.casic.smart.town.sanxi.service + +import android.content.Context +import android.os.Message +import android.util.Log +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.casic.smart.town.sanxi.view.MainActivity +import com.igexin.sdk.GTIntentService +import com.igexin.sdk.message.GTCmdMessage +import com.igexin.sdk.message.GTNotificationMessage +import com.igexin.sdk.message.GTTransmitMessage +import com.pengxh.kt.lite.extensions.toJson + +class PushIntentService : GTIntentService() { + + private val kTag = "SmartWellIntentService" + + override fun onReceiveServicePid(context: Context?, pid: Int) { + + } + + // 透传消息 + override fun onReceiveMessageData(context: Context?, msg: GTTransmitMessage?) { + Log.d(kTag, "透传消息 -> msg = $msg") + } + + // 接收 cid + override fun onReceiveClientId(context: Context?, clientid: String?) { + Log.d(kTag, "onReceiveClientId -> $clientid") + //通知MainActivity注册个推服务 + val msg: Message = MainActivity.weakReferenceHandler.obtainMessage() + msg.what = LocaleConstant.PUSH_REGISTER + msg.obj = clientid + MainActivity.weakReferenceHandler.sendMessage(msg) + } + + // cid 离线上线通知 + override fun onReceiveOnlineState(context: Context?, online: Boolean) { + + } + + // 各种事件处理回执 + override fun onReceiveCommandResult(context: Context?, msg: GTCmdMessage?) { + + } + + // 通知到达 + override fun onNotificationMessageArrived(context: Context?, msg: GTNotificationMessage?) { + //报警 +// { +// "content": "设备编号[412022030361]发生井盖开盖报警", +// "messageId": "380abf9a79d34306a2683dc9bf96ee78", +// "taskId": "OSL-0830_4hmfimp3Vu684wo3SjXso9", +// "title": "告警提醒", +// "appid": "HKv8K9qARd6WckZ1o2Vbu4", +// "clientId": "e78beacc42e9a02ae6fb9087eb2b1171", +// "pkgName": "com.casic.app.smartwell" +// } + if (msg == null) { + return + } + Log.d(kTag, "通知到达 -> msg = ${msg.toJson()}") +// val userDetailJson = SaveKeyValues.getValue(LocaleConstant.USER_DETAIL_MODEL, "") as String +// var userId = "" +// if (userDetailJson.isNotBlank()) { +// val userDataModel = Gson().fromJson( +// userDetailJson, object : TypeToken() {}.type +// ) +// userId = userDataModel.id.toString() +// } +// //解析编号 +// val splitArray = msg.content.split("\\[|\\]".toRegex()) +// DataBaseManager.instance.insertNotice( +// msg.messageId, msg.appid, msg.clientId, msg.taskId, +// userId, msg.title, msg.content, splitArray[1], "0", +// System.currentTimeMillis().timestampToCompleteDate() +// ) + } + + // 通知点击 + override fun onNotificationMessageClicked(context: Context?, msg: GTNotificationMessage?) { + Log.d(kTag, "通知点击 -> msg = $msg") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt new file mode 100644 index 0000000..daa7c38 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt @@ -0,0 +1,14 @@ +package com.casic.smart.town.sanxi.util + +import android.content.Context +import me.leolin.shortcutbadger.ShortcutBadger + +object BadeHelper { + fun setBadgeNum(context: Context, badgeCount: Int) { + if (badgeCount == 0) { + ShortcutBadger.removeCount(context) + } else { + ShortcutBadger.applyCount(context, badgeCount) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt new file mode 100644 index 0000000..0a52ef2 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt @@ -0,0 +1,75 @@ +package com.casic.smart.town.sanxi.util + +import com.casic.smart.town.sanxi.base.BaseApplication +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao + +class DataBaseManager private constructor() { + + companion object { + //Kotlin委托模式双重锁单例 + val instance: DataBaseManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) { + DataBaseManager() + } + } + + private val beanDao = + BaseApplication.obtainInstance().obtainDaoSession().alarmMessageLocaleBeanDao + +// fun insertNotice( +// messageId: String, appid: String, clientId: String, +// taskId: String, userId: String, title: String, +// content: String, deviceCode: String, isRead: String, +// noticeTime: String +// ) { +// val noticeLocaleBean = NoticeLocaleBean() +// noticeLocaleBean.messageId = messageId +// noticeLocaleBean.appid = appid +// noticeLocaleBean.clientId = clientId +// noticeLocaleBean.taskId = taskId +// noticeLocaleBean.userId = userId +// noticeLocaleBean.title = title +// noticeLocaleBean.content = content +// noticeLocaleBean.deviceCode = deviceCode +// noticeLocaleBean.isRead = isRead +// noticeLocaleBean.noticeTime = noticeTime +// beanDao.insert(noticeLocaleBean) +// //角标设置 +// BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadNotice()) +// } + + fun deleteByMessageId(messageId: String) { + val result = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).list() + beanDao.deleteInTx(result) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun updateNoticeByMessageId(messageId: String) { + val noticeLocaleBean = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).unique() ?: return + noticeLocaleBean.isRead = "1" + beanDao.update(noticeLocaleBean) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun queryMessageByPage(userId: String, offset: Int): MutableList { + return BaseApplication.obtainInstance().obtainDaoSession() + .queryBuilder(AlarmMessageLocaleBean::class.java) + .where(AlarmMessageLocaleBeanDao.Properties.UserId.eq(userId)) + .offset(offset * LocaleConstant.PAGE_LIMIT) + .orderDesc(AlarmMessageLocaleBeanDao.Properties.AlarmTime) + .limit(LocaleConstant.PAGE_LIMIT) + .list() + } + + private fun queryUnReadMessage(): Int { + return beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.IsRead.eq("0") + ).list().size + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt new file mode 100644 index 0000000..52926a8 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt @@ -0,0 +1,31 @@ +package com.casic.smart.town.sanxi.util; + +import android.app.Activity +import android.view.WindowManager +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object LoadingDialogHub { + private lateinit var loadingDialog: QMUITipDialog + + fun show(activity: Activity, message: String) { + loadingDialog = QMUITipDialog + .Builder(activity) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_LOADING) + .setTipWord(message) + .create() + if (!activity.isDestroyed) { + try { + loadingDialog.show() + } catch (e: WindowManager.BadTokenException) { + e.printStackTrace() + } + } + } + + + fun dismiss() { + if (loadingDialog.isShowing) { + loadingDialog.dismiss() + } + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt new file mode 100644 index 0000000..de61c9a --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.util + +import android.Manifest + +object LocaleConstant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.READ_PHONE_STATE, + Manifest.permission.ACCESS_COARSE_LOCATION, + Manifest.permission.READ_EXTERNAL_STORAGE + ) + + const val PERMISSIONS_CODE = 999 + const val PUSH_REGISTER = 2022100101 + const val PAGE_LIMIT = 20 +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt new file mode 100644 index 0000000..3bea1c9 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt @@ -0,0 +1,112 @@ +package com.casic.smart.town.sanxi.view + +import android.view.KeyEvent +import android.view.MenuItem +import androidx.fragment.app.Fragment +import androidx.viewpager.widget.ViewPager +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.adapter.ViewPagerAdapter +import com.casic.smart.town.sanxi.fragment.AlarmPageFragment +import com.casic.smart.town.sanxi.fragment.MonitorPageFragment +import com.casic.smart.town.sanxi.fragment.StatisticsPageFragment +import com.gyf.immersionbar.ImmersionBar +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.base.KotlinBaseActivity +import com.pengxh.kt.lite.extensions.convertColor +import com.pengxh.kt.lite.extensions.show +import com.pengxh.kt.lite.utils.ImmerseStatusBarUtil +import com.pengxh.kt.lite.utils.WeakReferenceHandler +import kotlinx.android.synthetic.main.activity_main.* + +class MainActivity : KotlinBaseActivity() { + + companion object { + lateinit var weakReferenceHandler: WeakReferenceHandler + } + + private val kTag = "MainActivity" + private var menuItem: MenuItem? = null + private var fragmentPages: ArrayList = ArrayList() + private var clickTime: Long = 0 + + init { + fragmentPages.add(StatisticsPageFragment()) + fragmentPages.add(MonitorPageFragment()) + fragmentPages.add(AlarmPageFragment()) + } + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + ImmersionBar.with(this).statusBarDarkFont(false).init() + ImmerseStatusBarUtil.setColor(this, R.color.mainThemeColor.convertColor(this)) + } + + override fun initData() { + //推送,多次调用 SDK 初始化并无影响。 + PushManager.getInstance().initialize(this) + weakReferenceHandler = WeakReferenceHandler { + + true + } + } + + override fun observeRequestState() { + + } + + override fun initEvent() { + bottomNavigation.itemIconTintList = null + bottomNavigation.setOnNavigationItemSelectedListener { menuItem -> + when (menuItem.itemId) { + R.id.nav_statistics -> { + mainViewPager.currentItem = 0 + } + R.id.nav_monitor -> { + mainViewPager.currentItem = 1 + } + R.id.nav_alarm -> { + mainViewPager.currentItem = 2 + } + } + false + } + mainViewPager.adapter = ViewPagerAdapter(fragmentPages, supportFragmentManager) + mainViewPager.offscreenPageLimit = fragmentPages.size //缓存页数 + mainViewPager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener { + override fun onPageScrollStateChanged(state: Int) { + + } + + override fun onPageScrolled( + position: Int, + positionOffset: Float, + positionOffsetPixels: Int + ) { + + } + + override fun onPageSelected(position: Int) { + if (menuItem != null) { + menuItem!!.isChecked = false + } else { + bottomNavigation.menu.getItem(0).isChecked = false + } + menuItem = bottomNavigation.menu.getItem(position) + menuItem!!.isChecked = true + } + }) + } + + override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean { + return if (keyCode == KeyEvent.KEYCODE_BACK) { + if (System.currentTimeMillis() - clickTime > 2000) { + "再按一次退出程序".show(this) + clickTime = System.currentTimeMillis() + true + } else { + super.onKeyDown(keyCode, event) + } + } else super.onKeyDown(keyCode, event) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt new file mode 100644 index 0000000..c5d8b22 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.view + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseActivity + +class MonitorRecordActivity : KotlinBaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_monitor_record + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt new file mode 100644 index 0000000..c478d83 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt @@ -0,0 +1,55 @@ +package com.casic.smart.town.sanxi.view + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.amap.api.maps.MapsInitializer +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.gyf.immersionbar.ImmersionBar +import com.pengxh.kt.lite.extensions.navigatePageTo +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + ImmersionBar.with(this).statusBarDarkFont(true).init() + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (EasyPermissions.hasPermissions(this, *LocaleConstant.USER_PERMISSIONS)) { + startSplashScreenActivity() + } else { + EasyPermissions.requestPermissions( + this@PermissionActivity, + resources.getString(R.string.app_name) + "需要获取相关权限", + LocaleConstant.PERMISSIONS_CODE, + *LocaleConstant.USER_PERMISSIONS + ) + } + } + + private fun startSplashScreenActivity() { + //先把导航隐私政策声明,后面导航会用到 + MapsInitializer.updatePrivacyAgree(this, true) + MapsInitializer.updatePrivacyShow(this, true, true) + this.navigatePageTo() + 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) { + startSplashScreenActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable/alarm_selector.xml b/app/src/main/res/drawable/alarm_selector.xml new file mode 100644 index 0000000..39b2595 --- /dev/null +++ b/app/src/main/res/drawable/alarm_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bottom_text_color.xml b/app/src/main/res/drawable/bottom_text_color.xml new file mode 100644 index 0000000..b284ea3 --- /dev/null +++ b/app/src/main/res/drawable/bottom_text_color.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_alarm.xml b/app/src/main/res/drawable/ic_alarm.xml new file mode 100644 index 0000000..dc33aab --- /dev/null +++ b/app/src/main/res/drawable/ic_alarm.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_alarm_selected.xml b/app/src/main/res/drawable/ic_alarm_selected.xml new file mode 100644 index 0000000..993fea6 --- /dev/null +++ b/app/src/main/res/drawable/ic_alarm_selected.xml @@ -0,0 +1,9 @@ + + + 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_monitor.xml b/app/src/main/res/drawable/ic_monitor.xml new file mode 100644 index 0000000..271f5b4 --- /dev/null +++ b/app/src/main/res/drawable/ic_monitor.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_monitor_selected.xml b/app/src/main/res/drawable/ic_monitor_selected.xml new file mode 100644 index 0000000..ee62d84 --- /dev/null +++ b/app/src/main/res/drawable/ic_monitor_selected.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_statistics.xml b/app/src/main/res/drawable/ic_statistics.xml new file mode 100644 index 0000000..7fde8ec --- /dev/null +++ b/app/src/main/res/drawable/ic_statistics.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_statistics_selected.xml b/app/src/main/res/drawable/ic_statistics_selected.xml new file mode 100644 index 0000000..49b6fcd --- /dev/null +++ b/app/src/main/res/drawable/ic_statistics_selected.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/monitor_selector.xml b/app/src/main/res/drawable/monitor_selector.xml new file mode 100644 index 0000000..fe11e9a --- /dev/null +++ b/app/src/main/res/drawable/monitor_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/statistics_selector.xml b/app/src/main/res/drawable/statistics_selector.xml new file mode 100644 index 0000000..2156cff --- /dev/null +++ b/app/src/main/res/drawable/statistics_selector.xml @@ -0,0 +1,5 @@ + + + + + \ 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..78a4a94 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,27 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_monitor_record.xml b/app/src/main/res/layout/activity_monitor_record.xml new file mode 100644 index 0000000..77d9ef6 --- /dev/null +++ b/app/src/main/res/layout/activity_monitor_record.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_alarm.xml b/app/src/main/res/layout/fragment_alarm.xml new file mode 100644 index 0000000..77d9ef6 --- /dev/null +++ b/app/src/main/res/layout/fragment_alarm.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_monitor.xml b/app/src/main/res/layout/fragment_monitor.xml new file mode 100644 index 0000000..19789c1 --- /dev/null +++ b/app/src/main/res/layout/fragment_monitor.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_statistics.xml b/app/src/main/res/layout/fragment_statistics.xml new file mode 100644 index 0000000..77d9ef6 --- /dev/null +++ b/app/src/main/res/layout/fragment_statistics.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/menu/bottom_nav_menu.xml b/app/src/main/res/menu/bottom_nav_menu.xml new file mode 100644 index 0000000..751fd61 --- /dev/null +++ b/app/src/main/res/menu/bottom_nav_menu.xml @@ -0,0 +1,29 @@ + + + + + + + + + \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..10cfdbf --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*.iml +.gradle +/local.properties +/.idea +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..a4cd2ca --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,101 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'org.greenrobot.greendao' + +android { +// signingConfigs { +// release { +// storeFile file('/Users/a203/Desktop/AndroidProjects/CasicSmartWell/app/CasicSmartWell.jks') +// storePassword '123456789' +// keyAlias 'key0' +// keyPassword '123456789' +// } +// } + compileSdkVersion 31 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.smart.town.sanxi" + minSdkVersion 23 + targetSdkVersion 31 + versionCode 1 + versionName "1.0.0" + + manifestPlaceholders = [GETUI_APPID: "A9V4DvwLcdAqkFCQuFyhq6"] + } + + buildTypes { + release { + minifyEnabled false +// signingConfig signingConfigs.release + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + + ndk { abiFilters "armeabi", "armeabi-v7a", "arm64-v8" } + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlin { + experimental { + coroutines 'enable' + } + } + + greendao { + schemaVersion 1//数据库版本号 + targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 + daoPackage 'com.casic.smart.town.sanxi.greendao'//设置DaoMaster、DaoSession、Dao包名 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + //基础依赖库 + implementation files('libs/lite-release.aar') + implementation 'androidx.appcompat:appcompat:1.4.2' + implementation 'androidx.core:core-ktx:1.8.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:3.0.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' + //MVVM+LiveData + implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.1" + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0" + implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + //Kotlin协程 + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1' + //图片加载框架 + implementation 'com.github.bumptech.glide:glide:4.9.0' + //返回值转换器 + implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' + implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + //okhttp3日志拦截器 + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //网络请求和接口封装 + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.9.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.9.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' + //高德地图 + implementation 'com.amap.api:3dmap:latest.integration' + //推送SDK + implementation 'com.getui:gtsdk:3.2.10.0' //个推SDK + implementation 'com.getui:gtc:3.1.9.0' //个推核心组件 + //数据库框架 + implementation 'org.greenrobot:greendao:3.3.0' + //桌面角标 + implementation "me.leolin:ShortcutBadger:1.1.22@aar" +} \ No newline at end of file diff --git a/app/libs/lite-release.aar b/app/libs/lite-release.aar new file mode 100644 index 0000000..45da4df --- /dev/null +++ b/app/libs/lite-release.aar Binary files differ diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /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 \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..a83c28a --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/svg/monitor.svg b/app/src/main/assets/svg/monitor.svg new file mode 100644 index 0000000..c8d3e25 --- /dev/null +++ b/app/src/main/assets/svg/monitor.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/msg.svg b/app/src/main/assets/svg/msg.svg new file mode 100644 index 0000000..e864e48 --- /dev/null +++ b/app/src/main/assets/svg/msg.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/statistics.svg b/app/src/main/assets/svg/statistics.svg new file mode 100644 index 0000000..974000e --- /dev/null +++ b/app/src/main/assets/svg/statistics.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt new file mode 100644 index 0000000..6b9cce0 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.adapter + +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentManager +import androidx.fragment.app.FragmentPagerAdapter + +class ViewPagerAdapter(list: ArrayList, manager: FragmentManager) : + FragmentPagerAdapter(manager) { + + private var pageList: List = list + + override fun getItem(position: Int) = pageList[position] + + override fun getCount() = pageList.size +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt new file mode 100644 index 0000000..4e017b1 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt @@ -0,0 +1,40 @@ +package com.casic.smart.town.sanxi.base + +import android.app.Application +import android.util.Log +import com.casic.smart.town.sanxi.greendao.DaoMaster +import com.casic.smart.town.sanxi.greendao.DaoSession +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + private val kTag = "BaseApplication" + + companion object { + private var instance: BaseApplication by Delegates.notNull() + + fun obtainInstance() = instance + + private lateinit var daoSession: DaoSession + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences(this) + //推送 + PushManager.getInstance().initialize(this) + PushManager.getInstance().setDebugLogger(this) { + Log.d(kTag, it) + } + val devOpenHelper = DaoMaster.DevOpenHelper(this, "SmartTown.db", null) + val daoMaster = DaoMaster(devOpenHelper.writableDatabase) + daoSession = daoMaster.newSession() + } + + fun obtainDaoSession(): DaoSession { + return daoSession + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java new file mode 100644 index 0000000..b8f67dc --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java @@ -0,0 +1,133 @@ +package com.casic.smart.town.sanxi.bean; + +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Generated; +import org.greenrobot.greendao.annotation.Id; +import org.greenrobot.greendao.annotation.Unique; + +@Entity +public class AlarmMessageLocaleBean { + @Id(autoincrement = true) + private Long id;//主键自增 + + @Unique + private String messageId; + private String appId; + private String clientId; + private String taskId; + private String userId; + private String title; + private String content; + private String deviceCode; + private String isRead;//0-未读,1-已读 + private String alarmTime; + + @Generated(hash = 566950134) + public AlarmMessageLocaleBean(Long id, String messageId, String appId, + String clientId, String taskId, String userId, String title, + String content, String deviceCode, String isRead, String alarmTime) { + this.id = id; + this.messageId = messageId; + this.appId = appId; + this.clientId = clientId; + this.taskId = taskId; + this.userId = userId; + this.title = title; + this.content = content; + this.deviceCode = deviceCode; + this.isRead = isRead; + this.alarmTime = alarmTime; + } + + @Generated(hash = 1737519562) + public AlarmMessageLocaleBean() { + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getMessageId() { + return this.messageId; + } + + public void setMessageId(String messageId) { + this.messageId = messageId; + } + + public String getAppId() { + return this.appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public String getClientId() { + return this.clientId; + } + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public String getTaskId() { + return this.taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getUserId() { + return this.userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getTitle() { + return this.title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return this.content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getDeviceCode() { + return this.deviceCode; + } + + public void setDeviceCode(String deviceCode) { + this.deviceCode = deviceCode; + } + + public String getIsRead() { + return this.isRead; + } + + public void setIsRead(String isRead) { + this.isRead = isRead; + } + + public String getAlarmTime() { + return this.alarmTime; + } + + public void setAlarmTime(String alarmTime) { + this.alarmTime = alarmTime; + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt new file mode 100644 index 0000000..650e201 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class AlarmPageFragment: KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_alarm + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt new file mode 100644 index 0000000..deac8ac --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt @@ -0,0 +1,76 @@ +package com.casic.smart.town.sanxi.fragment + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.Fragment +import com.amap.api.maps.AMap +import com.amap.api.maps.AMapOptions +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.view.MonitorRecordActivity +import com.pengxh.kt.lite.extensions.navigatePageTo +import com.pengxh.kt.lite.extensions.show +import kotlinx.android.synthetic.main.fragment_monitor.view.* + +class MonitorPageFragment : Fragment() { + + private val kTag = "HomePageFragment" + private lateinit var monitorView: View + private lateinit var aMap: AMap + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? + ): View { + monitorView = inflater.inflate(R.layout.fragment_monitor, container, false) + //地图初始化 + initMap(savedInstanceState) + + monitorView.rightOperateView.setOnClickListener { + requireContext().navigatePageTo() + } + return monitorView + } + + private fun initMap(savedInstanceState: Bundle?) { + monitorView.mapView.onCreate(savedInstanceState) + aMap = monitorView.mapView.map + aMap.mapType = AMap.MAP_TYPE_NORMAL + val uiSettings = aMap.uiSettings + uiSettings.isCompassEnabled = true + uiSettings.zoomPosition = AMapOptions.ZOOM_POSITION_RIGHT_CENTER + uiSettings.isTiltGesturesEnabled = false//不许地图随手势倾斜角度 + + // 地图加载成功监听 +// aMap.addOnMapLoadedListener(this) + // 地图缩放监听 +// aMap.addOnCameraChangeListener(this) + // marker 点击事件监听 +// aMap.addOnMarkerClickListener(this) + // 点击marker弹出自定义popup +// aMap.setInfoWindowAdapter(this) + //信息窗点击事件 +// aMap.addOnInfoWindowClickListener(this) + } + + /***以下是地图生命周期管理************************************************************************/ + override fun onResume() { + super.onResume() + monitorView.mapView.onResume() + } + + override fun onPause() { + super.onPause() + monitorView.mapView.onPause() + } + + override fun onSaveInstanceState(outState: Bundle) { + super.onSaveInstanceState(outState) + monitorView.mapView.onSaveInstanceState(outState) + } + + override fun onDestroy() { + super.onDestroy() + monitorView.mapView.onDestroy() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt new file mode 100644 index 0000000..e84df12 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class StatisticsPageFragment : KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_statistics + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java new file mode 100644 index 0000000..68d7901 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java @@ -0,0 +1,255 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.database.Cursor; +import android.database.sqlite.SQLiteStatement; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.Property; +import org.greenrobot.greendao.internal.DaoConfig; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseStatement; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * DAO for table "ALARM_MESSAGE_LOCALE_BEAN". +*/ +public class AlarmMessageLocaleBeanDao extends AbstractDao { + + public static final String TABLENAME = "ALARM_MESSAGE_LOCALE_BEAN"; + + /** + * Properties of entity AlarmMessageLocaleBean.
+ * Can be used for QueryBuilder and for referencing column names. + */ + public static class Properties { + public final static Property Id = new Property(0, Long.class, "id", true, "_id"); + public final static Property MessageId = new Property(1, String.class, "messageId", false, "MESSAGE_ID"); + public final static Property AppId = new Property(2, String.class, "appId", false, "APP_ID"); + public final static Property ClientId = new Property(3, String.class, "clientId", false, "CLIENT_ID"); + public final static Property TaskId = new Property(4, String.class, "taskId", false, "TASK_ID"); + public final static Property UserId = new Property(5, String.class, "userId", false, "USER_ID"); + public final static Property Title = new Property(6, String.class, "title", false, "TITLE"); + public final static Property Content = new Property(7, String.class, "content", false, "CONTENT"); + public final static Property DeviceCode = new Property(8, String.class, "deviceCode", false, "DEVICE_CODE"); + public final static Property IsRead = new Property(9, String.class, "isRead", false, "IS_READ"); + public final static Property AlarmTime = new Property(10, String.class, "alarmTime", false, "ALARM_TIME"); + } + + + public AlarmMessageLocaleBeanDao(DaoConfig config) { + super(config); + } + + public AlarmMessageLocaleBeanDao(DaoConfig config, DaoSession daoSession) { + super(config, daoSession); + } + + /** Creates the underlying database table. */ + public static void createTable(Database db, boolean ifNotExists) { + String constraint = ifNotExists? "IF NOT EXISTS ": ""; + db.execSQL("CREATE TABLE " + constraint + "\"ALARM_MESSAGE_LOCALE_BEAN\" (" + // + "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id + "\"MESSAGE_ID\" TEXT UNIQUE ," + // 1: messageId + "\"APP_ID\" TEXT," + // 2: appId + "\"CLIENT_ID\" TEXT," + // 3: clientId + "\"TASK_ID\" TEXT," + // 4: taskId + "\"USER_ID\" TEXT," + // 5: userId + "\"TITLE\" TEXT," + // 6: title + "\"CONTENT\" TEXT," + // 7: content + "\"DEVICE_CODE\" TEXT," + // 8: deviceCode + "\"IS_READ\" TEXT," + // 9: isRead + "\"ALARM_TIME\" TEXT);"); // 10: alarmTime + } + + /** Drops the underlying database table. */ + public static void dropTable(Database db, boolean ifExists) { + String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"ALARM_MESSAGE_LOCALE_BEAN\""; + db.execSQL(sql); + } + + @Override + protected final void bindValues(DatabaseStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + protected final void bindValues(SQLiteStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + public Long readKey(Cursor cursor, int offset) { + return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); + } + + @Override + public AlarmMessageLocaleBean readEntity(Cursor cursor, int offset) { + AlarmMessageLocaleBean entity = new AlarmMessageLocaleBean( // + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // messageId + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // appId + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // clientId + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // taskId + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // userId + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // title + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // content + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // deviceCode + cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // isRead + cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10) // alarmTime + ); + return entity; + } + + @Override + public void readEntity(Cursor cursor, AlarmMessageLocaleBean entity, int offset) { + entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); + entity.setMessageId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setAppId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setClientId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setTaskId(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); + entity.setUserId(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setTitle(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setContent(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); + entity.setDeviceCode(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); + entity.setIsRead(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9)); + entity.setAlarmTime(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); + } + + @Override + protected final Long updateKeyAfterInsert(AlarmMessageLocaleBean entity, long rowId) { + entity.setId(rowId); + return rowId; + } + + @Override + public Long getKey(AlarmMessageLocaleBean entity) { + if(entity != null) { + return entity.getId(); + } else { + return null; + } + } + + @Override + public boolean hasKey(AlarmMessageLocaleBean entity) { + return entity.getId() != null; + } + + @Override + protected final boolean isEntityUpdateable() { + return true; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java new file mode 100644 index 0000000..4222c40 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java @@ -0,0 +1,96 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.content.Context; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteDatabase.CursorFactory; +import android.util.Log; + +import org.greenrobot.greendao.AbstractDaoMaster; +import org.greenrobot.greendao.database.StandardDatabase; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseOpenHelper; +import org.greenrobot.greendao.identityscope.IdentityScopeType; + + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * Master of DAO (schema version 1): knows all DAOs. + */ +public class DaoMaster extends AbstractDaoMaster { + public static final int SCHEMA_VERSION = 1; + + /** Creates underlying database table using DAOs. */ + public static void createAllTables(Database db, boolean ifNotExists) { + AlarmMessageLocaleBeanDao.createTable(db, ifNotExists); + } + + /** Drops underlying database table using DAOs. */ + public static void dropAllTables(Database db, boolean ifExists) { + AlarmMessageLocaleBeanDao.dropTable(db, ifExists); + } + + /** + * WARNING: Drops all table on Upgrade! Use only during development. + * Convenience method using a {@link DevOpenHelper}. + */ + public static DaoSession newDevSession(Context context, String name) { + Database db = new DevOpenHelper(context, name).getWritableDb(); + DaoMaster daoMaster = new DaoMaster(db); + return daoMaster.newSession(); + } + + public DaoMaster(SQLiteDatabase db) { + this(new StandardDatabase(db)); + } + + public DaoMaster(Database db) { + super(db, SCHEMA_VERSION); + registerDaoClass(AlarmMessageLocaleBeanDao.class); + } + + public DaoSession newSession() { + return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); + } + + public DaoSession newSession(IdentityScopeType type) { + return new DaoSession(db, type, daoConfigMap); + } + + /** + * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} - + */ + public static abstract class OpenHelper extends DatabaseOpenHelper { + public OpenHelper(Context context, String name) { + super(context, name, SCHEMA_VERSION); + } + + public OpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory, SCHEMA_VERSION); + } + + @Override + public void onCreate(Database db) { + Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); + createAllTables(db, false); + } + } + + /** WARNING: Drops all table on Upgrade! Use only during development. */ + public static class DevOpenHelper extends OpenHelper { + public DevOpenHelper(Context context, String name) { + super(context, name); + } + + public DevOpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory); + } + + @Override + public void onUpgrade(Database db, int oldVersion, int newVersion) { + Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); + dropAllTables(db, true); + onCreate(db); + } + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java new file mode 100644 index 0000000..480ed84 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java @@ -0,0 +1,48 @@ +package com.casic.smart.town.sanxi.greendao; + +import java.util.Map; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.AbstractDaoSession; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.identityscope.IdentityScopeType; +import org.greenrobot.greendao.internal.DaoConfig; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. + +/** + * {@inheritDoc} + * + * @see org.greenrobot.greendao.AbstractDaoSession + */ +public class DaoSession extends AbstractDaoSession { + + private final DaoConfig alarmMessageLocaleBeanDaoConfig; + + private final AlarmMessageLocaleBeanDao alarmMessageLocaleBeanDao; + + public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> + daoConfigMap) { + super(db); + + alarmMessageLocaleBeanDaoConfig = daoConfigMap.get(AlarmMessageLocaleBeanDao.class).clone(); + alarmMessageLocaleBeanDaoConfig.initIdentityScope(type); + + alarmMessageLocaleBeanDao = new AlarmMessageLocaleBeanDao(alarmMessageLocaleBeanDaoConfig, this); + + registerDao(AlarmMessageLocaleBean.class, alarmMessageLocaleBeanDao); + } + + public void clear() { + alarmMessageLocaleBeanDaoConfig.clearIdentityScope(); + } + + public AlarmMessageLocaleBeanDao getAlarmMessageLocaleBeanDao() { + return alarmMessageLocaleBeanDao; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt new file mode 100644 index 0000000..875cb8c --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt @@ -0,0 +1,5 @@ +package com.casic.smart.town.sanxi.service + +import com.igexin.sdk.PushService + +class ApplicationPushService : PushService() \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt new file mode 100644 index 0000000..396129f --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt @@ -0,0 +1,84 @@ +package com.casic.smart.town.sanxi.service + +import android.content.Context +import android.os.Message +import android.util.Log +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.casic.smart.town.sanxi.view.MainActivity +import com.igexin.sdk.GTIntentService +import com.igexin.sdk.message.GTCmdMessage +import com.igexin.sdk.message.GTNotificationMessage +import com.igexin.sdk.message.GTTransmitMessage +import com.pengxh.kt.lite.extensions.toJson + +class PushIntentService : GTIntentService() { + + private val kTag = "SmartWellIntentService" + + override fun onReceiveServicePid(context: Context?, pid: Int) { + + } + + // 透传消息 + override fun onReceiveMessageData(context: Context?, msg: GTTransmitMessage?) { + Log.d(kTag, "透传消息 -> msg = $msg") + } + + // 接收 cid + override fun onReceiveClientId(context: Context?, clientid: String?) { + Log.d(kTag, "onReceiveClientId -> $clientid") + //通知MainActivity注册个推服务 + val msg: Message = MainActivity.weakReferenceHandler.obtainMessage() + msg.what = LocaleConstant.PUSH_REGISTER + msg.obj = clientid + MainActivity.weakReferenceHandler.sendMessage(msg) + } + + // cid 离线上线通知 + override fun onReceiveOnlineState(context: Context?, online: Boolean) { + + } + + // 各种事件处理回执 + override fun onReceiveCommandResult(context: Context?, msg: GTCmdMessage?) { + + } + + // 通知到达 + override fun onNotificationMessageArrived(context: Context?, msg: GTNotificationMessage?) { + //报警 +// { +// "content": "设备编号[412022030361]发生井盖开盖报警", +// "messageId": "380abf9a79d34306a2683dc9bf96ee78", +// "taskId": "OSL-0830_4hmfimp3Vu684wo3SjXso9", +// "title": "告警提醒", +// "appid": "HKv8K9qARd6WckZ1o2Vbu4", +// "clientId": "e78beacc42e9a02ae6fb9087eb2b1171", +// "pkgName": "com.casic.app.smartwell" +// } + if (msg == null) { + return + } + Log.d(kTag, "通知到达 -> msg = ${msg.toJson()}") +// val userDetailJson = SaveKeyValues.getValue(LocaleConstant.USER_DETAIL_MODEL, "") as String +// var userId = "" +// if (userDetailJson.isNotBlank()) { +// val userDataModel = Gson().fromJson( +// userDetailJson, object : TypeToken() {}.type +// ) +// userId = userDataModel.id.toString() +// } +// //解析编号 +// val splitArray = msg.content.split("\\[|\\]".toRegex()) +// DataBaseManager.instance.insertNotice( +// msg.messageId, msg.appid, msg.clientId, msg.taskId, +// userId, msg.title, msg.content, splitArray[1], "0", +// System.currentTimeMillis().timestampToCompleteDate() +// ) + } + + // 通知点击 + override fun onNotificationMessageClicked(context: Context?, msg: GTNotificationMessage?) { + Log.d(kTag, "通知点击 -> msg = $msg") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt new file mode 100644 index 0000000..daa7c38 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt @@ -0,0 +1,14 @@ +package com.casic.smart.town.sanxi.util + +import android.content.Context +import me.leolin.shortcutbadger.ShortcutBadger + +object BadeHelper { + fun setBadgeNum(context: Context, badgeCount: Int) { + if (badgeCount == 0) { + ShortcutBadger.removeCount(context) + } else { + ShortcutBadger.applyCount(context, badgeCount) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt new file mode 100644 index 0000000..0a52ef2 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt @@ -0,0 +1,75 @@ +package com.casic.smart.town.sanxi.util + +import com.casic.smart.town.sanxi.base.BaseApplication +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao + +class DataBaseManager private constructor() { + + companion object { + //Kotlin委托模式双重锁单例 + val instance: DataBaseManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) { + DataBaseManager() + } + } + + private val beanDao = + BaseApplication.obtainInstance().obtainDaoSession().alarmMessageLocaleBeanDao + +// fun insertNotice( +// messageId: String, appid: String, clientId: String, +// taskId: String, userId: String, title: String, +// content: String, deviceCode: String, isRead: String, +// noticeTime: String +// ) { +// val noticeLocaleBean = NoticeLocaleBean() +// noticeLocaleBean.messageId = messageId +// noticeLocaleBean.appid = appid +// noticeLocaleBean.clientId = clientId +// noticeLocaleBean.taskId = taskId +// noticeLocaleBean.userId = userId +// noticeLocaleBean.title = title +// noticeLocaleBean.content = content +// noticeLocaleBean.deviceCode = deviceCode +// noticeLocaleBean.isRead = isRead +// noticeLocaleBean.noticeTime = noticeTime +// beanDao.insert(noticeLocaleBean) +// //角标设置 +// BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadNotice()) +// } + + fun deleteByMessageId(messageId: String) { + val result = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).list() + beanDao.deleteInTx(result) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun updateNoticeByMessageId(messageId: String) { + val noticeLocaleBean = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).unique() ?: return + noticeLocaleBean.isRead = "1" + beanDao.update(noticeLocaleBean) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun queryMessageByPage(userId: String, offset: Int): MutableList { + return BaseApplication.obtainInstance().obtainDaoSession() + .queryBuilder(AlarmMessageLocaleBean::class.java) + .where(AlarmMessageLocaleBeanDao.Properties.UserId.eq(userId)) + .offset(offset * LocaleConstant.PAGE_LIMIT) + .orderDesc(AlarmMessageLocaleBeanDao.Properties.AlarmTime) + .limit(LocaleConstant.PAGE_LIMIT) + .list() + } + + private fun queryUnReadMessage(): Int { + return beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.IsRead.eq("0") + ).list().size + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt new file mode 100644 index 0000000..52926a8 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt @@ -0,0 +1,31 @@ +package com.casic.smart.town.sanxi.util; + +import android.app.Activity +import android.view.WindowManager +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object LoadingDialogHub { + private lateinit var loadingDialog: QMUITipDialog + + fun show(activity: Activity, message: String) { + loadingDialog = QMUITipDialog + .Builder(activity) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_LOADING) + .setTipWord(message) + .create() + if (!activity.isDestroyed) { + try { + loadingDialog.show() + } catch (e: WindowManager.BadTokenException) { + e.printStackTrace() + } + } + } + + + fun dismiss() { + if (loadingDialog.isShowing) { + loadingDialog.dismiss() + } + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt new file mode 100644 index 0000000..de61c9a --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.util + +import android.Manifest + +object LocaleConstant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.READ_PHONE_STATE, + Manifest.permission.ACCESS_COARSE_LOCATION, + Manifest.permission.READ_EXTERNAL_STORAGE + ) + + const val PERMISSIONS_CODE = 999 + const val PUSH_REGISTER = 2022100101 + const val PAGE_LIMIT = 20 +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt new file mode 100644 index 0000000..3bea1c9 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt @@ -0,0 +1,112 @@ +package com.casic.smart.town.sanxi.view + +import android.view.KeyEvent +import android.view.MenuItem +import androidx.fragment.app.Fragment +import androidx.viewpager.widget.ViewPager +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.adapter.ViewPagerAdapter +import com.casic.smart.town.sanxi.fragment.AlarmPageFragment +import com.casic.smart.town.sanxi.fragment.MonitorPageFragment +import com.casic.smart.town.sanxi.fragment.StatisticsPageFragment +import com.gyf.immersionbar.ImmersionBar +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.base.KotlinBaseActivity +import com.pengxh.kt.lite.extensions.convertColor +import com.pengxh.kt.lite.extensions.show +import com.pengxh.kt.lite.utils.ImmerseStatusBarUtil +import com.pengxh.kt.lite.utils.WeakReferenceHandler +import kotlinx.android.synthetic.main.activity_main.* + +class MainActivity : KotlinBaseActivity() { + + companion object { + lateinit var weakReferenceHandler: WeakReferenceHandler + } + + private val kTag = "MainActivity" + private var menuItem: MenuItem? = null + private var fragmentPages: ArrayList = ArrayList() + private var clickTime: Long = 0 + + init { + fragmentPages.add(StatisticsPageFragment()) + fragmentPages.add(MonitorPageFragment()) + fragmentPages.add(AlarmPageFragment()) + } + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + ImmersionBar.with(this).statusBarDarkFont(false).init() + ImmerseStatusBarUtil.setColor(this, R.color.mainThemeColor.convertColor(this)) + } + + override fun initData() { + //推送,多次调用 SDK 初始化并无影响。 + PushManager.getInstance().initialize(this) + weakReferenceHandler = WeakReferenceHandler { + + true + } + } + + override fun observeRequestState() { + + } + + override fun initEvent() { + bottomNavigation.itemIconTintList = null + bottomNavigation.setOnNavigationItemSelectedListener { menuItem -> + when (menuItem.itemId) { + R.id.nav_statistics -> { + mainViewPager.currentItem = 0 + } + R.id.nav_monitor -> { + mainViewPager.currentItem = 1 + } + R.id.nav_alarm -> { + mainViewPager.currentItem = 2 + } + } + false + } + mainViewPager.adapter = ViewPagerAdapter(fragmentPages, supportFragmentManager) + mainViewPager.offscreenPageLimit = fragmentPages.size //缓存页数 + mainViewPager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener { + override fun onPageScrollStateChanged(state: Int) { + + } + + override fun onPageScrolled( + position: Int, + positionOffset: Float, + positionOffsetPixels: Int + ) { + + } + + override fun onPageSelected(position: Int) { + if (menuItem != null) { + menuItem!!.isChecked = false + } else { + bottomNavigation.menu.getItem(0).isChecked = false + } + menuItem = bottomNavigation.menu.getItem(position) + menuItem!!.isChecked = true + } + }) + } + + override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean { + return if (keyCode == KeyEvent.KEYCODE_BACK) { + if (System.currentTimeMillis() - clickTime > 2000) { + "再按一次退出程序".show(this) + clickTime = System.currentTimeMillis() + true + } else { + super.onKeyDown(keyCode, event) + } + } else super.onKeyDown(keyCode, event) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt new file mode 100644 index 0000000..c5d8b22 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.view + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseActivity + +class MonitorRecordActivity : KotlinBaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_monitor_record + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt new file mode 100644 index 0000000..c478d83 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt @@ -0,0 +1,55 @@ +package com.casic.smart.town.sanxi.view + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.amap.api.maps.MapsInitializer +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.gyf.immersionbar.ImmersionBar +import com.pengxh.kt.lite.extensions.navigatePageTo +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + ImmersionBar.with(this).statusBarDarkFont(true).init() + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (EasyPermissions.hasPermissions(this, *LocaleConstant.USER_PERMISSIONS)) { + startSplashScreenActivity() + } else { + EasyPermissions.requestPermissions( + this@PermissionActivity, + resources.getString(R.string.app_name) + "需要获取相关权限", + LocaleConstant.PERMISSIONS_CODE, + *LocaleConstant.USER_PERMISSIONS + ) + } + } + + private fun startSplashScreenActivity() { + //先把导航隐私政策声明,后面导航会用到 + MapsInitializer.updatePrivacyAgree(this, true) + MapsInitializer.updatePrivacyShow(this, true, true) + this.navigatePageTo() + 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) { + startSplashScreenActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable/alarm_selector.xml b/app/src/main/res/drawable/alarm_selector.xml new file mode 100644 index 0000000..39b2595 --- /dev/null +++ b/app/src/main/res/drawable/alarm_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bottom_text_color.xml b/app/src/main/res/drawable/bottom_text_color.xml new file mode 100644 index 0000000..b284ea3 --- /dev/null +++ b/app/src/main/res/drawable/bottom_text_color.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_alarm.xml b/app/src/main/res/drawable/ic_alarm.xml new file mode 100644 index 0000000..dc33aab --- /dev/null +++ b/app/src/main/res/drawable/ic_alarm.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_alarm_selected.xml b/app/src/main/res/drawable/ic_alarm_selected.xml new file mode 100644 index 0000000..993fea6 --- /dev/null +++ b/app/src/main/res/drawable/ic_alarm_selected.xml @@ -0,0 +1,9 @@ + + + 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_monitor.xml b/app/src/main/res/drawable/ic_monitor.xml new file mode 100644 index 0000000..271f5b4 --- /dev/null +++ b/app/src/main/res/drawable/ic_monitor.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_monitor_selected.xml b/app/src/main/res/drawable/ic_monitor_selected.xml new file mode 100644 index 0000000..ee62d84 --- /dev/null +++ b/app/src/main/res/drawable/ic_monitor_selected.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_statistics.xml b/app/src/main/res/drawable/ic_statistics.xml new file mode 100644 index 0000000..7fde8ec --- /dev/null +++ b/app/src/main/res/drawable/ic_statistics.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_statistics_selected.xml b/app/src/main/res/drawable/ic_statistics_selected.xml new file mode 100644 index 0000000..49b6fcd --- /dev/null +++ b/app/src/main/res/drawable/ic_statistics_selected.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/monitor_selector.xml b/app/src/main/res/drawable/monitor_selector.xml new file mode 100644 index 0000000..fe11e9a --- /dev/null +++ b/app/src/main/res/drawable/monitor_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/statistics_selector.xml b/app/src/main/res/drawable/statistics_selector.xml new file mode 100644 index 0000000..2156cff --- /dev/null +++ b/app/src/main/res/drawable/statistics_selector.xml @@ -0,0 +1,5 @@ + + + + + \ 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..78a4a94 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,27 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_monitor_record.xml b/app/src/main/res/layout/activity_monitor_record.xml new file mode 100644 index 0000000..77d9ef6 --- /dev/null +++ b/app/src/main/res/layout/activity_monitor_record.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_alarm.xml b/app/src/main/res/layout/fragment_alarm.xml new file mode 100644 index 0000000..77d9ef6 --- /dev/null +++ b/app/src/main/res/layout/fragment_alarm.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_monitor.xml b/app/src/main/res/layout/fragment_monitor.xml new file mode 100644 index 0000000..19789c1 --- /dev/null +++ b/app/src/main/res/layout/fragment_monitor.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_statistics.xml b/app/src/main/res/layout/fragment_statistics.xml new file mode 100644 index 0000000..77d9ef6 --- /dev/null +++ b/app/src/main/res/layout/fragment_statistics.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/menu/bottom_nav_menu.xml b/app/src/main/res/menu/bottom_nav_menu.xml new file mode 100644 index 0000000..751fd61 --- /dev/null +++ b/app/src/main/res/menu/bottom_nav_menu.xml @@ -0,0 +1,29 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.webp b/app/src/main/res/mipmap-hdpi/ic_launcher.webp new file mode 100644 index 0000000..c209e78 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher.webp Binary files differ diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..10cfdbf --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*.iml +.gradle +/local.properties +/.idea +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..a4cd2ca --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,101 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'org.greenrobot.greendao' + +android { +// signingConfigs { +// release { +// storeFile file('/Users/a203/Desktop/AndroidProjects/CasicSmartWell/app/CasicSmartWell.jks') +// storePassword '123456789' +// keyAlias 'key0' +// keyPassword '123456789' +// } +// } + compileSdkVersion 31 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.smart.town.sanxi" + minSdkVersion 23 + targetSdkVersion 31 + versionCode 1 + versionName "1.0.0" + + manifestPlaceholders = [GETUI_APPID: "A9V4DvwLcdAqkFCQuFyhq6"] + } + + buildTypes { + release { + minifyEnabled false +// signingConfig signingConfigs.release + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + + ndk { abiFilters "armeabi", "armeabi-v7a", "arm64-v8" } + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlin { + experimental { + coroutines 'enable' + } + } + + greendao { + schemaVersion 1//数据库版本号 + targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 + daoPackage 'com.casic.smart.town.sanxi.greendao'//设置DaoMaster、DaoSession、Dao包名 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + //基础依赖库 + implementation files('libs/lite-release.aar') + implementation 'androidx.appcompat:appcompat:1.4.2' + implementation 'androidx.core:core-ktx:1.8.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:3.0.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' + //MVVM+LiveData + implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.1" + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0" + implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + //Kotlin协程 + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1' + //图片加载框架 + implementation 'com.github.bumptech.glide:glide:4.9.0' + //返回值转换器 + implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' + implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + //okhttp3日志拦截器 + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //网络请求和接口封装 + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.9.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.9.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' + //高德地图 + implementation 'com.amap.api:3dmap:latest.integration' + //推送SDK + implementation 'com.getui:gtsdk:3.2.10.0' //个推SDK + implementation 'com.getui:gtc:3.1.9.0' //个推核心组件 + //数据库框架 + implementation 'org.greenrobot:greendao:3.3.0' + //桌面角标 + implementation "me.leolin:ShortcutBadger:1.1.22@aar" +} \ No newline at end of file diff --git a/app/libs/lite-release.aar b/app/libs/lite-release.aar new file mode 100644 index 0000000..45da4df --- /dev/null +++ b/app/libs/lite-release.aar Binary files differ diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /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 \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..a83c28a --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/svg/monitor.svg b/app/src/main/assets/svg/monitor.svg new file mode 100644 index 0000000..c8d3e25 --- /dev/null +++ b/app/src/main/assets/svg/monitor.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/msg.svg b/app/src/main/assets/svg/msg.svg new file mode 100644 index 0000000..e864e48 --- /dev/null +++ b/app/src/main/assets/svg/msg.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/statistics.svg b/app/src/main/assets/svg/statistics.svg new file mode 100644 index 0000000..974000e --- /dev/null +++ b/app/src/main/assets/svg/statistics.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt new file mode 100644 index 0000000..6b9cce0 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.adapter + +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentManager +import androidx.fragment.app.FragmentPagerAdapter + +class ViewPagerAdapter(list: ArrayList, manager: FragmentManager) : + FragmentPagerAdapter(manager) { + + private var pageList: List = list + + override fun getItem(position: Int) = pageList[position] + + override fun getCount() = pageList.size +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt new file mode 100644 index 0000000..4e017b1 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt @@ -0,0 +1,40 @@ +package com.casic.smart.town.sanxi.base + +import android.app.Application +import android.util.Log +import com.casic.smart.town.sanxi.greendao.DaoMaster +import com.casic.smart.town.sanxi.greendao.DaoSession +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + private val kTag = "BaseApplication" + + companion object { + private var instance: BaseApplication by Delegates.notNull() + + fun obtainInstance() = instance + + private lateinit var daoSession: DaoSession + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences(this) + //推送 + PushManager.getInstance().initialize(this) + PushManager.getInstance().setDebugLogger(this) { + Log.d(kTag, it) + } + val devOpenHelper = DaoMaster.DevOpenHelper(this, "SmartTown.db", null) + val daoMaster = DaoMaster(devOpenHelper.writableDatabase) + daoSession = daoMaster.newSession() + } + + fun obtainDaoSession(): DaoSession { + return daoSession + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java new file mode 100644 index 0000000..b8f67dc --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java @@ -0,0 +1,133 @@ +package com.casic.smart.town.sanxi.bean; + +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Generated; +import org.greenrobot.greendao.annotation.Id; +import org.greenrobot.greendao.annotation.Unique; + +@Entity +public class AlarmMessageLocaleBean { + @Id(autoincrement = true) + private Long id;//主键自增 + + @Unique + private String messageId; + private String appId; + private String clientId; + private String taskId; + private String userId; + private String title; + private String content; + private String deviceCode; + private String isRead;//0-未读,1-已读 + private String alarmTime; + + @Generated(hash = 566950134) + public AlarmMessageLocaleBean(Long id, String messageId, String appId, + String clientId, String taskId, String userId, String title, + String content, String deviceCode, String isRead, String alarmTime) { + this.id = id; + this.messageId = messageId; + this.appId = appId; + this.clientId = clientId; + this.taskId = taskId; + this.userId = userId; + this.title = title; + this.content = content; + this.deviceCode = deviceCode; + this.isRead = isRead; + this.alarmTime = alarmTime; + } + + @Generated(hash = 1737519562) + public AlarmMessageLocaleBean() { + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getMessageId() { + return this.messageId; + } + + public void setMessageId(String messageId) { + this.messageId = messageId; + } + + public String getAppId() { + return this.appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public String getClientId() { + return this.clientId; + } + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public String getTaskId() { + return this.taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getUserId() { + return this.userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getTitle() { + return this.title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return this.content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getDeviceCode() { + return this.deviceCode; + } + + public void setDeviceCode(String deviceCode) { + this.deviceCode = deviceCode; + } + + public String getIsRead() { + return this.isRead; + } + + public void setIsRead(String isRead) { + this.isRead = isRead; + } + + public String getAlarmTime() { + return this.alarmTime; + } + + public void setAlarmTime(String alarmTime) { + this.alarmTime = alarmTime; + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt new file mode 100644 index 0000000..650e201 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class AlarmPageFragment: KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_alarm + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt new file mode 100644 index 0000000..deac8ac --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt @@ -0,0 +1,76 @@ +package com.casic.smart.town.sanxi.fragment + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.Fragment +import com.amap.api.maps.AMap +import com.amap.api.maps.AMapOptions +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.view.MonitorRecordActivity +import com.pengxh.kt.lite.extensions.navigatePageTo +import com.pengxh.kt.lite.extensions.show +import kotlinx.android.synthetic.main.fragment_monitor.view.* + +class MonitorPageFragment : Fragment() { + + private val kTag = "HomePageFragment" + private lateinit var monitorView: View + private lateinit var aMap: AMap + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? + ): View { + monitorView = inflater.inflate(R.layout.fragment_monitor, container, false) + //地图初始化 + initMap(savedInstanceState) + + monitorView.rightOperateView.setOnClickListener { + requireContext().navigatePageTo() + } + return monitorView + } + + private fun initMap(savedInstanceState: Bundle?) { + monitorView.mapView.onCreate(savedInstanceState) + aMap = monitorView.mapView.map + aMap.mapType = AMap.MAP_TYPE_NORMAL + val uiSettings = aMap.uiSettings + uiSettings.isCompassEnabled = true + uiSettings.zoomPosition = AMapOptions.ZOOM_POSITION_RIGHT_CENTER + uiSettings.isTiltGesturesEnabled = false//不许地图随手势倾斜角度 + + // 地图加载成功监听 +// aMap.addOnMapLoadedListener(this) + // 地图缩放监听 +// aMap.addOnCameraChangeListener(this) + // marker 点击事件监听 +// aMap.addOnMarkerClickListener(this) + // 点击marker弹出自定义popup +// aMap.setInfoWindowAdapter(this) + //信息窗点击事件 +// aMap.addOnInfoWindowClickListener(this) + } + + /***以下是地图生命周期管理************************************************************************/ + override fun onResume() { + super.onResume() + monitorView.mapView.onResume() + } + + override fun onPause() { + super.onPause() + monitorView.mapView.onPause() + } + + override fun onSaveInstanceState(outState: Bundle) { + super.onSaveInstanceState(outState) + monitorView.mapView.onSaveInstanceState(outState) + } + + override fun onDestroy() { + super.onDestroy() + monitorView.mapView.onDestroy() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt new file mode 100644 index 0000000..e84df12 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class StatisticsPageFragment : KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_statistics + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java new file mode 100644 index 0000000..68d7901 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java @@ -0,0 +1,255 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.database.Cursor; +import android.database.sqlite.SQLiteStatement; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.Property; +import org.greenrobot.greendao.internal.DaoConfig; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseStatement; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * DAO for table "ALARM_MESSAGE_LOCALE_BEAN". +*/ +public class AlarmMessageLocaleBeanDao extends AbstractDao { + + public static final String TABLENAME = "ALARM_MESSAGE_LOCALE_BEAN"; + + /** + * Properties of entity AlarmMessageLocaleBean.
+ * Can be used for QueryBuilder and for referencing column names. + */ + public static class Properties { + public final static Property Id = new Property(0, Long.class, "id", true, "_id"); + public final static Property MessageId = new Property(1, String.class, "messageId", false, "MESSAGE_ID"); + public final static Property AppId = new Property(2, String.class, "appId", false, "APP_ID"); + public final static Property ClientId = new Property(3, String.class, "clientId", false, "CLIENT_ID"); + public final static Property TaskId = new Property(4, String.class, "taskId", false, "TASK_ID"); + public final static Property UserId = new Property(5, String.class, "userId", false, "USER_ID"); + public final static Property Title = new Property(6, String.class, "title", false, "TITLE"); + public final static Property Content = new Property(7, String.class, "content", false, "CONTENT"); + public final static Property DeviceCode = new Property(8, String.class, "deviceCode", false, "DEVICE_CODE"); + public final static Property IsRead = new Property(9, String.class, "isRead", false, "IS_READ"); + public final static Property AlarmTime = new Property(10, String.class, "alarmTime", false, "ALARM_TIME"); + } + + + public AlarmMessageLocaleBeanDao(DaoConfig config) { + super(config); + } + + public AlarmMessageLocaleBeanDao(DaoConfig config, DaoSession daoSession) { + super(config, daoSession); + } + + /** Creates the underlying database table. */ + public static void createTable(Database db, boolean ifNotExists) { + String constraint = ifNotExists? "IF NOT EXISTS ": ""; + db.execSQL("CREATE TABLE " + constraint + "\"ALARM_MESSAGE_LOCALE_BEAN\" (" + // + "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id + "\"MESSAGE_ID\" TEXT UNIQUE ," + // 1: messageId + "\"APP_ID\" TEXT," + // 2: appId + "\"CLIENT_ID\" TEXT," + // 3: clientId + "\"TASK_ID\" TEXT," + // 4: taskId + "\"USER_ID\" TEXT," + // 5: userId + "\"TITLE\" TEXT," + // 6: title + "\"CONTENT\" TEXT," + // 7: content + "\"DEVICE_CODE\" TEXT," + // 8: deviceCode + "\"IS_READ\" TEXT," + // 9: isRead + "\"ALARM_TIME\" TEXT);"); // 10: alarmTime + } + + /** Drops the underlying database table. */ + public static void dropTable(Database db, boolean ifExists) { + String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"ALARM_MESSAGE_LOCALE_BEAN\""; + db.execSQL(sql); + } + + @Override + protected final void bindValues(DatabaseStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + protected final void bindValues(SQLiteStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + public Long readKey(Cursor cursor, int offset) { + return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); + } + + @Override + public AlarmMessageLocaleBean readEntity(Cursor cursor, int offset) { + AlarmMessageLocaleBean entity = new AlarmMessageLocaleBean( // + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // messageId + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // appId + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // clientId + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // taskId + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // userId + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // title + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // content + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // deviceCode + cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // isRead + cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10) // alarmTime + ); + return entity; + } + + @Override + public void readEntity(Cursor cursor, AlarmMessageLocaleBean entity, int offset) { + entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); + entity.setMessageId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setAppId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setClientId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setTaskId(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); + entity.setUserId(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setTitle(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setContent(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); + entity.setDeviceCode(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); + entity.setIsRead(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9)); + entity.setAlarmTime(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); + } + + @Override + protected final Long updateKeyAfterInsert(AlarmMessageLocaleBean entity, long rowId) { + entity.setId(rowId); + return rowId; + } + + @Override + public Long getKey(AlarmMessageLocaleBean entity) { + if(entity != null) { + return entity.getId(); + } else { + return null; + } + } + + @Override + public boolean hasKey(AlarmMessageLocaleBean entity) { + return entity.getId() != null; + } + + @Override + protected final boolean isEntityUpdateable() { + return true; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java new file mode 100644 index 0000000..4222c40 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java @@ -0,0 +1,96 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.content.Context; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteDatabase.CursorFactory; +import android.util.Log; + +import org.greenrobot.greendao.AbstractDaoMaster; +import org.greenrobot.greendao.database.StandardDatabase; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseOpenHelper; +import org.greenrobot.greendao.identityscope.IdentityScopeType; + + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * Master of DAO (schema version 1): knows all DAOs. + */ +public class DaoMaster extends AbstractDaoMaster { + public static final int SCHEMA_VERSION = 1; + + /** Creates underlying database table using DAOs. */ + public static void createAllTables(Database db, boolean ifNotExists) { + AlarmMessageLocaleBeanDao.createTable(db, ifNotExists); + } + + /** Drops underlying database table using DAOs. */ + public static void dropAllTables(Database db, boolean ifExists) { + AlarmMessageLocaleBeanDao.dropTable(db, ifExists); + } + + /** + * WARNING: Drops all table on Upgrade! Use only during development. + * Convenience method using a {@link DevOpenHelper}. + */ + public static DaoSession newDevSession(Context context, String name) { + Database db = new DevOpenHelper(context, name).getWritableDb(); + DaoMaster daoMaster = new DaoMaster(db); + return daoMaster.newSession(); + } + + public DaoMaster(SQLiteDatabase db) { + this(new StandardDatabase(db)); + } + + public DaoMaster(Database db) { + super(db, SCHEMA_VERSION); + registerDaoClass(AlarmMessageLocaleBeanDao.class); + } + + public DaoSession newSession() { + return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); + } + + public DaoSession newSession(IdentityScopeType type) { + return new DaoSession(db, type, daoConfigMap); + } + + /** + * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} - + */ + public static abstract class OpenHelper extends DatabaseOpenHelper { + public OpenHelper(Context context, String name) { + super(context, name, SCHEMA_VERSION); + } + + public OpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory, SCHEMA_VERSION); + } + + @Override + public void onCreate(Database db) { + Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); + createAllTables(db, false); + } + } + + /** WARNING: Drops all table on Upgrade! Use only during development. */ + public static class DevOpenHelper extends OpenHelper { + public DevOpenHelper(Context context, String name) { + super(context, name); + } + + public DevOpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory); + } + + @Override + public void onUpgrade(Database db, int oldVersion, int newVersion) { + Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); + dropAllTables(db, true); + onCreate(db); + } + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java new file mode 100644 index 0000000..480ed84 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java @@ -0,0 +1,48 @@ +package com.casic.smart.town.sanxi.greendao; + +import java.util.Map; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.AbstractDaoSession; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.identityscope.IdentityScopeType; +import org.greenrobot.greendao.internal.DaoConfig; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. + +/** + * {@inheritDoc} + * + * @see org.greenrobot.greendao.AbstractDaoSession + */ +public class DaoSession extends AbstractDaoSession { + + private final DaoConfig alarmMessageLocaleBeanDaoConfig; + + private final AlarmMessageLocaleBeanDao alarmMessageLocaleBeanDao; + + public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> + daoConfigMap) { + super(db); + + alarmMessageLocaleBeanDaoConfig = daoConfigMap.get(AlarmMessageLocaleBeanDao.class).clone(); + alarmMessageLocaleBeanDaoConfig.initIdentityScope(type); + + alarmMessageLocaleBeanDao = new AlarmMessageLocaleBeanDao(alarmMessageLocaleBeanDaoConfig, this); + + registerDao(AlarmMessageLocaleBean.class, alarmMessageLocaleBeanDao); + } + + public void clear() { + alarmMessageLocaleBeanDaoConfig.clearIdentityScope(); + } + + public AlarmMessageLocaleBeanDao getAlarmMessageLocaleBeanDao() { + return alarmMessageLocaleBeanDao; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt new file mode 100644 index 0000000..875cb8c --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt @@ -0,0 +1,5 @@ +package com.casic.smart.town.sanxi.service + +import com.igexin.sdk.PushService + +class ApplicationPushService : PushService() \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt new file mode 100644 index 0000000..396129f --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt @@ -0,0 +1,84 @@ +package com.casic.smart.town.sanxi.service + +import android.content.Context +import android.os.Message +import android.util.Log +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.casic.smart.town.sanxi.view.MainActivity +import com.igexin.sdk.GTIntentService +import com.igexin.sdk.message.GTCmdMessage +import com.igexin.sdk.message.GTNotificationMessage +import com.igexin.sdk.message.GTTransmitMessage +import com.pengxh.kt.lite.extensions.toJson + +class PushIntentService : GTIntentService() { + + private val kTag = "SmartWellIntentService" + + override fun onReceiveServicePid(context: Context?, pid: Int) { + + } + + // 透传消息 + override fun onReceiveMessageData(context: Context?, msg: GTTransmitMessage?) { + Log.d(kTag, "透传消息 -> msg = $msg") + } + + // 接收 cid + override fun onReceiveClientId(context: Context?, clientid: String?) { + Log.d(kTag, "onReceiveClientId -> $clientid") + //通知MainActivity注册个推服务 + val msg: Message = MainActivity.weakReferenceHandler.obtainMessage() + msg.what = LocaleConstant.PUSH_REGISTER + msg.obj = clientid + MainActivity.weakReferenceHandler.sendMessage(msg) + } + + // cid 离线上线通知 + override fun onReceiveOnlineState(context: Context?, online: Boolean) { + + } + + // 各种事件处理回执 + override fun onReceiveCommandResult(context: Context?, msg: GTCmdMessage?) { + + } + + // 通知到达 + override fun onNotificationMessageArrived(context: Context?, msg: GTNotificationMessage?) { + //报警 +// { +// "content": "设备编号[412022030361]发生井盖开盖报警", +// "messageId": "380abf9a79d34306a2683dc9bf96ee78", +// "taskId": "OSL-0830_4hmfimp3Vu684wo3SjXso9", +// "title": "告警提醒", +// "appid": "HKv8K9qARd6WckZ1o2Vbu4", +// "clientId": "e78beacc42e9a02ae6fb9087eb2b1171", +// "pkgName": "com.casic.app.smartwell" +// } + if (msg == null) { + return + } + Log.d(kTag, "通知到达 -> msg = ${msg.toJson()}") +// val userDetailJson = SaveKeyValues.getValue(LocaleConstant.USER_DETAIL_MODEL, "") as String +// var userId = "" +// if (userDetailJson.isNotBlank()) { +// val userDataModel = Gson().fromJson( +// userDetailJson, object : TypeToken() {}.type +// ) +// userId = userDataModel.id.toString() +// } +// //解析编号 +// val splitArray = msg.content.split("\\[|\\]".toRegex()) +// DataBaseManager.instance.insertNotice( +// msg.messageId, msg.appid, msg.clientId, msg.taskId, +// userId, msg.title, msg.content, splitArray[1], "0", +// System.currentTimeMillis().timestampToCompleteDate() +// ) + } + + // 通知点击 + override fun onNotificationMessageClicked(context: Context?, msg: GTNotificationMessage?) { + Log.d(kTag, "通知点击 -> msg = $msg") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt new file mode 100644 index 0000000..daa7c38 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt @@ -0,0 +1,14 @@ +package com.casic.smart.town.sanxi.util + +import android.content.Context +import me.leolin.shortcutbadger.ShortcutBadger + +object BadeHelper { + fun setBadgeNum(context: Context, badgeCount: Int) { + if (badgeCount == 0) { + ShortcutBadger.removeCount(context) + } else { + ShortcutBadger.applyCount(context, badgeCount) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt new file mode 100644 index 0000000..0a52ef2 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt @@ -0,0 +1,75 @@ +package com.casic.smart.town.sanxi.util + +import com.casic.smart.town.sanxi.base.BaseApplication +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao + +class DataBaseManager private constructor() { + + companion object { + //Kotlin委托模式双重锁单例 + val instance: DataBaseManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) { + DataBaseManager() + } + } + + private val beanDao = + BaseApplication.obtainInstance().obtainDaoSession().alarmMessageLocaleBeanDao + +// fun insertNotice( +// messageId: String, appid: String, clientId: String, +// taskId: String, userId: String, title: String, +// content: String, deviceCode: String, isRead: String, +// noticeTime: String +// ) { +// val noticeLocaleBean = NoticeLocaleBean() +// noticeLocaleBean.messageId = messageId +// noticeLocaleBean.appid = appid +// noticeLocaleBean.clientId = clientId +// noticeLocaleBean.taskId = taskId +// noticeLocaleBean.userId = userId +// noticeLocaleBean.title = title +// noticeLocaleBean.content = content +// noticeLocaleBean.deviceCode = deviceCode +// noticeLocaleBean.isRead = isRead +// noticeLocaleBean.noticeTime = noticeTime +// beanDao.insert(noticeLocaleBean) +// //角标设置 +// BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadNotice()) +// } + + fun deleteByMessageId(messageId: String) { + val result = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).list() + beanDao.deleteInTx(result) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun updateNoticeByMessageId(messageId: String) { + val noticeLocaleBean = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).unique() ?: return + noticeLocaleBean.isRead = "1" + beanDao.update(noticeLocaleBean) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun queryMessageByPage(userId: String, offset: Int): MutableList { + return BaseApplication.obtainInstance().obtainDaoSession() + .queryBuilder(AlarmMessageLocaleBean::class.java) + .where(AlarmMessageLocaleBeanDao.Properties.UserId.eq(userId)) + .offset(offset * LocaleConstant.PAGE_LIMIT) + .orderDesc(AlarmMessageLocaleBeanDao.Properties.AlarmTime) + .limit(LocaleConstant.PAGE_LIMIT) + .list() + } + + private fun queryUnReadMessage(): Int { + return beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.IsRead.eq("0") + ).list().size + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt new file mode 100644 index 0000000..52926a8 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt @@ -0,0 +1,31 @@ +package com.casic.smart.town.sanxi.util; + +import android.app.Activity +import android.view.WindowManager +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object LoadingDialogHub { + private lateinit var loadingDialog: QMUITipDialog + + fun show(activity: Activity, message: String) { + loadingDialog = QMUITipDialog + .Builder(activity) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_LOADING) + .setTipWord(message) + .create() + if (!activity.isDestroyed) { + try { + loadingDialog.show() + } catch (e: WindowManager.BadTokenException) { + e.printStackTrace() + } + } + } + + + fun dismiss() { + if (loadingDialog.isShowing) { + loadingDialog.dismiss() + } + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt new file mode 100644 index 0000000..de61c9a --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.util + +import android.Manifest + +object LocaleConstant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.READ_PHONE_STATE, + Manifest.permission.ACCESS_COARSE_LOCATION, + Manifest.permission.READ_EXTERNAL_STORAGE + ) + + const val PERMISSIONS_CODE = 999 + const val PUSH_REGISTER = 2022100101 + const val PAGE_LIMIT = 20 +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt new file mode 100644 index 0000000..3bea1c9 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt @@ -0,0 +1,112 @@ +package com.casic.smart.town.sanxi.view + +import android.view.KeyEvent +import android.view.MenuItem +import androidx.fragment.app.Fragment +import androidx.viewpager.widget.ViewPager +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.adapter.ViewPagerAdapter +import com.casic.smart.town.sanxi.fragment.AlarmPageFragment +import com.casic.smart.town.sanxi.fragment.MonitorPageFragment +import com.casic.smart.town.sanxi.fragment.StatisticsPageFragment +import com.gyf.immersionbar.ImmersionBar +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.base.KotlinBaseActivity +import com.pengxh.kt.lite.extensions.convertColor +import com.pengxh.kt.lite.extensions.show +import com.pengxh.kt.lite.utils.ImmerseStatusBarUtil +import com.pengxh.kt.lite.utils.WeakReferenceHandler +import kotlinx.android.synthetic.main.activity_main.* + +class MainActivity : KotlinBaseActivity() { + + companion object { + lateinit var weakReferenceHandler: WeakReferenceHandler + } + + private val kTag = "MainActivity" + private var menuItem: MenuItem? = null + private var fragmentPages: ArrayList = ArrayList() + private var clickTime: Long = 0 + + init { + fragmentPages.add(StatisticsPageFragment()) + fragmentPages.add(MonitorPageFragment()) + fragmentPages.add(AlarmPageFragment()) + } + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + ImmersionBar.with(this).statusBarDarkFont(false).init() + ImmerseStatusBarUtil.setColor(this, R.color.mainThemeColor.convertColor(this)) + } + + override fun initData() { + //推送,多次调用 SDK 初始化并无影响。 + PushManager.getInstance().initialize(this) + weakReferenceHandler = WeakReferenceHandler { + + true + } + } + + override fun observeRequestState() { + + } + + override fun initEvent() { + bottomNavigation.itemIconTintList = null + bottomNavigation.setOnNavigationItemSelectedListener { menuItem -> + when (menuItem.itemId) { + R.id.nav_statistics -> { + mainViewPager.currentItem = 0 + } + R.id.nav_monitor -> { + mainViewPager.currentItem = 1 + } + R.id.nav_alarm -> { + mainViewPager.currentItem = 2 + } + } + false + } + mainViewPager.adapter = ViewPagerAdapter(fragmentPages, supportFragmentManager) + mainViewPager.offscreenPageLimit = fragmentPages.size //缓存页数 + mainViewPager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener { + override fun onPageScrollStateChanged(state: Int) { + + } + + override fun onPageScrolled( + position: Int, + positionOffset: Float, + positionOffsetPixels: Int + ) { + + } + + override fun onPageSelected(position: Int) { + if (menuItem != null) { + menuItem!!.isChecked = false + } else { + bottomNavigation.menu.getItem(0).isChecked = false + } + menuItem = bottomNavigation.menu.getItem(position) + menuItem!!.isChecked = true + } + }) + } + + override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean { + return if (keyCode == KeyEvent.KEYCODE_BACK) { + if (System.currentTimeMillis() - clickTime > 2000) { + "再按一次退出程序".show(this) + clickTime = System.currentTimeMillis() + true + } else { + super.onKeyDown(keyCode, event) + } + } else super.onKeyDown(keyCode, event) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt new file mode 100644 index 0000000..c5d8b22 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.view + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseActivity + +class MonitorRecordActivity : KotlinBaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_monitor_record + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt new file mode 100644 index 0000000..c478d83 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt @@ -0,0 +1,55 @@ +package com.casic.smart.town.sanxi.view + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.amap.api.maps.MapsInitializer +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.gyf.immersionbar.ImmersionBar +import com.pengxh.kt.lite.extensions.navigatePageTo +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + ImmersionBar.with(this).statusBarDarkFont(true).init() + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (EasyPermissions.hasPermissions(this, *LocaleConstant.USER_PERMISSIONS)) { + startSplashScreenActivity() + } else { + EasyPermissions.requestPermissions( + this@PermissionActivity, + resources.getString(R.string.app_name) + "需要获取相关权限", + LocaleConstant.PERMISSIONS_CODE, + *LocaleConstant.USER_PERMISSIONS + ) + } + } + + private fun startSplashScreenActivity() { + //先把导航隐私政策声明,后面导航会用到 + MapsInitializer.updatePrivacyAgree(this, true) + MapsInitializer.updatePrivacyShow(this, true, true) + this.navigatePageTo() + 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) { + startSplashScreenActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable/alarm_selector.xml b/app/src/main/res/drawable/alarm_selector.xml new file mode 100644 index 0000000..39b2595 --- /dev/null +++ b/app/src/main/res/drawable/alarm_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bottom_text_color.xml b/app/src/main/res/drawable/bottom_text_color.xml new file mode 100644 index 0000000..b284ea3 --- /dev/null +++ b/app/src/main/res/drawable/bottom_text_color.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_alarm.xml b/app/src/main/res/drawable/ic_alarm.xml new file mode 100644 index 0000000..dc33aab --- /dev/null +++ b/app/src/main/res/drawable/ic_alarm.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_alarm_selected.xml b/app/src/main/res/drawable/ic_alarm_selected.xml new file mode 100644 index 0000000..993fea6 --- /dev/null +++ b/app/src/main/res/drawable/ic_alarm_selected.xml @@ -0,0 +1,9 @@ + + + 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_monitor.xml b/app/src/main/res/drawable/ic_monitor.xml new file mode 100644 index 0000000..271f5b4 --- /dev/null +++ b/app/src/main/res/drawable/ic_monitor.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_monitor_selected.xml b/app/src/main/res/drawable/ic_monitor_selected.xml new file mode 100644 index 0000000..ee62d84 --- /dev/null +++ b/app/src/main/res/drawable/ic_monitor_selected.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_statistics.xml b/app/src/main/res/drawable/ic_statistics.xml new file mode 100644 index 0000000..7fde8ec --- /dev/null +++ b/app/src/main/res/drawable/ic_statistics.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_statistics_selected.xml b/app/src/main/res/drawable/ic_statistics_selected.xml new file mode 100644 index 0000000..49b6fcd --- /dev/null +++ b/app/src/main/res/drawable/ic_statistics_selected.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/monitor_selector.xml b/app/src/main/res/drawable/monitor_selector.xml new file mode 100644 index 0000000..fe11e9a --- /dev/null +++ b/app/src/main/res/drawable/monitor_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/statistics_selector.xml b/app/src/main/res/drawable/statistics_selector.xml new file mode 100644 index 0000000..2156cff --- /dev/null +++ b/app/src/main/res/drawable/statistics_selector.xml @@ -0,0 +1,5 @@ + + + + + \ 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..78a4a94 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,27 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_monitor_record.xml b/app/src/main/res/layout/activity_monitor_record.xml new file mode 100644 index 0000000..77d9ef6 --- /dev/null +++ b/app/src/main/res/layout/activity_monitor_record.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_alarm.xml b/app/src/main/res/layout/fragment_alarm.xml new file mode 100644 index 0000000..77d9ef6 --- /dev/null +++ b/app/src/main/res/layout/fragment_alarm.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_monitor.xml b/app/src/main/res/layout/fragment_monitor.xml new file mode 100644 index 0000000..19789c1 --- /dev/null +++ b/app/src/main/res/layout/fragment_monitor.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_statistics.xml b/app/src/main/res/layout/fragment_statistics.xml new file mode 100644 index 0000000..77d9ef6 --- /dev/null +++ b/app/src/main/res/layout/fragment_statistics.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/menu/bottom_nav_menu.xml b/app/src/main/res/menu/bottom_nav_menu.xml new file mode 100644 index 0000000..751fd61 --- /dev/null +++ b/app/src/main/res/menu/bottom_nav_menu.xml @@ -0,0 +1,29 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.webp b/app/src/main/res/mipmap-hdpi/ic_launcher.webp new file mode 100644 index 0000000..c209e78 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp new file mode 100644 index 0000000..b2dfe3d --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp Binary files differ diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..10cfdbf --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*.iml +.gradle +/local.properties +/.idea +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..a4cd2ca --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,101 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'org.greenrobot.greendao' + +android { +// signingConfigs { +// release { +// storeFile file('/Users/a203/Desktop/AndroidProjects/CasicSmartWell/app/CasicSmartWell.jks') +// storePassword '123456789' +// keyAlias 'key0' +// keyPassword '123456789' +// } +// } + compileSdkVersion 31 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.smart.town.sanxi" + minSdkVersion 23 + targetSdkVersion 31 + versionCode 1 + versionName "1.0.0" + + manifestPlaceholders = [GETUI_APPID: "A9V4DvwLcdAqkFCQuFyhq6"] + } + + buildTypes { + release { + minifyEnabled false +// signingConfig signingConfigs.release + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + + ndk { abiFilters "armeabi", "armeabi-v7a", "arm64-v8" } + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlin { + experimental { + coroutines 'enable' + } + } + + greendao { + schemaVersion 1//数据库版本号 + targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 + daoPackage 'com.casic.smart.town.sanxi.greendao'//设置DaoMaster、DaoSession、Dao包名 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + //基础依赖库 + implementation files('libs/lite-release.aar') + implementation 'androidx.appcompat:appcompat:1.4.2' + implementation 'androidx.core:core-ktx:1.8.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:3.0.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' + //MVVM+LiveData + implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.1" + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0" + implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + //Kotlin协程 + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1' + //图片加载框架 + implementation 'com.github.bumptech.glide:glide:4.9.0' + //返回值转换器 + implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' + implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + //okhttp3日志拦截器 + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //网络请求和接口封装 + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.9.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.9.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' + //高德地图 + implementation 'com.amap.api:3dmap:latest.integration' + //推送SDK + implementation 'com.getui:gtsdk:3.2.10.0' //个推SDK + implementation 'com.getui:gtc:3.1.9.0' //个推核心组件 + //数据库框架 + implementation 'org.greenrobot:greendao:3.3.0' + //桌面角标 + implementation "me.leolin:ShortcutBadger:1.1.22@aar" +} \ No newline at end of file diff --git a/app/libs/lite-release.aar b/app/libs/lite-release.aar new file mode 100644 index 0000000..45da4df --- /dev/null +++ b/app/libs/lite-release.aar Binary files differ diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /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 \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..a83c28a --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/svg/monitor.svg b/app/src/main/assets/svg/monitor.svg new file mode 100644 index 0000000..c8d3e25 --- /dev/null +++ b/app/src/main/assets/svg/monitor.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/msg.svg b/app/src/main/assets/svg/msg.svg new file mode 100644 index 0000000..e864e48 --- /dev/null +++ b/app/src/main/assets/svg/msg.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/statistics.svg b/app/src/main/assets/svg/statistics.svg new file mode 100644 index 0000000..974000e --- /dev/null +++ b/app/src/main/assets/svg/statistics.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt new file mode 100644 index 0000000..6b9cce0 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.adapter + +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentManager +import androidx.fragment.app.FragmentPagerAdapter + +class ViewPagerAdapter(list: ArrayList, manager: FragmentManager) : + FragmentPagerAdapter(manager) { + + private var pageList: List = list + + override fun getItem(position: Int) = pageList[position] + + override fun getCount() = pageList.size +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt new file mode 100644 index 0000000..4e017b1 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt @@ -0,0 +1,40 @@ +package com.casic.smart.town.sanxi.base + +import android.app.Application +import android.util.Log +import com.casic.smart.town.sanxi.greendao.DaoMaster +import com.casic.smart.town.sanxi.greendao.DaoSession +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + private val kTag = "BaseApplication" + + companion object { + private var instance: BaseApplication by Delegates.notNull() + + fun obtainInstance() = instance + + private lateinit var daoSession: DaoSession + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences(this) + //推送 + PushManager.getInstance().initialize(this) + PushManager.getInstance().setDebugLogger(this) { + Log.d(kTag, it) + } + val devOpenHelper = DaoMaster.DevOpenHelper(this, "SmartTown.db", null) + val daoMaster = DaoMaster(devOpenHelper.writableDatabase) + daoSession = daoMaster.newSession() + } + + fun obtainDaoSession(): DaoSession { + return daoSession + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java new file mode 100644 index 0000000..b8f67dc --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java @@ -0,0 +1,133 @@ +package com.casic.smart.town.sanxi.bean; + +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Generated; +import org.greenrobot.greendao.annotation.Id; +import org.greenrobot.greendao.annotation.Unique; + +@Entity +public class AlarmMessageLocaleBean { + @Id(autoincrement = true) + private Long id;//主键自增 + + @Unique + private String messageId; + private String appId; + private String clientId; + private String taskId; + private String userId; + private String title; + private String content; + private String deviceCode; + private String isRead;//0-未读,1-已读 + private String alarmTime; + + @Generated(hash = 566950134) + public AlarmMessageLocaleBean(Long id, String messageId, String appId, + String clientId, String taskId, String userId, String title, + String content, String deviceCode, String isRead, String alarmTime) { + this.id = id; + this.messageId = messageId; + this.appId = appId; + this.clientId = clientId; + this.taskId = taskId; + this.userId = userId; + this.title = title; + this.content = content; + this.deviceCode = deviceCode; + this.isRead = isRead; + this.alarmTime = alarmTime; + } + + @Generated(hash = 1737519562) + public AlarmMessageLocaleBean() { + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getMessageId() { + return this.messageId; + } + + public void setMessageId(String messageId) { + this.messageId = messageId; + } + + public String getAppId() { + return this.appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public String getClientId() { + return this.clientId; + } + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public String getTaskId() { + return this.taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getUserId() { + return this.userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getTitle() { + return this.title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return this.content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getDeviceCode() { + return this.deviceCode; + } + + public void setDeviceCode(String deviceCode) { + this.deviceCode = deviceCode; + } + + public String getIsRead() { + return this.isRead; + } + + public void setIsRead(String isRead) { + this.isRead = isRead; + } + + public String getAlarmTime() { + return this.alarmTime; + } + + public void setAlarmTime(String alarmTime) { + this.alarmTime = alarmTime; + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt new file mode 100644 index 0000000..650e201 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class AlarmPageFragment: KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_alarm + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt new file mode 100644 index 0000000..deac8ac --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt @@ -0,0 +1,76 @@ +package com.casic.smart.town.sanxi.fragment + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.Fragment +import com.amap.api.maps.AMap +import com.amap.api.maps.AMapOptions +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.view.MonitorRecordActivity +import com.pengxh.kt.lite.extensions.navigatePageTo +import com.pengxh.kt.lite.extensions.show +import kotlinx.android.synthetic.main.fragment_monitor.view.* + +class MonitorPageFragment : Fragment() { + + private val kTag = "HomePageFragment" + private lateinit var monitorView: View + private lateinit var aMap: AMap + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? + ): View { + monitorView = inflater.inflate(R.layout.fragment_monitor, container, false) + //地图初始化 + initMap(savedInstanceState) + + monitorView.rightOperateView.setOnClickListener { + requireContext().navigatePageTo() + } + return monitorView + } + + private fun initMap(savedInstanceState: Bundle?) { + monitorView.mapView.onCreate(savedInstanceState) + aMap = monitorView.mapView.map + aMap.mapType = AMap.MAP_TYPE_NORMAL + val uiSettings = aMap.uiSettings + uiSettings.isCompassEnabled = true + uiSettings.zoomPosition = AMapOptions.ZOOM_POSITION_RIGHT_CENTER + uiSettings.isTiltGesturesEnabled = false//不许地图随手势倾斜角度 + + // 地图加载成功监听 +// aMap.addOnMapLoadedListener(this) + // 地图缩放监听 +// aMap.addOnCameraChangeListener(this) + // marker 点击事件监听 +// aMap.addOnMarkerClickListener(this) + // 点击marker弹出自定义popup +// aMap.setInfoWindowAdapter(this) + //信息窗点击事件 +// aMap.addOnInfoWindowClickListener(this) + } + + /***以下是地图生命周期管理************************************************************************/ + override fun onResume() { + super.onResume() + monitorView.mapView.onResume() + } + + override fun onPause() { + super.onPause() + monitorView.mapView.onPause() + } + + override fun onSaveInstanceState(outState: Bundle) { + super.onSaveInstanceState(outState) + monitorView.mapView.onSaveInstanceState(outState) + } + + override fun onDestroy() { + super.onDestroy() + monitorView.mapView.onDestroy() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt new file mode 100644 index 0000000..e84df12 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class StatisticsPageFragment : KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_statistics + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java new file mode 100644 index 0000000..68d7901 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java @@ -0,0 +1,255 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.database.Cursor; +import android.database.sqlite.SQLiteStatement; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.Property; +import org.greenrobot.greendao.internal.DaoConfig; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseStatement; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * DAO for table "ALARM_MESSAGE_LOCALE_BEAN". +*/ +public class AlarmMessageLocaleBeanDao extends AbstractDao { + + public static final String TABLENAME = "ALARM_MESSAGE_LOCALE_BEAN"; + + /** + * Properties of entity AlarmMessageLocaleBean.
+ * Can be used for QueryBuilder and for referencing column names. + */ + public static class Properties { + public final static Property Id = new Property(0, Long.class, "id", true, "_id"); + public final static Property MessageId = new Property(1, String.class, "messageId", false, "MESSAGE_ID"); + public final static Property AppId = new Property(2, String.class, "appId", false, "APP_ID"); + public final static Property ClientId = new Property(3, String.class, "clientId", false, "CLIENT_ID"); + public final static Property TaskId = new Property(4, String.class, "taskId", false, "TASK_ID"); + public final static Property UserId = new Property(5, String.class, "userId", false, "USER_ID"); + public final static Property Title = new Property(6, String.class, "title", false, "TITLE"); + public final static Property Content = new Property(7, String.class, "content", false, "CONTENT"); + public final static Property DeviceCode = new Property(8, String.class, "deviceCode", false, "DEVICE_CODE"); + public final static Property IsRead = new Property(9, String.class, "isRead", false, "IS_READ"); + public final static Property AlarmTime = new Property(10, String.class, "alarmTime", false, "ALARM_TIME"); + } + + + public AlarmMessageLocaleBeanDao(DaoConfig config) { + super(config); + } + + public AlarmMessageLocaleBeanDao(DaoConfig config, DaoSession daoSession) { + super(config, daoSession); + } + + /** Creates the underlying database table. */ + public static void createTable(Database db, boolean ifNotExists) { + String constraint = ifNotExists? "IF NOT EXISTS ": ""; + db.execSQL("CREATE TABLE " + constraint + "\"ALARM_MESSAGE_LOCALE_BEAN\" (" + // + "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id + "\"MESSAGE_ID\" TEXT UNIQUE ," + // 1: messageId + "\"APP_ID\" TEXT," + // 2: appId + "\"CLIENT_ID\" TEXT," + // 3: clientId + "\"TASK_ID\" TEXT," + // 4: taskId + "\"USER_ID\" TEXT," + // 5: userId + "\"TITLE\" TEXT," + // 6: title + "\"CONTENT\" TEXT," + // 7: content + "\"DEVICE_CODE\" TEXT," + // 8: deviceCode + "\"IS_READ\" TEXT," + // 9: isRead + "\"ALARM_TIME\" TEXT);"); // 10: alarmTime + } + + /** Drops the underlying database table. */ + public static void dropTable(Database db, boolean ifExists) { + String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"ALARM_MESSAGE_LOCALE_BEAN\""; + db.execSQL(sql); + } + + @Override + protected final void bindValues(DatabaseStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + protected final void bindValues(SQLiteStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + public Long readKey(Cursor cursor, int offset) { + return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); + } + + @Override + public AlarmMessageLocaleBean readEntity(Cursor cursor, int offset) { + AlarmMessageLocaleBean entity = new AlarmMessageLocaleBean( // + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // messageId + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // appId + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // clientId + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // taskId + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // userId + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // title + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // content + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // deviceCode + cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // isRead + cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10) // alarmTime + ); + return entity; + } + + @Override + public void readEntity(Cursor cursor, AlarmMessageLocaleBean entity, int offset) { + entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); + entity.setMessageId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setAppId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setClientId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setTaskId(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); + entity.setUserId(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setTitle(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setContent(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); + entity.setDeviceCode(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); + entity.setIsRead(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9)); + entity.setAlarmTime(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); + } + + @Override + protected final Long updateKeyAfterInsert(AlarmMessageLocaleBean entity, long rowId) { + entity.setId(rowId); + return rowId; + } + + @Override + public Long getKey(AlarmMessageLocaleBean entity) { + if(entity != null) { + return entity.getId(); + } else { + return null; + } + } + + @Override + public boolean hasKey(AlarmMessageLocaleBean entity) { + return entity.getId() != null; + } + + @Override + protected final boolean isEntityUpdateable() { + return true; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java new file mode 100644 index 0000000..4222c40 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java @@ -0,0 +1,96 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.content.Context; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteDatabase.CursorFactory; +import android.util.Log; + +import org.greenrobot.greendao.AbstractDaoMaster; +import org.greenrobot.greendao.database.StandardDatabase; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseOpenHelper; +import org.greenrobot.greendao.identityscope.IdentityScopeType; + + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * Master of DAO (schema version 1): knows all DAOs. + */ +public class DaoMaster extends AbstractDaoMaster { + public static final int SCHEMA_VERSION = 1; + + /** Creates underlying database table using DAOs. */ + public static void createAllTables(Database db, boolean ifNotExists) { + AlarmMessageLocaleBeanDao.createTable(db, ifNotExists); + } + + /** Drops underlying database table using DAOs. */ + public static void dropAllTables(Database db, boolean ifExists) { + AlarmMessageLocaleBeanDao.dropTable(db, ifExists); + } + + /** + * WARNING: Drops all table on Upgrade! Use only during development. + * Convenience method using a {@link DevOpenHelper}. + */ + public static DaoSession newDevSession(Context context, String name) { + Database db = new DevOpenHelper(context, name).getWritableDb(); + DaoMaster daoMaster = new DaoMaster(db); + return daoMaster.newSession(); + } + + public DaoMaster(SQLiteDatabase db) { + this(new StandardDatabase(db)); + } + + public DaoMaster(Database db) { + super(db, SCHEMA_VERSION); + registerDaoClass(AlarmMessageLocaleBeanDao.class); + } + + public DaoSession newSession() { + return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); + } + + public DaoSession newSession(IdentityScopeType type) { + return new DaoSession(db, type, daoConfigMap); + } + + /** + * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} - + */ + public static abstract class OpenHelper extends DatabaseOpenHelper { + public OpenHelper(Context context, String name) { + super(context, name, SCHEMA_VERSION); + } + + public OpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory, SCHEMA_VERSION); + } + + @Override + public void onCreate(Database db) { + Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); + createAllTables(db, false); + } + } + + /** WARNING: Drops all table on Upgrade! Use only during development. */ + public static class DevOpenHelper extends OpenHelper { + public DevOpenHelper(Context context, String name) { + super(context, name); + } + + public DevOpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory); + } + + @Override + public void onUpgrade(Database db, int oldVersion, int newVersion) { + Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); + dropAllTables(db, true); + onCreate(db); + } + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java new file mode 100644 index 0000000..480ed84 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java @@ -0,0 +1,48 @@ +package com.casic.smart.town.sanxi.greendao; + +import java.util.Map; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.AbstractDaoSession; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.identityscope.IdentityScopeType; +import org.greenrobot.greendao.internal.DaoConfig; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. + +/** + * {@inheritDoc} + * + * @see org.greenrobot.greendao.AbstractDaoSession + */ +public class DaoSession extends AbstractDaoSession { + + private final DaoConfig alarmMessageLocaleBeanDaoConfig; + + private final AlarmMessageLocaleBeanDao alarmMessageLocaleBeanDao; + + public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> + daoConfigMap) { + super(db); + + alarmMessageLocaleBeanDaoConfig = daoConfigMap.get(AlarmMessageLocaleBeanDao.class).clone(); + alarmMessageLocaleBeanDaoConfig.initIdentityScope(type); + + alarmMessageLocaleBeanDao = new AlarmMessageLocaleBeanDao(alarmMessageLocaleBeanDaoConfig, this); + + registerDao(AlarmMessageLocaleBean.class, alarmMessageLocaleBeanDao); + } + + public void clear() { + alarmMessageLocaleBeanDaoConfig.clearIdentityScope(); + } + + public AlarmMessageLocaleBeanDao getAlarmMessageLocaleBeanDao() { + return alarmMessageLocaleBeanDao; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt new file mode 100644 index 0000000..875cb8c --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt @@ -0,0 +1,5 @@ +package com.casic.smart.town.sanxi.service + +import com.igexin.sdk.PushService + +class ApplicationPushService : PushService() \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt new file mode 100644 index 0000000..396129f --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt @@ -0,0 +1,84 @@ +package com.casic.smart.town.sanxi.service + +import android.content.Context +import android.os.Message +import android.util.Log +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.casic.smart.town.sanxi.view.MainActivity +import com.igexin.sdk.GTIntentService +import com.igexin.sdk.message.GTCmdMessage +import com.igexin.sdk.message.GTNotificationMessage +import com.igexin.sdk.message.GTTransmitMessage +import com.pengxh.kt.lite.extensions.toJson + +class PushIntentService : GTIntentService() { + + private val kTag = "SmartWellIntentService" + + override fun onReceiveServicePid(context: Context?, pid: Int) { + + } + + // 透传消息 + override fun onReceiveMessageData(context: Context?, msg: GTTransmitMessage?) { + Log.d(kTag, "透传消息 -> msg = $msg") + } + + // 接收 cid + override fun onReceiveClientId(context: Context?, clientid: String?) { + Log.d(kTag, "onReceiveClientId -> $clientid") + //通知MainActivity注册个推服务 + val msg: Message = MainActivity.weakReferenceHandler.obtainMessage() + msg.what = LocaleConstant.PUSH_REGISTER + msg.obj = clientid + MainActivity.weakReferenceHandler.sendMessage(msg) + } + + // cid 离线上线通知 + override fun onReceiveOnlineState(context: Context?, online: Boolean) { + + } + + // 各种事件处理回执 + override fun onReceiveCommandResult(context: Context?, msg: GTCmdMessage?) { + + } + + // 通知到达 + override fun onNotificationMessageArrived(context: Context?, msg: GTNotificationMessage?) { + //报警 +// { +// "content": "设备编号[412022030361]发生井盖开盖报警", +// "messageId": "380abf9a79d34306a2683dc9bf96ee78", +// "taskId": "OSL-0830_4hmfimp3Vu684wo3SjXso9", +// "title": "告警提醒", +// "appid": "HKv8K9qARd6WckZ1o2Vbu4", +// "clientId": "e78beacc42e9a02ae6fb9087eb2b1171", +// "pkgName": "com.casic.app.smartwell" +// } + if (msg == null) { + return + } + Log.d(kTag, "通知到达 -> msg = ${msg.toJson()}") +// val userDetailJson = SaveKeyValues.getValue(LocaleConstant.USER_DETAIL_MODEL, "") as String +// var userId = "" +// if (userDetailJson.isNotBlank()) { +// val userDataModel = Gson().fromJson( +// userDetailJson, object : TypeToken() {}.type +// ) +// userId = userDataModel.id.toString() +// } +// //解析编号 +// val splitArray = msg.content.split("\\[|\\]".toRegex()) +// DataBaseManager.instance.insertNotice( +// msg.messageId, msg.appid, msg.clientId, msg.taskId, +// userId, msg.title, msg.content, splitArray[1], "0", +// System.currentTimeMillis().timestampToCompleteDate() +// ) + } + + // 通知点击 + override fun onNotificationMessageClicked(context: Context?, msg: GTNotificationMessage?) { + Log.d(kTag, "通知点击 -> msg = $msg") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt new file mode 100644 index 0000000..daa7c38 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt @@ -0,0 +1,14 @@ +package com.casic.smart.town.sanxi.util + +import android.content.Context +import me.leolin.shortcutbadger.ShortcutBadger + +object BadeHelper { + fun setBadgeNum(context: Context, badgeCount: Int) { + if (badgeCount == 0) { + ShortcutBadger.removeCount(context) + } else { + ShortcutBadger.applyCount(context, badgeCount) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt new file mode 100644 index 0000000..0a52ef2 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt @@ -0,0 +1,75 @@ +package com.casic.smart.town.sanxi.util + +import com.casic.smart.town.sanxi.base.BaseApplication +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao + +class DataBaseManager private constructor() { + + companion object { + //Kotlin委托模式双重锁单例 + val instance: DataBaseManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) { + DataBaseManager() + } + } + + private val beanDao = + BaseApplication.obtainInstance().obtainDaoSession().alarmMessageLocaleBeanDao + +// fun insertNotice( +// messageId: String, appid: String, clientId: String, +// taskId: String, userId: String, title: String, +// content: String, deviceCode: String, isRead: String, +// noticeTime: String +// ) { +// val noticeLocaleBean = NoticeLocaleBean() +// noticeLocaleBean.messageId = messageId +// noticeLocaleBean.appid = appid +// noticeLocaleBean.clientId = clientId +// noticeLocaleBean.taskId = taskId +// noticeLocaleBean.userId = userId +// noticeLocaleBean.title = title +// noticeLocaleBean.content = content +// noticeLocaleBean.deviceCode = deviceCode +// noticeLocaleBean.isRead = isRead +// noticeLocaleBean.noticeTime = noticeTime +// beanDao.insert(noticeLocaleBean) +// //角标设置 +// BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadNotice()) +// } + + fun deleteByMessageId(messageId: String) { + val result = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).list() + beanDao.deleteInTx(result) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun updateNoticeByMessageId(messageId: String) { + val noticeLocaleBean = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).unique() ?: return + noticeLocaleBean.isRead = "1" + beanDao.update(noticeLocaleBean) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun queryMessageByPage(userId: String, offset: Int): MutableList { + return BaseApplication.obtainInstance().obtainDaoSession() + .queryBuilder(AlarmMessageLocaleBean::class.java) + .where(AlarmMessageLocaleBeanDao.Properties.UserId.eq(userId)) + .offset(offset * LocaleConstant.PAGE_LIMIT) + .orderDesc(AlarmMessageLocaleBeanDao.Properties.AlarmTime) + .limit(LocaleConstant.PAGE_LIMIT) + .list() + } + + private fun queryUnReadMessage(): Int { + return beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.IsRead.eq("0") + ).list().size + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt new file mode 100644 index 0000000..52926a8 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt @@ -0,0 +1,31 @@ +package com.casic.smart.town.sanxi.util; + +import android.app.Activity +import android.view.WindowManager +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object LoadingDialogHub { + private lateinit var loadingDialog: QMUITipDialog + + fun show(activity: Activity, message: String) { + loadingDialog = QMUITipDialog + .Builder(activity) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_LOADING) + .setTipWord(message) + .create() + if (!activity.isDestroyed) { + try { + loadingDialog.show() + } catch (e: WindowManager.BadTokenException) { + e.printStackTrace() + } + } + } + + + fun dismiss() { + if (loadingDialog.isShowing) { + loadingDialog.dismiss() + } + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt new file mode 100644 index 0000000..de61c9a --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.util + +import android.Manifest + +object LocaleConstant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.READ_PHONE_STATE, + Manifest.permission.ACCESS_COARSE_LOCATION, + Manifest.permission.READ_EXTERNAL_STORAGE + ) + + const val PERMISSIONS_CODE = 999 + const val PUSH_REGISTER = 2022100101 + const val PAGE_LIMIT = 20 +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt new file mode 100644 index 0000000..3bea1c9 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt @@ -0,0 +1,112 @@ +package com.casic.smart.town.sanxi.view + +import android.view.KeyEvent +import android.view.MenuItem +import androidx.fragment.app.Fragment +import androidx.viewpager.widget.ViewPager +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.adapter.ViewPagerAdapter +import com.casic.smart.town.sanxi.fragment.AlarmPageFragment +import com.casic.smart.town.sanxi.fragment.MonitorPageFragment +import com.casic.smart.town.sanxi.fragment.StatisticsPageFragment +import com.gyf.immersionbar.ImmersionBar +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.base.KotlinBaseActivity +import com.pengxh.kt.lite.extensions.convertColor +import com.pengxh.kt.lite.extensions.show +import com.pengxh.kt.lite.utils.ImmerseStatusBarUtil +import com.pengxh.kt.lite.utils.WeakReferenceHandler +import kotlinx.android.synthetic.main.activity_main.* + +class MainActivity : KotlinBaseActivity() { + + companion object { + lateinit var weakReferenceHandler: WeakReferenceHandler + } + + private val kTag = "MainActivity" + private var menuItem: MenuItem? = null + private var fragmentPages: ArrayList = ArrayList() + private var clickTime: Long = 0 + + init { + fragmentPages.add(StatisticsPageFragment()) + fragmentPages.add(MonitorPageFragment()) + fragmentPages.add(AlarmPageFragment()) + } + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + ImmersionBar.with(this).statusBarDarkFont(false).init() + ImmerseStatusBarUtil.setColor(this, R.color.mainThemeColor.convertColor(this)) + } + + override fun initData() { + //推送,多次调用 SDK 初始化并无影响。 + PushManager.getInstance().initialize(this) + weakReferenceHandler = WeakReferenceHandler { + + true + } + } + + override fun observeRequestState() { + + } + + override fun initEvent() { + bottomNavigation.itemIconTintList = null + bottomNavigation.setOnNavigationItemSelectedListener { menuItem -> + when (menuItem.itemId) { + R.id.nav_statistics -> { + mainViewPager.currentItem = 0 + } + R.id.nav_monitor -> { + mainViewPager.currentItem = 1 + } + R.id.nav_alarm -> { + mainViewPager.currentItem = 2 + } + } + false + } + mainViewPager.adapter = ViewPagerAdapter(fragmentPages, supportFragmentManager) + mainViewPager.offscreenPageLimit = fragmentPages.size //缓存页数 + mainViewPager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener { + override fun onPageScrollStateChanged(state: Int) { + + } + + override fun onPageScrolled( + position: Int, + positionOffset: Float, + positionOffsetPixels: Int + ) { + + } + + override fun onPageSelected(position: Int) { + if (menuItem != null) { + menuItem!!.isChecked = false + } else { + bottomNavigation.menu.getItem(0).isChecked = false + } + menuItem = bottomNavigation.menu.getItem(position) + menuItem!!.isChecked = true + } + }) + } + + override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean { + return if (keyCode == KeyEvent.KEYCODE_BACK) { + if (System.currentTimeMillis() - clickTime > 2000) { + "再按一次退出程序".show(this) + clickTime = System.currentTimeMillis() + true + } else { + super.onKeyDown(keyCode, event) + } + } else super.onKeyDown(keyCode, event) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt new file mode 100644 index 0000000..c5d8b22 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.view + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseActivity + +class MonitorRecordActivity : KotlinBaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_monitor_record + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt new file mode 100644 index 0000000..c478d83 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt @@ -0,0 +1,55 @@ +package com.casic.smart.town.sanxi.view + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.amap.api.maps.MapsInitializer +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.gyf.immersionbar.ImmersionBar +import com.pengxh.kt.lite.extensions.navigatePageTo +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + ImmersionBar.with(this).statusBarDarkFont(true).init() + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (EasyPermissions.hasPermissions(this, *LocaleConstant.USER_PERMISSIONS)) { + startSplashScreenActivity() + } else { + EasyPermissions.requestPermissions( + this@PermissionActivity, + resources.getString(R.string.app_name) + "需要获取相关权限", + LocaleConstant.PERMISSIONS_CODE, + *LocaleConstant.USER_PERMISSIONS + ) + } + } + + private fun startSplashScreenActivity() { + //先把导航隐私政策声明,后面导航会用到 + MapsInitializer.updatePrivacyAgree(this, true) + MapsInitializer.updatePrivacyShow(this, true, true) + this.navigatePageTo() + 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) { + startSplashScreenActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable/alarm_selector.xml b/app/src/main/res/drawable/alarm_selector.xml new file mode 100644 index 0000000..39b2595 --- /dev/null +++ b/app/src/main/res/drawable/alarm_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bottom_text_color.xml b/app/src/main/res/drawable/bottom_text_color.xml new file mode 100644 index 0000000..b284ea3 --- /dev/null +++ b/app/src/main/res/drawable/bottom_text_color.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_alarm.xml b/app/src/main/res/drawable/ic_alarm.xml new file mode 100644 index 0000000..dc33aab --- /dev/null +++ b/app/src/main/res/drawable/ic_alarm.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_alarm_selected.xml b/app/src/main/res/drawable/ic_alarm_selected.xml new file mode 100644 index 0000000..993fea6 --- /dev/null +++ b/app/src/main/res/drawable/ic_alarm_selected.xml @@ -0,0 +1,9 @@ + + + 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_monitor.xml b/app/src/main/res/drawable/ic_monitor.xml new file mode 100644 index 0000000..271f5b4 --- /dev/null +++ b/app/src/main/res/drawable/ic_monitor.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_monitor_selected.xml b/app/src/main/res/drawable/ic_monitor_selected.xml new file mode 100644 index 0000000..ee62d84 --- /dev/null +++ b/app/src/main/res/drawable/ic_monitor_selected.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_statistics.xml b/app/src/main/res/drawable/ic_statistics.xml new file mode 100644 index 0000000..7fde8ec --- /dev/null +++ b/app/src/main/res/drawable/ic_statistics.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_statistics_selected.xml b/app/src/main/res/drawable/ic_statistics_selected.xml new file mode 100644 index 0000000..49b6fcd --- /dev/null +++ b/app/src/main/res/drawable/ic_statistics_selected.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/monitor_selector.xml b/app/src/main/res/drawable/monitor_selector.xml new file mode 100644 index 0000000..fe11e9a --- /dev/null +++ b/app/src/main/res/drawable/monitor_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/statistics_selector.xml b/app/src/main/res/drawable/statistics_selector.xml new file mode 100644 index 0000000..2156cff --- /dev/null +++ b/app/src/main/res/drawable/statistics_selector.xml @@ -0,0 +1,5 @@ + + + + + \ 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..78a4a94 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,27 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_monitor_record.xml b/app/src/main/res/layout/activity_monitor_record.xml new file mode 100644 index 0000000..77d9ef6 --- /dev/null +++ b/app/src/main/res/layout/activity_monitor_record.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_alarm.xml b/app/src/main/res/layout/fragment_alarm.xml new file mode 100644 index 0000000..77d9ef6 --- /dev/null +++ b/app/src/main/res/layout/fragment_alarm.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_monitor.xml b/app/src/main/res/layout/fragment_monitor.xml new file mode 100644 index 0000000..19789c1 --- /dev/null +++ b/app/src/main/res/layout/fragment_monitor.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_statistics.xml b/app/src/main/res/layout/fragment_statistics.xml new file mode 100644 index 0000000..77d9ef6 --- /dev/null +++ b/app/src/main/res/layout/fragment_statistics.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/menu/bottom_nav_menu.xml b/app/src/main/res/menu/bottom_nav_menu.xml new file mode 100644 index 0000000..751fd61 --- /dev/null +++ b/app/src/main/res/menu/bottom_nav_menu.xml @@ -0,0 +1,29 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.webp b/app/src/main/res/mipmap-hdpi/ic_launcher.webp new file mode 100644 index 0000000..c209e78 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp new file mode 100644 index 0000000..b2dfe3d --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.webp b/app/src/main/res/mipmap-mdpi/ic_launcher.webp new file mode 100644 index 0000000..4f0f1d6 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher.webp Binary files differ diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..10cfdbf --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*.iml +.gradle +/local.properties +/.idea +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..a4cd2ca --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,101 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'org.greenrobot.greendao' + +android { +// signingConfigs { +// release { +// storeFile file('/Users/a203/Desktop/AndroidProjects/CasicSmartWell/app/CasicSmartWell.jks') +// storePassword '123456789' +// keyAlias 'key0' +// keyPassword '123456789' +// } +// } + compileSdkVersion 31 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.smart.town.sanxi" + minSdkVersion 23 + targetSdkVersion 31 + versionCode 1 + versionName "1.0.0" + + manifestPlaceholders = [GETUI_APPID: "A9V4DvwLcdAqkFCQuFyhq6"] + } + + buildTypes { + release { + minifyEnabled false +// signingConfig signingConfigs.release + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + + ndk { abiFilters "armeabi", "armeabi-v7a", "arm64-v8" } + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlin { + experimental { + coroutines 'enable' + } + } + + greendao { + schemaVersion 1//数据库版本号 + targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 + daoPackage 'com.casic.smart.town.sanxi.greendao'//设置DaoMaster、DaoSession、Dao包名 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + //基础依赖库 + implementation files('libs/lite-release.aar') + implementation 'androidx.appcompat:appcompat:1.4.2' + implementation 'androidx.core:core-ktx:1.8.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:3.0.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' + //MVVM+LiveData + implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.1" + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0" + implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + //Kotlin协程 + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1' + //图片加载框架 + implementation 'com.github.bumptech.glide:glide:4.9.0' + //返回值转换器 + implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' + implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + //okhttp3日志拦截器 + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //网络请求和接口封装 + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.9.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.9.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' + //高德地图 + implementation 'com.amap.api:3dmap:latest.integration' + //推送SDK + implementation 'com.getui:gtsdk:3.2.10.0' //个推SDK + implementation 'com.getui:gtc:3.1.9.0' //个推核心组件 + //数据库框架 + implementation 'org.greenrobot:greendao:3.3.0' + //桌面角标 + implementation "me.leolin:ShortcutBadger:1.1.22@aar" +} \ No newline at end of file diff --git a/app/libs/lite-release.aar b/app/libs/lite-release.aar new file mode 100644 index 0000000..45da4df --- /dev/null +++ b/app/libs/lite-release.aar Binary files differ diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /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 \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..a83c28a --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/svg/monitor.svg b/app/src/main/assets/svg/monitor.svg new file mode 100644 index 0000000..c8d3e25 --- /dev/null +++ b/app/src/main/assets/svg/monitor.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/msg.svg b/app/src/main/assets/svg/msg.svg new file mode 100644 index 0000000..e864e48 --- /dev/null +++ b/app/src/main/assets/svg/msg.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/statistics.svg b/app/src/main/assets/svg/statistics.svg new file mode 100644 index 0000000..974000e --- /dev/null +++ b/app/src/main/assets/svg/statistics.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt new file mode 100644 index 0000000..6b9cce0 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.adapter + +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentManager +import androidx.fragment.app.FragmentPagerAdapter + +class ViewPagerAdapter(list: ArrayList, manager: FragmentManager) : + FragmentPagerAdapter(manager) { + + private var pageList: List = list + + override fun getItem(position: Int) = pageList[position] + + override fun getCount() = pageList.size +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt new file mode 100644 index 0000000..4e017b1 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt @@ -0,0 +1,40 @@ +package com.casic.smart.town.sanxi.base + +import android.app.Application +import android.util.Log +import com.casic.smart.town.sanxi.greendao.DaoMaster +import com.casic.smart.town.sanxi.greendao.DaoSession +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + private val kTag = "BaseApplication" + + companion object { + private var instance: BaseApplication by Delegates.notNull() + + fun obtainInstance() = instance + + private lateinit var daoSession: DaoSession + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences(this) + //推送 + PushManager.getInstance().initialize(this) + PushManager.getInstance().setDebugLogger(this) { + Log.d(kTag, it) + } + val devOpenHelper = DaoMaster.DevOpenHelper(this, "SmartTown.db", null) + val daoMaster = DaoMaster(devOpenHelper.writableDatabase) + daoSession = daoMaster.newSession() + } + + fun obtainDaoSession(): DaoSession { + return daoSession + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java new file mode 100644 index 0000000..b8f67dc --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java @@ -0,0 +1,133 @@ +package com.casic.smart.town.sanxi.bean; + +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Generated; +import org.greenrobot.greendao.annotation.Id; +import org.greenrobot.greendao.annotation.Unique; + +@Entity +public class AlarmMessageLocaleBean { + @Id(autoincrement = true) + private Long id;//主键自增 + + @Unique + private String messageId; + private String appId; + private String clientId; + private String taskId; + private String userId; + private String title; + private String content; + private String deviceCode; + private String isRead;//0-未读,1-已读 + private String alarmTime; + + @Generated(hash = 566950134) + public AlarmMessageLocaleBean(Long id, String messageId, String appId, + String clientId, String taskId, String userId, String title, + String content, String deviceCode, String isRead, String alarmTime) { + this.id = id; + this.messageId = messageId; + this.appId = appId; + this.clientId = clientId; + this.taskId = taskId; + this.userId = userId; + this.title = title; + this.content = content; + this.deviceCode = deviceCode; + this.isRead = isRead; + this.alarmTime = alarmTime; + } + + @Generated(hash = 1737519562) + public AlarmMessageLocaleBean() { + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getMessageId() { + return this.messageId; + } + + public void setMessageId(String messageId) { + this.messageId = messageId; + } + + public String getAppId() { + return this.appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public String getClientId() { + return this.clientId; + } + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public String getTaskId() { + return this.taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getUserId() { + return this.userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getTitle() { + return this.title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return this.content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getDeviceCode() { + return this.deviceCode; + } + + public void setDeviceCode(String deviceCode) { + this.deviceCode = deviceCode; + } + + public String getIsRead() { + return this.isRead; + } + + public void setIsRead(String isRead) { + this.isRead = isRead; + } + + public String getAlarmTime() { + return this.alarmTime; + } + + public void setAlarmTime(String alarmTime) { + this.alarmTime = alarmTime; + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt new file mode 100644 index 0000000..650e201 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class AlarmPageFragment: KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_alarm + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt new file mode 100644 index 0000000..deac8ac --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt @@ -0,0 +1,76 @@ +package com.casic.smart.town.sanxi.fragment + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.Fragment +import com.amap.api.maps.AMap +import com.amap.api.maps.AMapOptions +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.view.MonitorRecordActivity +import com.pengxh.kt.lite.extensions.navigatePageTo +import com.pengxh.kt.lite.extensions.show +import kotlinx.android.synthetic.main.fragment_monitor.view.* + +class MonitorPageFragment : Fragment() { + + private val kTag = "HomePageFragment" + private lateinit var monitorView: View + private lateinit var aMap: AMap + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? + ): View { + monitorView = inflater.inflate(R.layout.fragment_monitor, container, false) + //地图初始化 + initMap(savedInstanceState) + + monitorView.rightOperateView.setOnClickListener { + requireContext().navigatePageTo() + } + return monitorView + } + + private fun initMap(savedInstanceState: Bundle?) { + monitorView.mapView.onCreate(savedInstanceState) + aMap = monitorView.mapView.map + aMap.mapType = AMap.MAP_TYPE_NORMAL + val uiSettings = aMap.uiSettings + uiSettings.isCompassEnabled = true + uiSettings.zoomPosition = AMapOptions.ZOOM_POSITION_RIGHT_CENTER + uiSettings.isTiltGesturesEnabled = false//不许地图随手势倾斜角度 + + // 地图加载成功监听 +// aMap.addOnMapLoadedListener(this) + // 地图缩放监听 +// aMap.addOnCameraChangeListener(this) + // marker 点击事件监听 +// aMap.addOnMarkerClickListener(this) + // 点击marker弹出自定义popup +// aMap.setInfoWindowAdapter(this) + //信息窗点击事件 +// aMap.addOnInfoWindowClickListener(this) + } + + /***以下是地图生命周期管理************************************************************************/ + override fun onResume() { + super.onResume() + monitorView.mapView.onResume() + } + + override fun onPause() { + super.onPause() + monitorView.mapView.onPause() + } + + override fun onSaveInstanceState(outState: Bundle) { + super.onSaveInstanceState(outState) + monitorView.mapView.onSaveInstanceState(outState) + } + + override fun onDestroy() { + super.onDestroy() + monitorView.mapView.onDestroy() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt new file mode 100644 index 0000000..e84df12 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class StatisticsPageFragment : KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_statistics + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java new file mode 100644 index 0000000..68d7901 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java @@ -0,0 +1,255 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.database.Cursor; +import android.database.sqlite.SQLiteStatement; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.Property; +import org.greenrobot.greendao.internal.DaoConfig; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseStatement; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * DAO for table "ALARM_MESSAGE_LOCALE_BEAN". +*/ +public class AlarmMessageLocaleBeanDao extends AbstractDao { + + public static final String TABLENAME = "ALARM_MESSAGE_LOCALE_BEAN"; + + /** + * Properties of entity AlarmMessageLocaleBean.
+ * Can be used for QueryBuilder and for referencing column names. + */ + public static class Properties { + public final static Property Id = new Property(0, Long.class, "id", true, "_id"); + public final static Property MessageId = new Property(1, String.class, "messageId", false, "MESSAGE_ID"); + public final static Property AppId = new Property(2, String.class, "appId", false, "APP_ID"); + public final static Property ClientId = new Property(3, String.class, "clientId", false, "CLIENT_ID"); + public final static Property TaskId = new Property(4, String.class, "taskId", false, "TASK_ID"); + public final static Property UserId = new Property(5, String.class, "userId", false, "USER_ID"); + public final static Property Title = new Property(6, String.class, "title", false, "TITLE"); + public final static Property Content = new Property(7, String.class, "content", false, "CONTENT"); + public final static Property DeviceCode = new Property(8, String.class, "deviceCode", false, "DEVICE_CODE"); + public final static Property IsRead = new Property(9, String.class, "isRead", false, "IS_READ"); + public final static Property AlarmTime = new Property(10, String.class, "alarmTime", false, "ALARM_TIME"); + } + + + public AlarmMessageLocaleBeanDao(DaoConfig config) { + super(config); + } + + public AlarmMessageLocaleBeanDao(DaoConfig config, DaoSession daoSession) { + super(config, daoSession); + } + + /** Creates the underlying database table. */ + public static void createTable(Database db, boolean ifNotExists) { + String constraint = ifNotExists? "IF NOT EXISTS ": ""; + db.execSQL("CREATE TABLE " + constraint + "\"ALARM_MESSAGE_LOCALE_BEAN\" (" + // + "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id + "\"MESSAGE_ID\" TEXT UNIQUE ," + // 1: messageId + "\"APP_ID\" TEXT," + // 2: appId + "\"CLIENT_ID\" TEXT," + // 3: clientId + "\"TASK_ID\" TEXT," + // 4: taskId + "\"USER_ID\" TEXT," + // 5: userId + "\"TITLE\" TEXT," + // 6: title + "\"CONTENT\" TEXT," + // 7: content + "\"DEVICE_CODE\" TEXT," + // 8: deviceCode + "\"IS_READ\" TEXT," + // 9: isRead + "\"ALARM_TIME\" TEXT);"); // 10: alarmTime + } + + /** Drops the underlying database table. */ + public static void dropTable(Database db, boolean ifExists) { + String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"ALARM_MESSAGE_LOCALE_BEAN\""; + db.execSQL(sql); + } + + @Override + protected final void bindValues(DatabaseStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + protected final void bindValues(SQLiteStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + public Long readKey(Cursor cursor, int offset) { + return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); + } + + @Override + public AlarmMessageLocaleBean readEntity(Cursor cursor, int offset) { + AlarmMessageLocaleBean entity = new AlarmMessageLocaleBean( // + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // messageId + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // appId + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // clientId + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // taskId + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // userId + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // title + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // content + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // deviceCode + cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // isRead + cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10) // alarmTime + ); + return entity; + } + + @Override + public void readEntity(Cursor cursor, AlarmMessageLocaleBean entity, int offset) { + entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); + entity.setMessageId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setAppId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setClientId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setTaskId(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); + entity.setUserId(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setTitle(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setContent(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); + entity.setDeviceCode(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); + entity.setIsRead(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9)); + entity.setAlarmTime(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); + } + + @Override + protected final Long updateKeyAfterInsert(AlarmMessageLocaleBean entity, long rowId) { + entity.setId(rowId); + return rowId; + } + + @Override + public Long getKey(AlarmMessageLocaleBean entity) { + if(entity != null) { + return entity.getId(); + } else { + return null; + } + } + + @Override + public boolean hasKey(AlarmMessageLocaleBean entity) { + return entity.getId() != null; + } + + @Override + protected final boolean isEntityUpdateable() { + return true; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java new file mode 100644 index 0000000..4222c40 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java @@ -0,0 +1,96 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.content.Context; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteDatabase.CursorFactory; +import android.util.Log; + +import org.greenrobot.greendao.AbstractDaoMaster; +import org.greenrobot.greendao.database.StandardDatabase; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseOpenHelper; +import org.greenrobot.greendao.identityscope.IdentityScopeType; + + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * Master of DAO (schema version 1): knows all DAOs. + */ +public class DaoMaster extends AbstractDaoMaster { + public static final int SCHEMA_VERSION = 1; + + /** Creates underlying database table using DAOs. */ + public static void createAllTables(Database db, boolean ifNotExists) { + AlarmMessageLocaleBeanDao.createTable(db, ifNotExists); + } + + /** Drops underlying database table using DAOs. */ + public static void dropAllTables(Database db, boolean ifExists) { + AlarmMessageLocaleBeanDao.dropTable(db, ifExists); + } + + /** + * WARNING: Drops all table on Upgrade! Use only during development. + * Convenience method using a {@link DevOpenHelper}. + */ + public static DaoSession newDevSession(Context context, String name) { + Database db = new DevOpenHelper(context, name).getWritableDb(); + DaoMaster daoMaster = new DaoMaster(db); + return daoMaster.newSession(); + } + + public DaoMaster(SQLiteDatabase db) { + this(new StandardDatabase(db)); + } + + public DaoMaster(Database db) { + super(db, SCHEMA_VERSION); + registerDaoClass(AlarmMessageLocaleBeanDao.class); + } + + public DaoSession newSession() { + return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); + } + + public DaoSession newSession(IdentityScopeType type) { + return new DaoSession(db, type, daoConfigMap); + } + + /** + * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} - + */ + public static abstract class OpenHelper extends DatabaseOpenHelper { + public OpenHelper(Context context, String name) { + super(context, name, SCHEMA_VERSION); + } + + public OpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory, SCHEMA_VERSION); + } + + @Override + public void onCreate(Database db) { + Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); + createAllTables(db, false); + } + } + + /** WARNING: Drops all table on Upgrade! Use only during development. */ + public static class DevOpenHelper extends OpenHelper { + public DevOpenHelper(Context context, String name) { + super(context, name); + } + + public DevOpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory); + } + + @Override + public void onUpgrade(Database db, int oldVersion, int newVersion) { + Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); + dropAllTables(db, true); + onCreate(db); + } + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java new file mode 100644 index 0000000..480ed84 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java @@ -0,0 +1,48 @@ +package com.casic.smart.town.sanxi.greendao; + +import java.util.Map; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.AbstractDaoSession; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.identityscope.IdentityScopeType; +import org.greenrobot.greendao.internal.DaoConfig; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. + +/** + * {@inheritDoc} + * + * @see org.greenrobot.greendao.AbstractDaoSession + */ +public class DaoSession extends AbstractDaoSession { + + private final DaoConfig alarmMessageLocaleBeanDaoConfig; + + private final AlarmMessageLocaleBeanDao alarmMessageLocaleBeanDao; + + public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> + daoConfigMap) { + super(db); + + alarmMessageLocaleBeanDaoConfig = daoConfigMap.get(AlarmMessageLocaleBeanDao.class).clone(); + alarmMessageLocaleBeanDaoConfig.initIdentityScope(type); + + alarmMessageLocaleBeanDao = new AlarmMessageLocaleBeanDao(alarmMessageLocaleBeanDaoConfig, this); + + registerDao(AlarmMessageLocaleBean.class, alarmMessageLocaleBeanDao); + } + + public void clear() { + alarmMessageLocaleBeanDaoConfig.clearIdentityScope(); + } + + public AlarmMessageLocaleBeanDao getAlarmMessageLocaleBeanDao() { + return alarmMessageLocaleBeanDao; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt new file mode 100644 index 0000000..875cb8c --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt @@ -0,0 +1,5 @@ +package com.casic.smart.town.sanxi.service + +import com.igexin.sdk.PushService + +class ApplicationPushService : PushService() \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt new file mode 100644 index 0000000..396129f --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt @@ -0,0 +1,84 @@ +package com.casic.smart.town.sanxi.service + +import android.content.Context +import android.os.Message +import android.util.Log +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.casic.smart.town.sanxi.view.MainActivity +import com.igexin.sdk.GTIntentService +import com.igexin.sdk.message.GTCmdMessage +import com.igexin.sdk.message.GTNotificationMessage +import com.igexin.sdk.message.GTTransmitMessage +import com.pengxh.kt.lite.extensions.toJson + +class PushIntentService : GTIntentService() { + + private val kTag = "SmartWellIntentService" + + override fun onReceiveServicePid(context: Context?, pid: Int) { + + } + + // 透传消息 + override fun onReceiveMessageData(context: Context?, msg: GTTransmitMessage?) { + Log.d(kTag, "透传消息 -> msg = $msg") + } + + // 接收 cid + override fun onReceiveClientId(context: Context?, clientid: String?) { + Log.d(kTag, "onReceiveClientId -> $clientid") + //通知MainActivity注册个推服务 + val msg: Message = MainActivity.weakReferenceHandler.obtainMessage() + msg.what = LocaleConstant.PUSH_REGISTER + msg.obj = clientid + MainActivity.weakReferenceHandler.sendMessage(msg) + } + + // cid 离线上线通知 + override fun onReceiveOnlineState(context: Context?, online: Boolean) { + + } + + // 各种事件处理回执 + override fun onReceiveCommandResult(context: Context?, msg: GTCmdMessage?) { + + } + + // 通知到达 + override fun onNotificationMessageArrived(context: Context?, msg: GTNotificationMessage?) { + //报警 +// { +// "content": "设备编号[412022030361]发生井盖开盖报警", +// "messageId": "380abf9a79d34306a2683dc9bf96ee78", +// "taskId": "OSL-0830_4hmfimp3Vu684wo3SjXso9", +// "title": "告警提醒", +// "appid": "HKv8K9qARd6WckZ1o2Vbu4", +// "clientId": "e78beacc42e9a02ae6fb9087eb2b1171", +// "pkgName": "com.casic.app.smartwell" +// } + if (msg == null) { + return + } + Log.d(kTag, "通知到达 -> msg = ${msg.toJson()}") +// val userDetailJson = SaveKeyValues.getValue(LocaleConstant.USER_DETAIL_MODEL, "") as String +// var userId = "" +// if (userDetailJson.isNotBlank()) { +// val userDataModel = Gson().fromJson( +// userDetailJson, object : TypeToken() {}.type +// ) +// userId = userDataModel.id.toString() +// } +// //解析编号 +// val splitArray = msg.content.split("\\[|\\]".toRegex()) +// DataBaseManager.instance.insertNotice( +// msg.messageId, msg.appid, msg.clientId, msg.taskId, +// userId, msg.title, msg.content, splitArray[1], "0", +// System.currentTimeMillis().timestampToCompleteDate() +// ) + } + + // 通知点击 + override fun onNotificationMessageClicked(context: Context?, msg: GTNotificationMessage?) { + Log.d(kTag, "通知点击 -> msg = $msg") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt new file mode 100644 index 0000000..daa7c38 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt @@ -0,0 +1,14 @@ +package com.casic.smart.town.sanxi.util + +import android.content.Context +import me.leolin.shortcutbadger.ShortcutBadger + +object BadeHelper { + fun setBadgeNum(context: Context, badgeCount: Int) { + if (badgeCount == 0) { + ShortcutBadger.removeCount(context) + } else { + ShortcutBadger.applyCount(context, badgeCount) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt new file mode 100644 index 0000000..0a52ef2 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt @@ -0,0 +1,75 @@ +package com.casic.smart.town.sanxi.util + +import com.casic.smart.town.sanxi.base.BaseApplication +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao + +class DataBaseManager private constructor() { + + companion object { + //Kotlin委托模式双重锁单例 + val instance: DataBaseManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) { + DataBaseManager() + } + } + + private val beanDao = + BaseApplication.obtainInstance().obtainDaoSession().alarmMessageLocaleBeanDao + +// fun insertNotice( +// messageId: String, appid: String, clientId: String, +// taskId: String, userId: String, title: String, +// content: String, deviceCode: String, isRead: String, +// noticeTime: String +// ) { +// val noticeLocaleBean = NoticeLocaleBean() +// noticeLocaleBean.messageId = messageId +// noticeLocaleBean.appid = appid +// noticeLocaleBean.clientId = clientId +// noticeLocaleBean.taskId = taskId +// noticeLocaleBean.userId = userId +// noticeLocaleBean.title = title +// noticeLocaleBean.content = content +// noticeLocaleBean.deviceCode = deviceCode +// noticeLocaleBean.isRead = isRead +// noticeLocaleBean.noticeTime = noticeTime +// beanDao.insert(noticeLocaleBean) +// //角标设置 +// BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadNotice()) +// } + + fun deleteByMessageId(messageId: String) { + val result = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).list() + beanDao.deleteInTx(result) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun updateNoticeByMessageId(messageId: String) { + val noticeLocaleBean = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).unique() ?: return + noticeLocaleBean.isRead = "1" + beanDao.update(noticeLocaleBean) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun queryMessageByPage(userId: String, offset: Int): MutableList { + return BaseApplication.obtainInstance().obtainDaoSession() + .queryBuilder(AlarmMessageLocaleBean::class.java) + .where(AlarmMessageLocaleBeanDao.Properties.UserId.eq(userId)) + .offset(offset * LocaleConstant.PAGE_LIMIT) + .orderDesc(AlarmMessageLocaleBeanDao.Properties.AlarmTime) + .limit(LocaleConstant.PAGE_LIMIT) + .list() + } + + private fun queryUnReadMessage(): Int { + return beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.IsRead.eq("0") + ).list().size + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt new file mode 100644 index 0000000..52926a8 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt @@ -0,0 +1,31 @@ +package com.casic.smart.town.sanxi.util; + +import android.app.Activity +import android.view.WindowManager +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object LoadingDialogHub { + private lateinit var loadingDialog: QMUITipDialog + + fun show(activity: Activity, message: String) { + loadingDialog = QMUITipDialog + .Builder(activity) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_LOADING) + .setTipWord(message) + .create() + if (!activity.isDestroyed) { + try { + loadingDialog.show() + } catch (e: WindowManager.BadTokenException) { + e.printStackTrace() + } + } + } + + + fun dismiss() { + if (loadingDialog.isShowing) { + loadingDialog.dismiss() + } + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt new file mode 100644 index 0000000..de61c9a --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.util + +import android.Manifest + +object LocaleConstant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.READ_PHONE_STATE, + Manifest.permission.ACCESS_COARSE_LOCATION, + Manifest.permission.READ_EXTERNAL_STORAGE + ) + + const val PERMISSIONS_CODE = 999 + const val PUSH_REGISTER = 2022100101 + const val PAGE_LIMIT = 20 +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt new file mode 100644 index 0000000..3bea1c9 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt @@ -0,0 +1,112 @@ +package com.casic.smart.town.sanxi.view + +import android.view.KeyEvent +import android.view.MenuItem +import androidx.fragment.app.Fragment +import androidx.viewpager.widget.ViewPager +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.adapter.ViewPagerAdapter +import com.casic.smart.town.sanxi.fragment.AlarmPageFragment +import com.casic.smart.town.sanxi.fragment.MonitorPageFragment +import com.casic.smart.town.sanxi.fragment.StatisticsPageFragment +import com.gyf.immersionbar.ImmersionBar +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.base.KotlinBaseActivity +import com.pengxh.kt.lite.extensions.convertColor +import com.pengxh.kt.lite.extensions.show +import com.pengxh.kt.lite.utils.ImmerseStatusBarUtil +import com.pengxh.kt.lite.utils.WeakReferenceHandler +import kotlinx.android.synthetic.main.activity_main.* + +class MainActivity : KotlinBaseActivity() { + + companion object { + lateinit var weakReferenceHandler: WeakReferenceHandler + } + + private val kTag = "MainActivity" + private var menuItem: MenuItem? = null + private var fragmentPages: ArrayList = ArrayList() + private var clickTime: Long = 0 + + init { + fragmentPages.add(StatisticsPageFragment()) + fragmentPages.add(MonitorPageFragment()) + fragmentPages.add(AlarmPageFragment()) + } + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + ImmersionBar.with(this).statusBarDarkFont(false).init() + ImmerseStatusBarUtil.setColor(this, R.color.mainThemeColor.convertColor(this)) + } + + override fun initData() { + //推送,多次调用 SDK 初始化并无影响。 + PushManager.getInstance().initialize(this) + weakReferenceHandler = WeakReferenceHandler { + + true + } + } + + override fun observeRequestState() { + + } + + override fun initEvent() { + bottomNavigation.itemIconTintList = null + bottomNavigation.setOnNavigationItemSelectedListener { menuItem -> + when (menuItem.itemId) { + R.id.nav_statistics -> { + mainViewPager.currentItem = 0 + } + R.id.nav_monitor -> { + mainViewPager.currentItem = 1 + } + R.id.nav_alarm -> { + mainViewPager.currentItem = 2 + } + } + false + } + mainViewPager.adapter = ViewPagerAdapter(fragmentPages, supportFragmentManager) + mainViewPager.offscreenPageLimit = fragmentPages.size //缓存页数 + mainViewPager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener { + override fun onPageScrollStateChanged(state: Int) { + + } + + override fun onPageScrolled( + position: Int, + positionOffset: Float, + positionOffsetPixels: Int + ) { + + } + + override fun onPageSelected(position: Int) { + if (menuItem != null) { + menuItem!!.isChecked = false + } else { + bottomNavigation.menu.getItem(0).isChecked = false + } + menuItem = bottomNavigation.menu.getItem(position) + menuItem!!.isChecked = true + } + }) + } + + override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean { + return if (keyCode == KeyEvent.KEYCODE_BACK) { + if (System.currentTimeMillis() - clickTime > 2000) { + "再按一次退出程序".show(this) + clickTime = System.currentTimeMillis() + true + } else { + super.onKeyDown(keyCode, event) + } + } else super.onKeyDown(keyCode, event) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt new file mode 100644 index 0000000..c5d8b22 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.view + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseActivity + +class MonitorRecordActivity : KotlinBaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_monitor_record + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt new file mode 100644 index 0000000..c478d83 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt @@ -0,0 +1,55 @@ +package com.casic.smart.town.sanxi.view + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.amap.api.maps.MapsInitializer +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.gyf.immersionbar.ImmersionBar +import com.pengxh.kt.lite.extensions.navigatePageTo +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + ImmersionBar.with(this).statusBarDarkFont(true).init() + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (EasyPermissions.hasPermissions(this, *LocaleConstant.USER_PERMISSIONS)) { + startSplashScreenActivity() + } else { + EasyPermissions.requestPermissions( + this@PermissionActivity, + resources.getString(R.string.app_name) + "需要获取相关权限", + LocaleConstant.PERMISSIONS_CODE, + *LocaleConstant.USER_PERMISSIONS + ) + } + } + + private fun startSplashScreenActivity() { + //先把导航隐私政策声明,后面导航会用到 + MapsInitializer.updatePrivacyAgree(this, true) + MapsInitializer.updatePrivacyShow(this, true, true) + this.navigatePageTo() + 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) { + startSplashScreenActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable/alarm_selector.xml b/app/src/main/res/drawable/alarm_selector.xml new file mode 100644 index 0000000..39b2595 --- /dev/null +++ b/app/src/main/res/drawable/alarm_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bottom_text_color.xml b/app/src/main/res/drawable/bottom_text_color.xml new file mode 100644 index 0000000..b284ea3 --- /dev/null +++ b/app/src/main/res/drawable/bottom_text_color.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_alarm.xml b/app/src/main/res/drawable/ic_alarm.xml new file mode 100644 index 0000000..dc33aab --- /dev/null +++ b/app/src/main/res/drawable/ic_alarm.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_alarm_selected.xml b/app/src/main/res/drawable/ic_alarm_selected.xml new file mode 100644 index 0000000..993fea6 --- /dev/null +++ b/app/src/main/res/drawable/ic_alarm_selected.xml @@ -0,0 +1,9 @@ + + + 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_monitor.xml b/app/src/main/res/drawable/ic_monitor.xml new file mode 100644 index 0000000..271f5b4 --- /dev/null +++ b/app/src/main/res/drawable/ic_monitor.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_monitor_selected.xml b/app/src/main/res/drawable/ic_monitor_selected.xml new file mode 100644 index 0000000..ee62d84 --- /dev/null +++ b/app/src/main/res/drawable/ic_monitor_selected.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_statistics.xml b/app/src/main/res/drawable/ic_statistics.xml new file mode 100644 index 0000000..7fde8ec --- /dev/null +++ b/app/src/main/res/drawable/ic_statistics.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_statistics_selected.xml b/app/src/main/res/drawable/ic_statistics_selected.xml new file mode 100644 index 0000000..49b6fcd --- /dev/null +++ b/app/src/main/res/drawable/ic_statistics_selected.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/monitor_selector.xml b/app/src/main/res/drawable/monitor_selector.xml new file mode 100644 index 0000000..fe11e9a --- /dev/null +++ b/app/src/main/res/drawable/monitor_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/statistics_selector.xml b/app/src/main/res/drawable/statistics_selector.xml new file mode 100644 index 0000000..2156cff --- /dev/null +++ b/app/src/main/res/drawable/statistics_selector.xml @@ -0,0 +1,5 @@ + + + + + \ 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..78a4a94 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,27 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_monitor_record.xml b/app/src/main/res/layout/activity_monitor_record.xml new file mode 100644 index 0000000..77d9ef6 --- /dev/null +++ b/app/src/main/res/layout/activity_monitor_record.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_alarm.xml b/app/src/main/res/layout/fragment_alarm.xml new file mode 100644 index 0000000..77d9ef6 --- /dev/null +++ b/app/src/main/res/layout/fragment_alarm.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_monitor.xml b/app/src/main/res/layout/fragment_monitor.xml new file mode 100644 index 0000000..19789c1 --- /dev/null +++ b/app/src/main/res/layout/fragment_monitor.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_statistics.xml b/app/src/main/res/layout/fragment_statistics.xml new file mode 100644 index 0000000..77d9ef6 --- /dev/null +++ b/app/src/main/res/layout/fragment_statistics.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/menu/bottom_nav_menu.xml b/app/src/main/res/menu/bottom_nav_menu.xml new file mode 100644 index 0000000..751fd61 --- /dev/null +++ b/app/src/main/res/menu/bottom_nav_menu.xml @@ -0,0 +1,29 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.webp b/app/src/main/res/mipmap-hdpi/ic_launcher.webp new file mode 100644 index 0000000..c209e78 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp new file mode 100644 index 0000000..b2dfe3d --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.webp b/app/src/main/res/mipmap-mdpi/ic_launcher.webp new file mode 100644 index 0000000..4f0f1d6 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp new file mode 100644 index 0000000..62b611d --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp Binary files differ diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..10cfdbf --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*.iml +.gradle +/local.properties +/.idea +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..a4cd2ca --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,101 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'org.greenrobot.greendao' + +android { +// signingConfigs { +// release { +// storeFile file('/Users/a203/Desktop/AndroidProjects/CasicSmartWell/app/CasicSmartWell.jks') +// storePassword '123456789' +// keyAlias 'key0' +// keyPassword '123456789' +// } +// } + compileSdkVersion 31 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.smart.town.sanxi" + minSdkVersion 23 + targetSdkVersion 31 + versionCode 1 + versionName "1.0.0" + + manifestPlaceholders = [GETUI_APPID: "A9V4DvwLcdAqkFCQuFyhq6"] + } + + buildTypes { + release { + minifyEnabled false +// signingConfig signingConfigs.release + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + + ndk { abiFilters "armeabi", "armeabi-v7a", "arm64-v8" } + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlin { + experimental { + coroutines 'enable' + } + } + + greendao { + schemaVersion 1//数据库版本号 + targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 + daoPackage 'com.casic.smart.town.sanxi.greendao'//设置DaoMaster、DaoSession、Dao包名 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + //基础依赖库 + implementation files('libs/lite-release.aar') + implementation 'androidx.appcompat:appcompat:1.4.2' + implementation 'androidx.core:core-ktx:1.8.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:3.0.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' + //MVVM+LiveData + implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.1" + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0" + implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + //Kotlin协程 + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1' + //图片加载框架 + implementation 'com.github.bumptech.glide:glide:4.9.0' + //返回值转换器 + implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' + implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + //okhttp3日志拦截器 + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //网络请求和接口封装 + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.9.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.9.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' + //高德地图 + implementation 'com.amap.api:3dmap:latest.integration' + //推送SDK + implementation 'com.getui:gtsdk:3.2.10.0' //个推SDK + implementation 'com.getui:gtc:3.1.9.0' //个推核心组件 + //数据库框架 + implementation 'org.greenrobot:greendao:3.3.0' + //桌面角标 + implementation "me.leolin:ShortcutBadger:1.1.22@aar" +} \ No newline at end of file diff --git a/app/libs/lite-release.aar b/app/libs/lite-release.aar new file mode 100644 index 0000000..45da4df --- /dev/null +++ b/app/libs/lite-release.aar Binary files differ diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /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 \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..a83c28a --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/svg/monitor.svg b/app/src/main/assets/svg/monitor.svg new file mode 100644 index 0000000..c8d3e25 --- /dev/null +++ b/app/src/main/assets/svg/monitor.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/msg.svg b/app/src/main/assets/svg/msg.svg new file mode 100644 index 0000000..e864e48 --- /dev/null +++ b/app/src/main/assets/svg/msg.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/statistics.svg b/app/src/main/assets/svg/statistics.svg new file mode 100644 index 0000000..974000e --- /dev/null +++ b/app/src/main/assets/svg/statistics.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt new file mode 100644 index 0000000..6b9cce0 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.adapter + +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentManager +import androidx.fragment.app.FragmentPagerAdapter + +class ViewPagerAdapter(list: ArrayList, manager: FragmentManager) : + FragmentPagerAdapter(manager) { + + private var pageList: List = list + + override fun getItem(position: Int) = pageList[position] + + override fun getCount() = pageList.size +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt new file mode 100644 index 0000000..4e017b1 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt @@ -0,0 +1,40 @@ +package com.casic.smart.town.sanxi.base + +import android.app.Application +import android.util.Log +import com.casic.smart.town.sanxi.greendao.DaoMaster +import com.casic.smart.town.sanxi.greendao.DaoSession +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + private val kTag = "BaseApplication" + + companion object { + private var instance: BaseApplication by Delegates.notNull() + + fun obtainInstance() = instance + + private lateinit var daoSession: DaoSession + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences(this) + //推送 + PushManager.getInstance().initialize(this) + PushManager.getInstance().setDebugLogger(this) { + Log.d(kTag, it) + } + val devOpenHelper = DaoMaster.DevOpenHelper(this, "SmartTown.db", null) + val daoMaster = DaoMaster(devOpenHelper.writableDatabase) + daoSession = daoMaster.newSession() + } + + fun obtainDaoSession(): DaoSession { + return daoSession + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java new file mode 100644 index 0000000..b8f67dc --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java @@ -0,0 +1,133 @@ +package com.casic.smart.town.sanxi.bean; + +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Generated; +import org.greenrobot.greendao.annotation.Id; +import org.greenrobot.greendao.annotation.Unique; + +@Entity +public class AlarmMessageLocaleBean { + @Id(autoincrement = true) + private Long id;//主键自增 + + @Unique + private String messageId; + private String appId; + private String clientId; + private String taskId; + private String userId; + private String title; + private String content; + private String deviceCode; + private String isRead;//0-未读,1-已读 + private String alarmTime; + + @Generated(hash = 566950134) + public AlarmMessageLocaleBean(Long id, String messageId, String appId, + String clientId, String taskId, String userId, String title, + String content, String deviceCode, String isRead, String alarmTime) { + this.id = id; + this.messageId = messageId; + this.appId = appId; + this.clientId = clientId; + this.taskId = taskId; + this.userId = userId; + this.title = title; + this.content = content; + this.deviceCode = deviceCode; + this.isRead = isRead; + this.alarmTime = alarmTime; + } + + @Generated(hash = 1737519562) + public AlarmMessageLocaleBean() { + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getMessageId() { + return this.messageId; + } + + public void setMessageId(String messageId) { + this.messageId = messageId; + } + + public String getAppId() { + return this.appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public String getClientId() { + return this.clientId; + } + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public String getTaskId() { + return this.taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getUserId() { + return this.userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getTitle() { + return this.title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return this.content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getDeviceCode() { + return this.deviceCode; + } + + public void setDeviceCode(String deviceCode) { + this.deviceCode = deviceCode; + } + + public String getIsRead() { + return this.isRead; + } + + public void setIsRead(String isRead) { + this.isRead = isRead; + } + + public String getAlarmTime() { + return this.alarmTime; + } + + public void setAlarmTime(String alarmTime) { + this.alarmTime = alarmTime; + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt new file mode 100644 index 0000000..650e201 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class AlarmPageFragment: KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_alarm + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt new file mode 100644 index 0000000..deac8ac --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt @@ -0,0 +1,76 @@ +package com.casic.smart.town.sanxi.fragment + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.Fragment +import com.amap.api.maps.AMap +import com.amap.api.maps.AMapOptions +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.view.MonitorRecordActivity +import com.pengxh.kt.lite.extensions.navigatePageTo +import com.pengxh.kt.lite.extensions.show +import kotlinx.android.synthetic.main.fragment_monitor.view.* + +class MonitorPageFragment : Fragment() { + + private val kTag = "HomePageFragment" + private lateinit var monitorView: View + private lateinit var aMap: AMap + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? + ): View { + monitorView = inflater.inflate(R.layout.fragment_monitor, container, false) + //地图初始化 + initMap(savedInstanceState) + + monitorView.rightOperateView.setOnClickListener { + requireContext().navigatePageTo() + } + return monitorView + } + + private fun initMap(savedInstanceState: Bundle?) { + monitorView.mapView.onCreate(savedInstanceState) + aMap = monitorView.mapView.map + aMap.mapType = AMap.MAP_TYPE_NORMAL + val uiSettings = aMap.uiSettings + uiSettings.isCompassEnabled = true + uiSettings.zoomPosition = AMapOptions.ZOOM_POSITION_RIGHT_CENTER + uiSettings.isTiltGesturesEnabled = false//不许地图随手势倾斜角度 + + // 地图加载成功监听 +// aMap.addOnMapLoadedListener(this) + // 地图缩放监听 +// aMap.addOnCameraChangeListener(this) + // marker 点击事件监听 +// aMap.addOnMarkerClickListener(this) + // 点击marker弹出自定义popup +// aMap.setInfoWindowAdapter(this) + //信息窗点击事件 +// aMap.addOnInfoWindowClickListener(this) + } + + /***以下是地图生命周期管理************************************************************************/ + override fun onResume() { + super.onResume() + monitorView.mapView.onResume() + } + + override fun onPause() { + super.onPause() + monitorView.mapView.onPause() + } + + override fun onSaveInstanceState(outState: Bundle) { + super.onSaveInstanceState(outState) + monitorView.mapView.onSaveInstanceState(outState) + } + + override fun onDestroy() { + super.onDestroy() + monitorView.mapView.onDestroy() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt new file mode 100644 index 0000000..e84df12 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class StatisticsPageFragment : KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_statistics + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java new file mode 100644 index 0000000..68d7901 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java @@ -0,0 +1,255 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.database.Cursor; +import android.database.sqlite.SQLiteStatement; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.Property; +import org.greenrobot.greendao.internal.DaoConfig; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseStatement; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * DAO for table "ALARM_MESSAGE_LOCALE_BEAN". +*/ +public class AlarmMessageLocaleBeanDao extends AbstractDao { + + public static final String TABLENAME = "ALARM_MESSAGE_LOCALE_BEAN"; + + /** + * Properties of entity AlarmMessageLocaleBean.
+ * Can be used for QueryBuilder and for referencing column names. + */ + public static class Properties { + public final static Property Id = new Property(0, Long.class, "id", true, "_id"); + public final static Property MessageId = new Property(1, String.class, "messageId", false, "MESSAGE_ID"); + public final static Property AppId = new Property(2, String.class, "appId", false, "APP_ID"); + public final static Property ClientId = new Property(3, String.class, "clientId", false, "CLIENT_ID"); + public final static Property TaskId = new Property(4, String.class, "taskId", false, "TASK_ID"); + public final static Property UserId = new Property(5, String.class, "userId", false, "USER_ID"); + public final static Property Title = new Property(6, String.class, "title", false, "TITLE"); + public final static Property Content = new Property(7, String.class, "content", false, "CONTENT"); + public final static Property DeviceCode = new Property(8, String.class, "deviceCode", false, "DEVICE_CODE"); + public final static Property IsRead = new Property(9, String.class, "isRead", false, "IS_READ"); + public final static Property AlarmTime = new Property(10, String.class, "alarmTime", false, "ALARM_TIME"); + } + + + public AlarmMessageLocaleBeanDao(DaoConfig config) { + super(config); + } + + public AlarmMessageLocaleBeanDao(DaoConfig config, DaoSession daoSession) { + super(config, daoSession); + } + + /** Creates the underlying database table. */ + public static void createTable(Database db, boolean ifNotExists) { + String constraint = ifNotExists? "IF NOT EXISTS ": ""; + db.execSQL("CREATE TABLE " + constraint + "\"ALARM_MESSAGE_LOCALE_BEAN\" (" + // + "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id + "\"MESSAGE_ID\" TEXT UNIQUE ," + // 1: messageId + "\"APP_ID\" TEXT," + // 2: appId + "\"CLIENT_ID\" TEXT," + // 3: clientId + "\"TASK_ID\" TEXT," + // 4: taskId + "\"USER_ID\" TEXT," + // 5: userId + "\"TITLE\" TEXT," + // 6: title + "\"CONTENT\" TEXT," + // 7: content + "\"DEVICE_CODE\" TEXT," + // 8: deviceCode + "\"IS_READ\" TEXT," + // 9: isRead + "\"ALARM_TIME\" TEXT);"); // 10: alarmTime + } + + /** Drops the underlying database table. */ + public static void dropTable(Database db, boolean ifExists) { + String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"ALARM_MESSAGE_LOCALE_BEAN\""; + db.execSQL(sql); + } + + @Override + protected final void bindValues(DatabaseStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + protected final void bindValues(SQLiteStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + public Long readKey(Cursor cursor, int offset) { + return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); + } + + @Override + public AlarmMessageLocaleBean readEntity(Cursor cursor, int offset) { + AlarmMessageLocaleBean entity = new AlarmMessageLocaleBean( // + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // messageId + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // appId + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // clientId + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // taskId + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // userId + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // title + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // content + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // deviceCode + cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // isRead + cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10) // alarmTime + ); + return entity; + } + + @Override + public void readEntity(Cursor cursor, AlarmMessageLocaleBean entity, int offset) { + entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); + entity.setMessageId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setAppId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setClientId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setTaskId(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); + entity.setUserId(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setTitle(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setContent(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); + entity.setDeviceCode(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); + entity.setIsRead(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9)); + entity.setAlarmTime(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); + } + + @Override + protected final Long updateKeyAfterInsert(AlarmMessageLocaleBean entity, long rowId) { + entity.setId(rowId); + return rowId; + } + + @Override + public Long getKey(AlarmMessageLocaleBean entity) { + if(entity != null) { + return entity.getId(); + } else { + return null; + } + } + + @Override + public boolean hasKey(AlarmMessageLocaleBean entity) { + return entity.getId() != null; + } + + @Override + protected final boolean isEntityUpdateable() { + return true; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java new file mode 100644 index 0000000..4222c40 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java @@ -0,0 +1,96 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.content.Context; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteDatabase.CursorFactory; +import android.util.Log; + +import org.greenrobot.greendao.AbstractDaoMaster; +import org.greenrobot.greendao.database.StandardDatabase; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseOpenHelper; +import org.greenrobot.greendao.identityscope.IdentityScopeType; + + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * Master of DAO (schema version 1): knows all DAOs. + */ +public class DaoMaster extends AbstractDaoMaster { + public static final int SCHEMA_VERSION = 1; + + /** Creates underlying database table using DAOs. */ + public static void createAllTables(Database db, boolean ifNotExists) { + AlarmMessageLocaleBeanDao.createTable(db, ifNotExists); + } + + /** Drops underlying database table using DAOs. */ + public static void dropAllTables(Database db, boolean ifExists) { + AlarmMessageLocaleBeanDao.dropTable(db, ifExists); + } + + /** + * WARNING: Drops all table on Upgrade! Use only during development. + * Convenience method using a {@link DevOpenHelper}. + */ + public static DaoSession newDevSession(Context context, String name) { + Database db = new DevOpenHelper(context, name).getWritableDb(); + DaoMaster daoMaster = new DaoMaster(db); + return daoMaster.newSession(); + } + + public DaoMaster(SQLiteDatabase db) { + this(new StandardDatabase(db)); + } + + public DaoMaster(Database db) { + super(db, SCHEMA_VERSION); + registerDaoClass(AlarmMessageLocaleBeanDao.class); + } + + public DaoSession newSession() { + return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); + } + + public DaoSession newSession(IdentityScopeType type) { + return new DaoSession(db, type, daoConfigMap); + } + + /** + * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} - + */ + public static abstract class OpenHelper extends DatabaseOpenHelper { + public OpenHelper(Context context, String name) { + super(context, name, SCHEMA_VERSION); + } + + public OpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory, SCHEMA_VERSION); + } + + @Override + public void onCreate(Database db) { + Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); + createAllTables(db, false); + } + } + + /** WARNING: Drops all table on Upgrade! Use only during development. */ + public static class DevOpenHelper extends OpenHelper { + public DevOpenHelper(Context context, String name) { + super(context, name); + } + + public DevOpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory); + } + + @Override + public void onUpgrade(Database db, int oldVersion, int newVersion) { + Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); + dropAllTables(db, true); + onCreate(db); + } + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java new file mode 100644 index 0000000..480ed84 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java @@ -0,0 +1,48 @@ +package com.casic.smart.town.sanxi.greendao; + +import java.util.Map; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.AbstractDaoSession; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.identityscope.IdentityScopeType; +import org.greenrobot.greendao.internal.DaoConfig; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. + +/** + * {@inheritDoc} + * + * @see org.greenrobot.greendao.AbstractDaoSession + */ +public class DaoSession extends AbstractDaoSession { + + private final DaoConfig alarmMessageLocaleBeanDaoConfig; + + private final AlarmMessageLocaleBeanDao alarmMessageLocaleBeanDao; + + public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> + daoConfigMap) { + super(db); + + alarmMessageLocaleBeanDaoConfig = daoConfigMap.get(AlarmMessageLocaleBeanDao.class).clone(); + alarmMessageLocaleBeanDaoConfig.initIdentityScope(type); + + alarmMessageLocaleBeanDao = new AlarmMessageLocaleBeanDao(alarmMessageLocaleBeanDaoConfig, this); + + registerDao(AlarmMessageLocaleBean.class, alarmMessageLocaleBeanDao); + } + + public void clear() { + alarmMessageLocaleBeanDaoConfig.clearIdentityScope(); + } + + public AlarmMessageLocaleBeanDao getAlarmMessageLocaleBeanDao() { + return alarmMessageLocaleBeanDao; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt new file mode 100644 index 0000000..875cb8c --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt @@ -0,0 +1,5 @@ +package com.casic.smart.town.sanxi.service + +import com.igexin.sdk.PushService + +class ApplicationPushService : PushService() \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt new file mode 100644 index 0000000..396129f --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt @@ -0,0 +1,84 @@ +package com.casic.smart.town.sanxi.service + +import android.content.Context +import android.os.Message +import android.util.Log +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.casic.smart.town.sanxi.view.MainActivity +import com.igexin.sdk.GTIntentService +import com.igexin.sdk.message.GTCmdMessage +import com.igexin.sdk.message.GTNotificationMessage +import com.igexin.sdk.message.GTTransmitMessage +import com.pengxh.kt.lite.extensions.toJson + +class PushIntentService : GTIntentService() { + + private val kTag = "SmartWellIntentService" + + override fun onReceiveServicePid(context: Context?, pid: Int) { + + } + + // 透传消息 + override fun onReceiveMessageData(context: Context?, msg: GTTransmitMessage?) { + Log.d(kTag, "透传消息 -> msg = $msg") + } + + // 接收 cid + override fun onReceiveClientId(context: Context?, clientid: String?) { + Log.d(kTag, "onReceiveClientId -> $clientid") + //通知MainActivity注册个推服务 + val msg: Message = MainActivity.weakReferenceHandler.obtainMessage() + msg.what = LocaleConstant.PUSH_REGISTER + msg.obj = clientid + MainActivity.weakReferenceHandler.sendMessage(msg) + } + + // cid 离线上线通知 + override fun onReceiveOnlineState(context: Context?, online: Boolean) { + + } + + // 各种事件处理回执 + override fun onReceiveCommandResult(context: Context?, msg: GTCmdMessage?) { + + } + + // 通知到达 + override fun onNotificationMessageArrived(context: Context?, msg: GTNotificationMessage?) { + //报警 +// { +// "content": "设备编号[412022030361]发生井盖开盖报警", +// "messageId": "380abf9a79d34306a2683dc9bf96ee78", +// "taskId": "OSL-0830_4hmfimp3Vu684wo3SjXso9", +// "title": "告警提醒", +// "appid": "HKv8K9qARd6WckZ1o2Vbu4", +// "clientId": "e78beacc42e9a02ae6fb9087eb2b1171", +// "pkgName": "com.casic.app.smartwell" +// } + if (msg == null) { + return + } + Log.d(kTag, "通知到达 -> msg = ${msg.toJson()}") +// val userDetailJson = SaveKeyValues.getValue(LocaleConstant.USER_DETAIL_MODEL, "") as String +// var userId = "" +// if (userDetailJson.isNotBlank()) { +// val userDataModel = Gson().fromJson( +// userDetailJson, object : TypeToken() {}.type +// ) +// userId = userDataModel.id.toString() +// } +// //解析编号 +// val splitArray = msg.content.split("\\[|\\]".toRegex()) +// DataBaseManager.instance.insertNotice( +// msg.messageId, msg.appid, msg.clientId, msg.taskId, +// userId, msg.title, msg.content, splitArray[1], "0", +// System.currentTimeMillis().timestampToCompleteDate() +// ) + } + + // 通知点击 + override fun onNotificationMessageClicked(context: Context?, msg: GTNotificationMessage?) { + Log.d(kTag, "通知点击 -> msg = $msg") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt new file mode 100644 index 0000000..daa7c38 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt @@ -0,0 +1,14 @@ +package com.casic.smart.town.sanxi.util + +import android.content.Context +import me.leolin.shortcutbadger.ShortcutBadger + +object BadeHelper { + fun setBadgeNum(context: Context, badgeCount: Int) { + if (badgeCount == 0) { + ShortcutBadger.removeCount(context) + } else { + ShortcutBadger.applyCount(context, badgeCount) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt new file mode 100644 index 0000000..0a52ef2 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt @@ -0,0 +1,75 @@ +package com.casic.smart.town.sanxi.util + +import com.casic.smart.town.sanxi.base.BaseApplication +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao + +class DataBaseManager private constructor() { + + companion object { + //Kotlin委托模式双重锁单例 + val instance: DataBaseManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) { + DataBaseManager() + } + } + + private val beanDao = + BaseApplication.obtainInstance().obtainDaoSession().alarmMessageLocaleBeanDao + +// fun insertNotice( +// messageId: String, appid: String, clientId: String, +// taskId: String, userId: String, title: String, +// content: String, deviceCode: String, isRead: String, +// noticeTime: String +// ) { +// val noticeLocaleBean = NoticeLocaleBean() +// noticeLocaleBean.messageId = messageId +// noticeLocaleBean.appid = appid +// noticeLocaleBean.clientId = clientId +// noticeLocaleBean.taskId = taskId +// noticeLocaleBean.userId = userId +// noticeLocaleBean.title = title +// noticeLocaleBean.content = content +// noticeLocaleBean.deviceCode = deviceCode +// noticeLocaleBean.isRead = isRead +// noticeLocaleBean.noticeTime = noticeTime +// beanDao.insert(noticeLocaleBean) +// //角标设置 +// BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadNotice()) +// } + + fun deleteByMessageId(messageId: String) { + val result = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).list() + beanDao.deleteInTx(result) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun updateNoticeByMessageId(messageId: String) { + val noticeLocaleBean = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).unique() ?: return + noticeLocaleBean.isRead = "1" + beanDao.update(noticeLocaleBean) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun queryMessageByPage(userId: String, offset: Int): MutableList { + return BaseApplication.obtainInstance().obtainDaoSession() + .queryBuilder(AlarmMessageLocaleBean::class.java) + .where(AlarmMessageLocaleBeanDao.Properties.UserId.eq(userId)) + .offset(offset * LocaleConstant.PAGE_LIMIT) + .orderDesc(AlarmMessageLocaleBeanDao.Properties.AlarmTime) + .limit(LocaleConstant.PAGE_LIMIT) + .list() + } + + private fun queryUnReadMessage(): Int { + return beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.IsRead.eq("0") + ).list().size + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt new file mode 100644 index 0000000..52926a8 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt @@ -0,0 +1,31 @@ +package com.casic.smart.town.sanxi.util; + +import android.app.Activity +import android.view.WindowManager +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object LoadingDialogHub { + private lateinit var loadingDialog: QMUITipDialog + + fun show(activity: Activity, message: String) { + loadingDialog = QMUITipDialog + .Builder(activity) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_LOADING) + .setTipWord(message) + .create() + if (!activity.isDestroyed) { + try { + loadingDialog.show() + } catch (e: WindowManager.BadTokenException) { + e.printStackTrace() + } + } + } + + + fun dismiss() { + if (loadingDialog.isShowing) { + loadingDialog.dismiss() + } + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt new file mode 100644 index 0000000..de61c9a --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.util + +import android.Manifest + +object LocaleConstant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.READ_PHONE_STATE, + Manifest.permission.ACCESS_COARSE_LOCATION, + Manifest.permission.READ_EXTERNAL_STORAGE + ) + + const val PERMISSIONS_CODE = 999 + const val PUSH_REGISTER = 2022100101 + const val PAGE_LIMIT = 20 +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt new file mode 100644 index 0000000..3bea1c9 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt @@ -0,0 +1,112 @@ +package com.casic.smart.town.sanxi.view + +import android.view.KeyEvent +import android.view.MenuItem +import androidx.fragment.app.Fragment +import androidx.viewpager.widget.ViewPager +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.adapter.ViewPagerAdapter +import com.casic.smart.town.sanxi.fragment.AlarmPageFragment +import com.casic.smart.town.sanxi.fragment.MonitorPageFragment +import com.casic.smart.town.sanxi.fragment.StatisticsPageFragment +import com.gyf.immersionbar.ImmersionBar +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.base.KotlinBaseActivity +import com.pengxh.kt.lite.extensions.convertColor +import com.pengxh.kt.lite.extensions.show +import com.pengxh.kt.lite.utils.ImmerseStatusBarUtil +import com.pengxh.kt.lite.utils.WeakReferenceHandler +import kotlinx.android.synthetic.main.activity_main.* + +class MainActivity : KotlinBaseActivity() { + + companion object { + lateinit var weakReferenceHandler: WeakReferenceHandler + } + + private val kTag = "MainActivity" + private var menuItem: MenuItem? = null + private var fragmentPages: ArrayList = ArrayList() + private var clickTime: Long = 0 + + init { + fragmentPages.add(StatisticsPageFragment()) + fragmentPages.add(MonitorPageFragment()) + fragmentPages.add(AlarmPageFragment()) + } + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + ImmersionBar.with(this).statusBarDarkFont(false).init() + ImmerseStatusBarUtil.setColor(this, R.color.mainThemeColor.convertColor(this)) + } + + override fun initData() { + //推送,多次调用 SDK 初始化并无影响。 + PushManager.getInstance().initialize(this) + weakReferenceHandler = WeakReferenceHandler { + + true + } + } + + override fun observeRequestState() { + + } + + override fun initEvent() { + bottomNavigation.itemIconTintList = null + bottomNavigation.setOnNavigationItemSelectedListener { menuItem -> + when (menuItem.itemId) { + R.id.nav_statistics -> { + mainViewPager.currentItem = 0 + } + R.id.nav_monitor -> { + mainViewPager.currentItem = 1 + } + R.id.nav_alarm -> { + mainViewPager.currentItem = 2 + } + } + false + } + mainViewPager.adapter = ViewPagerAdapter(fragmentPages, supportFragmentManager) + mainViewPager.offscreenPageLimit = fragmentPages.size //缓存页数 + mainViewPager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener { + override fun onPageScrollStateChanged(state: Int) { + + } + + override fun onPageScrolled( + position: Int, + positionOffset: Float, + positionOffsetPixels: Int + ) { + + } + + override fun onPageSelected(position: Int) { + if (menuItem != null) { + menuItem!!.isChecked = false + } else { + bottomNavigation.menu.getItem(0).isChecked = false + } + menuItem = bottomNavigation.menu.getItem(position) + menuItem!!.isChecked = true + } + }) + } + + override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean { + return if (keyCode == KeyEvent.KEYCODE_BACK) { + if (System.currentTimeMillis() - clickTime > 2000) { + "再按一次退出程序".show(this) + clickTime = System.currentTimeMillis() + true + } else { + super.onKeyDown(keyCode, event) + } + } else super.onKeyDown(keyCode, event) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt new file mode 100644 index 0000000..c5d8b22 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.view + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseActivity + +class MonitorRecordActivity : KotlinBaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_monitor_record + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt new file mode 100644 index 0000000..c478d83 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt @@ -0,0 +1,55 @@ +package com.casic.smart.town.sanxi.view + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.amap.api.maps.MapsInitializer +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.gyf.immersionbar.ImmersionBar +import com.pengxh.kt.lite.extensions.navigatePageTo +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + ImmersionBar.with(this).statusBarDarkFont(true).init() + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (EasyPermissions.hasPermissions(this, *LocaleConstant.USER_PERMISSIONS)) { + startSplashScreenActivity() + } else { + EasyPermissions.requestPermissions( + this@PermissionActivity, + resources.getString(R.string.app_name) + "需要获取相关权限", + LocaleConstant.PERMISSIONS_CODE, + *LocaleConstant.USER_PERMISSIONS + ) + } + } + + private fun startSplashScreenActivity() { + //先把导航隐私政策声明,后面导航会用到 + MapsInitializer.updatePrivacyAgree(this, true) + MapsInitializer.updatePrivacyShow(this, true, true) + this.navigatePageTo() + 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) { + startSplashScreenActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable/alarm_selector.xml b/app/src/main/res/drawable/alarm_selector.xml new file mode 100644 index 0000000..39b2595 --- /dev/null +++ b/app/src/main/res/drawable/alarm_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bottom_text_color.xml b/app/src/main/res/drawable/bottom_text_color.xml new file mode 100644 index 0000000..b284ea3 --- /dev/null +++ b/app/src/main/res/drawable/bottom_text_color.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_alarm.xml b/app/src/main/res/drawable/ic_alarm.xml new file mode 100644 index 0000000..dc33aab --- /dev/null +++ b/app/src/main/res/drawable/ic_alarm.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_alarm_selected.xml b/app/src/main/res/drawable/ic_alarm_selected.xml new file mode 100644 index 0000000..993fea6 --- /dev/null +++ b/app/src/main/res/drawable/ic_alarm_selected.xml @@ -0,0 +1,9 @@ + + + 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_monitor.xml b/app/src/main/res/drawable/ic_monitor.xml new file mode 100644 index 0000000..271f5b4 --- /dev/null +++ b/app/src/main/res/drawable/ic_monitor.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_monitor_selected.xml b/app/src/main/res/drawable/ic_monitor_selected.xml new file mode 100644 index 0000000..ee62d84 --- /dev/null +++ b/app/src/main/res/drawable/ic_monitor_selected.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_statistics.xml b/app/src/main/res/drawable/ic_statistics.xml new file mode 100644 index 0000000..7fde8ec --- /dev/null +++ b/app/src/main/res/drawable/ic_statistics.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_statistics_selected.xml b/app/src/main/res/drawable/ic_statistics_selected.xml new file mode 100644 index 0000000..49b6fcd --- /dev/null +++ b/app/src/main/res/drawable/ic_statistics_selected.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/monitor_selector.xml b/app/src/main/res/drawable/monitor_selector.xml new file mode 100644 index 0000000..fe11e9a --- /dev/null +++ b/app/src/main/res/drawable/monitor_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/statistics_selector.xml b/app/src/main/res/drawable/statistics_selector.xml new file mode 100644 index 0000000..2156cff --- /dev/null +++ b/app/src/main/res/drawable/statistics_selector.xml @@ -0,0 +1,5 @@ + + + + + \ 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..78a4a94 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,27 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_monitor_record.xml b/app/src/main/res/layout/activity_monitor_record.xml new file mode 100644 index 0000000..77d9ef6 --- /dev/null +++ b/app/src/main/res/layout/activity_monitor_record.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_alarm.xml b/app/src/main/res/layout/fragment_alarm.xml new file mode 100644 index 0000000..77d9ef6 --- /dev/null +++ b/app/src/main/res/layout/fragment_alarm.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_monitor.xml b/app/src/main/res/layout/fragment_monitor.xml new file mode 100644 index 0000000..19789c1 --- /dev/null +++ b/app/src/main/res/layout/fragment_monitor.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_statistics.xml b/app/src/main/res/layout/fragment_statistics.xml new file mode 100644 index 0000000..77d9ef6 --- /dev/null +++ b/app/src/main/res/layout/fragment_statistics.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/menu/bottom_nav_menu.xml b/app/src/main/res/menu/bottom_nav_menu.xml new file mode 100644 index 0000000..751fd61 --- /dev/null +++ b/app/src/main/res/menu/bottom_nav_menu.xml @@ -0,0 +1,29 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.webp b/app/src/main/res/mipmap-hdpi/ic_launcher.webp new file mode 100644 index 0000000..c209e78 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp new file mode 100644 index 0000000..b2dfe3d --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.webp b/app/src/main/res/mipmap-mdpi/ic_launcher.webp new file mode 100644 index 0000000..4f0f1d6 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp new file mode 100644 index 0000000..62b611d --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher.webp new file mode 100644 index 0000000..948a307 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ic_launcher.webp Binary files differ diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..10cfdbf --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*.iml +.gradle +/local.properties +/.idea +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..a4cd2ca --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,101 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'org.greenrobot.greendao' + +android { +// signingConfigs { +// release { +// storeFile file('/Users/a203/Desktop/AndroidProjects/CasicSmartWell/app/CasicSmartWell.jks') +// storePassword '123456789' +// keyAlias 'key0' +// keyPassword '123456789' +// } +// } + compileSdkVersion 31 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.smart.town.sanxi" + minSdkVersion 23 + targetSdkVersion 31 + versionCode 1 + versionName "1.0.0" + + manifestPlaceholders = [GETUI_APPID: "A9V4DvwLcdAqkFCQuFyhq6"] + } + + buildTypes { + release { + minifyEnabled false +// signingConfig signingConfigs.release + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + + ndk { abiFilters "armeabi", "armeabi-v7a", "arm64-v8" } + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlin { + experimental { + coroutines 'enable' + } + } + + greendao { + schemaVersion 1//数据库版本号 + targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 + daoPackage 'com.casic.smart.town.sanxi.greendao'//设置DaoMaster、DaoSession、Dao包名 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + //基础依赖库 + implementation files('libs/lite-release.aar') + implementation 'androidx.appcompat:appcompat:1.4.2' + implementation 'androidx.core:core-ktx:1.8.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:3.0.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' + //MVVM+LiveData + implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.1" + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0" + implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + //Kotlin协程 + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1' + //图片加载框架 + implementation 'com.github.bumptech.glide:glide:4.9.0' + //返回值转换器 + implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' + implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + //okhttp3日志拦截器 + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //网络请求和接口封装 + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.9.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.9.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' + //高德地图 + implementation 'com.amap.api:3dmap:latest.integration' + //推送SDK + implementation 'com.getui:gtsdk:3.2.10.0' //个推SDK + implementation 'com.getui:gtc:3.1.9.0' //个推核心组件 + //数据库框架 + implementation 'org.greenrobot:greendao:3.3.0' + //桌面角标 + implementation "me.leolin:ShortcutBadger:1.1.22@aar" +} \ No newline at end of file diff --git a/app/libs/lite-release.aar b/app/libs/lite-release.aar new file mode 100644 index 0000000..45da4df --- /dev/null +++ b/app/libs/lite-release.aar Binary files differ diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /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 \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..a83c28a --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/svg/monitor.svg b/app/src/main/assets/svg/monitor.svg new file mode 100644 index 0000000..c8d3e25 --- /dev/null +++ b/app/src/main/assets/svg/monitor.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/msg.svg b/app/src/main/assets/svg/msg.svg new file mode 100644 index 0000000..e864e48 --- /dev/null +++ b/app/src/main/assets/svg/msg.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/statistics.svg b/app/src/main/assets/svg/statistics.svg new file mode 100644 index 0000000..974000e --- /dev/null +++ b/app/src/main/assets/svg/statistics.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt new file mode 100644 index 0000000..6b9cce0 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.adapter + +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentManager +import androidx.fragment.app.FragmentPagerAdapter + +class ViewPagerAdapter(list: ArrayList, manager: FragmentManager) : + FragmentPagerAdapter(manager) { + + private var pageList: List = list + + override fun getItem(position: Int) = pageList[position] + + override fun getCount() = pageList.size +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt new file mode 100644 index 0000000..4e017b1 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt @@ -0,0 +1,40 @@ +package com.casic.smart.town.sanxi.base + +import android.app.Application +import android.util.Log +import com.casic.smart.town.sanxi.greendao.DaoMaster +import com.casic.smart.town.sanxi.greendao.DaoSession +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + private val kTag = "BaseApplication" + + companion object { + private var instance: BaseApplication by Delegates.notNull() + + fun obtainInstance() = instance + + private lateinit var daoSession: DaoSession + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences(this) + //推送 + PushManager.getInstance().initialize(this) + PushManager.getInstance().setDebugLogger(this) { + Log.d(kTag, it) + } + val devOpenHelper = DaoMaster.DevOpenHelper(this, "SmartTown.db", null) + val daoMaster = DaoMaster(devOpenHelper.writableDatabase) + daoSession = daoMaster.newSession() + } + + fun obtainDaoSession(): DaoSession { + return daoSession + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java new file mode 100644 index 0000000..b8f67dc --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java @@ -0,0 +1,133 @@ +package com.casic.smart.town.sanxi.bean; + +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Generated; +import org.greenrobot.greendao.annotation.Id; +import org.greenrobot.greendao.annotation.Unique; + +@Entity +public class AlarmMessageLocaleBean { + @Id(autoincrement = true) + private Long id;//主键自增 + + @Unique + private String messageId; + private String appId; + private String clientId; + private String taskId; + private String userId; + private String title; + private String content; + private String deviceCode; + private String isRead;//0-未读,1-已读 + private String alarmTime; + + @Generated(hash = 566950134) + public AlarmMessageLocaleBean(Long id, String messageId, String appId, + String clientId, String taskId, String userId, String title, + String content, String deviceCode, String isRead, String alarmTime) { + this.id = id; + this.messageId = messageId; + this.appId = appId; + this.clientId = clientId; + this.taskId = taskId; + this.userId = userId; + this.title = title; + this.content = content; + this.deviceCode = deviceCode; + this.isRead = isRead; + this.alarmTime = alarmTime; + } + + @Generated(hash = 1737519562) + public AlarmMessageLocaleBean() { + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getMessageId() { + return this.messageId; + } + + public void setMessageId(String messageId) { + this.messageId = messageId; + } + + public String getAppId() { + return this.appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public String getClientId() { + return this.clientId; + } + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public String getTaskId() { + return this.taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getUserId() { + return this.userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getTitle() { + return this.title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return this.content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getDeviceCode() { + return this.deviceCode; + } + + public void setDeviceCode(String deviceCode) { + this.deviceCode = deviceCode; + } + + public String getIsRead() { + return this.isRead; + } + + public void setIsRead(String isRead) { + this.isRead = isRead; + } + + public String getAlarmTime() { + return this.alarmTime; + } + + public void setAlarmTime(String alarmTime) { + this.alarmTime = alarmTime; + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt new file mode 100644 index 0000000..650e201 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class AlarmPageFragment: KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_alarm + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt new file mode 100644 index 0000000..deac8ac --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt @@ -0,0 +1,76 @@ +package com.casic.smart.town.sanxi.fragment + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.Fragment +import com.amap.api.maps.AMap +import com.amap.api.maps.AMapOptions +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.view.MonitorRecordActivity +import com.pengxh.kt.lite.extensions.navigatePageTo +import com.pengxh.kt.lite.extensions.show +import kotlinx.android.synthetic.main.fragment_monitor.view.* + +class MonitorPageFragment : Fragment() { + + private val kTag = "HomePageFragment" + private lateinit var monitorView: View + private lateinit var aMap: AMap + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? + ): View { + monitorView = inflater.inflate(R.layout.fragment_monitor, container, false) + //地图初始化 + initMap(savedInstanceState) + + monitorView.rightOperateView.setOnClickListener { + requireContext().navigatePageTo() + } + return monitorView + } + + private fun initMap(savedInstanceState: Bundle?) { + monitorView.mapView.onCreate(savedInstanceState) + aMap = monitorView.mapView.map + aMap.mapType = AMap.MAP_TYPE_NORMAL + val uiSettings = aMap.uiSettings + uiSettings.isCompassEnabled = true + uiSettings.zoomPosition = AMapOptions.ZOOM_POSITION_RIGHT_CENTER + uiSettings.isTiltGesturesEnabled = false//不许地图随手势倾斜角度 + + // 地图加载成功监听 +// aMap.addOnMapLoadedListener(this) + // 地图缩放监听 +// aMap.addOnCameraChangeListener(this) + // marker 点击事件监听 +// aMap.addOnMarkerClickListener(this) + // 点击marker弹出自定义popup +// aMap.setInfoWindowAdapter(this) + //信息窗点击事件 +// aMap.addOnInfoWindowClickListener(this) + } + + /***以下是地图生命周期管理************************************************************************/ + override fun onResume() { + super.onResume() + monitorView.mapView.onResume() + } + + override fun onPause() { + super.onPause() + monitorView.mapView.onPause() + } + + override fun onSaveInstanceState(outState: Bundle) { + super.onSaveInstanceState(outState) + monitorView.mapView.onSaveInstanceState(outState) + } + + override fun onDestroy() { + super.onDestroy() + monitorView.mapView.onDestroy() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt new file mode 100644 index 0000000..e84df12 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class StatisticsPageFragment : KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_statistics + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java new file mode 100644 index 0000000..68d7901 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java @@ -0,0 +1,255 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.database.Cursor; +import android.database.sqlite.SQLiteStatement; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.Property; +import org.greenrobot.greendao.internal.DaoConfig; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseStatement; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * DAO for table "ALARM_MESSAGE_LOCALE_BEAN". +*/ +public class AlarmMessageLocaleBeanDao extends AbstractDao { + + public static final String TABLENAME = "ALARM_MESSAGE_LOCALE_BEAN"; + + /** + * Properties of entity AlarmMessageLocaleBean.
+ * Can be used for QueryBuilder and for referencing column names. + */ + public static class Properties { + public final static Property Id = new Property(0, Long.class, "id", true, "_id"); + public final static Property MessageId = new Property(1, String.class, "messageId", false, "MESSAGE_ID"); + public final static Property AppId = new Property(2, String.class, "appId", false, "APP_ID"); + public final static Property ClientId = new Property(3, String.class, "clientId", false, "CLIENT_ID"); + public final static Property TaskId = new Property(4, String.class, "taskId", false, "TASK_ID"); + public final static Property UserId = new Property(5, String.class, "userId", false, "USER_ID"); + public final static Property Title = new Property(6, String.class, "title", false, "TITLE"); + public final static Property Content = new Property(7, String.class, "content", false, "CONTENT"); + public final static Property DeviceCode = new Property(8, String.class, "deviceCode", false, "DEVICE_CODE"); + public final static Property IsRead = new Property(9, String.class, "isRead", false, "IS_READ"); + public final static Property AlarmTime = new Property(10, String.class, "alarmTime", false, "ALARM_TIME"); + } + + + public AlarmMessageLocaleBeanDao(DaoConfig config) { + super(config); + } + + public AlarmMessageLocaleBeanDao(DaoConfig config, DaoSession daoSession) { + super(config, daoSession); + } + + /** Creates the underlying database table. */ + public static void createTable(Database db, boolean ifNotExists) { + String constraint = ifNotExists? "IF NOT EXISTS ": ""; + db.execSQL("CREATE TABLE " + constraint + "\"ALARM_MESSAGE_LOCALE_BEAN\" (" + // + "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id + "\"MESSAGE_ID\" TEXT UNIQUE ," + // 1: messageId + "\"APP_ID\" TEXT," + // 2: appId + "\"CLIENT_ID\" TEXT," + // 3: clientId + "\"TASK_ID\" TEXT," + // 4: taskId + "\"USER_ID\" TEXT," + // 5: userId + "\"TITLE\" TEXT," + // 6: title + "\"CONTENT\" TEXT," + // 7: content + "\"DEVICE_CODE\" TEXT," + // 8: deviceCode + "\"IS_READ\" TEXT," + // 9: isRead + "\"ALARM_TIME\" TEXT);"); // 10: alarmTime + } + + /** Drops the underlying database table. */ + public static void dropTable(Database db, boolean ifExists) { + String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"ALARM_MESSAGE_LOCALE_BEAN\""; + db.execSQL(sql); + } + + @Override + protected final void bindValues(DatabaseStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + protected final void bindValues(SQLiteStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + public Long readKey(Cursor cursor, int offset) { + return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); + } + + @Override + public AlarmMessageLocaleBean readEntity(Cursor cursor, int offset) { + AlarmMessageLocaleBean entity = new AlarmMessageLocaleBean( // + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // messageId + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // appId + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // clientId + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // taskId + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // userId + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // title + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // content + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // deviceCode + cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // isRead + cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10) // alarmTime + ); + return entity; + } + + @Override + public void readEntity(Cursor cursor, AlarmMessageLocaleBean entity, int offset) { + entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); + entity.setMessageId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setAppId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setClientId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setTaskId(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); + entity.setUserId(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setTitle(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setContent(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); + entity.setDeviceCode(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); + entity.setIsRead(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9)); + entity.setAlarmTime(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); + } + + @Override + protected final Long updateKeyAfterInsert(AlarmMessageLocaleBean entity, long rowId) { + entity.setId(rowId); + return rowId; + } + + @Override + public Long getKey(AlarmMessageLocaleBean entity) { + if(entity != null) { + return entity.getId(); + } else { + return null; + } + } + + @Override + public boolean hasKey(AlarmMessageLocaleBean entity) { + return entity.getId() != null; + } + + @Override + protected final boolean isEntityUpdateable() { + return true; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java new file mode 100644 index 0000000..4222c40 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java @@ -0,0 +1,96 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.content.Context; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteDatabase.CursorFactory; +import android.util.Log; + +import org.greenrobot.greendao.AbstractDaoMaster; +import org.greenrobot.greendao.database.StandardDatabase; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseOpenHelper; +import org.greenrobot.greendao.identityscope.IdentityScopeType; + + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * Master of DAO (schema version 1): knows all DAOs. + */ +public class DaoMaster extends AbstractDaoMaster { + public static final int SCHEMA_VERSION = 1; + + /** Creates underlying database table using DAOs. */ + public static void createAllTables(Database db, boolean ifNotExists) { + AlarmMessageLocaleBeanDao.createTable(db, ifNotExists); + } + + /** Drops underlying database table using DAOs. */ + public static void dropAllTables(Database db, boolean ifExists) { + AlarmMessageLocaleBeanDao.dropTable(db, ifExists); + } + + /** + * WARNING: Drops all table on Upgrade! Use only during development. + * Convenience method using a {@link DevOpenHelper}. + */ + public static DaoSession newDevSession(Context context, String name) { + Database db = new DevOpenHelper(context, name).getWritableDb(); + DaoMaster daoMaster = new DaoMaster(db); + return daoMaster.newSession(); + } + + public DaoMaster(SQLiteDatabase db) { + this(new StandardDatabase(db)); + } + + public DaoMaster(Database db) { + super(db, SCHEMA_VERSION); + registerDaoClass(AlarmMessageLocaleBeanDao.class); + } + + public DaoSession newSession() { + return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); + } + + public DaoSession newSession(IdentityScopeType type) { + return new DaoSession(db, type, daoConfigMap); + } + + /** + * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} - + */ + public static abstract class OpenHelper extends DatabaseOpenHelper { + public OpenHelper(Context context, String name) { + super(context, name, SCHEMA_VERSION); + } + + public OpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory, SCHEMA_VERSION); + } + + @Override + public void onCreate(Database db) { + Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); + createAllTables(db, false); + } + } + + /** WARNING: Drops all table on Upgrade! Use only during development. */ + public static class DevOpenHelper extends OpenHelper { + public DevOpenHelper(Context context, String name) { + super(context, name); + } + + public DevOpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory); + } + + @Override + public void onUpgrade(Database db, int oldVersion, int newVersion) { + Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); + dropAllTables(db, true); + onCreate(db); + } + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java new file mode 100644 index 0000000..480ed84 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java @@ -0,0 +1,48 @@ +package com.casic.smart.town.sanxi.greendao; + +import java.util.Map; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.AbstractDaoSession; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.identityscope.IdentityScopeType; +import org.greenrobot.greendao.internal.DaoConfig; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. + +/** + * {@inheritDoc} + * + * @see org.greenrobot.greendao.AbstractDaoSession + */ +public class DaoSession extends AbstractDaoSession { + + private final DaoConfig alarmMessageLocaleBeanDaoConfig; + + private final AlarmMessageLocaleBeanDao alarmMessageLocaleBeanDao; + + public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> + daoConfigMap) { + super(db); + + alarmMessageLocaleBeanDaoConfig = daoConfigMap.get(AlarmMessageLocaleBeanDao.class).clone(); + alarmMessageLocaleBeanDaoConfig.initIdentityScope(type); + + alarmMessageLocaleBeanDao = new AlarmMessageLocaleBeanDao(alarmMessageLocaleBeanDaoConfig, this); + + registerDao(AlarmMessageLocaleBean.class, alarmMessageLocaleBeanDao); + } + + public void clear() { + alarmMessageLocaleBeanDaoConfig.clearIdentityScope(); + } + + public AlarmMessageLocaleBeanDao getAlarmMessageLocaleBeanDao() { + return alarmMessageLocaleBeanDao; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt new file mode 100644 index 0000000..875cb8c --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt @@ -0,0 +1,5 @@ +package com.casic.smart.town.sanxi.service + +import com.igexin.sdk.PushService + +class ApplicationPushService : PushService() \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt new file mode 100644 index 0000000..396129f --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt @@ -0,0 +1,84 @@ +package com.casic.smart.town.sanxi.service + +import android.content.Context +import android.os.Message +import android.util.Log +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.casic.smart.town.sanxi.view.MainActivity +import com.igexin.sdk.GTIntentService +import com.igexin.sdk.message.GTCmdMessage +import com.igexin.sdk.message.GTNotificationMessage +import com.igexin.sdk.message.GTTransmitMessage +import com.pengxh.kt.lite.extensions.toJson + +class PushIntentService : GTIntentService() { + + private val kTag = "SmartWellIntentService" + + override fun onReceiveServicePid(context: Context?, pid: Int) { + + } + + // 透传消息 + override fun onReceiveMessageData(context: Context?, msg: GTTransmitMessage?) { + Log.d(kTag, "透传消息 -> msg = $msg") + } + + // 接收 cid + override fun onReceiveClientId(context: Context?, clientid: String?) { + Log.d(kTag, "onReceiveClientId -> $clientid") + //通知MainActivity注册个推服务 + val msg: Message = MainActivity.weakReferenceHandler.obtainMessage() + msg.what = LocaleConstant.PUSH_REGISTER + msg.obj = clientid + MainActivity.weakReferenceHandler.sendMessage(msg) + } + + // cid 离线上线通知 + override fun onReceiveOnlineState(context: Context?, online: Boolean) { + + } + + // 各种事件处理回执 + override fun onReceiveCommandResult(context: Context?, msg: GTCmdMessage?) { + + } + + // 通知到达 + override fun onNotificationMessageArrived(context: Context?, msg: GTNotificationMessage?) { + //报警 +// { +// "content": "设备编号[412022030361]发生井盖开盖报警", +// "messageId": "380abf9a79d34306a2683dc9bf96ee78", +// "taskId": "OSL-0830_4hmfimp3Vu684wo3SjXso9", +// "title": "告警提醒", +// "appid": "HKv8K9qARd6WckZ1o2Vbu4", +// "clientId": "e78beacc42e9a02ae6fb9087eb2b1171", +// "pkgName": "com.casic.app.smartwell" +// } + if (msg == null) { + return + } + Log.d(kTag, "通知到达 -> msg = ${msg.toJson()}") +// val userDetailJson = SaveKeyValues.getValue(LocaleConstant.USER_DETAIL_MODEL, "") as String +// var userId = "" +// if (userDetailJson.isNotBlank()) { +// val userDataModel = Gson().fromJson( +// userDetailJson, object : TypeToken() {}.type +// ) +// userId = userDataModel.id.toString() +// } +// //解析编号 +// val splitArray = msg.content.split("\\[|\\]".toRegex()) +// DataBaseManager.instance.insertNotice( +// msg.messageId, msg.appid, msg.clientId, msg.taskId, +// userId, msg.title, msg.content, splitArray[1], "0", +// System.currentTimeMillis().timestampToCompleteDate() +// ) + } + + // 通知点击 + override fun onNotificationMessageClicked(context: Context?, msg: GTNotificationMessage?) { + Log.d(kTag, "通知点击 -> msg = $msg") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt new file mode 100644 index 0000000..daa7c38 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt @@ -0,0 +1,14 @@ +package com.casic.smart.town.sanxi.util + +import android.content.Context +import me.leolin.shortcutbadger.ShortcutBadger + +object BadeHelper { + fun setBadgeNum(context: Context, badgeCount: Int) { + if (badgeCount == 0) { + ShortcutBadger.removeCount(context) + } else { + ShortcutBadger.applyCount(context, badgeCount) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt new file mode 100644 index 0000000..0a52ef2 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt @@ -0,0 +1,75 @@ +package com.casic.smart.town.sanxi.util + +import com.casic.smart.town.sanxi.base.BaseApplication +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao + +class DataBaseManager private constructor() { + + companion object { + //Kotlin委托模式双重锁单例 + val instance: DataBaseManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) { + DataBaseManager() + } + } + + private val beanDao = + BaseApplication.obtainInstance().obtainDaoSession().alarmMessageLocaleBeanDao + +// fun insertNotice( +// messageId: String, appid: String, clientId: String, +// taskId: String, userId: String, title: String, +// content: String, deviceCode: String, isRead: String, +// noticeTime: String +// ) { +// val noticeLocaleBean = NoticeLocaleBean() +// noticeLocaleBean.messageId = messageId +// noticeLocaleBean.appid = appid +// noticeLocaleBean.clientId = clientId +// noticeLocaleBean.taskId = taskId +// noticeLocaleBean.userId = userId +// noticeLocaleBean.title = title +// noticeLocaleBean.content = content +// noticeLocaleBean.deviceCode = deviceCode +// noticeLocaleBean.isRead = isRead +// noticeLocaleBean.noticeTime = noticeTime +// beanDao.insert(noticeLocaleBean) +// //角标设置 +// BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadNotice()) +// } + + fun deleteByMessageId(messageId: String) { + val result = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).list() + beanDao.deleteInTx(result) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun updateNoticeByMessageId(messageId: String) { + val noticeLocaleBean = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).unique() ?: return + noticeLocaleBean.isRead = "1" + beanDao.update(noticeLocaleBean) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun queryMessageByPage(userId: String, offset: Int): MutableList { + return BaseApplication.obtainInstance().obtainDaoSession() + .queryBuilder(AlarmMessageLocaleBean::class.java) + .where(AlarmMessageLocaleBeanDao.Properties.UserId.eq(userId)) + .offset(offset * LocaleConstant.PAGE_LIMIT) + .orderDesc(AlarmMessageLocaleBeanDao.Properties.AlarmTime) + .limit(LocaleConstant.PAGE_LIMIT) + .list() + } + + private fun queryUnReadMessage(): Int { + return beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.IsRead.eq("0") + ).list().size + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt new file mode 100644 index 0000000..52926a8 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt @@ -0,0 +1,31 @@ +package com.casic.smart.town.sanxi.util; + +import android.app.Activity +import android.view.WindowManager +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object LoadingDialogHub { + private lateinit var loadingDialog: QMUITipDialog + + fun show(activity: Activity, message: String) { + loadingDialog = QMUITipDialog + .Builder(activity) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_LOADING) + .setTipWord(message) + .create() + if (!activity.isDestroyed) { + try { + loadingDialog.show() + } catch (e: WindowManager.BadTokenException) { + e.printStackTrace() + } + } + } + + + fun dismiss() { + if (loadingDialog.isShowing) { + loadingDialog.dismiss() + } + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt new file mode 100644 index 0000000..de61c9a --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.util + +import android.Manifest + +object LocaleConstant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.READ_PHONE_STATE, + Manifest.permission.ACCESS_COARSE_LOCATION, + Manifest.permission.READ_EXTERNAL_STORAGE + ) + + const val PERMISSIONS_CODE = 999 + const val PUSH_REGISTER = 2022100101 + const val PAGE_LIMIT = 20 +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt new file mode 100644 index 0000000..3bea1c9 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt @@ -0,0 +1,112 @@ +package com.casic.smart.town.sanxi.view + +import android.view.KeyEvent +import android.view.MenuItem +import androidx.fragment.app.Fragment +import androidx.viewpager.widget.ViewPager +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.adapter.ViewPagerAdapter +import com.casic.smart.town.sanxi.fragment.AlarmPageFragment +import com.casic.smart.town.sanxi.fragment.MonitorPageFragment +import com.casic.smart.town.sanxi.fragment.StatisticsPageFragment +import com.gyf.immersionbar.ImmersionBar +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.base.KotlinBaseActivity +import com.pengxh.kt.lite.extensions.convertColor +import com.pengxh.kt.lite.extensions.show +import com.pengxh.kt.lite.utils.ImmerseStatusBarUtil +import com.pengxh.kt.lite.utils.WeakReferenceHandler +import kotlinx.android.synthetic.main.activity_main.* + +class MainActivity : KotlinBaseActivity() { + + companion object { + lateinit var weakReferenceHandler: WeakReferenceHandler + } + + private val kTag = "MainActivity" + private var menuItem: MenuItem? = null + private var fragmentPages: ArrayList = ArrayList() + private var clickTime: Long = 0 + + init { + fragmentPages.add(StatisticsPageFragment()) + fragmentPages.add(MonitorPageFragment()) + fragmentPages.add(AlarmPageFragment()) + } + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + ImmersionBar.with(this).statusBarDarkFont(false).init() + ImmerseStatusBarUtil.setColor(this, R.color.mainThemeColor.convertColor(this)) + } + + override fun initData() { + //推送,多次调用 SDK 初始化并无影响。 + PushManager.getInstance().initialize(this) + weakReferenceHandler = WeakReferenceHandler { + + true + } + } + + override fun observeRequestState() { + + } + + override fun initEvent() { + bottomNavigation.itemIconTintList = null + bottomNavigation.setOnNavigationItemSelectedListener { menuItem -> + when (menuItem.itemId) { + R.id.nav_statistics -> { + mainViewPager.currentItem = 0 + } + R.id.nav_monitor -> { + mainViewPager.currentItem = 1 + } + R.id.nav_alarm -> { + mainViewPager.currentItem = 2 + } + } + false + } + mainViewPager.adapter = ViewPagerAdapter(fragmentPages, supportFragmentManager) + mainViewPager.offscreenPageLimit = fragmentPages.size //缓存页数 + mainViewPager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener { + override fun onPageScrollStateChanged(state: Int) { + + } + + override fun onPageScrolled( + position: Int, + positionOffset: Float, + positionOffsetPixels: Int + ) { + + } + + override fun onPageSelected(position: Int) { + if (menuItem != null) { + menuItem!!.isChecked = false + } else { + bottomNavigation.menu.getItem(0).isChecked = false + } + menuItem = bottomNavigation.menu.getItem(position) + menuItem!!.isChecked = true + } + }) + } + + override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean { + return if (keyCode == KeyEvent.KEYCODE_BACK) { + if (System.currentTimeMillis() - clickTime > 2000) { + "再按一次退出程序".show(this) + clickTime = System.currentTimeMillis() + true + } else { + super.onKeyDown(keyCode, event) + } + } else super.onKeyDown(keyCode, event) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt new file mode 100644 index 0000000..c5d8b22 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.view + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseActivity + +class MonitorRecordActivity : KotlinBaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_monitor_record + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt new file mode 100644 index 0000000..c478d83 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt @@ -0,0 +1,55 @@ +package com.casic.smart.town.sanxi.view + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.amap.api.maps.MapsInitializer +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.gyf.immersionbar.ImmersionBar +import com.pengxh.kt.lite.extensions.navigatePageTo +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + ImmersionBar.with(this).statusBarDarkFont(true).init() + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (EasyPermissions.hasPermissions(this, *LocaleConstant.USER_PERMISSIONS)) { + startSplashScreenActivity() + } else { + EasyPermissions.requestPermissions( + this@PermissionActivity, + resources.getString(R.string.app_name) + "需要获取相关权限", + LocaleConstant.PERMISSIONS_CODE, + *LocaleConstant.USER_PERMISSIONS + ) + } + } + + private fun startSplashScreenActivity() { + //先把导航隐私政策声明,后面导航会用到 + MapsInitializer.updatePrivacyAgree(this, true) + MapsInitializer.updatePrivacyShow(this, true, true) + this.navigatePageTo() + 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) { + startSplashScreenActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable/alarm_selector.xml b/app/src/main/res/drawable/alarm_selector.xml new file mode 100644 index 0000000..39b2595 --- /dev/null +++ b/app/src/main/res/drawable/alarm_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bottom_text_color.xml b/app/src/main/res/drawable/bottom_text_color.xml new file mode 100644 index 0000000..b284ea3 --- /dev/null +++ b/app/src/main/res/drawable/bottom_text_color.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_alarm.xml b/app/src/main/res/drawable/ic_alarm.xml new file mode 100644 index 0000000..dc33aab --- /dev/null +++ b/app/src/main/res/drawable/ic_alarm.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_alarm_selected.xml b/app/src/main/res/drawable/ic_alarm_selected.xml new file mode 100644 index 0000000..993fea6 --- /dev/null +++ b/app/src/main/res/drawable/ic_alarm_selected.xml @@ -0,0 +1,9 @@ + + + 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_monitor.xml b/app/src/main/res/drawable/ic_monitor.xml new file mode 100644 index 0000000..271f5b4 --- /dev/null +++ b/app/src/main/res/drawable/ic_monitor.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_monitor_selected.xml b/app/src/main/res/drawable/ic_monitor_selected.xml new file mode 100644 index 0000000..ee62d84 --- /dev/null +++ b/app/src/main/res/drawable/ic_monitor_selected.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_statistics.xml b/app/src/main/res/drawable/ic_statistics.xml new file mode 100644 index 0000000..7fde8ec --- /dev/null +++ b/app/src/main/res/drawable/ic_statistics.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_statistics_selected.xml b/app/src/main/res/drawable/ic_statistics_selected.xml new file mode 100644 index 0000000..49b6fcd --- /dev/null +++ b/app/src/main/res/drawable/ic_statistics_selected.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/monitor_selector.xml b/app/src/main/res/drawable/monitor_selector.xml new file mode 100644 index 0000000..fe11e9a --- /dev/null +++ b/app/src/main/res/drawable/monitor_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/statistics_selector.xml b/app/src/main/res/drawable/statistics_selector.xml new file mode 100644 index 0000000..2156cff --- /dev/null +++ b/app/src/main/res/drawable/statistics_selector.xml @@ -0,0 +1,5 @@ + + + + + \ 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..78a4a94 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,27 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_monitor_record.xml b/app/src/main/res/layout/activity_monitor_record.xml new file mode 100644 index 0000000..77d9ef6 --- /dev/null +++ b/app/src/main/res/layout/activity_monitor_record.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_alarm.xml b/app/src/main/res/layout/fragment_alarm.xml new file mode 100644 index 0000000..77d9ef6 --- /dev/null +++ b/app/src/main/res/layout/fragment_alarm.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_monitor.xml b/app/src/main/res/layout/fragment_monitor.xml new file mode 100644 index 0000000..19789c1 --- /dev/null +++ b/app/src/main/res/layout/fragment_monitor.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_statistics.xml b/app/src/main/res/layout/fragment_statistics.xml new file mode 100644 index 0000000..77d9ef6 --- /dev/null +++ b/app/src/main/res/layout/fragment_statistics.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/menu/bottom_nav_menu.xml b/app/src/main/res/menu/bottom_nav_menu.xml new file mode 100644 index 0000000..751fd61 --- /dev/null +++ b/app/src/main/res/menu/bottom_nav_menu.xml @@ -0,0 +1,29 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.webp b/app/src/main/res/mipmap-hdpi/ic_launcher.webp new file mode 100644 index 0000000..c209e78 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp new file mode 100644 index 0000000..b2dfe3d --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.webp b/app/src/main/res/mipmap-mdpi/ic_launcher.webp new file mode 100644 index 0000000..4f0f1d6 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp new file mode 100644 index 0000000..62b611d --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher.webp new file mode 100644 index 0000000..948a307 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..1b9a695 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp Binary files differ diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..10cfdbf --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*.iml +.gradle +/local.properties +/.idea +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..a4cd2ca --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,101 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'org.greenrobot.greendao' + +android { +// signingConfigs { +// release { +// storeFile file('/Users/a203/Desktop/AndroidProjects/CasicSmartWell/app/CasicSmartWell.jks') +// storePassword '123456789' +// keyAlias 'key0' +// keyPassword '123456789' +// } +// } + compileSdkVersion 31 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.smart.town.sanxi" + minSdkVersion 23 + targetSdkVersion 31 + versionCode 1 + versionName "1.0.0" + + manifestPlaceholders = [GETUI_APPID: "A9V4DvwLcdAqkFCQuFyhq6"] + } + + buildTypes { + release { + minifyEnabled false +// signingConfig signingConfigs.release + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + + ndk { abiFilters "armeabi", "armeabi-v7a", "arm64-v8" } + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlin { + experimental { + coroutines 'enable' + } + } + + greendao { + schemaVersion 1//数据库版本号 + targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 + daoPackage 'com.casic.smart.town.sanxi.greendao'//设置DaoMaster、DaoSession、Dao包名 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + //基础依赖库 + implementation files('libs/lite-release.aar') + implementation 'androidx.appcompat:appcompat:1.4.2' + implementation 'androidx.core:core-ktx:1.8.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:3.0.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' + //MVVM+LiveData + implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.1" + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0" + implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + //Kotlin协程 + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1' + //图片加载框架 + implementation 'com.github.bumptech.glide:glide:4.9.0' + //返回值转换器 + implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' + implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + //okhttp3日志拦截器 + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //网络请求和接口封装 + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.9.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.9.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' + //高德地图 + implementation 'com.amap.api:3dmap:latest.integration' + //推送SDK + implementation 'com.getui:gtsdk:3.2.10.0' //个推SDK + implementation 'com.getui:gtc:3.1.9.0' //个推核心组件 + //数据库框架 + implementation 'org.greenrobot:greendao:3.3.0' + //桌面角标 + implementation "me.leolin:ShortcutBadger:1.1.22@aar" +} \ No newline at end of file diff --git a/app/libs/lite-release.aar b/app/libs/lite-release.aar new file mode 100644 index 0000000..45da4df --- /dev/null +++ b/app/libs/lite-release.aar Binary files differ diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /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 \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..a83c28a --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/svg/monitor.svg b/app/src/main/assets/svg/monitor.svg new file mode 100644 index 0000000..c8d3e25 --- /dev/null +++ b/app/src/main/assets/svg/monitor.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/msg.svg b/app/src/main/assets/svg/msg.svg new file mode 100644 index 0000000..e864e48 --- /dev/null +++ b/app/src/main/assets/svg/msg.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/statistics.svg b/app/src/main/assets/svg/statistics.svg new file mode 100644 index 0000000..974000e --- /dev/null +++ b/app/src/main/assets/svg/statistics.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt new file mode 100644 index 0000000..6b9cce0 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.adapter + +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentManager +import androidx.fragment.app.FragmentPagerAdapter + +class ViewPagerAdapter(list: ArrayList, manager: FragmentManager) : + FragmentPagerAdapter(manager) { + + private var pageList: List = list + + override fun getItem(position: Int) = pageList[position] + + override fun getCount() = pageList.size +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt new file mode 100644 index 0000000..4e017b1 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt @@ -0,0 +1,40 @@ +package com.casic.smart.town.sanxi.base + +import android.app.Application +import android.util.Log +import com.casic.smart.town.sanxi.greendao.DaoMaster +import com.casic.smart.town.sanxi.greendao.DaoSession +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + private val kTag = "BaseApplication" + + companion object { + private var instance: BaseApplication by Delegates.notNull() + + fun obtainInstance() = instance + + private lateinit var daoSession: DaoSession + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences(this) + //推送 + PushManager.getInstance().initialize(this) + PushManager.getInstance().setDebugLogger(this) { + Log.d(kTag, it) + } + val devOpenHelper = DaoMaster.DevOpenHelper(this, "SmartTown.db", null) + val daoMaster = DaoMaster(devOpenHelper.writableDatabase) + daoSession = daoMaster.newSession() + } + + fun obtainDaoSession(): DaoSession { + return daoSession + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java new file mode 100644 index 0000000..b8f67dc --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java @@ -0,0 +1,133 @@ +package com.casic.smart.town.sanxi.bean; + +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Generated; +import org.greenrobot.greendao.annotation.Id; +import org.greenrobot.greendao.annotation.Unique; + +@Entity +public class AlarmMessageLocaleBean { + @Id(autoincrement = true) + private Long id;//主键自增 + + @Unique + private String messageId; + private String appId; + private String clientId; + private String taskId; + private String userId; + private String title; + private String content; + private String deviceCode; + private String isRead;//0-未读,1-已读 + private String alarmTime; + + @Generated(hash = 566950134) + public AlarmMessageLocaleBean(Long id, String messageId, String appId, + String clientId, String taskId, String userId, String title, + String content, String deviceCode, String isRead, String alarmTime) { + this.id = id; + this.messageId = messageId; + this.appId = appId; + this.clientId = clientId; + this.taskId = taskId; + this.userId = userId; + this.title = title; + this.content = content; + this.deviceCode = deviceCode; + this.isRead = isRead; + this.alarmTime = alarmTime; + } + + @Generated(hash = 1737519562) + public AlarmMessageLocaleBean() { + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getMessageId() { + return this.messageId; + } + + public void setMessageId(String messageId) { + this.messageId = messageId; + } + + public String getAppId() { + return this.appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public String getClientId() { + return this.clientId; + } + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public String getTaskId() { + return this.taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getUserId() { + return this.userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getTitle() { + return this.title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return this.content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getDeviceCode() { + return this.deviceCode; + } + + public void setDeviceCode(String deviceCode) { + this.deviceCode = deviceCode; + } + + public String getIsRead() { + return this.isRead; + } + + public void setIsRead(String isRead) { + this.isRead = isRead; + } + + public String getAlarmTime() { + return this.alarmTime; + } + + public void setAlarmTime(String alarmTime) { + this.alarmTime = alarmTime; + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt new file mode 100644 index 0000000..650e201 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class AlarmPageFragment: KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_alarm + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt new file mode 100644 index 0000000..deac8ac --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt @@ -0,0 +1,76 @@ +package com.casic.smart.town.sanxi.fragment + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.Fragment +import com.amap.api.maps.AMap +import com.amap.api.maps.AMapOptions +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.view.MonitorRecordActivity +import com.pengxh.kt.lite.extensions.navigatePageTo +import com.pengxh.kt.lite.extensions.show +import kotlinx.android.synthetic.main.fragment_monitor.view.* + +class MonitorPageFragment : Fragment() { + + private val kTag = "HomePageFragment" + private lateinit var monitorView: View + private lateinit var aMap: AMap + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? + ): View { + monitorView = inflater.inflate(R.layout.fragment_monitor, container, false) + //地图初始化 + initMap(savedInstanceState) + + monitorView.rightOperateView.setOnClickListener { + requireContext().navigatePageTo() + } + return monitorView + } + + private fun initMap(savedInstanceState: Bundle?) { + monitorView.mapView.onCreate(savedInstanceState) + aMap = monitorView.mapView.map + aMap.mapType = AMap.MAP_TYPE_NORMAL + val uiSettings = aMap.uiSettings + uiSettings.isCompassEnabled = true + uiSettings.zoomPosition = AMapOptions.ZOOM_POSITION_RIGHT_CENTER + uiSettings.isTiltGesturesEnabled = false//不许地图随手势倾斜角度 + + // 地图加载成功监听 +// aMap.addOnMapLoadedListener(this) + // 地图缩放监听 +// aMap.addOnCameraChangeListener(this) + // marker 点击事件监听 +// aMap.addOnMarkerClickListener(this) + // 点击marker弹出自定义popup +// aMap.setInfoWindowAdapter(this) + //信息窗点击事件 +// aMap.addOnInfoWindowClickListener(this) + } + + /***以下是地图生命周期管理************************************************************************/ + override fun onResume() { + super.onResume() + monitorView.mapView.onResume() + } + + override fun onPause() { + super.onPause() + monitorView.mapView.onPause() + } + + override fun onSaveInstanceState(outState: Bundle) { + super.onSaveInstanceState(outState) + monitorView.mapView.onSaveInstanceState(outState) + } + + override fun onDestroy() { + super.onDestroy() + monitorView.mapView.onDestroy() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt new file mode 100644 index 0000000..e84df12 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class StatisticsPageFragment : KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_statistics + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java new file mode 100644 index 0000000..68d7901 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java @@ -0,0 +1,255 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.database.Cursor; +import android.database.sqlite.SQLiteStatement; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.Property; +import org.greenrobot.greendao.internal.DaoConfig; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseStatement; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * DAO for table "ALARM_MESSAGE_LOCALE_BEAN". +*/ +public class AlarmMessageLocaleBeanDao extends AbstractDao { + + public static final String TABLENAME = "ALARM_MESSAGE_LOCALE_BEAN"; + + /** + * Properties of entity AlarmMessageLocaleBean.
+ * Can be used for QueryBuilder and for referencing column names. + */ + public static class Properties { + public final static Property Id = new Property(0, Long.class, "id", true, "_id"); + public final static Property MessageId = new Property(1, String.class, "messageId", false, "MESSAGE_ID"); + public final static Property AppId = new Property(2, String.class, "appId", false, "APP_ID"); + public final static Property ClientId = new Property(3, String.class, "clientId", false, "CLIENT_ID"); + public final static Property TaskId = new Property(4, String.class, "taskId", false, "TASK_ID"); + public final static Property UserId = new Property(5, String.class, "userId", false, "USER_ID"); + public final static Property Title = new Property(6, String.class, "title", false, "TITLE"); + public final static Property Content = new Property(7, String.class, "content", false, "CONTENT"); + public final static Property DeviceCode = new Property(8, String.class, "deviceCode", false, "DEVICE_CODE"); + public final static Property IsRead = new Property(9, String.class, "isRead", false, "IS_READ"); + public final static Property AlarmTime = new Property(10, String.class, "alarmTime", false, "ALARM_TIME"); + } + + + public AlarmMessageLocaleBeanDao(DaoConfig config) { + super(config); + } + + public AlarmMessageLocaleBeanDao(DaoConfig config, DaoSession daoSession) { + super(config, daoSession); + } + + /** Creates the underlying database table. */ + public static void createTable(Database db, boolean ifNotExists) { + String constraint = ifNotExists? "IF NOT EXISTS ": ""; + db.execSQL("CREATE TABLE " + constraint + "\"ALARM_MESSAGE_LOCALE_BEAN\" (" + // + "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id + "\"MESSAGE_ID\" TEXT UNIQUE ," + // 1: messageId + "\"APP_ID\" TEXT," + // 2: appId + "\"CLIENT_ID\" TEXT," + // 3: clientId + "\"TASK_ID\" TEXT," + // 4: taskId + "\"USER_ID\" TEXT," + // 5: userId + "\"TITLE\" TEXT," + // 6: title + "\"CONTENT\" TEXT," + // 7: content + "\"DEVICE_CODE\" TEXT," + // 8: deviceCode + "\"IS_READ\" TEXT," + // 9: isRead + "\"ALARM_TIME\" TEXT);"); // 10: alarmTime + } + + /** Drops the underlying database table. */ + public static void dropTable(Database db, boolean ifExists) { + String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"ALARM_MESSAGE_LOCALE_BEAN\""; + db.execSQL(sql); + } + + @Override + protected final void bindValues(DatabaseStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + protected final void bindValues(SQLiteStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + public Long readKey(Cursor cursor, int offset) { + return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); + } + + @Override + public AlarmMessageLocaleBean readEntity(Cursor cursor, int offset) { + AlarmMessageLocaleBean entity = new AlarmMessageLocaleBean( // + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // messageId + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // appId + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // clientId + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // taskId + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // userId + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // title + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // content + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // deviceCode + cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // isRead + cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10) // alarmTime + ); + return entity; + } + + @Override + public void readEntity(Cursor cursor, AlarmMessageLocaleBean entity, int offset) { + entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); + entity.setMessageId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setAppId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setClientId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setTaskId(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); + entity.setUserId(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setTitle(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setContent(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); + entity.setDeviceCode(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); + entity.setIsRead(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9)); + entity.setAlarmTime(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); + } + + @Override + protected final Long updateKeyAfterInsert(AlarmMessageLocaleBean entity, long rowId) { + entity.setId(rowId); + return rowId; + } + + @Override + public Long getKey(AlarmMessageLocaleBean entity) { + if(entity != null) { + return entity.getId(); + } else { + return null; + } + } + + @Override + public boolean hasKey(AlarmMessageLocaleBean entity) { + return entity.getId() != null; + } + + @Override + protected final boolean isEntityUpdateable() { + return true; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java new file mode 100644 index 0000000..4222c40 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java @@ -0,0 +1,96 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.content.Context; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteDatabase.CursorFactory; +import android.util.Log; + +import org.greenrobot.greendao.AbstractDaoMaster; +import org.greenrobot.greendao.database.StandardDatabase; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseOpenHelper; +import org.greenrobot.greendao.identityscope.IdentityScopeType; + + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * Master of DAO (schema version 1): knows all DAOs. + */ +public class DaoMaster extends AbstractDaoMaster { + public static final int SCHEMA_VERSION = 1; + + /** Creates underlying database table using DAOs. */ + public static void createAllTables(Database db, boolean ifNotExists) { + AlarmMessageLocaleBeanDao.createTable(db, ifNotExists); + } + + /** Drops underlying database table using DAOs. */ + public static void dropAllTables(Database db, boolean ifExists) { + AlarmMessageLocaleBeanDao.dropTable(db, ifExists); + } + + /** + * WARNING: Drops all table on Upgrade! Use only during development. + * Convenience method using a {@link DevOpenHelper}. + */ + public static DaoSession newDevSession(Context context, String name) { + Database db = new DevOpenHelper(context, name).getWritableDb(); + DaoMaster daoMaster = new DaoMaster(db); + return daoMaster.newSession(); + } + + public DaoMaster(SQLiteDatabase db) { + this(new StandardDatabase(db)); + } + + public DaoMaster(Database db) { + super(db, SCHEMA_VERSION); + registerDaoClass(AlarmMessageLocaleBeanDao.class); + } + + public DaoSession newSession() { + return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); + } + + public DaoSession newSession(IdentityScopeType type) { + return new DaoSession(db, type, daoConfigMap); + } + + /** + * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} - + */ + public static abstract class OpenHelper extends DatabaseOpenHelper { + public OpenHelper(Context context, String name) { + super(context, name, SCHEMA_VERSION); + } + + public OpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory, SCHEMA_VERSION); + } + + @Override + public void onCreate(Database db) { + Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); + createAllTables(db, false); + } + } + + /** WARNING: Drops all table on Upgrade! Use only during development. */ + public static class DevOpenHelper extends OpenHelper { + public DevOpenHelper(Context context, String name) { + super(context, name); + } + + public DevOpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory); + } + + @Override + public void onUpgrade(Database db, int oldVersion, int newVersion) { + Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); + dropAllTables(db, true); + onCreate(db); + } + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java new file mode 100644 index 0000000..480ed84 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java @@ -0,0 +1,48 @@ +package com.casic.smart.town.sanxi.greendao; + +import java.util.Map; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.AbstractDaoSession; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.identityscope.IdentityScopeType; +import org.greenrobot.greendao.internal.DaoConfig; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. + +/** + * {@inheritDoc} + * + * @see org.greenrobot.greendao.AbstractDaoSession + */ +public class DaoSession extends AbstractDaoSession { + + private final DaoConfig alarmMessageLocaleBeanDaoConfig; + + private final AlarmMessageLocaleBeanDao alarmMessageLocaleBeanDao; + + public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> + daoConfigMap) { + super(db); + + alarmMessageLocaleBeanDaoConfig = daoConfigMap.get(AlarmMessageLocaleBeanDao.class).clone(); + alarmMessageLocaleBeanDaoConfig.initIdentityScope(type); + + alarmMessageLocaleBeanDao = new AlarmMessageLocaleBeanDao(alarmMessageLocaleBeanDaoConfig, this); + + registerDao(AlarmMessageLocaleBean.class, alarmMessageLocaleBeanDao); + } + + public void clear() { + alarmMessageLocaleBeanDaoConfig.clearIdentityScope(); + } + + public AlarmMessageLocaleBeanDao getAlarmMessageLocaleBeanDao() { + return alarmMessageLocaleBeanDao; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt new file mode 100644 index 0000000..875cb8c --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt @@ -0,0 +1,5 @@ +package com.casic.smart.town.sanxi.service + +import com.igexin.sdk.PushService + +class ApplicationPushService : PushService() \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt new file mode 100644 index 0000000..396129f --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt @@ -0,0 +1,84 @@ +package com.casic.smart.town.sanxi.service + +import android.content.Context +import android.os.Message +import android.util.Log +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.casic.smart.town.sanxi.view.MainActivity +import com.igexin.sdk.GTIntentService +import com.igexin.sdk.message.GTCmdMessage +import com.igexin.sdk.message.GTNotificationMessage +import com.igexin.sdk.message.GTTransmitMessage +import com.pengxh.kt.lite.extensions.toJson + +class PushIntentService : GTIntentService() { + + private val kTag = "SmartWellIntentService" + + override fun onReceiveServicePid(context: Context?, pid: Int) { + + } + + // 透传消息 + override fun onReceiveMessageData(context: Context?, msg: GTTransmitMessage?) { + Log.d(kTag, "透传消息 -> msg = $msg") + } + + // 接收 cid + override fun onReceiveClientId(context: Context?, clientid: String?) { + Log.d(kTag, "onReceiveClientId -> $clientid") + //通知MainActivity注册个推服务 + val msg: Message = MainActivity.weakReferenceHandler.obtainMessage() + msg.what = LocaleConstant.PUSH_REGISTER + msg.obj = clientid + MainActivity.weakReferenceHandler.sendMessage(msg) + } + + // cid 离线上线通知 + override fun onReceiveOnlineState(context: Context?, online: Boolean) { + + } + + // 各种事件处理回执 + override fun onReceiveCommandResult(context: Context?, msg: GTCmdMessage?) { + + } + + // 通知到达 + override fun onNotificationMessageArrived(context: Context?, msg: GTNotificationMessage?) { + //报警 +// { +// "content": "设备编号[412022030361]发生井盖开盖报警", +// "messageId": "380abf9a79d34306a2683dc9bf96ee78", +// "taskId": "OSL-0830_4hmfimp3Vu684wo3SjXso9", +// "title": "告警提醒", +// "appid": "HKv8K9qARd6WckZ1o2Vbu4", +// "clientId": "e78beacc42e9a02ae6fb9087eb2b1171", +// "pkgName": "com.casic.app.smartwell" +// } + if (msg == null) { + return + } + Log.d(kTag, "通知到达 -> msg = ${msg.toJson()}") +// val userDetailJson = SaveKeyValues.getValue(LocaleConstant.USER_DETAIL_MODEL, "") as String +// var userId = "" +// if (userDetailJson.isNotBlank()) { +// val userDataModel = Gson().fromJson( +// userDetailJson, object : TypeToken() {}.type +// ) +// userId = userDataModel.id.toString() +// } +// //解析编号 +// val splitArray = msg.content.split("\\[|\\]".toRegex()) +// DataBaseManager.instance.insertNotice( +// msg.messageId, msg.appid, msg.clientId, msg.taskId, +// userId, msg.title, msg.content, splitArray[1], "0", +// System.currentTimeMillis().timestampToCompleteDate() +// ) + } + + // 通知点击 + override fun onNotificationMessageClicked(context: Context?, msg: GTNotificationMessage?) { + Log.d(kTag, "通知点击 -> msg = $msg") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt new file mode 100644 index 0000000..daa7c38 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt @@ -0,0 +1,14 @@ +package com.casic.smart.town.sanxi.util + +import android.content.Context +import me.leolin.shortcutbadger.ShortcutBadger + +object BadeHelper { + fun setBadgeNum(context: Context, badgeCount: Int) { + if (badgeCount == 0) { + ShortcutBadger.removeCount(context) + } else { + ShortcutBadger.applyCount(context, badgeCount) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt new file mode 100644 index 0000000..0a52ef2 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt @@ -0,0 +1,75 @@ +package com.casic.smart.town.sanxi.util + +import com.casic.smart.town.sanxi.base.BaseApplication +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao + +class DataBaseManager private constructor() { + + companion object { + //Kotlin委托模式双重锁单例 + val instance: DataBaseManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) { + DataBaseManager() + } + } + + private val beanDao = + BaseApplication.obtainInstance().obtainDaoSession().alarmMessageLocaleBeanDao + +// fun insertNotice( +// messageId: String, appid: String, clientId: String, +// taskId: String, userId: String, title: String, +// content: String, deviceCode: String, isRead: String, +// noticeTime: String +// ) { +// val noticeLocaleBean = NoticeLocaleBean() +// noticeLocaleBean.messageId = messageId +// noticeLocaleBean.appid = appid +// noticeLocaleBean.clientId = clientId +// noticeLocaleBean.taskId = taskId +// noticeLocaleBean.userId = userId +// noticeLocaleBean.title = title +// noticeLocaleBean.content = content +// noticeLocaleBean.deviceCode = deviceCode +// noticeLocaleBean.isRead = isRead +// noticeLocaleBean.noticeTime = noticeTime +// beanDao.insert(noticeLocaleBean) +// //角标设置 +// BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadNotice()) +// } + + fun deleteByMessageId(messageId: String) { + val result = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).list() + beanDao.deleteInTx(result) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun updateNoticeByMessageId(messageId: String) { + val noticeLocaleBean = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).unique() ?: return + noticeLocaleBean.isRead = "1" + beanDao.update(noticeLocaleBean) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun queryMessageByPage(userId: String, offset: Int): MutableList { + return BaseApplication.obtainInstance().obtainDaoSession() + .queryBuilder(AlarmMessageLocaleBean::class.java) + .where(AlarmMessageLocaleBeanDao.Properties.UserId.eq(userId)) + .offset(offset * LocaleConstant.PAGE_LIMIT) + .orderDesc(AlarmMessageLocaleBeanDao.Properties.AlarmTime) + .limit(LocaleConstant.PAGE_LIMIT) + .list() + } + + private fun queryUnReadMessage(): Int { + return beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.IsRead.eq("0") + ).list().size + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt new file mode 100644 index 0000000..52926a8 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt @@ -0,0 +1,31 @@ +package com.casic.smart.town.sanxi.util; + +import android.app.Activity +import android.view.WindowManager +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object LoadingDialogHub { + private lateinit var loadingDialog: QMUITipDialog + + fun show(activity: Activity, message: String) { + loadingDialog = QMUITipDialog + .Builder(activity) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_LOADING) + .setTipWord(message) + .create() + if (!activity.isDestroyed) { + try { + loadingDialog.show() + } catch (e: WindowManager.BadTokenException) { + e.printStackTrace() + } + } + } + + + fun dismiss() { + if (loadingDialog.isShowing) { + loadingDialog.dismiss() + } + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt new file mode 100644 index 0000000..de61c9a --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.util + +import android.Manifest + +object LocaleConstant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.READ_PHONE_STATE, + Manifest.permission.ACCESS_COARSE_LOCATION, + Manifest.permission.READ_EXTERNAL_STORAGE + ) + + const val PERMISSIONS_CODE = 999 + const val PUSH_REGISTER = 2022100101 + const val PAGE_LIMIT = 20 +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt new file mode 100644 index 0000000..3bea1c9 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt @@ -0,0 +1,112 @@ +package com.casic.smart.town.sanxi.view + +import android.view.KeyEvent +import android.view.MenuItem +import androidx.fragment.app.Fragment +import androidx.viewpager.widget.ViewPager +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.adapter.ViewPagerAdapter +import com.casic.smart.town.sanxi.fragment.AlarmPageFragment +import com.casic.smart.town.sanxi.fragment.MonitorPageFragment +import com.casic.smart.town.sanxi.fragment.StatisticsPageFragment +import com.gyf.immersionbar.ImmersionBar +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.base.KotlinBaseActivity +import com.pengxh.kt.lite.extensions.convertColor +import com.pengxh.kt.lite.extensions.show +import com.pengxh.kt.lite.utils.ImmerseStatusBarUtil +import com.pengxh.kt.lite.utils.WeakReferenceHandler +import kotlinx.android.synthetic.main.activity_main.* + +class MainActivity : KotlinBaseActivity() { + + companion object { + lateinit var weakReferenceHandler: WeakReferenceHandler + } + + private val kTag = "MainActivity" + private var menuItem: MenuItem? = null + private var fragmentPages: ArrayList = ArrayList() + private var clickTime: Long = 0 + + init { + fragmentPages.add(StatisticsPageFragment()) + fragmentPages.add(MonitorPageFragment()) + fragmentPages.add(AlarmPageFragment()) + } + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + ImmersionBar.with(this).statusBarDarkFont(false).init() + ImmerseStatusBarUtil.setColor(this, R.color.mainThemeColor.convertColor(this)) + } + + override fun initData() { + //推送,多次调用 SDK 初始化并无影响。 + PushManager.getInstance().initialize(this) + weakReferenceHandler = WeakReferenceHandler { + + true + } + } + + override fun observeRequestState() { + + } + + override fun initEvent() { + bottomNavigation.itemIconTintList = null + bottomNavigation.setOnNavigationItemSelectedListener { menuItem -> + when (menuItem.itemId) { + R.id.nav_statistics -> { + mainViewPager.currentItem = 0 + } + R.id.nav_monitor -> { + mainViewPager.currentItem = 1 + } + R.id.nav_alarm -> { + mainViewPager.currentItem = 2 + } + } + false + } + mainViewPager.adapter = ViewPagerAdapter(fragmentPages, supportFragmentManager) + mainViewPager.offscreenPageLimit = fragmentPages.size //缓存页数 + mainViewPager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener { + override fun onPageScrollStateChanged(state: Int) { + + } + + override fun onPageScrolled( + position: Int, + positionOffset: Float, + positionOffsetPixels: Int + ) { + + } + + override fun onPageSelected(position: Int) { + if (menuItem != null) { + menuItem!!.isChecked = false + } else { + bottomNavigation.menu.getItem(0).isChecked = false + } + menuItem = bottomNavigation.menu.getItem(position) + menuItem!!.isChecked = true + } + }) + } + + override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean { + return if (keyCode == KeyEvent.KEYCODE_BACK) { + if (System.currentTimeMillis() - clickTime > 2000) { + "再按一次退出程序".show(this) + clickTime = System.currentTimeMillis() + true + } else { + super.onKeyDown(keyCode, event) + } + } else super.onKeyDown(keyCode, event) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt new file mode 100644 index 0000000..c5d8b22 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.view + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseActivity + +class MonitorRecordActivity : KotlinBaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_monitor_record + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt new file mode 100644 index 0000000..c478d83 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt @@ -0,0 +1,55 @@ +package com.casic.smart.town.sanxi.view + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.amap.api.maps.MapsInitializer +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.gyf.immersionbar.ImmersionBar +import com.pengxh.kt.lite.extensions.navigatePageTo +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + ImmersionBar.with(this).statusBarDarkFont(true).init() + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (EasyPermissions.hasPermissions(this, *LocaleConstant.USER_PERMISSIONS)) { + startSplashScreenActivity() + } else { + EasyPermissions.requestPermissions( + this@PermissionActivity, + resources.getString(R.string.app_name) + "需要获取相关权限", + LocaleConstant.PERMISSIONS_CODE, + *LocaleConstant.USER_PERMISSIONS + ) + } + } + + private fun startSplashScreenActivity() { + //先把导航隐私政策声明,后面导航会用到 + MapsInitializer.updatePrivacyAgree(this, true) + MapsInitializer.updatePrivacyShow(this, true, true) + this.navigatePageTo() + 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) { + startSplashScreenActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable/alarm_selector.xml b/app/src/main/res/drawable/alarm_selector.xml new file mode 100644 index 0000000..39b2595 --- /dev/null +++ b/app/src/main/res/drawable/alarm_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bottom_text_color.xml b/app/src/main/res/drawable/bottom_text_color.xml new file mode 100644 index 0000000..b284ea3 --- /dev/null +++ b/app/src/main/res/drawable/bottom_text_color.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_alarm.xml b/app/src/main/res/drawable/ic_alarm.xml new file mode 100644 index 0000000..dc33aab --- /dev/null +++ b/app/src/main/res/drawable/ic_alarm.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_alarm_selected.xml b/app/src/main/res/drawable/ic_alarm_selected.xml new file mode 100644 index 0000000..993fea6 --- /dev/null +++ b/app/src/main/res/drawable/ic_alarm_selected.xml @@ -0,0 +1,9 @@ + + + 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_monitor.xml b/app/src/main/res/drawable/ic_monitor.xml new file mode 100644 index 0000000..271f5b4 --- /dev/null +++ b/app/src/main/res/drawable/ic_monitor.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_monitor_selected.xml b/app/src/main/res/drawable/ic_monitor_selected.xml new file mode 100644 index 0000000..ee62d84 --- /dev/null +++ b/app/src/main/res/drawable/ic_monitor_selected.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_statistics.xml b/app/src/main/res/drawable/ic_statistics.xml new file mode 100644 index 0000000..7fde8ec --- /dev/null +++ b/app/src/main/res/drawable/ic_statistics.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_statistics_selected.xml b/app/src/main/res/drawable/ic_statistics_selected.xml new file mode 100644 index 0000000..49b6fcd --- /dev/null +++ b/app/src/main/res/drawable/ic_statistics_selected.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/monitor_selector.xml b/app/src/main/res/drawable/monitor_selector.xml new file mode 100644 index 0000000..fe11e9a --- /dev/null +++ b/app/src/main/res/drawable/monitor_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/statistics_selector.xml b/app/src/main/res/drawable/statistics_selector.xml new file mode 100644 index 0000000..2156cff --- /dev/null +++ b/app/src/main/res/drawable/statistics_selector.xml @@ -0,0 +1,5 @@ + + + + + \ 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..78a4a94 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,27 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_monitor_record.xml b/app/src/main/res/layout/activity_monitor_record.xml new file mode 100644 index 0000000..77d9ef6 --- /dev/null +++ b/app/src/main/res/layout/activity_monitor_record.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_alarm.xml b/app/src/main/res/layout/fragment_alarm.xml new file mode 100644 index 0000000..77d9ef6 --- /dev/null +++ b/app/src/main/res/layout/fragment_alarm.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_monitor.xml b/app/src/main/res/layout/fragment_monitor.xml new file mode 100644 index 0000000..19789c1 --- /dev/null +++ b/app/src/main/res/layout/fragment_monitor.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_statistics.xml b/app/src/main/res/layout/fragment_statistics.xml new file mode 100644 index 0000000..77d9ef6 --- /dev/null +++ b/app/src/main/res/layout/fragment_statistics.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/menu/bottom_nav_menu.xml b/app/src/main/res/menu/bottom_nav_menu.xml new file mode 100644 index 0000000..751fd61 --- /dev/null +++ b/app/src/main/res/menu/bottom_nav_menu.xml @@ -0,0 +1,29 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.webp b/app/src/main/res/mipmap-hdpi/ic_launcher.webp new file mode 100644 index 0000000..c209e78 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp new file mode 100644 index 0000000..b2dfe3d --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.webp b/app/src/main/res/mipmap-mdpi/ic_launcher.webp new file mode 100644 index 0000000..4f0f1d6 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp new file mode 100644 index 0000000..62b611d --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher.webp new file mode 100644 index 0000000..948a307 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..1b9a695 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp Binary files differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp new file mode 100644 index 0000000..28d4b77 --- /dev/null +++ b/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp Binary files differ diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..10cfdbf --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*.iml +.gradle +/local.properties +/.idea +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..a4cd2ca --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,101 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'org.greenrobot.greendao' + +android { +// signingConfigs { +// release { +// storeFile file('/Users/a203/Desktop/AndroidProjects/CasicSmartWell/app/CasicSmartWell.jks') +// storePassword '123456789' +// keyAlias 'key0' +// keyPassword '123456789' +// } +// } + compileSdkVersion 31 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.smart.town.sanxi" + minSdkVersion 23 + targetSdkVersion 31 + versionCode 1 + versionName "1.0.0" + + manifestPlaceholders = [GETUI_APPID: "A9V4DvwLcdAqkFCQuFyhq6"] + } + + buildTypes { + release { + minifyEnabled false +// signingConfig signingConfigs.release + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + + ndk { abiFilters "armeabi", "armeabi-v7a", "arm64-v8" } + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlin { + experimental { + coroutines 'enable' + } + } + + greendao { + schemaVersion 1//数据库版本号 + targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 + daoPackage 'com.casic.smart.town.sanxi.greendao'//设置DaoMaster、DaoSession、Dao包名 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + //基础依赖库 + implementation files('libs/lite-release.aar') + implementation 'androidx.appcompat:appcompat:1.4.2' + implementation 'androidx.core:core-ktx:1.8.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:3.0.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' + //MVVM+LiveData + implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.1" + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0" + implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + //Kotlin协程 + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1' + //图片加载框架 + implementation 'com.github.bumptech.glide:glide:4.9.0' + //返回值转换器 + implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' + implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + //okhttp3日志拦截器 + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //网络请求和接口封装 + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.9.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.9.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' + //高德地图 + implementation 'com.amap.api:3dmap:latest.integration' + //推送SDK + implementation 'com.getui:gtsdk:3.2.10.0' //个推SDK + implementation 'com.getui:gtc:3.1.9.0' //个推核心组件 + //数据库框架 + implementation 'org.greenrobot:greendao:3.3.0' + //桌面角标 + implementation "me.leolin:ShortcutBadger:1.1.22@aar" +} \ No newline at end of file diff --git a/app/libs/lite-release.aar b/app/libs/lite-release.aar new file mode 100644 index 0000000..45da4df --- /dev/null +++ b/app/libs/lite-release.aar Binary files differ diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /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 \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..a83c28a --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/svg/monitor.svg b/app/src/main/assets/svg/monitor.svg new file mode 100644 index 0000000..c8d3e25 --- /dev/null +++ b/app/src/main/assets/svg/monitor.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/msg.svg b/app/src/main/assets/svg/msg.svg new file mode 100644 index 0000000..e864e48 --- /dev/null +++ b/app/src/main/assets/svg/msg.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/statistics.svg b/app/src/main/assets/svg/statistics.svg new file mode 100644 index 0000000..974000e --- /dev/null +++ b/app/src/main/assets/svg/statistics.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt new file mode 100644 index 0000000..6b9cce0 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.adapter + +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentManager +import androidx.fragment.app.FragmentPagerAdapter + +class ViewPagerAdapter(list: ArrayList, manager: FragmentManager) : + FragmentPagerAdapter(manager) { + + private var pageList: List = list + + override fun getItem(position: Int) = pageList[position] + + override fun getCount() = pageList.size +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt new file mode 100644 index 0000000..4e017b1 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt @@ -0,0 +1,40 @@ +package com.casic.smart.town.sanxi.base + +import android.app.Application +import android.util.Log +import com.casic.smart.town.sanxi.greendao.DaoMaster +import com.casic.smart.town.sanxi.greendao.DaoSession +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + private val kTag = "BaseApplication" + + companion object { + private var instance: BaseApplication by Delegates.notNull() + + fun obtainInstance() = instance + + private lateinit var daoSession: DaoSession + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences(this) + //推送 + PushManager.getInstance().initialize(this) + PushManager.getInstance().setDebugLogger(this) { + Log.d(kTag, it) + } + val devOpenHelper = DaoMaster.DevOpenHelper(this, "SmartTown.db", null) + val daoMaster = DaoMaster(devOpenHelper.writableDatabase) + daoSession = daoMaster.newSession() + } + + fun obtainDaoSession(): DaoSession { + return daoSession + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java new file mode 100644 index 0000000..b8f67dc --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java @@ -0,0 +1,133 @@ +package com.casic.smart.town.sanxi.bean; + +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Generated; +import org.greenrobot.greendao.annotation.Id; +import org.greenrobot.greendao.annotation.Unique; + +@Entity +public class AlarmMessageLocaleBean { + @Id(autoincrement = true) + private Long id;//主键自增 + + @Unique + private String messageId; + private String appId; + private String clientId; + private String taskId; + private String userId; + private String title; + private String content; + private String deviceCode; + private String isRead;//0-未读,1-已读 + private String alarmTime; + + @Generated(hash = 566950134) + public AlarmMessageLocaleBean(Long id, String messageId, String appId, + String clientId, String taskId, String userId, String title, + String content, String deviceCode, String isRead, String alarmTime) { + this.id = id; + this.messageId = messageId; + this.appId = appId; + this.clientId = clientId; + this.taskId = taskId; + this.userId = userId; + this.title = title; + this.content = content; + this.deviceCode = deviceCode; + this.isRead = isRead; + this.alarmTime = alarmTime; + } + + @Generated(hash = 1737519562) + public AlarmMessageLocaleBean() { + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getMessageId() { + return this.messageId; + } + + public void setMessageId(String messageId) { + this.messageId = messageId; + } + + public String getAppId() { + return this.appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public String getClientId() { + return this.clientId; + } + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public String getTaskId() { + return this.taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getUserId() { + return this.userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getTitle() { + return this.title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return this.content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getDeviceCode() { + return this.deviceCode; + } + + public void setDeviceCode(String deviceCode) { + this.deviceCode = deviceCode; + } + + public String getIsRead() { + return this.isRead; + } + + public void setIsRead(String isRead) { + this.isRead = isRead; + } + + public String getAlarmTime() { + return this.alarmTime; + } + + public void setAlarmTime(String alarmTime) { + this.alarmTime = alarmTime; + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt new file mode 100644 index 0000000..650e201 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class AlarmPageFragment: KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_alarm + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt new file mode 100644 index 0000000..deac8ac --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt @@ -0,0 +1,76 @@ +package com.casic.smart.town.sanxi.fragment + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.Fragment +import com.amap.api.maps.AMap +import com.amap.api.maps.AMapOptions +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.view.MonitorRecordActivity +import com.pengxh.kt.lite.extensions.navigatePageTo +import com.pengxh.kt.lite.extensions.show +import kotlinx.android.synthetic.main.fragment_monitor.view.* + +class MonitorPageFragment : Fragment() { + + private val kTag = "HomePageFragment" + private lateinit var monitorView: View + private lateinit var aMap: AMap + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? + ): View { + monitorView = inflater.inflate(R.layout.fragment_monitor, container, false) + //地图初始化 + initMap(savedInstanceState) + + monitorView.rightOperateView.setOnClickListener { + requireContext().navigatePageTo() + } + return monitorView + } + + private fun initMap(savedInstanceState: Bundle?) { + monitorView.mapView.onCreate(savedInstanceState) + aMap = monitorView.mapView.map + aMap.mapType = AMap.MAP_TYPE_NORMAL + val uiSettings = aMap.uiSettings + uiSettings.isCompassEnabled = true + uiSettings.zoomPosition = AMapOptions.ZOOM_POSITION_RIGHT_CENTER + uiSettings.isTiltGesturesEnabled = false//不许地图随手势倾斜角度 + + // 地图加载成功监听 +// aMap.addOnMapLoadedListener(this) + // 地图缩放监听 +// aMap.addOnCameraChangeListener(this) + // marker 点击事件监听 +// aMap.addOnMarkerClickListener(this) + // 点击marker弹出自定义popup +// aMap.setInfoWindowAdapter(this) + //信息窗点击事件 +// aMap.addOnInfoWindowClickListener(this) + } + + /***以下是地图生命周期管理************************************************************************/ + override fun onResume() { + super.onResume() + monitorView.mapView.onResume() + } + + override fun onPause() { + super.onPause() + monitorView.mapView.onPause() + } + + override fun onSaveInstanceState(outState: Bundle) { + super.onSaveInstanceState(outState) + monitorView.mapView.onSaveInstanceState(outState) + } + + override fun onDestroy() { + super.onDestroy() + monitorView.mapView.onDestroy() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt new file mode 100644 index 0000000..e84df12 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class StatisticsPageFragment : KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_statistics + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java new file mode 100644 index 0000000..68d7901 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java @@ -0,0 +1,255 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.database.Cursor; +import android.database.sqlite.SQLiteStatement; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.Property; +import org.greenrobot.greendao.internal.DaoConfig; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseStatement; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * DAO for table "ALARM_MESSAGE_LOCALE_BEAN". +*/ +public class AlarmMessageLocaleBeanDao extends AbstractDao { + + public static final String TABLENAME = "ALARM_MESSAGE_LOCALE_BEAN"; + + /** + * Properties of entity AlarmMessageLocaleBean.
+ * Can be used for QueryBuilder and for referencing column names. + */ + public static class Properties { + public final static Property Id = new Property(0, Long.class, "id", true, "_id"); + public final static Property MessageId = new Property(1, String.class, "messageId", false, "MESSAGE_ID"); + public final static Property AppId = new Property(2, String.class, "appId", false, "APP_ID"); + public final static Property ClientId = new Property(3, String.class, "clientId", false, "CLIENT_ID"); + public final static Property TaskId = new Property(4, String.class, "taskId", false, "TASK_ID"); + public final static Property UserId = new Property(5, String.class, "userId", false, "USER_ID"); + public final static Property Title = new Property(6, String.class, "title", false, "TITLE"); + public final static Property Content = new Property(7, String.class, "content", false, "CONTENT"); + public final static Property DeviceCode = new Property(8, String.class, "deviceCode", false, "DEVICE_CODE"); + public final static Property IsRead = new Property(9, String.class, "isRead", false, "IS_READ"); + public final static Property AlarmTime = new Property(10, String.class, "alarmTime", false, "ALARM_TIME"); + } + + + public AlarmMessageLocaleBeanDao(DaoConfig config) { + super(config); + } + + public AlarmMessageLocaleBeanDao(DaoConfig config, DaoSession daoSession) { + super(config, daoSession); + } + + /** Creates the underlying database table. */ + public static void createTable(Database db, boolean ifNotExists) { + String constraint = ifNotExists? "IF NOT EXISTS ": ""; + db.execSQL("CREATE TABLE " + constraint + "\"ALARM_MESSAGE_LOCALE_BEAN\" (" + // + "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id + "\"MESSAGE_ID\" TEXT UNIQUE ," + // 1: messageId + "\"APP_ID\" TEXT," + // 2: appId + "\"CLIENT_ID\" TEXT," + // 3: clientId + "\"TASK_ID\" TEXT," + // 4: taskId + "\"USER_ID\" TEXT," + // 5: userId + "\"TITLE\" TEXT," + // 6: title + "\"CONTENT\" TEXT," + // 7: content + "\"DEVICE_CODE\" TEXT," + // 8: deviceCode + "\"IS_READ\" TEXT," + // 9: isRead + "\"ALARM_TIME\" TEXT);"); // 10: alarmTime + } + + /** Drops the underlying database table. */ + public static void dropTable(Database db, boolean ifExists) { + String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"ALARM_MESSAGE_LOCALE_BEAN\""; + db.execSQL(sql); + } + + @Override + protected final void bindValues(DatabaseStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + protected final void bindValues(SQLiteStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + public Long readKey(Cursor cursor, int offset) { + return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); + } + + @Override + public AlarmMessageLocaleBean readEntity(Cursor cursor, int offset) { + AlarmMessageLocaleBean entity = new AlarmMessageLocaleBean( // + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // messageId + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // appId + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // clientId + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // taskId + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // userId + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // title + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // content + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // deviceCode + cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // isRead + cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10) // alarmTime + ); + return entity; + } + + @Override + public void readEntity(Cursor cursor, AlarmMessageLocaleBean entity, int offset) { + entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); + entity.setMessageId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setAppId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setClientId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setTaskId(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); + entity.setUserId(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setTitle(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setContent(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); + entity.setDeviceCode(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); + entity.setIsRead(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9)); + entity.setAlarmTime(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); + } + + @Override + protected final Long updateKeyAfterInsert(AlarmMessageLocaleBean entity, long rowId) { + entity.setId(rowId); + return rowId; + } + + @Override + public Long getKey(AlarmMessageLocaleBean entity) { + if(entity != null) { + return entity.getId(); + } else { + return null; + } + } + + @Override + public boolean hasKey(AlarmMessageLocaleBean entity) { + return entity.getId() != null; + } + + @Override + protected final boolean isEntityUpdateable() { + return true; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java new file mode 100644 index 0000000..4222c40 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java @@ -0,0 +1,96 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.content.Context; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteDatabase.CursorFactory; +import android.util.Log; + +import org.greenrobot.greendao.AbstractDaoMaster; +import org.greenrobot.greendao.database.StandardDatabase; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseOpenHelper; +import org.greenrobot.greendao.identityscope.IdentityScopeType; + + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * Master of DAO (schema version 1): knows all DAOs. + */ +public class DaoMaster extends AbstractDaoMaster { + public static final int SCHEMA_VERSION = 1; + + /** Creates underlying database table using DAOs. */ + public static void createAllTables(Database db, boolean ifNotExists) { + AlarmMessageLocaleBeanDao.createTable(db, ifNotExists); + } + + /** Drops underlying database table using DAOs. */ + public static void dropAllTables(Database db, boolean ifExists) { + AlarmMessageLocaleBeanDao.dropTable(db, ifExists); + } + + /** + * WARNING: Drops all table on Upgrade! Use only during development. + * Convenience method using a {@link DevOpenHelper}. + */ + public static DaoSession newDevSession(Context context, String name) { + Database db = new DevOpenHelper(context, name).getWritableDb(); + DaoMaster daoMaster = new DaoMaster(db); + return daoMaster.newSession(); + } + + public DaoMaster(SQLiteDatabase db) { + this(new StandardDatabase(db)); + } + + public DaoMaster(Database db) { + super(db, SCHEMA_VERSION); + registerDaoClass(AlarmMessageLocaleBeanDao.class); + } + + public DaoSession newSession() { + return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); + } + + public DaoSession newSession(IdentityScopeType type) { + return new DaoSession(db, type, daoConfigMap); + } + + /** + * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} - + */ + public static abstract class OpenHelper extends DatabaseOpenHelper { + public OpenHelper(Context context, String name) { + super(context, name, SCHEMA_VERSION); + } + + public OpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory, SCHEMA_VERSION); + } + + @Override + public void onCreate(Database db) { + Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); + createAllTables(db, false); + } + } + + /** WARNING: Drops all table on Upgrade! Use only during development. */ + public static class DevOpenHelper extends OpenHelper { + public DevOpenHelper(Context context, String name) { + super(context, name); + } + + public DevOpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory); + } + + @Override + public void onUpgrade(Database db, int oldVersion, int newVersion) { + Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); + dropAllTables(db, true); + onCreate(db); + } + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java new file mode 100644 index 0000000..480ed84 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java @@ -0,0 +1,48 @@ +package com.casic.smart.town.sanxi.greendao; + +import java.util.Map; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.AbstractDaoSession; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.identityscope.IdentityScopeType; +import org.greenrobot.greendao.internal.DaoConfig; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. + +/** + * {@inheritDoc} + * + * @see org.greenrobot.greendao.AbstractDaoSession + */ +public class DaoSession extends AbstractDaoSession { + + private final DaoConfig alarmMessageLocaleBeanDaoConfig; + + private final AlarmMessageLocaleBeanDao alarmMessageLocaleBeanDao; + + public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> + daoConfigMap) { + super(db); + + alarmMessageLocaleBeanDaoConfig = daoConfigMap.get(AlarmMessageLocaleBeanDao.class).clone(); + alarmMessageLocaleBeanDaoConfig.initIdentityScope(type); + + alarmMessageLocaleBeanDao = new AlarmMessageLocaleBeanDao(alarmMessageLocaleBeanDaoConfig, this); + + registerDao(AlarmMessageLocaleBean.class, alarmMessageLocaleBeanDao); + } + + public void clear() { + alarmMessageLocaleBeanDaoConfig.clearIdentityScope(); + } + + public AlarmMessageLocaleBeanDao getAlarmMessageLocaleBeanDao() { + return alarmMessageLocaleBeanDao; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt new file mode 100644 index 0000000..875cb8c --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt @@ -0,0 +1,5 @@ +package com.casic.smart.town.sanxi.service + +import com.igexin.sdk.PushService + +class ApplicationPushService : PushService() \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt new file mode 100644 index 0000000..396129f --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt @@ -0,0 +1,84 @@ +package com.casic.smart.town.sanxi.service + +import android.content.Context +import android.os.Message +import android.util.Log +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.casic.smart.town.sanxi.view.MainActivity +import com.igexin.sdk.GTIntentService +import com.igexin.sdk.message.GTCmdMessage +import com.igexin.sdk.message.GTNotificationMessage +import com.igexin.sdk.message.GTTransmitMessage +import com.pengxh.kt.lite.extensions.toJson + +class PushIntentService : GTIntentService() { + + private val kTag = "SmartWellIntentService" + + override fun onReceiveServicePid(context: Context?, pid: Int) { + + } + + // 透传消息 + override fun onReceiveMessageData(context: Context?, msg: GTTransmitMessage?) { + Log.d(kTag, "透传消息 -> msg = $msg") + } + + // 接收 cid + override fun onReceiveClientId(context: Context?, clientid: String?) { + Log.d(kTag, "onReceiveClientId -> $clientid") + //通知MainActivity注册个推服务 + val msg: Message = MainActivity.weakReferenceHandler.obtainMessage() + msg.what = LocaleConstant.PUSH_REGISTER + msg.obj = clientid + MainActivity.weakReferenceHandler.sendMessage(msg) + } + + // cid 离线上线通知 + override fun onReceiveOnlineState(context: Context?, online: Boolean) { + + } + + // 各种事件处理回执 + override fun onReceiveCommandResult(context: Context?, msg: GTCmdMessage?) { + + } + + // 通知到达 + override fun onNotificationMessageArrived(context: Context?, msg: GTNotificationMessage?) { + //报警 +// { +// "content": "设备编号[412022030361]发生井盖开盖报警", +// "messageId": "380abf9a79d34306a2683dc9bf96ee78", +// "taskId": "OSL-0830_4hmfimp3Vu684wo3SjXso9", +// "title": "告警提醒", +// "appid": "HKv8K9qARd6WckZ1o2Vbu4", +// "clientId": "e78beacc42e9a02ae6fb9087eb2b1171", +// "pkgName": "com.casic.app.smartwell" +// } + if (msg == null) { + return + } + Log.d(kTag, "通知到达 -> msg = ${msg.toJson()}") +// val userDetailJson = SaveKeyValues.getValue(LocaleConstant.USER_DETAIL_MODEL, "") as String +// var userId = "" +// if (userDetailJson.isNotBlank()) { +// val userDataModel = Gson().fromJson( +// userDetailJson, object : TypeToken() {}.type +// ) +// userId = userDataModel.id.toString() +// } +// //解析编号 +// val splitArray = msg.content.split("\\[|\\]".toRegex()) +// DataBaseManager.instance.insertNotice( +// msg.messageId, msg.appid, msg.clientId, msg.taskId, +// userId, msg.title, msg.content, splitArray[1], "0", +// System.currentTimeMillis().timestampToCompleteDate() +// ) + } + + // 通知点击 + override fun onNotificationMessageClicked(context: Context?, msg: GTNotificationMessage?) { + Log.d(kTag, "通知点击 -> msg = $msg") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt new file mode 100644 index 0000000..daa7c38 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt @@ -0,0 +1,14 @@ +package com.casic.smart.town.sanxi.util + +import android.content.Context +import me.leolin.shortcutbadger.ShortcutBadger + +object BadeHelper { + fun setBadgeNum(context: Context, badgeCount: Int) { + if (badgeCount == 0) { + ShortcutBadger.removeCount(context) + } else { + ShortcutBadger.applyCount(context, badgeCount) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt new file mode 100644 index 0000000..0a52ef2 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt @@ -0,0 +1,75 @@ +package com.casic.smart.town.sanxi.util + +import com.casic.smart.town.sanxi.base.BaseApplication +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao + +class DataBaseManager private constructor() { + + companion object { + //Kotlin委托模式双重锁单例 + val instance: DataBaseManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) { + DataBaseManager() + } + } + + private val beanDao = + BaseApplication.obtainInstance().obtainDaoSession().alarmMessageLocaleBeanDao + +// fun insertNotice( +// messageId: String, appid: String, clientId: String, +// taskId: String, userId: String, title: String, +// content: String, deviceCode: String, isRead: String, +// noticeTime: String +// ) { +// val noticeLocaleBean = NoticeLocaleBean() +// noticeLocaleBean.messageId = messageId +// noticeLocaleBean.appid = appid +// noticeLocaleBean.clientId = clientId +// noticeLocaleBean.taskId = taskId +// noticeLocaleBean.userId = userId +// noticeLocaleBean.title = title +// noticeLocaleBean.content = content +// noticeLocaleBean.deviceCode = deviceCode +// noticeLocaleBean.isRead = isRead +// noticeLocaleBean.noticeTime = noticeTime +// beanDao.insert(noticeLocaleBean) +// //角标设置 +// BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadNotice()) +// } + + fun deleteByMessageId(messageId: String) { + val result = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).list() + beanDao.deleteInTx(result) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun updateNoticeByMessageId(messageId: String) { + val noticeLocaleBean = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).unique() ?: return + noticeLocaleBean.isRead = "1" + beanDao.update(noticeLocaleBean) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun queryMessageByPage(userId: String, offset: Int): MutableList { + return BaseApplication.obtainInstance().obtainDaoSession() + .queryBuilder(AlarmMessageLocaleBean::class.java) + .where(AlarmMessageLocaleBeanDao.Properties.UserId.eq(userId)) + .offset(offset * LocaleConstant.PAGE_LIMIT) + .orderDesc(AlarmMessageLocaleBeanDao.Properties.AlarmTime) + .limit(LocaleConstant.PAGE_LIMIT) + .list() + } + + private fun queryUnReadMessage(): Int { + return beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.IsRead.eq("0") + ).list().size + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt new file mode 100644 index 0000000..52926a8 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt @@ -0,0 +1,31 @@ +package com.casic.smart.town.sanxi.util; + +import android.app.Activity +import android.view.WindowManager +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object LoadingDialogHub { + private lateinit var loadingDialog: QMUITipDialog + + fun show(activity: Activity, message: String) { + loadingDialog = QMUITipDialog + .Builder(activity) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_LOADING) + .setTipWord(message) + .create() + if (!activity.isDestroyed) { + try { + loadingDialog.show() + } catch (e: WindowManager.BadTokenException) { + e.printStackTrace() + } + } + } + + + fun dismiss() { + if (loadingDialog.isShowing) { + loadingDialog.dismiss() + } + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt new file mode 100644 index 0000000..de61c9a --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.util + +import android.Manifest + +object LocaleConstant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.READ_PHONE_STATE, + Manifest.permission.ACCESS_COARSE_LOCATION, + Manifest.permission.READ_EXTERNAL_STORAGE + ) + + const val PERMISSIONS_CODE = 999 + const val PUSH_REGISTER = 2022100101 + const val PAGE_LIMIT = 20 +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt new file mode 100644 index 0000000..3bea1c9 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt @@ -0,0 +1,112 @@ +package com.casic.smart.town.sanxi.view + +import android.view.KeyEvent +import android.view.MenuItem +import androidx.fragment.app.Fragment +import androidx.viewpager.widget.ViewPager +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.adapter.ViewPagerAdapter +import com.casic.smart.town.sanxi.fragment.AlarmPageFragment +import com.casic.smart.town.sanxi.fragment.MonitorPageFragment +import com.casic.smart.town.sanxi.fragment.StatisticsPageFragment +import com.gyf.immersionbar.ImmersionBar +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.base.KotlinBaseActivity +import com.pengxh.kt.lite.extensions.convertColor +import com.pengxh.kt.lite.extensions.show +import com.pengxh.kt.lite.utils.ImmerseStatusBarUtil +import com.pengxh.kt.lite.utils.WeakReferenceHandler +import kotlinx.android.synthetic.main.activity_main.* + +class MainActivity : KotlinBaseActivity() { + + companion object { + lateinit var weakReferenceHandler: WeakReferenceHandler + } + + private val kTag = "MainActivity" + private var menuItem: MenuItem? = null + private var fragmentPages: ArrayList = ArrayList() + private var clickTime: Long = 0 + + init { + fragmentPages.add(StatisticsPageFragment()) + fragmentPages.add(MonitorPageFragment()) + fragmentPages.add(AlarmPageFragment()) + } + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + ImmersionBar.with(this).statusBarDarkFont(false).init() + ImmerseStatusBarUtil.setColor(this, R.color.mainThemeColor.convertColor(this)) + } + + override fun initData() { + //推送,多次调用 SDK 初始化并无影响。 + PushManager.getInstance().initialize(this) + weakReferenceHandler = WeakReferenceHandler { + + true + } + } + + override fun observeRequestState() { + + } + + override fun initEvent() { + bottomNavigation.itemIconTintList = null + bottomNavigation.setOnNavigationItemSelectedListener { menuItem -> + when (menuItem.itemId) { + R.id.nav_statistics -> { + mainViewPager.currentItem = 0 + } + R.id.nav_monitor -> { + mainViewPager.currentItem = 1 + } + R.id.nav_alarm -> { + mainViewPager.currentItem = 2 + } + } + false + } + mainViewPager.adapter = ViewPagerAdapter(fragmentPages, supportFragmentManager) + mainViewPager.offscreenPageLimit = fragmentPages.size //缓存页数 + mainViewPager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener { + override fun onPageScrollStateChanged(state: Int) { + + } + + override fun onPageScrolled( + position: Int, + positionOffset: Float, + positionOffsetPixels: Int + ) { + + } + + override fun onPageSelected(position: Int) { + if (menuItem != null) { + menuItem!!.isChecked = false + } else { + bottomNavigation.menu.getItem(0).isChecked = false + } + menuItem = bottomNavigation.menu.getItem(position) + menuItem!!.isChecked = true + } + }) + } + + override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean { + return if (keyCode == KeyEvent.KEYCODE_BACK) { + if (System.currentTimeMillis() - clickTime > 2000) { + "再按一次退出程序".show(this) + clickTime = System.currentTimeMillis() + true + } else { + super.onKeyDown(keyCode, event) + } + } else super.onKeyDown(keyCode, event) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt new file mode 100644 index 0000000..c5d8b22 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.view + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseActivity + +class MonitorRecordActivity : KotlinBaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_monitor_record + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt new file mode 100644 index 0000000..c478d83 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt @@ -0,0 +1,55 @@ +package com.casic.smart.town.sanxi.view + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.amap.api.maps.MapsInitializer +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.gyf.immersionbar.ImmersionBar +import com.pengxh.kt.lite.extensions.navigatePageTo +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + ImmersionBar.with(this).statusBarDarkFont(true).init() + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (EasyPermissions.hasPermissions(this, *LocaleConstant.USER_PERMISSIONS)) { + startSplashScreenActivity() + } else { + EasyPermissions.requestPermissions( + this@PermissionActivity, + resources.getString(R.string.app_name) + "需要获取相关权限", + LocaleConstant.PERMISSIONS_CODE, + *LocaleConstant.USER_PERMISSIONS + ) + } + } + + private fun startSplashScreenActivity() { + //先把导航隐私政策声明,后面导航会用到 + MapsInitializer.updatePrivacyAgree(this, true) + MapsInitializer.updatePrivacyShow(this, true, true) + this.navigatePageTo() + 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) { + startSplashScreenActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable/alarm_selector.xml b/app/src/main/res/drawable/alarm_selector.xml new file mode 100644 index 0000000..39b2595 --- /dev/null +++ b/app/src/main/res/drawable/alarm_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bottom_text_color.xml b/app/src/main/res/drawable/bottom_text_color.xml new file mode 100644 index 0000000..b284ea3 --- /dev/null +++ b/app/src/main/res/drawable/bottom_text_color.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_alarm.xml b/app/src/main/res/drawable/ic_alarm.xml new file mode 100644 index 0000000..dc33aab --- /dev/null +++ b/app/src/main/res/drawable/ic_alarm.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_alarm_selected.xml b/app/src/main/res/drawable/ic_alarm_selected.xml new file mode 100644 index 0000000..993fea6 --- /dev/null +++ b/app/src/main/res/drawable/ic_alarm_selected.xml @@ -0,0 +1,9 @@ + + + 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_monitor.xml b/app/src/main/res/drawable/ic_monitor.xml new file mode 100644 index 0000000..271f5b4 --- /dev/null +++ b/app/src/main/res/drawable/ic_monitor.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_monitor_selected.xml b/app/src/main/res/drawable/ic_monitor_selected.xml new file mode 100644 index 0000000..ee62d84 --- /dev/null +++ b/app/src/main/res/drawable/ic_monitor_selected.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_statistics.xml b/app/src/main/res/drawable/ic_statistics.xml new file mode 100644 index 0000000..7fde8ec --- /dev/null +++ b/app/src/main/res/drawable/ic_statistics.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_statistics_selected.xml b/app/src/main/res/drawable/ic_statistics_selected.xml new file mode 100644 index 0000000..49b6fcd --- /dev/null +++ b/app/src/main/res/drawable/ic_statistics_selected.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/monitor_selector.xml b/app/src/main/res/drawable/monitor_selector.xml new file mode 100644 index 0000000..fe11e9a --- /dev/null +++ b/app/src/main/res/drawable/monitor_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/statistics_selector.xml b/app/src/main/res/drawable/statistics_selector.xml new file mode 100644 index 0000000..2156cff --- /dev/null +++ b/app/src/main/res/drawable/statistics_selector.xml @@ -0,0 +1,5 @@ + + + + + \ 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..78a4a94 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,27 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_monitor_record.xml b/app/src/main/res/layout/activity_monitor_record.xml new file mode 100644 index 0000000..77d9ef6 --- /dev/null +++ b/app/src/main/res/layout/activity_monitor_record.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_alarm.xml b/app/src/main/res/layout/fragment_alarm.xml new file mode 100644 index 0000000..77d9ef6 --- /dev/null +++ b/app/src/main/res/layout/fragment_alarm.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_monitor.xml b/app/src/main/res/layout/fragment_monitor.xml new file mode 100644 index 0000000..19789c1 --- /dev/null +++ b/app/src/main/res/layout/fragment_monitor.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_statistics.xml b/app/src/main/res/layout/fragment_statistics.xml new file mode 100644 index 0000000..77d9ef6 --- /dev/null +++ b/app/src/main/res/layout/fragment_statistics.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/menu/bottom_nav_menu.xml b/app/src/main/res/menu/bottom_nav_menu.xml new file mode 100644 index 0000000..751fd61 --- /dev/null +++ b/app/src/main/res/menu/bottom_nav_menu.xml @@ -0,0 +1,29 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.webp b/app/src/main/res/mipmap-hdpi/ic_launcher.webp new file mode 100644 index 0000000..c209e78 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp new file mode 100644 index 0000000..b2dfe3d --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.webp b/app/src/main/res/mipmap-mdpi/ic_launcher.webp new file mode 100644 index 0000000..4f0f1d6 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp new file mode 100644 index 0000000..62b611d --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher.webp new file mode 100644 index 0000000..948a307 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..1b9a695 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp Binary files differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp new file mode 100644 index 0000000..28d4b77 --- /dev/null +++ b/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..9287f50 --- /dev/null +++ b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp Binary files differ diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..10cfdbf --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*.iml +.gradle +/local.properties +/.idea +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..a4cd2ca --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,101 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'org.greenrobot.greendao' + +android { +// signingConfigs { +// release { +// storeFile file('/Users/a203/Desktop/AndroidProjects/CasicSmartWell/app/CasicSmartWell.jks') +// storePassword '123456789' +// keyAlias 'key0' +// keyPassword '123456789' +// } +// } + compileSdkVersion 31 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.smart.town.sanxi" + minSdkVersion 23 + targetSdkVersion 31 + versionCode 1 + versionName "1.0.0" + + manifestPlaceholders = [GETUI_APPID: "A9V4DvwLcdAqkFCQuFyhq6"] + } + + buildTypes { + release { + minifyEnabled false +// signingConfig signingConfigs.release + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + + ndk { abiFilters "armeabi", "armeabi-v7a", "arm64-v8" } + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlin { + experimental { + coroutines 'enable' + } + } + + greendao { + schemaVersion 1//数据库版本号 + targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 + daoPackage 'com.casic.smart.town.sanxi.greendao'//设置DaoMaster、DaoSession、Dao包名 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + //基础依赖库 + implementation files('libs/lite-release.aar') + implementation 'androidx.appcompat:appcompat:1.4.2' + implementation 'androidx.core:core-ktx:1.8.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:3.0.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' + //MVVM+LiveData + implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.1" + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0" + implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + //Kotlin协程 + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1' + //图片加载框架 + implementation 'com.github.bumptech.glide:glide:4.9.0' + //返回值转换器 + implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' + implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + //okhttp3日志拦截器 + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //网络请求和接口封装 + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.9.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.9.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' + //高德地图 + implementation 'com.amap.api:3dmap:latest.integration' + //推送SDK + implementation 'com.getui:gtsdk:3.2.10.0' //个推SDK + implementation 'com.getui:gtc:3.1.9.0' //个推核心组件 + //数据库框架 + implementation 'org.greenrobot:greendao:3.3.0' + //桌面角标 + implementation "me.leolin:ShortcutBadger:1.1.22@aar" +} \ No newline at end of file diff --git a/app/libs/lite-release.aar b/app/libs/lite-release.aar new file mode 100644 index 0000000..45da4df --- /dev/null +++ b/app/libs/lite-release.aar Binary files differ diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /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 \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..a83c28a --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/svg/monitor.svg b/app/src/main/assets/svg/monitor.svg new file mode 100644 index 0000000..c8d3e25 --- /dev/null +++ b/app/src/main/assets/svg/monitor.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/msg.svg b/app/src/main/assets/svg/msg.svg new file mode 100644 index 0000000..e864e48 --- /dev/null +++ b/app/src/main/assets/svg/msg.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/statistics.svg b/app/src/main/assets/svg/statistics.svg new file mode 100644 index 0000000..974000e --- /dev/null +++ b/app/src/main/assets/svg/statistics.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt new file mode 100644 index 0000000..6b9cce0 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.adapter + +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentManager +import androidx.fragment.app.FragmentPagerAdapter + +class ViewPagerAdapter(list: ArrayList, manager: FragmentManager) : + FragmentPagerAdapter(manager) { + + private var pageList: List = list + + override fun getItem(position: Int) = pageList[position] + + override fun getCount() = pageList.size +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt new file mode 100644 index 0000000..4e017b1 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt @@ -0,0 +1,40 @@ +package com.casic.smart.town.sanxi.base + +import android.app.Application +import android.util.Log +import com.casic.smart.town.sanxi.greendao.DaoMaster +import com.casic.smart.town.sanxi.greendao.DaoSession +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + private val kTag = "BaseApplication" + + companion object { + private var instance: BaseApplication by Delegates.notNull() + + fun obtainInstance() = instance + + private lateinit var daoSession: DaoSession + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences(this) + //推送 + PushManager.getInstance().initialize(this) + PushManager.getInstance().setDebugLogger(this) { + Log.d(kTag, it) + } + val devOpenHelper = DaoMaster.DevOpenHelper(this, "SmartTown.db", null) + val daoMaster = DaoMaster(devOpenHelper.writableDatabase) + daoSession = daoMaster.newSession() + } + + fun obtainDaoSession(): DaoSession { + return daoSession + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java new file mode 100644 index 0000000..b8f67dc --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java @@ -0,0 +1,133 @@ +package com.casic.smart.town.sanxi.bean; + +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Generated; +import org.greenrobot.greendao.annotation.Id; +import org.greenrobot.greendao.annotation.Unique; + +@Entity +public class AlarmMessageLocaleBean { + @Id(autoincrement = true) + private Long id;//主键自增 + + @Unique + private String messageId; + private String appId; + private String clientId; + private String taskId; + private String userId; + private String title; + private String content; + private String deviceCode; + private String isRead;//0-未读,1-已读 + private String alarmTime; + + @Generated(hash = 566950134) + public AlarmMessageLocaleBean(Long id, String messageId, String appId, + String clientId, String taskId, String userId, String title, + String content, String deviceCode, String isRead, String alarmTime) { + this.id = id; + this.messageId = messageId; + this.appId = appId; + this.clientId = clientId; + this.taskId = taskId; + this.userId = userId; + this.title = title; + this.content = content; + this.deviceCode = deviceCode; + this.isRead = isRead; + this.alarmTime = alarmTime; + } + + @Generated(hash = 1737519562) + public AlarmMessageLocaleBean() { + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getMessageId() { + return this.messageId; + } + + public void setMessageId(String messageId) { + this.messageId = messageId; + } + + public String getAppId() { + return this.appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public String getClientId() { + return this.clientId; + } + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public String getTaskId() { + return this.taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getUserId() { + return this.userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getTitle() { + return this.title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return this.content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getDeviceCode() { + return this.deviceCode; + } + + public void setDeviceCode(String deviceCode) { + this.deviceCode = deviceCode; + } + + public String getIsRead() { + return this.isRead; + } + + public void setIsRead(String isRead) { + this.isRead = isRead; + } + + public String getAlarmTime() { + return this.alarmTime; + } + + public void setAlarmTime(String alarmTime) { + this.alarmTime = alarmTime; + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt new file mode 100644 index 0000000..650e201 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class AlarmPageFragment: KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_alarm + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt new file mode 100644 index 0000000..deac8ac --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt @@ -0,0 +1,76 @@ +package com.casic.smart.town.sanxi.fragment + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.Fragment +import com.amap.api.maps.AMap +import com.amap.api.maps.AMapOptions +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.view.MonitorRecordActivity +import com.pengxh.kt.lite.extensions.navigatePageTo +import com.pengxh.kt.lite.extensions.show +import kotlinx.android.synthetic.main.fragment_monitor.view.* + +class MonitorPageFragment : Fragment() { + + private val kTag = "HomePageFragment" + private lateinit var monitorView: View + private lateinit var aMap: AMap + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? + ): View { + monitorView = inflater.inflate(R.layout.fragment_monitor, container, false) + //地图初始化 + initMap(savedInstanceState) + + monitorView.rightOperateView.setOnClickListener { + requireContext().navigatePageTo() + } + return monitorView + } + + private fun initMap(savedInstanceState: Bundle?) { + monitorView.mapView.onCreate(savedInstanceState) + aMap = monitorView.mapView.map + aMap.mapType = AMap.MAP_TYPE_NORMAL + val uiSettings = aMap.uiSettings + uiSettings.isCompassEnabled = true + uiSettings.zoomPosition = AMapOptions.ZOOM_POSITION_RIGHT_CENTER + uiSettings.isTiltGesturesEnabled = false//不许地图随手势倾斜角度 + + // 地图加载成功监听 +// aMap.addOnMapLoadedListener(this) + // 地图缩放监听 +// aMap.addOnCameraChangeListener(this) + // marker 点击事件监听 +// aMap.addOnMarkerClickListener(this) + // 点击marker弹出自定义popup +// aMap.setInfoWindowAdapter(this) + //信息窗点击事件 +// aMap.addOnInfoWindowClickListener(this) + } + + /***以下是地图生命周期管理************************************************************************/ + override fun onResume() { + super.onResume() + monitorView.mapView.onResume() + } + + override fun onPause() { + super.onPause() + monitorView.mapView.onPause() + } + + override fun onSaveInstanceState(outState: Bundle) { + super.onSaveInstanceState(outState) + monitorView.mapView.onSaveInstanceState(outState) + } + + override fun onDestroy() { + super.onDestroy() + monitorView.mapView.onDestroy() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt new file mode 100644 index 0000000..e84df12 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class StatisticsPageFragment : KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_statistics + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java new file mode 100644 index 0000000..68d7901 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java @@ -0,0 +1,255 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.database.Cursor; +import android.database.sqlite.SQLiteStatement; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.Property; +import org.greenrobot.greendao.internal.DaoConfig; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseStatement; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * DAO for table "ALARM_MESSAGE_LOCALE_BEAN". +*/ +public class AlarmMessageLocaleBeanDao extends AbstractDao { + + public static final String TABLENAME = "ALARM_MESSAGE_LOCALE_BEAN"; + + /** + * Properties of entity AlarmMessageLocaleBean.
+ * Can be used for QueryBuilder and for referencing column names. + */ + public static class Properties { + public final static Property Id = new Property(0, Long.class, "id", true, "_id"); + public final static Property MessageId = new Property(1, String.class, "messageId", false, "MESSAGE_ID"); + public final static Property AppId = new Property(2, String.class, "appId", false, "APP_ID"); + public final static Property ClientId = new Property(3, String.class, "clientId", false, "CLIENT_ID"); + public final static Property TaskId = new Property(4, String.class, "taskId", false, "TASK_ID"); + public final static Property UserId = new Property(5, String.class, "userId", false, "USER_ID"); + public final static Property Title = new Property(6, String.class, "title", false, "TITLE"); + public final static Property Content = new Property(7, String.class, "content", false, "CONTENT"); + public final static Property DeviceCode = new Property(8, String.class, "deviceCode", false, "DEVICE_CODE"); + public final static Property IsRead = new Property(9, String.class, "isRead", false, "IS_READ"); + public final static Property AlarmTime = new Property(10, String.class, "alarmTime", false, "ALARM_TIME"); + } + + + public AlarmMessageLocaleBeanDao(DaoConfig config) { + super(config); + } + + public AlarmMessageLocaleBeanDao(DaoConfig config, DaoSession daoSession) { + super(config, daoSession); + } + + /** Creates the underlying database table. */ + public static void createTable(Database db, boolean ifNotExists) { + String constraint = ifNotExists? "IF NOT EXISTS ": ""; + db.execSQL("CREATE TABLE " + constraint + "\"ALARM_MESSAGE_LOCALE_BEAN\" (" + // + "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id + "\"MESSAGE_ID\" TEXT UNIQUE ," + // 1: messageId + "\"APP_ID\" TEXT," + // 2: appId + "\"CLIENT_ID\" TEXT," + // 3: clientId + "\"TASK_ID\" TEXT," + // 4: taskId + "\"USER_ID\" TEXT," + // 5: userId + "\"TITLE\" TEXT," + // 6: title + "\"CONTENT\" TEXT," + // 7: content + "\"DEVICE_CODE\" TEXT," + // 8: deviceCode + "\"IS_READ\" TEXT," + // 9: isRead + "\"ALARM_TIME\" TEXT);"); // 10: alarmTime + } + + /** Drops the underlying database table. */ + public static void dropTable(Database db, boolean ifExists) { + String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"ALARM_MESSAGE_LOCALE_BEAN\""; + db.execSQL(sql); + } + + @Override + protected final void bindValues(DatabaseStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + protected final void bindValues(SQLiteStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + public Long readKey(Cursor cursor, int offset) { + return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); + } + + @Override + public AlarmMessageLocaleBean readEntity(Cursor cursor, int offset) { + AlarmMessageLocaleBean entity = new AlarmMessageLocaleBean( // + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // messageId + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // appId + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // clientId + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // taskId + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // userId + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // title + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // content + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // deviceCode + cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // isRead + cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10) // alarmTime + ); + return entity; + } + + @Override + public void readEntity(Cursor cursor, AlarmMessageLocaleBean entity, int offset) { + entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); + entity.setMessageId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setAppId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setClientId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setTaskId(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); + entity.setUserId(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setTitle(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setContent(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); + entity.setDeviceCode(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); + entity.setIsRead(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9)); + entity.setAlarmTime(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); + } + + @Override + protected final Long updateKeyAfterInsert(AlarmMessageLocaleBean entity, long rowId) { + entity.setId(rowId); + return rowId; + } + + @Override + public Long getKey(AlarmMessageLocaleBean entity) { + if(entity != null) { + return entity.getId(); + } else { + return null; + } + } + + @Override + public boolean hasKey(AlarmMessageLocaleBean entity) { + return entity.getId() != null; + } + + @Override + protected final boolean isEntityUpdateable() { + return true; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java new file mode 100644 index 0000000..4222c40 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java @@ -0,0 +1,96 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.content.Context; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteDatabase.CursorFactory; +import android.util.Log; + +import org.greenrobot.greendao.AbstractDaoMaster; +import org.greenrobot.greendao.database.StandardDatabase; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseOpenHelper; +import org.greenrobot.greendao.identityscope.IdentityScopeType; + + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * Master of DAO (schema version 1): knows all DAOs. + */ +public class DaoMaster extends AbstractDaoMaster { + public static final int SCHEMA_VERSION = 1; + + /** Creates underlying database table using DAOs. */ + public static void createAllTables(Database db, boolean ifNotExists) { + AlarmMessageLocaleBeanDao.createTable(db, ifNotExists); + } + + /** Drops underlying database table using DAOs. */ + public static void dropAllTables(Database db, boolean ifExists) { + AlarmMessageLocaleBeanDao.dropTable(db, ifExists); + } + + /** + * WARNING: Drops all table on Upgrade! Use only during development. + * Convenience method using a {@link DevOpenHelper}. + */ + public static DaoSession newDevSession(Context context, String name) { + Database db = new DevOpenHelper(context, name).getWritableDb(); + DaoMaster daoMaster = new DaoMaster(db); + return daoMaster.newSession(); + } + + public DaoMaster(SQLiteDatabase db) { + this(new StandardDatabase(db)); + } + + public DaoMaster(Database db) { + super(db, SCHEMA_VERSION); + registerDaoClass(AlarmMessageLocaleBeanDao.class); + } + + public DaoSession newSession() { + return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); + } + + public DaoSession newSession(IdentityScopeType type) { + return new DaoSession(db, type, daoConfigMap); + } + + /** + * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} - + */ + public static abstract class OpenHelper extends DatabaseOpenHelper { + public OpenHelper(Context context, String name) { + super(context, name, SCHEMA_VERSION); + } + + public OpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory, SCHEMA_VERSION); + } + + @Override + public void onCreate(Database db) { + Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); + createAllTables(db, false); + } + } + + /** WARNING: Drops all table on Upgrade! Use only during development. */ + public static class DevOpenHelper extends OpenHelper { + public DevOpenHelper(Context context, String name) { + super(context, name); + } + + public DevOpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory); + } + + @Override + public void onUpgrade(Database db, int oldVersion, int newVersion) { + Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); + dropAllTables(db, true); + onCreate(db); + } + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java new file mode 100644 index 0000000..480ed84 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java @@ -0,0 +1,48 @@ +package com.casic.smart.town.sanxi.greendao; + +import java.util.Map; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.AbstractDaoSession; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.identityscope.IdentityScopeType; +import org.greenrobot.greendao.internal.DaoConfig; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. + +/** + * {@inheritDoc} + * + * @see org.greenrobot.greendao.AbstractDaoSession + */ +public class DaoSession extends AbstractDaoSession { + + private final DaoConfig alarmMessageLocaleBeanDaoConfig; + + private final AlarmMessageLocaleBeanDao alarmMessageLocaleBeanDao; + + public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> + daoConfigMap) { + super(db); + + alarmMessageLocaleBeanDaoConfig = daoConfigMap.get(AlarmMessageLocaleBeanDao.class).clone(); + alarmMessageLocaleBeanDaoConfig.initIdentityScope(type); + + alarmMessageLocaleBeanDao = new AlarmMessageLocaleBeanDao(alarmMessageLocaleBeanDaoConfig, this); + + registerDao(AlarmMessageLocaleBean.class, alarmMessageLocaleBeanDao); + } + + public void clear() { + alarmMessageLocaleBeanDaoConfig.clearIdentityScope(); + } + + public AlarmMessageLocaleBeanDao getAlarmMessageLocaleBeanDao() { + return alarmMessageLocaleBeanDao; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt new file mode 100644 index 0000000..875cb8c --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt @@ -0,0 +1,5 @@ +package com.casic.smart.town.sanxi.service + +import com.igexin.sdk.PushService + +class ApplicationPushService : PushService() \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt new file mode 100644 index 0000000..396129f --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt @@ -0,0 +1,84 @@ +package com.casic.smart.town.sanxi.service + +import android.content.Context +import android.os.Message +import android.util.Log +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.casic.smart.town.sanxi.view.MainActivity +import com.igexin.sdk.GTIntentService +import com.igexin.sdk.message.GTCmdMessage +import com.igexin.sdk.message.GTNotificationMessage +import com.igexin.sdk.message.GTTransmitMessage +import com.pengxh.kt.lite.extensions.toJson + +class PushIntentService : GTIntentService() { + + private val kTag = "SmartWellIntentService" + + override fun onReceiveServicePid(context: Context?, pid: Int) { + + } + + // 透传消息 + override fun onReceiveMessageData(context: Context?, msg: GTTransmitMessage?) { + Log.d(kTag, "透传消息 -> msg = $msg") + } + + // 接收 cid + override fun onReceiveClientId(context: Context?, clientid: String?) { + Log.d(kTag, "onReceiveClientId -> $clientid") + //通知MainActivity注册个推服务 + val msg: Message = MainActivity.weakReferenceHandler.obtainMessage() + msg.what = LocaleConstant.PUSH_REGISTER + msg.obj = clientid + MainActivity.weakReferenceHandler.sendMessage(msg) + } + + // cid 离线上线通知 + override fun onReceiveOnlineState(context: Context?, online: Boolean) { + + } + + // 各种事件处理回执 + override fun onReceiveCommandResult(context: Context?, msg: GTCmdMessage?) { + + } + + // 通知到达 + override fun onNotificationMessageArrived(context: Context?, msg: GTNotificationMessage?) { + //报警 +// { +// "content": "设备编号[412022030361]发生井盖开盖报警", +// "messageId": "380abf9a79d34306a2683dc9bf96ee78", +// "taskId": "OSL-0830_4hmfimp3Vu684wo3SjXso9", +// "title": "告警提醒", +// "appid": "HKv8K9qARd6WckZ1o2Vbu4", +// "clientId": "e78beacc42e9a02ae6fb9087eb2b1171", +// "pkgName": "com.casic.app.smartwell" +// } + if (msg == null) { + return + } + Log.d(kTag, "通知到达 -> msg = ${msg.toJson()}") +// val userDetailJson = SaveKeyValues.getValue(LocaleConstant.USER_DETAIL_MODEL, "") as String +// var userId = "" +// if (userDetailJson.isNotBlank()) { +// val userDataModel = Gson().fromJson( +// userDetailJson, object : TypeToken() {}.type +// ) +// userId = userDataModel.id.toString() +// } +// //解析编号 +// val splitArray = msg.content.split("\\[|\\]".toRegex()) +// DataBaseManager.instance.insertNotice( +// msg.messageId, msg.appid, msg.clientId, msg.taskId, +// userId, msg.title, msg.content, splitArray[1], "0", +// System.currentTimeMillis().timestampToCompleteDate() +// ) + } + + // 通知点击 + override fun onNotificationMessageClicked(context: Context?, msg: GTNotificationMessage?) { + Log.d(kTag, "通知点击 -> msg = $msg") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt new file mode 100644 index 0000000..daa7c38 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt @@ -0,0 +1,14 @@ +package com.casic.smart.town.sanxi.util + +import android.content.Context +import me.leolin.shortcutbadger.ShortcutBadger + +object BadeHelper { + fun setBadgeNum(context: Context, badgeCount: Int) { + if (badgeCount == 0) { + ShortcutBadger.removeCount(context) + } else { + ShortcutBadger.applyCount(context, badgeCount) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt new file mode 100644 index 0000000..0a52ef2 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt @@ -0,0 +1,75 @@ +package com.casic.smart.town.sanxi.util + +import com.casic.smart.town.sanxi.base.BaseApplication +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao + +class DataBaseManager private constructor() { + + companion object { + //Kotlin委托模式双重锁单例 + val instance: DataBaseManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) { + DataBaseManager() + } + } + + private val beanDao = + BaseApplication.obtainInstance().obtainDaoSession().alarmMessageLocaleBeanDao + +// fun insertNotice( +// messageId: String, appid: String, clientId: String, +// taskId: String, userId: String, title: String, +// content: String, deviceCode: String, isRead: String, +// noticeTime: String +// ) { +// val noticeLocaleBean = NoticeLocaleBean() +// noticeLocaleBean.messageId = messageId +// noticeLocaleBean.appid = appid +// noticeLocaleBean.clientId = clientId +// noticeLocaleBean.taskId = taskId +// noticeLocaleBean.userId = userId +// noticeLocaleBean.title = title +// noticeLocaleBean.content = content +// noticeLocaleBean.deviceCode = deviceCode +// noticeLocaleBean.isRead = isRead +// noticeLocaleBean.noticeTime = noticeTime +// beanDao.insert(noticeLocaleBean) +// //角标设置 +// BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadNotice()) +// } + + fun deleteByMessageId(messageId: String) { + val result = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).list() + beanDao.deleteInTx(result) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun updateNoticeByMessageId(messageId: String) { + val noticeLocaleBean = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).unique() ?: return + noticeLocaleBean.isRead = "1" + beanDao.update(noticeLocaleBean) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun queryMessageByPage(userId: String, offset: Int): MutableList { + return BaseApplication.obtainInstance().obtainDaoSession() + .queryBuilder(AlarmMessageLocaleBean::class.java) + .where(AlarmMessageLocaleBeanDao.Properties.UserId.eq(userId)) + .offset(offset * LocaleConstant.PAGE_LIMIT) + .orderDesc(AlarmMessageLocaleBeanDao.Properties.AlarmTime) + .limit(LocaleConstant.PAGE_LIMIT) + .list() + } + + private fun queryUnReadMessage(): Int { + return beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.IsRead.eq("0") + ).list().size + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt new file mode 100644 index 0000000..52926a8 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt @@ -0,0 +1,31 @@ +package com.casic.smart.town.sanxi.util; + +import android.app.Activity +import android.view.WindowManager +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object LoadingDialogHub { + private lateinit var loadingDialog: QMUITipDialog + + fun show(activity: Activity, message: String) { + loadingDialog = QMUITipDialog + .Builder(activity) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_LOADING) + .setTipWord(message) + .create() + if (!activity.isDestroyed) { + try { + loadingDialog.show() + } catch (e: WindowManager.BadTokenException) { + e.printStackTrace() + } + } + } + + + fun dismiss() { + if (loadingDialog.isShowing) { + loadingDialog.dismiss() + } + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt new file mode 100644 index 0000000..de61c9a --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.util + +import android.Manifest + +object LocaleConstant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.READ_PHONE_STATE, + Manifest.permission.ACCESS_COARSE_LOCATION, + Manifest.permission.READ_EXTERNAL_STORAGE + ) + + const val PERMISSIONS_CODE = 999 + const val PUSH_REGISTER = 2022100101 + const val PAGE_LIMIT = 20 +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt new file mode 100644 index 0000000..3bea1c9 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt @@ -0,0 +1,112 @@ +package com.casic.smart.town.sanxi.view + +import android.view.KeyEvent +import android.view.MenuItem +import androidx.fragment.app.Fragment +import androidx.viewpager.widget.ViewPager +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.adapter.ViewPagerAdapter +import com.casic.smart.town.sanxi.fragment.AlarmPageFragment +import com.casic.smart.town.sanxi.fragment.MonitorPageFragment +import com.casic.smart.town.sanxi.fragment.StatisticsPageFragment +import com.gyf.immersionbar.ImmersionBar +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.base.KotlinBaseActivity +import com.pengxh.kt.lite.extensions.convertColor +import com.pengxh.kt.lite.extensions.show +import com.pengxh.kt.lite.utils.ImmerseStatusBarUtil +import com.pengxh.kt.lite.utils.WeakReferenceHandler +import kotlinx.android.synthetic.main.activity_main.* + +class MainActivity : KotlinBaseActivity() { + + companion object { + lateinit var weakReferenceHandler: WeakReferenceHandler + } + + private val kTag = "MainActivity" + private var menuItem: MenuItem? = null + private var fragmentPages: ArrayList = ArrayList() + private var clickTime: Long = 0 + + init { + fragmentPages.add(StatisticsPageFragment()) + fragmentPages.add(MonitorPageFragment()) + fragmentPages.add(AlarmPageFragment()) + } + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + ImmersionBar.with(this).statusBarDarkFont(false).init() + ImmerseStatusBarUtil.setColor(this, R.color.mainThemeColor.convertColor(this)) + } + + override fun initData() { + //推送,多次调用 SDK 初始化并无影响。 + PushManager.getInstance().initialize(this) + weakReferenceHandler = WeakReferenceHandler { + + true + } + } + + override fun observeRequestState() { + + } + + override fun initEvent() { + bottomNavigation.itemIconTintList = null + bottomNavigation.setOnNavigationItemSelectedListener { menuItem -> + when (menuItem.itemId) { + R.id.nav_statistics -> { + mainViewPager.currentItem = 0 + } + R.id.nav_monitor -> { + mainViewPager.currentItem = 1 + } + R.id.nav_alarm -> { + mainViewPager.currentItem = 2 + } + } + false + } + mainViewPager.adapter = ViewPagerAdapter(fragmentPages, supportFragmentManager) + mainViewPager.offscreenPageLimit = fragmentPages.size //缓存页数 + mainViewPager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener { + override fun onPageScrollStateChanged(state: Int) { + + } + + override fun onPageScrolled( + position: Int, + positionOffset: Float, + positionOffsetPixels: Int + ) { + + } + + override fun onPageSelected(position: Int) { + if (menuItem != null) { + menuItem!!.isChecked = false + } else { + bottomNavigation.menu.getItem(0).isChecked = false + } + menuItem = bottomNavigation.menu.getItem(position) + menuItem!!.isChecked = true + } + }) + } + + override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean { + return if (keyCode == KeyEvent.KEYCODE_BACK) { + if (System.currentTimeMillis() - clickTime > 2000) { + "再按一次退出程序".show(this) + clickTime = System.currentTimeMillis() + true + } else { + super.onKeyDown(keyCode, event) + } + } else super.onKeyDown(keyCode, event) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt new file mode 100644 index 0000000..c5d8b22 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.view + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseActivity + +class MonitorRecordActivity : KotlinBaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_monitor_record + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt new file mode 100644 index 0000000..c478d83 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt @@ -0,0 +1,55 @@ +package com.casic.smart.town.sanxi.view + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.amap.api.maps.MapsInitializer +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.gyf.immersionbar.ImmersionBar +import com.pengxh.kt.lite.extensions.navigatePageTo +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + ImmersionBar.with(this).statusBarDarkFont(true).init() + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (EasyPermissions.hasPermissions(this, *LocaleConstant.USER_PERMISSIONS)) { + startSplashScreenActivity() + } else { + EasyPermissions.requestPermissions( + this@PermissionActivity, + resources.getString(R.string.app_name) + "需要获取相关权限", + LocaleConstant.PERMISSIONS_CODE, + *LocaleConstant.USER_PERMISSIONS + ) + } + } + + private fun startSplashScreenActivity() { + //先把导航隐私政策声明,后面导航会用到 + MapsInitializer.updatePrivacyAgree(this, true) + MapsInitializer.updatePrivacyShow(this, true, true) + this.navigatePageTo() + 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) { + startSplashScreenActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable/alarm_selector.xml b/app/src/main/res/drawable/alarm_selector.xml new file mode 100644 index 0000000..39b2595 --- /dev/null +++ b/app/src/main/res/drawable/alarm_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bottom_text_color.xml b/app/src/main/res/drawable/bottom_text_color.xml new file mode 100644 index 0000000..b284ea3 --- /dev/null +++ b/app/src/main/res/drawable/bottom_text_color.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_alarm.xml b/app/src/main/res/drawable/ic_alarm.xml new file mode 100644 index 0000000..dc33aab --- /dev/null +++ b/app/src/main/res/drawable/ic_alarm.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_alarm_selected.xml b/app/src/main/res/drawable/ic_alarm_selected.xml new file mode 100644 index 0000000..993fea6 --- /dev/null +++ b/app/src/main/res/drawable/ic_alarm_selected.xml @@ -0,0 +1,9 @@ + + + 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_monitor.xml b/app/src/main/res/drawable/ic_monitor.xml new file mode 100644 index 0000000..271f5b4 --- /dev/null +++ b/app/src/main/res/drawable/ic_monitor.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_monitor_selected.xml b/app/src/main/res/drawable/ic_monitor_selected.xml new file mode 100644 index 0000000..ee62d84 --- /dev/null +++ b/app/src/main/res/drawable/ic_monitor_selected.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_statistics.xml b/app/src/main/res/drawable/ic_statistics.xml new file mode 100644 index 0000000..7fde8ec --- /dev/null +++ b/app/src/main/res/drawable/ic_statistics.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_statistics_selected.xml b/app/src/main/res/drawable/ic_statistics_selected.xml new file mode 100644 index 0000000..49b6fcd --- /dev/null +++ b/app/src/main/res/drawable/ic_statistics_selected.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/monitor_selector.xml b/app/src/main/res/drawable/monitor_selector.xml new file mode 100644 index 0000000..fe11e9a --- /dev/null +++ b/app/src/main/res/drawable/monitor_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/statistics_selector.xml b/app/src/main/res/drawable/statistics_selector.xml new file mode 100644 index 0000000..2156cff --- /dev/null +++ b/app/src/main/res/drawable/statistics_selector.xml @@ -0,0 +1,5 @@ + + + + + \ 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..78a4a94 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,27 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_monitor_record.xml b/app/src/main/res/layout/activity_monitor_record.xml new file mode 100644 index 0000000..77d9ef6 --- /dev/null +++ b/app/src/main/res/layout/activity_monitor_record.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_alarm.xml b/app/src/main/res/layout/fragment_alarm.xml new file mode 100644 index 0000000..77d9ef6 --- /dev/null +++ b/app/src/main/res/layout/fragment_alarm.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_monitor.xml b/app/src/main/res/layout/fragment_monitor.xml new file mode 100644 index 0000000..19789c1 --- /dev/null +++ b/app/src/main/res/layout/fragment_monitor.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_statistics.xml b/app/src/main/res/layout/fragment_statistics.xml new file mode 100644 index 0000000..77d9ef6 --- /dev/null +++ b/app/src/main/res/layout/fragment_statistics.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/menu/bottom_nav_menu.xml b/app/src/main/res/menu/bottom_nav_menu.xml new file mode 100644 index 0000000..751fd61 --- /dev/null +++ b/app/src/main/res/menu/bottom_nav_menu.xml @@ -0,0 +1,29 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.webp b/app/src/main/res/mipmap-hdpi/ic_launcher.webp new file mode 100644 index 0000000..c209e78 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp new file mode 100644 index 0000000..b2dfe3d --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.webp b/app/src/main/res/mipmap-mdpi/ic_launcher.webp new file mode 100644 index 0000000..4f0f1d6 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp new file mode 100644 index 0000000..62b611d --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher.webp new file mode 100644 index 0000000..948a307 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..1b9a695 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp Binary files differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp new file mode 100644 index 0000000..28d4b77 --- /dev/null +++ b/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..9287f50 --- /dev/null +++ b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp new file mode 100644 index 0000000..aa7d642 --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp Binary files differ diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..10cfdbf --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*.iml +.gradle +/local.properties +/.idea +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..a4cd2ca --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,101 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'org.greenrobot.greendao' + +android { +// signingConfigs { +// release { +// storeFile file('/Users/a203/Desktop/AndroidProjects/CasicSmartWell/app/CasicSmartWell.jks') +// storePassword '123456789' +// keyAlias 'key0' +// keyPassword '123456789' +// } +// } + compileSdkVersion 31 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.smart.town.sanxi" + minSdkVersion 23 + targetSdkVersion 31 + versionCode 1 + versionName "1.0.0" + + manifestPlaceholders = [GETUI_APPID: "A9V4DvwLcdAqkFCQuFyhq6"] + } + + buildTypes { + release { + minifyEnabled false +// signingConfig signingConfigs.release + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + + ndk { abiFilters "armeabi", "armeabi-v7a", "arm64-v8" } + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlin { + experimental { + coroutines 'enable' + } + } + + greendao { + schemaVersion 1//数据库版本号 + targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 + daoPackage 'com.casic.smart.town.sanxi.greendao'//设置DaoMaster、DaoSession、Dao包名 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + //基础依赖库 + implementation files('libs/lite-release.aar') + implementation 'androidx.appcompat:appcompat:1.4.2' + implementation 'androidx.core:core-ktx:1.8.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:3.0.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' + //MVVM+LiveData + implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.1" + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0" + implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + //Kotlin协程 + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1' + //图片加载框架 + implementation 'com.github.bumptech.glide:glide:4.9.0' + //返回值转换器 + implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' + implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + //okhttp3日志拦截器 + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //网络请求和接口封装 + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.9.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.9.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' + //高德地图 + implementation 'com.amap.api:3dmap:latest.integration' + //推送SDK + implementation 'com.getui:gtsdk:3.2.10.0' //个推SDK + implementation 'com.getui:gtc:3.1.9.0' //个推核心组件 + //数据库框架 + implementation 'org.greenrobot:greendao:3.3.0' + //桌面角标 + implementation "me.leolin:ShortcutBadger:1.1.22@aar" +} \ No newline at end of file diff --git a/app/libs/lite-release.aar b/app/libs/lite-release.aar new file mode 100644 index 0000000..45da4df --- /dev/null +++ b/app/libs/lite-release.aar Binary files differ diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /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 \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..a83c28a --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/svg/monitor.svg b/app/src/main/assets/svg/monitor.svg new file mode 100644 index 0000000..c8d3e25 --- /dev/null +++ b/app/src/main/assets/svg/monitor.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/msg.svg b/app/src/main/assets/svg/msg.svg new file mode 100644 index 0000000..e864e48 --- /dev/null +++ b/app/src/main/assets/svg/msg.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/statistics.svg b/app/src/main/assets/svg/statistics.svg new file mode 100644 index 0000000..974000e --- /dev/null +++ b/app/src/main/assets/svg/statistics.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt new file mode 100644 index 0000000..6b9cce0 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.adapter + +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentManager +import androidx.fragment.app.FragmentPagerAdapter + +class ViewPagerAdapter(list: ArrayList, manager: FragmentManager) : + FragmentPagerAdapter(manager) { + + private var pageList: List = list + + override fun getItem(position: Int) = pageList[position] + + override fun getCount() = pageList.size +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt new file mode 100644 index 0000000..4e017b1 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt @@ -0,0 +1,40 @@ +package com.casic.smart.town.sanxi.base + +import android.app.Application +import android.util.Log +import com.casic.smart.town.sanxi.greendao.DaoMaster +import com.casic.smart.town.sanxi.greendao.DaoSession +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + private val kTag = "BaseApplication" + + companion object { + private var instance: BaseApplication by Delegates.notNull() + + fun obtainInstance() = instance + + private lateinit var daoSession: DaoSession + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences(this) + //推送 + PushManager.getInstance().initialize(this) + PushManager.getInstance().setDebugLogger(this) { + Log.d(kTag, it) + } + val devOpenHelper = DaoMaster.DevOpenHelper(this, "SmartTown.db", null) + val daoMaster = DaoMaster(devOpenHelper.writableDatabase) + daoSession = daoMaster.newSession() + } + + fun obtainDaoSession(): DaoSession { + return daoSession + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java new file mode 100644 index 0000000..b8f67dc --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java @@ -0,0 +1,133 @@ +package com.casic.smart.town.sanxi.bean; + +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Generated; +import org.greenrobot.greendao.annotation.Id; +import org.greenrobot.greendao.annotation.Unique; + +@Entity +public class AlarmMessageLocaleBean { + @Id(autoincrement = true) + private Long id;//主键自增 + + @Unique + private String messageId; + private String appId; + private String clientId; + private String taskId; + private String userId; + private String title; + private String content; + private String deviceCode; + private String isRead;//0-未读,1-已读 + private String alarmTime; + + @Generated(hash = 566950134) + public AlarmMessageLocaleBean(Long id, String messageId, String appId, + String clientId, String taskId, String userId, String title, + String content, String deviceCode, String isRead, String alarmTime) { + this.id = id; + this.messageId = messageId; + this.appId = appId; + this.clientId = clientId; + this.taskId = taskId; + this.userId = userId; + this.title = title; + this.content = content; + this.deviceCode = deviceCode; + this.isRead = isRead; + this.alarmTime = alarmTime; + } + + @Generated(hash = 1737519562) + public AlarmMessageLocaleBean() { + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getMessageId() { + return this.messageId; + } + + public void setMessageId(String messageId) { + this.messageId = messageId; + } + + public String getAppId() { + return this.appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public String getClientId() { + return this.clientId; + } + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public String getTaskId() { + return this.taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getUserId() { + return this.userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getTitle() { + return this.title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return this.content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getDeviceCode() { + return this.deviceCode; + } + + public void setDeviceCode(String deviceCode) { + this.deviceCode = deviceCode; + } + + public String getIsRead() { + return this.isRead; + } + + public void setIsRead(String isRead) { + this.isRead = isRead; + } + + public String getAlarmTime() { + return this.alarmTime; + } + + public void setAlarmTime(String alarmTime) { + this.alarmTime = alarmTime; + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt new file mode 100644 index 0000000..650e201 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class AlarmPageFragment: KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_alarm + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt new file mode 100644 index 0000000..deac8ac --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt @@ -0,0 +1,76 @@ +package com.casic.smart.town.sanxi.fragment + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.Fragment +import com.amap.api.maps.AMap +import com.amap.api.maps.AMapOptions +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.view.MonitorRecordActivity +import com.pengxh.kt.lite.extensions.navigatePageTo +import com.pengxh.kt.lite.extensions.show +import kotlinx.android.synthetic.main.fragment_monitor.view.* + +class MonitorPageFragment : Fragment() { + + private val kTag = "HomePageFragment" + private lateinit var monitorView: View + private lateinit var aMap: AMap + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? + ): View { + monitorView = inflater.inflate(R.layout.fragment_monitor, container, false) + //地图初始化 + initMap(savedInstanceState) + + monitorView.rightOperateView.setOnClickListener { + requireContext().navigatePageTo() + } + return monitorView + } + + private fun initMap(savedInstanceState: Bundle?) { + monitorView.mapView.onCreate(savedInstanceState) + aMap = monitorView.mapView.map + aMap.mapType = AMap.MAP_TYPE_NORMAL + val uiSettings = aMap.uiSettings + uiSettings.isCompassEnabled = true + uiSettings.zoomPosition = AMapOptions.ZOOM_POSITION_RIGHT_CENTER + uiSettings.isTiltGesturesEnabled = false//不许地图随手势倾斜角度 + + // 地图加载成功监听 +// aMap.addOnMapLoadedListener(this) + // 地图缩放监听 +// aMap.addOnCameraChangeListener(this) + // marker 点击事件监听 +// aMap.addOnMarkerClickListener(this) + // 点击marker弹出自定义popup +// aMap.setInfoWindowAdapter(this) + //信息窗点击事件 +// aMap.addOnInfoWindowClickListener(this) + } + + /***以下是地图生命周期管理************************************************************************/ + override fun onResume() { + super.onResume() + monitorView.mapView.onResume() + } + + override fun onPause() { + super.onPause() + monitorView.mapView.onPause() + } + + override fun onSaveInstanceState(outState: Bundle) { + super.onSaveInstanceState(outState) + monitorView.mapView.onSaveInstanceState(outState) + } + + override fun onDestroy() { + super.onDestroy() + monitorView.mapView.onDestroy() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt new file mode 100644 index 0000000..e84df12 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class StatisticsPageFragment : KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_statistics + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java new file mode 100644 index 0000000..68d7901 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java @@ -0,0 +1,255 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.database.Cursor; +import android.database.sqlite.SQLiteStatement; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.Property; +import org.greenrobot.greendao.internal.DaoConfig; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseStatement; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * DAO for table "ALARM_MESSAGE_LOCALE_BEAN". +*/ +public class AlarmMessageLocaleBeanDao extends AbstractDao { + + public static final String TABLENAME = "ALARM_MESSAGE_LOCALE_BEAN"; + + /** + * Properties of entity AlarmMessageLocaleBean.
+ * Can be used for QueryBuilder and for referencing column names. + */ + public static class Properties { + public final static Property Id = new Property(0, Long.class, "id", true, "_id"); + public final static Property MessageId = new Property(1, String.class, "messageId", false, "MESSAGE_ID"); + public final static Property AppId = new Property(2, String.class, "appId", false, "APP_ID"); + public final static Property ClientId = new Property(3, String.class, "clientId", false, "CLIENT_ID"); + public final static Property TaskId = new Property(4, String.class, "taskId", false, "TASK_ID"); + public final static Property UserId = new Property(5, String.class, "userId", false, "USER_ID"); + public final static Property Title = new Property(6, String.class, "title", false, "TITLE"); + public final static Property Content = new Property(7, String.class, "content", false, "CONTENT"); + public final static Property DeviceCode = new Property(8, String.class, "deviceCode", false, "DEVICE_CODE"); + public final static Property IsRead = new Property(9, String.class, "isRead", false, "IS_READ"); + public final static Property AlarmTime = new Property(10, String.class, "alarmTime", false, "ALARM_TIME"); + } + + + public AlarmMessageLocaleBeanDao(DaoConfig config) { + super(config); + } + + public AlarmMessageLocaleBeanDao(DaoConfig config, DaoSession daoSession) { + super(config, daoSession); + } + + /** Creates the underlying database table. */ + public static void createTable(Database db, boolean ifNotExists) { + String constraint = ifNotExists? "IF NOT EXISTS ": ""; + db.execSQL("CREATE TABLE " + constraint + "\"ALARM_MESSAGE_LOCALE_BEAN\" (" + // + "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id + "\"MESSAGE_ID\" TEXT UNIQUE ," + // 1: messageId + "\"APP_ID\" TEXT," + // 2: appId + "\"CLIENT_ID\" TEXT," + // 3: clientId + "\"TASK_ID\" TEXT," + // 4: taskId + "\"USER_ID\" TEXT," + // 5: userId + "\"TITLE\" TEXT," + // 6: title + "\"CONTENT\" TEXT," + // 7: content + "\"DEVICE_CODE\" TEXT," + // 8: deviceCode + "\"IS_READ\" TEXT," + // 9: isRead + "\"ALARM_TIME\" TEXT);"); // 10: alarmTime + } + + /** Drops the underlying database table. */ + public static void dropTable(Database db, boolean ifExists) { + String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"ALARM_MESSAGE_LOCALE_BEAN\""; + db.execSQL(sql); + } + + @Override + protected final void bindValues(DatabaseStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + protected final void bindValues(SQLiteStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + public Long readKey(Cursor cursor, int offset) { + return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); + } + + @Override + public AlarmMessageLocaleBean readEntity(Cursor cursor, int offset) { + AlarmMessageLocaleBean entity = new AlarmMessageLocaleBean( // + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // messageId + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // appId + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // clientId + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // taskId + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // userId + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // title + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // content + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // deviceCode + cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // isRead + cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10) // alarmTime + ); + return entity; + } + + @Override + public void readEntity(Cursor cursor, AlarmMessageLocaleBean entity, int offset) { + entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); + entity.setMessageId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setAppId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setClientId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setTaskId(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); + entity.setUserId(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setTitle(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setContent(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); + entity.setDeviceCode(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); + entity.setIsRead(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9)); + entity.setAlarmTime(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); + } + + @Override + protected final Long updateKeyAfterInsert(AlarmMessageLocaleBean entity, long rowId) { + entity.setId(rowId); + return rowId; + } + + @Override + public Long getKey(AlarmMessageLocaleBean entity) { + if(entity != null) { + return entity.getId(); + } else { + return null; + } + } + + @Override + public boolean hasKey(AlarmMessageLocaleBean entity) { + return entity.getId() != null; + } + + @Override + protected final boolean isEntityUpdateable() { + return true; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java new file mode 100644 index 0000000..4222c40 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java @@ -0,0 +1,96 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.content.Context; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteDatabase.CursorFactory; +import android.util.Log; + +import org.greenrobot.greendao.AbstractDaoMaster; +import org.greenrobot.greendao.database.StandardDatabase; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseOpenHelper; +import org.greenrobot.greendao.identityscope.IdentityScopeType; + + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * Master of DAO (schema version 1): knows all DAOs. + */ +public class DaoMaster extends AbstractDaoMaster { + public static final int SCHEMA_VERSION = 1; + + /** Creates underlying database table using DAOs. */ + public static void createAllTables(Database db, boolean ifNotExists) { + AlarmMessageLocaleBeanDao.createTable(db, ifNotExists); + } + + /** Drops underlying database table using DAOs. */ + public static void dropAllTables(Database db, boolean ifExists) { + AlarmMessageLocaleBeanDao.dropTable(db, ifExists); + } + + /** + * WARNING: Drops all table on Upgrade! Use only during development. + * Convenience method using a {@link DevOpenHelper}. + */ + public static DaoSession newDevSession(Context context, String name) { + Database db = new DevOpenHelper(context, name).getWritableDb(); + DaoMaster daoMaster = new DaoMaster(db); + return daoMaster.newSession(); + } + + public DaoMaster(SQLiteDatabase db) { + this(new StandardDatabase(db)); + } + + public DaoMaster(Database db) { + super(db, SCHEMA_VERSION); + registerDaoClass(AlarmMessageLocaleBeanDao.class); + } + + public DaoSession newSession() { + return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); + } + + public DaoSession newSession(IdentityScopeType type) { + return new DaoSession(db, type, daoConfigMap); + } + + /** + * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} - + */ + public static abstract class OpenHelper extends DatabaseOpenHelper { + public OpenHelper(Context context, String name) { + super(context, name, SCHEMA_VERSION); + } + + public OpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory, SCHEMA_VERSION); + } + + @Override + public void onCreate(Database db) { + Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); + createAllTables(db, false); + } + } + + /** WARNING: Drops all table on Upgrade! Use only during development. */ + public static class DevOpenHelper extends OpenHelper { + public DevOpenHelper(Context context, String name) { + super(context, name); + } + + public DevOpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory); + } + + @Override + public void onUpgrade(Database db, int oldVersion, int newVersion) { + Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); + dropAllTables(db, true); + onCreate(db); + } + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java new file mode 100644 index 0000000..480ed84 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java @@ -0,0 +1,48 @@ +package com.casic.smart.town.sanxi.greendao; + +import java.util.Map; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.AbstractDaoSession; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.identityscope.IdentityScopeType; +import org.greenrobot.greendao.internal.DaoConfig; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. + +/** + * {@inheritDoc} + * + * @see org.greenrobot.greendao.AbstractDaoSession + */ +public class DaoSession extends AbstractDaoSession { + + private final DaoConfig alarmMessageLocaleBeanDaoConfig; + + private final AlarmMessageLocaleBeanDao alarmMessageLocaleBeanDao; + + public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> + daoConfigMap) { + super(db); + + alarmMessageLocaleBeanDaoConfig = daoConfigMap.get(AlarmMessageLocaleBeanDao.class).clone(); + alarmMessageLocaleBeanDaoConfig.initIdentityScope(type); + + alarmMessageLocaleBeanDao = new AlarmMessageLocaleBeanDao(alarmMessageLocaleBeanDaoConfig, this); + + registerDao(AlarmMessageLocaleBean.class, alarmMessageLocaleBeanDao); + } + + public void clear() { + alarmMessageLocaleBeanDaoConfig.clearIdentityScope(); + } + + public AlarmMessageLocaleBeanDao getAlarmMessageLocaleBeanDao() { + return alarmMessageLocaleBeanDao; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt new file mode 100644 index 0000000..875cb8c --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt @@ -0,0 +1,5 @@ +package com.casic.smart.town.sanxi.service + +import com.igexin.sdk.PushService + +class ApplicationPushService : PushService() \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt new file mode 100644 index 0000000..396129f --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt @@ -0,0 +1,84 @@ +package com.casic.smart.town.sanxi.service + +import android.content.Context +import android.os.Message +import android.util.Log +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.casic.smart.town.sanxi.view.MainActivity +import com.igexin.sdk.GTIntentService +import com.igexin.sdk.message.GTCmdMessage +import com.igexin.sdk.message.GTNotificationMessage +import com.igexin.sdk.message.GTTransmitMessage +import com.pengxh.kt.lite.extensions.toJson + +class PushIntentService : GTIntentService() { + + private val kTag = "SmartWellIntentService" + + override fun onReceiveServicePid(context: Context?, pid: Int) { + + } + + // 透传消息 + override fun onReceiveMessageData(context: Context?, msg: GTTransmitMessage?) { + Log.d(kTag, "透传消息 -> msg = $msg") + } + + // 接收 cid + override fun onReceiveClientId(context: Context?, clientid: String?) { + Log.d(kTag, "onReceiveClientId -> $clientid") + //通知MainActivity注册个推服务 + val msg: Message = MainActivity.weakReferenceHandler.obtainMessage() + msg.what = LocaleConstant.PUSH_REGISTER + msg.obj = clientid + MainActivity.weakReferenceHandler.sendMessage(msg) + } + + // cid 离线上线通知 + override fun onReceiveOnlineState(context: Context?, online: Boolean) { + + } + + // 各种事件处理回执 + override fun onReceiveCommandResult(context: Context?, msg: GTCmdMessage?) { + + } + + // 通知到达 + override fun onNotificationMessageArrived(context: Context?, msg: GTNotificationMessage?) { + //报警 +// { +// "content": "设备编号[412022030361]发生井盖开盖报警", +// "messageId": "380abf9a79d34306a2683dc9bf96ee78", +// "taskId": "OSL-0830_4hmfimp3Vu684wo3SjXso9", +// "title": "告警提醒", +// "appid": "HKv8K9qARd6WckZ1o2Vbu4", +// "clientId": "e78beacc42e9a02ae6fb9087eb2b1171", +// "pkgName": "com.casic.app.smartwell" +// } + if (msg == null) { + return + } + Log.d(kTag, "通知到达 -> msg = ${msg.toJson()}") +// val userDetailJson = SaveKeyValues.getValue(LocaleConstant.USER_DETAIL_MODEL, "") as String +// var userId = "" +// if (userDetailJson.isNotBlank()) { +// val userDataModel = Gson().fromJson( +// userDetailJson, object : TypeToken() {}.type +// ) +// userId = userDataModel.id.toString() +// } +// //解析编号 +// val splitArray = msg.content.split("\\[|\\]".toRegex()) +// DataBaseManager.instance.insertNotice( +// msg.messageId, msg.appid, msg.clientId, msg.taskId, +// userId, msg.title, msg.content, splitArray[1], "0", +// System.currentTimeMillis().timestampToCompleteDate() +// ) + } + + // 通知点击 + override fun onNotificationMessageClicked(context: Context?, msg: GTNotificationMessage?) { + Log.d(kTag, "通知点击 -> msg = $msg") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt new file mode 100644 index 0000000..daa7c38 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt @@ -0,0 +1,14 @@ +package com.casic.smart.town.sanxi.util + +import android.content.Context +import me.leolin.shortcutbadger.ShortcutBadger + +object BadeHelper { + fun setBadgeNum(context: Context, badgeCount: Int) { + if (badgeCount == 0) { + ShortcutBadger.removeCount(context) + } else { + ShortcutBadger.applyCount(context, badgeCount) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt new file mode 100644 index 0000000..0a52ef2 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt @@ -0,0 +1,75 @@ +package com.casic.smart.town.sanxi.util + +import com.casic.smart.town.sanxi.base.BaseApplication +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao + +class DataBaseManager private constructor() { + + companion object { + //Kotlin委托模式双重锁单例 + val instance: DataBaseManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) { + DataBaseManager() + } + } + + private val beanDao = + BaseApplication.obtainInstance().obtainDaoSession().alarmMessageLocaleBeanDao + +// fun insertNotice( +// messageId: String, appid: String, clientId: String, +// taskId: String, userId: String, title: String, +// content: String, deviceCode: String, isRead: String, +// noticeTime: String +// ) { +// val noticeLocaleBean = NoticeLocaleBean() +// noticeLocaleBean.messageId = messageId +// noticeLocaleBean.appid = appid +// noticeLocaleBean.clientId = clientId +// noticeLocaleBean.taskId = taskId +// noticeLocaleBean.userId = userId +// noticeLocaleBean.title = title +// noticeLocaleBean.content = content +// noticeLocaleBean.deviceCode = deviceCode +// noticeLocaleBean.isRead = isRead +// noticeLocaleBean.noticeTime = noticeTime +// beanDao.insert(noticeLocaleBean) +// //角标设置 +// BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadNotice()) +// } + + fun deleteByMessageId(messageId: String) { + val result = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).list() + beanDao.deleteInTx(result) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun updateNoticeByMessageId(messageId: String) { + val noticeLocaleBean = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).unique() ?: return + noticeLocaleBean.isRead = "1" + beanDao.update(noticeLocaleBean) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun queryMessageByPage(userId: String, offset: Int): MutableList { + return BaseApplication.obtainInstance().obtainDaoSession() + .queryBuilder(AlarmMessageLocaleBean::class.java) + .where(AlarmMessageLocaleBeanDao.Properties.UserId.eq(userId)) + .offset(offset * LocaleConstant.PAGE_LIMIT) + .orderDesc(AlarmMessageLocaleBeanDao.Properties.AlarmTime) + .limit(LocaleConstant.PAGE_LIMIT) + .list() + } + + private fun queryUnReadMessage(): Int { + return beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.IsRead.eq("0") + ).list().size + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt new file mode 100644 index 0000000..52926a8 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt @@ -0,0 +1,31 @@ +package com.casic.smart.town.sanxi.util; + +import android.app.Activity +import android.view.WindowManager +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object LoadingDialogHub { + private lateinit var loadingDialog: QMUITipDialog + + fun show(activity: Activity, message: String) { + loadingDialog = QMUITipDialog + .Builder(activity) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_LOADING) + .setTipWord(message) + .create() + if (!activity.isDestroyed) { + try { + loadingDialog.show() + } catch (e: WindowManager.BadTokenException) { + e.printStackTrace() + } + } + } + + + fun dismiss() { + if (loadingDialog.isShowing) { + loadingDialog.dismiss() + } + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt new file mode 100644 index 0000000..de61c9a --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.util + +import android.Manifest + +object LocaleConstant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.READ_PHONE_STATE, + Manifest.permission.ACCESS_COARSE_LOCATION, + Manifest.permission.READ_EXTERNAL_STORAGE + ) + + const val PERMISSIONS_CODE = 999 + const val PUSH_REGISTER = 2022100101 + const val PAGE_LIMIT = 20 +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt new file mode 100644 index 0000000..3bea1c9 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt @@ -0,0 +1,112 @@ +package com.casic.smart.town.sanxi.view + +import android.view.KeyEvent +import android.view.MenuItem +import androidx.fragment.app.Fragment +import androidx.viewpager.widget.ViewPager +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.adapter.ViewPagerAdapter +import com.casic.smart.town.sanxi.fragment.AlarmPageFragment +import com.casic.smart.town.sanxi.fragment.MonitorPageFragment +import com.casic.smart.town.sanxi.fragment.StatisticsPageFragment +import com.gyf.immersionbar.ImmersionBar +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.base.KotlinBaseActivity +import com.pengxh.kt.lite.extensions.convertColor +import com.pengxh.kt.lite.extensions.show +import com.pengxh.kt.lite.utils.ImmerseStatusBarUtil +import com.pengxh.kt.lite.utils.WeakReferenceHandler +import kotlinx.android.synthetic.main.activity_main.* + +class MainActivity : KotlinBaseActivity() { + + companion object { + lateinit var weakReferenceHandler: WeakReferenceHandler + } + + private val kTag = "MainActivity" + private var menuItem: MenuItem? = null + private var fragmentPages: ArrayList = ArrayList() + private var clickTime: Long = 0 + + init { + fragmentPages.add(StatisticsPageFragment()) + fragmentPages.add(MonitorPageFragment()) + fragmentPages.add(AlarmPageFragment()) + } + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + ImmersionBar.with(this).statusBarDarkFont(false).init() + ImmerseStatusBarUtil.setColor(this, R.color.mainThemeColor.convertColor(this)) + } + + override fun initData() { + //推送,多次调用 SDK 初始化并无影响。 + PushManager.getInstance().initialize(this) + weakReferenceHandler = WeakReferenceHandler { + + true + } + } + + override fun observeRequestState() { + + } + + override fun initEvent() { + bottomNavigation.itemIconTintList = null + bottomNavigation.setOnNavigationItemSelectedListener { menuItem -> + when (menuItem.itemId) { + R.id.nav_statistics -> { + mainViewPager.currentItem = 0 + } + R.id.nav_monitor -> { + mainViewPager.currentItem = 1 + } + R.id.nav_alarm -> { + mainViewPager.currentItem = 2 + } + } + false + } + mainViewPager.adapter = ViewPagerAdapter(fragmentPages, supportFragmentManager) + mainViewPager.offscreenPageLimit = fragmentPages.size //缓存页数 + mainViewPager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener { + override fun onPageScrollStateChanged(state: Int) { + + } + + override fun onPageScrolled( + position: Int, + positionOffset: Float, + positionOffsetPixels: Int + ) { + + } + + override fun onPageSelected(position: Int) { + if (menuItem != null) { + menuItem!!.isChecked = false + } else { + bottomNavigation.menu.getItem(0).isChecked = false + } + menuItem = bottomNavigation.menu.getItem(position) + menuItem!!.isChecked = true + } + }) + } + + override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean { + return if (keyCode == KeyEvent.KEYCODE_BACK) { + if (System.currentTimeMillis() - clickTime > 2000) { + "再按一次退出程序".show(this) + clickTime = System.currentTimeMillis() + true + } else { + super.onKeyDown(keyCode, event) + } + } else super.onKeyDown(keyCode, event) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt new file mode 100644 index 0000000..c5d8b22 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.view + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseActivity + +class MonitorRecordActivity : KotlinBaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_monitor_record + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt new file mode 100644 index 0000000..c478d83 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt @@ -0,0 +1,55 @@ +package com.casic.smart.town.sanxi.view + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.amap.api.maps.MapsInitializer +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.gyf.immersionbar.ImmersionBar +import com.pengxh.kt.lite.extensions.navigatePageTo +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + ImmersionBar.with(this).statusBarDarkFont(true).init() + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (EasyPermissions.hasPermissions(this, *LocaleConstant.USER_PERMISSIONS)) { + startSplashScreenActivity() + } else { + EasyPermissions.requestPermissions( + this@PermissionActivity, + resources.getString(R.string.app_name) + "需要获取相关权限", + LocaleConstant.PERMISSIONS_CODE, + *LocaleConstant.USER_PERMISSIONS + ) + } + } + + private fun startSplashScreenActivity() { + //先把导航隐私政策声明,后面导航会用到 + MapsInitializer.updatePrivacyAgree(this, true) + MapsInitializer.updatePrivacyShow(this, true, true) + this.navigatePageTo() + 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) { + startSplashScreenActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable/alarm_selector.xml b/app/src/main/res/drawable/alarm_selector.xml new file mode 100644 index 0000000..39b2595 --- /dev/null +++ b/app/src/main/res/drawable/alarm_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bottom_text_color.xml b/app/src/main/res/drawable/bottom_text_color.xml new file mode 100644 index 0000000..b284ea3 --- /dev/null +++ b/app/src/main/res/drawable/bottom_text_color.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_alarm.xml b/app/src/main/res/drawable/ic_alarm.xml new file mode 100644 index 0000000..dc33aab --- /dev/null +++ b/app/src/main/res/drawable/ic_alarm.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_alarm_selected.xml b/app/src/main/res/drawable/ic_alarm_selected.xml new file mode 100644 index 0000000..993fea6 --- /dev/null +++ b/app/src/main/res/drawable/ic_alarm_selected.xml @@ -0,0 +1,9 @@ + + + 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_monitor.xml b/app/src/main/res/drawable/ic_monitor.xml new file mode 100644 index 0000000..271f5b4 --- /dev/null +++ b/app/src/main/res/drawable/ic_monitor.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_monitor_selected.xml b/app/src/main/res/drawable/ic_monitor_selected.xml new file mode 100644 index 0000000..ee62d84 --- /dev/null +++ b/app/src/main/res/drawable/ic_monitor_selected.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_statistics.xml b/app/src/main/res/drawable/ic_statistics.xml new file mode 100644 index 0000000..7fde8ec --- /dev/null +++ b/app/src/main/res/drawable/ic_statistics.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_statistics_selected.xml b/app/src/main/res/drawable/ic_statistics_selected.xml new file mode 100644 index 0000000..49b6fcd --- /dev/null +++ b/app/src/main/res/drawable/ic_statistics_selected.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/monitor_selector.xml b/app/src/main/res/drawable/monitor_selector.xml new file mode 100644 index 0000000..fe11e9a --- /dev/null +++ b/app/src/main/res/drawable/monitor_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/statistics_selector.xml b/app/src/main/res/drawable/statistics_selector.xml new file mode 100644 index 0000000..2156cff --- /dev/null +++ b/app/src/main/res/drawable/statistics_selector.xml @@ -0,0 +1,5 @@ + + + + + \ 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..78a4a94 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,27 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_monitor_record.xml b/app/src/main/res/layout/activity_monitor_record.xml new file mode 100644 index 0000000..77d9ef6 --- /dev/null +++ b/app/src/main/res/layout/activity_monitor_record.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_alarm.xml b/app/src/main/res/layout/fragment_alarm.xml new file mode 100644 index 0000000..77d9ef6 --- /dev/null +++ b/app/src/main/res/layout/fragment_alarm.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_monitor.xml b/app/src/main/res/layout/fragment_monitor.xml new file mode 100644 index 0000000..19789c1 --- /dev/null +++ b/app/src/main/res/layout/fragment_monitor.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_statistics.xml b/app/src/main/res/layout/fragment_statistics.xml new file mode 100644 index 0000000..77d9ef6 --- /dev/null +++ b/app/src/main/res/layout/fragment_statistics.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/menu/bottom_nav_menu.xml b/app/src/main/res/menu/bottom_nav_menu.xml new file mode 100644 index 0000000..751fd61 --- /dev/null +++ b/app/src/main/res/menu/bottom_nav_menu.xml @@ -0,0 +1,29 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.webp b/app/src/main/res/mipmap-hdpi/ic_launcher.webp new file mode 100644 index 0000000..c209e78 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp new file mode 100644 index 0000000..b2dfe3d --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.webp b/app/src/main/res/mipmap-mdpi/ic_launcher.webp new file mode 100644 index 0000000..4f0f1d6 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp new file mode 100644 index 0000000..62b611d --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher.webp new file mode 100644 index 0000000..948a307 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..1b9a695 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp Binary files differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp new file mode 100644 index 0000000..28d4b77 --- /dev/null +++ b/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..9287f50 --- /dev/null +++ b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp new file mode 100644 index 0000000..aa7d642 --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..9126ae3 --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp Binary files differ diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..10cfdbf --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*.iml +.gradle +/local.properties +/.idea +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..a4cd2ca --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,101 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'org.greenrobot.greendao' + +android { +// signingConfigs { +// release { +// storeFile file('/Users/a203/Desktop/AndroidProjects/CasicSmartWell/app/CasicSmartWell.jks') +// storePassword '123456789' +// keyAlias 'key0' +// keyPassword '123456789' +// } +// } + compileSdkVersion 31 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.smart.town.sanxi" + minSdkVersion 23 + targetSdkVersion 31 + versionCode 1 + versionName "1.0.0" + + manifestPlaceholders = [GETUI_APPID: "A9V4DvwLcdAqkFCQuFyhq6"] + } + + buildTypes { + release { + minifyEnabled false +// signingConfig signingConfigs.release + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + + ndk { abiFilters "armeabi", "armeabi-v7a", "arm64-v8" } + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlin { + experimental { + coroutines 'enable' + } + } + + greendao { + schemaVersion 1//数据库版本号 + targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 + daoPackage 'com.casic.smart.town.sanxi.greendao'//设置DaoMaster、DaoSession、Dao包名 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + //基础依赖库 + implementation files('libs/lite-release.aar') + implementation 'androidx.appcompat:appcompat:1.4.2' + implementation 'androidx.core:core-ktx:1.8.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:3.0.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' + //MVVM+LiveData + implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.1" + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0" + implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + //Kotlin协程 + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1' + //图片加载框架 + implementation 'com.github.bumptech.glide:glide:4.9.0' + //返回值转换器 + implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' + implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + //okhttp3日志拦截器 + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //网络请求和接口封装 + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.9.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.9.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' + //高德地图 + implementation 'com.amap.api:3dmap:latest.integration' + //推送SDK + implementation 'com.getui:gtsdk:3.2.10.0' //个推SDK + implementation 'com.getui:gtc:3.1.9.0' //个推核心组件 + //数据库框架 + implementation 'org.greenrobot:greendao:3.3.0' + //桌面角标 + implementation "me.leolin:ShortcutBadger:1.1.22@aar" +} \ No newline at end of file diff --git a/app/libs/lite-release.aar b/app/libs/lite-release.aar new file mode 100644 index 0000000..45da4df --- /dev/null +++ b/app/libs/lite-release.aar Binary files differ diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /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 \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..a83c28a --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/svg/monitor.svg b/app/src/main/assets/svg/monitor.svg new file mode 100644 index 0000000..c8d3e25 --- /dev/null +++ b/app/src/main/assets/svg/monitor.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/msg.svg b/app/src/main/assets/svg/msg.svg new file mode 100644 index 0000000..e864e48 --- /dev/null +++ b/app/src/main/assets/svg/msg.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/statistics.svg b/app/src/main/assets/svg/statistics.svg new file mode 100644 index 0000000..974000e --- /dev/null +++ b/app/src/main/assets/svg/statistics.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt new file mode 100644 index 0000000..6b9cce0 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.adapter + +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentManager +import androidx.fragment.app.FragmentPagerAdapter + +class ViewPagerAdapter(list: ArrayList, manager: FragmentManager) : + FragmentPagerAdapter(manager) { + + private var pageList: List = list + + override fun getItem(position: Int) = pageList[position] + + override fun getCount() = pageList.size +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt new file mode 100644 index 0000000..4e017b1 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt @@ -0,0 +1,40 @@ +package com.casic.smart.town.sanxi.base + +import android.app.Application +import android.util.Log +import com.casic.smart.town.sanxi.greendao.DaoMaster +import com.casic.smart.town.sanxi.greendao.DaoSession +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + private val kTag = "BaseApplication" + + companion object { + private var instance: BaseApplication by Delegates.notNull() + + fun obtainInstance() = instance + + private lateinit var daoSession: DaoSession + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences(this) + //推送 + PushManager.getInstance().initialize(this) + PushManager.getInstance().setDebugLogger(this) { + Log.d(kTag, it) + } + val devOpenHelper = DaoMaster.DevOpenHelper(this, "SmartTown.db", null) + val daoMaster = DaoMaster(devOpenHelper.writableDatabase) + daoSession = daoMaster.newSession() + } + + fun obtainDaoSession(): DaoSession { + return daoSession + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java new file mode 100644 index 0000000..b8f67dc --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java @@ -0,0 +1,133 @@ +package com.casic.smart.town.sanxi.bean; + +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Generated; +import org.greenrobot.greendao.annotation.Id; +import org.greenrobot.greendao.annotation.Unique; + +@Entity +public class AlarmMessageLocaleBean { + @Id(autoincrement = true) + private Long id;//主键自增 + + @Unique + private String messageId; + private String appId; + private String clientId; + private String taskId; + private String userId; + private String title; + private String content; + private String deviceCode; + private String isRead;//0-未读,1-已读 + private String alarmTime; + + @Generated(hash = 566950134) + public AlarmMessageLocaleBean(Long id, String messageId, String appId, + String clientId, String taskId, String userId, String title, + String content, String deviceCode, String isRead, String alarmTime) { + this.id = id; + this.messageId = messageId; + this.appId = appId; + this.clientId = clientId; + this.taskId = taskId; + this.userId = userId; + this.title = title; + this.content = content; + this.deviceCode = deviceCode; + this.isRead = isRead; + this.alarmTime = alarmTime; + } + + @Generated(hash = 1737519562) + public AlarmMessageLocaleBean() { + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getMessageId() { + return this.messageId; + } + + public void setMessageId(String messageId) { + this.messageId = messageId; + } + + public String getAppId() { + return this.appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public String getClientId() { + return this.clientId; + } + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public String getTaskId() { + return this.taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getUserId() { + return this.userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getTitle() { + return this.title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return this.content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getDeviceCode() { + return this.deviceCode; + } + + public void setDeviceCode(String deviceCode) { + this.deviceCode = deviceCode; + } + + public String getIsRead() { + return this.isRead; + } + + public void setIsRead(String isRead) { + this.isRead = isRead; + } + + public String getAlarmTime() { + return this.alarmTime; + } + + public void setAlarmTime(String alarmTime) { + this.alarmTime = alarmTime; + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt new file mode 100644 index 0000000..650e201 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class AlarmPageFragment: KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_alarm + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt new file mode 100644 index 0000000..deac8ac --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt @@ -0,0 +1,76 @@ +package com.casic.smart.town.sanxi.fragment + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.Fragment +import com.amap.api.maps.AMap +import com.amap.api.maps.AMapOptions +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.view.MonitorRecordActivity +import com.pengxh.kt.lite.extensions.navigatePageTo +import com.pengxh.kt.lite.extensions.show +import kotlinx.android.synthetic.main.fragment_monitor.view.* + +class MonitorPageFragment : Fragment() { + + private val kTag = "HomePageFragment" + private lateinit var monitorView: View + private lateinit var aMap: AMap + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? + ): View { + monitorView = inflater.inflate(R.layout.fragment_monitor, container, false) + //地图初始化 + initMap(savedInstanceState) + + monitorView.rightOperateView.setOnClickListener { + requireContext().navigatePageTo() + } + return monitorView + } + + private fun initMap(savedInstanceState: Bundle?) { + monitorView.mapView.onCreate(savedInstanceState) + aMap = monitorView.mapView.map + aMap.mapType = AMap.MAP_TYPE_NORMAL + val uiSettings = aMap.uiSettings + uiSettings.isCompassEnabled = true + uiSettings.zoomPosition = AMapOptions.ZOOM_POSITION_RIGHT_CENTER + uiSettings.isTiltGesturesEnabled = false//不许地图随手势倾斜角度 + + // 地图加载成功监听 +// aMap.addOnMapLoadedListener(this) + // 地图缩放监听 +// aMap.addOnCameraChangeListener(this) + // marker 点击事件监听 +// aMap.addOnMarkerClickListener(this) + // 点击marker弹出自定义popup +// aMap.setInfoWindowAdapter(this) + //信息窗点击事件 +// aMap.addOnInfoWindowClickListener(this) + } + + /***以下是地图生命周期管理************************************************************************/ + override fun onResume() { + super.onResume() + monitorView.mapView.onResume() + } + + override fun onPause() { + super.onPause() + monitorView.mapView.onPause() + } + + override fun onSaveInstanceState(outState: Bundle) { + super.onSaveInstanceState(outState) + monitorView.mapView.onSaveInstanceState(outState) + } + + override fun onDestroy() { + super.onDestroy() + monitorView.mapView.onDestroy() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt new file mode 100644 index 0000000..e84df12 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class StatisticsPageFragment : KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_statistics + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java new file mode 100644 index 0000000..68d7901 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java @@ -0,0 +1,255 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.database.Cursor; +import android.database.sqlite.SQLiteStatement; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.Property; +import org.greenrobot.greendao.internal.DaoConfig; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseStatement; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * DAO for table "ALARM_MESSAGE_LOCALE_BEAN". +*/ +public class AlarmMessageLocaleBeanDao extends AbstractDao { + + public static final String TABLENAME = "ALARM_MESSAGE_LOCALE_BEAN"; + + /** + * Properties of entity AlarmMessageLocaleBean.
+ * Can be used for QueryBuilder and for referencing column names. + */ + public static class Properties { + public final static Property Id = new Property(0, Long.class, "id", true, "_id"); + public final static Property MessageId = new Property(1, String.class, "messageId", false, "MESSAGE_ID"); + public final static Property AppId = new Property(2, String.class, "appId", false, "APP_ID"); + public final static Property ClientId = new Property(3, String.class, "clientId", false, "CLIENT_ID"); + public final static Property TaskId = new Property(4, String.class, "taskId", false, "TASK_ID"); + public final static Property UserId = new Property(5, String.class, "userId", false, "USER_ID"); + public final static Property Title = new Property(6, String.class, "title", false, "TITLE"); + public final static Property Content = new Property(7, String.class, "content", false, "CONTENT"); + public final static Property DeviceCode = new Property(8, String.class, "deviceCode", false, "DEVICE_CODE"); + public final static Property IsRead = new Property(9, String.class, "isRead", false, "IS_READ"); + public final static Property AlarmTime = new Property(10, String.class, "alarmTime", false, "ALARM_TIME"); + } + + + public AlarmMessageLocaleBeanDao(DaoConfig config) { + super(config); + } + + public AlarmMessageLocaleBeanDao(DaoConfig config, DaoSession daoSession) { + super(config, daoSession); + } + + /** Creates the underlying database table. */ + public static void createTable(Database db, boolean ifNotExists) { + String constraint = ifNotExists? "IF NOT EXISTS ": ""; + db.execSQL("CREATE TABLE " + constraint + "\"ALARM_MESSAGE_LOCALE_BEAN\" (" + // + "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id + "\"MESSAGE_ID\" TEXT UNIQUE ," + // 1: messageId + "\"APP_ID\" TEXT," + // 2: appId + "\"CLIENT_ID\" TEXT," + // 3: clientId + "\"TASK_ID\" TEXT," + // 4: taskId + "\"USER_ID\" TEXT," + // 5: userId + "\"TITLE\" TEXT," + // 6: title + "\"CONTENT\" TEXT," + // 7: content + "\"DEVICE_CODE\" TEXT," + // 8: deviceCode + "\"IS_READ\" TEXT," + // 9: isRead + "\"ALARM_TIME\" TEXT);"); // 10: alarmTime + } + + /** Drops the underlying database table. */ + public static void dropTable(Database db, boolean ifExists) { + String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"ALARM_MESSAGE_LOCALE_BEAN\""; + db.execSQL(sql); + } + + @Override + protected final void bindValues(DatabaseStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + protected final void bindValues(SQLiteStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + public Long readKey(Cursor cursor, int offset) { + return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); + } + + @Override + public AlarmMessageLocaleBean readEntity(Cursor cursor, int offset) { + AlarmMessageLocaleBean entity = new AlarmMessageLocaleBean( // + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // messageId + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // appId + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // clientId + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // taskId + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // userId + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // title + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // content + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // deviceCode + cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // isRead + cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10) // alarmTime + ); + return entity; + } + + @Override + public void readEntity(Cursor cursor, AlarmMessageLocaleBean entity, int offset) { + entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); + entity.setMessageId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setAppId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setClientId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setTaskId(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); + entity.setUserId(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setTitle(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setContent(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); + entity.setDeviceCode(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); + entity.setIsRead(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9)); + entity.setAlarmTime(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); + } + + @Override + protected final Long updateKeyAfterInsert(AlarmMessageLocaleBean entity, long rowId) { + entity.setId(rowId); + return rowId; + } + + @Override + public Long getKey(AlarmMessageLocaleBean entity) { + if(entity != null) { + return entity.getId(); + } else { + return null; + } + } + + @Override + public boolean hasKey(AlarmMessageLocaleBean entity) { + return entity.getId() != null; + } + + @Override + protected final boolean isEntityUpdateable() { + return true; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java new file mode 100644 index 0000000..4222c40 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java @@ -0,0 +1,96 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.content.Context; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteDatabase.CursorFactory; +import android.util.Log; + +import org.greenrobot.greendao.AbstractDaoMaster; +import org.greenrobot.greendao.database.StandardDatabase; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseOpenHelper; +import org.greenrobot.greendao.identityscope.IdentityScopeType; + + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * Master of DAO (schema version 1): knows all DAOs. + */ +public class DaoMaster extends AbstractDaoMaster { + public static final int SCHEMA_VERSION = 1; + + /** Creates underlying database table using DAOs. */ + public static void createAllTables(Database db, boolean ifNotExists) { + AlarmMessageLocaleBeanDao.createTable(db, ifNotExists); + } + + /** Drops underlying database table using DAOs. */ + public static void dropAllTables(Database db, boolean ifExists) { + AlarmMessageLocaleBeanDao.dropTable(db, ifExists); + } + + /** + * WARNING: Drops all table on Upgrade! Use only during development. + * Convenience method using a {@link DevOpenHelper}. + */ + public static DaoSession newDevSession(Context context, String name) { + Database db = new DevOpenHelper(context, name).getWritableDb(); + DaoMaster daoMaster = new DaoMaster(db); + return daoMaster.newSession(); + } + + public DaoMaster(SQLiteDatabase db) { + this(new StandardDatabase(db)); + } + + public DaoMaster(Database db) { + super(db, SCHEMA_VERSION); + registerDaoClass(AlarmMessageLocaleBeanDao.class); + } + + public DaoSession newSession() { + return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); + } + + public DaoSession newSession(IdentityScopeType type) { + return new DaoSession(db, type, daoConfigMap); + } + + /** + * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} - + */ + public static abstract class OpenHelper extends DatabaseOpenHelper { + public OpenHelper(Context context, String name) { + super(context, name, SCHEMA_VERSION); + } + + public OpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory, SCHEMA_VERSION); + } + + @Override + public void onCreate(Database db) { + Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); + createAllTables(db, false); + } + } + + /** WARNING: Drops all table on Upgrade! Use only during development. */ + public static class DevOpenHelper extends OpenHelper { + public DevOpenHelper(Context context, String name) { + super(context, name); + } + + public DevOpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory); + } + + @Override + public void onUpgrade(Database db, int oldVersion, int newVersion) { + Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); + dropAllTables(db, true); + onCreate(db); + } + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java new file mode 100644 index 0000000..480ed84 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java @@ -0,0 +1,48 @@ +package com.casic.smart.town.sanxi.greendao; + +import java.util.Map; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.AbstractDaoSession; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.identityscope.IdentityScopeType; +import org.greenrobot.greendao.internal.DaoConfig; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. + +/** + * {@inheritDoc} + * + * @see org.greenrobot.greendao.AbstractDaoSession + */ +public class DaoSession extends AbstractDaoSession { + + private final DaoConfig alarmMessageLocaleBeanDaoConfig; + + private final AlarmMessageLocaleBeanDao alarmMessageLocaleBeanDao; + + public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> + daoConfigMap) { + super(db); + + alarmMessageLocaleBeanDaoConfig = daoConfigMap.get(AlarmMessageLocaleBeanDao.class).clone(); + alarmMessageLocaleBeanDaoConfig.initIdentityScope(type); + + alarmMessageLocaleBeanDao = new AlarmMessageLocaleBeanDao(alarmMessageLocaleBeanDaoConfig, this); + + registerDao(AlarmMessageLocaleBean.class, alarmMessageLocaleBeanDao); + } + + public void clear() { + alarmMessageLocaleBeanDaoConfig.clearIdentityScope(); + } + + public AlarmMessageLocaleBeanDao getAlarmMessageLocaleBeanDao() { + return alarmMessageLocaleBeanDao; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt new file mode 100644 index 0000000..875cb8c --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt @@ -0,0 +1,5 @@ +package com.casic.smart.town.sanxi.service + +import com.igexin.sdk.PushService + +class ApplicationPushService : PushService() \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt new file mode 100644 index 0000000..396129f --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt @@ -0,0 +1,84 @@ +package com.casic.smart.town.sanxi.service + +import android.content.Context +import android.os.Message +import android.util.Log +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.casic.smart.town.sanxi.view.MainActivity +import com.igexin.sdk.GTIntentService +import com.igexin.sdk.message.GTCmdMessage +import com.igexin.sdk.message.GTNotificationMessage +import com.igexin.sdk.message.GTTransmitMessage +import com.pengxh.kt.lite.extensions.toJson + +class PushIntentService : GTIntentService() { + + private val kTag = "SmartWellIntentService" + + override fun onReceiveServicePid(context: Context?, pid: Int) { + + } + + // 透传消息 + override fun onReceiveMessageData(context: Context?, msg: GTTransmitMessage?) { + Log.d(kTag, "透传消息 -> msg = $msg") + } + + // 接收 cid + override fun onReceiveClientId(context: Context?, clientid: String?) { + Log.d(kTag, "onReceiveClientId -> $clientid") + //通知MainActivity注册个推服务 + val msg: Message = MainActivity.weakReferenceHandler.obtainMessage() + msg.what = LocaleConstant.PUSH_REGISTER + msg.obj = clientid + MainActivity.weakReferenceHandler.sendMessage(msg) + } + + // cid 离线上线通知 + override fun onReceiveOnlineState(context: Context?, online: Boolean) { + + } + + // 各种事件处理回执 + override fun onReceiveCommandResult(context: Context?, msg: GTCmdMessage?) { + + } + + // 通知到达 + override fun onNotificationMessageArrived(context: Context?, msg: GTNotificationMessage?) { + //报警 +// { +// "content": "设备编号[412022030361]发生井盖开盖报警", +// "messageId": "380abf9a79d34306a2683dc9bf96ee78", +// "taskId": "OSL-0830_4hmfimp3Vu684wo3SjXso9", +// "title": "告警提醒", +// "appid": "HKv8K9qARd6WckZ1o2Vbu4", +// "clientId": "e78beacc42e9a02ae6fb9087eb2b1171", +// "pkgName": "com.casic.app.smartwell" +// } + if (msg == null) { + return + } + Log.d(kTag, "通知到达 -> msg = ${msg.toJson()}") +// val userDetailJson = SaveKeyValues.getValue(LocaleConstant.USER_DETAIL_MODEL, "") as String +// var userId = "" +// if (userDetailJson.isNotBlank()) { +// val userDataModel = Gson().fromJson( +// userDetailJson, object : TypeToken() {}.type +// ) +// userId = userDataModel.id.toString() +// } +// //解析编号 +// val splitArray = msg.content.split("\\[|\\]".toRegex()) +// DataBaseManager.instance.insertNotice( +// msg.messageId, msg.appid, msg.clientId, msg.taskId, +// userId, msg.title, msg.content, splitArray[1], "0", +// System.currentTimeMillis().timestampToCompleteDate() +// ) + } + + // 通知点击 + override fun onNotificationMessageClicked(context: Context?, msg: GTNotificationMessage?) { + Log.d(kTag, "通知点击 -> msg = $msg") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt new file mode 100644 index 0000000..daa7c38 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt @@ -0,0 +1,14 @@ +package com.casic.smart.town.sanxi.util + +import android.content.Context +import me.leolin.shortcutbadger.ShortcutBadger + +object BadeHelper { + fun setBadgeNum(context: Context, badgeCount: Int) { + if (badgeCount == 0) { + ShortcutBadger.removeCount(context) + } else { + ShortcutBadger.applyCount(context, badgeCount) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt new file mode 100644 index 0000000..0a52ef2 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt @@ -0,0 +1,75 @@ +package com.casic.smart.town.sanxi.util + +import com.casic.smart.town.sanxi.base.BaseApplication +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao + +class DataBaseManager private constructor() { + + companion object { + //Kotlin委托模式双重锁单例 + val instance: DataBaseManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) { + DataBaseManager() + } + } + + private val beanDao = + BaseApplication.obtainInstance().obtainDaoSession().alarmMessageLocaleBeanDao + +// fun insertNotice( +// messageId: String, appid: String, clientId: String, +// taskId: String, userId: String, title: String, +// content: String, deviceCode: String, isRead: String, +// noticeTime: String +// ) { +// val noticeLocaleBean = NoticeLocaleBean() +// noticeLocaleBean.messageId = messageId +// noticeLocaleBean.appid = appid +// noticeLocaleBean.clientId = clientId +// noticeLocaleBean.taskId = taskId +// noticeLocaleBean.userId = userId +// noticeLocaleBean.title = title +// noticeLocaleBean.content = content +// noticeLocaleBean.deviceCode = deviceCode +// noticeLocaleBean.isRead = isRead +// noticeLocaleBean.noticeTime = noticeTime +// beanDao.insert(noticeLocaleBean) +// //角标设置 +// BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadNotice()) +// } + + fun deleteByMessageId(messageId: String) { + val result = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).list() + beanDao.deleteInTx(result) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun updateNoticeByMessageId(messageId: String) { + val noticeLocaleBean = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).unique() ?: return + noticeLocaleBean.isRead = "1" + beanDao.update(noticeLocaleBean) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun queryMessageByPage(userId: String, offset: Int): MutableList { + return BaseApplication.obtainInstance().obtainDaoSession() + .queryBuilder(AlarmMessageLocaleBean::class.java) + .where(AlarmMessageLocaleBeanDao.Properties.UserId.eq(userId)) + .offset(offset * LocaleConstant.PAGE_LIMIT) + .orderDesc(AlarmMessageLocaleBeanDao.Properties.AlarmTime) + .limit(LocaleConstant.PAGE_LIMIT) + .list() + } + + private fun queryUnReadMessage(): Int { + return beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.IsRead.eq("0") + ).list().size + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt new file mode 100644 index 0000000..52926a8 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt @@ -0,0 +1,31 @@ +package com.casic.smart.town.sanxi.util; + +import android.app.Activity +import android.view.WindowManager +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object LoadingDialogHub { + private lateinit var loadingDialog: QMUITipDialog + + fun show(activity: Activity, message: String) { + loadingDialog = QMUITipDialog + .Builder(activity) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_LOADING) + .setTipWord(message) + .create() + if (!activity.isDestroyed) { + try { + loadingDialog.show() + } catch (e: WindowManager.BadTokenException) { + e.printStackTrace() + } + } + } + + + fun dismiss() { + if (loadingDialog.isShowing) { + loadingDialog.dismiss() + } + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt new file mode 100644 index 0000000..de61c9a --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.util + +import android.Manifest + +object LocaleConstant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.READ_PHONE_STATE, + Manifest.permission.ACCESS_COARSE_LOCATION, + Manifest.permission.READ_EXTERNAL_STORAGE + ) + + const val PERMISSIONS_CODE = 999 + const val PUSH_REGISTER = 2022100101 + const val PAGE_LIMIT = 20 +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt new file mode 100644 index 0000000..3bea1c9 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt @@ -0,0 +1,112 @@ +package com.casic.smart.town.sanxi.view + +import android.view.KeyEvent +import android.view.MenuItem +import androidx.fragment.app.Fragment +import androidx.viewpager.widget.ViewPager +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.adapter.ViewPagerAdapter +import com.casic.smart.town.sanxi.fragment.AlarmPageFragment +import com.casic.smart.town.sanxi.fragment.MonitorPageFragment +import com.casic.smart.town.sanxi.fragment.StatisticsPageFragment +import com.gyf.immersionbar.ImmersionBar +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.base.KotlinBaseActivity +import com.pengxh.kt.lite.extensions.convertColor +import com.pengxh.kt.lite.extensions.show +import com.pengxh.kt.lite.utils.ImmerseStatusBarUtil +import com.pengxh.kt.lite.utils.WeakReferenceHandler +import kotlinx.android.synthetic.main.activity_main.* + +class MainActivity : KotlinBaseActivity() { + + companion object { + lateinit var weakReferenceHandler: WeakReferenceHandler + } + + private val kTag = "MainActivity" + private var menuItem: MenuItem? = null + private var fragmentPages: ArrayList = ArrayList() + private var clickTime: Long = 0 + + init { + fragmentPages.add(StatisticsPageFragment()) + fragmentPages.add(MonitorPageFragment()) + fragmentPages.add(AlarmPageFragment()) + } + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + ImmersionBar.with(this).statusBarDarkFont(false).init() + ImmerseStatusBarUtil.setColor(this, R.color.mainThemeColor.convertColor(this)) + } + + override fun initData() { + //推送,多次调用 SDK 初始化并无影响。 + PushManager.getInstance().initialize(this) + weakReferenceHandler = WeakReferenceHandler { + + true + } + } + + override fun observeRequestState() { + + } + + override fun initEvent() { + bottomNavigation.itemIconTintList = null + bottomNavigation.setOnNavigationItemSelectedListener { menuItem -> + when (menuItem.itemId) { + R.id.nav_statistics -> { + mainViewPager.currentItem = 0 + } + R.id.nav_monitor -> { + mainViewPager.currentItem = 1 + } + R.id.nav_alarm -> { + mainViewPager.currentItem = 2 + } + } + false + } + mainViewPager.adapter = ViewPagerAdapter(fragmentPages, supportFragmentManager) + mainViewPager.offscreenPageLimit = fragmentPages.size //缓存页数 + mainViewPager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener { + override fun onPageScrollStateChanged(state: Int) { + + } + + override fun onPageScrolled( + position: Int, + positionOffset: Float, + positionOffsetPixels: Int + ) { + + } + + override fun onPageSelected(position: Int) { + if (menuItem != null) { + menuItem!!.isChecked = false + } else { + bottomNavigation.menu.getItem(0).isChecked = false + } + menuItem = bottomNavigation.menu.getItem(position) + menuItem!!.isChecked = true + } + }) + } + + override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean { + return if (keyCode == KeyEvent.KEYCODE_BACK) { + if (System.currentTimeMillis() - clickTime > 2000) { + "再按一次退出程序".show(this) + clickTime = System.currentTimeMillis() + true + } else { + super.onKeyDown(keyCode, event) + } + } else super.onKeyDown(keyCode, event) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt new file mode 100644 index 0000000..c5d8b22 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.view + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseActivity + +class MonitorRecordActivity : KotlinBaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_monitor_record + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt new file mode 100644 index 0000000..c478d83 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt @@ -0,0 +1,55 @@ +package com.casic.smart.town.sanxi.view + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.amap.api.maps.MapsInitializer +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.gyf.immersionbar.ImmersionBar +import com.pengxh.kt.lite.extensions.navigatePageTo +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + ImmersionBar.with(this).statusBarDarkFont(true).init() + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (EasyPermissions.hasPermissions(this, *LocaleConstant.USER_PERMISSIONS)) { + startSplashScreenActivity() + } else { + EasyPermissions.requestPermissions( + this@PermissionActivity, + resources.getString(R.string.app_name) + "需要获取相关权限", + LocaleConstant.PERMISSIONS_CODE, + *LocaleConstant.USER_PERMISSIONS + ) + } + } + + private fun startSplashScreenActivity() { + //先把导航隐私政策声明,后面导航会用到 + MapsInitializer.updatePrivacyAgree(this, true) + MapsInitializer.updatePrivacyShow(this, true, true) + this.navigatePageTo() + 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) { + startSplashScreenActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable/alarm_selector.xml b/app/src/main/res/drawable/alarm_selector.xml new file mode 100644 index 0000000..39b2595 --- /dev/null +++ b/app/src/main/res/drawable/alarm_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bottom_text_color.xml b/app/src/main/res/drawable/bottom_text_color.xml new file mode 100644 index 0000000..b284ea3 --- /dev/null +++ b/app/src/main/res/drawable/bottom_text_color.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_alarm.xml b/app/src/main/res/drawable/ic_alarm.xml new file mode 100644 index 0000000..dc33aab --- /dev/null +++ b/app/src/main/res/drawable/ic_alarm.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_alarm_selected.xml b/app/src/main/res/drawable/ic_alarm_selected.xml new file mode 100644 index 0000000..993fea6 --- /dev/null +++ b/app/src/main/res/drawable/ic_alarm_selected.xml @@ -0,0 +1,9 @@ + + + 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_monitor.xml b/app/src/main/res/drawable/ic_monitor.xml new file mode 100644 index 0000000..271f5b4 --- /dev/null +++ b/app/src/main/res/drawable/ic_monitor.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_monitor_selected.xml b/app/src/main/res/drawable/ic_monitor_selected.xml new file mode 100644 index 0000000..ee62d84 --- /dev/null +++ b/app/src/main/res/drawable/ic_monitor_selected.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_statistics.xml b/app/src/main/res/drawable/ic_statistics.xml new file mode 100644 index 0000000..7fde8ec --- /dev/null +++ b/app/src/main/res/drawable/ic_statistics.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_statistics_selected.xml b/app/src/main/res/drawable/ic_statistics_selected.xml new file mode 100644 index 0000000..49b6fcd --- /dev/null +++ b/app/src/main/res/drawable/ic_statistics_selected.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/monitor_selector.xml b/app/src/main/res/drawable/monitor_selector.xml new file mode 100644 index 0000000..fe11e9a --- /dev/null +++ b/app/src/main/res/drawable/monitor_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/statistics_selector.xml b/app/src/main/res/drawable/statistics_selector.xml new file mode 100644 index 0000000..2156cff --- /dev/null +++ b/app/src/main/res/drawable/statistics_selector.xml @@ -0,0 +1,5 @@ + + + + + \ 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..78a4a94 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,27 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_monitor_record.xml b/app/src/main/res/layout/activity_monitor_record.xml new file mode 100644 index 0000000..77d9ef6 --- /dev/null +++ b/app/src/main/res/layout/activity_monitor_record.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_alarm.xml b/app/src/main/res/layout/fragment_alarm.xml new file mode 100644 index 0000000..77d9ef6 --- /dev/null +++ b/app/src/main/res/layout/fragment_alarm.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_monitor.xml b/app/src/main/res/layout/fragment_monitor.xml new file mode 100644 index 0000000..19789c1 --- /dev/null +++ b/app/src/main/res/layout/fragment_monitor.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_statistics.xml b/app/src/main/res/layout/fragment_statistics.xml new file mode 100644 index 0000000..77d9ef6 --- /dev/null +++ b/app/src/main/res/layout/fragment_statistics.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/menu/bottom_nav_menu.xml b/app/src/main/res/menu/bottom_nav_menu.xml new file mode 100644 index 0000000..751fd61 --- /dev/null +++ b/app/src/main/res/menu/bottom_nav_menu.xml @@ -0,0 +1,29 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.webp b/app/src/main/res/mipmap-hdpi/ic_launcher.webp new file mode 100644 index 0000000..c209e78 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp new file mode 100644 index 0000000..b2dfe3d --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.webp b/app/src/main/res/mipmap-mdpi/ic_launcher.webp new file mode 100644 index 0000000..4f0f1d6 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp new file mode 100644 index 0000000..62b611d --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher.webp new file mode 100644 index 0000000..948a307 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..1b9a695 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp Binary files differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp new file mode 100644 index 0000000..28d4b77 --- /dev/null +++ b/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..9287f50 --- /dev/null +++ b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp new file mode 100644 index 0000000..aa7d642 --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..9126ae3 --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp 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..bbce66f --- /dev/null +++ b/app/src/main/res/values/colors.xml @@ -0,0 +1,14 @@ + + + #1D55C6 + #333333 + #CCCCCC + + #FFBB86FC + #FF6200EE + #FF3700B3 + #FF03DAC5 + #FF018786 + #FF000000 + #FFFFFFFF + \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..10cfdbf --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*.iml +.gradle +/local.properties +/.idea +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..a4cd2ca --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,101 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'org.greenrobot.greendao' + +android { +// signingConfigs { +// release { +// storeFile file('/Users/a203/Desktop/AndroidProjects/CasicSmartWell/app/CasicSmartWell.jks') +// storePassword '123456789' +// keyAlias 'key0' +// keyPassword '123456789' +// } +// } + compileSdkVersion 31 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.smart.town.sanxi" + minSdkVersion 23 + targetSdkVersion 31 + versionCode 1 + versionName "1.0.0" + + manifestPlaceholders = [GETUI_APPID: "A9V4DvwLcdAqkFCQuFyhq6"] + } + + buildTypes { + release { + minifyEnabled false +// signingConfig signingConfigs.release + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + + ndk { abiFilters "armeabi", "armeabi-v7a", "arm64-v8" } + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlin { + experimental { + coroutines 'enable' + } + } + + greendao { + schemaVersion 1//数据库版本号 + targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 + daoPackage 'com.casic.smart.town.sanxi.greendao'//设置DaoMaster、DaoSession、Dao包名 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + //基础依赖库 + implementation files('libs/lite-release.aar') + implementation 'androidx.appcompat:appcompat:1.4.2' + implementation 'androidx.core:core-ktx:1.8.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:3.0.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' + //MVVM+LiveData + implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.1" + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0" + implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + //Kotlin协程 + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1' + //图片加载框架 + implementation 'com.github.bumptech.glide:glide:4.9.0' + //返回值转换器 + implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' + implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + //okhttp3日志拦截器 + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //网络请求和接口封装 + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.9.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.9.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' + //高德地图 + implementation 'com.amap.api:3dmap:latest.integration' + //推送SDK + implementation 'com.getui:gtsdk:3.2.10.0' //个推SDK + implementation 'com.getui:gtc:3.1.9.0' //个推核心组件 + //数据库框架 + implementation 'org.greenrobot:greendao:3.3.0' + //桌面角标 + implementation "me.leolin:ShortcutBadger:1.1.22@aar" +} \ No newline at end of file diff --git a/app/libs/lite-release.aar b/app/libs/lite-release.aar new file mode 100644 index 0000000..45da4df --- /dev/null +++ b/app/libs/lite-release.aar Binary files differ diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /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 \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..a83c28a --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/svg/monitor.svg b/app/src/main/assets/svg/monitor.svg new file mode 100644 index 0000000..c8d3e25 --- /dev/null +++ b/app/src/main/assets/svg/monitor.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/msg.svg b/app/src/main/assets/svg/msg.svg new file mode 100644 index 0000000..e864e48 --- /dev/null +++ b/app/src/main/assets/svg/msg.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/statistics.svg b/app/src/main/assets/svg/statistics.svg new file mode 100644 index 0000000..974000e --- /dev/null +++ b/app/src/main/assets/svg/statistics.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt new file mode 100644 index 0000000..6b9cce0 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.adapter + +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentManager +import androidx.fragment.app.FragmentPagerAdapter + +class ViewPagerAdapter(list: ArrayList, manager: FragmentManager) : + FragmentPagerAdapter(manager) { + + private var pageList: List = list + + override fun getItem(position: Int) = pageList[position] + + override fun getCount() = pageList.size +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt new file mode 100644 index 0000000..4e017b1 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt @@ -0,0 +1,40 @@ +package com.casic.smart.town.sanxi.base + +import android.app.Application +import android.util.Log +import com.casic.smart.town.sanxi.greendao.DaoMaster +import com.casic.smart.town.sanxi.greendao.DaoSession +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + private val kTag = "BaseApplication" + + companion object { + private var instance: BaseApplication by Delegates.notNull() + + fun obtainInstance() = instance + + private lateinit var daoSession: DaoSession + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences(this) + //推送 + PushManager.getInstance().initialize(this) + PushManager.getInstance().setDebugLogger(this) { + Log.d(kTag, it) + } + val devOpenHelper = DaoMaster.DevOpenHelper(this, "SmartTown.db", null) + val daoMaster = DaoMaster(devOpenHelper.writableDatabase) + daoSession = daoMaster.newSession() + } + + fun obtainDaoSession(): DaoSession { + return daoSession + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java new file mode 100644 index 0000000..b8f67dc --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java @@ -0,0 +1,133 @@ +package com.casic.smart.town.sanxi.bean; + +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Generated; +import org.greenrobot.greendao.annotation.Id; +import org.greenrobot.greendao.annotation.Unique; + +@Entity +public class AlarmMessageLocaleBean { + @Id(autoincrement = true) + private Long id;//主键自增 + + @Unique + private String messageId; + private String appId; + private String clientId; + private String taskId; + private String userId; + private String title; + private String content; + private String deviceCode; + private String isRead;//0-未读,1-已读 + private String alarmTime; + + @Generated(hash = 566950134) + public AlarmMessageLocaleBean(Long id, String messageId, String appId, + String clientId, String taskId, String userId, String title, + String content, String deviceCode, String isRead, String alarmTime) { + this.id = id; + this.messageId = messageId; + this.appId = appId; + this.clientId = clientId; + this.taskId = taskId; + this.userId = userId; + this.title = title; + this.content = content; + this.deviceCode = deviceCode; + this.isRead = isRead; + this.alarmTime = alarmTime; + } + + @Generated(hash = 1737519562) + public AlarmMessageLocaleBean() { + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getMessageId() { + return this.messageId; + } + + public void setMessageId(String messageId) { + this.messageId = messageId; + } + + public String getAppId() { + return this.appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public String getClientId() { + return this.clientId; + } + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public String getTaskId() { + return this.taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getUserId() { + return this.userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getTitle() { + return this.title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return this.content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getDeviceCode() { + return this.deviceCode; + } + + public void setDeviceCode(String deviceCode) { + this.deviceCode = deviceCode; + } + + public String getIsRead() { + return this.isRead; + } + + public void setIsRead(String isRead) { + this.isRead = isRead; + } + + public String getAlarmTime() { + return this.alarmTime; + } + + public void setAlarmTime(String alarmTime) { + this.alarmTime = alarmTime; + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt new file mode 100644 index 0000000..650e201 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class AlarmPageFragment: KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_alarm + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt new file mode 100644 index 0000000..deac8ac --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt @@ -0,0 +1,76 @@ +package com.casic.smart.town.sanxi.fragment + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.Fragment +import com.amap.api.maps.AMap +import com.amap.api.maps.AMapOptions +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.view.MonitorRecordActivity +import com.pengxh.kt.lite.extensions.navigatePageTo +import com.pengxh.kt.lite.extensions.show +import kotlinx.android.synthetic.main.fragment_monitor.view.* + +class MonitorPageFragment : Fragment() { + + private val kTag = "HomePageFragment" + private lateinit var monitorView: View + private lateinit var aMap: AMap + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? + ): View { + monitorView = inflater.inflate(R.layout.fragment_monitor, container, false) + //地图初始化 + initMap(savedInstanceState) + + monitorView.rightOperateView.setOnClickListener { + requireContext().navigatePageTo() + } + return monitorView + } + + private fun initMap(savedInstanceState: Bundle?) { + monitorView.mapView.onCreate(savedInstanceState) + aMap = monitorView.mapView.map + aMap.mapType = AMap.MAP_TYPE_NORMAL + val uiSettings = aMap.uiSettings + uiSettings.isCompassEnabled = true + uiSettings.zoomPosition = AMapOptions.ZOOM_POSITION_RIGHT_CENTER + uiSettings.isTiltGesturesEnabled = false//不许地图随手势倾斜角度 + + // 地图加载成功监听 +// aMap.addOnMapLoadedListener(this) + // 地图缩放监听 +// aMap.addOnCameraChangeListener(this) + // marker 点击事件监听 +// aMap.addOnMarkerClickListener(this) + // 点击marker弹出自定义popup +// aMap.setInfoWindowAdapter(this) + //信息窗点击事件 +// aMap.addOnInfoWindowClickListener(this) + } + + /***以下是地图生命周期管理************************************************************************/ + override fun onResume() { + super.onResume() + monitorView.mapView.onResume() + } + + override fun onPause() { + super.onPause() + monitorView.mapView.onPause() + } + + override fun onSaveInstanceState(outState: Bundle) { + super.onSaveInstanceState(outState) + monitorView.mapView.onSaveInstanceState(outState) + } + + override fun onDestroy() { + super.onDestroy() + monitorView.mapView.onDestroy() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt new file mode 100644 index 0000000..e84df12 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class StatisticsPageFragment : KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_statistics + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java new file mode 100644 index 0000000..68d7901 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java @@ -0,0 +1,255 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.database.Cursor; +import android.database.sqlite.SQLiteStatement; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.Property; +import org.greenrobot.greendao.internal.DaoConfig; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseStatement; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * DAO for table "ALARM_MESSAGE_LOCALE_BEAN". +*/ +public class AlarmMessageLocaleBeanDao extends AbstractDao { + + public static final String TABLENAME = "ALARM_MESSAGE_LOCALE_BEAN"; + + /** + * Properties of entity AlarmMessageLocaleBean.
+ * Can be used for QueryBuilder and for referencing column names. + */ + public static class Properties { + public final static Property Id = new Property(0, Long.class, "id", true, "_id"); + public final static Property MessageId = new Property(1, String.class, "messageId", false, "MESSAGE_ID"); + public final static Property AppId = new Property(2, String.class, "appId", false, "APP_ID"); + public final static Property ClientId = new Property(3, String.class, "clientId", false, "CLIENT_ID"); + public final static Property TaskId = new Property(4, String.class, "taskId", false, "TASK_ID"); + public final static Property UserId = new Property(5, String.class, "userId", false, "USER_ID"); + public final static Property Title = new Property(6, String.class, "title", false, "TITLE"); + public final static Property Content = new Property(7, String.class, "content", false, "CONTENT"); + public final static Property DeviceCode = new Property(8, String.class, "deviceCode", false, "DEVICE_CODE"); + public final static Property IsRead = new Property(9, String.class, "isRead", false, "IS_READ"); + public final static Property AlarmTime = new Property(10, String.class, "alarmTime", false, "ALARM_TIME"); + } + + + public AlarmMessageLocaleBeanDao(DaoConfig config) { + super(config); + } + + public AlarmMessageLocaleBeanDao(DaoConfig config, DaoSession daoSession) { + super(config, daoSession); + } + + /** Creates the underlying database table. */ + public static void createTable(Database db, boolean ifNotExists) { + String constraint = ifNotExists? "IF NOT EXISTS ": ""; + db.execSQL("CREATE TABLE " + constraint + "\"ALARM_MESSAGE_LOCALE_BEAN\" (" + // + "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id + "\"MESSAGE_ID\" TEXT UNIQUE ," + // 1: messageId + "\"APP_ID\" TEXT," + // 2: appId + "\"CLIENT_ID\" TEXT," + // 3: clientId + "\"TASK_ID\" TEXT," + // 4: taskId + "\"USER_ID\" TEXT," + // 5: userId + "\"TITLE\" TEXT," + // 6: title + "\"CONTENT\" TEXT," + // 7: content + "\"DEVICE_CODE\" TEXT," + // 8: deviceCode + "\"IS_READ\" TEXT," + // 9: isRead + "\"ALARM_TIME\" TEXT);"); // 10: alarmTime + } + + /** Drops the underlying database table. */ + public static void dropTable(Database db, boolean ifExists) { + String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"ALARM_MESSAGE_LOCALE_BEAN\""; + db.execSQL(sql); + } + + @Override + protected final void bindValues(DatabaseStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + protected final void bindValues(SQLiteStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + public Long readKey(Cursor cursor, int offset) { + return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); + } + + @Override + public AlarmMessageLocaleBean readEntity(Cursor cursor, int offset) { + AlarmMessageLocaleBean entity = new AlarmMessageLocaleBean( // + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // messageId + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // appId + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // clientId + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // taskId + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // userId + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // title + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // content + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // deviceCode + cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // isRead + cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10) // alarmTime + ); + return entity; + } + + @Override + public void readEntity(Cursor cursor, AlarmMessageLocaleBean entity, int offset) { + entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); + entity.setMessageId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setAppId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setClientId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setTaskId(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); + entity.setUserId(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setTitle(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setContent(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); + entity.setDeviceCode(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); + entity.setIsRead(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9)); + entity.setAlarmTime(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); + } + + @Override + protected final Long updateKeyAfterInsert(AlarmMessageLocaleBean entity, long rowId) { + entity.setId(rowId); + return rowId; + } + + @Override + public Long getKey(AlarmMessageLocaleBean entity) { + if(entity != null) { + return entity.getId(); + } else { + return null; + } + } + + @Override + public boolean hasKey(AlarmMessageLocaleBean entity) { + return entity.getId() != null; + } + + @Override + protected final boolean isEntityUpdateable() { + return true; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java new file mode 100644 index 0000000..4222c40 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java @@ -0,0 +1,96 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.content.Context; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteDatabase.CursorFactory; +import android.util.Log; + +import org.greenrobot.greendao.AbstractDaoMaster; +import org.greenrobot.greendao.database.StandardDatabase; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseOpenHelper; +import org.greenrobot.greendao.identityscope.IdentityScopeType; + + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * Master of DAO (schema version 1): knows all DAOs. + */ +public class DaoMaster extends AbstractDaoMaster { + public static final int SCHEMA_VERSION = 1; + + /** Creates underlying database table using DAOs. */ + public static void createAllTables(Database db, boolean ifNotExists) { + AlarmMessageLocaleBeanDao.createTable(db, ifNotExists); + } + + /** Drops underlying database table using DAOs. */ + public static void dropAllTables(Database db, boolean ifExists) { + AlarmMessageLocaleBeanDao.dropTable(db, ifExists); + } + + /** + * WARNING: Drops all table on Upgrade! Use only during development. + * Convenience method using a {@link DevOpenHelper}. + */ + public static DaoSession newDevSession(Context context, String name) { + Database db = new DevOpenHelper(context, name).getWritableDb(); + DaoMaster daoMaster = new DaoMaster(db); + return daoMaster.newSession(); + } + + public DaoMaster(SQLiteDatabase db) { + this(new StandardDatabase(db)); + } + + public DaoMaster(Database db) { + super(db, SCHEMA_VERSION); + registerDaoClass(AlarmMessageLocaleBeanDao.class); + } + + public DaoSession newSession() { + return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); + } + + public DaoSession newSession(IdentityScopeType type) { + return new DaoSession(db, type, daoConfigMap); + } + + /** + * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} - + */ + public static abstract class OpenHelper extends DatabaseOpenHelper { + public OpenHelper(Context context, String name) { + super(context, name, SCHEMA_VERSION); + } + + public OpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory, SCHEMA_VERSION); + } + + @Override + public void onCreate(Database db) { + Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); + createAllTables(db, false); + } + } + + /** WARNING: Drops all table on Upgrade! Use only during development. */ + public static class DevOpenHelper extends OpenHelper { + public DevOpenHelper(Context context, String name) { + super(context, name); + } + + public DevOpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory); + } + + @Override + public void onUpgrade(Database db, int oldVersion, int newVersion) { + Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); + dropAllTables(db, true); + onCreate(db); + } + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java new file mode 100644 index 0000000..480ed84 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java @@ -0,0 +1,48 @@ +package com.casic.smart.town.sanxi.greendao; + +import java.util.Map; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.AbstractDaoSession; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.identityscope.IdentityScopeType; +import org.greenrobot.greendao.internal.DaoConfig; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. + +/** + * {@inheritDoc} + * + * @see org.greenrobot.greendao.AbstractDaoSession + */ +public class DaoSession extends AbstractDaoSession { + + private final DaoConfig alarmMessageLocaleBeanDaoConfig; + + private final AlarmMessageLocaleBeanDao alarmMessageLocaleBeanDao; + + public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> + daoConfigMap) { + super(db); + + alarmMessageLocaleBeanDaoConfig = daoConfigMap.get(AlarmMessageLocaleBeanDao.class).clone(); + alarmMessageLocaleBeanDaoConfig.initIdentityScope(type); + + alarmMessageLocaleBeanDao = new AlarmMessageLocaleBeanDao(alarmMessageLocaleBeanDaoConfig, this); + + registerDao(AlarmMessageLocaleBean.class, alarmMessageLocaleBeanDao); + } + + public void clear() { + alarmMessageLocaleBeanDaoConfig.clearIdentityScope(); + } + + public AlarmMessageLocaleBeanDao getAlarmMessageLocaleBeanDao() { + return alarmMessageLocaleBeanDao; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt new file mode 100644 index 0000000..875cb8c --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt @@ -0,0 +1,5 @@ +package com.casic.smart.town.sanxi.service + +import com.igexin.sdk.PushService + +class ApplicationPushService : PushService() \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt new file mode 100644 index 0000000..396129f --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt @@ -0,0 +1,84 @@ +package com.casic.smart.town.sanxi.service + +import android.content.Context +import android.os.Message +import android.util.Log +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.casic.smart.town.sanxi.view.MainActivity +import com.igexin.sdk.GTIntentService +import com.igexin.sdk.message.GTCmdMessage +import com.igexin.sdk.message.GTNotificationMessage +import com.igexin.sdk.message.GTTransmitMessage +import com.pengxh.kt.lite.extensions.toJson + +class PushIntentService : GTIntentService() { + + private val kTag = "SmartWellIntentService" + + override fun onReceiveServicePid(context: Context?, pid: Int) { + + } + + // 透传消息 + override fun onReceiveMessageData(context: Context?, msg: GTTransmitMessage?) { + Log.d(kTag, "透传消息 -> msg = $msg") + } + + // 接收 cid + override fun onReceiveClientId(context: Context?, clientid: String?) { + Log.d(kTag, "onReceiveClientId -> $clientid") + //通知MainActivity注册个推服务 + val msg: Message = MainActivity.weakReferenceHandler.obtainMessage() + msg.what = LocaleConstant.PUSH_REGISTER + msg.obj = clientid + MainActivity.weakReferenceHandler.sendMessage(msg) + } + + // cid 离线上线通知 + override fun onReceiveOnlineState(context: Context?, online: Boolean) { + + } + + // 各种事件处理回执 + override fun onReceiveCommandResult(context: Context?, msg: GTCmdMessage?) { + + } + + // 通知到达 + override fun onNotificationMessageArrived(context: Context?, msg: GTNotificationMessage?) { + //报警 +// { +// "content": "设备编号[412022030361]发生井盖开盖报警", +// "messageId": "380abf9a79d34306a2683dc9bf96ee78", +// "taskId": "OSL-0830_4hmfimp3Vu684wo3SjXso9", +// "title": "告警提醒", +// "appid": "HKv8K9qARd6WckZ1o2Vbu4", +// "clientId": "e78beacc42e9a02ae6fb9087eb2b1171", +// "pkgName": "com.casic.app.smartwell" +// } + if (msg == null) { + return + } + Log.d(kTag, "通知到达 -> msg = ${msg.toJson()}") +// val userDetailJson = SaveKeyValues.getValue(LocaleConstant.USER_DETAIL_MODEL, "") as String +// var userId = "" +// if (userDetailJson.isNotBlank()) { +// val userDataModel = Gson().fromJson( +// userDetailJson, object : TypeToken() {}.type +// ) +// userId = userDataModel.id.toString() +// } +// //解析编号 +// val splitArray = msg.content.split("\\[|\\]".toRegex()) +// DataBaseManager.instance.insertNotice( +// msg.messageId, msg.appid, msg.clientId, msg.taskId, +// userId, msg.title, msg.content, splitArray[1], "0", +// System.currentTimeMillis().timestampToCompleteDate() +// ) + } + + // 通知点击 + override fun onNotificationMessageClicked(context: Context?, msg: GTNotificationMessage?) { + Log.d(kTag, "通知点击 -> msg = $msg") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt new file mode 100644 index 0000000..daa7c38 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt @@ -0,0 +1,14 @@ +package com.casic.smart.town.sanxi.util + +import android.content.Context +import me.leolin.shortcutbadger.ShortcutBadger + +object BadeHelper { + fun setBadgeNum(context: Context, badgeCount: Int) { + if (badgeCount == 0) { + ShortcutBadger.removeCount(context) + } else { + ShortcutBadger.applyCount(context, badgeCount) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt new file mode 100644 index 0000000..0a52ef2 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt @@ -0,0 +1,75 @@ +package com.casic.smart.town.sanxi.util + +import com.casic.smart.town.sanxi.base.BaseApplication +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao + +class DataBaseManager private constructor() { + + companion object { + //Kotlin委托模式双重锁单例 + val instance: DataBaseManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) { + DataBaseManager() + } + } + + private val beanDao = + BaseApplication.obtainInstance().obtainDaoSession().alarmMessageLocaleBeanDao + +// fun insertNotice( +// messageId: String, appid: String, clientId: String, +// taskId: String, userId: String, title: String, +// content: String, deviceCode: String, isRead: String, +// noticeTime: String +// ) { +// val noticeLocaleBean = NoticeLocaleBean() +// noticeLocaleBean.messageId = messageId +// noticeLocaleBean.appid = appid +// noticeLocaleBean.clientId = clientId +// noticeLocaleBean.taskId = taskId +// noticeLocaleBean.userId = userId +// noticeLocaleBean.title = title +// noticeLocaleBean.content = content +// noticeLocaleBean.deviceCode = deviceCode +// noticeLocaleBean.isRead = isRead +// noticeLocaleBean.noticeTime = noticeTime +// beanDao.insert(noticeLocaleBean) +// //角标设置 +// BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadNotice()) +// } + + fun deleteByMessageId(messageId: String) { + val result = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).list() + beanDao.deleteInTx(result) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun updateNoticeByMessageId(messageId: String) { + val noticeLocaleBean = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).unique() ?: return + noticeLocaleBean.isRead = "1" + beanDao.update(noticeLocaleBean) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun queryMessageByPage(userId: String, offset: Int): MutableList { + return BaseApplication.obtainInstance().obtainDaoSession() + .queryBuilder(AlarmMessageLocaleBean::class.java) + .where(AlarmMessageLocaleBeanDao.Properties.UserId.eq(userId)) + .offset(offset * LocaleConstant.PAGE_LIMIT) + .orderDesc(AlarmMessageLocaleBeanDao.Properties.AlarmTime) + .limit(LocaleConstant.PAGE_LIMIT) + .list() + } + + private fun queryUnReadMessage(): Int { + return beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.IsRead.eq("0") + ).list().size + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt new file mode 100644 index 0000000..52926a8 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt @@ -0,0 +1,31 @@ +package com.casic.smart.town.sanxi.util; + +import android.app.Activity +import android.view.WindowManager +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object LoadingDialogHub { + private lateinit var loadingDialog: QMUITipDialog + + fun show(activity: Activity, message: String) { + loadingDialog = QMUITipDialog + .Builder(activity) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_LOADING) + .setTipWord(message) + .create() + if (!activity.isDestroyed) { + try { + loadingDialog.show() + } catch (e: WindowManager.BadTokenException) { + e.printStackTrace() + } + } + } + + + fun dismiss() { + if (loadingDialog.isShowing) { + loadingDialog.dismiss() + } + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt new file mode 100644 index 0000000..de61c9a --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.util + +import android.Manifest + +object LocaleConstant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.READ_PHONE_STATE, + Manifest.permission.ACCESS_COARSE_LOCATION, + Manifest.permission.READ_EXTERNAL_STORAGE + ) + + const val PERMISSIONS_CODE = 999 + const val PUSH_REGISTER = 2022100101 + const val PAGE_LIMIT = 20 +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt new file mode 100644 index 0000000..3bea1c9 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt @@ -0,0 +1,112 @@ +package com.casic.smart.town.sanxi.view + +import android.view.KeyEvent +import android.view.MenuItem +import androidx.fragment.app.Fragment +import androidx.viewpager.widget.ViewPager +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.adapter.ViewPagerAdapter +import com.casic.smart.town.sanxi.fragment.AlarmPageFragment +import com.casic.smart.town.sanxi.fragment.MonitorPageFragment +import com.casic.smart.town.sanxi.fragment.StatisticsPageFragment +import com.gyf.immersionbar.ImmersionBar +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.base.KotlinBaseActivity +import com.pengxh.kt.lite.extensions.convertColor +import com.pengxh.kt.lite.extensions.show +import com.pengxh.kt.lite.utils.ImmerseStatusBarUtil +import com.pengxh.kt.lite.utils.WeakReferenceHandler +import kotlinx.android.synthetic.main.activity_main.* + +class MainActivity : KotlinBaseActivity() { + + companion object { + lateinit var weakReferenceHandler: WeakReferenceHandler + } + + private val kTag = "MainActivity" + private var menuItem: MenuItem? = null + private var fragmentPages: ArrayList = ArrayList() + private var clickTime: Long = 0 + + init { + fragmentPages.add(StatisticsPageFragment()) + fragmentPages.add(MonitorPageFragment()) + fragmentPages.add(AlarmPageFragment()) + } + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + ImmersionBar.with(this).statusBarDarkFont(false).init() + ImmerseStatusBarUtil.setColor(this, R.color.mainThemeColor.convertColor(this)) + } + + override fun initData() { + //推送,多次调用 SDK 初始化并无影响。 + PushManager.getInstance().initialize(this) + weakReferenceHandler = WeakReferenceHandler { + + true + } + } + + override fun observeRequestState() { + + } + + override fun initEvent() { + bottomNavigation.itemIconTintList = null + bottomNavigation.setOnNavigationItemSelectedListener { menuItem -> + when (menuItem.itemId) { + R.id.nav_statistics -> { + mainViewPager.currentItem = 0 + } + R.id.nav_monitor -> { + mainViewPager.currentItem = 1 + } + R.id.nav_alarm -> { + mainViewPager.currentItem = 2 + } + } + false + } + mainViewPager.adapter = ViewPagerAdapter(fragmentPages, supportFragmentManager) + mainViewPager.offscreenPageLimit = fragmentPages.size //缓存页数 + mainViewPager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener { + override fun onPageScrollStateChanged(state: Int) { + + } + + override fun onPageScrolled( + position: Int, + positionOffset: Float, + positionOffsetPixels: Int + ) { + + } + + override fun onPageSelected(position: Int) { + if (menuItem != null) { + menuItem!!.isChecked = false + } else { + bottomNavigation.menu.getItem(0).isChecked = false + } + menuItem = bottomNavigation.menu.getItem(position) + menuItem!!.isChecked = true + } + }) + } + + override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean { + return if (keyCode == KeyEvent.KEYCODE_BACK) { + if (System.currentTimeMillis() - clickTime > 2000) { + "再按一次退出程序".show(this) + clickTime = System.currentTimeMillis() + true + } else { + super.onKeyDown(keyCode, event) + } + } else super.onKeyDown(keyCode, event) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt new file mode 100644 index 0000000..c5d8b22 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.view + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseActivity + +class MonitorRecordActivity : KotlinBaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_monitor_record + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt new file mode 100644 index 0000000..c478d83 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt @@ -0,0 +1,55 @@ +package com.casic.smart.town.sanxi.view + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.amap.api.maps.MapsInitializer +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.gyf.immersionbar.ImmersionBar +import com.pengxh.kt.lite.extensions.navigatePageTo +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + ImmersionBar.with(this).statusBarDarkFont(true).init() + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (EasyPermissions.hasPermissions(this, *LocaleConstant.USER_PERMISSIONS)) { + startSplashScreenActivity() + } else { + EasyPermissions.requestPermissions( + this@PermissionActivity, + resources.getString(R.string.app_name) + "需要获取相关权限", + LocaleConstant.PERMISSIONS_CODE, + *LocaleConstant.USER_PERMISSIONS + ) + } + } + + private fun startSplashScreenActivity() { + //先把导航隐私政策声明,后面导航会用到 + MapsInitializer.updatePrivacyAgree(this, true) + MapsInitializer.updatePrivacyShow(this, true, true) + this.navigatePageTo() + 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) { + startSplashScreenActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable/alarm_selector.xml b/app/src/main/res/drawable/alarm_selector.xml new file mode 100644 index 0000000..39b2595 --- /dev/null +++ b/app/src/main/res/drawable/alarm_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bottom_text_color.xml b/app/src/main/res/drawable/bottom_text_color.xml new file mode 100644 index 0000000..b284ea3 --- /dev/null +++ b/app/src/main/res/drawable/bottom_text_color.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_alarm.xml b/app/src/main/res/drawable/ic_alarm.xml new file mode 100644 index 0000000..dc33aab --- /dev/null +++ b/app/src/main/res/drawable/ic_alarm.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_alarm_selected.xml b/app/src/main/res/drawable/ic_alarm_selected.xml new file mode 100644 index 0000000..993fea6 --- /dev/null +++ b/app/src/main/res/drawable/ic_alarm_selected.xml @@ -0,0 +1,9 @@ + + + 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_monitor.xml b/app/src/main/res/drawable/ic_monitor.xml new file mode 100644 index 0000000..271f5b4 --- /dev/null +++ b/app/src/main/res/drawable/ic_monitor.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_monitor_selected.xml b/app/src/main/res/drawable/ic_monitor_selected.xml new file mode 100644 index 0000000..ee62d84 --- /dev/null +++ b/app/src/main/res/drawable/ic_monitor_selected.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_statistics.xml b/app/src/main/res/drawable/ic_statistics.xml new file mode 100644 index 0000000..7fde8ec --- /dev/null +++ b/app/src/main/res/drawable/ic_statistics.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_statistics_selected.xml b/app/src/main/res/drawable/ic_statistics_selected.xml new file mode 100644 index 0000000..49b6fcd --- /dev/null +++ b/app/src/main/res/drawable/ic_statistics_selected.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/monitor_selector.xml b/app/src/main/res/drawable/monitor_selector.xml new file mode 100644 index 0000000..fe11e9a --- /dev/null +++ b/app/src/main/res/drawable/monitor_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/statistics_selector.xml b/app/src/main/res/drawable/statistics_selector.xml new file mode 100644 index 0000000..2156cff --- /dev/null +++ b/app/src/main/res/drawable/statistics_selector.xml @@ -0,0 +1,5 @@ + + + + + \ 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..78a4a94 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,27 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_monitor_record.xml b/app/src/main/res/layout/activity_monitor_record.xml new file mode 100644 index 0000000..77d9ef6 --- /dev/null +++ b/app/src/main/res/layout/activity_monitor_record.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_alarm.xml b/app/src/main/res/layout/fragment_alarm.xml new file mode 100644 index 0000000..77d9ef6 --- /dev/null +++ b/app/src/main/res/layout/fragment_alarm.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_monitor.xml b/app/src/main/res/layout/fragment_monitor.xml new file mode 100644 index 0000000..19789c1 --- /dev/null +++ b/app/src/main/res/layout/fragment_monitor.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_statistics.xml b/app/src/main/res/layout/fragment_statistics.xml new file mode 100644 index 0000000..77d9ef6 --- /dev/null +++ b/app/src/main/res/layout/fragment_statistics.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/menu/bottom_nav_menu.xml b/app/src/main/res/menu/bottom_nav_menu.xml new file mode 100644 index 0000000..751fd61 --- /dev/null +++ b/app/src/main/res/menu/bottom_nav_menu.xml @@ -0,0 +1,29 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.webp b/app/src/main/res/mipmap-hdpi/ic_launcher.webp new file mode 100644 index 0000000..c209e78 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp new file mode 100644 index 0000000..b2dfe3d --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.webp b/app/src/main/res/mipmap-mdpi/ic_launcher.webp new file mode 100644 index 0000000..4f0f1d6 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp new file mode 100644 index 0000000..62b611d --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher.webp new file mode 100644 index 0000000..948a307 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..1b9a695 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp Binary files differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp new file mode 100644 index 0000000..28d4b77 --- /dev/null +++ b/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..9287f50 --- /dev/null +++ b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp new file mode 100644 index 0000000..aa7d642 --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..9126ae3 --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp 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..bbce66f --- /dev/null +++ b/app/src/main/res/values/colors.xml @@ -0,0 +1,14 @@ + + + #1D55C6 + #333333 + #CCCCCC + + #FFBB86FC + #FF6200EE + #FF3700B3 + #FF03DAC5 + #FF018786 + #FF000000 + #FFFFFFFF + \ No newline at end of file diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml new file mode 100644 index 0000000..b7a9292 --- /dev/null +++ b/app/src/main/res/values/dimens.xml @@ -0,0 +1,33 @@ + + + + 12sp + 14sp + 16sp + 18sp + 20sp + 22sp + + + 3dp + 5dp + 7dp + 10dp + 15dp + 20dp + 25dp + 30dp + 35dp + 40dp + 45dp + 50dp + 55dp + 60dp + 75dp + + + 1dp + + + 45dp + \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..10cfdbf --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*.iml +.gradle +/local.properties +/.idea +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..a4cd2ca --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,101 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'org.greenrobot.greendao' + +android { +// signingConfigs { +// release { +// storeFile file('/Users/a203/Desktop/AndroidProjects/CasicSmartWell/app/CasicSmartWell.jks') +// storePassword '123456789' +// keyAlias 'key0' +// keyPassword '123456789' +// } +// } + compileSdkVersion 31 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.smart.town.sanxi" + minSdkVersion 23 + targetSdkVersion 31 + versionCode 1 + versionName "1.0.0" + + manifestPlaceholders = [GETUI_APPID: "A9V4DvwLcdAqkFCQuFyhq6"] + } + + buildTypes { + release { + minifyEnabled false +// signingConfig signingConfigs.release + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + + ndk { abiFilters "armeabi", "armeabi-v7a", "arm64-v8" } + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlin { + experimental { + coroutines 'enable' + } + } + + greendao { + schemaVersion 1//数据库版本号 + targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 + daoPackage 'com.casic.smart.town.sanxi.greendao'//设置DaoMaster、DaoSession、Dao包名 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + //基础依赖库 + implementation files('libs/lite-release.aar') + implementation 'androidx.appcompat:appcompat:1.4.2' + implementation 'androidx.core:core-ktx:1.8.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:3.0.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' + //MVVM+LiveData + implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.1" + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0" + implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + //Kotlin协程 + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1' + //图片加载框架 + implementation 'com.github.bumptech.glide:glide:4.9.0' + //返回值转换器 + implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' + implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + //okhttp3日志拦截器 + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //网络请求和接口封装 + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.9.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.9.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' + //高德地图 + implementation 'com.amap.api:3dmap:latest.integration' + //推送SDK + implementation 'com.getui:gtsdk:3.2.10.0' //个推SDK + implementation 'com.getui:gtc:3.1.9.0' //个推核心组件 + //数据库框架 + implementation 'org.greenrobot:greendao:3.3.0' + //桌面角标 + implementation "me.leolin:ShortcutBadger:1.1.22@aar" +} \ No newline at end of file diff --git a/app/libs/lite-release.aar b/app/libs/lite-release.aar new file mode 100644 index 0000000..45da4df --- /dev/null +++ b/app/libs/lite-release.aar Binary files differ diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /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 \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..a83c28a --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/svg/monitor.svg b/app/src/main/assets/svg/monitor.svg new file mode 100644 index 0000000..c8d3e25 --- /dev/null +++ b/app/src/main/assets/svg/monitor.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/msg.svg b/app/src/main/assets/svg/msg.svg new file mode 100644 index 0000000..e864e48 --- /dev/null +++ b/app/src/main/assets/svg/msg.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/statistics.svg b/app/src/main/assets/svg/statistics.svg new file mode 100644 index 0000000..974000e --- /dev/null +++ b/app/src/main/assets/svg/statistics.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt new file mode 100644 index 0000000..6b9cce0 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.adapter + +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentManager +import androidx.fragment.app.FragmentPagerAdapter + +class ViewPagerAdapter(list: ArrayList, manager: FragmentManager) : + FragmentPagerAdapter(manager) { + + private var pageList: List = list + + override fun getItem(position: Int) = pageList[position] + + override fun getCount() = pageList.size +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt new file mode 100644 index 0000000..4e017b1 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt @@ -0,0 +1,40 @@ +package com.casic.smart.town.sanxi.base + +import android.app.Application +import android.util.Log +import com.casic.smart.town.sanxi.greendao.DaoMaster +import com.casic.smart.town.sanxi.greendao.DaoSession +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + private val kTag = "BaseApplication" + + companion object { + private var instance: BaseApplication by Delegates.notNull() + + fun obtainInstance() = instance + + private lateinit var daoSession: DaoSession + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences(this) + //推送 + PushManager.getInstance().initialize(this) + PushManager.getInstance().setDebugLogger(this) { + Log.d(kTag, it) + } + val devOpenHelper = DaoMaster.DevOpenHelper(this, "SmartTown.db", null) + val daoMaster = DaoMaster(devOpenHelper.writableDatabase) + daoSession = daoMaster.newSession() + } + + fun obtainDaoSession(): DaoSession { + return daoSession + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java new file mode 100644 index 0000000..b8f67dc --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java @@ -0,0 +1,133 @@ +package com.casic.smart.town.sanxi.bean; + +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Generated; +import org.greenrobot.greendao.annotation.Id; +import org.greenrobot.greendao.annotation.Unique; + +@Entity +public class AlarmMessageLocaleBean { + @Id(autoincrement = true) + private Long id;//主键自增 + + @Unique + private String messageId; + private String appId; + private String clientId; + private String taskId; + private String userId; + private String title; + private String content; + private String deviceCode; + private String isRead;//0-未读,1-已读 + private String alarmTime; + + @Generated(hash = 566950134) + public AlarmMessageLocaleBean(Long id, String messageId, String appId, + String clientId, String taskId, String userId, String title, + String content, String deviceCode, String isRead, String alarmTime) { + this.id = id; + this.messageId = messageId; + this.appId = appId; + this.clientId = clientId; + this.taskId = taskId; + this.userId = userId; + this.title = title; + this.content = content; + this.deviceCode = deviceCode; + this.isRead = isRead; + this.alarmTime = alarmTime; + } + + @Generated(hash = 1737519562) + public AlarmMessageLocaleBean() { + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getMessageId() { + return this.messageId; + } + + public void setMessageId(String messageId) { + this.messageId = messageId; + } + + public String getAppId() { + return this.appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public String getClientId() { + return this.clientId; + } + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public String getTaskId() { + return this.taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getUserId() { + return this.userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getTitle() { + return this.title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return this.content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getDeviceCode() { + return this.deviceCode; + } + + public void setDeviceCode(String deviceCode) { + this.deviceCode = deviceCode; + } + + public String getIsRead() { + return this.isRead; + } + + public void setIsRead(String isRead) { + this.isRead = isRead; + } + + public String getAlarmTime() { + return this.alarmTime; + } + + public void setAlarmTime(String alarmTime) { + this.alarmTime = alarmTime; + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt new file mode 100644 index 0000000..650e201 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class AlarmPageFragment: KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_alarm + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt new file mode 100644 index 0000000..deac8ac --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt @@ -0,0 +1,76 @@ +package com.casic.smart.town.sanxi.fragment + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.Fragment +import com.amap.api.maps.AMap +import com.amap.api.maps.AMapOptions +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.view.MonitorRecordActivity +import com.pengxh.kt.lite.extensions.navigatePageTo +import com.pengxh.kt.lite.extensions.show +import kotlinx.android.synthetic.main.fragment_monitor.view.* + +class MonitorPageFragment : Fragment() { + + private val kTag = "HomePageFragment" + private lateinit var monitorView: View + private lateinit var aMap: AMap + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? + ): View { + monitorView = inflater.inflate(R.layout.fragment_monitor, container, false) + //地图初始化 + initMap(savedInstanceState) + + monitorView.rightOperateView.setOnClickListener { + requireContext().navigatePageTo() + } + return monitorView + } + + private fun initMap(savedInstanceState: Bundle?) { + monitorView.mapView.onCreate(savedInstanceState) + aMap = monitorView.mapView.map + aMap.mapType = AMap.MAP_TYPE_NORMAL + val uiSettings = aMap.uiSettings + uiSettings.isCompassEnabled = true + uiSettings.zoomPosition = AMapOptions.ZOOM_POSITION_RIGHT_CENTER + uiSettings.isTiltGesturesEnabled = false//不许地图随手势倾斜角度 + + // 地图加载成功监听 +// aMap.addOnMapLoadedListener(this) + // 地图缩放监听 +// aMap.addOnCameraChangeListener(this) + // marker 点击事件监听 +// aMap.addOnMarkerClickListener(this) + // 点击marker弹出自定义popup +// aMap.setInfoWindowAdapter(this) + //信息窗点击事件 +// aMap.addOnInfoWindowClickListener(this) + } + + /***以下是地图生命周期管理************************************************************************/ + override fun onResume() { + super.onResume() + monitorView.mapView.onResume() + } + + override fun onPause() { + super.onPause() + monitorView.mapView.onPause() + } + + override fun onSaveInstanceState(outState: Bundle) { + super.onSaveInstanceState(outState) + monitorView.mapView.onSaveInstanceState(outState) + } + + override fun onDestroy() { + super.onDestroy() + monitorView.mapView.onDestroy() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt new file mode 100644 index 0000000..e84df12 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class StatisticsPageFragment : KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_statistics + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java new file mode 100644 index 0000000..68d7901 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java @@ -0,0 +1,255 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.database.Cursor; +import android.database.sqlite.SQLiteStatement; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.Property; +import org.greenrobot.greendao.internal.DaoConfig; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseStatement; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * DAO for table "ALARM_MESSAGE_LOCALE_BEAN". +*/ +public class AlarmMessageLocaleBeanDao extends AbstractDao { + + public static final String TABLENAME = "ALARM_MESSAGE_LOCALE_BEAN"; + + /** + * Properties of entity AlarmMessageLocaleBean.
+ * Can be used for QueryBuilder and for referencing column names. + */ + public static class Properties { + public final static Property Id = new Property(0, Long.class, "id", true, "_id"); + public final static Property MessageId = new Property(1, String.class, "messageId", false, "MESSAGE_ID"); + public final static Property AppId = new Property(2, String.class, "appId", false, "APP_ID"); + public final static Property ClientId = new Property(3, String.class, "clientId", false, "CLIENT_ID"); + public final static Property TaskId = new Property(4, String.class, "taskId", false, "TASK_ID"); + public final static Property UserId = new Property(5, String.class, "userId", false, "USER_ID"); + public final static Property Title = new Property(6, String.class, "title", false, "TITLE"); + public final static Property Content = new Property(7, String.class, "content", false, "CONTENT"); + public final static Property DeviceCode = new Property(8, String.class, "deviceCode", false, "DEVICE_CODE"); + public final static Property IsRead = new Property(9, String.class, "isRead", false, "IS_READ"); + public final static Property AlarmTime = new Property(10, String.class, "alarmTime", false, "ALARM_TIME"); + } + + + public AlarmMessageLocaleBeanDao(DaoConfig config) { + super(config); + } + + public AlarmMessageLocaleBeanDao(DaoConfig config, DaoSession daoSession) { + super(config, daoSession); + } + + /** Creates the underlying database table. */ + public static void createTable(Database db, boolean ifNotExists) { + String constraint = ifNotExists? "IF NOT EXISTS ": ""; + db.execSQL("CREATE TABLE " + constraint + "\"ALARM_MESSAGE_LOCALE_BEAN\" (" + // + "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id + "\"MESSAGE_ID\" TEXT UNIQUE ," + // 1: messageId + "\"APP_ID\" TEXT," + // 2: appId + "\"CLIENT_ID\" TEXT," + // 3: clientId + "\"TASK_ID\" TEXT," + // 4: taskId + "\"USER_ID\" TEXT," + // 5: userId + "\"TITLE\" TEXT," + // 6: title + "\"CONTENT\" TEXT," + // 7: content + "\"DEVICE_CODE\" TEXT," + // 8: deviceCode + "\"IS_READ\" TEXT," + // 9: isRead + "\"ALARM_TIME\" TEXT);"); // 10: alarmTime + } + + /** Drops the underlying database table. */ + public static void dropTable(Database db, boolean ifExists) { + String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"ALARM_MESSAGE_LOCALE_BEAN\""; + db.execSQL(sql); + } + + @Override + protected final void bindValues(DatabaseStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + protected final void bindValues(SQLiteStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + public Long readKey(Cursor cursor, int offset) { + return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); + } + + @Override + public AlarmMessageLocaleBean readEntity(Cursor cursor, int offset) { + AlarmMessageLocaleBean entity = new AlarmMessageLocaleBean( // + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // messageId + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // appId + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // clientId + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // taskId + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // userId + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // title + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // content + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // deviceCode + cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // isRead + cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10) // alarmTime + ); + return entity; + } + + @Override + public void readEntity(Cursor cursor, AlarmMessageLocaleBean entity, int offset) { + entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); + entity.setMessageId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setAppId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setClientId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setTaskId(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); + entity.setUserId(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setTitle(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setContent(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); + entity.setDeviceCode(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); + entity.setIsRead(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9)); + entity.setAlarmTime(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); + } + + @Override + protected final Long updateKeyAfterInsert(AlarmMessageLocaleBean entity, long rowId) { + entity.setId(rowId); + return rowId; + } + + @Override + public Long getKey(AlarmMessageLocaleBean entity) { + if(entity != null) { + return entity.getId(); + } else { + return null; + } + } + + @Override + public boolean hasKey(AlarmMessageLocaleBean entity) { + return entity.getId() != null; + } + + @Override + protected final boolean isEntityUpdateable() { + return true; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java new file mode 100644 index 0000000..4222c40 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java @@ -0,0 +1,96 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.content.Context; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteDatabase.CursorFactory; +import android.util.Log; + +import org.greenrobot.greendao.AbstractDaoMaster; +import org.greenrobot.greendao.database.StandardDatabase; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseOpenHelper; +import org.greenrobot.greendao.identityscope.IdentityScopeType; + + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * Master of DAO (schema version 1): knows all DAOs. + */ +public class DaoMaster extends AbstractDaoMaster { + public static final int SCHEMA_VERSION = 1; + + /** Creates underlying database table using DAOs. */ + public static void createAllTables(Database db, boolean ifNotExists) { + AlarmMessageLocaleBeanDao.createTable(db, ifNotExists); + } + + /** Drops underlying database table using DAOs. */ + public static void dropAllTables(Database db, boolean ifExists) { + AlarmMessageLocaleBeanDao.dropTable(db, ifExists); + } + + /** + * WARNING: Drops all table on Upgrade! Use only during development. + * Convenience method using a {@link DevOpenHelper}. + */ + public static DaoSession newDevSession(Context context, String name) { + Database db = new DevOpenHelper(context, name).getWritableDb(); + DaoMaster daoMaster = new DaoMaster(db); + return daoMaster.newSession(); + } + + public DaoMaster(SQLiteDatabase db) { + this(new StandardDatabase(db)); + } + + public DaoMaster(Database db) { + super(db, SCHEMA_VERSION); + registerDaoClass(AlarmMessageLocaleBeanDao.class); + } + + public DaoSession newSession() { + return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); + } + + public DaoSession newSession(IdentityScopeType type) { + return new DaoSession(db, type, daoConfigMap); + } + + /** + * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} - + */ + public static abstract class OpenHelper extends DatabaseOpenHelper { + public OpenHelper(Context context, String name) { + super(context, name, SCHEMA_VERSION); + } + + public OpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory, SCHEMA_VERSION); + } + + @Override + public void onCreate(Database db) { + Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); + createAllTables(db, false); + } + } + + /** WARNING: Drops all table on Upgrade! Use only during development. */ + public static class DevOpenHelper extends OpenHelper { + public DevOpenHelper(Context context, String name) { + super(context, name); + } + + public DevOpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory); + } + + @Override + public void onUpgrade(Database db, int oldVersion, int newVersion) { + Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); + dropAllTables(db, true); + onCreate(db); + } + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java new file mode 100644 index 0000000..480ed84 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java @@ -0,0 +1,48 @@ +package com.casic.smart.town.sanxi.greendao; + +import java.util.Map; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.AbstractDaoSession; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.identityscope.IdentityScopeType; +import org.greenrobot.greendao.internal.DaoConfig; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. + +/** + * {@inheritDoc} + * + * @see org.greenrobot.greendao.AbstractDaoSession + */ +public class DaoSession extends AbstractDaoSession { + + private final DaoConfig alarmMessageLocaleBeanDaoConfig; + + private final AlarmMessageLocaleBeanDao alarmMessageLocaleBeanDao; + + public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> + daoConfigMap) { + super(db); + + alarmMessageLocaleBeanDaoConfig = daoConfigMap.get(AlarmMessageLocaleBeanDao.class).clone(); + alarmMessageLocaleBeanDaoConfig.initIdentityScope(type); + + alarmMessageLocaleBeanDao = new AlarmMessageLocaleBeanDao(alarmMessageLocaleBeanDaoConfig, this); + + registerDao(AlarmMessageLocaleBean.class, alarmMessageLocaleBeanDao); + } + + public void clear() { + alarmMessageLocaleBeanDaoConfig.clearIdentityScope(); + } + + public AlarmMessageLocaleBeanDao getAlarmMessageLocaleBeanDao() { + return alarmMessageLocaleBeanDao; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt new file mode 100644 index 0000000..875cb8c --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt @@ -0,0 +1,5 @@ +package com.casic.smart.town.sanxi.service + +import com.igexin.sdk.PushService + +class ApplicationPushService : PushService() \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt new file mode 100644 index 0000000..396129f --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt @@ -0,0 +1,84 @@ +package com.casic.smart.town.sanxi.service + +import android.content.Context +import android.os.Message +import android.util.Log +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.casic.smart.town.sanxi.view.MainActivity +import com.igexin.sdk.GTIntentService +import com.igexin.sdk.message.GTCmdMessage +import com.igexin.sdk.message.GTNotificationMessage +import com.igexin.sdk.message.GTTransmitMessage +import com.pengxh.kt.lite.extensions.toJson + +class PushIntentService : GTIntentService() { + + private val kTag = "SmartWellIntentService" + + override fun onReceiveServicePid(context: Context?, pid: Int) { + + } + + // 透传消息 + override fun onReceiveMessageData(context: Context?, msg: GTTransmitMessage?) { + Log.d(kTag, "透传消息 -> msg = $msg") + } + + // 接收 cid + override fun onReceiveClientId(context: Context?, clientid: String?) { + Log.d(kTag, "onReceiveClientId -> $clientid") + //通知MainActivity注册个推服务 + val msg: Message = MainActivity.weakReferenceHandler.obtainMessage() + msg.what = LocaleConstant.PUSH_REGISTER + msg.obj = clientid + MainActivity.weakReferenceHandler.sendMessage(msg) + } + + // cid 离线上线通知 + override fun onReceiveOnlineState(context: Context?, online: Boolean) { + + } + + // 各种事件处理回执 + override fun onReceiveCommandResult(context: Context?, msg: GTCmdMessage?) { + + } + + // 通知到达 + override fun onNotificationMessageArrived(context: Context?, msg: GTNotificationMessage?) { + //报警 +// { +// "content": "设备编号[412022030361]发生井盖开盖报警", +// "messageId": "380abf9a79d34306a2683dc9bf96ee78", +// "taskId": "OSL-0830_4hmfimp3Vu684wo3SjXso9", +// "title": "告警提醒", +// "appid": "HKv8K9qARd6WckZ1o2Vbu4", +// "clientId": "e78beacc42e9a02ae6fb9087eb2b1171", +// "pkgName": "com.casic.app.smartwell" +// } + if (msg == null) { + return + } + Log.d(kTag, "通知到达 -> msg = ${msg.toJson()}") +// val userDetailJson = SaveKeyValues.getValue(LocaleConstant.USER_DETAIL_MODEL, "") as String +// var userId = "" +// if (userDetailJson.isNotBlank()) { +// val userDataModel = Gson().fromJson( +// userDetailJson, object : TypeToken() {}.type +// ) +// userId = userDataModel.id.toString() +// } +// //解析编号 +// val splitArray = msg.content.split("\\[|\\]".toRegex()) +// DataBaseManager.instance.insertNotice( +// msg.messageId, msg.appid, msg.clientId, msg.taskId, +// userId, msg.title, msg.content, splitArray[1], "0", +// System.currentTimeMillis().timestampToCompleteDate() +// ) + } + + // 通知点击 + override fun onNotificationMessageClicked(context: Context?, msg: GTNotificationMessage?) { + Log.d(kTag, "通知点击 -> msg = $msg") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt new file mode 100644 index 0000000..daa7c38 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt @@ -0,0 +1,14 @@ +package com.casic.smart.town.sanxi.util + +import android.content.Context +import me.leolin.shortcutbadger.ShortcutBadger + +object BadeHelper { + fun setBadgeNum(context: Context, badgeCount: Int) { + if (badgeCount == 0) { + ShortcutBadger.removeCount(context) + } else { + ShortcutBadger.applyCount(context, badgeCount) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt new file mode 100644 index 0000000..0a52ef2 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt @@ -0,0 +1,75 @@ +package com.casic.smart.town.sanxi.util + +import com.casic.smart.town.sanxi.base.BaseApplication +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao + +class DataBaseManager private constructor() { + + companion object { + //Kotlin委托模式双重锁单例 + val instance: DataBaseManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) { + DataBaseManager() + } + } + + private val beanDao = + BaseApplication.obtainInstance().obtainDaoSession().alarmMessageLocaleBeanDao + +// fun insertNotice( +// messageId: String, appid: String, clientId: String, +// taskId: String, userId: String, title: String, +// content: String, deviceCode: String, isRead: String, +// noticeTime: String +// ) { +// val noticeLocaleBean = NoticeLocaleBean() +// noticeLocaleBean.messageId = messageId +// noticeLocaleBean.appid = appid +// noticeLocaleBean.clientId = clientId +// noticeLocaleBean.taskId = taskId +// noticeLocaleBean.userId = userId +// noticeLocaleBean.title = title +// noticeLocaleBean.content = content +// noticeLocaleBean.deviceCode = deviceCode +// noticeLocaleBean.isRead = isRead +// noticeLocaleBean.noticeTime = noticeTime +// beanDao.insert(noticeLocaleBean) +// //角标设置 +// BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadNotice()) +// } + + fun deleteByMessageId(messageId: String) { + val result = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).list() + beanDao.deleteInTx(result) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun updateNoticeByMessageId(messageId: String) { + val noticeLocaleBean = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).unique() ?: return + noticeLocaleBean.isRead = "1" + beanDao.update(noticeLocaleBean) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun queryMessageByPage(userId: String, offset: Int): MutableList { + return BaseApplication.obtainInstance().obtainDaoSession() + .queryBuilder(AlarmMessageLocaleBean::class.java) + .where(AlarmMessageLocaleBeanDao.Properties.UserId.eq(userId)) + .offset(offset * LocaleConstant.PAGE_LIMIT) + .orderDesc(AlarmMessageLocaleBeanDao.Properties.AlarmTime) + .limit(LocaleConstant.PAGE_LIMIT) + .list() + } + + private fun queryUnReadMessage(): Int { + return beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.IsRead.eq("0") + ).list().size + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt new file mode 100644 index 0000000..52926a8 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt @@ -0,0 +1,31 @@ +package com.casic.smart.town.sanxi.util; + +import android.app.Activity +import android.view.WindowManager +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object LoadingDialogHub { + private lateinit var loadingDialog: QMUITipDialog + + fun show(activity: Activity, message: String) { + loadingDialog = QMUITipDialog + .Builder(activity) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_LOADING) + .setTipWord(message) + .create() + if (!activity.isDestroyed) { + try { + loadingDialog.show() + } catch (e: WindowManager.BadTokenException) { + e.printStackTrace() + } + } + } + + + fun dismiss() { + if (loadingDialog.isShowing) { + loadingDialog.dismiss() + } + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt new file mode 100644 index 0000000..de61c9a --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.util + +import android.Manifest + +object LocaleConstant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.READ_PHONE_STATE, + Manifest.permission.ACCESS_COARSE_LOCATION, + Manifest.permission.READ_EXTERNAL_STORAGE + ) + + const val PERMISSIONS_CODE = 999 + const val PUSH_REGISTER = 2022100101 + const val PAGE_LIMIT = 20 +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt new file mode 100644 index 0000000..3bea1c9 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt @@ -0,0 +1,112 @@ +package com.casic.smart.town.sanxi.view + +import android.view.KeyEvent +import android.view.MenuItem +import androidx.fragment.app.Fragment +import androidx.viewpager.widget.ViewPager +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.adapter.ViewPagerAdapter +import com.casic.smart.town.sanxi.fragment.AlarmPageFragment +import com.casic.smart.town.sanxi.fragment.MonitorPageFragment +import com.casic.smart.town.sanxi.fragment.StatisticsPageFragment +import com.gyf.immersionbar.ImmersionBar +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.base.KotlinBaseActivity +import com.pengxh.kt.lite.extensions.convertColor +import com.pengxh.kt.lite.extensions.show +import com.pengxh.kt.lite.utils.ImmerseStatusBarUtil +import com.pengxh.kt.lite.utils.WeakReferenceHandler +import kotlinx.android.synthetic.main.activity_main.* + +class MainActivity : KotlinBaseActivity() { + + companion object { + lateinit var weakReferenceHandler: WeakReferenceHandler + } + + private val kTag = "MainActivity" + private var menuItem: MenuItem? = null + private var fragmentPages: ArrayList = ArrayList() + private var clickTime: Long = 0 + + init { + fragmentPages.add(StatisticsPageFragment()) + fragmentPages.add(MonitorPageFragment()) + fragmentPages.add(AlarmPageFragment()) + } + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + ImmersionBar.with(this).statusBarDarkFont(false).init() + ImmerseStatusBarUtil.setColor(this, R.color.mainThemeColor.convertColor(this)) + } + + override fun initData() { + //推送,多次调用 SDK 初始化并无影响。 + PushManager.getInstance().initialize(this) + weakReferenceHandler = WeakReferenceHandler { + + true + } + } + + override fun observeRequestState() { + + } + + override fun initEvent() { + bottomNavigation.itemIconTintList = null + bottomNavigation.setOnNavigationItemSelectedListener { menuItem -> + when (menuItem.itemId) { + R.id.nav_statistics -> { + mainViewPager.currentItem = 0 + } + R.id.nav_monitor -> { + mainViewPager.currentItem = 1 + } + R.id.nav_alarm -> { + mainViewPager.currentItem = 2 + } + } + false + } + mainViewPager.adapter = ViewPagerAdapter(fragmentPages, supportFragmentManager) + mainViewPager.offscreenPageLimit = fragmentPages.size //缓存页数 + mainViewPager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener { + override fun onPageScrollStateChanged(state: Int) { + + } + + override fun onPageScrolled( + position: Int, + positionOffset: Float, + positionOffsetPixels: Int + ) { + + } + + override fun onPageSelected(position: Int) { + if (menuItem != null) { + menuItem!!.isChecked = false + } else { + bottomNavigation.menu.getItem(0).isChecked = false + } + menuItem = bottomNavigation.menu.getItem(position) + menuItem!!.isChecked = true + } + }) + } + + override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean { + return if (keyCode == KeyEvent.KEYCODE_BACK) { + if (System.currentTimeMillis() - clickTime > 2000) { + "再按一次退出程序".show(this) + clickTime = System.currentTimeMillis() + true + } else { + super.onKeyDown(keyCode, event) + } + } else super.onKeyDown(keyCode, event) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt new file mode 100644 index 0000000..c5d8b22 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.view + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseActivity + +class MonitorRecordActivity : KotlinBaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_monitor_record + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt new file mode 100644 index 0000000..c478d83 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt @@ -0,0 +1,55 @@ +package com.casic.smart.town.sanxi.view + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.amap.api.maps.MapsInitializer +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.gyf.immersionbar.ImmersionBar +import com.pengxh.kt.lite.extensions.navigatePageTo +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + ImmersionBar.with(this).statusBarDarkFont(true).init() + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (EasyPermissions.hasPermissions(this, *LocaleConstant.USER_PERMISSIONS)) { + startSplashScreenActivity() + } else { + EasyPermissions.requestPermissions( + this@PermissionActivity, + resources.getString(R.string.app_name) + "需要获取相关权限", + LocaleConstant.PERMISSIONS_CODE, + *LocaleConstant.USER_PERMISSIONS + ) + } + } + + private fun startSplashScreenActivity() { + //先把导航隐私政策声明,后面导航会用到 + MapsInitializer.updatePrivacyAgree(this, true) + MapsInitializer.updatePrivacyShow(this, true, true) + this.navigatePageTo() + 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) { + startSplashScreenActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable/alarm_selector.xml b/app/src/main/res/drawable/alarm_selector.xml new file mode 100644 index 0000000..39b2595 --- /dev/null +++ b/app/src/main/res/drawable/alarm_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bottom_text_color.xml b/app/src/main/res/drawable/bottom_text_color.xml new file mode 100644 index 0000000..b284ea3 --- /dev/null +++ b/app/src/main/res/drawable/bottom_text_color.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_alarm.xml b/app/src/main/res/drawable/ic_alarm.xml new file mode 100644 index 0000000..dc33aab --- /dev/null +++ b/app/src/main/res/drawable/ic_alarm.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_alarm_selected.xml b/app/src/main/res/drawable/ic_alarm_selected.xml new file mode 100644 index 0000000..993fea6 --- /dev/null +++ b/app/src/main/res/drawable/ic_alarm_selected.xml @@ -0,0 +1,9 @@ + + + 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_monitor.xml b/app/src/main/res/drawable/ic_monitor.xml new file mode 100644 index 0000000..271f5b4 --- /dev/null +++ b/app/src/main/res/drawable/ic_monitor.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_monitor_selected.xml b/app/src/main/res/drawable/ic_monitor_selected.xml new file mode 100644 index 0000000..ee62d84 --- /dev/null +++ b/app/src/main/res/drawable/ic_monitor_selected.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_statistics.xml b/app/src/main/res/drawable/ic_statistics.xml new file mode 100644 index 0000000..7fde8ec --- /dev/null +++ b/app/src/main/res/drawable/ic_statistics.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_statistics_selected.xml b/app/src/main/res/drawable/ic_statistics_selected.xml new file mode 100644 index 0000000..49b6fcd --- /dev/null +++ b/app/src/main/res/drawable/ic_statistics_selected.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/monitor_selector.xml b/app/src/main/res/drawable/monitor_selector.xml new file mode 100644 index 0000000..fe11e9a --- /dev/null +++ b/app/src/main/res/drawable/monitor_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/statistics_selector.xml b/app/src/main/res/drawable/statistics_selector.xml new file mode 100644 index 0000000..2156cff --- /dev/null +++ b/app/src/main/res/drawable/statistics_selector.xml @@ -0,0 +1,5 @@ + + + + + \ 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..78a4a94 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,27 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_monitor_record.xml b/app/src/main/res/layout/activity_monitor_record.xml new file mode 100644 index 0000000..77d9ef6 --- /dev/null +++ b/app/src/main/res/layout/activity_monitor_record.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_alarm.xml b/app/src/main/res/layout/fragment_alarm.xml new file mode 100644 index 0000000..77d9ef6 --- /dev/null +++ b/app/src/main/res/layout/fragment_alarm.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_monitor.xml b/app/src/main/res/layout/fragment_monitor.xml new file mode 100644 index 0000000..19789c1 --- /dev/null +++ b/app/src/main/res/layout/fragment_monitor.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_statistics.xml b/app/src/main/res/layout/fragment_statistics.xml new file mode 100644 index 0000000..77d9ef6 --- /dev/null +++ b/app/src/main/res/layout/fragment_statistics.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/menu/bottom_nav_menu.xml b/app/src/main/res/menu/bottom_nav_menu.xml new file mode 100644 index 0000000..751fd61 --- /dev/null +++ b/app/src/main/res/menu/bottom_nav_menu.xml @@ -0,0 +1,29 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.webp b/app/src/main/res/mipmap-hdpi/ic_launcher.webp new file mode 100644 index 0000000..c209e78 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp new file mode 100644 index 0000000..b2dfe3d --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.webp b/app/src/main/res/mipmap-mdpi/ic_launcher.webp new file mode 100644 index 0000000..4f0f1d6 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp new file mode 100644 index 0000000..62b611d --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher.webp new file mode 100644 index 0000000..948a307 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..1b9a695 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp Binary files differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp new file mode 100644 index 0000000..28d4b77 --- /dev/null +++ b/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..9287f50 --- /dev/null +++ b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp new file mode 100644 index 0000000..aa7d642 --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..9126ae3 --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp 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..bbce66f --- /dev/null +++ b/app/src/main/res/values/colors.xml @@ -0,0 +1,14 @@ + + + #1D55C6 + #333333 + #CCCCCC + + #FFBB86FC + #FF6200EE + #FF3700B3 + #FF03DAC5 + #FF018786 + #FF000000 + #FFFFFFFF + \ No newline at end of file diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml new file mode 100644 index 0000000..b7a9292 --- /dev/null +++ b/app/src/main/res/values/dimens.xml @@ -0,0 +1,33 @@ + + + + 12sp + 14sp + 16sp + 18sp + 20sp + 22sp + + + 3dp + 5dp + 7dp + 10dp + 15dp + 20dp + 25dp + 30dp + 35dp + 40dp + 45dp + 50dp + 55dp + 60dp + 75dp + + + 1dp + + + 45dp + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml new file mode 100644 index 0000000..f636245 --- /dev/null +++ b/app/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + SmartTown + \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..10cfdbf --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*.iml +.gradle +/local.properties +/.idea +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..a4cd2ca --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,101 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'org.greenrobot.greendao' + +android { +// signingConfigs { +// release { +// storeFile file('/Users/a203/Desktop/AndroidProjects/CasicSmartWell/app/CasicSmartWell.jks') +// storePassword '123456789' +// keyAlias 'key0' +// keyPassword '123456789' +// } +// } + compileSdkVersion 31 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.smart.town.sanxi" + minSdkVersion 23 + targetSdkVersion 31 + versionCode 1 + versionName "1.0.0" + + manifestPlaceholders = [GETUI_APPID: "A9V4DvwLcdAqkFCQuFyhq6"] + } + + buildTypes { + release { + minifyEnabled false +// signingConfig signingConfigs.release + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + + ndk { abiFilters "armeabi", "armeabi-v7a", "arm64-v8" } + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlin { + experimental { + coroutines 'enable' + } + } + + greendao { + schemaVersion 1//数据库版本号 + targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 + daoPackage 'com.casic.smart.town.sanxi.greendao'//设置DaoMaster、DaoSession、Dao包名 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + //基础依赖库 + implementation files('libs/lite-release.aar') + implementation 'androidx.appcompat:appcompat:1.4.2' + implementation 'androidx.core:core-ktx:1.8.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:3.0.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' + //MVVM+LiveData + implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.1" + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0" + implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + //Kotlin协程 + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1' + //图片加载框架 + implementation 'com.github.bumptech.glide:glide:4.9.0' + //返回值转换器 + implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' + implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + //okhttp3日志拦截器 + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //网络请求和接口封装 + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.9.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.9.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' + //高德地图 + implementation 'com.amap.api:3dmap:latest.integration' + //推送SDK + implementation 'com.getui:gtsdk:3.2.10.0' //个推SDK + implementation 'com.getui:gtc:3.1.9.0' //个推核心组件 + //数据库框架 + implementation 'org.greenrobot:greendao:3.3.0' + //桌面角标 + implementation "me.leolin:ShortcutBadger:1.1.22@aar" +} \ No newline at end of file diff --git a/app/libs/lite-release.aar b/app/libs/lite-release.aar new file mode 100644 index 0000000..45da4df --- /dev/null +++ b/app/libs/lite-release.aar Binary files differ diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /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 \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..a83c28a --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/svg/monitor.svg b/app/src/main/assets/svg/monitor.svg new file mode 100644 index 0000000..c8d3e25 --- /dev/null +++ b/app/src/main/assets/svg/monitor.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/msg.svg b/app/src/main/assets/svg/msg.svg new file mode 100644 index 0000000..e864e48 --- /dev/null +++ b/app/src/main/assets/svg/msg.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/statistics.svg b/app/src/main/assets/svg/statistics.svg new file mode 100644 index 0000000..974000e --- /dev/null +++ b/app/src/main/assets/svg/statistics.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt new file mode 100644 index 0000000..6b9cce0 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.adapter + +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentManager +import androidx.fragment.app.FragmentPagerAdapter + +class ViewPagerAdapter(list: ArrayList, manager: FragmentManager) : + FragmentPagerAdapter(manager) { + + private var pageList: List = list + + override fun getItem(position: Int) = pageList[position] + + override fun getCount() = pageList.size +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt new file mode 100644 index 0000000..4e017b1 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt @@ -0,0 +1,40 @@ +package com.casic.smart.town.sanxi.base + +import android.app.Application +import android.util.Log +import com.casic.smart.town.sanxi.greendao.DaoMaster +import com.casic.smart.town.sanxi.greendao.DaoSession +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + private val kTag = "BaseApplication" + + companion object { + private var instance: BaseApplication by Delegates.notNull() + + fun obtainInstance() = instance + + private lateinit var daoSession: DaoSession + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences(this) + //推送 + PushManager.getInstance().initialize(this) + PushManager.getInstance().setDebugLogger(this) { + Log.d(kTag, it) + } + val devOpenHelper = DaoMaster.DevOpenHelper(this, "SmartTown.db", null) + val daoMaster = DaoMaster(devOpenHelper.writableDatabase) + daoSession = daoMaster.newSession() + } + + fun obtainDaoSession(): DaoSession { + return daoSession + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java new file mode 100644 index 0000000..b8f67dc --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java @@ -0,0 +1,133 @@ +package com.casic.smart.town.sanxi.bean; + +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Generated; +import org.greenrobot.greendao.annotation.Id; +import org.greenrobot.greendao.annotation.Unique; + +@Entity +public class AlarmMessageLocaleBean { + @Id(autoincrement = true) + private Long id;//主键自增 + + @Unique + private String messageId; + private String appId; + private String clientId; + private String taskId; + private String userId; + private String title; + private String content; + private String deviceCode; + private String isRead;//0-未读,1-已读 + private String alarmTime; + + @Generated(hash = 566950134) + public AlarmMessageLocaleBean(Long id, String messageId, String appId, + String clientId, String taskId, String userId, String title, + String content, String deviceCode, String isRead, String alarmTime) { + this.id = id; + this.messageId = messageId; + this.appId = appId; + this.clientId = clientId; + this.taskId = taskId; + this.userId = userId; + this.title = title; + this.content = content; + this.deviceCode = deviceCode; + this.isRead = isRead; + this.alarmTime = alarmTime; + } + + @Generated(hash = 1737519562) + public AlarmMessageLocaleBean() { + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getMessageId() { + return this.messageId; + } + + public void setMessageId(String messageId) { + this.messageId = messageId; + } + + public String getAppId() { + return this.appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public String getClientId() { + return this.clientId; + } + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public String getTaskId() { + return this.taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getUserId() { + return this.userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getTitle() { + return this.title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return this.content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getDeviceCode() { + return this.deviceCode; + } + + public void setDeviceCode(String deviceCode) { + this.deviceCode = deviceCode; + } + + public String getIsRead() { + return this.isRead; + } + + public void setIsRead(String isRead) { + this.isRead = isRead; + } + + public String getAlarmTime() { + return this.alarmTime; + } + + public void setAlarmTime(String alarmTime) { + this.alarmTime = alarmTime; + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt new file mode 100644 index 0000000..650e201 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class AlarmPageFragment: KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_alarm + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt new file mode 100644 index 0000000..deac8ac --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt @@ -0,0 +1,76 @@ +package com.casic.smart.town.sanxi.fragment + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.Fragment +import com.amap.api.maps.AMap +import com.amap.api.maps.AMapOptions +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.view.MonitorRecordActivity +import com.pengxh.kt.lite.extensions.navigatePageTo +import com.pengxh.kt.lite.extensions.show +import kotlinx.android.synthetic.main.fragment_monitor.view.* + +class MonitorPageFragment : Fragment() { + + private val kTag = "HomePageFragment" + private lateinit var monitorView: View + private lateinit var aMap: AMap + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? + ): View { + monitorView = inflater.inflate(R.layout.fragment_monitor, container, false) + //地图初始化 + initMap(savedInstanceState) + + monitorView.rightOperateView.setOnClickListener { + requireContext().navigatePageTo() + } + return monitorView + } + + private fun initMap(savedInstanceState: Bundle?) { + monitorView.mapView.onCreate(savedInstanceState) + aMap = monitorView.mapView.map + aMap.mapType = AMap.MAP_TYPE_NORMAL + val uiSettings = aMap.uiSettings + uiSettings.isCompassEnabled = true + uiSettings.zoomPosition = AMapOptions.ZOOM_POSITION_RIGHT_CENTER + uiSettings.isTiltGesturesEnabled = false//不许地图随手势倾斜角度 + + // 地图加载成功监听 +// aMap.addOnMapLoadedListener(this) + // 地图缩放监听 +// aMap.addOnCameraChangeListener(this) + // marker 点击事件监听 +// aMap.addOnMarkerClickListener(this) + // 点击marker弹出自定义popup +// aMap.setInfoWindowAdapter(this) + //信息窗点击事件 +// aMap.addOnInfoWindowClickListener(this) + } + + /***以下是地图生命周期管理************************************************************************/ + override fun onResume() { + super.onResume() + monitorView.mapView.onResume() + } + + override fun onPause() { + super.onPause() + monitorView.mapView.onPause() + } + + override fun onSaveInstanceState(outState: Bundle) { + super.onSaveInstanceState(outState) + monitorView.mapView.onSaveInstanceState(outState) + } + + override fun onDestroy() { + super.onDestroy() + monitorView.mapView.onDestroy() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt new file mode 100644 index 0000000..e84df12 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class StatisticsPageFragment : KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_statistics + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java new file mode 100644 index 0000000..68d7901 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java @@ -0,0 +1,255 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.database.Cursor; +import android.database.sqlite.SQLiteStatement; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.Property; +import org.greenrobot.greendao.internal.DaoConfig; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseStatement; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * DAO for table "ALARM_MESSAGE_LOCALE_BEAN". +*/ +public class AlarmMessageLocaleBeanDao extends AbstractDao { + + public static final String TABLENAME = "ALARM_MESSAGE_LOCALE_BEAN"; + + /** + * Properties of entity AlarmMessageLocaleBean.
+ * Can be used for QueryBuilder and for referencing column names. + */ + public static class Properties { + public final static Property Id = new Property(0, Long.class, "id", true, "_id"); + public final static Property MessageId = new Property(1, String.class, "messageId", false, "MESSAGE_ID"); + public final static Property AppId = new Property(2, String.class, "appId", false, "APP_ID"); + public final static Property ClientId = new Property(3, String.class, "clientId", false, "CLIENT_ID"); + public final static Property TaskId = new Property(4, String.class, "taskId", false, "TASK_ID"); + public final static Property UserId = new Property(5, String.class, "userId", false, "USER_ID"); + public final static Property Title = new Property(6, String.class, "title", false, "TITLE"); + public final static Property Content = new Property(7, String.class, "content", false, "CONTENT"); + public final static Property DeviceCode = new Property(8, String.class, "deviceCode", false, "DEVICE_CODE"); + public final static Property IsRead = new Property(9, String.class, "isRead", false, "IS_READ"); + public final static Property AlarmTime = new Property(10, String.class, "alarmTime", false, "ALARM_TIME"); + } + + + public AlarmMessageLocaleBeanDao(DaoConfig config) { + super(config); + } + + public AlarmMessageLocaleBeanDao(DaoConfig config, DaoSession daoSession) { + super(config, daoSession); + } + + /** Creates the underlying database table. */ + public static void createTable(Database db, boolean ifNotExists) { + String constraint = ifNotExists? "IF NOT EXISTS ": ""; + db.execSQL("CREATE TABLE " + constraint + "\"ALARM_MESSAGE_LOCALE_BEAN\" (" + // + "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id + "\"MESSAGE_ID\" TEXT UNIQUE ," + // 1: messageId + "\"APP_ID\" TEXT," + // 2: appId + "\"CLIENT_ID\" TEXT," + // 3: clientId + "\"TASK_ID\" TEXT," + // 4: taskId + "\"USER_ID\" TEXT," + // 5: userId + "\"TITLE\" TEXT," + // 6: title + "\"CONTENT\" TEXT," + // 7: content + "\"DEVICE_CODE\" TEXT," + // 8: deviceCode + "\"IS_READ\" TEXT," + // 9: isRead + "\"ALARM_TIME\" TEXT);"); // 10: alarmTime + } + + /** Drops the underlying database table. */ + public static void dropTable(Database db, boolean ifExists) { + String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"ALARM_MESSAGE_LOCALE_BEAN\""; + db.execSQL(sql); + } + + @Override + protected final void bindValues(DatabaseStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + protected final void bindValues(SQLiteStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + public Long readKey(Cursor cursor, int offset) { + return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); + } + + @Override + public AlarmMessageLocaleBean readEntity(Cursor cursor, int offset) { + AlarmMessageLocaleBean entity = new AlarmMessageLocaleBean( // + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // messageId + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // appId + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // clientId + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // taskId + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // userId + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // title + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // content + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // deviceCode + cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // isRead + cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10) // alarmTime + ); + return entity; + } + + @Override + public void readEntity(Cursor cursor, AlarmMessageLocaleBean entity, int offset) { + entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); + entity.setMessageId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setAppId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setClientId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setTaskId(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); + entity.setUserId(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setTitle(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setContent(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); + entity.setDeviceCode(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); + entity.setIsRead(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9)); + entity.setAlarmTime(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); + } + + @Override + protected final Long updateKeyAfterInsert(AlarmMessageLocaleBean entity, long rowId) { + entity.setId(rowId); + return rowId; + } + + @Override + public Long getKey(AlarmMessageLocaleBean entity) { + if(entity != null) { + return entity.getId(); + } else { + return null; + } + } + + @Override + public boolean hasKey(AlarmMessageLocaleBean entity) { + return entity.getId() != null; + } + + @Override + protected final boolean isEntityUpdateable() { + return true; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java new file mode 100644 index 0000000..4222c40 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java @@ -0,0 +1,96 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.content.Context; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteDatabase.CursorFactory; +import android.util.Log; + +import org.greenrobot.greendao.AbstractDaoMaster; +import org.greenrobot.greendao.database.StandardDatabase; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseOpenHelper; +import org.greenrobot.greendao.identityscope.IdentityScopeType; + + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * Master of DAO (schema version 1): knows all DAOs. + */ +public class DaoMaster extends AbstractDaoMaster { + public static final int SCHEMA_VERSION = 1; + + /** Creates underlying database table using DAOs. */ + public static void createAllTables(Database db, boolean ifNotExists) { + AlarmMessageLocaleBeanDao.createTable(db, ifNotExists); + } + + /** Drops underlying database table using DAOs. */ + public static void dropAllTables(Database db, boolean ifExists) { + AlarmMessageLocaleBeanDao.dropTable(db, ifExists); + } + + /** + * WARNING: Drops all table on Upgrade! Use only during development. + * Convenience method using a {@link DevOpenHelper}. + */ + public static DaoSession newDevSession(Context context, String name) { + Database db = new DevOpenHelper(context, name).getWritableDb(); + DaoMaster daoMaster = new DaoMaster(db); + return daoMaster.newSession(); + } + + public DaoMaster(SQLiteDatabase db) { + this(new StandardDatabase(db)); + } + + public DaoMaster(Database db) { + super(db, SCHEMA_VERSION); + registerDaoClass(AlarmMessageLocaleBeanDao.class); + } + + public DaoSession newSession() { + return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); + } + + public DaoSession newSession(IdentityScopeType type) { + return new DaoSession(db, type, daoConfigMap); + } + + /** + * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} - + */ + public static abstract class OpenHelper extends DatabaseOpenHelper { + public OpenHelper(Context context, String name) { + super(context, name, SCHEMA_VERSION); + } + + public OpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory, SCHEMA_VERSION); + } + + @Override + public void onCreate(Database db) { + Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); + createAllTables(db, false); + } + } + + /** WARNING: Drops all table on Upgrade! Use only during development. */ + public static class DevOpenHelper extends OpenHelper { + public DevOpenHelper(Context context, String name) { + super(context, name); + } + + public DevOpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory); + } + + @Override + public void onUpgrade(Database db, int oldVersion, int newVersion) { + Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); + dropAllTables(db, true); + onCreate(db); + } + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java new file mode 100644 index 0000000..480ed84 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java @@ -0,0 +1,48 @@ +package com.casic.smart.town.sanxi.greendao; + +import java.util.Map; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.AbstractDaoSession; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.identityscope.IdentityScopeType; +import org.greenrobot.greendao.internal.DaoConfig; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. + +/** + * {@inheritDoc} + * + * @see org.greenrobot.greendao.AbstractDaoSession + */ +public class DaoSession extends AbstractDaoSession { + + private final DaoConfig alarmMessageLocaleBeanDaoConfig; + + private final AlarmMessageLocaleBeanDao alarmMessageLocaleBeanDao; + + public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> + daoConfigMap) { + super(db); + + alarmMessageLocaleBeanDaoConfig = daoConfigMap.get(AlarmMessageLocaleBeanDao.class).clone(); + alarmMessageLocaleBeanDaoConfig.initIdentityScope(type); + + alarmMessageLocaleBeanDao = new AlarmMessageLocaleBeanDao(alarmMessageLocaleBeanDaoConfig, this); + + registerDao(AlarmMessageLocaleBean.class, alarmMessageLocaleBeanDao); + } + + public void clear() { + alarmMessageLocaleBeanDaoConfig.clearIdentityScope(); + } + + public AlarmMessageLocaleBeanDao getAlarmMessageLocaleBeanDao() { + return alarmMessageLocaleBeanDao; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt new file mode 100644 index 0000000..875cb8c --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt @@ -0,0 +1,5 @@ +package com.casic.smart.town.sanxi.service + +import com.igexin.sdk.PushService + +class ApplicationPushService : PushService() \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt new file mode 100644 index 0000000..396129f --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt @@ -0,0 +1,84 @@ +package com.casic.smart.town.sanxi.service + +import android.content.Context +import android.os.Message +import android.util.Log +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.casic.smart.town.sanxi.view.MainActivity +import com.igexin.sdk.GTIntentService +import com.igexin.sdk.message.GTCmdMessage +import com.igexin.sdk.message.GTNotificationMessage +import com.igexin.sdk.message.GTTransmitMessage +import com.pengxh.kt.lite.extensions.toJson + +class PushIntentService : GTIntentService() { + + private val kTag = "SmartWellIntentService" + + override fun onReceiveServicePid(context: Context?, pid: Int) { + + } + + // 透传消息 + override fun onReceiveMessageData(context: Context?, msg: GTTransmitMessage?) { + Log.d(kTag, "透传消息 -> msg = $msg") + } + + // 接收 cid + override fun onReceiveClientId(context: Context?, clientid: String?) { + Log.d(kTag, "onReceiveClientId -> $clientid") + //通知MainActivity注册个推服务 + val msg: Message = MainActivity.weakReferenceHandler.obtainMessage() + msg.what = LocaleConstant.PUSH_REGISTER + msg.obj = clientid + MainActivity.weakReferenceHandler.sendMessage(msg) + } + + // cid 离线上线通知 + override fun onReceiveOnlineState(context: Context?, online: Boolean) { + + } + + // 各种事件处理回执 + override fun onReceiveCommandResult(context: Context?, msg: GTCmdMessage?) { + + } + + // 通知到达 + override fun onNotificationMessageArrived(context: Context?, msg: GTNotificationMessage?) { + //报警 +// { +// "content": "设备编号[412022030361]发生井盖开盖报警", +// "messageId": "380abf9a79d34306a2683dc9bf96ee78", +// "taskId": "OSL-0830_4hmfimp3Vu684wo3SjXso9", +// "title": "告警提醒", +// "appid": "HKv8K9qARd6WckZ1o2Vbu4", +// "clientId": "e78beacc42e9a02ae6fb9087eb2b1171", +// "pkgName": "com.casic.app.smartwell" +// } + if (msg == null) { + return + } + Log.d(kTag, "通知到达 -> msg = ${msg.toJson()}") +// val userDetailJson = SaveKeyValues.getValue(LocaleConstant.USER_DETAIL_MODEL, "") as String +// var userId = "" +// if (userDetailJson.isNotBlank()) { +// val userDataModel = Gson().fromJson( +// userDetailJson, object : TypeToken() {}.type +// ) +// userId = userDataModel.id.toString() +// } +// //解析编号 +// val splitArray = msg.content.split("\\[|\\]".toRegex()) +// DataBaseManager.instance.insertNotice( +// msg.messageId, msg.appid, msg.clientId, msg.taskId, +// userId, msg.title, msg.content, splitArray[1], "0", +// System.currentTimeMillis().timestampToCompleteDate() +// ) + } + + // 通知点击 + override fun onNotificationMessageClicked(context: Context?, msg: GTNotificationMessage?) { + Log.d(kTag, "通知点击 -> msg = $msg") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt new file mode 100644 index 0000000..daa7c38 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt @@ -0,0 +1,14 @@ +package com.casic.smart.town.sanxi.util + +import android.content.Context +import me.leolin.shortcutbadger.ShortcutBadger + +object BadeHelper { + fun setBadgeNum(context: Context, badgeCount: Int) { + if (badgeCount == 0) { + ShortcutBadger.removeCount(context) + } else { + ShortcutBadger.applyCount(context, badgeCount) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt new file mode 100644 index 0000000..0a52ef2 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt @@ -0,0 +1,75 @@ +package com.casic.smart.town.sanxi.util + +import com.casic.smart.town.sanxi.base.BaseApplication +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao + +class DataBaseManager private constructor() { + + companion object { + //Kotlin委托模式双重锁单例 + val instance: DataBaseManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) { + DataBaseManager() + } + } + + private val beanDao = + BaseApplication.obtainInstance().obtainDaoSession().alarmMessageLocaleBeanDao + +// fun insertNotice( +// messageId: String, appid: String, clientId: String, +// taskId: String, userId: String, title: String, +// content: String, deviceCode: String, isRead: String, +// noticeTime: String +// ) { +// val noticeLocaleBean = NoticeLocaleBean() +// noticeLocaleBean.messageId = messageId +// noticeLocaleBean.appid = appid +// noticeLocaleBean.clientId = clientId +// noticeLocaleBean.taskId = taskId +// noticeLocaleBean.userId = userId +// noticeLocaleBean.title = title +// noticeLocaleBean.content = content +// noticeLocaleBean.deviceCode = deviceCode +// noticeLocaleBean.isRead = isRead +// noticeLocaleBean.noticeTime = noticeTime +// beanDao.insert(noticeLocaleBean) +// //角标设置 +// BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadNotice()) +// } + + fun deleteByMessageId(messageId: String) { + val result = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).list() + beanDao.deleteInTx(result) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun updateNoticeByMessageId(messageId: String) { + val noticeLocaleBean = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).unique() ?: return + noticeLocaleBean.isRead = "1" + beanDao.update(noticeLocaleBean) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun queryMessageByPage(userId: String, offset: Int): MutableList { + return BaseApplication.obtainInstance().obtainDaoSession() + .queryBuilder(AlarmMessageLocaleBean::class.java) + .where(AlarmMessageLocaleBeanDao.Properties.UserId.eq(userId)) + .offset(offset * LocaleConstant.PAGE_LIMIT) + .orderDesc(AlarmMessageLocaleBeanDao.Properties.AlarmTime) + .limit(LocaleConstant.PAGE_LIMIT) + .list() + } + + private fun queryUnReadMessage(): Int { + return beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.IsRead.eq("0") + ).list().size + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt new file mode 100644 index 0000000..52926a8 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt @@ -0,0 +1,31 @@ +package com.casic.smart.town.sanxi.util; + +import android.app.Activity +import android.view.WindowManager +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object LoadingDialogHub { + private lateinit var loadingDialog: QMUITipDialog + + fun show(activity: Activity, message: String) { + loadingDialog = QMUITipDialog + .Builder(activity) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_LOADING) + .setTipWord(message) + .create() + if (!activity.isDestroyed) { + try { + loadingDialog.show() + } catch (e: WindowManager.BadTokenException) { + e.printStackTrace() + } + } + } + + + fun dismiss() { + if (loadingDialog.isShowing) { + loadingDialog.dismiss() + } + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt new file mode 100644 index 0000000..de61c9a --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.util + +import android.Manifest + +object LocaleConstant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.READ_PHONE_STATE, + Manifest.permission.ACCESS_COARSE_LOCATION, + Manifest.permission.READ_EXTERNAL_STORAGE + ) + + const val PERMISSIONS_CODE = 999 + const val PUSH_REGISTER = 2022100101 + const val PAGE_LIMIT = 20 +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt new file mode 100644 index 0000000..3bea1c9 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt @@ -0,0 +1,112 @@ +package com.casic.smart.town.sanxi.view + +import android.view.KeyEvent +import android.view.MenuItem +import androidx.fragment.app.Fragment +import androidx.viewpager.widget.ViewPager +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.adapter.ViewPagerAdapter +import com.casic.smart.town.sanxi.fragment.AlarmPageFragment +import com.casic.smart.town.sanxi.fragment.MonitorPageFragment +import com.casic.smart.town.sanxi.fragment.StatisticsPageFragment +import com.gyf.immersionbar.ImmersionBar +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.base.KotlinBaseActivity +import com.pengxh.kt.lite.extensions.convertColor +import com.pengxh.kt.lite.extensions.show +import com.pengxh.kt.lite.utils.ImmerseStatusBarUtil +import com.pengxh.kt.lite.utils.WeakReferenceHandler +import kotlinx.android.synthetic.main.activity_main.* + +class MainActivity : KotlinBaseActivity() { + + companion object { + lateinit var weakReferenceHandler: WeakReferenceHandler + } + + private val kTag = "MainActivity" + private var menuItem: MenuItem? = null + private var fragmentPages: ArrayList = ArrayList() + private var clickTime: Long = 0 + + init { + fragmentPages.add(StatisticsPageFragment()) + fragmentPages.add(MonitorPageFragment()) + fragmentPages.add(AlarmPageFragment()) + } + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + ImmersionBar.with(this).statusBarDarkFont(false).init() + ImmerseStatusBarUtil.setColor(this, R.color.mainThemeColor.convertColor(this)) + } + + override fun initData() { + //推送,多次调用 SDK 初始化并无影响。 + PushManager.getInstance().initialize(this) + weakReferenceHandler = WeakReferenceHandler { + + true + } + } + + override fun observeRequestState() { + + } + + override fun initEvent() { + bottomNavigation.itemIconTintList = null + bottomNavigation.setOnNavigationItemSelectedListener { menuItem -> + when (menuItem.itemId) { + R.id.nav_statistics -> { + mainViewPager.currentItem = 0 + } + R.id.nav_monitor -> { + mainViewPager.currentItem = 1 + } + R.id.nav_alarm -> { + mainViewPager.currentItem = 2 + } + } + false + } + mainViewPager.adapter = ViewPagerAdapter(fragmentPages, supportFragmentManager) + mainViewPager.offscreenPageLimit = fragmentPages.size //缓存页数 + mainViewPager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener { + override fun onPageScrollStateChanged(state: Int) { + + } + + override fun onPageScrolled( + position: Int, + positionOffset: Float, + positionOffsetPixels: Int + ) { + + } + + override fun onPageSelected(position: Int) { + if (menuItem != null) { + menuItem!!.isChecked = false + } else { + bottomNavigation.menu.getItem(0).isChecked = false + } + menuItem = bottomNavigation.menu.getItem(position) + menuItem!!.isChecked = true + } + }) + } + + override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean { + return if (keyCode == KeyEvent.KEYCODE_BACK) { + if (System.currentTimeMillis() - clickTime > 2000) { + "再按一次退出程序".show(this) + clickTime = System.currentTimeMillis() + true + } else { + super.onKeyDown(keyCode, event) + } + } else super.onKeyDown(keyCode, event) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt new file mode 100644 index 0000000..c5d8b22 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.view + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseActivity + +class MonitorRecordActivity : KotlinBaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_monitor_record + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt new file mode 100644 index 0000000..c478d83 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt @@ -0,0 +1,55 @@ +package com.casic.smart.town.sanxi.view + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.amap.api.maps.MapsInitializer +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.gyf.immersionbar.ImmersionBar +import com.pengxh.kt.lite.extensions.navigatePageTo +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + ImmersionBar.with(this).statusBarDarkFont(true).init() + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (EasyPermissions.hasPermissions(this, *LocaleConstant.USER_PERMISSIONS)) { + startSplashScreenActivity() + } else { + EasyPermissions.requestPermissions( + this@PermissionActivity, + resources.getString(R.string.app_name) + "需要获取相关权限", + LocaleConstant.PERMISSIONS_CODE, + *LocaleConstant.USER_PERMISSIONS + ) + } + } + + private fun startSplashScreenActivity() { + //先把导航隐私政策声明,后面导航会用到 + MapsInitializer.updatePrivacyAgree(this, true) + MapsInitializer.updatePrivacyShow(this, true, true) + this.navigatePageTo() + 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) { + startSplashScreenActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable/alarm_selector.xml b/app/src/main/res/drawable/alarm_selector.xml new file mode 100644 index 0000000..39b2595 --- /dev/null +++ b/app/src/main/res/drawable/alarm_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bottom_text_color.xml b/app/src/main/res/drawable/bottom_text_color.xml new file mode 100644 index 0000000..b284ea3 --- /dev/null +++ b/app/src/main/res/drawable/bottom_text_color.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_alarm.xml b/app/src/main/res/drawable/ic_alarm.xml new file mode 100644 index 0000000..dc33aab --- /dev/null +++ b/app/src/main/res/drawable/ic_alarm.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_alarm_selected.xml b/app/src/main/res/drawable/ic_alarm_selected.xml new file mode 100644 index 0000000..993fea6 --- /dev/null +++ b/app/src/main/res/drawable/ic_alarm_selected.xml @@ -0,0 +1,9 @@ + + + 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_monitor.xml b/app/src/main/res/drawable/ic_monitor.xml new file mode 100644 index 0000000..271f5b4 --- /dev/null +++ b/app/src/main/res/drawable/ic_monitor.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_monitor_selected.xml b/app/src/main/res/drawable/ic_monitor_selected.xml new file mode 100644 index 0000000..ee62d84 --- /dev/null +++ b/app/src/main/res/drawable/ic_monitor_selected.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_statistics.xml b/app/src/main/res/drawable/ic_statistics.xml new file mode 100644 index 0000000..7fde8ec --- /dev/null +++ b/app/src/main/res/drawable/ic_statistics.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_statistics_selected.xml b/app/src/main/res/drawable/ic_statistics_selected.xml new file mode 100644 index 0000000..49b6fcd --- /dev/null +++ b/app/src/main/res/drawable/ic_statistics_selected.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/monitor_selector.xml b/app/src/main/res/drawable/monitor_selector.xml new file mode 100644 index 0000000..fe11e9a --- /dev/null +++ b/app/src/main/res/drawable/monitor_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/statistics_selector.xml b/app/src/main/res/drawable/statistics_selector.xml new file mode 100644 index 0000000..2156cff --- /dev/null +++ b/app/src/main/res/drawable/statistics_selector.xml @@ -0,0 +1,5 @@ + + + + + \ 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..78a4a94 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,27 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_monitor_record.xml b/app/src/main/res/layout/activity_monitor_record.xml new file mode 100644 index 0000000..77d9ef6 --- /dev/null +++ b/app/src/main/res/layout/activity_monitor_record.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_alarm.xml b/app/src/main/res/layout/fragment_alarm.xml new file mode 100644 index 0000000..77d9ef6 --- /dev/null +++ b/app/src/main/res/layout/fragment_alarm.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_monitor.xml b/app/src/main/res/layout/fragment_monitor.xml new file mode 100644 index 0000000..19789c1 --- /dev/null +++ b/app/src/main/res/layout/fragment_monitor.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_statistics.xml b/app/src/main/res/layout/fragment_statistics.xml new file mode 100644 index 0000000..77d9ef6 --- /dev/null +++ b/app/src/main/res/layout/fragment_statistics.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/menu/bottom_nav_menu.xml b/app/src/main/res/menu/bottom_nav_menu.xml new file mode 100644 index 0000000..751fd61 --- /dev/null +++ b/app/src/main/res/menu/bottom_nav_menu.xml @@ -0,0 +1,29 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.webp b/app/src/main/res/mipmap-hdpi/ic_launcher.webp new file mode 100644 index 0000000..c209e78 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp new file mode 100644 index 0000000..b2dfe3d --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.webp b/app/src/main/res/mipmap-mdpi/ic_launcher.webp new file mode 100644 index 0000000..4f0f1d6 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp new file mode 100644 index 0000000..62b611d --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher.webp new file mode 100644 index 0000000..948a307 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..1b9a695 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp Binary files differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp new file mode 100644 index 0000000..28d4b77 --- /dev/null +++ b/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..9287f50 --- /dev/null +++ b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp new file mode 100644 index 0000000..aa7d642 --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..9126ae3 --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp 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..bbce66f --- /dev/null +++ b/app/src/main/res/values/colors.xml @@ -0,0 +1,14 @@ + + + #1D55C6 + #333333 + #CCCCCC + + #FFBB86FC + #FF6200EE + #FF3700B3 + #FF03DAC5 + #FF018786 + #FF000000 + #FFFFFFFF + \ No newline at end of file diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml new file mode 100644 index 0000000..b7a9292 --- /dev/null +++ b/app/src/main/res/values/dimens.xml @@ -0,0 +1,33 @@ + + + + 12sp + 14sp + 16sp + 18sp + 20sp + 22sp + + + 3dp + 5dp + 7dp + 10dp + 15dp + 20dp + 25dp + 30dp + 35dp + 40dp + 45dp + 50dp + 55dp + 60dp + 75dp + + + 1dp + + + 45dp + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml new file mode 100644 index 0000000..f636245 --- /dev/null +++ b/app/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + SmartTown + \ No newline at end of file diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml new file mode 100644 index 0000000..635e8e0 --- /dev/null +++ b/app/src/main/res/values/themes.xml @@ -0,0 +1,16 @@ + + + + \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..10cfdbf --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*.iml +.gradle +/local.properties +/.idea +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..a4cd2ca --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,101 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'org.greenrobot.greendao' + +android { +// signingConfigs { +// release { +// storeFile file('/Users/a203/Desktop/AndroidProjects/CasicSmartWell/app/CasicSmartWell.jks') +// storePassword '123456789' +// keyAlias 'key0' +// keyPassword '123456789' +// } +// } + compileSdkVersion 31 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.smart.town.sanxi" + minSdkVersion 23 + targetSdkVersion 31 + versionCode 1 + versionName "1.0.0" + + manifestPlaceholders = [GETUI_APPID: "A9V4DvwLcdAqkFCQuFyhq6"] + } + + buildTypes { + release { + minifyEnabled false +// signingConfig signingConfigs.release + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + + ndk { abiFilters "armeabi", "armeabi-v7a", "arm64-v8" } + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlin { + experimental { + coroutines 'enable' + } + } + + greendao { + schemaVersion 1//数据库版本号 + targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 + daoPackage 'com.casic.smart.town.sanxi.greendao'//设置DaoMaster、DaoSession、Dao包名 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + //基础依赖库 + implementation files('libs/lite-release.aar') + implementation 'androidx.appcompat:appcompat:1.4.2' + implementation 'androidx.core:core-ktx:1.8.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:3.0.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' + //MVVM+LiveData + implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.1" + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0" + implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + //Kotlin协程 + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1' + //图片加载框架 + implementation 'com.github.bumptech.glide:glide:4.9.0' + //返回值转换器 + implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' + implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + //okhttp3日志拦截器 + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //网络请求和接口封装 + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.9.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.9.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' + //高德地图 + implementation 'com.amap.api:3dmap:latest.integration' + //推送SDK + implementation 'com.getui:gtsdk:3.2.10.0' //个推SDK + implementation 'com.getui:gtc:3.1.9.0' //个推核心组件 + //数据库框架 + implementation 'org.greenrobot:greendao:3.3.0' + //桌面角标 + implementation "me.leolin:ShortcutBadger:1.1.22@aar" +} \ No newline at end of file diff --git a/app/libs/lite-release.aar b/app/libs/lite-release.aar new file mode 100644 index 0000000..45da4df --- /dev/null +++ b/app/libs/lite-release.aar Binary files differ diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /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 \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..a83c28a --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/svg/monitor.svg b/app/src/main/assets/svg/monitor.svg new file mode 100644 index 0000000..c8d3e25 --- /dev/null +++ b/app/src/main/assets/svg/monitor.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/msg.svg b/app/src/main/assets/svg/msg.svg new file mode 100644 index 0000000..e864e48 --- /dev/null +++ b/app/src/main/assets/svg/msg.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/statistics.svg b/app/src/main/assets/svg/statistics.svg new file mode 100644 index 0000000..974000e --- /dev/null +++ b/app/src/main/assets/svg/statistics.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt new file mode 100644 index 0000000..6b9cce0 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.adapter + +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentManager +import androidx.fragment.app.FragmentPagerAdapter + +class ViewPagerAdapter(list: ArrayList, manager: FragmentManager) : + FragmentPagerAdapter(manager) { + + private var pageList: List = list + + override fun getItem(position: Int) = pageList[position] + + override fun getCount() = pageList.size +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt new file mode 100644 index 0000000..4e017b1 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt @@ -0,0 +1,40 @@ +package com.casic.smart.town.sanxi.base + +import android.app.Application +import android.util.Log +import com.casic.smart.town.sanxi.greendao.DaoMaster +import com.casic.smart.town.sanxi.greendao.DaoSession +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + private val kTag = "BaseApplication" + + companion object { + private var instance: BaseApplication by Delegates.notNull() + + fun obtainInstance() = instance + + private lateinit var daoSession: DaoSession + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences(this) + //推送 + PushManager.getInstance().initialize(this) + PushManager.getInstance().setDebugLogger(this) { + Log.d(kTag, it) + } + val devOpenHelper = DaoMaster.DevOpenHelper(this, "SmartTown.db", null) + val daoMaster = DaoMaster(devOpenHelper.writableDatabase) + daoSession = daoMaster.newSession() + } + + fun obtainDaoSession(): DaoSession { + return daoSession + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java new file mode 100644 index 0000000..b8f67dc --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java @@ -0,0 +1,133 @@ +package com.casic.smart.town.sanxi.bean; + +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Generated; +import org.greenrobot.greendao.annotation.Id; +import org.greenrobot.greendao.annotation.Unique; + +@Entity +public class AlarmMessageLocaleBean { + @Id(autoincrement = true) + private Long id;//主键自增 + + @Unique + private String messageId; + private String appId; + private String clientId; + private String taskId; + private String userId; + private String title; + private String content; + private String deviceCode; + private String isRead;//0-未读,1-已读 + private String alarmTime; + + @Generated(hash = 566950134) + public AlarmMessageLocaleBean(Long id, String messageId, String appId, + String clientId, String taskId, String userId, String title, + String content, String deviceCode, String isRead, String alarmTime) { + this.id = id; + this.messageId = messageId; + this.appId = appId; + this.clientId = clientId; + this.taskId = taskId; + this.userId = userId; + this.title = title; + this.content = content; + this.deviceCode = deviceCode; + this.isRead = isRead; + this.alarmTime = alarmTime; + } + + @Generated(hash = 1737519562) + public AlarmMessageLocaleBean() { + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getMessageId() { + return this.messageId; + } + + public void setMessageId(String messageId) { + this.messageId = messageId; + } + + public String getAppId() { + return this.appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public String getClientId() { + return this.clientId; + } + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public String getTaskId() { + return this.taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getUserId() { + return this.userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getTitle() { + return this.title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return this.content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getDeviceCode() { + return this.deviceCode; + } + + public void setDeviceCode(String deviceCode) { + this.deviceCode = deviceCode; + } + + public String getIsRead() { + return this.isRead; + } + + public void setIsRead(String isRead) { + this.isRead = isRead; + } + + public String getAlarmTime() { + return this.alarmTime; + } + + public void setAlarmTime(String alarmTime) { + this.alarmTime = alarmTime; + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt new file mode 100644 index 0000000..650e201 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class AlarmPageFragment: KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_alarm + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt new file mode 100644 index 0000000..deac8ac --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt @@ -0,0 +1,76 @@ +package com.casic.smart.town.sanxi.fragment + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.Fragment +import com.amap.api.maps.AMap +import com.amap.api.maps.AMapOptions +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.view.MonitorRecordActivity +import com.pengxh.kt.lite.extensions.navigatePageTo +import com.pengxh.kt.lite.extensions.show +import kotlinx.android.synthetic.main.fragment_monitor.view.* + +class MonitorPageFragment : Fragment() { + + private val kTag = "HomePageFragment" + private lateinit var monitorView: View + private lateinit var aMap: AMap + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? + ): View { + monitorView = inflater.inflate(R.layout.fragment_monitor, container, false) + //地图初始化 + initMap(savedInstanceState) + + monitorView.rightOperateView.setOnClickListener { + requireContext().navigatePageTo() + } + return monitorView + } + + private fun initMap(savedInstanceState: Bundle?) { + monitorView.mapView.onCreate(savedInstanceState) + aMap = monitorView.mapView.map + aMap.mapType = AMap.MAP_TYPE_NORMAL + val uiSettings = aMap.uiSettings + uiSettings.isCompassEnabled = true + uiSettings.zoomPosition = AMapOptions.ZOOM_POSITION_RIGHT_CENTER + uiSettings.isTiltGesturesEnabled = false//不许地图随手势倾斜角度 + + // 地图加载成功监听 +// aMap.addOnMapLoadedListener(this) + // 地图缩放监听 +// aMap.addOnCameraChangeListener(this) + // marker 点击事件监听 +// aMap.addOnMarkerClickListener(this) + // 点击marker弹出自定义popup +// aMap.setInfoWindowAdapter(this) + //信息窗点击事件 +// aMap.addOnInfoWindowClickListener(this) + } + + /***以下是地图生命周期管理************************************************************************/ + override fun onResume() { + super.onResume() + monitorView.mapView.onResume() + } + + override fun onPause() { + super.onPause() + monitorView.mapView.onPause() + } + + override fun onSaveInstanceState(outState: Bundle) { + super.onSaveInstanceState(outState) + monitorView.mapView.onSaveInstanceState(outState) + } + + override fun onDestroy() { + super.onDestroy() + monitorView.mapView.onDestroy() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt new file mode 100644 index 0000000..e84df12 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class StatisticsPageFragment : KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_statistics + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java new file mode 100644 index 0000000..68d7901 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java @@ -0,0 +1,255 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.database.Cursor; +import android.database.sqlite.SQLiteStatement; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.Property; +import org.greenrobot.greendao.internal.DaoConfig; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseStatement; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * DAO for table "ALARM_MESSAGE_LOCALE_BEAN". +*/ +public class AlarmMessageLocaleBeanDao extends AbstractDao { + + public static final String TABLENAME = "ALARM_MESSAGE_LOCALE_BEAN"; + + /** + * Properties of entity AlarmMessageLocaleBean.
+ * Can be used for QueryBuilder and for referencing column names. + */ + public static class Properties { + public final static Property Id = new Property(0, Long.class, "id", true, "_id"); + public final static Property MessageId = new Property(1, String.class, "messageId", false, "MESSAGE_ID"); + public final static Property AppId = new Property(2, String.class, "appId", false, "APP_ID"); + public final static Property ClientId = new Property(3, String.class, "clientId", false, "CLIENT_ID"); + public final static Property TaskId = new Property(4, String.class, "taskId", false, "TASK_ID"); + public final static Property UserId = new Property(5, String.class, "userId", false, "USER_ID"); + public final static Property Title = new Property(6, String.class, "title", false, "TITLE"); + public final static Property Content = new Property(7, String.class, "content", false, "CONTENT"); + public final static Property DeviceCode = new Property(8, String.class, "deviceCode", false, "DEVICE_CODE"); + public final static Property IsRead = new Property(9, String.class, "isRead", false, "IS_READ"); + public final static Property AlarmTime = new Property(10, String.class, "alarmTime", false, "ALARM_TIME"); + } + + + public AlarmMessageLocaleBeanDao(DaoConfig config) { + super(config); + } + + public AlarmMessageLocaleBeanDao(DaoConfig config, DaoSession daoSession) { + super(config, daoSession); + } + + /** Creates the underlying database table. */ + public static void createTable(Database db, boolean ifNotExists) { + String constraint = ifNotExists? "IF NOT EXISTS ": ""; + db.execSQL("CREATE TABLE " + constraint + "\"ALARM_MESSAGE_LOCALE_BEAN\" (" + // + "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id + "\"MESSAGE_ID\" TEXT UNIQUE ," + // 1: messageId + "\"APP_ID\" TEXT," + // 2: appId + "\"CLIENT_ID\" TEXT," + // 3: clientId + "\"TASK_ID\" TEXT," + // 4: taskId + "\"USER_ID\" TEXT," + // 5: userId + "\"TITLE\" TEXT," + // 6: title + "\"CONTENT\" TEXT," + // 7: content + "\"DEVICE_CODE\" TEXT," + // 8: deviceCode + "\"IS_READ\" TEXT," + // 9: isRead + "\"ALARM_TIME\" TEXT);"); // 10: alarmTime + } + + /** Drops the underlying database table. */ + public static void dropTable(Database db, boolean ifExists) { + String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"ALARM_MESSAGE_LOCALE_BEAN\""; + db.execSQL(sql); + } + + @Override + protected final void bindValues(DatabaseStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + protected final void bindValues(SQLiteStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + public Long readKey(Cursor cursor, int offset) { + return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); + } + + @Override + public AlarmMessageLocaleBean readEntity(Cursor cursor, int offset) { + AlarmMessageLocaleBean entity = new AlarmMessageLocaleBean( // + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // messageId + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // appId + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // clientId + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // taskId + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // userId + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // title + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // content + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // deviceCode + cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // isRead + cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10) // alarmTime + ); + return entity; + } + + @Override + public void readEntity(Cursor cursor, AlarmMessageLocaleBean entity, int offset) { + entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); + entity.setMessageId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setAppId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setClientId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setTaskId(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); + entity.setUserId(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setTitle(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setContent(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); + entity.setDeviceCode(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); + entity.setIsRead(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9)); + entity.setAlarmTime(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); + } + + @Override + protected final Long updateKeyAfterInsert(AlarmMessageLocaleBean entity, long rowId) { + entity.setId(rowId); + return rowId; + } + + @Override + public Long getKey(AlarmMessageLocaleBean entity) { + if(entity != null) { + return entity.getId(); + } else { + return null; + } + } + + @Override + public boolean hasKey(AlarmMessageLocaleBean entity) { + return entity.getId() != null; + } + + @Override + protected final boolean isEntityUpdateable() { + return true; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java new file mode 100644 index 0000000..4222c40 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java @@ -0,0 +1,96 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.content.Context; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteDatabase.CursorFactory; +import android.util.Log; + +import org.greenrobot.greendao.AbstractDaoMaster; +import org.greenrobot.greendao.database.StandardDatabase; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseOpenHelper; +import org.greenrobot.greendao.identityscope.IdentityScopeType; + + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * Master of DAO (schema version 1): knows all DAOs. + */ +public class DaoMaster extends AbstractDaoMaster { + public static final int SCHEMA_VERSION = 1; + + /** Creates underlying database table using DAOs. */ + public static void createAllTables(Database db, boolean ifNotExists) { + AlarmMessageLocaleBeanDao.createTable(db, ifNotExists); + } + + /** Drops underlying database table using DAOs. */ + public static void dropAllTables(Database db, boolean ifExists) { + AlarmMessageLocaleBeanDao.dropTable(db, ifExists); + } + + /** + * WARNING: Drops all table on Upgrade! Use only during development. + * Convenience method using a {@link DevOpenHelper}. + */ + public static DaoSession newDevSession(Context context, String name) { + Database db = new DevOpenHelper(context, name).getWritableDb(); + DaoMaster daoMaster = new DaoMaster(db); + return daoMaster.newSession(); + } + + public DaoMaster(SQLiteDatabase db) { + this(new StandardDatabase(db)); + } + + public DaoMaster(Database db) { + super(db, SCHEMA_VERSION); + registerDaoClass(AlarmMessageLocaleBeanDao.class); + } + + public DaoSession newSession() { + return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); + } + + public DaoSession newSession(IdentityScopeType type) { + return new DaoSession(db, type, daoConfigMap); + } + + /** + * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} - + */ + public static abstract class OpenHelper extends DatabaseOpenHelper { + public OpenHelper(Context context, String name) { + super(context, name, SCHEMA_VERSION); + } + + public OpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory, SCHEMA_VERSION); + } + + @Override + public void onCreate(Database db) { + Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); + createAllTables(db, false); + } + } + + /** WARNING: Drops all table on Upgrade! Use only during development. */ + public static class DevOpenHelper extends OpenHelper { + public DevOpenHelper(Context context, String name) { + super(context, name); + } + + public DevOpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory); + } + + @Override + public void onUpgrade(Database db, int oldVersion, int newVersion) { + Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); + dropAllTables(db, true); + onCreate(db); + } + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java new file mode 100644 index 0000000..480ed84 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java @@ -0,0 +1,48 @@ +package com.casic.smart.town.sanxi.greendao; + +import java.util.Map; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.AbstractDaoSession; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.identityscope.IdentityScopeType; +import org.greenrobot.greendao.internal.DaoConfig; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. + +/** + * {@inheritDoc} + * + * @see org.greenrobot.greendao.AbstractDaoSession + */ +public class DaoSession extends AbstractDaoSession { + + private final DaoConfig alarmMessageLocaleBeanDaoConfig; + + private final AlarmMessageLocaleBeanDao alarmMessageLocaleBeanDao; + + public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> + daoConfigMap) { + super(db); + + alarmMessageLocaleBeanDaoConfig = daoConfigMap.get(AlarmMessageLocaleBeanDao.class).clone(); + alarmMessageLocaleBeanDaoConfig.initIdentityScope(type); + + alarmMessageLocaleBeanDao = new AlarmMessageLocaleBeanDao(alarmMessageLocaleBeanDaoConfig, this); + + registerDao(AlarmMessageLocaleBean.class, alarmMessageLocaleBeanDao); + } + + public void clear() { + alarmMessageLocaleBeanDaoConfig.clearIdentityScope(); + } + + public AlarmMessageLocaleBeanDao getAlarmMessageLocaleBeanDao() { + return alarmMessageLocaleBeanDao; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt new file mode 100644 index 0000000..875cb8c --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt @@ -0,0 +1,5 @@ +package com.casic.smart.town.sanxi.service + +import com.igexin.sdk.PushService + +class ApplicationPushService : PushService() \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt new file mode 100644 index 0000000..396129f --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt @@ -0,0 +1,84 @@ +package com.casic.smart.town.sanxi.service + +import android.content.Context +import android.os.Message +import android.util.Log +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.casic.smart.town.sanxi.view.MainActivity +import com.igexin.sdk.GTIntentService +import com.igexin.sdk.message.GTCmdMessage +import com.igexin.sdk.message.GTNotificationMessage +import com.igexin.sdk.message.GTTransmitMessage +import com.pengxh.kt.lite.extensions.toJson + +class PushIntentService : GTIntentService() { + + private val kTag = "SmartWellIntentService" + + override fun onReceiveServicePid(context: Context?, pid: Int) { + + } + + // 透传消息 + override fun onReceiveMessageData(context: Context?, msg: GTTransmitMessage?) { + Log.d(kTag, "透传消息 -> msg = $msg") + } + + // 接收 cid + override fun onReceiveClientId(context: Context?, clientid: String?) { + Log.d(kTag, "onReceiveClientId -> $clientid") + //通知MainActivity注册个推服务 + val msg: Message = MainActivity.weakReferenceHandler.obtainMessage() + msg.what = LocaleConstant.PUSH_REGISTER + msg.obj = clientid + MainActivity.weakReferenceHandler.sendMessage(msg) + } + + // cid 离线上线通知 + override fun onReceiveOnlineState(context: Context?, online: Boolean) { + + } + + // 各种事件处理回执 + override fun onReceiveCommandResult(context: Context?, msg: GTCmdMessage?) { + + } + + // 通知到达 + override fun onNotificationMessageArrived(context: Context?, msg: GTNotificationMessage?) { + //报警 +// { +// "content": "设备编号[412022030361]发生井盖开盖报警", +// "messageId": "380abf9a79d34306a2683dc9bf96ee78", +// "taskId": "OSL-0830_4hmfimp3Vu684wo3SjXso9", +// "title": "告警提醒", +// "appid": "HKv8K9qARd6WckZ1o2Vbu4", +// "clientId": "e78beacc42e9a02ae6fb9087eb2b1171", +// "pkgName": "com.casic.app.smartwell" +// } + if (msg == null) { + return + } + Log.d(kTag, "通知到达 -> msg = ${msg.toJson()}") +// val userDetailJson = SaveKeyValues.getValue(LocaleConstant.USER_DETAIL_MODEL, "") as String +// var userId = "" +// if (userDetailJson.isNotBlank()) { +// val userDataModel = Gson().fromJson( +// userDetailJson, object : TypeToken() {}.type +// ) +// userId = userDataModel.id.toString() +// } +// //解析编号 +// val splitArray = msg.content.split("\\[|\\]".toRegex()) +// DataBaseManager.instance.insertNotice( +// msg.messageId, msg.appid, msg.clientId, msg.taskId, +// userId, msg.title, msg.content, splitArray[1], "0", +// System.currentTimeMillis().timestampToCompleteDate() +// ) + } + + // 通知点击 + override fun onNotificationMessageClicked(context: Context?, msg: GTNotificationMessage?) { + Log.d(kTag, "通知点击 -> msg = $msg") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt new file mode 100644 index 0000000..daa7c38 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt @@ -0,0 +1,14 @@ +package com.casic.smart.town.sanxi.util + +import android.content.Context +import me.leolin.shortcutbadger.ShortcutBadger + +object BadeHelper { + fun setBadgeNum(context: Context, badgeCount: Int) { + if (badgeCount == 0) { + ShortcutBadger.removeCount(context) + } else { + ShortcutBadger.applyCount(context, badgeCount) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt new file mode 100644 index 0000000..0a52ef2 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt @@ -0,0 +1,75 @@ +package com.casic.smart.town.sanxi.util + +import com.casic.smart.town.sanxi.base.BaseApplication +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao + +class DataBaseManager private constructor() { + + companion object { + //Kotlin委托模式双重锁单例 + val instance: DataBaseManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) { + DataBaseManager() + } + } + + private val beanDao = + BaseApplication.obtainInstance().obtainDaoSession().alarmMessageLocaleBeanDao + +// fun insertNotice( +// messageId: String, appid: String, clientId: String, +// taskId: String, userId: String, title: String, +// content: String, deviceCode: String, isRead: String, +// noticeTime: String +// ) { +// val noticeLocaleBean = NoticeLocaleBean() +// noticeLocaleBean.messageId = messageId +// noticeLocaleBean.appid = appid +// noticeLocaleBean.clientId = clientId +// noticeLocaleBean.taskId = taskId +// noticeLocaleBean.userId = userId +// noticeLocaleBean.title = title +// noticeLocaleBean.content = content +// noticeLocaleBean.deviceCode = deviceCode +// noticeLocaleBean.isRead = isRead +// noticeLocaleBean.noticeTime = noticeTime +// beanDao.insert(noticeLocaleBean) +// //角标设置 +// BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadNotice()) +// } + + fun deleteByMessageId(messageId: String) { + val result = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).list() + beanDao.deleteInTx(result) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun updateNoticeByMessageId(messageId: String) { + val noticeLocaleBean = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).unique() ?: return + noticeLocaleBean.isRead = "1" + beanDao.update(noticeLocaleBean) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun queryMessageByPage(userId: String, offset: Int): MutableList { + return BaseApplication.obtainInstance().obtainDaoSession() + .queryBuilder(AlarmMessageLocaleBean::class.java) + .where(AlarmMessageLocaleBeanDao.Properties.UserId.eq(userId)) + .offset(offset * LocaleConstant.PAGE_LIMIT) + .orderDesc(AlarmMessageLocaleBeanDao.Properties.AlarmTime) + .limit(LocaleConstant.PAGE_LIMIT) + .list() + } + + private fun queryUnReadMessage(): Int { + return beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.IsRead.eq("0") + ).list().size + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt new file mode 100644 index 0000000..52926a8 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt @@ -0,0 +1,31 @@ +package com.casic.smart.town.sanxi.util; + +import android.app.Activity +import android.view.WindowManager +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object LoadingDialogHub { + private lateinit var loadingDialog: QMUITipDialog + + fun show(activity: Activity, message: String) { + loadingDialog = QMUITipDialog + .Builder(activity) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_LOADING) + .setTipWord(message) + .create() + if (!activity.isDestroyed) { + try { + loadingDialog.show() + } catch (e: WindowManager.BadTokenException) { + e.printStackTrace() + } + } + } + + + fun dismiss() { + if (loadingDialog.isShowing) { + loadingDialog.dismiss() + } + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt new file mode 100644 index 0000000..de61c9a --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.util + +import android.Manifest + +object LocaleConstant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.READ_PHONE_STATE, + Manifest.permission.ACCESS_COARSE_LOCATION, + Manifest.permission.READ_EXTERNAL_STORAGE + ) + + const val PERMISSIONS_CODE = 999 + const val PUSH_REGISTER = 2022100101 + const val PAGE_LIMIT = 20 +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt new file mode 100644 index 0000000..3bea1c9 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt @@ -0,0 +1,112 @@ +package com.casic.smart.town.sanxi.view + +import android.view.KeyEvent +import android.view.MenuItem +import androidx.fragment.app.Fragment +import androidx.viewpager.widget.ViewPager +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.adapter.ViewPagerAdapter +import com.casic.smart.town.sanxi.fragment.AlarmPageFragment +import com.casic.smart.town.sanxi.fragment.MonitorPageFragment +import com.casic.smart.town.sanxi.fragment.StatisticsPageFragment +import com.gyf.immersionbar.ImmersionBar +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.base.KotlinBaseActivity +import com.pengxh.kt.lite.extensions.convertColor +import com.pengxh.kt.lite.extensions.show +import com.pengxh.kt.lite.utils.ImmerseStatusBarUtil +import com.pengxh.kt.lite.utils.WeakReferenceHandler +import kotlinx.android.synthetic.main.activity_main.* + +class MainActivity : KotlinBaseActivity() { + + companion object { + lateinit var weakReferenceHandler: WeakReferenceHandler + } + + private val kTag = "MainActivity" + private var menuItem: MenuItem? = null + private var fragmentPages: ArrayList = ArrayList() + private var clickTime: Long = 0 + + init { + fragmentPages.add(StatisticsPageFragment()) + fragmentPages.add(MonitorPageFragment()) + fragmentPages.add(AlarmPageFragment()) + } + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + ImmersionBar.with(this).statusBarDarkFont(false).init() + ImmerseStatusBarUtil.setColor(this, R.color.mainThemeColor.convertColor(this)) + } + + override fun initData() { + //推送,多次调用 SDK 初始化并无影响。 + PushManager.getInstance().initialize(this) + weakReferenceHandler = WeakReferenceHandler { + + true + } + } + + override fun observeRequestState() { + + } + + override fun initEvent() { + bottomNavigation.itemIconTintList = null + bottomNavigation.setOnNavigationItemSelectedListener { menuItem -> + when (menuItem.itemId) { + R.id.nav_statistics -> { + mainViewPager.currentItem = 0 + } + R.id.nav_monitor -> { + mainViewPager.currentItem = 1 + } + R.id.nav_alarm -> { + mainViewPager.currentItem = 2 + } + } + false + } + mainViewPager.adapter = ViewPagerAdapter(fragmentPages, supportFragmentManager) + mainViewPager.offscreenPageLimit = fragmentPages.size //缓存页数 + mainViewPager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener { + override fun onPageScrollStateChanged(state: Int) { + + } + + override fun onPageScrolled( + position: Int, + positionOffset: Float, + positionOffsetPixels: Int + ) { + + } + + override fun onPageSelected(position: Int) { + if (menuItem != null) { + menuItem!!.isChecked = false + } else { + bottomNavigation.menu.getItem(0).isChecked = false + } + menuItem = bottomNavigation.menu.getItem(position) + menuItem!!.isChecked = true + } + }) + } + + override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean { + return if (keyCode == KeyEvent.KEYCODE_BACK) { + if (System.currentTimeMillis() - clickTime > 2000) { + "再按一次退出程序".show(this) + clickTime = System.currentTimeMillis() + true + } else { + super.onKeyDown(keyCode, event) + } + } else super.onKeyDown(keyCode, event) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt new file mode 100644 index 0000000..c5d8b22 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.view + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseActivity + +class MonitorRecordActivity : KotlinBaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_monitor_record + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt new file mode 100644 index 0000000..c478d83 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt @@ -0,0 +1,55 @@ +package com.casic.smart.town.sanxi.view + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.amap.api.maps.MapsInitializer +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.gyf.immersionbar.ImmersionBar +import com.pengxh.kt.lite.extensions.navigatePageTo +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + ImmersionBar.with(this).statusBarDarkFont(true).init() + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (EasyPermissions.hasPermissions(this, *LocaleConstant.USER_PERMISSIONS)) { + startSplashScreenActivity() + } else { + EasyPermissions.requestPermissions( + this@PermissionActivity, + resources.getString(R.string.app_name) + "需要获取相关权限", + LocaleConstant.PERMISSIONS_CODE, + *LocaleConstant.USER_PERMISSIONS + ) + } + } + + private fun startSplashScreenActivity() { + //先把导航隐私政策声明,后面导航会用到 + MapsInitializer.updatePrivacyAgree(this, true) + MapsInitializer.updatePrivacyShow(this, true, true) + this.navigatePageTo() + 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) { + startSplashScreenActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable/alarm_selector.xml b/app/src/main/res/drawable/alarm_selector.xml new file mode 100644 index 0000000..39b2595 --- /dev/null +++ b/app/src/main/res/drawable/alarm_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bottom_text_color.xml b/app/src/main/res/drawable/bottom_text_color.xml new file mode 100644 index 0000000..b284ea3 --- /dev/null +++ b/app/src/main/res/drawable/bottom_text_color.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_alarm.xml b/app/src/main/res/drawable/ic_alarm.xml new file mode 100644 index 0000000..dc33aab --- /dev/null +++ b/app/src/main/res/drawable/ic_alarm.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_alarm_selected.xml b/app/src/main/res/drawable/ic_alarm_selected.xml new file mode 100644 index 0000000..993fea6 --- /dev/null +++ b/app/src/main/res/drawable/ic_alarm_selected.xml @@ -0,0 +1,9 @@ + + + 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_monitor.xml b/app/src/main/res/drawable/ic_monitor.xml new file mode 100644 index 0000000..271f5b4 --- /dev/null +++ b/app/src/main/res/drawable/ic_monitor.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_monitor_selected.xml b/app/src/main/res/drawable/ic_monitor_selected.xml new file mode 100644 index 0000000..ee62d84 --- /dev/null +++ b/app/src/main/res/drawable/ic_monitor_selected.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_statistics.xml b/app/src/main/res/drawable/ic_statistics.xml new file mode 100644 index 0000000..7fde8ec --- /dev/null +++ b/app/src/main/res/drawable/ic_statistics.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_statistics_selected.xml b/app/src/main/res/drawable/ic_statistics_selected.xml new file mode 100644 index 0000000..49b6fcd --- /dev/null +++ b/app/src/main/res/drawable/ic_statistics_selected.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/monitor_selector.xml b/app/src/main/res/drawable/monitor_selector.xml new file mode 100644 index 0000000..fe11e9a --- /dev/null +++ b/app/src/main/res/drawable/monitor_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/statistics_selector.xml b/app/src/main/res/drawable/statistics_selector.xml new file mode 100644 index 0000000..2156cff --- /dev/null +++ b/app/src/main/res/drawable/statistics_selector.xml @@ -0,0 +1,5 @@ + + + + + \ 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..78a4a94 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,27 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_monitor_record.xml b/app/src/main/res/layout/activity_monitor_record.xml new file mode 100644 index 0000000..77d9ef6 --- /dev/null +++ b/app/src/main/res/layout/activity_monitor_record.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_alarm.xml b/app/src/main/res/layout/fragment_alarm.xml new file mode 100644 index 0000000..77d9ef6 --- /dev/null +++ b/app/src/main/res/layout/fragment_alarm.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_monitor.xml b/app/src/main/res/layout/fragment_monitor.xml new file mode 100644 index 0000000..19789c1 --- /dev/null +++ b/app/src/main/res/layout/fragment_monitor.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_statistics.xml b/app/src/main/res/layout/fragment_statistics.xml new file mode 100644 index 0000000..77d9ef6 --- /dev/null +++ b/app/src/main/res/layout/fragment_statistics.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/menu/bottom_nav_menu.xml b/app/src/main/res/menu/bottom_nav_menu.xml new file mode 100644 index 0000000..751fd61 --- /dev/null +++ b/app/src/main/res/menu/bottom_nav_menu.xml @@ -0,0 +1,29 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.webp b/app/src/main/res/mipmap-hdpi/ic_launcher.webp new file mode 100644 index 0000000..c209e78 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp new file mode 100644 index 0000000..b2dfe3d --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.webp b/app/src/main/res/mipmap-mdpi/ic_launcher.webp new file mode 100644 index 0000000..4f0f1d6 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp new file mode 100644 index 0000000..62b611d --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher.webp new file mode 100644 index 0000000..948a307 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..1b9a695 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp Binary files differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp new file mode 100644 index 0000000..28d4b77 --- /dev/null +++ b/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..9287f50 --- /dev/null +++ b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp new file mode 100644 index 0000000..aa7d642 --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..9126ae3 --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp 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..bbce66f --- /dev/null +++ b/app/src/main/res/values/colors.xml @@ -0,0 +1,14 @@ + + + #1D55C6 + #333333 + #CCCCCC + + #FFBB86FC + #FF6200EE + #FF3700B3 + #FF03DAC5 + #FF018786 + #FF000000 + #FFFFFFFF + \ No newline at end of file diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml new file mode 100644 index 0000000..b7a9292 --- /dev/null +++ b/app/src/main/res/values/dimens.xml @@ -0,0 +1,33 @@ + + + + 12sp + 14sp + 16sp + 18sp + 20sp + 22sp + + + 3dp + 5dp + 7dp + 10dp + 15dp + 20dp + 25dp + 30dp + 35dp + 40dp + 45dp + 50dp + 55dp + 60dp + 75dp + + + 1dp + + + 45dp + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml new file mode 100644 index 0000000..f636245 --- /dev/null +++ b/app/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + SmartTown + \ No newline at end of file diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml new file mode 100644 index 0000000..635e8e0 --- /dev/null +++ b/app/src/main/res/values/themes.xml @@ -0,0 +1,16 @@ + + + + \ No newline at end of file diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..62b9d90 --- /dev/null +++ b/build.gradle @@ -0,0 +1,30 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. +buildscript { + ext.kotlin_version = '1.6.10' + repositories { + maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' } + google() + } + dependencies { + classpath 'com.android.tools.build:gradle:3.6.4' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + classpath 'org.greenrobot:greendao-gradle-plugin:3.3.0' + + // 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() + maven { url "https://mvn.getui.com/nexus/content/repositories/releases/"} + } +} + +task clean(type: Delete) { + delete rootProject.buildDir +} \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..10cfdbf --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*.iml +.gradle +/local.properties +/.idea +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..a4cd2ca --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,101 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'org.greenrobot.greendao' + +android { +// signingConfigs { +// release { +// storeFile file('/Users/a203/Desktop/AndroidProjects/CasicSmartWell/app/CasicSmartWell.jks') +// storePassword '123456789' +// keyAlias 'key0' +// keyPassword '123456789' +// } +// } + compileSdkVersion 31 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.smart.town.sanxi" + minSdkVersion 23 + targetSdkVersion 31 + versionCode 1 + versionName "1.0.0" + + manifestPlaceholders = [GETUI_APPID: "A9V4DvwLcdAqkFCQuFyhq6"] + } + + buildTypes { + release { + minifyEnabled false +// signingConfig signingConfigs.release + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + + ndk { abiFilters "armeabi", "armeabi-v7a", "arm64-v8" } + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlin { + experimental { + coroutines 'enable' + } + } + + greendao { + schemaVersion 1//数据库版本号 + targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 + daoPackage 'com.casic.smart.town.sanxi.greendao'//设置DaoMaster、DaoSession、Dao包名 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + //基础依赖库 + implementation files('libs/lite-release.aar') + implementation 'androidx.appcompat:appcompat:1.4.2' + implementation 'androidx.core:core-ktx:1.8.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:3.0.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' + //MVVM+LiveData + implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.1" + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0" + implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + //Kotlin协程 + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1' + //图片加载框架 + implementation 'com.github.bumptech.glide:glide:4.9.0' + //返回值转换器 + implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' + implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + //okhttp3日志拦截器 + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //网络请求和接口封装 + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.9.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.9.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' + //高德地图 + implementation 'com.amap.api:3dmap:latest.integration' + //推送SDK + implementation 'com.getui:gtsdk:3.2.10.0' //个推SDK + implementation 'com.getui:gtc:3.1.9.0' //个推核心组件 + //数据库框架 + implementation 'org.greenrobot:greendao:3.3.0' + //桌面角标 + implementation "me.leolin:ShortcutBadger:1.1.22@aar" +} \ No newline at end of file diff --git a/app/libs/lite-release.aar b/app/libs/lite-release.aar new file mode 100644 index 0000000..45da4df --- /dev/null +++ b/app/libs/lite-release.aar Binary files differ diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /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 \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..a83c28a --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/svg/monitor.svg b/app/src/main/assets/svg/monitor.svg new file mode 100644 index 0000000..c8d3e25 --- /dev/null +++ b/app/src/main/assets/svg/monitor.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/msg.svg b/app/src/main/assets/svg/msg.svg new file mode 100644 index 0000000..e864e48 --- /dev/null +++ b/app/src/main/assets/svg/msg.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/statistics.svg b/app/src/main/assets/svg/statistics.svg new file mode 100644 index 0000000..974000e --- /dev/null +++ b/app/src/main/assets/svg/statistics.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt new file mode 100644 index 0000000..6b9cce0 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.adapter + +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentManager +import androidx.fragment.app.FragmentPagerAdapter + +class ViewPagerAdapter(list: ArrayList, manager: FragmentManager) : + FragmentPagerAdapter(manager) { + + private var pageList: List = list + + override fun getItem(position: Int) = pageList[position] + + override fun getCount() = pageList.size +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt new file mode 100644 index 0000000..4e017b1 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt @@ -0,0 +1,40 @@ +package com.casic.smart.town.sanxi.base + +import android.app.Application +import android.util.Log +import com.casic.smart.town.sanxi.greendao.DaoMaster +import com.casic.smart.town.sanxi.greendao.DaoSession +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + private val kTag = "BaseApplication" + + companion object { + private var instance: BaseApplication by Delegates.notNull() + + fun obtainInstance() = instance + + private lateinit var daoSession: DaoSession + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences(this) + //推送 + PushManager.getInstance().initialize(this) + PushManager.getInstance().setDebugLogger(this) { + Log.d(kTag, it) + } + val devOpenHelper = DaoMaster.DevOpenHelper(this, "SmartTown.db", null) + val daoMaster = DaoMaster(devOpenHelper.writableDatabase) + daoSession = daoMaster.newSession() + } + + fun obtainDaoSession(): DaoSession { + return daoSession + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java new file mode 100644 index 0000000..b8f67dc --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java @@ -0,0 +1,133 @@ +package com.casic.smart.town.sanxi.bean; + +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Generated; +import org.greenrobot.greendao.annotation.Id; +import org.greenrobot.greendao.annotation.Unique; + +@Entity +public class AlarmMessageLocaleBean { + @Id(autoincrement = true) + private Long id;//主键自增 + + @Unique + private String messageId; + private String appId; + private String clientId; + private String taskId; + private String userId; + private String title; + private String content; + private String deviceCode; + private String isRead;//0-未读,1-已读 + private String alarmTime; + + @Generated(hash = 566950134) + public AlarmMessageLocaleBean(Long id, String messageId, String appId, + String clientId, String taskId, String userId, String title, + String content, String deviceCode, String isRead, String alarmTime) { + this.id = id; + this.messageId = messageId; + this.appId = appId; + this.clientId = clientId; + this.taskId = taskId; + this.userId = userId; + this.title = title; + this.content = content; + this.deviceCode = deviceCode; + this.isRead = isRead; + this.alarmTime = alarmTime; + } + + @Generated(hash = 1737519562) + public AlarmMessageLocaleBean() { + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getMessageId() { + return this.messageId; + } + + public void setMessageId(String messageId) { + this.messageId = messageId; + } + + public String getAppId() { + return this.appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public String getClientId() { + return this.clientId; + } + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public String getTaskId() { + return this.taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getUserId() { + return this.userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getTitle() { + return this.title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return this.content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getDeviceCode() { + return this.deviceCode; + } + + public void setDeviceCode(String deviceCode) { + this.deviceCode = deviceCode; + } + + public String getIsRead() { + return this.isRead; + } + + public void setIsRead(String isRead) { + this.isRead = isRead; + } + + public String getAlarmTime() { + return this.alarmTime; + } + + public void setAlarmTime(String alarmTime) { + this.alarmTime = alarmTime; + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt new file mode 100644 index 0000000..650e201 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class AlarmPageFragment: KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_alarm + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt new file mode 100644 index 0000000..deac8ac --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt @@ -0,0 +1,76 @@ +package com.casic.smart.town.sanxi.fragment + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.Fragment +import com.amap.api.maps.AMap +import com.amap.api.maps.AMapOptions +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.view.MonitorRecordActivity +import com.pengxh.kt.lite.extensions.navigatePageTo +import com.pengxh.kt.lite.extensions.show +import kotlinx.android.synthetic.main.fragment_monitor.view.* + +class MonitorPageFragment : Fragment() { + + private val kTag = "HomePageFragment" + private lateinit var monitorView: View + private lateinit var aMap: AMap + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? + ): View { + monitorView = inflater.inflate(R.layout.fragment_monitor, container, false) + //地图初始化 + initMap(savedInstanceState) + + monitorView.rightOperateView.setOnClickListener { + requireContext().navigatePageTo() + } + return monitorView + } + + private fun initMap(savedInstanceState: Bundle?) { + monitorView.mapView.onCreate(savedInstanceState) + aMap = monitorView.mapView.map + aMap.mapType = AMap.MAP_TYPE_NORMAL + val uiSettings = aMap.uiSettings + uiSettings.isCompassEnabled = true + uiSettings.zoomPosition = AMapOptions.ZOOM_POSITION_RIGHT_CENTER + uiSettings.isTiltGesturesEnabled = false//不许地图随手势倾斜角度 + + // 地图加载成功监听 +// aMap.addOnMapLoadedListener(this) + // 地图缩放监听 +// aMap.addOnCameraChangeListener(this) + // marker 点击事件监听 +// aMap.addOnMarkerClickListener(this) + // 点击marker弹出自定义popup +// aMap.setInfoWindowAdapter(this) + //信息窗点击事件 +// aMap.addOnInfoWindowClickListener(this) + } + + /***以下是地图生命周期管理************************************************************************/ + override fun onResume() { + super.onResume() + monitorView.mapView.onResume() + } + + override fun onPause() { + super.onPause() + monitorView.mapView.onPause() + } + + override fun onSaveInstanceState(outState: Bundle) { + super.onSaveInstanceState(outState) + monitorView.mapView.onSaveInstanceState(outState) + } + + override fun onDestroy() { + super.onDestroy() + monitorView.mapView.onDestroy() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt new file mode 100644 index 0000000..e84df12 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class StatisticsPageFragment : KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_statistics + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java new file mode 100644 index 0000000..68d7901 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java @@ -0,0 +1,255 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.database.Cursor; +import android.database.sqlite.SQLiteStatement; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.Property; +import org.greenrobot.greendao.internal.DaoConfig; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseStatement; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * DAO for table "ALARM_MESSAGE_LOCALE_BEAN". +*/ +public class AlarmMessageLocaleBeanDao extends AbstractDao { + + public static final String TABLENAME = "ALARM_MESSAGE_LOCALE_BEAN"; + + /** + * Properties of entity AlarmMessageLocaleBean.
+ * Can be used for QueryBuilder and for referencing column names. + */ + public static class Properties { + public final static Property Id = new Property(0, Long.class, "id", true, "_id"); + public final static Property MessageId = new Property(1, String.class, "messageId", false, "MESSAGE_ID"); + public final static Property AppId = new Property(2, String.class, "appId", false, "APP_ID"); + public final static Property ClientId = new Property(3, String.class, "clientId", false, "CLIENT_ID"); + public final static Property TaskId = new Property(4, String.class, "taskId", false, "TASK_ID"); + public final static Property UserId = new Property(5, String.class, "userId", false, "USER_ID"); + public final static Property Title = new Property(6, String.class, "title", false, "TITLE"); + public final static Property Content = new Property(7, String.class, "content", false, "CONTENT"); + public final static Property DeviceCode = new Property(8, String.class, "deviceCode", false, "DEVICE_CODE"); + public final static Property IsRead = new Property(9, String.class, "isRead", false, "IS_READ"); + public final static Property AlarmTime = new Property(10, String.class, "alarmTime", false, "ALARM_TIME"); + } + + + public AlarmMessageLocaleBeanDao(DaoConfig config) { + super(config); + } + + public AlarmMessageLocaleBeanDao(DaoConfig config, DaoSession daoSession) { + super(config, daoSession); + } + + /** Creates the underlying database table. */ + public static void createTable(Database db, boolean ifNotExists) { + String constraint = ifNotExists? "IF NOT EXISTS ": ""; + db.execSQL("CREATE TABLE " + constraint + "\"ALARM_MESSAGE_LOCALE_BEAN\" (" + // + "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id + "\"MESSAGE_ID\" TEXT UNIQUE ," + // 1: messageId + "\"APP_ID\" TEXT," + // 2: appId + "\"CLIENT_ID\" TEXT," + // 3: clientId + "\"TASK_ID\" TEXT," + // 4: taskId + "\"USER_ID\" TEXT," + // 5: userId + "\"TITLE\" TEXT," + // 6: title + "\"CONTENT\" TEXT," + // 7: content + "\"DEVICE_CODE\" TEXT," + // 8: deviceCode + "\"IS_READ\" TEXT," + // 9: isRead + "\"ALARM_TIME\" TEXT);"); // 10: alarmTime + } + + /** Drops the underlying database table. */ + public static void dropTable(Database db, boolean ifExists) { + String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"ALARM_MESSAGE_LOCALE_BEAN\""; + db.execSQL(sql); + } + + @Override + protected final void bindValues(DatabaseStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + protected final void bindValues(SQLiteStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + public Long readKey(Cursor cursor, int offset) { + return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); + } + + @Override + public AlarmMessageLocaleBean readEntity(Cursor cursor, int offset) { + AlarmMessageLocaleBean entity = new AlarmMessageLocaleBean( // + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // messageId + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // appId + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // clientId + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // taskId + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // userId + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // title + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // content + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // deviceCode + cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // isRead + cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10) // alarmTime + ); + return entity; + } + + @Override + public void readEntity(Cursor cursor, AlarmMessageLocaleBean entity, int offset) { + entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); + entity.setMessageId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setAppId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setClientId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setTaskId(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); + entity.setUserId(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setTitle(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setContent(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); + entity.setDeviceCode(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); + entity.setIsRead(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9)); + entity.setAlarmTime(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); + } + + @Override + protected final Long updateKeyAfterInsert(AlarmMessageLocaleBean entity, long rowId) { + entity.setId(rowId); + return rowId; + } + + @Override + public Long getKey(AlarmMessageLocaleBean entity) { + if(entity != null) { + return entity.getId(); + } else { + return null; + } + } + + @Override + public boolean hasKey(AlarmMessageLocaleBean entity) { + return entity.getId() != null; + } + + @Override + protected final boolean isEntityUpdateable() { + return true; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java new file mode 100644 index 0000000..4222c40 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java @@ -0,0 +1,96 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.content.Context; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteDatabase.CursorFactory; +import android.util.Log; + +import org.greenrobot.greendao.AbstractDaoMaster; +import org.greenrobot.greendao.database.StandardDatabase; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseOpenHelper; +import org.greenrobot.greendao.identityscope.IdentityScopeType; + + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * Master of DAO (schema version 1): knows all DAOs. + */ +public class DaoMaster extends AbstractDaoMaster { + public static final int SCHEMA_VERSION = 1; + + /** Creates underlying database table using DAOs. */ + public static void createAllTables(Database db, boolean ifNotExists) { + AlarmMessageLocaleBeanDao.createTable(db, ifNotExists); + } + + /** Drops underlying database table using DAOs. */ + public static void dropAllTables(Database db, boolean ifExists) { + AlarmMessageLocaleBeanDao.dropTable(db, ifExists); + } + + /** + * WARNING: Drops all table on Upgrade! Use only during development. + * Convenience method using a {@link DevOpenHelper}. + */ + public static DaoSession newDevSession(Context context, String name) { + Database db = new DevOpenHelper(context, name).getWritableDb(); + DaoMaster daoMaster = new DaoMaster(db); + return daoMaster.newSession(); + } + + public DaoMaster(SQLiteDatabase db) { + this(new StandardDatabase(db)); + } + + public DaoMaster(Database db) { + super(db, SCHEMA_VERSION); + registerDaoClass(AlarmMessageLocaleBeanDao.class); + } + + public DaoSession newSession() { + return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); + } + + public DaoSession newSession(IdentityScopeType type) { + return new DaoSession(db, type, daoConfigMap); + } + + /** + * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} - + */ + public static abstract class OpenHelper extends DatabaseOpenHelper { + public OpenHelper(Context context, String name) { + super(context, name, SCHEMA_VERSION); + } + + public OpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory, SCHEMA_VERSION); + } + + @Override + public void onCreate(Database db) { + Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); + createAllTables(db, false); + } + } + + /** WARNING: Drops all table on Upgrade! Use only during development. */ + public static class DevOpenHelper extends OpenHelper { + public DevOpenHelper(Context context, String name) { + super(context, name); + } + + public DevOpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory); + } + + @Override + public void onUpgrade(Database db, int oldVersion, int newVersion) { + Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); + dropAllTables(db, true); + onCreate(db); + } + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java new file mode 100644 index 0000000..480ed84 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java @@ -0,0 +1,48 @@ +package com.casic.smart.town.sanxi.greendao; + +import java.util.Map; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.AbstractDaoSession; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.identityscope.IdentityScopeType; +import org.greenrobot.greendao.internal.DaoConfig; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. + +/** + * {@inheritDoc} + * + * @see org.greenrobot.greendao.AbstractDaoSession + */ +public class DaoSession extends AbstractDaoSession { + + private final DaoConfig alarmMessageLocaleBeanDaoConfig; + + private final AlarmMessageLocaleBeanDao alarmMessageLocaleBeanDao; + + public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> + daoConfigMap) { + super(db); + + alarmMessageLocaleBeanDaoConfig = daoConfigMap.get(AlarmMessageLocaleBeanDao.class).clone(); + alarmMessageLocaleBeanDaoConfig.initIdentityScope(type); + + alarmMessageLocaleBeanDao = new AlarmMessageLocaleBeanDao(alarmMessageLocaleBeanDaoConfig, this); + + registerDao(AlarmMessageLocaleBean.class, alarmMessageLocaleBeanDao); + } + + public void clear() { + alarmMessageLocaleBeanDaoConfig.clearIdentityScope(); + } + + public AlarmMessageLocaleBeanDao getAlarmMessageLocaleBeanDao() { + return alarmMessageLocaleBeanDao; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt new file mode 100644 index 0000000..875cb8c --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt @@ -0,0 +1,5 @@ +package com.casic.smart.town.sanxi.service + +import com.igexin.sdk.PushService + +class ApplicationPushService : PushService() \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt new file mode 100644 index 0000000..396129f --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt @@ -0,0 +1,84 @@ +package com.casic.smart.town.sanxi.service + +import android.content.Context +import android.os.Message +import android.util.Log +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.casic.smart.town.sanxi.view.MainActivity +import com.igexin.sdk.GTIntentService +import com.igexin.sdk.message.GTCmdMessage +import com.igexin.sdk.message.GTNotificationMessage +import com.igexin.sdk.message.GTTransmitMessage +import com.pengxh.kt.lite.extensions.toJson + +class PushIntentService : GTIntentService() { + + private val kTag = "SmartWellIntentService" + + override fun onReceiveServicePid(context: Context?, pid: Int) { + + } + + // 透传消息 + override fun onReceiveMessageData(context: Context?, msg: GTTransmitMessage?) { + Log.d(kTag, "透传消息 -> msg = $msg") + } + + // 接收 cid + override fun onReceiveClientId(context: Context?, clientid: String?) { + Log.d(kTag, "onReceiveClientId -> $clientid") + //通知MainActivity注册个推服务 + val msg: Message = MainActivity.weakReferenceHandler.obtainMessage() + msg.what = LocaleConstant.PUSH_REGISTER + msg.obj = clientid + MainActivity.weakReferenceHandler.sendMessage(msg) + } + + // cid 离线上线通知 + override fun onReceiveOnlineState(context: Context?, online: Boolean) { + + } + + // 各种事件处理回执 + override fun onReceiveCommandResult(context: Context?, msg: GTCmdMessage?) { + + } + + // 通知到达 + override fun onNotificationMessageArrived(context: Context?, msg: GTNotificationMessage?) { + //报警 +// { +// "content": "设备编号[412022030361]发生井盖开盖报警", +// "messageId": "380abf9a79d34306a2683dc9bf96ee78", +// "taskId": "OSL-0830_4hmfimp3Vu684wo3SjXso9", +// "title": "告警提醒", +// "appid": "HKv8K9qARd6WckZ1o2Vbu4", +// "clientId": "e78beacc42e9a02ae6fb9087eb2b1171", +// "pkgName": "com.casic.app.smartwell" +// } + if (msg == null) { + return + } + Log.d(kTag, "通知到达 -> msg = ${msg.toJson()}") +// val userDetailJson = SaveKeyValues.getValue(LocaleConstant.USER_DETAIL_MODEL, "") as String +// var userId = "" +// if (userDetailJson.isNotBlank()) { +// val userDataModel = Gson().fromJson( +// userDetailJson, object : TypeToken() {}.type +// ) +// userId = userDataModel.id.toString() +// } +// //解析编号 +// val splitArray = msg.content.split("\\[|\\]".toRegex()) +// DataBaseManager.instance.insertNotice( +// msg.messageId, msg.appid, msg.clientId, msg.taskId, +// userId, msg.title, msg.content, splitArray[1], "0", +// System.currentTimeMillis().timestampToCompleteDate() +// ) + } + + // 通知点击 + override fun onNotificationMessageClicked(context: Context?, msg: GTNotificationMessage?) { + Log.d(kTag, "通知点击 -> msg = $msg") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt new file mode 100644 index 0000000..daa7c38 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt @@ -0,0 +1,14 @@ +package com.casic.smart.town.sanxi.util + +import android.content.Context +import me.leolin.shortcutbadger.ShortcutBadger + +object BadeHelper { + fun setBadgeNum(context: Context, badgeCount: Int) { + if (badgeCount == 0) { + ShortcutBadger.removeCount(context) + } else { + ShortcutBadger.applyCount(context, badgeCount) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt new file mode 100644 index 0000000..0a52ef2 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt @@ -0,0 +1,75 @@ +package com.casic.smart.town.sanxi.util + +import com.casic.smart.town.sanxi.base.BaseApplication +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao + +class DataBaseManager private constructor() { + + companion object { + //Kotlin委托模式双重锁单例 + val instance: DataBaseManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) { + DataBaseManager() + } + } + + private val beanDao = + BaseApplication.obtainInstance().obtainDaoSession().alarmMessageLocaleBeanDao + +// fun insertNotice( +// messageId: String, appid: String, clientId: String, +// taskId: String, userId: String, title: String, +// content: String, deviceCode: String, isRead: String, +// noticeTime: String +// ) { +// val noticeLocaleBean = NoticeLocaleBean() +// noticeLocaleBean.messageId = messageId +// noticeLocaleBean.appid = appid +// noticeLocaleBean.clientId = clientId +// noticeLocaleBean.taskId = taskId +// noticeLocaleBean.userId = userId +// noticeLocaleBean.title = title +// noticeLocaleBean.content = content +// noticeLocaleBean.deviceCode = deviceCode +// noticeLocaleBean.isRead = isRead +// noticeLocaleBean.noticeTime = noticeTime +// beanDao.insert(noticeLocaleBean) +// //角标设置 +// BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadNotice()) +// } + + fun deleteByMessageId(messageId: String) { + val result = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).list() + beanDao.deleteInTx(result) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun updateNoticeByMessageId(messageId: String) { + val noticeLocaleBean = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).unique() ?: return + noticeLocaleBean.isRead = "1" + beanDao.update(noticeLocaleBean) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun queryMessageByPage(userId: String, offset: Int): MutableList { + return BaseApplication.obtainInstance().obtainDaoSession() + .queryBuilder(AlarmMessageLocaleBean::class.java) + .where(AlarmMessageLocaleBeanDao.Properties.UserId.eq(userId)) + .offset(offset * LocaleConstant.PAGE_LIMIT) + .orderDesc(AlarmMessageLocaleBeanDao.Properties.AlarmTime) + .limit(LocaleConstant.PAGE_LIMIT) + .list() + } + + private fun queryUnReadMessage(): Int { + return beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.IsRead.eq("0") + ).list().size + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt new file mode 100644 index 0000000..52926a8 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt @@ -0,0 +1,31 @@ +package com.casic.smart.town.sanxi.util; + +import android.app.Activity +import android.view.WindowManager +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object LoadingDialogHub { + private lateinit var loadingDialog: QMUITipDialog + + fun show(activity: Activity, message: String) { + loadingDialog = QMUITipDialog + .Builder(activity) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_LOADING) + .setTipWord(message) + .create() + if (!activity.isDestroyed) { + try { + loadingDialog.show() + } catch (e: WindowManager.BadTokenException) { + e.printStackTrace() + } + } + } + + + fun dismiss() { + if (loadingDialog.isShowing) { + loadingDialog.dismiss() + } + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt new file mode 100644 index 0000000..de61c9a --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.util + +import android.Manifest + +object LocaleConstant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.READ_PHONE_STATE, + Manifest.permission.ACCESS_COARSE_LOCATION, + Manifest.permission.READ_EXTERNAL_STORAGE + ) + + const val PERMISSIONS_CODE = 999 + const val PUSH_REGISTER = 2022100101 + const val PAGE_LIMIT = 20 +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt new file mode 100644 index 0000000..3bea1c9 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt @@ -0,0 +1,112 @@ +package com.casic.smart.town.sanxi.view + +import android.view.KeyEvent +import android.view.MenuItem +import androidx.fragment.app.Fragment +import androidx.viewpager.widget.ViewPager +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.adapter.ViewPagerAdapter +import com.casic.smart.town.sanxi.fragment.AlarmPageFragment +import com.casic.smart.town.sanxi.fragment.MonitorPageFragment +import com.casic.smart.town.sanxi.fragment.StatisticsPageFragment +import com.gyf.immersionbar.ImmersionBar +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.base.KotlinBaseActivity +import com.pengxh.kt.lite.extensions.convertColor +import com.pengxh.kt.lite.extensions.show +import com.pengxh.kt.lite.utils.ImmerseStatusBarUtil +import com.pengxh.kt.lite.utils.WeakReferenceHandler +import kotlinx.android.synthetic.main.activity_main.* + +class MainActivity : KotlinBaseActivity() { + + companion object { + lateinit var weakReferenceHandler: WeakReferenceHandler + } + + private val kTag = "MainActivity" + private var menuItem: MenuItem? = null + private var fragmentPages: ArrayList = ArrayList() + private var clickTime: Long = 0 + + init { + fragmentPages.add(StatisticsPageFragment()) + fragmentPages.add(MonitorPageFragment()) + fragmentPages.add(AlarmPageFragment()) + } + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + ImmersionBar.with(this).statusBarDarkFont(false).init() + ImmerseStatusBarUtil.setColor(this, R.color.mainThemeColor.convertColor(this)) + } + + override fun initData() { + //推送,多次调用 SDK 初始化并无影响。 + PushManager.getInstance().initialize(this) + weakReferenceHandler = WeakReferenceHandler { + + true + } + } + + override fun observeRequestState() { + + } + + override fun initEvent() { + bottomNavigation.itemIconTintList = null + bottomNavigation.setOnNavigationItemSelectedListener { menuItem -> + when (menuItem.itemId) { + R.id.nav_statistics -> { + mainViewPager.currentItem = 0 + } + R.id.nav_monitor -> { + mainViewPager.currentItem = 1 + } + R.id.nav_alarm -> { + mainViewPager.currentItem = 2 + } + } + false + } + mainViewPager.adapter = ViewPagerAdapter(fragmentPages, supportFragmentManager) + mainViewPager.offscreenPageLimit = fragmentPages.size //缓存页数 + mainViewPager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener { + override fun onPageScrollStateChanged(state: Int) { + + } + + override fun onPageScrolled( + position: Int, + positionOffset: Float, + positionOffsetPixels: Int + ) { + + } + + override fun onPageSelected(position: Int) { + if (menuItem != null) { + menuItem!!.isChecked = false + } else { + bottomNavigation.menu.getItem(0).isChecked = false + } + menuItem = bottomNavigation.menu.getItem(position) + menuItem!!.isChecked = true + } + }) + } + + override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean { + return if (keyCode == KeyEvent.KEYCODE_BACK) { + if (System.currentTimeMillis() - clickTime > 2000) { + "再按一次退出程序".show(this) + clickTime = System.currentTimeMillis() + true + } else { + super.onKeyDown(keyCode, event) + } + } else super.onKeyDown(keyCode, event) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt new file mode 100644 index 0000000..c5d8b22 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.view + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseActivity + +class MonitorRecordActivity : KotlinBaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_monitor_record + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt new file mode 100644 index 0000000..c478d83 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt @@ -0,0 +1,55 @@ +package com.casic.smart.town.sanxi.view + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.amap.api.maps.MapsInitializer +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.gyf.immersionbar.ImmersionBar +import com.pengxh.kt.lite.extensions.navigatePageTo +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + ImmersionBar.with(this).statusBarDarkFont(true).init() + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (EasyPermissions.hasPermissions(this, *LocaleConstant.USER_PERMISSIONS)) { + startSplashScreenActivity() + } else { + EasyPermissions.requestPermissions( + this@PermissionActivity, + resources.getString(R.string.app_name) + "需要获取相关权限", + LocaleConstant.PERMISSIONS_CODE, + *LocaleConstant.USER_PERMISSIONS + ) + } + } + + private fun startSplashScreenActivity() { + //先把导航隐私政策声明,后面导航会用到 + MapsInitializer.updatePrivacyAgree(this, true) + MapsInitializer.updatePrivacyShow(this, true, true) + this.navigatePageTo() + 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) { + startSplashScreenActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable/alarm_selector.xml b/app/src/main/res/drawable/alarm_selector.xml new file mode 100644 index 0000000..39b2595 --- /dev/null +++ b/app/src/main/res/drawable/alarm_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bottom_text_color.xml b/app/src/main/res/drawable/bottom_text_color.xml new file mode 100644 index 0000000..b284ea3 --- /dev/null +++ b/app/src/main/res/drawable/bottom_text_color.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_alarm.xml b/app/src/main/res/drawable/ic_alarm.xml new file mode 100644 index 0000000..dc33aab --- /dev/null +++ b/app/src/main/res/drawable/ic_alarm.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_alarm_selected.xml b/app/src/main/res/drawable/ic_alarm_selected.xml new file mode 100644 index 0000000..993fea6 --- /dev/null +++ b/app/src/main/res/drawable/ic_alarm_selected.xml @@ -0,0 +1,9 @@ + + + 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_monitor.xml b/app/src/main/res/drawable/ic_monitor.xml new file mode 100644 index 0000000..271f5b4 --- /dev/null +++ b/app/src/main/res/drawable/ic_monitor.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_monitor_selected.xml b/app/src/main/res/drawable/ic_monitor_selected.xml new file mode 100644 index 0000000..ee62d84 --- /dev/null +++ b/app/src/main/res/drawable/ic_monitor_selected.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_statistics.xml b/app/src/main/res/drawable/ic_statistics.xml new file mode 100644 index 0000000..7fde8ec --- /dev/null +++ b/app/src/main/res/drawable/ic_statistics.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_statistics_selected.xml b/app/src/main/res/drawable/ic_statistics_selected.xml new file mode 100644 index 0000000..49b6fcd --- /dev/null +++ b/app/src/main/res/drawable/ic_statistics_selected.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/monitor_selector.xml b/app/src/main/res/drawable/monitor_selector.xml new file mode 100644 index 0000000..fe11e9a --- /dev/null +++ b/app/src/main/res/drawable/monitor_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/statistics_selector.xml b/app/src/main/res/drawable/statistics_selector.xml new file mode 100644 index 0000000..2156cff --- /dev/null +++ b/app/src/main/res/drawable/statistics_selector.xml @@ -0,0 +1,5 @@ + + + + + \ 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..78a4a94 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,27 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_monitor_record.xml b/app/src/main/res/layout/activity_monitor_record.xml new file mode 100644 index 0000000..77d9ef6 --- /dev/null +++ b/app/src/main/res/layout/activity_monitor_record.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_alarm.xml b/app/src/main/res/layout/fragment_alarm.xml new file mode 100644 index 0000000..77d9ef6 --- /dev/null +++ b/app/src/main/res/layout/fragment_alarm.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_monitor.xml b/app/src/main/res/layout/fragment_monitor.xml new file mode 100644 index 0000000..19789c1 --- /dev/null +++ b/app/src/main/res/layout/fragment_monitor.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_statistics.xml b/app/src/main/res/layout/fragment_statistics.xml new file mode 100644 index 0000000..77d9ef6 --- /dev/null +++ b/app/src/main/res/layout/fragment_statistics.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/menu/bottom_nav_menu.xml b/app/src/main/res/menu/bottom_nav_menu.xml new file mode 100644 index 0000000..751fd61 --- /dev/null +++ b/app/src/main/res/menu/bottom_nav_menu.xml @@ -0,0 +1,29 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.webp b/app/src/main/res/mipmap-hdpi/ic_launcher.webp new file mode 100644 index 0000000..c209e78 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp new file mode 100644 index 0000000..b2dfe3d --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.webp b/app/src/main/res/mipmap-mdpi/ic_launcher.webp new file mode 100644 index 0000000..4f0f1d6 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp new file mode 100644 index 0000000..62b611d --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher.webp new file mode 100644 index 0000000..948a307 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..1b9a695 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp Binary files differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp new file mode 100644 index 0000000..28d4b77 --- /dev/null +++ b/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..9287f50 --- /dev/null +++ b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp new file mode 100644 index 0000000..aa7d642 --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..9126ae3 --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp 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..bbce66f --- /dev/null +++ b/app/src/main/res/values/colors.xml @@ -0,0 +1,14 @@ + + + #1D55C6 + #333333 + #CCCCCC + + #FFBB86FC + #FF6200EE + #FF3700B3 + #FF03DAC5 + #FF018786 + #FF000000 + #FFFFFFFF + \ No newline at end of file diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml new file mode 100644 index 0000000..b7a9292 --- /dev/null +++ b/app/src/main/res/values/dimens.xml @@ -0,0 +1,33 @@ + + + + 12sp + 14sp + 16sp + 18sp + 20sp + 22sp + + + 3dp + 5dp + 7dp + 10dp + 15dp + 20dp + 25dp + 30dp + 35dp + 40dp + 45dp + 50dp + 55dp + 60dp + 75dp + + + 1dp + + + 45dp + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml new file mode 100644 index 0000000..f636245 --- /dev/null +++ b/app/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + SmartTown + \ No newline at end of file diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml new file mode 100644 index 0000000..635e8e0 --- /dev/null +++ b/app/src/main/res/values/themes.xml @@ -0,0 +1,16 @@ + + + + \ No newline at end of file diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..62b9d90 --- /dev/null +++ b/build.gradle @@ -0,0 +1,30 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. +buildscript { + ext.kotlin_version = '1.6.10' + repositories { + maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' } + google() + } + dependencies { + classpath 'com.android.tools.build:gradle:3.6.4' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + classpath 'org.greenrobot:greendao-gradle-plugin:3.3.0' + + // 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() + maven { url "https://mvn.getui.com/nexus/content/repositories/releases/"} + } +} + +task clean(type: Delete) { + delete rootProject.buildDir +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..98bed16 --- /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=-Xmx2048m -Dfile.encoding=UTF-8 +# 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 \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..10cfdbf --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*.iml +.gradle +/local.properties +/.idea +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..a4cd2ca --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,101 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'org.greenrobot.greendao' + +android { +// signingConfigs { +// release { +// storeFile file('/Users/a203/Desktop/AndroidProjects/CasicSmartWell/app/CasicSmartWell.jks') +// storePassword '123456789' +// keyAlias 'key0' +// keyPassword '123456789' +// } +// } + compileSdkVersion 31 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.smart.town.sanxi" + minSdkVersion 23 + targetSdkVersion 31 + versionCode 1 + versionName "1.0.0" + + manifestPlaceholders = [GETUI_APPID: "A9V4DvwLcdAqkFCQuFyhq6"] + } + + buildTypes { + release { + minifyEnabled false +// signingConfig signingConfigs.release + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + + ndk { abiFilters "armeabi", "armeabi-v7a", "arm64-v8" } + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlin { + experimental { + coroutines 'enable' + } + } + + greendao { + schemaVersion 1//数据库版本号 + targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 + daoPackage 'com.casic.smart.town.sanxi.greendao'//设置DaoMaster、DaoSession、Dao包名 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + //基础依赖库 + implementation files('libs/lite-release.aar') + implementation 'androidx.appcompat:appcompat:1.4.2' + implementation 'androidx.core:core-ktx:1.8.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:3.0.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' + //MVVM+LiveData + implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.1" + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0" + implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + //Kotlin协程 + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1' + //图片加载框架 + implementation 'com.github.bumptech.glide:glide:4.9.0' + //返回值转换器 + implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' + implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + //okhttp3日志拦截器 + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //网络请求和接口封装 + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.9.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.9.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' + //高德地图 + implementation 'com.amap.api:3dmap:latest.integration' + //推送SDK + implementation 'com.getui:gtsdk:3.2.10.0' //个推SDK + implementation 'com.getui:gtc:3.1.9.0' //个推核心组件 + //数据库框架 + implementation 'org.greenrobot:greendao:3.3.0' + //桌面角标 + implementation "me.leolin:ShortcutBadger:1.1.22@aar" +} \ No newline at end of file diff --git a/app/libs/lite-release.aar b/app/libs/lite-release.aar new file mode 100644 index 0000000..45da4df --- /dev/null +++ b/app/libs/lite-release.aar Binary files differ diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /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 \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..a83c28a --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/svg/monitor.svg b/app/src/main/assets/svg/monitor.svg new file mode 100644 index 0000000..c8d3e25 --- /dev/null +++ b/app/src/main/assets/svg/monitor.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/msg.svg b/app/src/main/assets/svg/msg.svg new file mode 100644 index 0000000..e864e48 --- /dev/null +++ b/app/src/main/assets/svg/msg.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/statistics.svg b/app/src/main/assets/svg/statistics.svg new file mode 100644 index 0000000..974000e --- /dev/null +++ b/app/src/main/assets/svg/statistics.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt new file mode 100644 index 0000000..6b9cce0 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.adapter + +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentManager +import androidx.fragment.app.FragmentPagerAdapter + +class ViewPagerAdapter(list: ArrayList, manager: FragmentManager) : + FragmentPagerAdapter(manager) { + + private var pageList: List = list + + override fun getItem(position: Int) = pageList[position] + + override fun getCount() = pageList.size +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt new file mode 100644 index 0000000..4e017b1 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt @@ -0,0 +1,40 @@ +package com.casic.smart.town.sanxi.base + +import android.app.Application +import android.util.Log +import com.casic.smart.town.sanxi.greendao.DaoMaster +import com.casic.smart.town.sanxi.greendao.DaoSession +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + private val kTag = "BaseApplication" + + companion object { + private var instance: BaseApplication by Delegates.notNull() + + fun obtainInstance() = instance + + private lateinit var daoSession: DaoSession + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences(this) + //推送 + PushManager.getInstance().initialize(this) + PushManager.getInstance().setDebugLogger(this) { + Log.d(kTag, it) + } + val devOpenHelper = DaoMaster.DevOpenHelper(this, "SmartTown.db", null) + val daoMaster = DaoMaster(devOpenHelper.writableDatabase) + daoSession = daoMaster.newSession() + } + + fun obtainDaoSession(): DaoSession { + return daoSession + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java new file mode 100644 index 0000000..b8f67dc --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java @@ -0,0 +1,133 @@ +package com.casic.smart.town.sanxi.bean; + +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Generated; +import org.greenrobot.greendao.annotation.Id; +import org.greenrobot.greendao.annotation.Unique; + +@Entity +public class AlarmMessageLocaleBean { + @Id(autoincrement = true) + private Long id;//主键自增 + + @Unique + private String messageId; + private String appId; + private String clientId; + private String taskId; + private String userId; + private String title; + private String content; + private String deviceCode; + private String isRead;//0-未读,1-已读 + private String alarmTime; + + @Generated(hash = 566950134) + public AlarmMessageLocaleBean(Long id, String messageId, String appId, + String clientId, String taskId, String userId, String title, + String content, String deviceCode, String isRead, String alarmTime) { + this.id = id; + this.messageId = messageId; + this.appId = appId; + this.clientId = clientId; + this.taskId = taskId; + this.userId = userId; + this.title = title; + this.content = content; + this.deviceCode = deviceCode; + this.isRead = isRead; + this.alarmTime = alarmTime; + } + + @Generated(hash = 1737519562) + public AlarmMessageLocaleBean() { + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getMessageId() { + return this.messageId; + } + + public void setMessageId(String messageId) { + this.messageId = messageId; + } + + public String getAppId() { + return this.appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public String getClientId() { + return this.clientId; + } + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public String getTaskId() { + return this.taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getUserId() { + return this.userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getTitle() { + return this.title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return this.content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getDeviceCode() { + return this.deviceCode; + } + + public void setDeviceCode(String deviceCode) { + this.deviceCode = deviceCode; + } + + public String getIsRead() { + return this.isRead; + } + + public void setIsRead(String isRead) { + this.isRead = isRead; + } + + public String getAlarmTime() { + return this.alarmTime; + } + + public void setAlarmTime(String alarmTime) { + this.alarmTime = alarmTime; + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt new file mode 100644 index 0000000..650e201 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class AlarmPageFragment: KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_alarm + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt new file mode 100644 index 0000000..deac8ac --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt @@ -0,0 +1,76 @@ +package com.casic.smart.town.sanxi.fragment + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.Fragment +import com.amap.api.maps.AMap +import com.amap.api.maps.AMapOptions +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.view.MonitorRecordActivity +import com.pengxh.kt.lite.extensions.navigatePageTo +import com.pengxh.kt.lite.extensions.show +import kotlinx.android.synthetic.main.fragment_monitor.view.* + +class MonitorPageFragment : Fragment() { + + private val kTag = "HomePageFragment" + private lateinit var monitorView: View + private lateinit var aMap: AMap + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? + ): View { + monitorView = inflater.inflate(R.layout.fragment_monitor, container, false) + //地图初始化 + initMap(savedInstanceState) + + monitorView.rightOperateView.setOnClickListener { + requireContext().navigatePageTo() + } + return monitorView + } + + private fun initMap(savedInstanceState: Bundle?) { + monitorView.mapView.onCreate(savedInstanceState) + aMap = monitorView.mapView.map + aMap.mapType = AMap.MAP_TYPE_NORMAL + val uiSettings = aMap.uiSettings + uiSettings.isCompassEnabled = true + uiSettings.zoomPosition = AMapOptions.ZOOM_POSITION_RIGHT_CENTER + uiSettings.isTiltGesturesEnabled = false//不许地图随手势倾斜角度 + + // 地图加载成功监听 +// aMap.addOnMapLoadedListener(this) + // 地图缩放监听 +// aMap.addOnCameraChangeListener(this) + // marker 点击事件监听 +// aMap.addOnMarkerClickListener(this) + // 点击marker弹出自定义popup +// aMap.setInfoWindowAdapter(this) + //信息窗点击事件 +// aMap.addOnInfoWindowClickListener(this) + } + + /***以下是地图生命周期管理************************************************************************/ + override fun onResume() { + super.onResume() + monitorView.mapView.onResume() + } + + override fun onPause() { + super.onPause() + monitorView.mapView.onPause() + } + + override fun onSaveInstanceState(outState: Bundle) { + super.onSaveInstanceState(outState) + monitorView.mapView.onSaveInstanceState(outState) + } + + override fun onDestroy() { + super.onDestroy() + monitorView.mapView.onDestroy() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt new file mode 100644 index 0000000..e84df12 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class StatisticsPageFragment : KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_statistics + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java new file mode 100644 index 0000000..68d7901 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java @@ -0,0 +1,255 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.database.Cursor; +import android.database.sqlite.SQLiteStatement; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.Property; +import org.greenrobot.greendao.internal.DaoConfig; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseStatement; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * DAO for table "ALARM_MESSAGE_LOCALE_BEAN". +*/ +public class AlarmMessageLocaleBeanDao extends AbstractDao { + + public static final String TABLENAME = "ALARM_MESSAGE_LOCALE_BEAN"; + + /** + * Properties of entity AlarmMessageLocaleBean.
+ * Can be used for QueryBuilder and for referencing column names. + */ + public static class Properties { + public final static Property Id = new Property(0, Long.class, "id", true, "_id"); + public final static Property MessageId = new Property(1, String.class, "messageId", false, "MESSAGE_ID"); + public final static Property AppId = new Property(2, String.class, "appId", false, "APP_ID"); + public final static Property ClientId = new Property(3, String.class, "clientId", false, "CLIENT_ID"); + public final static Property TaskId = new Property(4, String.class, "taskId", false, "TASK_ID"); + public final static Property UserId = new Property(5, String.class, "userId", false, "USER_ID"); + public final static Property Title = new Property(6, String.class, "title", false, "TITLE"); + public final static Property Content = new Property(7, String.class, "content", false, "CONTENT"); + public final static Property DeviceCode = new Property(8, String.class, "deviceCode", false, "DEVICE_CODE"); + public final static Property IsRead = new Property(9, String.class, "isRead", false, "IS_READ"); + public final static Property AlarmTime = new Property(10, String.class, "alarmTime", false, "ALARM_TIME"); + } + + + public AlarmMessageLocaleBeanDao(DaoConfig config) { + super(config); + } + + public AlarmMessageLocaleBeanDao(DaoConfig config, DaoSession daoSession) { + super(config, daoSession); + } + + /** Creates the underlying database table. */ + public static void createTable(Database db, boolean ifNotExists) { + String constraint = ifNotExists? "IF NOT EXISTS ": ""; + db.execSQL("CREATE TABLE " + constraint + "\"ALARM_MESSAGE_LOCALE_BEAN\" (" + // + "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id + "\"MESSAGE_ID\" TEXT UNIQUE ," + // 1: messageId + "\"APP_ID\" TEXT," + // 2: appId + "\"CLIENT_ID\" TEXT," + // 3: clientId + "\"TASK_ID\" TEXT," + // 4: taskId + "\"USER_ID\" TEXT," + // 5: userId + "\"TITLE\" TEXT," + // 6: title + "\"CONTENT\" TEXT," + // 7: content + "\"DEVICE_CODE\" TEXT," + // 8: deviceCode + "\"IS_READ\" TEXT," + // 9: isRead + "\"ALARM_TIME\" TEXT);"); // 10: alarmTime + } + + /** Drops the underlying database table. */ + public static void dropTable(Database db, boolean ifExists) { + String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"ALARM_MESSAGE_LOCALE_BEAN\""; + db.execSQL(sql); + } + + @Override + protected final void bindValues(DatabaseStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + protected final void bindValues(SQLiteStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + public Long readKey(Cursor cursor, int offset) { + return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); + } + + @Override + public AlarmMessageLocaleBean readEntity(Cursor cursor, int offset) { + AlarmMessageLocaleBean entity = new AlarmMessageLocaleBean( // + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // messageId + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // appId + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // clientId + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // taskId + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // userId + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // title + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // content + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // deviceCode + cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // isRead + cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10) // alarmTime + ); + return entity; + } + + @Override + public void readEntity(Cursor cursor, AlarmMessageLocaleBean entity, int offset) { + entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); + entity.setMessageId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setAppId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setClientId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setTaskId(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); + entity.setUserId(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setTitle(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setContent(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); + entity.setDeviceCode(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); + entity.setIsRead(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9)); + entity.setAlarmTime(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); + } + + @Override + protected final Long updateKeyAfterInsert(AlarmMessageLocaleBean entity, long rowId) { + entity.setId(rowId); + return rowId; + } + + @Override + public Long getKey(AlarmMessageLocaleBean entity) { + if(entity != null) { + return entity.getId(); + } else { + return null; + } + } + + @Override + public boolean hasKey(AlarmMessageLocaleBean entity) { + return entity.getId() != null; + } + + @Override + protected final boolean isEntityUpdateable() { + return true; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java new file mode 100644 index 0000000..4222c40 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java @@ -0,0 +1,96 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.content.Context; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteDatabase.CursorFactory; +import android.util.Log; + +import org.greenrobot.greendao.AbstractDaoMaster; +import org.greenrobot.greendao.database.StandardDatabase; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseOpenHelper; +import org.greenrobot.greendao.identityscope.IdentityScopeType; + + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * Master of DAO (schema version 1): knows all DAOs. + */ +public class DaoMaster extends AbstractDaoMaster { + public static final int SCHEMA_VERSION = 1; + + /** Creates underlying database table using DAOs. */ + public static void createAllTables(Database db, boolean ifNotExists) { + AlarmMessageLocaleBeanDao.createTable(db, ifNotExists); + } + + /** Drops underlying database table using DAOs. */ + public static void dropAllTables(Database db, boolean ifExists) { + AlarmMessageLocaleBeanDao.dropTable(db, ifExists); + } + + /** + * WARNING: Drops all table on Upgrade! Use only during development. + * Convenience method using a {@link DevOpenHelper}. + */ + public static DaoSession newDevSession(Context context, String name) { + Database db = new DevOpenHelper(context, name).getWritableDb(); + DaoMaster daoMaster = new DaoMaster(db); + return daoMaster.newSession(); + } + + public DaoMaster(SQLiteDatabase db) { + this(new StandardDatabase(db)); + } + + public DaoMaster(Database db) { + super(db, SCHEMA_VERSION); + registerDaoClass(AlarmMessageLocaleBeanDao.class); + } + + public DaoSession newSession() { + return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); + } + + public DaoSession newSession(IdentityScopeType type) { + return new DaoSession(db, type, daoConfigMap); + } + + /** + * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} - + */ + public static abstract class OpenHelper extends DatabaseOpenHelper { + public OpenHelper(Context context, String name) { + super(context, name, SCHEMA_VERSION); + } + + public OpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory, SCHEMA_VERSION); + } + + @Override + public void onCreate(Database db) { + Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); + createAllTables(db, false); + } + } + + /** WARNING: Drops all table on Upgrade! Use only during development. */ + public static class DevOpenHelper extends OpenHelper { + public DevOpenHelper(Context context, String name) { + super(context, name); + } + + public DevOpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory); + } + + @Override + public void onUpgrade(Database db, int oldVersion, int newVersion) { + Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); + dropAllTables(db, true); + onCreate(db); + } + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java new file mode 100644 index 0000000..480ed84 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java @@ -0,0 +1,48 @@ +package com.casic.smart.town.sanxi.greendao; + +import java.util.Map; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.AbstractDaoSession; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.identityscope.IdentityScopeType; +import org.greenrobot.greendao.internal.DaoConfig; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. + +/** + * {@inheritDoc} + * + * @see org.greenrobot.greendao.AbstractDaoSession + */ +public class DaoSession extends AbstractDaoSession { + + private final DaoConfig alarmMessageLocaleBeanDaoConfig; + + private final AlarmMessageLocaleBeanDao alarmMessageLocaleBeanDao; + + public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> + daoConfigMap) { + super(db); + + alarmMessageLocaleBeanDaoConfig = daoConfigMap.get(AlarmMessageLocaleBeanDao.class).clone(); + alarmMessageLocaleBeanDaoConfig.initIdentityScope(type); + + alarmMessageLocaleBeanDao = new AlarmMessageLocaleBeanDao(alarmMessageLocaleBeanDaoConfig, this); + + registerDao(AlarmMessageLocaleBean.class, alarmMessageLocaleBeanDao); + } + + public void clear() { + alarmMessageLocaleBeanDaoConfig.clearIdentityScope(); + } + + public AlarmMessageLocaleBeanDao getAlarmMessageLocaleBeanDao() { + return alarmMessageLocaleBeanDao; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt new file mode 100644 index 0000000..875cb8c --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt @@ -0,0 +1,5 @@ +package com.casic.smart.town.sanxi.service + +import com.igexin.sdk.PushService + +class ApplicationPushService : PushService() \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt new file mode 100644 index 0000000..396129f --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt @@ -0,0 +1,84 @@ +package com.casic.smart.town.sanxi.service + +import android.content.Context +import android.os.Message +import android.util.Log +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.casic.smart.town.sanxi.view.MainActivity +import com.igexin.sdk.GTIntentService +import com.igexin.sdk.message.GTCmdMessage +import com.igexin.sdk.message.GTNotificationMessage +import com.igexin.sdk.message.GTTransmitMessage +import com.pengxh.kt.lite.extensions.toJson + +class PushIntentService : GTIntentService() { + + private val kTag = "SmartWellIntentService" + + override fun onReceiveServicePid(context: Context?, pid: Int) { + + } + + // 透传消息 + override fun onReceiveMessageData(context: Context?, msg: GTTransmitMessage?) { + Log.d(kTag, "透传消息 -> msg = $msg") + } + + // 接收 cid + override fun onReceiveClientId(context: Context?, clientid: String?) { + Log.d(kTag, "onReceiveClientId -> $clientid") + //通知MainActivity注册个推服务 + val msg: Message = MainActivity.weakReferenceHandler.obtainMessage() + msg.what = LocaleConstant.PUSH_REGISTER + msg.obj = clientid + MainActivity.weakReferenceHandler.sendMessage(msg) + } + + // cid 离线上线通知 + override fun onReceiveOnlineState(context: Context?, online: Boolean) { + + } + + // 各种事件处理回执 + override fun onReceiveCommandResult(context: Context?, msg: GTCmdMessage?) { + + } + + // 通知到达 + override fun onNotificationMessageArrived(context: Context?, msg: GTNotificationMessage?) { + //报警 +// { +// "content": "设备编号[412022030361]发生井盖开盖报警", +// "messageId": "380abf9a79d34306a2683dc9bf96ee78", +// "taskId": "OSL-0830_4hmfimp3Vu684wo3SjXso9", +// "title": "告警提醒", +// "appid": "HKv8K9qARd6WckZ1o2Vbu4", +// "clientId": "e78beacc42e9a02ae6fb9087eb2b1171", +// "pkgName": "com.casic.app.smartwell" +// } + if (msg == null) { + return + } + Log.d(kTag, "通知到达 -> msg = ${msg.toJson()}") +// val userDetailJson = SaveKeyValues.getValue(LocaleConstant.USER_DETAIL_MODEL, "") as String +// var userId = "" +// if (userDetailJson.isNotBlank()) { +// val userDataModel = Gson().fromJson( +// userDetailJson, object : TypeToken() {}.type +// ) +// userId = userDataModel.id.toString() +// } +// //解析编号 +// val splitArray = msg.content.split("\\[|\\]".toRegex()) +// DataBaseManager.instance.insertNotice( +// msg.messageId, msg.appid, msg.clientId, msg.taskId, +// userId, msg.title, msg.content, splitArray[1], "0", +// System.currentTimeMillis().timestampToCompleteDate() +// ) + } + + // 通知点击 + override fun onNotificationMessageClicked(context: Context?, msg: GTNotificationMessage?) { + Log.d(kTag, "通知点击 -> msg = $msg") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt new file mode 100644 index 0000000..daa7c38 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt @@ -0,0 +1,14 @@ +package com.casic.smart.town.sanxi.util + +import android.content.Context +import me.leolin.shortcutbadger.ShortcutBadger + +object BadeHelper { + fun setBadgeNum(context: Context, badgeCount: Int) { + if (badgeCount == 0) { + ShortcutBadger.removeCount(context) + } else { + ShortcutBadger.applyCount(context, badgeCount) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt new file mode 100644 index 0000000..0a52ef2 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt @@ -0,0 +1,75 @@ +package com.casic.smart.town.sanxi.util + +import com.casic.smart.town.sanxi.base.BaseApplication +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao + +class DataBaseManager private constructor() { + + companion object { + //Kotlin委托模式双重锁单例 + val instance: DataBaseManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) { + DataBaseManager() + } + } + + private val beanDao = + BaseApplication.obtainInstance().obtainDaoSession().alarmMessageLocaleBeanDao + +// fun insertNotice( +// messageId: String, appid: String, clientId: String, +// taskId: String, userId: String, title: String, +// content: String, deviceCode: String, isRead: String, +// noticeTime: String +// ) { +// val noticeLocaleBean = NoticeLocaleBean() +// noticeLocaleBean.messageId = messageId +// noticeLocaleBean.appid = appid +// noticeLocaleBean.clientId = clientId +// noticeLocaleBean.taskId = taskId +// noticeLocaleBean.userId = userId +// noticeLocaleBean.title = title +// noticeLocaleBean.content = content +// noticeLocaleBean.deviceCode = deviceCode +// noticeLocaleBean.isRead = isRead +// noticeLocaleBean.noticeTime = noticeTime +// beanDao.insert(noticeLocaleBean) +// //角标设置 +// BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadNotice()) +// } + + fun deleteByMessageId(messageId: String) { + val result = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).list() + beanDao.deleteInTx(result) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun updateNoticeByMessageId(messageId: String) { + val noticeLocaleBean = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).unique() ?: return + noticeLocaleBean.isRead = "1" + beanDao.update(noticeLocaleBean) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun queryMessageByPage(userId: String, offset: Int): MutableList { + return BaseApplication.obtainInstance().obtainDaoSession() + .queryBuilder(AlarmMessageLocaleBean::class.java) + .where(AlarmMessageLocaleBeanDao.Properties.UserId.eq(userId)) + .offset(offset * LocaleConstant.PAGE_LIMIT) + .orderDesc(AlarmMessageLocaleBeanDao.Properties.AlarmTime) + .limit(LocaleConstant.PAGE_LIMIT) + .list() + } + + private fun queryUnReadMessage(): Int { + return beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.IsRead.eq("0") + ).list().size + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt new file mode 100644 index 0000000..52926a8 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt @@ -0,0 +1,31 @@ +package com.casic.smart.town.sanxi.util; + +import android.app.Activity +import android.view.WindowManager +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object LoadingDialogHub { + private lateinit var loadingDialog: QMUITipDialog + + fun show(activity: Activity, message: String) { + loadingDialog = QMUITipDialog + .Builder(activity) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_LOADING) + .setTipWord(message) + .create() + if (!activity.isDestroyed) { + try { + loadingDialog.show() + } catch (e: WindowManager.BadTokenException) { + e.printStackTrace() + } + } + } + + + fun dismiss() { + if (loadingDialog.isShowing) { + loadingDialog.dismiss() + } + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt new file mode 100644 index 0000000..de61c9a --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.util + +import android.Manifest + +object LocaleConstant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.READ_PHONE_STATE, + Manifest.permission.ACCESS_COARSE_LOCATION, + Manifest.permission.READ_EXTERNAL_STORAGE + ) + + const val PERMISSIONS_CODE = 999 + const val PUSH_REGISTER = 2022100101 + const val PAGE_LIMIT = 20 +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt new file mode 100644 index 0000000..3bea1c9 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt @@ -0,0 +1,112 @@ +package com.casic.smart.town.sanxi.view + +import android.view.KeyEvent +import android.view.MenuItem +import androidx.fragment.app.Fragment +import androidx.viewpager.widget.ViewPager +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.adapter.ViewPagerAdapter +import com.casic.smart.town.sanxi.fragment.AlarmPageFragment +import com.casic.smart.town.sanxi.fragment.MonitorPageFragment +import com.casic.smart.town.sanxi.fragment.StatisticsPageFragment +import com.gyf.immersionbar.ImmersionBar +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.base.KotlinBaseActivity +import com.pengxh.kt.lite.extensions.convertColor +import com.pengxh.kt.lite.extensions.show +import com.pengxh.kt.lite.utils.ImmerseStatusBarUtil +import com.pengxh.kt.lite.utils.WeakReferenceHandler +import kotlinx.android.synthetic.main.activity_main.* + +class MainActivity : KotlinBaseActivity() { + + companion object { + lateinit var weakReferenceHandler: WeakReferenceHandler + } + + private val kTag = "MainActivity" + private var menuItem: MenuItem? = null + private var fragmentPages: ArrayList = ArrayList() + private var clickTime: Long = 0 + + init { + fragmentPages.add(StatisticsPageFragment()) + fragmentPages.add(MonitorPageFragment()) + fragmentPages.add(AlarmPageFragment()) + } + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + ImmersionBar.with(this).statusBarDarkFont(false).init() + ImmerseStatusBarUtil.setColor(this, R.color.mainThemeColor.convertColor(this)) + } + + override fun initData() { + //推送,多次调用 SDK 初始化并无影响。 + PushManager.getInstance().initialize(this) + weakReferenceHandler = WeakReferenceHandler { + + true + } + } + + override fun observeRequestState() { + + } + + override fun initEvent() { + bottomNavigation.itemIconTintList = null + bottomNavigation.setOnNavigationItemSelectedListener { menuItem -> + when (menuItem.itemId) { + R.id.nav_statistics -> { + mainViewPager.currentItem = 0 + } + R.id.nav_monitor -> { + mainViewPager.currentItem = 1 + } + R.id.nav_alarm -> { + mainViewPager.currentItem = 2 + } + } + false + } + mainViewPager.adapter = ViewPagerAdapter(fragmentPages, supportFragmentManager) + mainViewPager.offscreenPageLimit = fragmentPages.size //缓存页数 + mainViewPager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener { + override fun onPageScrollStateChanged(state: Int) { + + } + + override fun onPageScrolled( + position: Int, + positionOffset: Float, + positionOffsetPixels: Int + ) { + + } + + override fun onPageSelected(position: Int) { + if (menuItem != null) { + menuItem!!.isChecked = false + } else { + bottomNavigation.menu.getItem(0).isChecked = false + } + menuItem = bottomNavigation.menu.getItem(position) + menuItem!!.isChecked = true + } + }) + } + + override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean { + return if (keyCode == KeyEvent.KEYCODE_BACK) { + if (System.currentTimeMillis() - clickTime > 2000) { + "再按一次退出程序".show(this) + clickTime = System.currentTimeMillis() + true + } else { + super.onKeyDown(keyCode, event) + } + } else super.onKeyDown(keyCode, event) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt new file mode 100644 index 0000000..c5d8b22 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.view + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseActivity + +class MonitorRecordActivity : KotlinBaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_monitor_record + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt new file mode 100644 index 0000000..c478d83 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt @@ -0,0 +1,55 @@ +package com.casic.smart.town.sanxi.view + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.amap.api.maps.MapsInitializer +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.gyf.immersionbar.ImmersionBar +import com.pengxh.kt.lite.extensions.navigatePageTo +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + ImmersionBar.with(this).statusBarDarkFont(true).init() + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (EasyPermissions.hasPermissions(this, *LocaleConstant.USER_PERMISSIONS)) { + startSplashScreenActivity() + } else { + EasyPermissions.requestPermissions( + this@PermissionActivity, + resources.getString(R.string.app_name) + "需要获取相关权限", + LocaleConstant.PERMISSIONS_CODE, + *LocaleConstant.USER_PERMISSIONS + ) + } + } + + private fun startSplashScreenActivity() { + //先把导航隐私政策声明,后面导航会用到 + MapsInitializer.updatePrivacyAgree(this, true) + MapsInitializer.updatePrivacyShow(this, true, true) + this.navigatePageTo() + 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) { + startSplashScreenActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable/alarm_selector.xml b/app/src/main/res/drawable/alarm_selector.xml new file mode 100644 index 0000000..39b2595 --- /dev/null +++ b/app/src/main/res/drawable/alarm_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bottom_text_color.xml b/app/src/main/res/drawable/bottom_text_color.xml new file mode 100644 index 0000000..b284ea3 --- /dev/null +++ b/app/src/main/res/drawable/bottom_text_color.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_alarm.xml b/app/src/main/res/drawable/ic_alarm.xml new file mode 100644 index 0000000..dc33aab --- /dev/null +++ b/app/src/main/res/drawable/ic_alarm.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_alarm_selected.xml b/app/src/main/res/drawable/ic_alarm_selected.xml new file mode 100644 index 0000000..993fea6 --- /dev/null +++ b/app/src/main/res/drawable/ic_alarm_selected.xml @@ -0,0 +1,9 @@ + + + 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_monitor.xml b/app/src/main/res/drawable/ic_monitor.xml new file mode 100644 index 0000000..271f5b4 --- /dev/null +++ b/app/src/main/res/drawable/ic_monitor.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_monitor_selected.xml b/app/src/main/res/drawable/ic_monitor_selected.xml new file mode 100644 index 0000000..ee62d84 --- /dev/null +++ b/app/src/main/res/drawable/ic_monitor_selected.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_statistics.xml b/app/src/main/res/drawable/ic_statistics.xml new file mode 100644 index 0000000..7fde8ec --- /dev/null +++ b/app/src/main/res/drawable/ic_statistics.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_statistics_selected.xml b/app/src/main/res/drawable/ic_statistics_selected.xml new file mode 100644 index 0000000..49b6fcd --- /dev/null +++ b/app/src/main/res/drawable/ic_statistics_selected.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/monitor_selector.xml b/app/src/main/res/drawable/monitor_selector.xml new file mode 100644 index 0000000..fe11e9a --- /dev/null +++ b/app/src/main/res/drawable/monitor_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/statistics_selector.xml b/app/src/main/res/drawable/statistics_selector.xml new file mode 100644 index 0000000..2156cff --- /dev/null +++ b/app/src/main/res/drawable/statistics_selector.xml @@ -0,0 +1,5 @@ + + + + + \ 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..78a4a94 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,27 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_monitor_record.xml b/app/src/main/res/layout/activity_monitor_record.xml new file mode 100644 index 0000000..77d9ef6 --- /dev/null +++ b/app/src/main/res/layout/activity_monitor_record.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_alarm.xml b/app/src/main/res/layout/fragment_alarm.xml new file mode 100644 index 0000000..77d9ef6 --- /dev/null +++ b/app/src/main/res/layout/fragment_alarm.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_monitor.xml b/app/src/main/res/layout/fragment_monitor.xml new file mode 100644 index 0000000..19789c1 --- /dev/null +++ b/app/src/main/res/layout/fragment_monitor.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_statistics.xml b/app/src/main/res/layout/fragment_statistics.xml new file mode 100644 index 0000000..77d9ef6 --- /dev/null +++ b/app/src/main/res/layout/fragment_statistics.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/menu/bottom_nav_menu.xml b/app/src/main/res/menu/bottom_nav_menu.xml new file mode 100644 index 0000000..751fd61 --- /dev/null +++ b/app/src/main/res/menu/bottom_nav_menu.xml @@ -0,0 +1,29 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.webp b/app/src/main/res/mipmap-hdpi/ic_launcher.webp new file mode 100644 index 0000000..c209e78 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp new file mode 100644 index 0000000..b2dfe3d --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.webp b/app/src/main/res/mipmap-mdpi/ic_launcher.webp new file mode 100644 index 0000000..4f0f1d6 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp new file mode 100644 index 0000000..62b611d --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher.webp new file mode 100644 index 0000000..948a307 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..1b9a695 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp Binary files differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp new file mode 100644 index 0000000..28d4b77 --- /dev/null +++ b/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..9287f50 --- /dev/null +++ b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp new file mode 100644 index 0000000..aa7d642 --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..9126ae3 --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp 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..bbce66f --- /dev/null +++ b/app/src/main/res/values/colors.xml @@ -0,0 +1,14 @@ + + + #1D55C6 + #333333 + #CCCCCC + + #FFBB86FC + #FF6200EE + #FF3700B3 + #FF03DAC5 + #FF018786 + #FF000000 + #FFFFFFFF + \ No newline at end of file diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml new file mode 100644 index 0000000..b7a9292 --- /dev/null +++ b/app/src/main/res/values/dimens.xml @@ -0,0 +1,33 @@ + + + + 12sp + 14sp + 16sp + 18sp + 20sp + 22sp + + + 3dp + 5dp + 7dp + 10dp + 15dp + 20dp + 25dp + 30dp + 35dp + 40dp + 45dp + 50dp + 55dp + 60dp + 75dp + + + 1dp + + + 45dp + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml new file mode 100644 index 0000000..f636245 --- /dev/null +++ b/app/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + SmartTown + \ No newline at end of file diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml new file mode 100644 index 0000000..635e8e0 --- /dev/null +++ b/app/src/main/res/values/themes.xml @@ -0,0 +1,16 @@ + + + + \ No newline at end of file diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..62b9d90 --- /dev/null +++ b/build.gradle @@ -0,0 +1,30 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. +buildscript { + ext.kotlin_version = '1.6.10' + repositories { + maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' } + google() + } + dependencies { + classpath 'com.android.tools.build:gradle:3.6.4' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + classpath 'org.greenrobot:greendao-gradle-plugin:3.3.0' + + // 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() + maven { url "https://mvn.getui.com/nexus/content/repositories/releases/"} + } +} + +task clean(type: Delete) { + delete rootProject.buildDir +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..98bed16 --- /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=-Xmx2048m -Dfile.encoding=UTF-8 +# 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 \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..e708b1c --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.jar Binary files differ diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..10cfdbf --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*.iml +.gradle +/local.properties +/.idea +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..a4cd2ca --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,101 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'org.greenrobot.greendao' + +android { +// signingConfigs { +// release { +// storeFile file('/Users/a203/Desktop/AndroidProjects/CasicSmartWell/app/CasicSmartWell.jks') +// storePassword '123456789' +// keyAlias 'key0' +// keyPassword '123456789' +// } +// } + compileSdkVersion 31 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.smart.town.sanxi" + minSdkVersion 23 + targetSdkVersion 31 + versionCode 1 + versionName "1.0.0" + + manifestPlaceholders = [GETUI_APPID: "A9V4DvwLcdAqkFCQuFyhq6"] + } + + buildTypes { + release { + minifyEnabled false +// signingConfig signingConfigs.release + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + + ndk { abiFilters "armeabi", "armeabi-v7a", "arm64-v8" } + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlin { + experimental { + coroutines 'enable' + } + } + + greendao { + schemaVersion 1//数据库版本号 + targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 + daoPackage 'com.casic.smart.town.sanxi.greendao'//设置DaoMaster、DaoSession、Dao包名 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + //基础依赖库 + implementation files('libs/lite-release.aar') + implementation 'androidx.appcompat:appcompat:1.4.2' + implementation 'androidx.core:core-ktx:1.8.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:3.0.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' + //MVVM+LiveData + implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.1" + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0" + implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + //Kotlin协程 + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1' + //图片加载框架 + implementation 'com.github.bumptech.glide:glide:4.9.0' + //返回值转换器 + implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' + implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + //okhttp3日志拦截器 + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //网络请求和接口封装 + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.9.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.9.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' + //高德地图 + implementation 'com.amap.api:3dmap:latest.integration' + //推送SDK + implementation 'com.getui:gtsdk:3.2.10.0' //个推SDK + implementation 'com.getui:gtc:3.1.9.0' //个推核心组件 + //数据库框架 + implementation 'org.greenrobot:greendao:3.3.0' + //桌面角标 + implementation "me.leolin:ShortcutBadger:1.1.22@aar" +} \ No newline at end of file diff --git a/app/libs/lite-release.aar b/app/libs/lite-release.aar new file mode 100644 index 0000000..45da4df --- /dev/null +++ b/app/libs/lite-release.aar Binary files differ diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /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 \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..a83c28a --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/svg/monitor.svg b/app/src/main/assets/svg/monitor.svg new file mode 100644 index 0000000..c8d3e25 --- /dev/null +++ b/app/src/main/assets/svg/monitor.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/msg.svg b/app/src/main/assets/svg/msg.svg new file mode 100644 index 0000000..e864e48 --- /dev/null +++ b/app/src/main/assets/svg/msg.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/statistics.svg b/app/src/main/assets/svg/statistics.svg new file mode 100644 index 0000000..974000e --- /dev/null +++ b/app/src/main/assets/svg/statistics.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt new file mode 100644 index 0000000..6b9cce0 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.adapter + +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentManager +import androidx.fragment.app.FragmentPagerAdapter + +class ViewPagerAdapter(list: ArrayList, manager: FragmentManager) : + FragmentPagerAdapter(manager) { + + private var pageList: List = list + + override fun getItem(position: Int) = pageList[position] + + override fun getCount() = pageList.size +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt new file mode 100644 index 0000000..4e017b1 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt @@ -0,0 +1,40 @@ +package com.casic.smart.town.sanxi.base + +import android.app.Application +import android.util.Log +import com.casic.smart.town.sanxi.greendao.DaoMaster +import com.casic.smart.town.sanxi.greendao.DaoSession +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + private val kTag = "BaseApplication" + + companion object { + private var instance: BaseApplication by Delegates.notNull() + + fun obtainInstance() = instance + + private lateinit var daoSession: DaoSession + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences(this) + //推送 + PushManager.getInstance().initialize(this) + PushManager.getInstance().setDebugLogger(this) { + Log.d(kTag, it) + } + val devOpenHelper = DaoMaster.DevOpenHelper(this, "SmartTown.db", null) + val daoMaster = DaoMaster(devOpenHelper.writableDatabase) + daoSession = daoMaster.newSession() + } + + fun obtainDaoSession(): DaoSession { + return daoSession + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java new file mode 100644 index 0000000..b8f67dc --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java @@ -0,0 +1,133 @@ +package com.casic.smart.town.sanxi.bean; + +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Generated; +import org.greenrobot.greendao.annotation.Id; +import org.greenrobot.greendao.annotation.Unique; + +@Entity +public class AlarmMessageLocaleBean { + @Id(autoincrement = true) + private Long id;//主键自增 + + @Unique + private String messageId; + private String appId; + private String clientId; + private String taskId; + private String userId; + private String title; + private String content; + private String deviceCode; + private String isRead;//0-未读,1-已读 + private String alarmTime; + + @Generated(hash = 566950134) + public AlarmMessageLocaleBean(Long id, String messageId, String appId, + String clientId, String taskId, String userId, String title, + String content, String deviceCode, String isRead, String alarmTime) { + this.id = id; + this.messageId = messageId; + this.appId = appId; + this.clientId = clientId; + this.taskId = taskId; + this.userId = userId; + this.title = title; + this.content = content; + this.deviceCode = deviceCode; + this.isRead = isRead; + this.alarmTime = alarmTime; + } + + @Generated(hash = 1737519562) + public AlarmMessageLocaleBean() { + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getMessageId() { + return this.messageId; + } + + public void setMessageId(String messageId) { + this.messageId = messageId; + } + + public String getAppId() { + return this.appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public String getClientId() { + return this.clientId; + } + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public String getTaskId() { + return this.taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getUserId() { + return this.userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getTitle() { + return this.title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return this.content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getDeviceCode() { + return this.deviceCode; + } + + public void setDeviceCode(String deviceCode) { + this.deviceCode = deviceCode; + } + + public String getIsRead() { + return this.isRead; + } + + public void setIsRead(String isRead) { + this.isRead = isRead; + } + + public String getAlarmTime() { + return this.alarmTime; + } + + public void setAlarmTime(String alarmTime) { + this.alarmTime = alarmTime; + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt new file mode 100644 index 0000000..650e201 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class AlarmPageFragment: KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_alarm + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt new file mode 100644 index 0000000..deac8ac --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt @@ -0,0 +1,76 @@ +package com.casic.smart.town.sanxi.fragment + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.Fragment +import com.amap.api.maps.AMap +import com.amap.api.maps.AMapOptions +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.view.MonitorRecordActivity +import com.pengxh.kt.lite.extensions.navigatePageTo +import com.pengxh.kt.lite.extensions.show +import kotlinx.android.synthetic.main.fragment_monitor.view.* + +class MonitorPageFragment : Fragment() { + + private val kTag = "HomePageFragment" + private lateinit var monitorView: View + private lateinit var aMap: AMap + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? + ): View { + monitorView = inflater.inflate(R.layout.fragment_monitor, container, false) + //地图初始化 + initMap(savedInstanceState) + + monitorView.rightOperateView.setOnClickListener { + requireContext().navigatePageTo() + } + return monitorView + } + + private fun initMap(savedInstanceState: Bundle?) { + monitorView.mapView.onCreate(savedInstanceState) + aMap = monitorView.mapView.map + aMap.mapType = AMap.MAP_TYPE_NORMAL + val uiSettings = aMap.uiSettings + uiSettings.isCompassEnabled = true + uiSettings.zoomPosition = AMapOptions.ZOOM_POSITION_RIGHT_CENTER + uiSettings.isTiltGesturesEnabled = false//不许地图随手势倾斜角度 + + // 地图加载成功监听 +// aMap.addOnMapLoadedListener(this) + // 地图缩放监听 +// aMap.addOnCameraChangeListener(this) + // marker 点击事件监听 +// aMap.addOnMarkerClickListener(this) + // 点击marker弹出自定义popup +// aMap.setInfoWindowAdapter(this) + //信息窗点击事件 +// aMap.addOnInfoWindowClickListener(this) + } + + /***以下是地图生命周期管理************************************************************************/ + override fun onResume() { + super.onResume() + monitorView.mapView.onResume() + } + + override fun onPause() { + super.onPause() + monitorView.mapView.onPause() + } + + override fun onSaveInstanceState(outState: Bundle) { + super.onSaveInstanceState(outState) + monitorView.mapView.onSaveInstanceState(outState) + } + + override fun onDestroy() { + super.onDestroy() + monitorView.mapView.onDestroy() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt new file mode 100644 index 0000000..e84df12 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class StatisticsPageFragment : KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_statistics + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java new file mode 100644 index 0000000..68d7901 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java @@ -0,0 +1,255 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.database.Cursor; +import android.database.sqlite.SQLiteStatement; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.Property; +import org.greenrobot.greendao.internal.DaoConfig; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseStatement; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * DAO for table "ALARM_MESSAGE_LOCALE_BEAN". +*/ +public class AlarmMessageLocaleBeanDao extends AbstractDao { + + public static final String TABLENAME = "ALARM_MESSAGE_LOCALE_BEAN"; + + /** + * Properties of entity AlarmMessageLocaleBean.
+ * Can be used for QueryBuilder and for referencing column names. + */ + public static class Properties { + public final static Property Id = new Property(0, Long.class, "id", true, "_id"); + public final static Property MessageId = new Property(1, String.class, "messageId", false, "MESSAGE_ID"); + public final static Property AppId = new Property(2, String.class, "appId", false, "APP_ID"); + public final static Property ClientId = new Property(3, String.class, "clientId", false, "CLIENT_ID"); + public final static Property TaskId = new Property(4, String.class, "taskId", false, "TASK_ID"); + public final static Property UserId = new Property(5, String.class, "userId", false, "USER_ID"); + public final static Property Title = new Property(6, String.class, "title", false, "TITLE"); + public final static Property Content = new Property(7, String.class, "content", false, "CONTENT"); + public final static Property DeviceCode = new Property(8, String.class, "deviceCode", false, "DEVICE_CODE"); + public final static Property IsRead = new Property(9, String.class, "isRead", false, "IS_READ"); + public final static Property AlarmTime = new Property(10, String.class, "alarmTime", false, "ALARM_TIME"); + } + + + public AlarmMessageLocaleBeanDao(DaoConfig config) { + super(config); + } + + public AlarmMessageLocaleBeanDao(DaoConfig config, DaoSession daoSession) { + super(config, daoSession); + } + + /** Creates the underlying database table. */ + public static void createTable(Database db, boolean ifNotExists) { + String constraint = ifNotExists? "IF NOT EXISTS ": ""; + db.execSQL("CREATE TABLE " + constraint + "\"ALARM_MESSAGE_LOCALE_BEAN\" (" + // + "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id + "\"MESSAGE_ID\" TEXT UNIQUE ," + // 1: messageId + "\"APP_ID\" TEXT," + // 2: appId + "\"CLIENT_ID\" TEXT," + // 3: clientId + "\"TASK_ID\" TEXT," + // 4: taskId + "\"USER_ID\" TEXT," + // 5: userId + "\"TITLE\" TEXT," + // 6: title + "\"CONTENT\" TEXT," + // 7: content + "\"DEVICE_CODE\" TEXT," + // 8: deviceCode + "\"IS_READ\" TEXT," + // 9: isRead + "\"ALARM_TIME\" TEXT);"); // 10: alarmTime + } + + /** Drops the underlying database table. */ + public static void dropTable(Database db, boolean ifExists) { + String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"ALARM_MESSAGE_LOCALE_BEAN\""; + db.execSQL(sql); + } + + @Override + protected final void bindValues(DatabaseStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + protected final void bindValues(SQLiteStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + public Long readKey(Cursor cursor, int offset) { + return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); + } + + @Override + public AlarmMessageLocaleBean readEntity(Cursor cursor, int offset) { + AlarmMessageLocaleBean entity = new AlarmMessageLocaleBean( // + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // messageId + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // appId + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // clientId + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // taskId + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // userId + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // title + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // content + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // deviceCode + cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // isRead + cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10) // alarmTime + ); + return entity; + } + + @Override + public void readEntity(Cursor cursor, AlarmMessageLocaleBean entity, int offset) { + entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); + entity.setMessageId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setAppId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setClientId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setTaskId(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); + entity.setUserId(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setTitle(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setContent(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); + entity.setDeviceCode(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); + entity.setIsRead(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9)); + entity.setAlarmTime(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); + } + + @Override + protected final Long updateKeyAfterInsert(AlarmMessageLocaleBean entity, long rowId) { + entity.setId(rowId); + return rowId; + } + + @Override + public Long getKey(AlarmMessageLocaleBean entity) { + if(entity != null) { + return entity.getId(); + } else { + return null; + } + } + + @Override + public boolean hasKey(AlarmMessageLocaleBean entity) { + return entity.getId() != null; + } + + @Override + protected final boolean isEntityUpdateable() { + return true; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java new file mode 100644 index 0000000..4222c40 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java @@ -0,0 +1,96 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.content.Context; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteDatabase.CursorFactory; +import android.util.Log; + +import org.greenrobot.greendao.AbstractDaoMaster; +import org.greenrobot.greendao.database.StandardDatabase; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseOpenHelper; +import org.greenrobot.greendao.identityscope.IdentityScopeType; + + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * Master of DAO (schema version 1): knows all DAOs. + */ +public class DaoMaster extends AbstractDaoMaster { + public static final int SCHEMA_VERSION = 1; + + /** Creates underlying database table using DAOs. */ + public static void createAllTables(Database db, boolean ifNotExists) { + AlarmMessageLocaleBeanDao.createTable(db, ifNotExists); + } + + /** Drops underlying database table using DAOs. */ + public static void dropAllTables(Database db, boolean ifExists) { + AlarmMessageLocaleBeanDao.dropTable(db, ifExists); + } + + /** + * WARNING: Drops all table on Upgrade! Use only during development. + * Convenience method using a {@link DevOpenHelper}. + */ + public static DaoSession newDevSession(Context context, String name) { + Database db = new DevOpenHelper(context, name).getWritableDb(); + DaoMaster daoMaster = new DaoMaster(db); + return daoMaster.newSession(); + } + + public DaoMaster(SQLiteDatabase db) { + this(new StandardDatabase(db)); + } + + public DaoMaster(Database db) { + super(db, SCHEMA_VERSION); + registerDaoClass(AlarmMessageLocaleBeanDao.class); + } + + public DaoSession newSession() { + return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); + } + + public DaoSession newSession(IdentityScopeType type) { + return new DaoSession(db, type, daoConfigMap); + } + + /** + * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} - + */ + public static abstract class OpenHelper extends DatabaseOpenHelper { + public OpenHelper(Context context, String name) { + super(context, name, SCHEMA_VERSION); + } + + public OpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory, SCHEMA_VERSION); + } + + @Override + public void onCreate(Database db) { + Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); + createAllTables(db, false); + } + } + + /** WARNING: Drops all table on Upgrade! Use only during development. */ + public static class DevOpenHelper extends OpenHelper { + public DevOpenHelper(Context context, String name) { + super(context, name); + } + + public DevOpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory); + } + + @Override + public void onUpgrade(Database db, int oldVersion, int newVersion) { + Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); + dropAllTables(db, true); + onCreate(db); + } + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java new file mode 100644 index 0000000..480ed84 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java @@ -0,0 +1,48 @@ +package com.casic.smart.town.sanxi.greendao; + +import java.util.Map; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.AbstractDaoSession; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.identityscope.IdentityScopeType; +import org.greenrobot.greendao.internal.DaoConfig; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. + +/** + * {@inheritDoc} + * + * @see org.greenrobot.greendao.AbstractDaoSession + */ +public class DaoSession extends AbstractDaoSession { + + private final DaoConfig alarmMessageLocaleBeanDaoConfig; + + private final AlarmMessageLocaleBeanDao alarmMessageLocaleBeanDao; + + public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> + daoConfigMap) { + super(db); + + alarmMessageLocaleBeanDaoConfig = daoConfigMap.get(AlarmMessageLocaleBeanDao.class).clone(); + alarmMessageLocaleBeanDaoConfig.initIdentityScope(type); + + alarmMessageLocaleBeanDao = new AlarmMessageLocaleBeanDao(alarmMessageLocaleBeanDaoConfig, this); + + registerDao(AlarmMessageLocaleBean.class, alarmMessageLocaleBeanDao); + } + + public void clear() { + alarmMessageLocaleBeanDaoConfig.clearIdentityScope(); + } + + public AlarmMessageLocaleBeanDao getAlarmMessageLocaleBeanDao() { + return alarmMessageLocaleBeanDao; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt new file mode 100644 index 0000000..875cb8c --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt @@ -0,0 +1,5 @@ +package com.casic.smart.town.sanxi.service + +import com.igexin.sdk.PushService + +class ApplicationPushService : PushService() \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt new file mode 100644 index 0000000..396129f --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt @@ -0,0 +1,84 @@ +package com.casic.smart.town.sanxi.service + +import android.content.Context +import android.os.Message +import android.util.Log +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.casic.smart.town.sanxi.view.MainActivity +import com.igexin.sdk.GTIntentService +import com.igexin.sdk.message.GTCmdMessage +import com.igexin.sdk.message.GTNotificationMessage +import com.igexin.sdk.message.GTTransmitMessage +import com.pengxh.kt.lite.extensions.toJson + +class PushIntentService : GTIntentService() { + + private val kTag = "SmartWellIntentService" + + override fun onReceiveServicePid(context: Context?, pid: Int) { + + } + + // 透传消息 + override fun onReceiveMessageData(context: Context?, msg: GTTransmitMessage?) { + Log.d(kTag, "透传消息 -> msg = $msg") + } + + // 接收 cid + override fun onReceiveClientId(context: Context?, clientid: String?) { + Log.d(kTag, "onReceiveClientId -> $clientid") + //通知MainActivity注册个推服务 + val msg: Message = MainActivity.weakReferenceHandler.obtainMessage() + msg.what = LocaleConstant.PUSH_REGISTER + msg.obj = clientid + MainActivity.weakReferenceHandler.sendMessage(msg) + } + + // cid 离线上线通知 + override fun onReceiveOnlineState(context: Context?, online: Boolean) { + + } + + // 各种事件处理回执 + override fun onReceiveCommandResult(context: Context?, msg: GTCmdMessage?) { + + } + + // 通知到达 + override fun onNotificationMessageArrived(context: Context?, msg: GTNotificationMessage?) { + //报警 +// { +// "content": "设备编号[412022030361]发生井盖开盖报警", +// "messageId": "380abf9a79d34306a2683dc9bf96ee78", +// "taskId": "OSL-0830_4hmfimp3Vu684wo3SjXso9", +// "title": "告警提醒", +// "appid": "HKv8K9qARd6WckZ1o2Vbu4", +// "clientId": "e78beacc42e9a02ae6fb9087eb2b1171", +// "pkgName": "com.casic.app.smartwell" +// } + if (msg == null) { + return + } + Log.d(kTag, "通知到达 -> msg = ${msg.toJson()}") +// val userDetailJson = SaveKeyValues.getValue(LocaleConstant.USER_DETAIL_MODEL, "") as String +// var userId = "" +// if (userDetailJson.isNotBlank()) { +// val userDataModel = Gson().fromJson( +// userDetailJson, object : TypeToken() {}.type +// ) +// userId = userDataModel.id.toString() +// } +// //解析编号 +// val splitArray = msg.content.split("\\[|\\]".toRegex()) +// DataBaseManager.instance.insertNotice( +// msg.messageId, msg.appid, msg.clientId, msg.taskId, +// userId, msg.title, msg.content, splitArray[1], "0", +// System.currentTimeMillis().timestampToCompleteDate() +// ) + } + + // 通知点击 + override fun onNotificationMessageClicked(context: Context?, msg: GTNotificationMessage?) { + Log.d(kTag, "通知点击 -> msg = $msg") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt new file mode 100644 index 0000000..daa7c38 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt @@ -0,0 +1,14 @@ +package com.casic.smart.town.sanxi.util + +import android.content.Context +import me.leolin.shortcutbadger.ShortcutBadger + +object BadeHelper { + fun setBadgeNum(context: Context, badgeCount: Int) { + if (badgeCount == 0) { + ShortcutBadger.removeCount(context) + } else { + ShortcutBadger.applyCount(context, badgeCount) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt new file mode 100644 index 0000000..0a52ef2 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt @@ -0,0 +1,75 @@ +package com.casic.smart.town.sanxi.util + +import com.casic.smart.town.sanxi.base.BaseApplication +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao + +class DataBaseManager private constructor() { + + companion object { + //Kotlin委托模式双重锁单例 + val instance: DataBaseManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) { + DataBaseManager() + } + } + + private val beanDao = + BaseApplication.obtainInstance().obtainDaoSession().alarmMessageLocaleBeanDao + +// fun insertNotice( +// messageId: String, appid: String, clientId: String, +// taskId: String, userId: String, title: String, +// content: String, deviceCode: String, isRead: String, +// noticeTime: String +// ) { +// val noticeLocaleBean = NoticeLocaleBean() +// noticeLocaleBean.messageId = messageId +// noticeLocaleBean.appid = appid +// noticeLocaleBean.clientId = clientId +// noticeLocaleBean.taskId = taskId +// noticeLocaleBean.userId = userId +// noticeLocaleBean.title = title +// noticeLocaleBean.content = content +// noticeLocaleBean.deviceCode = deviceCode +// noticeLocaleBean.isRead = isRead +// noticeLocaleBean.noticeTime = noticeTime +// beanDao.insert(noticeLocaleBean) +// //角标设置 +// BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadNotice()) +// } + + fun deleteByMessageId(messageId: String) { + val result = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).list() + beanDao.deleteInTx(result) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun updateNoticeByMessageId(messageId: String) { + val noticeLocaleBean = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).unique() ?: return + noticeLocaleBean.isRead = "1" + beanDao.update(noticeLocaleBean) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun queryMessageByPage(userId: String, offset: Int): MutableList { + return BaseApplication.obtainInstance().obtainDaoSession() + .queryBuilder(AlarmMessageLocaleBean::class.java) + .where(AlarmMessageLocaleBeanDao.Properties.UserId.eq(userId)) + .offset(offset * LocaleConstant.PAGE_LIMIT) + .orderDesc(AlarmMessageLocaleBeanDao.Properties.AlarmTime) + .limit(LocaleConstant.PAGE_LIMIT) + .list() + } + + private fun queryUnReadMessage(): Int { + return beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.IsRead.eq("0") + ).list().size + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt new file mode 100644 index 0000000..52926a8 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt @@ -0,0 +1,31 @@ +package com.casic.smart.town.sanxi.util; + +import android.app.Activity +import android.view.WindowManager +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object LoadingDialogHub { + private lateinit var loadingDialog: QMUITipDialog + + fun show(activity: Activity, message: String) { + loadingDialog = QMUITipDialog + .Builder(activity) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_LOADING) + .setTipWord(message) + .create() + if (!activity.isDestroyed) { + try { + loadingDialog.show() + } catch (e: WindowManager.BadTokenException) { + e.printStackTrace() + } + } + } + + + fun dismiss() { + if (loadingDialog.isShowing) { + loadingDialog.dismiss() + } + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt new file mode 100644 index 0000000..de61c9a --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.util + +import android.Manifest + +object LocaleConstant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.READ_PHONE_STATE, + Manifest.permission.ACCESS_COARSE_LOCATION, + Manifest.permission.READ_EXTERNAL_STORAGE + ) + + const val PERMISSIONS_CODE = 999 + const val PUSH_REGISTER = 2022100101 + const val PAGE_LIMIT = 20 +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt new file mode 100644 index 0000000..3bea1c9 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt @@ -0,0 +1,112 @@ +package com.casic.smart.town.sanxi.view + +import android.view.KeyEvent +import android.view.MenuItem +import androidx.fragment.app.Fragment +import androidx.viewpager.widget.ViewPager +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.adapter.ViewPagerAdapter +import com.casic.smart.town.sanxi.fragment.AlarmPageFragment +import com.casic.smart.town.sanxi.fragment.MonitorPageFragment +import com.casic.smart.town.sanxi.fragment.StatisticsPageFragment +import com.gyf.immersionbar.ImmersionBar +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.base.KotlinBaseActivity +import com.pengxh.kt.lite.extensions.convertColor +import com.pengxh.kt.lite.extensions.show +import com.pengxh.kt.lite.utils.ImmerseStatusBarUtil +import com.pengxh.kt.lite.utils.WeakReferenceHandler +import kotlinx.android.synthetic.main.activity_main.* + +class MainActivity : KotlinBaseActivity() { + + companion object { + lateinit var weakReferenceHandler: WeakReferenceHandler + } + + private val kTag = "MainActivity" + private var menuItem: MenuItem? = null + private var fragmentPages: ArrayList = ArrayList() + private var clickTime: Long = 0 + + init { + fragmentPages.add(StatisticsPageFragment()) + fragmentPages.add(MonitorPageFragment()) + fragmentPages.add(AlarmPageFragment()) + } + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + ImmersionBar.with(this).statusBarDarkFont(false).init() + ImmerseStatusBarUtil.setColor(this, R.color.mainThemeColor.convertColor(this)) + } + + override fun initData() { + //推送,多次调用 SDK 初始化并无影响。 + PushManager.getInstance().initialize(this) + weakReferenceHandler = WeakReferenceHandler { + + true + } + } + + override fun observeRequestState() { + + } + + override fun initEvent() { + bottomNavigation.itemIconTintList = null + bottomNavigation.setOnNavigationItemSelectedListener { menuItem -> + when (menuItem.itemId) { + R.id.nav_statistics -> { + mainViewPager.currentItem = 0 + } + R.id.nav_monitor -> { + mainViewPager.currentItem = 1 + } + R.id.nav_alarm -> { + mainViewPager.currentItem = 2 + } + } + false + } + mainViewPager.adapter = ViewPagerAdapter(fragmentPages, supportFragmentManager) + mainViewPager.offscreenPageLimit = fragmentPages.size //缓存页数 + mainViewPager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener { + override fun onPageScrollStateChanged(state: Int) { + + } + + override fun onPageScrolled( + position: Int, + positionOffset: Float, + positionOffsetPixels: Int + ) { + + } + + override fun onPageSelected(position: Int) { + if (menuItem != null) { + menuItem!!.isChecked = false + } else { + bottomNavigation.menu.getItem(0).isChecked = false + } + menuItem = bottomNavigation.menu.getItem(position) + menuItem!!.isChecked = true + } + }) + } + + override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean { + return if (keyCode == KeyEvent.KEYCODE_BACK) { + if (System.currentTimeMillis() - clickTime > 2000) { + "再按一次退出程序".show(this) + clickTime = System.currentTimeMillis() + true + } else { + super.onKeyDown(keyCode, event) + } + } else super.onKeyDown(keyCode, event) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt new file mode 100644 index 0000000..c5d8b22 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.view + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseActivity + +class MonitorRecordActivity : KotlinBaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_monitor_record + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt new file mode 100644 index 0000000..c478d83 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt @@ -0,0 +1,55 @@ +package com.casic.smart.town.sanxi.view + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.amap.api.maps.MapsInitializer +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.gyf.immersionbar.ImmersionBar +import com.pengxh.kt.lite.extensions.navigatePageTo +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + ImmersionBar.with(this).statusBarDarkFont(true).init() + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (EasyPermissions.hasPermissions(this, *LocaleConstant.USER_PERMISSIONS)) { + startSplashScreenActivity() + } else { + EasyPermissions.requestPermissions( + this@PermissionActivity, + resources.getString(R.string.app_name) + "需要获取相关权限", + LocaleConstant.PERMISSIONS_CODE, + *LocaleConstant.USER_PERMISSIONS + ) + } + } + + private fun startSplashScreenActivity() { + //先把导航隐私政策声明,后面导航会用到 + MapsInitializer.updatePrivacyAgree(this, true) + MapsInitializer.updatePrivacyShow(this, true, true) + this.navigatePageTo() + 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) { + startSplashScreenActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable/alarm_selector.xml b/app/src/main/res/drawable/alarm_selector.xml new file mode 100644 index 0000000..39b2595 --- /dev/null +++ b/app/src/main/res/drawable/alarm_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bottom_text_color.xml b/app/src/main/res/drawable/bottom_text_color.xml new file mode 100644 index 0000000..b284ea3 --- /dev/null +++ b/app/src/main/res/drawable/bottom_text_color.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_alarm.xml b/app/src/main/res/drawable/ic_alarm.xml new file mode 100644 index 0000000..dc33aab --- /dev/null +++ b/app/src/main/res/drawable/ic_alarm.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_alarm_selected.xml b/app/src/main/res/drawable/ic_alarm_selected.xml new file mode 100644 index 0000000..993fea6 --- /dev/null +++ b/app/src/main/res/drawable/ic_alarm_selected.xml @@ -0,0 +1,9 @@ + + + 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_monitor.xml b/app/src/main/res/drawable/ic_monitor.xml new file mode 100644 index 0000000..271f5b4 --- /dev/null +++ b/app/src/main/res/drawable/ic_monitor.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_monitor_selected.xml b/app/src/main/res/drawable/ic_monitor_selected.xml new file mode 100644 index 0000000..ee62d84 --- /dev/null +++ b/app/src/main/res/drawable/ic_monitor_selected.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_statistics.xml b/app/src/main/res/drawable/ic_statistics.xml new file mode 100644 index 0000000..7fde8ec --- /dev/null +++ b/app/src/main/res/drawable/ic_statistics.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_statistics_selected.xml b/app/src/main/res/drawable/ic_statistics_selected.xml new file mode 100644 index 0000000..49b6fcd --- /dev/null +++ b/app/src/main/res/drawable/ic_statistics_selected.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/monitor_selector.xml b/app/src/main/res/drawable/monitor_selector.xml new file mode 100644 index 0000000..fe11e9a --- /dev/null +++ b/app/src/main/res/drawable/monitor_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/statistics_selector.xml b/app/src/main/res/drawable/statistics_selector.xml new file mode 100644 index 0000000..2156cff --- /dev/null +++ b/app/src/main/res/drawable/statistics_selector.xml @@ -0,0 +1,5 @@ + + + + + \ 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..78a4a94 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,27 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_monitor_record.xml b/app/src/main/res/layout/activity_monitor_record.xml new file mode 100644 index 0000000..77d9ef6 --- /dev/null +++ b/app/src/main/res/layout/activity_monitor_record.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_alarm.xml b/app/src/main/res/layout/fragment_alarm.xml new file mode 100644 index 0000000..77d9ef6 --- /dev/null +++ b/app/src/main/res/layout/fragment_alarm.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_monitor.xml b/app/src/main/res/layout/fragment_monitor.xml new file mode 100644 index 0000000..19789c1 --- /dev/null +++ b/app/src/main/res/layout/fragment_monitor.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_statistics.xml b/app/src/main/res/layout/fragment_statistics.xml new file mode 100644 index 0000000..77d9ef6 --- /dev/null +++ b/app/src/main/res/layout/fragment_statistics.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/menu/bottom_nav_menu.xml b/app/src/main/res/menu/bottom_nav_menu.xml new file mode 100644 index 0000000..751fd61 --- /dev/null +++ b/app/src/main/res/menu/bottom_nav_menu.xml @@ -0,0 +1,29 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.webp b/app/src/main/res/mipmap-hdpi/ic_launcher.webp new file mode 100644 index 0000000..c209e78 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp new file mode 100644 index 0000000..b2dfe3d --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.webp b/app/src/main/res/mipmap-mdpi/ic_launcher.webp new file mode 100644 index 0000000..4f0f1d6 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp new file mode 100644 index 0000000..62b611d --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher.webp new file mode 100644 index 0000000..948a307 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..1b9a695 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp Binary files differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp new file mode 100644 index 0000000..28d4b77 --- /dev/null +++ b/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..9287f50 --- /dev/null +++ b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp new file mode 100644 index 0000000..aa7d642 --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..9126ae3 --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp 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..bbce66f --- /dev/null +++ b/app/src/main/res/values/colors.xml @@ -0,0 +1,14 @@ + + + #1D55C6 + #333333 + #CCCCCC + + #FFBB86FC + #FF6200EE + #FF3700B3 + #FF03DAC5 + #FF018786 + #FF000000 + #FFFFFFFF + \ No newline at end of file diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml new file mode 100644 index 0000000..b7a9292 --- /dev/null +++ b/app/src/main/res/values/dimens.xml @@ -0,0 +1,33 @@ + + + + 12sp + 14sp + 16sp + 18sp + 20sp + 22sp + + + 3dp + 5dp + 7dp + 10dp + 15dp + 20dp + 25dp + 30dp + 35dp + 40dp + 45dp + 50dp + 55dp + 60dp + 75dp + + + 1dp + + + 45dp + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml new file mode 100644 index 0000000..f636245 --- /dev/null +++ b/app/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + SmartTown + \ No newline at end of file diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml new file mode 100644 index 0000000..635e8e0 --- /dev/null +++ b/app/src/main/res/values/themes.xml @@ -0,0 +1,16 @@ + + + + \ No newline at end of file diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..62b9d90 --- /dev/null +++ b/build.gradle @@ -0,0 +1,30 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. +buildscript { + ext.kotlin_version = '1.6.10' + repositories { + maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' } + google() + } + dependencies { + classpath 'com.android.tools.build:gradle:3.6.4' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + classpath 'org.greenrobot:greendao-gradle-plugin:3.3.0' + + // 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() + maven { url "https://mvn.getui.com/nexus/content/repositories/releases/"} + } +} + +task clean(type: Delete) { + delete rootProject.buildDir +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..98bed16 --- /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=-Xmx2048m -Dfile.encoding=UTF-8 +# 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 \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..e708b1c --- /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..35bda37 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Sat Oct 08 09:41:32 CST 2022 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..10cfdbf --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*.iml +.gradle +/local.properties +/.idea +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..a4cd2ca --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,101 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'org.greenrobot.greendao' + +android { +// signingConfigs { +// release { +// storeFile file('/Users/a203/Desktop/AndroidProjects/CasicSmartWell/app/CasicSmartWell.jks') +// storePassword '123456789' +// keyAlias 'key0' +// keyPassword '123456789' +// } +// } + compileSdkVersion 31 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.smart.town.sanxi" + minSdkVersion 23 + targetSdkVersion 31 + versionCode 1 + versionName "1.0.0" + + manifestPlaceholders = [GETUI_APPID: "A9V4DvwLcdAqkFCQuFyhq6"] + } + + buildTypes { + release { + minifyEnabled false +// signingConfig signingConfigs.release + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + + ndk { abiFilters "armeabi", "armeabi-v7a", "arm64-v8" } + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlin { + experimental { + coroutines 'enable' + } + } + + greendao { + schemaVersion 1//数据库版本号 + targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 + daoPackage 'com.casic.smart.town.sanxi.greendao'//设置DaoMaster、DaoSession、Dao包名 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + //基础依赖库 + implementation files('libs/lite-release.aar') + implementation 'androidx.appcompat:appcompat:1.4.2' + implementation 'androidx.core:core-ktx:1.8.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:3.0.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' + //MVVM+LiveData + implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.1" + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0" + implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + //Kotlin协程 + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1' + //图片加载框架 + implementation 'com.github.bumptech.glide:glide:4.9.0' + //返回值转换器 + implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' + implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + //okhttp3日志拦截器 + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //网络请求和接口封装 + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.9.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.9.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' + //高德地图 + implementation 'com.amap.api:3dmap:latest.integration' + //推送SDK + implementation 'com.getui:gtsdk:3.2.10.0' //个推SDK + implementation 'com.getui:gtc:3.1.9.0' //个推核心组件 + //数据库框架 + implementation 'org.greenrobot:greendao:3.3.0' + //桌面角标 + implementation "me.leolin:ShortcutBadger:1.1.22@aar" +} \ No newline at end of file diff --git a/app/libs/lite-release.aar b/app/libs/lite-release.aar new file mode 100644 index 0000000..45da4df --- /dev/null +++ b/app/libs/lite-release.aar Binary files differ diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /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 \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..a83c28a --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/svg/monitor.svg b/app/src/main/assets/svg/monitor.svg new file mode 100644 index 0000000..c8d3e25 --- /dev/null +++ b/app/src/main/assets/svg/monitor.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/msg.svg b/app/src/main/assets/svg/msg.svg new file mode 100644 index 0000000..e864e48 --- /dev/null +++ b/app/src/main/assets/svg/msg.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/statistics.svg b/app/src/main/assets/svg/statistics.svg new file mode 100644 index 0000000..974000e --- /dev/null +++ b/app/src/main/assets/svg/statistics.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt new file mode 100644 index 0000000..6b9cce0 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.adapter + +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentManager +import androidx.fragment.app.FragmentPagerAdapter + +class ViewPagerAdapter(list: ArrayList, manager: FragmentManager) : + FragmentPagerAdapter(manager) { + + private var pageList: List = list + + override fun getItem(position: Int) = pageList[position] + + override fun getCount() = pageList.size +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt new file mode 100644 index 0000000..4e017b1 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt @@ -0,0 +1,40 @@ +package com.casic.smart.town.sanxi.base + +import android.app.Application +import android.util.Log +import com.casic.smart.town.sanxi.greendao.DaoMaster +import com.casic.smart.town.sanxi.greendao.DaoSession +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + private val kTag = "BaseApplication" + + companion object { + private var instance: BaseApplication by Delegates.notNull() + + fun obtainInstance() = instance + + private lateinit var daoSession: DaoSession + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences(this) + //推送 + PushManager.getInstance().initialize(this) + PushManager.getInstance().setDebugLogger(this) { + Log.d(kTag, it) + } + val devOpenHelper = DaoMaster.DevOpenHelper(this, "SmartTown.db", null) + val daoMaster = DaoMaster(devOpenHelper.writableDatabase) + daoSession = daoMaster.newSession() + } + + fun obtainDaoSession(): DaoSession { + return daoSession + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java new file mode 100644 index 0000000..b8f67dc --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java @@ -0,0 +1,133 @@ +package com.casic.smart.town.sanxi.bean; + +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Generated; +import org.greenrobot.greendao.annotation.Id; +import org.greenrobot.greendao.annotation.Unique; + +@Entity +public class AlarmMessageLocaleBean { + @Id(autoincrement = true) + private Long id;//主键自增 + + @Unique + private String messageId; + private String appId; + private String clientId; + private String taskId; + private String userId; + private String title; + private String content; + private String deviceCode; + private String isRead;//0-未读,1-已读 + private String alarmTime; + + @Generated(hash = 566950134) + public AlarmMessageLocaleBean(Long id, String messageId, String appId, + String clientId, String taskId, String userId, String title, + String content, String deviceCode, String isRead, String alarmTime) { + this.id = id; + this.messageId = messageId; + this.appId = appId; + this.clientId = clientId; + this.taskId = taskId; + this.userId = userId; + this.title = title; + this.content = content; + this.deviceCode = deviceCode; + this.isRead = isRead; + this.alarmTime = alarmTime; + } + + @Generated(hash = 1737519562) + public AlarmMessageLocaleBean() { + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getMessageId() { + return this.messageId; + } + + public void setMessageId(String messageId) { + this.messageId = messageId; + } + + public String getAppId() { + return this.appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public String getClientId() { + return this.clientId; + } + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public String getTaskId() { + return this.taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getUserId() { + return this.userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getTitle() { + return this.title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return this.content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getDeviceCode() { + return this.deviceCode; + } + + public void setDeviceCode(String deviceCode) { + this.deviceCode = deviceCode; + } + + public String getIsRead() { + return this.isRead; + } + + public void setIsRead(String isRead) { + this.isRead = isRead; + } + + public String getAlarmTime() { + return this.alarmTime; + } + + public void setAlarmTime(String alarmTime) { + this.alarmTime = alarmTime; + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt new file mode 100644 index 0000000..650e201 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class AlarmPageFragment: KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_alarm + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt new file mode 100644 index 0000000..deac8ac --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt @@ -0,0 +1,76 @@ +package com.casic.smart.town.sanxi.fragment + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.Fragment +import com.amap.api.maps.AMap +import com.amap.api.maps.AMapOptions +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.view.MonitorRecordActivity +import com.pengxh.kt.lite.extensions.navigatePageTo +import com.pengxh.kt.lite.extensions.show +import kotlinx.android.synthetic.main.fragment_monitor.view.* + +class MonitorPageFragment : Fragment() { + + private val kTag = "HomePageFragment" + private lateinit var monitorView: View + private lateinit var aMap: AMap + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? + ): View { + monitorView = inflater.inflate(R.layout.fragment_monitor, container, false) + //地图初始化 + initMap(savedInstanceState) + + monitorView.rightOperateView.setOnClickListener { + requireContext().navigatePageTo() + } + return monitorView + } + + private fun initMap(savedInstanceState: Bundle?) { + monitorView.mapView.onCreate(savedInstanceState) + aMap = monitorView.mapView.map + aMap.mapType = AMap.MAP_TYPE_NORMAL + val uiSettings = aMap.uiSettings + uiSettings.isCompassEnabled = true + uiSettings.zoomPosition = AMapOptions.ZOOM_POSITION_RIGHT_CENTER + uiSettings.isTiltGesturesEnabled = false//不许地图随手势倾斜角度 + + // 地图加载成功监听 +// aMap.addOnMapLoadedListener(this) + // 地图缩放监听 +// aMap.addOnCameraChangeListener(this) + // marker 点击事件监听 +// aMap.addOnMarkerClickListener(this) + // 点击marker弹出自定义popup +// aMap.setInfoWindowAdapter(this) + //信息窗点击事件 +// aMap.addOnInfoWindowClickListener(this) + } + + /***以下是地图生命周期管理************************************************************************/ + override fun onResume() { + super.onResume() + monitorView.mapView.onResume() + } + + override fun onPause() { + super.onPause() + monitorView.mapView.onPause() + } + + override fun onSaveInstanceState(outState: Bundle) { + super.onSaveInstanceState(outState) + monitorView.mapView.onSaveInstanceState(outState) + } + + override fun onDestroy() { + super.onDestroy() + monitorView.mapView.onDestroy() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt new file mode 100644 index 0000000..e84df12 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class StatisticsPageFragment : KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_statistics + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java new file mode 100644 index 0000000..68d7901 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java @@ -0,0 +1,255 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.database.Cursor; +import android.database.sqlite.SQLiteStatement; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.Property; +import org.greenrobot.greendao.internal.DaoConfig; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseStatement; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * DAO for table "ALARM_MESSAGE_LOCALE_BEAN". +*/ +public class AlarmMessageLocaleBeanDao extends AbstractDao { + + public static final String TABLENAME = "ALARM_MESSAGE_LOCALE_BEAN"; + + /** + * Properties of entity AlarmMessageLocaleBean.
+ * Can be used for QueryBuilder and for referencing column names. + */ + public static class Properties { + public final static Property Id = new Property(0, Long.class, "id", true, "_id"); + public final static Property MessageId = new Property(1, String.class, "messageId", false, "MESSAGE_ID"); + public final static Property AppId = new Property(2, String.class, "appId", false, "APP_ID"); + public final static Property ClientId = new Property(3, String.class, "clientId", false, "CLIENT_ID"); + public final static Property TaskId = new Property(4, String.class, "taskId", false, "TASK_ID"); + public final static Property UserId = new Property(5, String.class, "userId", false, "USER_ID"); + public final static Property Title = new Property(6, String.class, "title", false, "TITLE"); + public final static Property Content = new Property(7, String.class, "content", false, "CONTENT"); + public final static Property DeviceCode = new Property(8, String.class, "deviceCode", false, "DEVICE_CODE"); + public final static Property IsRead = new Property(9, String.class, "isRead", false, "IS_READ"); + public final static Property AlarmTime = new Property(10, String.class, "alarmTime", false, "ALARM_TIME"); + } + + + public AlarmMessageLocaleBeanDao(DaoConfig config) { + super(config); + } + + public AlarmMessageLocaleBeanDao(DaoConfig config, DaoSession daoSession) { + super(config, daoSession); + } + + /** Creates the underlying database table. */ + public static void createTable(Database db, boolean ifNotExists) { + String constraint = ifNotExists? "IF NOT EXISTS ": ""; + db.execSQL("CREATE TABLE " + constraint + "\"ALARM_MESSAGE_LOCALE_BEAN\" (" + // + "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id + "\"MESSAGE_ID\" TEXT UNIQUE ," + // 1: messageId + "\"APP_ID\" TEXT," + // 2: appId + "\"CLIENT_ID\" TEXT," + // 3: clientId + "\"TASK_ID\" TEXT," + // 4: taskId + "\"USER_ID\" TEXT," + // 5: userId + "\"TITLE\" TEXT," + // 6: title + "\"CONTENT\" TEXT," + // 7: content + "\"DEVICE_CODE\" TEXT," + // 8: deviceCode + "\"IS_READ\" TEXT," + // 9: isRead + "\"ALARM_TIME\" TEXT);"); // 10: alarmTime + } + + /** Drops the underlying database table. */ + public static void dropTable(Database db, boolean ifExists) { + String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"ALARM_MESSAGE_LOCALE_BEAN\""; + db.execSQL(sql); + } + + @Override + protected final void bindValues(DatabaseStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + protected final void bindValues(SQLiteStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + public Long readKey(Cursor cursor, int offset) { + return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); + } + + @Override + public AlarmMessageLocaleBean readEntity(Cursor cursor, int offset) { + AlarmMessageLocaleBean entity = new AlarmMessageLocaleBean( // + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // messageId + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // appId + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // clientId + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // taskId + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // userId + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // title + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // content + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // deviceCode + cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // isRead + cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10) // alarmTime + ); + return entity; + } + + @Override + public void readEntity(Cursor cursor, AlarmMessageLocaleBean entity, int offset) { + entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); + entity.setMessageId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setAppId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setClientId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setTaskId(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); + entity.setUserId(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setTitle(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setContent(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); + entity.setDeviceCode(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); + entity.setIsRead(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9)); + entity.setAlarmTime(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); + } + + @Override + protected final Long updateKeyAfterInsert(AlarmMessageLocaleBean entity, long rowId) { + entity.setId(rowId); + return rowId; + } + + @Override + public Long getKey(AlarmMessageLocaleBean entity) { + if(entity != null) { + return entity.getId(); + } else { + return null; + } + } + + @Override + public boolean hasKey(AlarmMessageLocaleBean entity) { + return entity.getId() != null; + } + + @Override + protected final boolean isEntityUpdateable() { + return true; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java new file mode 100644 index 0000000..4222c40 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java @@ -0,0 +1,96 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.content.Context; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteDatabase.CursorFactory; +import android.util.Log; + +import org.greenrobot.greendao.AbstractDaoMaster; +import org.greenrobot.greendao.database.StandardDatabase; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseOpenHelper; +import org.greenrobot.greendao.identityscope.IdentityScopeType; + + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * Master of DAO (schema version 1): knows all DAOs. + */ +public class DaoMaster extends AbstractDaoMaster { + public static final int SCHEMA_VERSION = 1; + + /** Creates underlying database table using DAOs. */ + public static void createAllTables(Database db, boolean ifNotExists) { + AlarmMessageLocaleBeanDao.createTable(db, ifNotExists); + } + + /** Drops underlying database table using DAOs. */ + public static void dropAllTables(Database db, boolean ifExists) { + AlarmMessageLocaleBeanDao.dropTable(db, ifExists); + } + + /** + * WARNING: Drops all table on Upgrade! Use only during development. + * Convenience method using a {@link DevOpenHelper}. + */ + public static DaoSession newDevSession(Context context, String name) { + Database db = new DevOpenHelper(context, name).getWritableDb(); + DaoMaster daoMaster = new DaoMaster(db); + return daoMaster.newSession(); + } + + public DaoMaster(SQLiteDatabase db) { + this(new StandardDatabase(db)); + } + + public DaoMaster(Database db) { + super(db, SCHEMA_VERSION); + registerDaoClass(AlarmMessageLocaleBeanDao.class); + } + + public DaoSession newSession() { + return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); + } + + public DaoSession newSession(IdentityScopeType type) { + return new DaoSession(db, type, daoConfigMap); + } + + /** + * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} - + */ + public static abstract class OpenHelper extends DatabaseOpenHelper { + public OpenHelper(Context context, String name) { + super(context, name, SCHEMA_VERSION); + } + + public OpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory, SCHEMA_VERSION); + } + + @Override + public void onCreate(Database db) { + Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); + createAllTables(db, false); + } + } + + /** WARNING: Drops all table on Upgrade! Use only during development. */ + public static class DevOpenHelper extends OpenHelper { + public DevOpenHelper(Context context, String name) { + super(context, name); + } + + public DevOpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory); + } + + @Override + public void onUpgrade(Database db, int oldVersion, int newVersion) { + Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); + dropAllTables(db, true); + onCreate(db); + } + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java new file mode 100644 index 0000000..480ed84 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java @@ -0,0 +1,48 @@ +package com.casic.smart.town.sanxi.greendao; + +import java.util.Map; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.AbstractDaoSession; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.identityscope.IdentityScopeType; +import org.greenrobot.greendao.internal.DaoConfig; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. + +/** + * {@inheritDoc} + * + * @see org.greenrobot.greendao.AbstractDaoSession + */ +public class DaoSession extends AbstractDaoSession { + + private final DaoConfig alarmMessageLocaleBeanDaoConfig; + + private final AlarmMessageLocaleBeanDao alarmMessageLocaleBeanDao; + + public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> + daoConfigMap) { + super(db); + + alarmMessageLocaleBeanDaoConfig = daoConfigMap.get(AlarmMessageLocaleBeanDao.class).clone(); + alarmMessageLocaleBeanDaoConfig.initIdentityScope(type); + + alarmMessageLocaleBeanDao = new AlarmMessageLocaleBeanDao(alarmMessageLocaleBeanDaoConfig, this); + + registerDao(AlarmMessageLocaleBean.class, alarmMessageLocaleBeanDao); + } + + public void clear() { + alarmMessageLocaleBeanDaoConfig.clearIdentityScope(); + } + + public AlarmMessageLocaleBeanDao getAlarmMessageLocaleBeanDao() { + return alarmMessageLocaleBeanDao; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt new file mode 100644 index 0000000..875cb8c --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt @@ -0,0 +1,5 @@ +package com.casic.smart.town.sanxi.service + +import com.igexin.sdk.PushService + +class ApplicationPushService : PushService() \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt new file mode 100644 index 0000000..396129f --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt @@ -0,0 +1,84 @@ +package com.casic.smart.town.sanxi.service + +import android.content.Context +import android.os.Message +import android.util.Log +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.casic.smart.town.sanxi.view.MainActivity +import com.igexin.sdk.GTIntentService +import com.igexin.sdk.message.GTCmdMessage +import com.igexin.sdk.message.GTNotificationMessage +import com.igexin.sdk.message.GTTransmitMessage +import com.pengxh.kt.lite.extensions.toJson + +class PushIntentService : GTIntentService() { + + private val kTag = "SmartWellIntentService" + + override fun onReceiveServicePid(context: Context?, pid: Int) { + + } + + // 透传消息 + override fun onReceiveMessageData(context: Context?, msg: GTTransmitMessage?) { + Log.d(kTag, "透传消息 -> msg = $msg") + } + + // 接收 cid + override fun onReceiveClientId(context: Context?, clientid: String?) { + Log.d(kTag, "onReceiveClientId -> $clientid") + //通知MainActivity注册个推服务 + val msg: Message = MainActivity.weakReferenceHandler.obtainMessage() + msg.what = LocaleConstant.PUSH_REGISTER + msg.obj = clientid + MainActivity.weakReferenceHandler.sendMessage(msg) + } + + // cid 离线上线通知 + override fun onReceiveOnlineState(context: Context?, online: Boolean) { + + } + + // 各种事件处理回执 + override fun onReceiveCommandResult(context: Context?, msg: GTCmdMessage?) { + + } + + // 通知到达 + override fun onNotificationMessageArrived(context: Context?, msg: GTNotificationMessage?) { + //报警 +// { +// "content": "设备编号[412022030361]发生井盖开盖报警", +// "messageId": "380abf9a79d34306a2683dc9bf96ee78", +// "taskId": "OSL-0830_4hmfimp3Vu684wo3SjXso9", +// "title": "告警提醒", +// "appid": "HKv8K9qARd6WckZ1o2Vbu4", +// "clientId": "e78beacc42e9a02ae6fb9087eb2b1171", +// "pkgName": "com.casic.app.smartwell" +// } + if (msg == null) { + return + } + Log.d(kTag, "通知到达 -> msg = ${msg.toJson()}") +// val userDetailJson = SaveKeyValues.getValue(LocaleConstant.USER_DETAIL_MODEL, "") as String +// var userId = "" +// if (userDetailJson.isNotBlank()) { +// val userDataModel = Gson().fromJson( +// userDetailJson, object : TypeToken() {}.type +// ) +// userId = userDataModel.id.toString() +// } +// //解析编号 +// val splitArray = msg.content.split("\\[|\\]".toRegex()) +// DataBaseManager.instance.insertNotice( +// msg.messageId, msg.appid, msg.clientId, msg.taskId, +// userId, msg.title, msg.content, splitArray[1], "0", +// System.currentTimeMillis().timestampToCompleteDate() +// ) + } + + // 通知点击 + override fun onNotificationMessageClicked(context: Context?, msg: GTNotificationMessage?) { + Log.d(kTag, "通知点击 -> msg = $msg") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt new file mode 100644 index 0000000..daa7c38 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt @@ -0,0 +1,14 @@ +package com.casic.smart.town.sanxi.util + +import android.content.Context +import me.leolin.shortcutbadger.ShortcutBadger + +object BadeHelper { + fun setBadgeNum(context: Context, badgeCount: Int) { + if (badgeCount == 0) { + ShortcutBadger.removeCount(context) + } else { + ShortcutBadger.applyCount(context, badgeCount) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt new file mode 100644 index 0000000..0a52ef2 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt @@ -0,0 +1,75 @@ +package com.casic.smart.town.sanxi.util + +import com.casic.smart.town.sanxi.base.BaseApplication +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao + +class DataBaseManager private constructor() { + + companion object { + //Kotlin委托模式双重锁单例 + val instance: DataBaseManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) { + DataBaseManager() + } + } + + private val beanDao = + BaseApplication.obtainInstance().obtainDaoSession().alarmMessageLocaleBeanDao + +// fun insertNotice( +// messageId: String, appid: String, clientId: String, +// taskId: String, userId: String, title: String, +// content: String, deviceCode: String, isRead: String, +// noticeTime: String +// ) { +// val noticeLocaleBean = NoticeLocaleBean() +// noticeLocaleBean.messageId = messageId +// noticeLocaleBean.appid = appid +// noticeLocaleBean.clientId = clientId +// noticeLocaleBean.taskId = taskId +// noticeLocaleBean.userId = userId +// noticeLocaleBean.title = title +// noticeLocaleBean.content = content +// noticeLocaleBean.deviceCode = deviceCode +// noticeLocaleBean.isRead = isRead +// noticeLocaleBean.noticeTime = noticeTime +// beanDao.insert(noticeLocaleBean) +// //角标设置 +// BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadNotice()) +// } + + fun deleteByMessageId(messageId: String) { + val result = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).list() + beanDao.deleteInTx(result) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun updateNoticeByMessageId(messageId: String) { + val noticeLocaleBean = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).unique() ?: return + noticeLocaleBean.isRead = "1" + beanDao.update(noticeLocaleBean) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun queryMessageByPage(userId: String, offset: Int): MutableList { + return BaseApplication.obtainInstance().obtainDaoSession() + .queryBuilder(AlarmMessageLocaleBean::class.java) + .where(AlarmMessageLocaleBeanDao.Properties.UserId.eq(userId)) + .offset(offset * LocaleConstant.PAGE_LIMIT) + .orderDesc(AlarmMessageLocaleBeanDao.Properties.AlarmTime) + .limit(LocaleConstant.PAGE_LIMIT) + .list() + } + + private fun queryUnReadMessage(): Int { + return beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.IsRead.eq("0") + ).list().size + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt new file mode 100644 index 0000000..52926a8 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt @@ -0,0 +1,31 @@ +package com.casic.smart.town.sanxi.util; + +import android.app.Activity +import android.view.WindowManager +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object LoadingDialogHub { + private lateinit var loadingDialog: QMUITipDialog + + fun show(activity: Activity, message: String) { + loadingDialog = QMUITipDialog + .Builder(activity) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_LOADING) + .setTipWord(message) + .create() + if (!activity.isDestroyed) { + try { + loadingDialog.show() + } catch (e: WindowManager.BadTokenException) { + e.printStackTrace() + } + } + } + + + fun dismiss() { + if (loadingDialog.isShowing) { + loadingDialog.dismiss() + } + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt new file mode 100644 index 0000000..de61c9a --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.util + +import android.Manifest + +object LocaleConstant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.READ_PHONE_STATE, + Manifest.permission.ACCESS_COARSE_LOCATION, + Manifest.permission.READ_EXTERNAL_STORAGE + ) + + const val PERMISSIONS_CODE = 999 + const val PUSH_REGISTER = 2022100101 + const val PAGE_LIMIT = 20 +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt new file mode 100644 index 0000000..3bea1c9 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt @@ -0,0 +1,112 @@ +package com.casic.smart.town.sanxi.view + +import android.view.KeyEvent +import android.view.MenuItem +import androidx.fragment.app.Fragment +import androidx.viewpager.widget.ViewPager +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.adapter.ViewPagerAdapter +import com.casic.smart.town.sanxi.fragment.AlarmPageFragment +import com.casic.smart.town.sanxi.fragment.MonitorPageFragment +import com.casic.smart.town.sanxi.fragment.StatisticsPageFragment +import com.gyf.immersionbar.ImmersionBar +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.base.KotlinBaseActivity +import com.pengxh.kt.lite.extensions.convertColor +import com.pengxh.kt.lite.extensions.show +import com.pengxh.kt.lite.utils.ImmerseStatusBarUtil +import com.pengxh.kt.lite.utils.WeakReferenceHandler +import kotlinx.android.synthetic.main.activity_main.* + +class MainActivity : KotlinBaseActivity() { + + companion object { + lateinit var weakReferenceHandler: WeakReferenceHandler + } + + private val kTag = "MainActivity" + private var menuItem: MenuItem? = null + private var fragmentPages: ArrayList = ArrayList() + private var clickTime: Long = 0 + + init { + fragmentPages.add(StatisticsPageFragment()) + fragmentPages.add(MonitorPageFragment()) + fragmentPages.add(AlarmPageFragment()) + } + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + ImmersionBar.with(this).statusBarDarkFont(false).init() + ImmerseStatusBarUtil.setColor(this, R.color.mainThemeColor.convertColor(this)) + } + + override fun initData() { + //推送,多次调用 SDK 初始化并无影响。 + PushManager.getInstance().initialize(this) + weakReferenceHandler = WeakReferenceHandler { + + true + } + } + + override fun observeRequestState() { + + } + + override fun initEvent() { + bottomNavigation.itemIconTintList = null + bottomNavigation.setOnNavigationItemSelectedListener { menuItem -> + when (menuItem.itemId) { + R.id.nav_statistics -> { + mainViewPager.currentItem = 0 + } + R.id.nav_monitor -> { + mainViewPager.currentItem = 1 + } + R.id.nav_alarm -> { + mainViewPager.currentItem = 2 + } + } + false + } + mainViewPager.adapter = ViewPagerAdapter(fragmentPages, supportFragmentManager) + mainViewPager.offscreenPageLimit = fragmentPages.size //缓存页数 + mainViewPager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener { + override fun onPageScrollStateChanged(state: Int) { + + } + + override fun onPageScrolled( + position: Int, + positionOffset: Float, + positionOffsetPixels: Int + ) { + + } + + override fun onPageSelected(position: Int) { + if (menuItem != null) { + menuItem!!.isChecked = false + } else { + bottomNavigation.menu.getItem(0).isChecked = false + } + menuItem = bottomNavigation.menu.getItem(position) + menuItem!!.isChecked = true + } + }) + } + + override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean { + return if (keyCode == KeyEvent.KEYCODE_BACK) { + if (System.currentTimeMillis() - clickTime > 2000) { + "再按一次退出程序".show(this) + clickTime = System.currentTimeMillis() + true + } else { + super.onKeyDown(keyCode, event) + } + } else super.onKeyDown(keyCode, event) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt new file mode 100644 index 0000000..c5d8b22 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.view + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseActivity + +class MonitorRecordActivity : KotlinBaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_monitor_record + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt new file mode 100644 index 0000000..c478d83 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt @@ -0,0 +1,55 @@ +package com.casic.smart.town.sanxi.view + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.amap.api.maps.MapsInitializer +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.gyf.immersionbar.ImmersionBar +import com.pengxh.kt.lite.extensions.navigatePageTo +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + ImmersionBar.with(this).statusBarDarkFont(true).init() + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (EasyPermissions.hasPermissions(this, *LocaleConstant.USER_PERMISSIONS)) { + startSplashScreenActivity() + } else { + EasyPermissions.requestPermissions( + this@PermissionActivity, + resources.getString(R.string.app_name) + "需要获取相关权限", + LocaleConstant.PERMISSIONS_CODE, + *LocaleConstant.USER_PERMISSIONS + ) + } + } + + private fun startSplashScreenActivity() { + //先把导航隐私政策声明,后面导航会用到 + MapsInitializer.updatePrivacyAgree(this, true) + MapsInitializer.updatePrivacyShow(this, true, true) + this.navigatePageTo() + 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) { + startSplashScreenActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable/alarm_selector.xml b/app/src/main/res/drawable/alarm_selector.xml new file mode 100644 index 0000000..39b2595 --- /dev/null +++ b/app/src/main/res/drawable/alarm_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bottom_text_color.xml b/app/src/main/res/drawable/bottom_text_color.xml new file mode 100644 index 0000000..b284ea3 --- /dev/null +++ b/app/src/main/res/drawable/bottom_text_color.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_alarm.xml b/app/src/main/res/drawable/ic_alarm.xml new file mode 100644 index 0000000..dc33aab --- /dev/null +++ b/app/src/main/res/drawable/ic_alarm.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_alarm_selected.xml b/app/src/main/res/drawable/ic_alarm_selected.xml new file mode 100644 index 0000000..993fea6 --- /dev/null +++ b/app/src/main/res/drawable/ic_alarm_selected.xml @@ -0,0 +1,9 @@ + + + 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_monitor.xml b/app/src/main/res/drawable/ic_monitor.xml new file mode 100644 index 0000000..271f5b4 --- /dev/null +++ b/app/src/main/res/drawable/ic_monitor.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_monitor_selected.xml b/app/src/main/res/drawable/ic_monitor_selected.xml new file mode 100644 index 0000000..ee62d84 --- /dev/null +++ b/app/src/main/res/drawable/ic_monitor_selected.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_statistics.xml b/app/src/main/res/drawable/ic_statistics.xml new file mode 100644 index 0000000..7fde8ec --- /dev/null +++ b/app/src/main/res/drawable/ic_statistics.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_statistics_selected.xml b/app/src/main/res/drawable/ic_statistics_selected.xml new file mode 100644 index 0000000..49b6fcd --- /dev/null +++ b/app/src/main/res/drawable/ic_statistics_selected.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/monitor_selector.xml b/app/src/main/res/drawable/monitor_selector.xml new file mode 100644 index 0000000..fe11e9a --- /dev/null +++ b/app/src/main/res/drawable/monitor_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/statistics_selector.xml b/app/src/main/res/drawable/statistics_selector.xml new file mode 100644 index 0000000..2156cff --- /dev/null +++ b/app/src/main/res/drawable/statistics_selector.xml @@ -0,0 +1,5 @@ + + + + + \ 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..78a4a94 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,27 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_monitor_record.xml b/app/src/main/res/layout/activity_monitor_record.xml new file mode 100644 index 0000000..77d9ef6 --- /dev/null +++ b/app/src/main/res/layout/activity_monitor_record.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_alarm.xml b/app/src/main/res/layout/fragment_alarm.xml new file mode 100644 index 0000000..77d9ef6 --- /dev/null +++ b/app/src/main/res/layout/fragment_alarm.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_monitor.xml b/app/src/main/res/layout/fragment_monitor.xml new file mode 100644 index 0000000..19789c1 --- /dev/null +++ b/app/src/main/res/layout/fragment_monitor.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_statistics.xml b/app/src/main/res/layout/fragment_statistics.xml new file mode 100644 index 0000000..77d9ef6 --- /dev/null +++ b/app/src/main/res/layout/fragment_statistics.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/menu/bottom_nav_menu.xml b/app/src/main/res/menu/bottom_nav_menu.xml new file mode 100644 index 0000000..751fd61 --- /dev/null +++ b/app/src/main/res/menu/bottom_nav_menu.xml @@ -0,0 +1,29 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.webp b/app/src/main/res/mipmap-hdpi/ic_launcher.webp new file mode 100644 index 0000000..c209e78 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp new file mode 100644 index 0000000..b2dfe3d --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.webp b/app/src/main/res/mipmap-mdpi/ic_launcher.webp new file mode 100644 index 0000000..4f0f1d6 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp new file mode 100644 index 0000000..62b611d --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher.webp new file mode 100644 index 0000000..948a307 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..1b9a695 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp Binary files differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp new file mode 100644 index 0000000..28d4b77 --- /dev/null +++ b/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..9287f50 --- /dev/null +++ b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp new file mode 100644 index 0000000..aa7d642 --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..9126ae3 --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp 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..bbce66f --- /dev/null +++ b/app/src/main/res/values/colors.xml @@ -0,0 +1,14 @@ + + + #1D55C6 + #333333 + #CCCCCC + + #FFBB86FC + #FF6200EE + #FF3700B3 + #FF03DAC5 + #FF018786 + #FF000000 + #FFFFFFFF + \ No newline at end of file diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml new file mode 100644 index 0000000..b7a9292 --- /dev/null +++ b/app/src/main/res/values/dimens.xml @@ -0,0 +1,33 @@ + + + + 12sp + 14sp + 16sp + 18sp + 20sp + 22sp + + + 3dp + 5dp + 7dp + 10dp + 15dp + 20dp + 25dp + 30dp + 35dp + 40dp + 45dp + 50dp + 55dp + 60dp + 75dp + + + 1dp + + + 45dp + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml new file mode 100644 index 0000000..f636245 --- /dev/null +++ b/app/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + SmartTown + \ No newline at end of file diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml new file mode 100644 index 0000000..635e8e0 --- /dev/null +++ b/app/src/main/res/values/themes.xml @@ -0,0 +1,16 @@ + + + + \ No newline at end of file diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..62b9d90 --- /dev/null +++ b/build.gradle @@ -0,0 +1,30 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. +buildscript { + ext.kotlin_version = '1.6.10' + repositories { + maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' } + google() + } + dependencies { + classpath 'com.android.tools.build:gradle:3.6.4' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + classpath 'org.greenrobot:greendao-gradle-plugin:3.3.0' + + // 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() + maven { url "https://mvn.getui.com/nexus/content/repositories/releases/"} + } +} + +task clean(type: Delete) { + delete rootProject.buildDir +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..98bed16 --- /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=-Xmx2048m -Dfile.encoding=UTF-8 +# 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 \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..e708b1c --- /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..35bda37 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Sat Oct 08 09:41:32 CST 2022 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip diff --git a/gradlew b/gradlew new file mode 100755 index 0000000..4f906e0 --- /dev/null +++ b/gradlew @@ -0,0 +1,185 @@ +#!/usr/bin/env sh + +# +# Copyright 2015 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +## +## 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='"-Xmx64m" "-Xms64m"' + +# 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 or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; 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=`expr $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" + +exec "$JAVACMD" "$@" diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..10cfdbf --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*.iml +.gradle +/local.properties +/.idea +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..a4cd2ca --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,101 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'org.greenrobot.greendao' + +android { +// signingConfigs { +// release { +// storeFile file('/Users/a203/Desktop/AndroidProjects/CasicSmartWell/app/CasicSmartWell.jks') +// storePassword '123456789' +// keyAlias 'key0' +// keyPassword '123456789' +// } +// } + compileSdkVersion 31 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.smart.town.sanxi" + minSdkVersion 23 + targetSdkVersion 31 + versionCode 1 + versionName "1.0.0" + + manifestPlaceholders = [GETUI_APPID: "A9V4DvwLcdAqkFCQuFyhq6"] + } + + buildTypes { + release { + minifyEnabled false +// signingConfig signingConfigs.release + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + + ndk { abiFilters "armeabi", "armeabi-v7a", "arm64-v8" } + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlin { + experimental { + coroutines 'enable' + } + } + + greendao { + schemaVersion 1//数据库版本号 + targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 + daoPackage 'com.casic.smart.town.sanxi.greendao'//设置DaoMaster、DaoSession、Dao包名 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + //基础依赖库 + implementation files('libs/lite-release.aar') + implementation 'androidx.appcompat:appcompat:1.4.2' + implementation 'androidx.core:core-ktx:1.8.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:3.0.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' + //MVVM+LiveData + implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.1" + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0" + implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + //Kotlin协程 + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1' + //图片加载框架 + implementation 'com.github.bumptech.glide:glide:4.9.0' + //返回值转换器 + implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' + implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + //okhttp3日志拦截器 + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //网络请求和接口封装 + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.9.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.9.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' + //高德地图 + implementation 'com.amap.api:3dmap:latest.integration' + //推送SDK + implementation 'com.getui:gtsdk:3.2.10.0' //个推SDK + implementation 'com.getui:gtc:3.1.9.0' //个推核心组件 + //数据库框架 + implementation 'org.greenrobot:greendao:3.3.0' + //桌面角标 + implementation "me.leolin:ShortcutBadger:1.1.22@aar" +} \ No newline at end of file diff --git a/app/libs/lite-release.aar b/app/libs/lite-release.aar new file mode 100644 index 0000000..45da4df --- /dev/null +++ b/app/libs/lite-release.aar Binary files differ diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /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 \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..a83c28a --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/svg/monitor.svg b/app/src/main/assets/svg/monitor.svg new file mode 100644 index 0000000..c8d3e25 --- /dev/null +++ b/app/src/main/assets/svg/monitor.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/msg.svg b/app/src/main/assets/svg/msg.svg new file mode 100644 index 0000000..e864e48 --- /dev/null +++ b/app/src/main/assets/svg/msg.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/statistics.svg b/app/src/main/assets/svg/statistics.svg new file mode 100644 index 0000000..974000e --- /dev/null +++ b/app/src/main/assets/svg/statistics.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt new file mode 100644 index 0000000..6b9cce0 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.adapter + +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentManager +import androidx.fragment.app.FragmentPagerAdapter + +class ViewPagerAdapter(list: ArrayList, manager: FragmentManager) : + FragmentPagerAdapter(manager) { + + private var pageList: List = list + + override fun getItem(position: Int) = pageList[position] + + override fun getCount() = pageList.size +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt new file mode 100644 index 0000000..4e017b1 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt @@ -0,0 +1,40 @@ +package com.casic.smart.town.sanxi.base + +import android.app.Application +import android.util.Log +import com.casic.smart.town.sanxi.greendao.DaoMaster +import com.casic.smart.town.sanxi.greendao.DaoSession +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + private val kTag = "BaseApplication" + + companion object { + private var instance: BaseApplication by Delegates.notNull() + + fun obtainInstance() = instance + + private lateinit var daoSession: DaoSession + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences(this) + //推送 + PushManager.getInstance().initialize(this) + PushManager.getInstance().setDebugLogger(this) { + Log.d(kTag, it) + } + val devOpenHelper = DaoMaster.DevOpenHelper(this, "SmartTown.db", null) + val daoMaster = DaoMaster(devOpenHelper.writableDatabase) + daoSession = daoMaster.newSession() + } + + fun obtainDaoSession(): DaoSession { + return daoSession + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java new file mode 100644 index 0000000..b8f67dc --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java @@ -0,0 +1,133 @@ +package com.casic.smart.town.sanxi.bean; + +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Generated; +import org.greenrobot.greendao.annotation.Id; +import org.greenrobot.greendao.annotation.Unique; + +@Entity +public class AlarmMessageLocaleBean { + @Id(autoincrement = true) + private Long id;//主键自增 + + @Unique + private String messageId; + private String appId; + private String clientId; + private String taskId; + private String userId; + private String title; + private String content; + private String deviceCode; + private String isRead;//0-未读,1-已读 + private String alarmTime; + + @Generated(hash = 566950134) + public AlarmMessageLocaleBean(Long id, String messageId, String appId, + String clientId, String taskId, String userId, String title, + String content, String deviceCode, String isRead, String alarmTime) { + this.id = id; + this.messageId = messageId; + this.appId = appId; + this.clientId = clientId; + this.taskId = taskId; + this.userId = userId; + this.title = title; + this.content = content; + this.deviceCode = deviceCode; + this.isRead = isRead; + this.alarmTime = alarmTime; + } + + @Generated(hash = 1737519562) + public AlarmMessageLocaleBean() { + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getMessageId() { + return this.messageId; + } + + public void setMessageId(String messageId) { + this.messageId = messageId; + } + + public String getAppId() { + return this.appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public String getClientId() { + return this.clientId; + } + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public String getTaskId() { + return this.taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getUserId() { + return this.userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getTitle() { + return this.title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return this.content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getDeviceCode() { + return this.deviceCode; + } + + public void setDeviceCode(String deviceCode) { + this.deviceCode = deviceCode; + } + + public String getIsRead() { + return this.isRead; + } + + public void setIsRead(String isRead) { + this.isRead = isRead; + } + + public String getAlarmTime() { + return this.alarmTime; + } + + public void setAlarmTime(String alarmTime) { + this.alarmTime = alarmTime; + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt new file mode 100644 index 0000000..650e201 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class AlarmPageFragment: KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_alarm + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt new file mode 100644 index 0000000..deac8ac --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt @@ -0,0 +1,76 @@ +package com.casic.smart.town.sanxi.fragment + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.Fragment +import com.amap.api.maps.AMap +import com.amap.api.maps.AMapOptions +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.view.MonitorRecordActivity +import com.pengxh.kt.lite.extensions.navigatePageTo +import com.pengxh.kt.lite.extensions.show +import kotlinx.android.synthetic.main.fragment_monitor.view.* + +class MonitorPageFragment : Fragment() { + + private val kTag = "HomePageFragment" + private lateinit var monitorView: View + private lateinit var aMap: AMap + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? + ): View { + monitorView = inflater.inflate(R.layout.fragment_monitor, container, false) + //地图初始化 + initMap(savedInstanceState) + + monitorView.rightOperateView.setOnClickListener { + requireContext().navigatePageTo() + } + return monitorView + } + + private fun initMap(savedInstanceState: Bundle?) { + monitorView.mapView.onCreate(savedInstanceState) + aMap = monitorView.mapView.map + aMap.mapType = AMap.MAP_TYPE_NORMAL + val uiSettings = aMap.uiSettings + uiSettings.isCompassEnabled = true + uiSettings.zoomPosition = AMapOptions.ZOOM_POSITION_RIGHT_CENTER + uiSettings.isTiltGesturesEnabled = false//不许地图随手势倾斜角度 + + // 地图加载成功监听 +// aMap.addOnMapLoadedListener(this) + // 地图缩放监听 +// aMap.addOnCameraChangeListener(this) + // marker 点击事件监听 +// aMap.addOnMarkerClickListener(this) + // 点击marker弹出自定义popup +// aMap.setInfoWindowAdapter(this) + //信息窗点击事件 +// aMap.addOnInfoWindowClickListener(this) + } + + /***以下是地图生命周期管理************************************************************************/ + override fun onResume() { + super.onResume() + monitorView.mapView.onResume() + } + + override fun onPause() { + super.onPause() + monitorView.mapView.onPause() + } + + override fun onSaveInstanceState(outState: Bundle) { + super.onSaveInstanceState(outState) + monitorView.mapView.onSaveInstanceState(outState) + } + + override fun onDestroy() { + super.onDestroy() + monitorView.mapView.onDestroy() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt new file mode 100644 index 0000000..e84df12 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class StatisticsPageFragment : KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_statistics + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java new file mode 100644 index 0000000..68d7901 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java @@ -0,0 +1,255 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.database.Cursor; +import android.database.sqlite.SQLiteStatement; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.Property; +import org.greenrobot.greendao.internal.DaoConfig; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseStatement; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * DAO for table "ALARM_MESSAGE_LOCALE_BEAN". +*/ +public class AlarmMessageLocaleBeanDao extends AbstractDao { + + public static final String TABLENAME = "ALARM_MESSAGE_LOCALE_BEAN"; + + /** + * Properties of entity AlarmMessageLocaleBean.
+ * Can be used for QueryBuilder and for referencing column names. + */ + public static class Properties { + public final static Property Id = new Property(0, Long.class, "id", true, "_id"); + public final static Property MessageId = new Property(1, String.class, "messageId", false, "MESSAGE_ID"); + public final static Property AppId = new Property(2, String.class, "appId", false, "APP_ID"); + public final static Property ClientId = new Property(3, String.class, "clientId", false, "CLIENT_ID"); + public final static Property TaskId = new Property(4, String.class, "taskId", false, "TASK_ID"); + public final static Property UserId = new Property(5, String.class, "userId", false, "USER_ID"); + public final static Property Title = new Property(6, String.class, "title", false, "TITLE"); + public final static Property Content = new Property(7, String.class, "content", false, "CONTENT"); + public final static Property DeviceCode = new Property(8, String.class, "deviceCode", false, "DEVICE_CODE"); + public final static Property IsRead = new Property(9, String.class, "isRead", false, "IS_READ"); + public final static Property AlarmTime = new Property(10, String.class, "alarmTime", false, "ALARM_TIME"); + } + + + public AlarmMessageLocaleBeanDao(DaoConfig config) { + super(config); + } + + public AlarmMessageLocaleBeanDao(DaoConfig config, DaoSession daoSession) { + super(config, daoSession); + } + + /** Creates the underlying database table. */ + public static void createTable(Database db, boolean ifNotExists) { + String constraint = ifNotExists? "IF NOT EXISTS ": ""; + db.execSQL("CREATE TABLE " + constraint + "\"ALARM_MESSAGE_LOCALE_BEAN\" (" + // + "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id + "\"MESSAGE_ID\" TEXT UNIQUE ," + // 1: messageId + "\"APP_ID\" TEXT," + // 2: appId + "\"CLIENT_ID\" TEXT," + // 3: clientId + "\"TASK_ID\" TEXT," + // 4: taskId + "\"USER_ID\" TEXT," + // 5: userId + "\"TITLE\" TEXT," + // 6: title + "\"CONTENT\" TEXT," + // 7: content + "\"DEVICE_CODE\" TEXT," + // 8: deviceCode + "\"IS_READ\" TEXT," + // 9: isRead + "\"ALARM_TIME\" TEXT);"); // 10: alarmTime + } + + /** Drops the underlying database table. */ + public static void dropTable(Database db, boolean ifExists) { + String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"ALARM_MESSAGE_LOCALE_BEAN\""; + db.execSQL(sql); + } + + @Override + protected final void bindValues(DatabaseStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + protected final void bindValues(SQLiteStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + public Long readKey(Cursor cursor, int offset) { + return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); + } + + @Override + public AlarmMessageLocaleBean readEntity(Cursor cursor, int offset) { + AlarmMessageLocaleBean entity = new AlarmMessageLocaleBean( // + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // messageId + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // appId + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // clientId + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // taskId + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // userId + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // title + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // content + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // deviceCode + cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // isRead + cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10) // alarmTime + ); + return entity; + } + + @Override + public void readEntity(Cursor cursor, AlarmMessageLocaleBean entity, int offset) { + entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); + entity.setMessageId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setAppId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setClientId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setTaskId(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); + entity.setUserId(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setTitle(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setContent(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); + entity.setDeviceCode(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); + entity.setIsRead(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9)); + entity.setAlarmTime(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); + } + + @Override + protected final Long updateKeyAfterInsert(AlarmMessageLocaleBean entity, long rowId) { + entity.setId(rowId); + return rowId; + } + + @Override + public Long getKey(AlarmMessageLocaleBean entity) { + if(entity != null) { + return entity.getId(); + } else { + return null; + } + } + + @Override + public boolean hasKey(AlarmMessageLocaleBean entity) { + return entity.getId() != null; + } + + @Override + protected final boolean isEntityUpdateable() { + return true; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java new file mode 100644 index 0000000..4222c40 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java @@ -0,0 +1,96 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.content.Context; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteDatabase.CursorFactory; +import android.util.Log; + +import org.greenrobot.greendao.AbstractDaoMaster; +import org.greenrobot.greendao.database.StandardDatabase; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseOpenHelper; +import org.greenrobot.greendao.identityscope.IdentityScopeType; + + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * Master of DAO (schema version 1): knows all DAOs. + */ +public class DaoMaster extends AbstractDaoMaster { + public static final int SCHEMA_VERSION = 1; + + /** Creates underlying database table using DAOs. */ + public static void createAllTables(Database db, boolean ifNotExists) { + AlarmMessageLocaleBeanDao.createTable(db, ifNotExists); + } + + /** Drops underlying database table using DAOs. */ + public static void dropAllTables(Database db, boolean ifExists) { + AlarmMessageLocaleBeanDao.dropTable(db, ifExists); + } + + /** + * WARNING: Drops all table on Upgrade! Use only during development. + * Convenience method using a {@link DevOpenHelper}. + */ + public static DaoSession newDevSession(Context context, String name) { + Database db = new DevOpenHelper(context, name).getWritableDb(); + DaoMaster daoMaster = new DaoMaster(db); + return daoMaster.newSession(); + } + + public DaoMaster(SQLiteDatabase db) { + this(new StandardDatabase(db)); + } + + public DaoMaster(Database db) { + super(db, SCHEMA_VERSION); + registerDaoClass(AlarmMessageLocaleBeanDao.class); + } + + public DaoSession newSession() { + return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); + } + + public DaoSession newSession(IdentityScopeType type) { + return new DaoSession(db, type, daoConfigMap); + } + + /** + * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} - + */ + public static abstract class OpenHelper extends DatabaseOpenHelper { + public OpenHelper(Context context, String name) { + super(context, name, SCHEMA_VERSION); + } + + public OpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory, SCHEMA_VERSION); + } + + @Override + public void onCreate(Database db) { + Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); + createAllTables(db, false); + } + } + + /** WARNING: Drops all table on Upgrade! Use only during development. */ + public static class DevOpenHelper extends OpenHelper { + public DevOpenHelper(Context context, String name) { + super(context, name); + } + + public DevOpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory); + } + + @Override + public void onUpgrade(Database db, int oldVersion, int newVersion) { + Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); + dropAllTables(db, true); + onCreate(db); + } + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java new file mode 100644 index 0000000..480ed84 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java @@ -0,0 +1,48 @@ +package com.casic.smart.town.sanxi.greendao; + +import java.util.Map; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.AbstractDaoSession; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.identityscope.IdentityScopeType; +import org.greenrobot.greendao.internal.DaoConfig; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. + +/** + * {@inheritDoc} + * + * @see org.greenrobot.greendao.AbstractDaoSession + */ +public class DaoSession extends AbstractDaoSession { + + private final DaoConfig alarmMessageLocaleBeanDaoConfig; + + private final AlarmMessageLocaleBeanDao alarmMessageLocaleBeanDao; + + public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> + daoConfigMap) { + super(db); + + alarmMessageLocaleBeanDaoConfig = daoConfigMap.get(AlarmMessageLocaleBeanDao.class).clone(); + alarmMessageLocaleBeanDaoConfig.initIdentityScope(type); + + alarmMessageLocaleBeanDao = new AlarmMessageLocaleBeanDao(alarmMessageLocaleBeanDaoConfig, this); + + registerDao(AlarmMessageLocaleBean.class, alarmMessageLocaleBeanDao); + } + + public void clear() { + alarmMessageLocaleBeanDaoConfig.clearIdentityScope(); + } + + public AlarmMessageLocaleBeanDao getAlarmMessageLocaleBeanDao() { + return alarmMessageLocaleBeanDao; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt new file mode 100644 index 0000000..875cb8c --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt @@ -0,0 +1,5 @@ +package com.casic.smart.town.sanxi.service + +import com.igexin.sdk.PushService + +class ApplicationPushService : PushService() \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt new file mode 100644 index 0000000..396129f --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt @@ -0,0 +1,84 @@ +package com.casic.smart.town.sanxi.service + +import android.content.Context +import android.os.Message +import android.util.Log +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.casic.smart.town.sanxi.view.MainActivity +import com.igexin.sdk.GTIntentService +import com.igexin.sdk.message.GTCmdMessage +import com.igexin.sdk.message.GTNotificationMessage +import com.igexin.sdk.message.GTTransmitMessage +import com.pengxh.kt.lite.extensions.toJson + +class PushIntentService : GTIntentService() { + + private val kTag = "SmartWellIntentService" + + override fun onReceiveServicePid(context: Context?, pid: Int) { + + } + + // 透传消息 + override fun onReceiveMessageData(context: Context?, msg: GTTransmitMessage?) { + Log.d(kTag, "透传消息 -> msg = $msg") + } + + // 接收 cid + override fun onReceiveClientId(context: Context?, clientid: String?) { + Log.d(kTag, "onReceiveClientId -> $clientid") + //通知MainActivity注册个推服务 + val msg: Message = MainActivity.weakReferenceHandler.obtainMessage() + msg.what = LocaleConstant.PUSH_REGISTER + msg.obj = clientid + MainActivity.weakReferenceHandler.sendMessage(msg) + } + + // cid 离线上线通知 + override fun onReceiveOnlineState(context: Context?, online: Boolean) { + + } + + // 各种事件处理回执 + override fun onReceiveCommandResult(context: Context?, msg: GTCmdMessage?) { + + } + + // 通知到达 + override fun onNotificationMessageArrived(context: Context?, msg: GTNotificationMessage?) { + //报警 +// { +// "content": "设备编号[412022030361]发生井盖开盖报警", +// "messageId": "380abf9a79d34306a2683dc9bf96ee78", +// "taskId": "OSL-0830_4hmfimp3Vu684wo3SjXso9", +// "title": "告警提醒", +// "appid": "HKv8K9qARd6WckZ1o2Vbu4", +// "clientId": "e78beacc42e9a02ae6fb9087eb2b1171", +// "pkgName": "com.casic.app.smartwell" +// } + if (msg == null) { + return + } + Log.d(kTag, "通知到达 -> msg = ${msg.toJson()}") +// val userDetailJson = SaveKeyValues.getValue(LocaleConstant.USER_DETAIL_MODEL, "") as String +// var userId = "" +// if (userDetailJson.isNotBlank()) { +// val userDataModel = Gson().fromJson( +// userDetailJson, object : TypeToken() {}.type +// ) +// userId = userDataModel.id.toString() +// } +// //解析编号 +// val splitArray = msg.content.split("\\[|\\]".toRegex()) +// DataBaseManager.instance.insertNotice( +// msg.messageId, msg.appid, msg.clientId, msg.taskId, +// userId, msg.title, msg.content, splitArray[1], "0", +// System.currentTimeMillis().timestampToCompleteDate() +// ) + } + + // 通知点击 + override fun onNotificationMessageClicked(context: Context?, msg: GTNotificationMessage?) { + Log.d(kTag, "通知点击 -> msg = $msg") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt new file mode 100644 index 0000000..daa7c38 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt @@ -0,0 +1,14 @@ +package com.casic.smart.town.sanxi.util + +import android.content.Context +import me.leolin.shortcutbadger.ShortcutBadger + +object BadeHelper { + fun setBadgeNum(context: Context, badgeCount: Int) { + if (badgeCount == 0) { + ShortcutBadger.removeCount(context) + } else { + ShortcutBadger.applyCount(context, badgeCount) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt new file mode 100644 index 0000000..0a52ef2 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt @@ -0,0 +1,75 @@ +package com.casic.smart.town.sanxi.util + +import com.casic.smart.town.sanxi.base.BaseApplication +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao + +class DataBaseManager private constructor() { + + companion object { + //Kotlin委托模式双重锁单例 + val instance: DataBaseManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) { + DataBaseManager() + } + } + + private val beanDao = + BaseApplication.obtainInstance().obtainDaoSession().alarmMessageLocaleBeanDao + +// fun insertNotice( +// messageId: String, appid: String, clientId: String, +// taskId: String, userId: String, title: String, +// content: String, deviceCode: String, isRead: String, +// noticeTime: String +// ) { +// val noticeLocaleBean = NoticeLocaleBean() +// noticeLocaleBean.messageId = messageId +// noticeLocaleBean.appid = appid +// noticeLocaleBean.clientId = clientId +// noticeLocaleBean.taskId = taskId +// noticeLocaleBean.userId = userId +// noticeLocaleBean.title = title +// noticeLocaleBean.content = content +// noticeLocaleBean.deviceCode = deviceCode +// noticeLocaleBean.isRead = isRead +// noticeLocaleBean.noticeTime = noticeTime +// beanDao.insert(noticeLocaleBean) +// //角标设置 +// BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadNotice()) +// } + + fun deleteByMessageId(messageId: String) { + val result = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).list() + beanDao.deleteInTx(result) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun updateNoticeByMessageId(messageId: String) { + val noticeLocaleBean = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).unique() ?: return + noticeLocaleBean.isRead = "1" + beanDao.update(noticeLocaleBean) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun queryMessageByPage(userId: String, offset: Int): MutableList { + return BaseApplication.obtainInstance().obtainDaoSession() + .queryBuilder(AlarmMessageLocaleBean::class.java) + .where(AlarmMessageLocaleBeanDao.Properties.UserId.eq(userId)) + .offset(offset * LocaleConstant.PAGE_LIMIT) + .orderDesc(AlarmMessageLocaleBeanDao.Properties.AlarmTime) + .limit(LocaleConstant.PAGE_LIMIT) + .list() + } + + private fun queryUnReadMessage(): Int { + return beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.IsRead.eq("0") + ).list().size + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt new file mode 100644 index 0000000..52926a8 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt @@ -0,0 +1,31 @@ +package com.casic.smart.town.sanxi.util; + +import android.app.Activity +import android.view.WindowManager +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object LoadingDialogHub { + private lateinit var loadingDialog: QMUITipDialog + + fun show(activity: Activity, message: String) { + loadingDialog = QMUITipDialog + .Builder(activity) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_LOADING) + .setTipWord(message) + .create() + if (!activity.isDestroyed) { + try { + loadingDialog.show() + } catch (e: WindowManager.BadTokenException) { + e.printStackTrace() + } + } + } + + + fun dismiss() { + if (loadingDialog.isShowing) { + loadingDialog.dismiss() + } + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt new file mode 100644 index 0000000..de61c9a --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.util + +import android.Manifest + +object LocaleConstant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.READ_PHONE_STATE, + Manifest.permission.ACCESS_COARSE_LOCATION, + Manifest.permission.READ_EXTERNAL_STORAGE + ) + + const val PERMISSIONS_CODE = 999 + const val PUSH_REGISTER = 2022100101 + const val PAGE_LIMIT = 20 +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt new file mode 100644 index 0000000..3bea1c9 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt @@ -0,0 +1,112 @@ +package com.casic.smart.town.sanxi.view + +import android.view.KeyEvent +import android.view.MenuItem +import androidx.fragment.app.Fragment +import androidx.viewpager.widget.ViewPager +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.adapter.ViewPagerAdapter +import com.casic.smart.town.sanxi.fragment.AlarmPageFragment +import com.casic.smart.town.sanxi.fragment.MonitorPageFragment +import com.casic.smart.town.sanxi.fragment.StatisticsPageFragment +import com.gyf.immersionbar.ImmersionBar +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.base.KotlinBaseActivity +import com.pengxh.kt.lite.extensions.convertColor +import com.pengxh.kt.lite.extensions.show +import com.pengxh.kt.lite.utils.ImmerseStatusBarUtil +import com.pengxh.kt.lite.utils.WeakReferenceHandler +import kotlinx.android.synthetic.main.activity_main.* + +class MainActivity : KotlinBaseActivity() { + + companion object { + lateinit var weakReferenceHandler: WeakReferenceHandler + } + + private val kTag = "MainActivity" + private var menuItem: MenuItem? = null + private var fragmentPages: ArrayList = ArrayList() + private var clickTime: Long = 0 + + init { + fragmentPages.add(StatisticsPageFragment()) + fragmentPages.add(MonitorPageFragment()) + fragmentPages.add(AlarmPageFragment()) + } + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + ImmersionBar.with(this).statusBarDarkFont(false).init() + ImmerseStatusBarUtil.setColor(this, R.color.mainThemeColor.convertColor(this)) + } + + override fun initData() { + //推送,多次调用 SDK 初始化并无影响。 + PushManager.getInstance().initialize(this) + weakReferenceHandler = WeakReferenceHandler { + + true + } + } + + override fun observeRequestState() { + + } + + override fun initEvent() { + bottomNavigation.itemIconTintList = null + bottomNavigation.setOnNavigationItemSelectedListener { menuItem -> + when (menuItem.itemId) { + R.id.nav_statistics -> { + mainViewPager.currentItem = 0 + } + R.id.nav_monitor -> { + mainViewPager.currentItem = 1 + } + R.id.nav_alarm -> { + mainViewPager.currentItem = 2 + } + } + false + } + mainViewPager.adapter = ViewPagerAdapter(fragmentPages, supportFragmentManager) + mainViewPager.offscreenPageLimit = fragmentPages.size //缓存页数 + mainViewPager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener { + override fun onPageScrollStateChanged(state: Int) { + + } + + override fun onPageScrolled( + position: Int, + positionOffset: Float, + positionOffsetPixels: Int + ) { + + } + + override fun onPageSelected(position: Int) { + if (menuItem != null) { + menuItem!!.isChecked = false + } else { + bottomNavigation.menu.getItem(0).isChecked = false + } + menuItem = bottomNavigation.menu.getItem(position) + menuItem!!.isChecked = true + } + }) + } + + override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean { + return if (keyCode == KeyEvent.KEYCODE_BACK) { + if (System.currentTimeMillis() - clickTime > 2000) { + "再按一次退出程序".show(this) + clickTime = System.currentTimeMillis() + true + } else { + super.onKeyDown(keyCode, event) + } + } else super.onKeyDown(keyCode, event) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt new file mode 100644 index 0000000..c5d8b22 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.view + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseActivity + +class MonitorRecordActivity : KotlinBaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_monitor_record + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt new file mode 100644 index 0000000..c478d83 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt @@ -0,0 +1,55 @@ +package com.casic.smart.town.sanxi.view + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.amap.api.maps.MapsInitializer +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.gyf.immersionbar.ImmersionBar +import com.pengxh.kt.lite.extensions.navigatePageTo +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + ImmersionBar.with(this).statusBarDarkFont(true).init() + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (EasyPermissions.hasPermissions(this, *LocaleConstant.USER_PERMISSIONS)) { + startSplashScreenActivity() + } else { + EasyPermissions.requestPermissions( + this@PermissionActivity, + resources.getString(R.string.app_name) + "需要获取相关权限", + LocaleConstant.PERMISSIONS_CODE, + *LocaleConstant.USER_PERMISSIONS + ) + } + } + + private fun startSplashScreenActivity() { + //先把导航隐私政策声明,后面导航会用到 + MapsInitializer.updatePrivacyAgree(this, true) + MapsInitializer.updatePrivacyShow(this, true, true) + this.navigatePageTo() + 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) { + startSplashScreenActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable/alarm_selector.xml b/app/src/main/res/drawable/alarm_selector.xml new file mode 100644 index 0000000..39b2595 --- /dev/null +++ b/app/src/main/res/drawable/alarm_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bottom_text_color.xml b/app/src/main/res/drawable/bottom_text_color.xml new file mode 100644 index 0000000..b284ea3 --- /dev/null +++ b/app/src/main/res/drawable/bottom_text_color.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_alarm.xml b/app/src/main/res/drawable/ic_alarm.xml new file mode 100644 index 0000000..dc33aab --- /dev/null +++ b/app/src/main/res/drawable/ic_alarm.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_alarm_selected.xml b/app/src/main/res/drawable/ic_alarm_selected.xml new file mode 100644 index 0000000..993fea6 --- /dev/null +++ b/app/src/main/res/drawable/ic_alarm_selected.xml @@ -0,0 +1,9 @@ + + + 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_monitor.xml b/app/src/main/res/drawable/ic_monitor.xml new file mode 100644 index 0000000..271f5b4 --- /dev/null +++ b/app/src/main/res/drawable/ic_monitor.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_monitor_selected.xml b/app/src/main/res/drawable/ic_monitor_selected.xml new file mode 100644 index 0000000..ee62d84 --- /dev/null +++ b/app/src/main/res/drawable/ic_monitor_selected.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_statistics.xml b/app/src/main/res/drawable/ic_statistics.xml new file mode 100644 index 0000000..7fde8ec --- /dev/null +++ b/app/src/main/res/drawable/ic_statistics.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_statistics_selected.xml b/app/src/main/res/drawable/ic_statistics_selected.xml new file mode 100644 index 0000000..49b6fcd --- /dev/null +++ b/app/src/main/res/drawable/ic_statistics_selected.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/monitor_selector.xml b/app/src/main/res/drawable/monitor_selector.xml new file mode 100644 index 0000000..fe11e9a --- /dev/null +++ b/app/src/main/res/drawable/monitor_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/statistics_selector.xml b/app/src/main/res/drawable/statistics_selector.xml new file mode 100644 index 0000000..2156cff --- /dev/null +++ b/app/src/main/res/drawable/statistics_selector.xml @@ -0,0 +1,5 @@ + + + + + \ 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..78a4a94 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,27 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_monitor_record.xml b/app/src/main/res/layout/activity_monitor_record.xml new file mode 100644 index 0000000..77d9ef6 --- /dev/null +++ b/app/src/main/res/layout/activity_monitor_record.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_alarm.xml b/app/src/main/res/layout/fragment_alarm.xml new file mode 100644 index 0000000..77d9ef6 --- /dev/null +++ b/app/src/main/res/layout/fragment_alarm.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_monitor.xml b/app/src/main/res/layout/fragment_monitor.xml new file mode 100644 index 0000000..19789c1 --- /dev/null +++ b/app/src/main/res/layout/fragment_monitor.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_statistics.xml b/app/src/main/res/layout/fragment_statistics.xml new file mode 100644 index 0000000..77d9ef6 --- /dev/null +++ b/app/src/main/res/layout/fragment_statistics.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/menu/bottom_nav_menu.xml b/app/src/main/res/menu/bottom_nav_menu.xml new file mode 100644 index 0000000..751fd61 --- /dev/null +++ b/app/src/main/res/menu/bottom_nav_menu.xml @@ -0,0 +1,29 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.webp b/app/src/main/res/mipmap-hdpi/ic_launcher.webp new file mode 100644 index 0000000..c209e78 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp new file mode 100644 index 0000000..b2dfe3d --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.webp b/app/src/main/res/mipmap-mdpi/ic_launcher.webp new file mode 100644 index 0000000..4f0f1d6 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp new file mode 100644 index 0000000..62b611d --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher.webp new file mode 100644 index 0000000..948a307 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..1b9a695 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp Binary files differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp new file mode 100644 index 0000000..28d4b77 --- /dev/null +++ b/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..9287f50 --- /dev/null +++ b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp new file mode 100644 index 0000000..aa7d642 --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..9126ae3 --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp 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..bbce66f --- /dev/null +++ b/app/src/main/res/values/colors.xml @@ -0,0 +1,14 @@ + + + #1D55C6 + #333333 + #CCCCCC + + #FFBB86FC + #FF6200EE + #FF3700B3 + #FF03DAC5 + #FF018786 + #FF000000 + #FFFFFFFF + \ No newline at end of file diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml new file mode 100644 index 0000000..b7a9292 --- /dev/null +++ b/app/src/main/res/values/dimens.xml @@ -0,0 +1,33 @@ + + + + 12sp + 14sp + 16sp + 18sp + 20sp + 22sp + + + 3dp + 5dp + 7dp + 10dp + 15dp + 20dp + 25dp + 30dp + 35dp + 40dp + 45dp + 50dp + 55dp + 60dp + 75dp + + + 1dp + + + 45dp + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml new file mode 100644 index 0000000..f636245 --- /dev/null +++ b/app/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + SmartTown + \ No newline at end of file diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml new file mode 100644 index 0000000..635e8e0 --- /dev/null +++ b/app/src/main/res/values/themes.xml @@ -0,0 +1,16 @@ + + + + \ No newline at end of file diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..62b9d90 --- /dev/null +++ b/build.gradle @@ -0,0 +1,30 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. +buildscript { + ext.kotlin_version = '1.6.10' + repositories { + maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' } + google() + } + dependencies { + classpath 'com.android.tools.build:gradle:3.6.4' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + classpath 'org.greenrobot:greendao-gradle-plugin:3.3.0' + + // 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() + maven { url "https://mvn.getui.com/nexus/content/repositories/releases/"} + } +} + +task clean(type: Delete) { + delete rootProject.buildDir +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..98bed16 --- /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=-Xmx2048m -Dfile.encoding=UTF-8 +# 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 \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..e708b1c --- /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..35bda37 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Sat Oct 08 09:41:32 CST 2022 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip diff --git a/gradlew b/gradlew new file mode 100755 index 0000000..4f906e0 --- /dev/null +++ b/gradlew @@ -0,0 +1,185 @@ +#!/usr/bin/env sh + +# +# Copyright 2015 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +## +## 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='"-Xmx64m" "-Xms64m"' + +# 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 or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; 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=`expr $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" + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..107acd3 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,89 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@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 Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@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="-Xmx64m" "-Xms64m" + +@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 execute + +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 execute + +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 + +: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 %* + +: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..10cfdbf --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*.iml +.gradle +/local.properties +/.idea +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..a4cd2ca --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,101 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'org.greenrobot.greendao' + +android { +// signingConfigs { +// release { +// storeFile file('/Users/a203/Desktop/AndroidProjects/CasicSmartWell/app/CasicSmartWell.jks') +// storePassword '123456789' +// keyAlias 'key0' +// keyPassword '123456789' +// } +// } + compileSdkVersion 31 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.casic.smart.town.sanxi" + minSdkVersion 23 + targetSdkVersion 31 + versionCode 1 + versionName "1.0.0" + + manifestPlaceholders = [GETUI_APPID: "A9V4DvwLcdAqkFCQuFyhq6"] + } + + buildTypes { + release { + minifyEnabled false +// signingConfig signingConfigs.release + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + + ndk { abiFilters "armeabi", "armeabi-v7a", "arm64-v8" } + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlin { + experimental { + coroutines 'enable' + } + } + + greendao { + schemaVersion 1//数据库版本号 + targetGenDir 'src/main/java'//设置DaoMaster、DaoSession、Dao目录 + daoPackage 'com.casic.smart.town.sanxi.greendao'//设置DaoMaster、DaoSession、Dao包名 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + //基础依赖库 + implementation files('libs/lite-release.aar') + implementation 'androidx.appcompat:appcompat:1.4.2' + implementation 'androidx.core:core-ktx:1.8.0' + //Google官方授权框架 + implementation 'pub.devrel:easypermissions:3.0.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' + //MVVM+LiveData + implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.1" + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0" + implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" + //Kotlin协程 + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1' + //图片加载框架 + implementation 'com.github.bumptech.glide:glide:4.9.0' + //返回值转换器 + implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' + implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' + implementation 'com.squareup.retrofit2:converter-gson:2.8.1' + //okhttp3日志拦截器 + implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0' + //网络请求和接口封装 + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.9.0' + //官方Json解析库 + implementation 'com.google.code.gson:gson:2.9.0' + //上拉加载下拉刷新 + implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' + //高德地图 + implementation 'com.amap.api:3dmap:latest.integration' + //推送SDK + implementation 'com.getui:gtsdk:3.2.10.0' //个推SDK + implementation 'com.getui:gtc:3.1.9.0' //个推核心组件 + //数据库框架 + implementation 'org.greenrobot:greendao:3.3.0' + //桌面角标 + implementation "me.leolin:ShortcutBadger:1.1.22@aar" +} \ No newline at end of file diff --git a/app/libs/lite-release.aar b/app/libs/lite-release.aar new file mode 100644 index 0000000..45da4df --- /dev/null +++ b/app/libs/lite-release.aar Binary files differ diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /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 \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..a83c28a --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/svg/monitor.svg b/app/src/main/assets/svg/monitor.svg new file mode 100644 index 0000000..c8d3e25 --- /dev/null +++ b/app/src/main/assets/svg/monitor.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/msg.svg b/app/src/main/assets/svg/msg.svg new file mode 100644 index 0000000..e864e48 --- /dev/null +++ b/app/src/main/assets/svg/msg.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/assets/svg/statistics.svg b/app/src/main/assets/svg/statistics.svg new file mode 100644 index 0000000..974000e --- /dev/null +++ b/app/src/main/assets/svg/statistics.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt new file mode 100644 index 0000000..6b9cce0 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/adapter/ViewPagerAdapter.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.adapter + +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentManager +import androidx.fragment.app.FragmentPagerAdapter + +class ViewPagerAdapter(list: ArrayList, manager: FragmentManager) : + FragmentPagerAdapter(manager) { + + private var pageList: List = list + + override fun getItem(position: Int) = pageList[position] + + override fun getCount() = pageList.size +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt new file mode 100644 index 0000000..4e017b1 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/base/BaseApplication.kt @@ -0,0 +1,40 @@ +package com.casic.smart.town.sanxi.base + +import android.app.Application +import android.util.Log +import com.casic.smart.town.sanxi.greendao.DaoMaster +import com.casic.smart.town.sanxi.greendao.DaoSession +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.utils.SaveKeyValues +import kotlin.properties.Delegates + +class BaseApplication : Application() { + + private val kTag = "BaseApplication" + + companion object { + private var instance: BaseApplication by Delegates.notNull() + + fun obtainInstance() = instance + + private lateinit var daoSession: DaoSession + } + + override fun onCreate() { + super.onCreate() + instance = this + SaveKeyValues.initSharedPreferences(this) + //推送 + PushManager.getInstance().initialize(this) + PushManager.getInstance().setDebugLogger(this) { + Log.d(kTag, it) + } + val devOpenHelper = DaoMaster.DevOpenHelper(this, "SmartTown.db", null) + val daoMaster = DaoMaster(devOpenHelper.writableDatabase) + daoSession = daoMaster.newSession() + } + + fun obtainDaoSession(): DaoSession { + return daoSession + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java new file mode 100644 index 0000000..b8f67dc --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/bean/AlarmMessageLocaleBean.java @@ -0,0 +1,133 @@ +package com.casic.smart.town.sanxi.bean; + +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Generated; +import org.greenrobot.greendao.annotation.Id; +import org.greenrobot.greendao.annotation.Unique; + +@Entity +public class AlarmMessageLocaleBean { + @Id(autoincrement = true) + private Long id;//主键自增 + + @Unique + private String messageId; + private String appId; + private String clientId; + private String taskId; + private String userId; + private String title; + private String content; + private String deviceCode; + private String isRead;//0-未读,1-已读 + private String alarmTime; + + @Generated(hash = 566950134) + public AlarmMessageLocaleBean(Long id, String messageId, String appId, + String clientId, String taskId, String userId, String title, + String content, String deviceCode, String isRead, String alarmTime) { + this.id = id; + this.messageId = messageId; + this.appId = appId; + this.clientId = clientId; + this.taskId = taskId; + this.userId = userId; + this.title = title; + this.content = content; + this.deviceCode = deviceCode; + this.isRead = isRead; + this.alarmTime = alarmTime; + } + + @Generated(hash = 1737519562) + public AlarmMessageLocaleBean() { + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getMessageId() { + return this.messageId; + } + + public void setMessageId(String messageId) { + this.messageId = messageId; + } + + public String getAppId() { + return this.appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public String getClientId() { + return this.clientId; + } + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public String getTaskId() { + return this.taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getUserId() { + return this.userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getTitle() { + return this.title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return this.content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getDeviceCode() { + return this.deviceCode; + } + + public void setDeviceCode(String deviceCode) { + this.deviceCode = deviceCode; + } + + public String getIsRead() { + return this.isRead; + } + + public void setIsRead(String isRead) { + this.isRead = isRead; + } + + public String getAlarmTime() { + return this.alarmTime; + } + + public void setAlarmTime(String alarmTime) { + this.alarmTime = alarmTime; + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt new file mode 100644 index 0000000..650e201 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/AlarmPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class AlarmPageFragment: KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_alarm + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt new file mode 100644 index 0000000..deac8ac --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt @@ -0,0 +1,76 @@ +package com.casic.smart.town.sanxi.fragment + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.Fragment +import com.amap.api.maps.AMap +import com.amap.api.maps.AMapOptions +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.view.MonitorRecordActivity +import com.pengxh.kt.lite.extensions.navigatePageTo +import com.pengxh.kt.lite.extensions.show +import kotlinx.android.synthetic.main.fragment_monitor.view.* + +class MonitorPageFragment : Fragment() { + + private val kTag = "HomePageFragment" + private lateinit var monitorView: View + private lateinit var aMap: AMap + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? + ): View { + monitorView = inflater.inflate(R.layout.fragment_monitor, container, false) + //地图初始化 + initMap(savedInstanceState) + + monitorView.rightOperateView.setOnClickListener { + requireContext().navigatePageTo() + } + return monitorView + } + + private fun initMap(savedInstanceState: Bundle?) { + monitorView.mapView.onCreate(savedInstanceState) + aMap = monitorView.mapView.map + aMap.mapType = AMap.MAP_TYPE_NORMAL + val uiSettings = aMap.uiSettings + uiSettings.isCompassEnabled = true + uiSettings.zoomPosition = AMapOptions.ZOOM_POSITION_RIGHT_CENTER + uiSettings.isTiltGesturesEnabled = false//不许地图随手势倾斜角度 + + // 地图加载成功监听 +// aMap.addOnMapLoadedListener(this) + // 地图缩放监听 +// aMap.addOnCameraChangeListener(this) + // marker 点击事件监听 +// aMap.addOnMarkerClickListener(this) + // 点击marker弹出自定义popup +// aMap.setInfoWindowAdapter(this) + //信息窗点击事件 +// aMap.addOnInfoWindowClickListener(this) + } + + /***以下是地图生命周期管理************************************************************************/ + override fun onResume() { + super.onResume() + monitorView.mapView.onResume() + } + + override fun onPause() { + super.onPause() + monitorView.mapView.onPause() + } + + override fun onSaveInstanceState(outState: Bundle) { + super.onSaveInstanceState(outState) + monitorView.mapView.onSaveInstanceState(outState) + } + + override fun onDestroy() { + super.onDestroy() + monitorView.mapView.onDestroy() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt new file mode 100644 index 0000000..e84df12 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/StatisticsPageFragment.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.fragment + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseFragment + +class StatisticsPageFragment : KotlinBaseFragment() { + + override fun initLayoutView(): Int = R.layout.fragment_statistics + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java new file mode 100644 index 0000000..68d7901 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/AlarmMessageLocaleBeanDao.java @@ -0,0 +1,255 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.database.Cursor; +import android.database.sqlite.SQLiteStatement; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.Property; +import org.greenrobot.greendao.internal.DaoConfig; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseStatement; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * DAO for table "ALARM_MESSAGE_LOCALE_BEAN". +*/ +public class AlarmMessageLocaleBeanDao extends AbstractDao { + + public static final String TABLENAME = "ALARM_MESSAGE_LOCALE_BEAN"; + + /** + * Properties of entity AlarmMessageLocaleBean.
+ * Can be used for QueryBuilder and for referencing column names. + */ + public static class Properties { + public final static Property Id = new Property(0, Long.class, "id", true, "_id"); + public final static Property MessageId = new Property(1, String.class, "messageId", false, "MESSAGE_ID"); + public final static Property AppId = new Property(2, String.class, "appId", false, "APP_ID"); + public final static Property ClientId = new Property(3, String.class, "clientId", false, "CLIENT_ID"); + public final static Property TaskId = new Property(4, String.class, "taskId", false, "TASK_ID"); + public final static Property UserId = new Property(5, String.class, "userId", false, "USER_ID"); + public final static Property Title = new Property(6, String.class, "title", false, "TITLE"); + public final static Property Content = new Property(7, String.class, "content", false, "CONTENT"); + public final static Property DeviceCode = new Property(8, String.class, "deviceCode", false, "DEVICE_CODE"); + public final static Property IsRead = new Property(9, String.class, "isRead", false, "IS_READ"); + public final static Property AlarmTime = new Property(10, String.class, "alarmTime", false, "ALARM_TIME"); + } + + + public AlarmMessageLocaleBeanDao(DaoConfig config) { + super(config); + } + + public AlarmMessageLocaleBeanDao(DaoConfig config, DaoSession daoSession) { + super(config, daoSession); + } + + /** Creates the underlying database table. */ + public static void createTable(Database db, boolean ifNotExists) { + String constraint = ifNotExists? "IF NOT EXISTS ": ""; + db.execSQL("CREATE TABLE " + constraint + "\"ALARM_MESSAGE_LOCALE_BEAN\" (" + // + "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id + "\"MESSAGE_ID\" TEXT UNIQUE ," + // 1: messageId + "\"APP_ID\" TEXT," + // 2: appId + "\"CLIENT_ID\" TEXT," + // 3: clientId + "\"TASK_ID\" TEXT," + // 4: taskId + "\"USER_ID\" TEXT," + // 5: userId + "\"TITLE\" TEXT," + // 6: title + "\"CONTENT\" TEXT," + // 7: content + "\"DEVICE_CODE\" TEXT," + // 8: deviceCode + "\"IS_READ\" TEXT," + // 9: isRead + "\"ALARM_TIME\" TEXT);"); // 10: alarmTime + } + + /** Drops the underlying database table. */ + public static void dropTable(Database db, boolean ifExists) { + String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"ALARM_MESSAGE_LOCALE_BEAN\""; + db.execSQL(sql); + } + + @Override + protected final void bindValues(DatabaseStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + protected final void bindValues(SQLiteStatement stmt, AlarmMessageLocaleBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String messageId = entity.getMessageId(); + if (messageId != null) { + stmt.bindString(2, messageId); + } + + String appId = entity.getAppId(); + if (appId != null) { + stmt.bindString(3, appId); + } + + String clientId = entity.getClientId(); + if (clientId != null) { + stmt.bindString(4, clientId); + } + + String taskId = entity.getTaskId(); + if (taskId != null) { + stmt.bindString(5, taskId); + } + + String userId = entity.getUserId(); + if (userId != null) { + stmt.bindString(6, userId); + } + + String title = entity.getTitle(); + if (title != null) { + stmt.bindString(7, title); + } + + String content = entity.getContent(); + if (content != null) { + stmt.bindString(8, content); + } + + String deviceCode = entity.getDeviceCode(); + if (deviceCode != null) { + stmt.bindString(9, deviceCode); + } + + String isRead = entity.getIsRead(); + if (isRead != null) { + stmt.bindString(10, isRead); + } + + String alarmTime = entity.getAlarmTime(); + if (alarmTime != null) { + stmt.bindString(11, alarmTime); + } + } + + @Override + public Long readKey(Cursor cursor, int offset) { + return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); + } + + @Override + public AlarmMessageLocaleBean readEntity(Cursor cursor, int offset) { + AlarmMessageLocaleBean entity = new AlarmMessageLocaleBean( // + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // messageId + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // appId + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // clientId + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // taskId + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // userId + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // title + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // content + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // deviceCode + cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // isRead + cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10) // alarmTime + ); + return entity; + } + + @Override + public void readEntity(Cursor cursor, AlarmMessageLocaleBean entity, int offset) { + entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); + entity.setMessageId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setAppId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setClientId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setTaskId(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); + entity.setUserId(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setTitle(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setContent(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); + entity.setDeviceCode(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); + entity.setIsRead(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9)); + entity.setAlarmTime(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); + } + + @Override + protected final Long updateKeyAfterInsert(AlarmMessageLocaleBean entity, long rowId) { + entity.setId(rowId); + return rowId; + } + + @Override + public Long getKey(AlarmMessageLocaleBean entity) { + if(entity != null) { + return entity.getId(); + } else { + return null; + } + } + + @Override + public boolean hasKey(AlarmMessageLocaleBean entity) { + return entity.getId() != null; + } + + @Override + protected final boolean isEntityUpdateable() { + return true; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java new file mode 100644 index 0000000..4222c40 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoMaster.java @@ -0,0 +1,96 @@ +package com.casic.smart.town.sanxi.greendao; + +import android.content.Context; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteDatabase.CursorFactory; +import android.util.Log; + +import org.greenrobot.greendao.AbstractDaoMaster; +import org.greenrobot.greendao.database.StandardDatabase; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseOpenHelper; +import org.greenrobot.greendao.identityscope.IdentityScopeType; + + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * Master of DAO (schema version 1): knows all DAOs. + */ +public class DaoMaster extends AbstractDaoMaster { + public static final int SCHEMA_VERSION = 1; + + /** Creates underlying database table using DAOs. */ + public static void createAllTables(Database db, boolean ifNotExists) { + AlarmMessageLocaleBeanDao.createTable(db, ifNotExists); + } + + /** Drops underlying database table using DAOs. */ + public static void dropAllTables(Database db, boolean ifExists) { + AlarmMessageLocaleBeanDao.dropTable(db, ifExists); + } + + /** + * WARNING: Drops all table on Upgrade! Use only during development. + * Convenience method using a {@link DevOpenHelper}. + */ + public static DaoSession newDevSession(Context context, String name) { + Database db = new DevOpenHelper(context, name).getWritableDb(); + DaoMaster daoMaster = new DaoMaster(db); + return daoMaster.newSession(); + } + + public DaoMaster(SQLiteDatabase db) { + this(new StandardDatabase(db)); + } + + public DaoMaster(Database db) { + super(db, SCHEMA_VERSION); + registerDaoClass(AlarmMessageLocaleBeanDao.class); + } + + public DaoSession newSession() { + return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); + } + + public DaoSession newSession(IdentityScopeType type) { + return new DaoSession(db, type, daoConfigMap); + } + + /** + * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} - + */ + public static abstract class OpenHelper extends DatabaseOpenHelper { + public OpenHelper(Context context, String name) { + super(context, name, SCHEMA_VERSION); + } + + public OpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory, SCHEMA_VERSION); + } + + @Override + public void onCreate(Database db) { + Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); + createAllTables(db, false); + } + } + + /** WARNING: Drops all table on Upgrade! Use only during development. */ + public static class DevOpenHelper extends OpenHelper { + public DevOpenHelper(Context context, String name) { + super(context, name); + } + + public DevOpenHelper(Context context, String name, CursorFactory factory) { + super(context, name, factory); + } + + @Override + public void onUpgrade(Database db, int oldVersion, int newVersion) { + Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); + dropAllTables(db, true); + onCreate(db); + } + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java new file mode 100644 index 0000000..480ed84 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/greendao/DaoSession.java @@ -0,0 +1,48 @@ +package com.casic.smart.town.sanxi.greendao; + +import java.util.Map; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.AbstractDaoSession; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.identityscope.IdentityScopeType; +import org.greenrobot.greendao.internal.DaoConfig; + +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean; + +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. + +/** + * {@inheritDoc} + * + * @see org.greenrobot.greendao.AbstractDaoSession + */ +public class DaoSession extends AbstractDaoSession { + + private final DaoConfig alarmMessageLocaleBeanDaoConfig; + + private final AlarmMessageLocaleBeanDao alarmMessageLocaleBeanDao; + + public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> + daoConfigMap) { + super(db); + + alarmMessageLocaleBeanDaoConfig = daoConfigMap.get(AlarmMessageLocaleBeanDao.class).clone(); + alarmMessageLocaleBeanDaoConfig.initIdentityScope(type); + + alarmMessageLocaleBeanDao = new AlarmMessageLocaleBeanDao(alarmMessageLocaleBeanDaoConfig, this); + + registerDao(AlarmMessageLocaleBean.class, alarmMessageLocaleBeanDao); + } + + public void clear() { + alarmMessageLocaleBeanDaoConfig.clearIdentityScope(); + } + + public AlarmMessageLocaleBeanDao getAlarmMessageLocaleBeanDao() { + return alarmMessageLocaleBeanDao; + } + +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt new file mode 100644 index 0000000..875cb8c --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/ApplicationPushService.kt @@ -0,0 +1,5 @@ +package com.casic.smart.town.sanxi.service + +import com.igexin.sdk.PushService + +class ApplicationPushService : PushService() \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt new file mode 100644 index 0000000..396129f --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/service/PushIntentService.kt @@ -0,0 +1,84 @@ +package com.casic.smart.town.sanxi.service + +import android.content.Context +import android.os.Message +import android.util.Log +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.casic.smart.town.sanxi.view.MainActivity +import com.igexin.sdk.GTIntentService +import com.igexin.sdk.message.GTCmdMessage +import com.igexin.sdk.message.GTNotificationMessage +import com.igexin.sdk.message.GTTransmitMessage +import com.pengxh.kt.lite.extensions.toJson + +class PushIntentService : GTIntentService() { + + private val kTag = "SmartWellIntentService" + + override fun onReceiveServicePid(context: Context?, pid: Int) { + + } + + // 透传消息 + override fun onReceiveMessageData(context: Context?, msg: GTTransmitMessage?) { + Log.d(kTag, "透传消息 -> msg = $msg") + } + + // 接收 cid + override fun onReceiveClientId(context: Context?, clientid: String?) { + Log.d(kTag, "onReceiveClientId -> $clientid") + //通知MainActivity注册个推服务 + val msg: Message = MainActivity.weakReferenceHandler.obtainMessage() + msg.what = LocaleConstant.PUSH_REGISTER + msg.obj = clientid + MainActivity.weakReferenceHandler.sendMessage(msg) + } + + // cid 离线上线通知 + override fun onReceiveOnlineState(context: Context?, online: Boolean) { + + } + + // 各种事件处理回执 + override fun onReceiveCommandResult(context: Context?, msg: GTCmdMessage?) { + + } + + // 通知到达 + override fun onNotificationMessageArrived(context: Context?, msg: GTNotificationMessage?) { + //报警 +// { +// "content": "设备编号[412022030361]发生井盖开盖报警", +// "messageId": "380abf9a79d34306a2683dc9bf96ee78", +// "taskId": "OSL-0830_4hmfimp3Vu684wo3SjXso9", +// "title": "告警提醒", +// "appid": "HKv8K9qARd6WckZ1o2Vbu4", +// "clientId": "e78beacc42e9a02ae6fb9087eb2b1171", +// "pkgName": "com.casic.app.smartwell" +// } + if (msg == null) { + return + } + Log.d(kTag, "通知到达 -> msg = ${msg.toJson()}") +// val userDetailJson = SaveKeyValues.getValue(LocaleConstant.USER_DETAIL_MODEL, "") as String +// var userId = "" +// if (userDetailJson.isNotBlank()) { +// val userDataModel = Gson().fromJson( +// userDetailJson, object : TypeToken() {}.type +// ) +// userId = userDataModel.id.toString() +// } +// //解析编号 +// val splitArray = msg.content.split("\\[|\\]".toRegex()) +// DataBaseManager.instance.insertNotice( +// msg.messageId, msg.appid, msg.clientId, msg.taskId, +// userId, msg.title, msg.content, splitArray[1], "0", +// System.currentTimeMillis().timestampToCompleteDate() +// ) + } + + // 通知点击 + override fun onNotificationMessageClicked(context: Context?, msg: GTNotificationMessage?) { + Log.d(kTag, "通知点击 -> msg = $msg") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt new file mode 100644 index 0000000..daa7c38 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/BadeHelper.kt @@ -0,0 +1,14 @@ +package com.casic.smart.town.sanxi.util + +import android.content.Context +import me.leolin.shortcutbadger.ShortcutBadger + +object BadeHelper { + fun setBadgeNum(context: Context, badgeCount: Int) { + if (badgeCount == 0) { + ShortcutBadger.removeCount(context) + } else { + ShortcutBadger.applyCount(context, badgeCount) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt new file mode 100644 index 0000000..0a52ef2 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/DataBaseManager.kt @@ -0,0 +1,75 @@ +package com.casic.smart.town.sanxi.util + +import com.casic.smart.town.sanxi.base.BaseApplication +import com.casic.smart.town.sanxi.bean.AlarmMessageLocaleBean +import com.casic.smart.town.sanxi.greendao.AlarmMessageLocaleBeanDao + +class DataBaseManager private constructor() { + + companion object { + //Kotlin委托模式双重锁单例 + val instance: DataBaseManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) { + DataBaseManager() + } + } + + private val beanDao = + BaseApplication.obtainInstance().obtainDaoSession().alarmMessageLocaleBeanDao + +// fun insertNotice( +// messageId: String, appid: String, clientId: String, +// taskId: String, userId: String, title: String, +// content: String, deviceCode: String, isRead: String, +// noticeTime: String +// ) { +// val noticeLocaleBean = NoticeLocaleBean() +// noticeLocaleBean.messageId = messageId +// noticeLocaleBean.appid = appid +// noticeLocaleBean.clientId = clientId +// noticeLocaleBean.taskId = taskId +// noticeLocaleBean.userId = userId +// noticeLocaleBean.title = title +// noticeLocaleBean.content = content +// noticeLocaleBean.deviceCode = deviceCode +// noticeLocaleBean.isRead = isRead +// noticeLocaleBean.noticeTime = noticeTime +// beanDao.insert(noticeLocaleBean) +// //角标设置 +// BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadNotice()) +// } + + fun deleteByMessageId(messageId: String) { + val result = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).list() + beanDao.deleteInTx(result) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun updateNoticeByMessageId(messageId: String) { + val noticeLocaleBean = beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.MessageId.eq(messageId) + ).unique() ?: return + noticeLocaleBean.isRead = "1" + beanDao.update(noticeLocaleBean) + //角标设置 + BadeHelper.setBadgeNum(BaseApplication.obtainInstance(), queryUnReadMessage()) + } + + fun queryMessageByPage(userId: String, offset: Int): MutableList { + return BaseApplication.obtainInstance().obtainDaoSession() + .queryBuilder(AlarmMessageLocaleBean::class.java) + .where(AlarmMessageLocaleBeanDao.Properties.UserId.eq(userId)) + .offset(offset * LocaleConstant.PAGE_LIMIT) + .orderDesc(AlarmMessageLocaleBeanDao.Properties.AlarmTime) + .limit(LocaleConstant.PAGE_LIMIT) + .list() + } + + private fun queryUnReadMessage(): Int { + return beanDao.queryBuilder().where( + AlarmMessageLocaleBeanDao.Properties.IsRead.eq("0") + ).list().size + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt new file mode 100644 index 0000000..52926a8 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LoadingDialogHub.kt @@ -0,0 +1,31 @@ +package com.casic.smart.town.sanxi.util; + +import android.app.Activity +import android.view.WindowManager +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog + +object LoadingDialogHub { + private lateinit var loadingDialog: QMUITipDialog + + fun show(activity: Activity, message: String) { + loadingDialog = QMUITipDialog + .Builder(activity) + .setIconType(QMUITipDialog.Builder.ICON_TYPE_LOADING) + .setTipWord(message) + .create() + if (!activity.isDestroyed) { + try { + loadingDialog.show() + } catch (e: WindowManager.BadTokenException) { + e.printStackTrace() + } + } + } + + + fun dismiss() { + if (loadingDialog.isShowing) { + loadingDialog.dismiss() + } + } +} diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt new file mode 100644 index 0000000..de61c9a --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt @@ -0,0 +1,15 @@ +package com.casic.smart.town.sanxi.util + +import android.Manifest + +object LocaleConstant { + val USER_PERMISSIONS = arrayOf( + Manifest.permission.READ_PHONE_STATE, + Manifest.permission.ACCESS_COARSE_LOCATION, + Manifest.permission.READ_EXTERNAL_STORAGE + ) + + const val PERMISSIONS_CODE = 999 + const val PUSH_REGISTER = 2022100101 + const val PAGE_LIMIT = 20 +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt new file mode 100644 index 0000000..3bea1c9 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MainActivity.kt @@ -0,0 +1,112 @@ +package com.casic.smart.town.sanxi.view + +import android.view.KeyEvent +import android.view.MenuItem +import androidx.fragment.app.Fragment +import androidx.viewpager.widget.ViewPager +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.adapter.ViewPagerAdapter +import com.casic.smart.town.sanxi.fragment.AlarmPageFragment +import com.casic.smart.town.sanxi.fragment.MonitorPageFragment +import com.casic.smart.town.sanxi.fragment.StatisticsPageFragment +import com.gyf.immersionbar.ImmersionBar +import com.igexin.sdk.PushManager +import com.pengxh.kt.lite.base.KotlinBaseActivity +import com.pengxh.kt.lite.extensions.convertColor +import com.pengxh.kt.lite.extensions.show +import com.pengxh.kt.lite.utils.ImmerseStatusBarUtil +import com.pengxh.kt.lite.utils.WeakReferenceHandler +import kotlinx.android.synthetic.main.activity_main.* + +class MainActivity : KotlinBaseActivity() { + + companion object { + lateinit var weakReferenceHandler: WeakReferenceHandler + } + + private val kTag = "MainActivity" + private var menuItem: MenuItem? = null + private var fragmentPages: ArrayList = ArrayList() + private var clickTime: Long = 0 + + init { + fragmentPages.add(StatisticsPageFragment()) + fragmentPages.add(MonitorPageFragment()) + fragmentPages.add(AlarmPageFragment()) + } + + override fun initLayoutView(): Int = R.layout.activity_main + + override fun setupTopBarLayout() { + ImmersionBar.with(this).statusBarDarkFont(false).init() + ImmerseStatusBarUtil.setColor(this, R.color.mainThemeColor.convertColor(this)) + } + + override fun initData() { + //推送,多次调用 SDK 初始化并无影响。 + PushManager.getInstance().initialize(this) + weakReferenceHandler = WeakReferenceHandler { + + true + } + } + + override fun observeRequestState() { + + } + + override fun initEvent() { + bottomNavigation.itemIconTintList = null + bottomNavigation.setOnNavigationItemSelectedListener { menuItem -> + when (menuItem.itemId) { + R.id.nav_statistics -> { + mainViewPager.currentItem = 0 + } + R.id.nav_monitor -> { + mainViewPager.currentItem = 1 + } + R.id.nav_alarm -> { + mainViewPager.currentItem = 2 + } + } + false + } + mainViewPager.adapter = ViewPagerAdapter(fragmentPages, supportFragmentManager) + mainViewPager.offscreenPageLimit = fragmentPages.size //缓存页数 + mainViewPager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener { + override fun onPageScrollStateChanged(state: Int) { + + } + + override fun onPageScrolled( + position: Int, + positionOffset: Float, + positionOffsetPixels: Int + ) { + + } + + override fun onPageSelected(position: Int) { + if (menuItem != null) { + menuItem!!.isChecked = false + } else { + bottomNavigation.menu.getItem(0).isChecked = false + } + menuItem = bottomNavigation.menu.getItem(position) + menuItem!!.isChecked = true + } + }) + } + + override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean { + return if (keyCode == KeyEvent.KEYCODE_BACK) { + if (System.currentTimeMillis() - clickTime > 2000) { + "再按一次退出程序".show(this) + clickTime = System.currentTimeMillis() + true + } else { + super.onKeyDown(keyCode, event) + } + } else super.onKeyDown(keyCode, event) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt new file mode 100644 index 0000000..c5d8b22 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/MonitorRecordActivity.kt @@ -0,0 +1,25 @@ +package com.casic.smart.town.sanxi.view + +import com.casic.smart.town.sanxi.R +import com.pengxh.kt.lite.base.KotlinBaseActivity + +class MonitorRecordActivity : KotlinBaseActivity() { + + override fun initLayoutView(): Int = R.layout.activity_monitor_record + + override fun observeRequestState() { + + } + + override fun setupTopBarLayout() { + + } + + override fun initData() { + + } + + override fun initEvent() { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt new file mode 100644 index 0000000..c478d83 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/view/PermissionActivity.kt @@ -0,0 +1,55 @@ +package com.casic.smart.town.sanxi.view + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.amap.api.maps.MapsInitializer +import com.casic.smart.town.sanxi.R +import com.casic.smart.town.sanxi.util.LocaleConstant +import com.gyf.immersionbar.ImmersionBar +import com.pengxh.kt.lite.extensions.navigatePageTo +import pub.devrel.easypermissions.EasyPermissions +import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks + +class PermissionActivity : AppCompatActivity(), PermissionCallbacks { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + ImmersionBar.with(this).statusBarDarkFont(true).init() + //判断是否有权限,如果版本大于5.1才需要判断(即6.0以上),其他则不需要判断。 + if (EasyPermissions.hasPermissions(this, *LocaleConstant.USER_PERMISSIONS)) { + startSplashScreenActivity() + } else { + EasyPermissions.requestPermissions( + this@PermissionActivity, + resources.getString(R.string.app_name) + "需要获取相关权限", + LocaleConstant.PERMISSIONS_CODE, + *LocaleConstant.USER_PERMISSIONS + ) + } + } + + private fun startSplashScreenActivity() { + //先把导航隐私政策声明,后面导航会用到 + MapsInitializer.updatePrivacyAgree(this, true) + MapsInitializer.updatePrivacyShow(this, true, true) + this.navigatePageTo() + 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) { + startSplashScreenActivity() + } + + override fun onPermissionsDenied(requestCode: Int, perms: List) { + + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable/alarm_selector.xml b/app/src/main/res/drawable/alarm_selector.xml new file mode 100644 index 0000000..39b2595 --- /dev/null +++ b/app/src/main/res/drawable/alarm_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bottom_text_color.xml b/app/src/main/res/drawable/bottom_text_color.xml new file mode 100644 index 0000000..b284ea3 --- /dev/null +++ b/app/src/main/res/drawable/bottom_text_color.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_alarm.xml b/app/src/main/res/drawable/ic_alarm.xml new file mode 100644 index 0000000..dc33aab --- /dev/null +++ b/app/src/main/res/drawable/ic_alarm.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_alarm_selected.xml b/app/src/main/res/drawable/ic_alarm_selected.xml new file mode 100644 index 0000000..993fea6 --- /dev/null +++ b/app/src/main/res/drawable/ic_alarm_selected.xml @@ -0,0 +1,9 @@ + + + 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_monitor.xml b/app/src/main/res/drawable/ic_monitor.xml new file mode 100644 index 0000000..271f5b4 --- /dev/null +++ b/app/src/main/res/drawable/ic_monitor.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_monitor_selected.xml b/app/src/main/res/drawable/ic_monitor_selected.xml new file mode 100644 index 0000000..ee62d84 --- /dev/null +++ b/app/src/main/res/drawable/ic_monitor_selected.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_statistics.xml b/app/src/main/res/drawable/ic_statistics.xml new file mode 100644 index 0000000..7fde8ec --- /dev/null +++ b/app/src/main/res/drawable/ic_statistics.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_statistics_selected.xml b/app/src/main/res/drawable/ic_statistics_selected.xml new file mode 100644 index 0000000..49b6fcd --- /dev/null +++ b/app/src/main/res/drawable/ic_statistics_selected.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/monitor_selector.xml b/app/src/main/res/drawable/monitor_selector.xml new file mode 100644 index 0000000..fe11e9a --- /dev/null +++ b/app/src/main/res/drawable/monitor_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/statistics_selector.xml b/app/src/main/res/drawable/statistics_selector.xml new file mode 100644 index 0000000..2156cff --- /dev/null +++ b/app/src/main/res/drawable/statistics_selector.xml @@ -0,0 +1,5 @@ + + + + + \ 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..78a4a94 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,27 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_monitor_record.xml b/app/src/main/res/layout/activity_monitor_record.xml new file mode 100644 index 0000000..77d9ef6 --- /dev/null +++ b/app/src/main/res/layout/activity_monitor_record.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_alarm.xml b/app/src/main/res/layout/fragment_alarm.xml new file mode 100644 index 0000000..77d9ef6 --- /dev/null +++ b/app/src/main/res/layout/fragment_alarm.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_monitor.xml b/app/src/main/res/layout/fragment_monitor.xml new file mode 100644 index 0000000..19789c1 --- /dev/null +++ b/app/src/main/res/layout/fragment_monitor.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_statistics.xml b/app/src/main/res/layout/fragment_statistics.xml new file mode 100644 index 0000000..77d9ef6 --- /dev/null +++ b/app/src/main/res/layout/fragment_statistics.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/menu/bottom_nav_menu.xml b/app/src/main/res/menu/bottom_nav_menu.xml new file mode 100644 index 0000000..751fd61 --- /dev/null +++ b/app/src/main/res/menu/bottom_nav_menu.xml @@ -0,0 +1,29 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.webp b/app/src/main/res/mipmap-hdpi/ic_launcher.webp new file mode 100644 index 0000000..c209e78 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp new file mode 100644 index 0000000..b2dfe3d --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.webp b/app/src/main/res/mipmap-mdpi/ic_launcher.webp new file mode 100644 index 0000000..4f0f1d6 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp new file mode 100644 index 0000000..62b611d --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher.webp new file mode 100644 index 0000000..948a307 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..1b9a695 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp Binary files differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp new file mode 100644 index 0000000..28d4b77 --- /dev/null +++ b/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..9287f50 --- /dev/null +++ b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp new file mode 100644 index 0000000..aa7d642 --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..9126ae3 --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp 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..bbce66f --- /dev/null +++ b/app/src/main/res/values/colors.xml @@ -0,0 +1,14 @@ + + + #1D55C6 + #333333 + #CCCCCC + + #FFBB86FC + #FF6200EE + #FF3700B3 + #FF03DAC5 + #FF018786 + #FF000000 + #FFFFFFFF + \ No newline at end of file diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml new file mode 100644 index 0000000..b7a9292 --- /dev/null +++ b/app/src/main/res/values/dimens.xml @@ -0,0 +1,33 @@ + + + + 12sp + 14sp + 16sp + 18sp + 20sp + 22sp + + + 3dp + 5dp + 7dp + 10dp + 15dp + 20dp + 25dp + 30dp + 35dp + 40dp + 45dp + 50dp + 55dp + 60dp + 75dp + + + 1dp + + + 45dp + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml new file mode 100644 index 0000000..f636245 --- /dev/null +++ b/app/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + SmartTown + \ No newline at end of file diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml new file mode 100644 index 0000000..635e8e0 --- /dev/null +++ b/app/src/main/res/values/themes.xml @@ -0,0 +1,16 @@ + + + + \ No newline at end of file diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..62b9d90 --- /dev/null +++ b/build.gradle @@ -0,0 +1,30 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. +buildscript { + ext.kotlin_version = '1.6.10' + repositories { + maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' } + google() + } + dependencies { + classpath 'com.android.tools.build:gradle:3.6.4' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + classpath 'org.greenrobot:greendao-gradle-plugin:3.3.0' + + // 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() + maven { url "https://mvn.getui.com/nexus/content/repositories/releases/"} + } +} + +task clean(type: Delete) { + delete rootProject.buildDir +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..98bed16 --- /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=-Xmx2048m -Dfile.encoding=UTF-8 +# 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 \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..e708b1c --- /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..35bda37 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Sat Oct 08 09:41:32 CST 2022 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip diff --git a/gradlew b/gradlew new file mode 100755 index 0000000..4f906e0 --- /dev/null +++ b/gradlew @@ -0,0 +1,185 @@ +#!/usr/bin/env sh + +# +# Copyright 2015 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +## +## 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='"-Xmx64m" "-Xms64m"' + +# 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 or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; 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=`expr $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" + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..107acd3 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,89 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@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 Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@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="-Xmx64m" "-Xms64m" + +@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 execute + +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 execute + +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 + +: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 %* + +: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..047ce48 --- /dev/null +++ b/settings.gradle @@ -0,0 +1,2 @@ +rootProject.name = "SmartTown" +include ':app'