add v1.0.0
This commit is contained in:
2
DaKa/entry/.gitignore
vendored
Normal file
2
DaKa/entry/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
/build
|
||||
/node_modules
|
1
DaKa/entry/agconnect-services.json
Normal file
1
DaKa/entry/agconnect-services.json
Normal file
@@ -0,0 +1 @@
|
||||
你自己的agconnect-services.json文件
|
45
DaKa/entry/build.gradle
Normal file
45
DaKa/entry/build.gradle
Normal file
@@ -0,0 +1,45 @@
|
||||
apply plugin: 'com.huawei.ohos.hap'
|
||||
apply plugin: 'com.huawei.ohos.decctest'
|
||||
apply plugin: 'com.huawei.agconnect'
|
||||
//For instructions on signature configuration, see https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ide_debug_device-0000001053822404#section1112183053510
|
||||
ohos {
|
||||
compileSdkVersion 6
|
||||
defaultConfig {
|
||||
compatibleSdkVersion 6
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
proguardOpt {
|
||||
proguardEnabled true
|
||||
rulesFiles 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
debug {
|
||||
proguardOpt {
|
||||
proguardEnabled true
|
||||
rulesFiles 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar', '*.har'])
|
||||
testImplementation 'junit:junit:4.13.1'
|
||||
ohosTestImplementation 'com.huawei.ohos.testkit:runner:2.0.0.200'
|
||||
implementation 'org.json:json:20211205'
|
||||
implementation 'org.conscrypt:conscrypt-openjdk:2.5.2'
|
||||
implementation project(':jianjia')
|
||||
implementation "com.google.code.gson:gson:2.9.0"//网络Json数据解析
|
||||
implementation 'com.squareup.okhttp3:logging-interceptor:3.14.9'//网络框架依赖
|
||||
implementation 'com.huawei.agconnect:agconnect-core-harmony:1.3.0.300'//agc核心依赖
|
||||
implementation 'com.huawei.hms:hianalytics-harmony:6.3.2.301'//HMS服务
|
||||
implementation 'com.huawei.hms:location-harmony:6.3.0.300'//HMS定位
|
||||
}
|
||||
decc {
|
||||
supportType = ['html', 'xml']
|
||||
}
|
130
DaKa/entry/proguard-rules.pro
vendored
Normal file
130
DaKa/entry/proguard-rules.pro
vendored
Normal file
@@ -0,0 +1,130 @@
|
||||
-dontwarn
|
||||
# 代码混淆压缩比,在0~7之间
|
||||
-optimizationpasses 5
|
||||
# 混合时不使用大小写混合,混合后的类名为小写
|
||||
-dontusemixedcaseclassnames
|
||||
# 在读取依赖的库文件时,不要略过那些非public类成员
|
||||
-dontskipnonpubliclibraryclassmembers
|
||||
# 指定不去忽略非公共库的类
|
||||
-dontskipnonpubliclibraryclasses
|
||||
# 不做预校验,preverify是proguard的四个步骤之一,去掉这一步能够加快混淆速度。
|
||||
-dontpreverify
|
||||
-verbose
|
||||
# google推荐算法
|
||||
#-optimizations !code/simplification/arithmetic,!code/simplification/cast,!field/*,!class/merging/*
|
||||
-dontoptimize#注意在上传时配置,本地无需配置
|
||||
# 保留注解、内部类、泛型、匿名类
|
||||
-keepattributes *Annotation*,Exceptions,InnerClasses,Signature,EnclosingMethod
|
||||
# 重命名抛出异常时的文件名称
|
||||
-renamesourcefileattribute SourceFile
|
||||
# 抛出异常时保留代码行号
|
||||
-keepattributes SourceFile,LineNumberTable
|
||||
-dontwarn javax.annotation.**
|
||||
# 保留本地native方法不被混淆
|
||||
-keepclasseswithmembernames,allowshrinking class * {
|
||||
native <methods>;
|
||||
}
|
||||
# 保留枚举类不被混淆
|
||||
-keepclassmembers enum * {
|
||||
public static **[] values();
|
||||
public static ** valueOf(java.lang.String);
|
||||
}
|
||||
# 保留自定义类
|
||||
-keep class com.xcl.location.MyApplication
|
||||
-keep class com.xcl.location.Net.**{*;}
|
||||
|
||||
# 忽略数据库有关
|
||||
-keep class com.litesuits.orm.**
|
||||
-keepclassmembers class com.litesuits.orm.**{*;}
|
||||
-keep enum com.litesuits.orm.**
|
||||
-keepclassmembers enum com.litesuits.orm.**{*;}
|
||||
-keep interface com.litesuits.orm.**
|
||||
-keepclassmembers interface com.litesuits.orm.**{*;}
|
||||
-keep class com.xcl.study.DataANet.**{*;}
|
||||
# 忽略继承
|
||||
-keepclassmembers class * implements java.io.Serializable {
|
||||
static final long serialVersionUID;
|
||||
private static final java.io.ObjectStreamField[] serialPersistentFields;
|
||||
private void writeObject(java.io.ObjectOutputStream);
|
||||
private void readObject(java.io.ObjectInputStream);
|
||||
java.lang.Object writeReplace();
|
||||
java.lang.Object readResolve();
|
||||
}
|
||||
# 保留HMS相关接入[AnalyticsKit SDK和依赖SDK的混淆配置]
|
||||
-ignorewarnings
|
||||
-repackageclasses
|
||||
-keep class com.huawei.agconnect.**{*;}
|
||||
-keep class com.huawei.hms.analytics.**{*;}
|
||||
-keep class com.huawei.hms.push.**{*;}
|
||||
-keep class com.huawei.hms.**{*;}
|
||||
# 保留fastjson
|
||||
#-dontwarn com.alibaba.fastjson.**
|
||||
#-keep class com.alibaba.fastjson.**{*; }
|
||||
# 保留okhttp
|
||||
-keep class com.squareup.okhttp.** { *;}
|
||||
-dontwarn com.squareup.okhttp.**
|
||||
-dontwarn org.apache.http.**
|
||||
-keep class okio.**{*;}
|
||||
-keep class okhttp3.** { *; }
|
||||
-keep interface okhttp3.** { *; }
|
||||
-dontwarn okhttp3.**
|
||||
# HMS接口服务
|
||||
-keepattributes Exceptions
|
||||
-keep interface com.huawei.hms.analytics.type.HAEventType{*;}
|
||||
-keep interface com.huawei.hms.analytics.type.HAParamType{*;}
|
||||
-keep class com.huawei.hms.analytics.HiAnalyticsInstance{*;}
|
||||
-keep class com.huawei.hms.analytics.HiAnalytics{*;}
|
||||
-keep class com.huawei.hianalytics.**{*;}
|
||||
-keep class com.huawei.updatesdk.**{*;}
|
||||
-keep class com.huawei.harmony.**{*;}
|
||||
-keep class com.huawei.mylibrary.**{*;}
|
||||
# 保留HarmonyOS应用/服务入口类
|
||||
-keep public class * extends *.aafwk.ability.Ability
|
||||
-keep public class * extends *.ace.ability.AceAbility
|
||||
-keep public class * extends *.aafwk.ability.AbilitySlice
|
||||
-keep public class * extends *.aafwk.ability.AbilityPackage
|
||||
-dontwarn java.lang.invoke.**
|
||||
-dontwarn javax.naming.**
|
||||
# 保留HarmonyOS定位服务
|
||||
-keep public class com.huawei.hms.location.harmony.* {*;}
|
||||
-keep public class com.huawei.hms.location.harmony.base.* {*;}
|
||||
-keep class com.huawei.hmf.tasks.* {*;}
|
||||
#网络有关
|
||||
#okgo
|
||||
-dontwarn com.lzy.okgo.**
|
||||
-keep class com.lzy.okgo.**{*;}
|
||||
|
||||
#okrx
|
||||
-dontwarn com.lzy.okrx.**
|
||||
-keep class com.lzy.okrx.**{*;}
|
||||
|
||||
#okrx2
|
||||
-dontwarn com.lzy.okrx2.**
|
||||
-keep class com.lzy.okrx2.**{*;}
|
||||
|
||||
#okserver
|
||||
-dontwarn com.lzy.okserver.**
|
||||
-keep class com.lzy.okserver.**{*;}
|
||||
|
||||
-keepattributes Signature, InnerClasses, EnclosingMethod, Exceptions
|
||||
# 蒹葭
|
||||
-dontwarn com.net.jianjia.**
|
||||
-keep class com.net.jianjia.** { *; }
|
||||
-keep class com.net.jianjia.gson.** { *; }
|
||||
-keep class com.net.jianjia.conventer.** { *; }
|
||||
-keepattributes RuntimeVisibleAnnotations, RuntimeVisibleParameterAnnotations
|
||||
-keepclassmembers,allowshrinking,allowobfuscation interface * {
|
||||
@com.net.jianjia.http.* <methods>;
|
||||
}
|
||||
|
||||
# OkHttp3
|
||||
-dontwarn okhttp3.logging.**
|
||||
-keep class okhttp3.internal.**{*;}
|
||||
-dontwarn okio.**
|
||||
|
||||
# gson
|
||||
-keep class sun.misc.Unsafe { *; }
|
||||
-keep class com.google.gson.stream.** { *; }
|
||||
|
||||
# 保留配置文件
|
||||
-printmapping mapping.txt
|
87
DaKa/entry/src/main/config.json
Normal file
87
DaKa/entry/src/main/config.json
Normal file
@@ -0,0 +1,87 @@
|
||||
{
|
||||
"app": {
|
||||
"bundleName": "com.xcl.location",
|
||||
"vendor": "xcl",
|
||||
"version": {
|
||||
"code": 326,
|
||||
"name": "1.0.1.220326"
|
||||
}
|
||||
},
|
||||
"deviceConfig": {
|
||||
"default": {
|
||||
"supportBackup": true
|
||||
}
|
||||
},
|
||||
"module": {
|
||||
"package": "com.xcl.location",
|
||||
"name": ".MyApplication",
|
||||
"mainAbility": "com.xcl.location.MainAbility",
|
||||
"deviceType": [
|
||||
"phone",
|
||||
"tablet"
|
||||
],
|
||||
"distro": {
|
||||
"deliveryWithInstall": true,
|
||||
"moduleName": "entry",
|
||||
"moduleType": "entry",
|
||||
"installationFree": false
|
||||
},
|
||||
"abilities": [
|
||||
{
|
||||
"skills": [
|
||||
{
|
||||
"entities": [
|
||||
"entity.system.home"
|
||||
],
|
||||
"actions": [
|
||||
"action.system.home"
|
||||
]
|
||||
}
|
||||
],
|
||||
"orientation": "unspecified",
|
||||
"visible": true,
|
||||
"name": "com.xcl.location.MainAbility",
|
||||
"icon": "$media:icon",
|
||||
"label": "$string:entry_MainAbility",
|
||||
"type": "page",
|
||||
"launchType": "standard"
|
||||
},
|
||||
{
|
||||
"permissions": [
|
||||
"com.huawei.agconnect.core.DataAbilityShellProvider.PROVIDER"
|
||||
],
|
||||
"name": "com.huawei.agconnect.core.provider.AGConnectInitializeAbility",
|
||||
"type": "data",
|
||||
"uri": "dataability://com.xcl.location.location.AGConnectInitializeAbility"
|
||||
}
|
||||
],
|
||||
"metaData": {
|
||||
"customizeData": [
|
||||
{
|
||||
"name": "hwc-theme",
|
||||
"extra": "",
|
||||
"value": "androidhwext:style/Theme.Emui.Wallpaper.NoTitleBar"
|
||||
}
|
||||
]
|
||||
},
|
||||
"reqPermissions": [
|
||||
{
|
||||
"name": "ohos.permission.LOCATION",
|
||||
"reason": "定位",
|
||||
"usedScene": {
|
||||
"ability": [
|
||||
"com.xcl.location.MainAbility"
|
||||
],
|
||||
"when": "always"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "ohos.permission.GET_NETWORK_INFO",
|
||||
"reason": "Allows programs to obtain network information status"
|
||||
},
|
||||
{
|
||||
"name": "ohos.permission.LOCATION_IN_BACKGROUND"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
103
DaKa/entry/src/main/java/com/xcl/location/MainAbility.java
Normal file
103
DaKa/entry/src/main/java/com/xcl/location/MainAbility.java
Normal file
@@ -0,0 +1,103 @@
|
||||
package com.xcl.location;
|
||||
|
||||
import com.xcl.location.Util.MyToastDialog;
|
||||
import com.xcl.location.slice.MainAbilitySlice;
|
||||
import ohos.aafwk.ability.Ability;
|
||||
import ohos.aafwk.content.Intent;
|
||||
import ohos.aafwk.content.Operation;
|
||||
import ohos.agp.utils.LayoutAlignment;
|
||||
import ohos.agp.window.service.WindowManager;
|
||||
import ohos.bundle.IBundleManager;
|
||||
import ohos.hiviewdfx.HiLog;
|
||||
import ohos.hiviewdfx.HiLogLabel;
|
||||
import ohos.utils.IntentConstants;
|
||||
import ohos.utils.net.Uri;
|
||||
|
||||
/**
|
||||
* The type Main ability.
|
||||
*/
|
||||
public class MainAbility extends Ability {
|
||||
private static final HiLogLabel label = new HiLogLabel(HiLog.LOG_APP, 0x00234, "MainAbility");
|
||||
|
||||
/**
|
||||
* The Main ability slice.
|
||||
*/
|
||||
MainAbilitySlice MainAbilitySlice;
|
||||
|
||||
@Override
|
||||
public void onStart(Intent intent) {
|
||||
super.onStart(intent);
|
||||
|
||||
super.setAbilitySliceAnimator(null);
|
||||
super.setTransitionAnimation(0, 0);
|
||||
this.getWindow().addFlags(WindowManager.LayoutConfig.MARK_ALLOW_EXTEND_LAYOUT);
|
||||
super.setMainRoute(MainAbilitySlice.class.getName());
|
||||
super.setAbilitySliceAnimator(null);
|
||||
super.setTransitionAnimation(0, 0);
|
||||
}
|
||||
|
||||
private void ShowDialog(String text1) {
|
||||
try {
|
||||
new MyToastDialog(this.getContext(), text1, ResourceTable.Graphic_xtoast_framem, 36, 25)
|
||||
.setDuration(120)
|
||||
.setAlignment(LayoutAlignment.BOTTOM)
|
||||
.setOffset(0, 100)
|
||||
.show();
|
||||
} catch (Exception e) {
|
||||
XLog.error(label, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 权限
|
||||
*
|
||||
* @param requestCode the request code
|
||||
* @param permissions the permissions
|
||||
* @param grantResults the grant results
|
||||
*/
|
||||
@Override
|
||||
public void onRequestPermissionsFromUserResult(int requestCode, String[] permissions, int[] grantResults) {
|
||||
super.onRequestPermissionsFromUserResult(requestCode, permissions, grantResults);
|
||||
switch (requestCode) {
|
||||
case 20220109: {
|
||||
// 匹配requestPermissions的requestCode
|
||||
if (grantResults.length > 0
|
||||
&& grantResults[0] == IBundleManager.PERMISSION_GRANTED) {
|
||||
// 权限被授予之后做相应业务逻辑的处理
|
||||
} else {
|
||||
// 权限被拒绝
|
||||
this.ShowDialog("权限被拒绝");
|
||||
this.ShowDialog("请在设置中开启定位权限");
|
||||
/*无参--页面跳转开始*/
|
||||
Intent intent1 = new Intent();
|
||||
Operation operation = new Intent.OperationBuilder()
|
||||
.withAction(IntentConstants.ACTION_APPLICATION_DETAILS_SETTINGS)
|
||||
.withUri(Uri.getUriFromParts("package", getBundleName(), null))
|
||||
.build();
|
||||
intent1.setOperation(operation);
|
||||
startAbility(intent1);
|
||||
this.onBackPressed();
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets main ability slice.
|
||||
*
|
||||
* @return the main ability slice
|
||||
*/
|
||||
public MainAbilitySlice getMainAbilitySlice() {
|
||||
return this.MainAbilitySlice;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets main ability slice.
|
||||
*
|
||||
* @param bianQianShareAbilitySlice the bian qian share ability slice
|
||||
*/
|
||||
public void setMainAbilitySlice(MainAbilitySlice bianQianShareAbilitySlice) {
|
||||
this.MainAbilitySlice = bianQianShareAbilitySlice;
|
||||
}
|
||||
}
|
76
DaKa/entry/src/main/java/com/xcl/location/MyApplication.java
Normal file
76
DaKa/entry/src/main/java/com/xcl/location/MyApplication.java
Normal file
@@ -0,0 +1,76 @@
|
||||
package com.xcl.location;
|
||||
|
||||
import com.huawei.hms.analytics.HiAnalyticsTools;
|
||||
import com.net.jianjia.JianJia;
|
||||
import com.net.jianjia.gson.GsonConverterFactory;
|
||||
import com.xcl.location.Net.Wan;
|
||||
import ohos.aafwk.ability.AbilityPackage;
|
||||
import ohos.hiviewdfx.HiLog;
|
||||
import ohos.hiviewdfx.HiLogLabel;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.logging.HttpLoggingInterceptor;
|
||||
|
||||
/**
|
||||
* The type My application.
|
||||
*/
|
||||
public class MyApplication extends AbilityPackage {
|
||||
private static final HiLogLabel label = new HiLogLabel(HiLog.LOG_APP, 0x00234, "MyApplication");
|
||||
private static MyApplication Instance;
|
||||
private JianJia mJianJia;
|
||||
private Wan mWan;
|
||||
|
||||
/**
|
||||
* Gets instance.
|
||||
*
|
||||
* @return the instance
|
||||
*/
|
||||
public static MyApplication getInstance() {
|
||||
return Instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets jian jia.
|
||||
*
|
||||
* @return the jian jia
|
||||
*/
|
||||
public JianJia getJianJia() {
|
||||
return this.mJianJia;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets wan.
|
||||
*
|
||||
* @return the wan
|
||||
*/
|
||||
public Wan getWan() {
|
||||
return this.mWan;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
super.onInitialize();
|
||||
try {
|
||||
Preference_RW.context = this.getContext();
|
||||
XLog.pd_pd = Preference_RW.ff7_r();
|
||||
XLog.pd_pd = 555;
|
||||
HiAnalyticsTools.enableLog();
|
||||
//创建日志拦截器
|
||||
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
|
||||
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
|
||||
//为OKHTTP添加日志拦截器
|
||||
OkHttpClient okHttpClient = new OkHttpClient.Builder()
|
||||
.addInterceptor(logging)
|
||||
.build();
|
||||
this.mJianJia = new JianJia.Builder()
|
||||
// 使用自定义的okHttpClient对象
|
||||
.callFactory(okHttpClient)
|
||||
.baseUrl("https://api.xuegao-xcl.tech")
|
||||
.addConverterFactory(GsonConverterFactory.create())
|
||||
.build();
|
||||
Instance = this;
|
||||
this.mWan = this.mJianJia.create(Wan.class);
|
||||
} catch (Exception e) {
|
||||
XLog.error(label, e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
49
DaKa/entry/src/main/java/com/xcl/location/Net/DXJX.java
Normal file
49
DaKa/entry/src/main/java/com/xcl/location/Net/DXJX.java
Normal file
@@ -0,0 +1,49 @@
|
||||
package com.xcl.location.Net;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* The type Dxjx.
|
||||
*
|
||||
* @author Xcl
|
||||
* @date 2022 /3/25
|
||||
* @package com.xcl.location.Net
|
||||
*/
|
||||
public class DXJX {
|
||||
/**
|
||||
* The Result.
|
||||
*/
|
||||
public Result result;
|
||||
|
||||
/**
|
||||
* The type Result.
|
||||
*/
|
||||
public static class Result implements Serializable {
|
||||
/**
|
||||
* The Address component.
|
||||
*/
|
||||
public AddressComponent addressComponent;
|
||||
|
||||
/**
|
||||
* The type Address component.
|
||||
*/
|
||||
public static class AddressComponent implements Serializable {
|
||||
/**
|
||||
* The Province.
|
||||
*/
|
||||
public String province;
|
||||
/**
|
||||
* The City.
|
||||
*/
|
||||
public String city;
|
||||
/**
|
||||
* The District.
|
||||
*/
|
||||
public String district;
|
||||
/**
|
||||
* The Street.
|
||||
*/
|
||||
public String street;
|
||||
}
|
||||
}
|
||||
}
|
15
DaKa/entry/src/main/java/com/xcl/location/Net/TJXX.java
Normal file
15
DaKa/entry/src/main/java/com/xcl/location/Net/TJXX.java
Normal file
@@ -0,0 +1,15 @@
|
||||
package com.xcl.location.Net;
|
||||
|
||||
/**
|
||||
* The type Tjxx.
|
||||
*
|
||||
* @author Xcl
|
||||
* @date 2022 /3/25
|
||||
* @package com.xcl.location.Net
|
||||
*/
|
||||
public class TJXX {
|
||||
/**
|
||||
* The Msg.
|
||||
*/
|
||||
public String msg;
|
||||
}
|
36
DaKa/entry/src/main/java/com/xcl/location/Net/Wan.java
Normal file
36
DaKa/entry/src/main/java/com/xcl/location/Net/Wan.java
Normal file
@@ -0,0 +1,36 @@
|
||||
package com.xcl.location.Net;
|
||||
|
||||
import com.net.jianjia.Call;
|
||||
import com.net.jianjia.http.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* The interface Wan.
|
||||
*
|
||||
* @author Xcl
|
||||
* @date 2022 /2/18
|
||||
* @package com.xcl.study.DataANet
|
||||
*/
|
||||
public interface Wan {
|
||||
/**
|
||||
* Gets dkxx.
|
||||
*
|
||||
* @param param the param
|
||||
* @return the dkxx
|
||||
*/
|
||||
@BaseUrl("https://api.map.baidu.com/")
|
||||
@GET("/reverse_geocoding/v3")
|
||||
Call<DXJX> getDKXX(@QueryMap Map<String, String> param);
|
||||
|
||||
/**
|
||||
* Post dkxx call.
|
||||
*
|
||||
* @param param the param
|
||||
* @return the call
|
||||
*/
|
||||
@BaseUrl("https://yx.ty-ke.com/")
|
||||
@POST("/Home/Monitor/monitor_add")
|
||||
@FormUrlEncoded
|
||||
Call<TJXX> postDKXX(@FieldMap Map<String, String> param);
|
||||
}
|
187
DaKa/entry/src/main/java/com/xcl/location/Preference_RW.java
Normal file
187
DaKa/entry/src/main/java/com/xcl/location/Preference_RW.java
Normal file
@@ -0,0 +1,187 @@
|
||||
package com.xcl.location;
|
||||
|
||||
import ohos.aafwk.ability.Ability;
|
||||
import ohos.app.Context;
|
||||
import ohos.data.DatabaseHelper;
|
||||
import ohos.data.preferences.Preferences;
|
||||
import ohos.hiviewdfx.HiLog;
|
||||
import ohos.hiviewdfx.HiLogLabel;
|
||||
|
||||
/**
|
||||
* The type Preference rw.
|
||||
*
|
||||
* @author Xcl
|
||||
* @date 2022 /3/25
|
||||
* @package com.xcl.location
|
||||
*/
|
||||
public class Preference_RW extends Ability {
|
||||
private static final HiLogLabel label = new HiLogLabel(HiLog.LOG_APP, 0x00234, "Preference_RW");
|
||||
private static final String preferenceFile = "messages_tzx_xcl_dx";
|
||||
private static final String counterKey7 = "DeBug";
|
||||
private static final String counterKey1 = "dszh";
|
||||
private static final String counterKey2 = "dxtempd";
|
||||
private static final String counterKey3 = "dxtem";
|
||||
private static final String counterKey4 = "autodxpd";
|
||||
/**
|
||||
* The constant context.
|
||||
*/
|
||||
public static Context context;
|
||||
|
||||
private static void writeCounter(String key, int message) {
|
||||
try {
|
||||
DatabaseHelper databaseHelper = new DatabaseHelper(context);
|
||||
Preferences preferences = databaseHelper.getPreferences(preferenceFile);
|
||||
preferences.putInt(key, message);
|
||||
preferences.flush();
|
||||
} catch (Exception e) {
|
||||
HiLog.error(label, "写发生错误[" + e.getMessage() + "],key=[" + key + "],message=[" + message + "]");
|
||||
}
|
||||
}
|
||||
|
||||
private static void writeCounter(String key, long message) {
|
||||
try {
|
||||
DatabaseHelper databaseHelper = new DatabaseHelper(context);
|
||||
Preferences preferences = databaseHelper.getPreferences(preferenceFile);
|
||||
preferences.putLong(key, message);
|
||||
preferences.flush();
|
||||
} catch (Exception e) {
|
||||
HiLog.error(label, "写发生错误[" + e.getMessage() + "],key=[" + key + "],message=[" + message + "]");
|
||||
}
|
||||
}
|
||||
|
||||
private static void writeCounter(String key, String message) {
|
||||
try {
|
||||
DatabaseHelper databaseHelper = new DatabaseHelper(context);
|
||||
Preferences preferences = databaseHelper.getPreferences(preferenceFile);
|
||||
preferences.putString(key, message);
|
||||
preferences.flush();
|
||||
} catch (Exception e) {
|
||||
HiLog.warn(label, "xcl写发生错误[" + e.getMessage() + "],key=[" + key + "],message=[" + message + "]");
|
||||
}
|
||||
}
|
||||
|
||||
private static int readCounter(String key) {
|
||||
try {
|
||||
DatabaseHelper databaseHelper = new DatabaseHelper(context);
|
||||
Preferences preferences = databaseHelper.getPreferences(preferenceFile);
|
||||
return preferences.getInt(key, 0);
|
||||
} catch (Exception e) {
|
||||
HiLog.error(label, "读发生错误" + e.getMessage());
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
private static long readCounter(String key, int a) {
|
||||
try {
|
||||
XLog.info(label, "没必要的数据:" + a);
|
||||
DatabaseHelper databaseHelper = new DatabaseHelper(context);
|
||||
Preferences preferences = databaseHelper.getPreferences(preferenceFile);
|
||||
return preferences.getLong(key, 0);
|
||||
} catch (Exception e) {
|
||||
HiLog.error(label, "读发生错误" + e.getMessage());
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
private static String readCounter(String key, String a) {
|
||||
try {
|
||||
XLog.info(label, "没必要的数据:" + a);
|
||||
DatabaseHelper databaseHelper = new DatabaseHelper(context);
|
||||
Preferences preferences = databaseHelper.getPreferences(preferenceFile);
|
||||
return preferences.getString(key, String.valueOf(0));
|
||||
} catch (Exception e) {
|
||||
HiLog.warn(label, "xcl读发生错误" + e.getMessage());
|
||||
return "0";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ff 7 r int.
|
||||
*
|
||||
* @return the int
|
||||
*/
|
||||
public static int ff7_r() {
|
||||
return readCounter(counterKey7);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ff 7 w.
|
||||
*
|
||||
* @param a1 the a 1
|
||||
*/
|
||||
public static void ff7_w(int a1) {
|
||||
Preference_RW.writeCounter(counterKey7, a1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ff 2 r int.
|
||||
*
|
||||
* @return the int
|
||||
*/
|
||||
public static int ff2_r() {
|
||||
return readCounter(counterKey2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ff 2 w.
|
||||
*
|
||||
* @param a1 the a 1
|
||||
*/
|
||||
public static void ff2_w(int a1) {
|
||||
Preference_RW.writeCounter(counterKey2, a1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ff 4 r int.
|
||||
*
|
||||
* @return the int
|
||||
*/
|
||||
public static int ff4_r() {
|
||||
return readCounter(counterKey4);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ff 4 w.
|
||||
*
|
||||
* @param a1 the a 1
|
||||
*/
|
||||
public static void ff4_w(int a1) {
|
||||
Preference_RW.writeCounter(counterKey4, a1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ff 1 r string.
|
||||
*
|
||||
* @return the string
|
||||
*/
|
||||
public static String ff1_r() {
|
||||
return readCounter(counterKey1, "0");
|
||||
}
|
||||
|
||||
/**
|
||||
* Ff 1 w.
|
||||
*
|
||||
* @param a1 the a 1
|
||||
*/
|
||||
public static void ff1_w(String a1) {
|
||||
Preference_RW.writeCounter(counterKey1, a1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ff 3 r string.
|
||||
*
|
||||
* @return the string
|
||||
*/
|
||||
public static String ff3_r() {
|
||||
return readCounter(counterKey3, "0");
|
||||
}
|
||||
|
||||
/**
|
||||
* Ff 3 w.
|
||||
*
|
||||
* @param a1 the a 1
|
||||
*/
|
||||
public static void ff3_w(String a1) {
|
||||
Preference_RW.writeCounter(counterKey3, a1);
|
||||
}
|
||||
}
|
@@ -0,0 +1,93 @@
|
||||
package com.xcl.location.Util;
|
||||
|
||||
import com.xcl.location.Preference_RW;
|
||||
import com.xcl.location.XLog;
|
||||
import ohos.agp.components.AttrHelper;
|
||||
import ohos.agp.components.ComponentContainer;
|
||||
import ohos.agp.components.DirectionalLayout;
|
||||
import ohos.agp.components.Text;
|
||||
import ohos.agp.components.element.ShapeElement;
|
||||
import ohos.agp.utils.Color;
|
||||
import ohos.agp.utils.LayoutAlignment;
|
||||
import ohos.agp.utils.TextAlignment;
|
||||
import ohos.agp.window.dialog.ToastDialog;
|
||||
import ohos.app.Context;
|
||||
import ohos.hiviewdfx.HiLog;
|
||||
import ohos.hiviewdfx.HiLogLabel;
|
||||
|
||||
/**
|
||||
* The type My toast dialog.
|
||||
*
|
||||
* @author Xcl
|
||||
* @date 2021 /12/31
|
||||
* @package com.xcl.study.slice.Dialog
|
||||
*/
|
||||
public class MyToastDialog extends ToastDialog {
|
||||
/**
|
||||
* The constant label.
|
||||
*/
|
||||
private static final HiLogLabel label = new HiLogLabel(HiLog.LOG_APP, 0x00234, "MyToastDialog");
|
||||
/**
|
||||
* The Text component.
|
||||
*/
|
||||
private Text textComponent;
|
||||
|
||||
/**
|
||||
* Instantiates a new My toast dialog.
|
||||
*
|
||||
* @param context the context
|
||||
* @param text the text
|
||||
* @param style the style
|
||||
* @param size the size
|
||||
* @param pad the pad
|
||||
*/
|
||||
public MyToastDialog(Context context, String text, int style, int size, int pad) {
|
||||
super(context);
|
||||
this.init(context, style, size, pad);
|
||||
this.setText(text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Init.
|
||||
*
|
||||
* @param context the context
|
||||
* @param style the style
|
||||
* @param size the size
|
||||
* @param pad the pad
|
||||
*/
|
||||
private void init(Context context, int style, int size, int pad) {
|
||||
try {
|
||||
this.textComponent = new Text(context);
|
||||
this.textComponent.setPadding(pad, pad, pad, pad);
|
||||
this.textComponent.setTextColor(Color.BLACK);
|
||||
this.textComponent.setTextAlignment(TextAlignment.CENTER);
|
||||
this.textComponent.setTextSize(size);
|
||||
ShapeElement shapeElement = new ShapeElement(context, style);
|
||||
this.textComponent.setBackground(shapeElement);
|
||||
this.textComponent.setMultipleLine(true);
|
||||
DirectionalLayout.LayoutConfig layoutConfig = new DirectionalLayout.LayoutConfig();
|
||||
layoutConfig.width = ComponentContainer.LayoutConfig.MATCH_CONTENT;
|
||||
layoutConfig.height = ComponentContainer.LayoutConfig.MATCH_CONTENT;
|
||||
layoutConfig.alignment = LayoutAlignment.CENTER;
|
||||
this.textComponent.setLayoutConfig(layoutConfig);
|
||||
this.setTransparent(true);
|
||||
this.setComponent(this.textComponent);
|
||||
this.setCornerRadius(AttrHelper.vp2px(25, context));
|
||||
} catch (Exception e) {
|
||||
XLog.pd_pd = Preference_RW.ff7_r();
|
||||
XLog.error(label, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets text.
|
||||
*
|
||||
* @param text the text
|
||||
* @return the text
|
||||
*/
|
||||
@Override
|
||||
public MyToastDialog setText(String text) {
|
||||
this.textComponent.setText(text);
|
||||
return this;
|
||||
}
|
||||
}
|
68
DaKa/entry/src/main/java/com/xcl/location/XLog.java
Normal file
68
DaKa/entry/src/main/java/com/xcl/location/XLog.java
Normal file
@@ -0,0 +1,68 @@
|
||||
package com.xcl.location;
|
||||
|
||||
import ohos.aafwk.ability.Ability;
|
||||
import ohos.hiviewdfx.HiLog;
|
||||
import ohos.hiviewdfx.HiLogLabel;
|
||||
|
||||
/**
|
||||
* The type X log.
|
||||
*
|
||||
* @author Xcl
|
||||
* @date 2022 /1/24
|
||||
* @package com.xcl.study.Log
|
||||
*/
|
||||
public class XLog extends Ability {
|
||||
/**
|
||||
* The constant pd_pd.
|
||||
*/
|
||||
public static int pd_pd;
|
||||
/**
|
||||
* The .
|
||||
*/
|
||||
static int i = 0;//TODO:其实这个值P用没有,只是因为有些情况下不输出日志就会卡死≥▂≤
|
||||
|
||||
/**
|
||||
* Info.
|
||||
*
|
||||
* @param label the label
|
||||
* @param message the message
|
||||
*/
|
||||
public static void info(HiLogLabel label, String message) {
|
||||
if (pd_pd == 555) {
|
||||
HiLog.info(label, "信息:[" + message + "]");
|
||||
} else {
|
||||
i++;
|
||||
}
|
||||
//HiLog.info(label, "信息:[" + message + "]");
|
||||
}
|
||||
|
||||
/**
|
||||
* Warn.
|
||||
*
|
||||
* @param label the label
|
||||
* @param message the message
|
||||
*/
|
||||
public static void warn(HiLogLabel label, String message) {
|
||||
if (pd_pd == 555) {
|
||||
HiLog.warn(label, "警告:[" + message + "]");
|
||||
} else {
|
||||
i++;
|
||||
}
|
||||
//HiLog.warn(label, "警告:[" + message + "]");
|
||||
}
|
||||
|
||||
/**
|
||||
* Error.
|
||||
*
|
||||
* @param label the label
|
||||
* @param message the message
|
||||
*/
|
||||
public static void error(HiLogLabel label, String message) {
|
||||
if (pd_pd == 555) {
|
||||
HiLog.error(label, "错误:[" + message + "]");
|
||||
} else {
|
||||
i++;
|
||||
}
|
||||
//HiLog.error(label, "错误:[" + message + "]");
|
||||
}
|
||||
}
|
@@ -0,0 +1,369 @@
|
||||
package com.xcl.location.slice;
|
||||
|
||||
import com.huawei.hmf.tasks.OnFailureListener;
|
||||
import com.huawei.hmf.tasks.OnSuccessListener;
|
||||
import com.huawei.hms.location.harmony.*;
|
||||
import com.net.jianjia.Call;
|
||||
import com.net.jianjia.Callback;
|
||||
import com.net.jianjia.Response;
|
||||
import com.xcl.location.*;
|
||||
import com.xcl.location.Net.DXJX;
|
||||
import com.xcl.location.Net.TJXX;
|
||||
import com.xcl.location.Util.MyToastDialog;
|
||||
import ohos.aafwk.ability.AbilitySlice;
|
||||
import ohos.aafwk.content.Intent;
|
||||
import ohos.aafwk.content.Operation;
|
||||
import ohos.agp.components.*;
|
||||
import ohos.agp.utils.LayoutAlignment;
|
||||
import ohos.app.Context;
|
||||
import ohos.bundle.IBundleManager;
|
||||
import ohos.hiviewdfx.HiLog;
|
||||
import ohos.hiviewdfx.HiLogLabel;
|
||||
import ohos.utils.IntentConstants;
|
||||
import ohos.utils.net.Uri;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* The type Main ability slice.
|
||||
*/
|
||||
public class MainAbilitySlice extends AbilitySlice {
|
||||
private static final HiLogLabel label = new HiLogLabel(HiLog.LOG_APP, 0x00111, "MainAbilitySlice");
|
||||
/**
|
||||
* The Fused location client.
|
||||
*/
|
||||
public FusedLocationClient fusedLocationClient;
|
||||
/**
|
||||
* The Settings provider client.
|
||||
*/
|
||||
SettingsProviderClient settingsProviderClient;
|
||||
/**
|
||||
* The Location callback.
|
||||
*/
|
||||
LocationCallback locationCallback;
|
||||
/**
|
||||
* The Location request.
|
||||
*/
|
||||
LocationRequest locationRequest = new LocationRequest();
|
||||
/**
|
||||
* The Input.
|
||||
*/
|
||||
TextField input;
|
||||
/**
|
||||
* The Inputtem.
|
||||
*/
|
||||
TextField inputtem;
|
||||
/**
|
||||
* The Result.
|
||||
*/
|
||||
Text result;
|
||||
/**
|
||||
* The Latitude.
|
||||
*/
|
||||
Double latitude;
|
||||
/**
|
||||
* The Longitude.
|
||||
*/
|
||||
Double Longitude;
|
||||
/**
|
||||
* The Province.
|
||||
*/
|
||||
String province;
|
||||
/**
|
||||
* The City.
|
||||
*/
|
||||
String city;
|
||||
/**
|
||||
* The District.
|
||||
*/
|
||||
String district;
|
||||
/**
|
||||
* The Street.
|
||||
*/
|
||||
String street;
|
||||
private Context context;
|
||||
private Text geoAddressInfoText;
|
||||
private Text locationInfoText;
|
||||
|
||||
@Override
|
||||
public void onStart(Intent intent) {
|
||||
super.onStart(intent);
|
||||
super.setUIContent(ResourceTable.Layout_main_ability_slice);
|
||||
MainAbility bianQianShareAbility = (MainAbility) this.getAbility();
|
||||
bianQianShareAbility.setMainAbilitySlice(this);
|
||||
if (this.verifySelfPermission(ohos.security.SystemPermission.DISTRIBUTED_DATASYNC) != IBundleManager.PERMISSION_GRANTED) {
|
||||
if (this.canRequestPermission(ohos.security.SystemPermission.DISTRIBUTED_DATASYNC)) {
|
||||
this.requestPermissionsFromUser(
|
||||
new String[]{ohos.security.SystemPermission.LOCATION}, 20220109);
|
||||
} else {
|
||||
// 显示应用需要权限的理由,提示用户进入设置授权
|
||||
this.ShowDialog("请在设置中开启定位权限");
|
||||
/*无参--页面跳转开始*/
|
||||
Intent intent1 = new Intent();
|
||||
Operation operation = new Intent.OperationBuilder()
|
||||
.withAction(IntentConstants.ACTION_APPLICATION_DETAILS_SETTINGS)
|
||||
.withUri(Uri.getUriFromParts("package", getBundleName(), null))
|
||||
.build();
|
||||
intent1.setOperation(operation);
|
||||
startAbility(intent1);
|
||||
this.onBackPressed();
|
||||
}
|
||||
}
|
||||
locationInfoText = (Text) findComponentById(ResourceTable.Id_location_info);
|
||||
geoAddressInfoText = (Text) findComponentById(ResourceTable.Id_geo_address_info);
|
||||
input = (TextField) findComponentById(ResourceTable.Id_dxzh);
|
||||
inputtem = (TextField) findComponentById(ResourceTable.Id_dxtem);
|
||||
result = (Text) findComponentById(ResourceTable.Id_dkjg);
|
||||
inputtem.setEnabled(false);
|
||||
if (Preference_RW.ff1_r() == null || Preference_RW.ff1_r().equals("") || Preference_RW.ff1_r().equals("0")) {
|
||||
input.setText("");
|
||||
} else {
|
||||
input.setText(Preference_RW.ff1_r());
|
||||
}
|
||||
if (Preference_RW.ff2_r() == 2) {
|
||||
if (Preference_RW.ff3_r() == null || Preference_RW.ff3_r().equals("") || Preference_RW.ff3_r().equals("0")) {
|
||||
inputtem.setText("");
|
||||
} else {
|
||||
inputtem.setText(Preference_RW.ff3_r());
|
||||
}
|
||||
}
|
||||
XLog.info(label, "onStart start");
|
||||
fusedLocationClient = new FusedLocationClient(this);
|
||||
settingsProviderClient = new SettingsProviderClient(this);
|
||||
// 设置位置更新的间隔(毫秒:单位)
|
||||
locationRequest.setInterval(5000);
|
||||
// 设置权重
|
||||
locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
|
||||
// (可选)设置是否需要返回地址信息
|
||||
locationRequest.setNeedAddress(true);
|
||||
// (可选)设置返回地址信息的语言
|
||||
locationRequest.setLanguage("zh");
|
||||
locationCallback = new LocationCallback() {
|
||||
@Override
|
||||
public void onLocationResult(LocationResult locationResult) {
|
||||
if (locationResult != null) {
|
||||
// 处理位置回调结果
|
||||
XLog.info(label, "onLocationResult");
|
||||
latitude = locationResult.getLastHWLocation().getLatitude();
|
||||
Longitude = locationResult.getLastHWLocation().getLongitude();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLocationAvailability(LocationAvailability locationAvailability) {
|
||||
super.onLocationAvailability(locationAvailability);
|
||||
if (locationAvailability != null) {
|
||||
// 处理位置状态
|
||||
XLog.info(label, "onLocationAvailability");
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
fusedLocationClient.requestLocationUpdates(locationRequest, locationCallback)
|
||||
.addOnSuccessListener(new OnSuccessListener() {
|
||||
@Override
|
||||
public void onSuccess(Object v) {
|
||||
// 接口调用成功的处理
|
||||
XLog.info(label, "requestLocationUpdates success");
|
||||
}
|
||||
})
|
||||
.addOnFailureListener(new OnFailureListener() {
|
||||
@Override
|
||||
public void onFailure(Exception e) {
|
||||
// 接口调用失败的处理
|
||||
XLog.error(label, "requestLocationUpdates failure");
|
||||
}
|
||||
});
|
||||
context = this;
|
||||
Button stopLocatingButton = (Button) findComponentById(ResourceTable.Id_stop_locating);
|
||||
Map<String, String> url = new HashMap<String, String>();
|
||||
Map<String, String> url1 = new HashMap<String, String>();
|
||||
url.put("ak", "此处填写你的百度地图ak");//TODO:百度地图ak
|
||||
url.put("output", "json");
|
||||
url.put("coordtype", "wgs84ll");
|
||||
stopLocatingButton.setClickedListener(new Component.ClickedListener() {
|
||||
@Override
|
||||
public void onClick(Component component) {
|
||||
// 注意:停止位置更新时,mLocationCallback与requestLocationUpdates()中的LocationCallback参数为同一对象。
|
||||
fusedLocationClient.removeLocationUpdates(locationCallback)
|
||||
.addOnSuccessListener(v -> {
|
||||
// 接口调用成功的处理
|
||||
XLog.info(label, "removeLocationUpdates success");
|
||||
})
|
||||
.addOnFailureListener(e -> {
|
||||
// 接口调用失败的处理
|
||||
XLog.error(label, "removeLocationUpdates failure");
|
||||
});
|
||||
locationInfoText.setText(latitude + "," + Longitude);
|
||||
XLog.error(label, latitude + "," + Longitude);
|
||||
url.put("location", latitude + "," + Longitude);
|
||||
MyApplication.getInstance().getWan().getDKXX(url).enqueue(new Callback<DXJX>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(Call<DXJX> call, Response<DXJX> response) {
|
||||
province = response.body().result.addressComponent.province;
|
||||
city = response.body().result.addressComponent.city;
|
||||
district = response.body().result.addressComponent.district;
|
||||
street = response.body().result.addressComponent.street;
|
||||
geoAddressInfoText.setText(response.body().result.addressComponent.province +
|
||||
response.body().result.addressComponent.city +
|
||||
response.body().result.addressComponent.district +
|
||||
response.body().result.addressComponent.street);
|
||||
XLog.error(label, response.body().result.addressComponent.province +
|
||||
response.body().result.addressComponent.city +
|
||||
response.body().result.addressComponent.district +
|
||||
response.body().result.addressComponent.street);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<DXJX> call, Throwable t) {
|
||||
XLog.error(label, t.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
Button save = (Button) findComponentById(ResourceTable.Id_save_button);
|
||||
save.setClickedListener(new Component.ClickedListener() {
|
||||
@Override
|
||||
public void onClick(Component component) {
|
||||
Preference_RW.ff1_w(input.getText());
|
||||
if (Preference_RW.ff2_r() == 2) {
|
||||
Preference_RW.ff3_w(inputtem.getText());
|
||||
}
|
||||
ShowDialog("保存成功!");
|
||||
}
|
||||
});
|
||||
RadioContainer radioContainer = (RadioContainer) findComponentById(ResourceTable.Id_radio_container0);
|
||||
radioContainer.cancelMarks();
|
||||
if (Preference_RW.ff2_r() == 1) {
|
||||
radioContainer.mark(0);
|
||||
Random rand = new Random();//36.0-36.9
|
||||
DecimalFormat df = new DecimalFormat("0.0");
|
||||
inputtem.setText(df.format((float) (rand.nextInt(10) + 360) / 10));
|
||||
} else if (Preference_RW.ff2_r() == 2) {
|
||||
radioContainer.mark(1);
|
||||
inputtem.setText("");
|
||||
inputtem.setEnabled(true);
|
||||
} else {
|
||||
radioContainer.mark(0);
|
||||
Preference_RW.ff2_w(1);
|
||||
Random rand = new Random();//36.0-36.9
|
||||
DecimalFormat df = new DecimalFormat("0.0");
|
||||
inputtem.setText(df.format((float) (rand.nextInt(10) + 360) / 10));
|
||||
}
|
||||
radioContainer.setMarkChangedListener(new RadioContainer.CheckedStateChangedListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(RadioContainer radioContainer, int i) {
|
||||
XLog.info(label, "用户选择的是:" + i);
|
||||
if (i == 0) {
|
||||
XLog.info(label, "用户选择的是:是");
|
||||
Preference_RW.ff2_w(1);
|
||||
Random rand = new Random();//36.0-36.9
|
||||
DecimalFormat df = new DecimalFormat("0.0");
|
||||
inputtem.setText(df.format((float) (rand.nextInt(10) + 360) / 10));
|
||||
inputtem.setEnabled(false);
|
||||
} else if (i == 1) {
|
||||
XLog.info(label, "用户选择的是:否");
|
||||
Preference_RW.ff2_w(2);
|
||||
inputtem.setText("");
|
||||
inputtem.setEnabled(true);
|
||||
} else {
|
||||
XLog.error(label, "这tm不可能!");
|
||||
}
|
||||
}
|
||||
});
|
||||
RadioContainer radioContainer1 = (RadioContainer) findComponentById(ResourceTable.Id_radio_container1);
|
||||
radioContainer1.cancelMarks();
|
||||
if (Preference_RW.ff4_r() == 1) {
|
||||
radioContainer1.mark(0);
|
||||
} else if (Preference_RW.ff4_r() == 2) {
|
||||
radioContainer1.mark(1);
|
||||
} else {
|
||||
radioContainer1.mark(0);
|
||||
Preference_RW.ff4_w(1);
|
||||
}
|
||||
radioContainer1.setMarkChangedListener(new RadioContainer.CheckedStateChangedListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(RadioContainer radioContainer, int i) {
|
||||
XLog.info(label, "用户选择的是:" + i);
|
||||
if (i == 0) {
|
||||
XLog.info(label, "用户选择的是:是");
|
||||
Preference_RW.ff4_w(1);
|
||||
} else if (i == 1) {
|
||||
XLog.info(label, "用户选择的是:否");
|
||||
Preference_RW.ff4_w(2);
|
||||
} else {
|
||||
XLog.error(label, "这tm不可能!");
|
||||
}
|
||||
}
|
||||
});
|
||||
Button daka = (Button) findComponentById(ResourceTable.Id_sddk_button);
|
||||
daka.setClickedListener(new Component.ClickedListener() {
|
||||
@Override
|
||||
public void onClick(Component component) {
|
||||
url1.put("mobile", Preference_RW.ff1_r());
|
||||
url1.put("city", city);
|
||||
url1.put("jk_type", "健康");
|
||||
url1.put("district", district);
|
||||
url1.put("address", province + city + district + street);
|
||||
url1.put("title", inputtem.getText());
|
||||
url1.put("jc_type", "否");
|
||||
url1.put("wc_type", "否");
|
||||
url1.put("is_verify", "0");
|
||||
url1.put("province", province);
|
||||
MyApplication.getInstance().getWan().postDKXX(url1).enqueue(new Callback<TJXX>() {
|
||||
@Override
|
||||
public void onResponse(Call<TJXX> call, Response<TJXX> response) {
|
||||
ShowDialog("打卡成功!");
|
||||
XLog.info(label, response.body().msg);
|
||||
result.setText(response.body().msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<TJXX> call, Throwable t) {
|
||||
XLog.error(label, t.getMessage());
|
||||
ShowDialog("打卡失败!错误原因:" + t.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void ShowDialog(String text1) {
|
||||
try {
|
||||
new MyToastDialog(this.getContext(), text1, ResourceTable.Graphic_xtoast_framem, 36, 25)
|
||||
.setDuration(120)
|
||||
.setAlignment(LayoutAlignment.BOTTOM)
|
||||
.setOffset(0, 100)
|
||||
.show();
|
||||
} catch (Exception e) {
|
||||
|
||||
XLog.error(label, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
XLog.info(label, "onStop start");
|
||||
super.onStop();
|
||||
try {
|
||||
fusedLocationClient.removeLocationUpdates(locationCallback)
|
||||
.addOnSuccessListener(v -> {
|
||||
// 接口调用成功的处理
|
||||
XLog.info(label, "removeLocationUpdates success");
|
||||
})
|
||||
.addOnFailureListener(e -> {
|
||||
// 接口调用失败的处理
|
||||
XLog.error(label, "removeLocationUpdates failure");
|
||||
});
|
||||
} catch (Exception e) {
|
||||
|
||||
XLog.error(label, e.getMessage());
|
||||
}
|
||||
XLog.info(label, "onStop end");
|
||||
}
|
||||
}
|
||||
|
16
DaKa/entry/src/main/resources/base/element/string.json
Normal file
16
DaKa/entry/src/main/resources/base/element/string.json
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name": "entry_MainAbility",
|
||||
"value": "校企通[魔改版]"
|
||||
},
|
||||
{
|
||||
"name": "mainability_description",
|
||||
"value": "Java_Empty Ability"
|
||||
},
|
||||
{
|
||||
"name": "mainability_HelloWorld",
|
||||
"value": "Hello World"
|
||||
}
|
||||
]
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape
|
||||
xmlns:ohos="http://schemas.huawei.com/res/ohos"
|
||||
ohos:shape="rectangle">
|
||||
|
||||
<solid
|
||||
ohos:color="#D89BCBFF"/>
|
||||
|
||||
<corners
|
||||
ohos:radius="4"/>
|
||||
</shape>
|
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape
|
||||
xmlns:ohos="http://schemas.huawei.com/res/ohos"
|
||||
ohos:shape="rectangle">
|
||||
|
||||
<stroke
|
||||
ohos:width="5"
|
||||
ohos:color="#FF6D788A"/>
|
||||
|
||||
<corners
|
||||
ohos:radius="4"/>
|
||||
</shape>
|
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<state-container
|
||||
xmlns:ohos="http://schemas.huawei.com/res/ohos">
|
||||
|
||||
<item
|
||||
ohos:element="$graphic:background_checkbox_checkedm"
|
||||
ohos:state="component_state_checked"/>
|
||||
|
||||
<item
|
||||
ohos:element="$graphic:background_checkbox_emptym"
|
||||
ohos:state="component_state_empty"/>
|
||||
</state-container>
|
11
DaKa/entry/src/main/resources/base/graphic/xtoast_framem.xml
Normal file
11
DaKa/entry/src/main/resources/base/graphic/xtoast_framem.xml
Normal file
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape
|
||||
xmlns:ohos="http://schemas.huawei.com/res/ohos"
|
||||
ohos:shape="rectangle">
|
||||
|
||||
<corners
|
||||
ohos:radius="30vp"/>
|
||||
|
||||
<solid
|
||||
ohos:color="#FFE2C7C7"/>
|
||||
</shape>
|
345
DaKa/entry/src/main/resources/base/layout/main_ability_slice.xml
Normal file
345
DaKa/entry/src/main/resources/base/layout/main_ability_slice.xml
Normal file
@@ -0,0 +1,345 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<DirectionalLayout
|
||||
xmlns:ohos="http://schemas.huawei.com/res/ohos"
|
||||
ohos:height="match_parent"
|
||||
ohos:width="match_parent"
|
||||
ohos:background_element="#F8F3ECEC"
|
||||
ohos:bottom_padding="20vp"
|
||||
ohos:left_padding="15vp"
|
||||
ohos:orientation="vertical"
|
||||
ohos:right_padding="15vp"
|
||||
ohos:top_padding="30vp">
|
||||
|
||||
<DirectionalLayout
|
||||
ohos:height="match_parent"
|
||||
ohos:width="match_parent"
|
||||
ohos:layout_alignment="center"
|
||||
ohos:orientation="horizontal"
|
||||
ohos:weight="1"
|
||||
>
|
||||
|
||||
<Text
|
||||
ohos:height="match_parent"
|
||||
ohos:width="match_parent"
|
||||
ohos:layout_alignment="center"
|
||||
ohos:margin="1vp"
|
||||
ohos:text="打卡账号"
|
||||
ohos:text_color="black"
|
||||
ohos:text_size="25vp"
|
||||
ohos:weight="2"
|
||||
/>
|
||||
|
||||
<TextField
|
||||
ohos:id="$+id:dxzh"
|
||||
ohos:height="match_parent"
|
||||
ohos:width="match_parent"
|
||||
ohos:bubble_height="15px"
|
||||
ohos:bubble_left_height="17px"
|
||||
ohos:bubble_left_width="20px"
|
||||
ohos:bubble_right_height="17px"
|
||||
ohos:bubble_right_width="20px"
|
||||
ohos:bubble_width="15px"
|
||||
ohos:hint="学号或身份证号"
|
||||
ohos:hint_color="#FFAE8787"
|
||||
ohos:layout_alignment="center"
|
||||
ohos:left_padding="10vp"
|
||||
ohos:text_alignment="vertical_center|left"
|
||||
ohos:text_color="#FFA77728"
|
||||
ohos:text_size="16.5vp"
|
||||
ohos:truncation_mode="auto_scrolling"
|
||||
ohos:weight="3"
|
||||
/>
|
||||
</DirectionalLayout>
|
||||
|
||||
<DirectionalLayout
|
||||
ohos:height="match_parent"
|
||||
ohos:width="match_parent"
|
||||
ohos:layout_alignment="center"
|
||||
ohos:orientation="horizontal"
|
||||
ohos:weight="2"
|
||||
>
|
||||
|
||||
<Text
|
||||
ohos:height="match_parent"
|
||||
ohos:width="match_parent"
|
||||
ohos:layout_alignment="center"
|
||||
ohos:margin="1vp"
|
||||
ohos:multiple_lines="true"
|
||||
ohos:text="位置信息"
|
||||
ohos:text_color="black"
|
||||
ohos:text_size="20vp"
|
||||
ohos:weight="2"
|
||||
/>
|
||||
|
||||
<Text
|
||||
ohos:id="$+id:location_info"
|
||||
ohos:height="match_parent"
|
||||
ohos:width="match_parent"
|
||||
ohos:layout_alignment="center"
|
||||
ohos:margin="1vp"
|
||||
ohos:multiple_lines="true"
|
||||
ohos:scrollable="true"
|
||||
ohos:text_color="black"
|
||||
ohos:text_size="20vp"
|
||||
ohos:weight="4"
|
||||
/>
|
||||
</DirectionalLayout>
|
||||
|
||||
<DirectionalLayout
|
||||
ohos:height="match_parent"
|
||||
ohos:width="match_parent"
|
||||
ohos:layout_alignment="center"
|
||||
ohos:orientation="horizontal"
|
||||
ohos:weight="2"
|
||||
>
|
||||
|
||||
<Text
|
||||
ohos:height="match_parent"
|
||||
ohos:width="match_parent"
|
||||
ohos:layout_alignment="center"
|
||||
ohos:margin="1vp"
|
||||
ohos:multiple_lines="true"
|
||||
ohos:text="当前地理位置信息"
|
||||
ohos:text_color="black"
|
||||
ohos:text_size="20vp"
|
||||
ohos:weight="2"
|
||||
/>
|
||||
|
||||
<Text
|
||||
ohos:id="$+id:geo_address_info"
|
||||
ohos:height="match_parent"
|
||||
ohos:width="match_parent"
|
||||
ohos:layout_alignment="center"
|
||||
ohos:margin="1vp"
|
||||
ohos:multiple_lines="true"
|
||||
ohos:scrollable="true"
|
||||
ohos:text_color="black"
|
||||
ohos:text_size="20vp"
|
||||
ohos:weight="4"
|
||||
/>
|
||||
</DirectionalLayout>
|
||||
|
||||
<DirectionalLayout
|
||||
ohos:height="match_parent"
|
||||
ohos:width="match_parent"
|
||||
ohos:layout_alignment="center"
|
||||
ohos:orientation="horizontal"
|
||||
ohos:weight="1"
|
||||
>
|
||||
|
||||
<Text
|
||||
ohos:height="match_parent"
|
||||
ohos:width="match_parent"
|
||||
ohos:layout_alignment="center"
|
||||
ohos:margin="1vp"
|
||||
ohos:text="是否随机温度"
|
||||
ohos:text_color="black"
|
||||
ohos:text_size="20vp"
|
||||
ohos:weight="2"
|
||||
/>
|
||||
|
||||
<RadioContainer
|
||||
ohos:id="$+id:radio_container0"
|
||||
ohos:height="match_parent"
|
||||
ohos:width="0vp"
|
||||
ohos:layout_alignment="center"
|
||||
ohos:orientation="horizontal"
|
||||
ohos:weight="3"
|
||||
>
|
||||
|
||||
<RadioButton
|
||||
ohos:id="$+id:radio_button_1"
|
||||
ohos:height="match_parent"
|
||||
ohos:width="match_parent"
|
||||
ohos:check_element="$graphic:checkbox_check_elementm"
|
||||
ohos:text="是"
|
||||
ohos:text_color_off="#FF8A9AB5"
|
||||
ohos:text_color_on="#FF1773EF"
|
||||
ohos:text_size="23vp"
|
||||
ohos:weight="8"/>
|
||||
|
||||
<RadioButton
|
||||
ohos:id="$+id:radio_button_2"
|
||||
ohos:height="match_parent"
|
||||
ohos:width="match_parent"
|
||||
ohos:check_element="$graphic:checkbox_check_elementm"
|
||||
ohos:text="否"
|
||||
ohos:text_color_off="#FF8A9AB5"
|
||||
ohos:text_color_on="#FF1773EF"
|
||||
ohos:text_size="23vp"
|
||||
ohos:weight="8"/>
|
||||
</RadioContainer>
|
||||
</DirectionalLayout>
|
||||
|
||||
<DirectionalLayout
|
||||
ohos:height="match_parent"
|
||||
ohos:width="match_parent"
|
||||
ohos:layout_alignment="center"
|
||||
ohos:orientation="horizontal"
|
||||
ohos:weight="1"
|
||||
>
|
||||
|
||||
<Text
|
||||
ohos:height="match_parent"
|
||||
ohos:width="match_parent"
|
||||
ohos:layout_alignment="center"
|
||||
ohos:margin="1vp"
|
||||
ohos:text="打卡温度"
|
||||
ohos:text_color="black"
|
||||
ohos:text_size="20vp"
|
||||
ohos:weight="2"
|
||||
/>
|
||||
|
||||
<TextField
|
||||
ohos:id="$+id:dxtem"
|
||||
ohos:height="match_parent"
|
||||
ohos:width="match_parent"
|
||||
ohos:bubble_height="15px"
|
||||
ohos:bubble_left_height="17px"
|
||||
ohos:bubble_left_width="20px"
|
||||
ohos:bubble_right_height="17px"
|
||||
ohos:bubble_right_width="20px"
|
||||
ohos:bubble_width="15px"
|
||||
ohos:hint="温度"
|
||||
ohos:hint_color="#FFAB9B9B"
|
||||
ohos:layout_alignment="center"
|
||||
ohos:left_padding="10vp"
|
||||
ohos:text_alignment="vertical_center|left"
|
||||
ohos:text_color="#FF9D8051"
|
||||
ohos:text_size="20.5vp"
|
||||
ohos:truncation_mode="auto_scrolling"
|
||||
ohos:weight="3"
|
||||
/>
|
||||
</DirectionalLayout>
|
||||
|
||||
<DirectionalLayout
|
||||
ohos:height="match_parent"
|
||||
ohos:width="match_parent"
|
||||
ohos:layout_alignment="center"
|
||||
ohos:orientation="horizontal"
|
||||
ohos:weight="1"
|
||||
>
|
||||
|
||||
<Text
|
||||
ohos:height="match_parent"
|
||||
ohos:width="match_parent"
|
||||
ohos:layout_alignment="center"
|
||||
ohos:margin="1vp"
|
||||
ohos:text="是否自动打卡"
|
||||
ohos:text_color="black"
|
||||
ohos:text_size="20vp"
|
||||
ohos:weight="2"
|
||||
/>
|
||||
|
||||
<RadioContainer
|
||||
ohos:id="$+id:radio_container1"
|
||||
ohos:height="match_parent"
|
||||
ohos:width="0vp"
|
||||
ohos:layout_alignment="center"
|
||||
ohos:orientation="horizontal"
|
||||
ohos:weight="3"
|
||||
>
|
||||
|
||||
<RadioButton
|
||||
ohos:id="$+id:radio_button_11"
|
||||
ohos:height="match_parent"
|
||||
ohos:width="match_parent"
|
||||
ohos:check_element="$graphic:checkbox_check_elementm"
|
||||
ohos:text="是"
|
||||
ohos:text_color_off="#FF8A9AB5"
|
||||
ohos:text_color_on="#FF1773EF"
|
||||
ohos:text_size="23vp"
|
||||
ohos:weight="8"/>
|
||||
|
||||
<RadioButton
|
||||
ohos:id="$+id:radio_button_21"
|
||||
ohos:height="match_parent"
|
||||
ohos:width="match_parent"
|
||||
ohos:check_element="$graphic:checkbox_check_elementm"
|
||||
ohos:text="否"
|
||||
ohos:text_color_off="#FF8A9AB5"
|
||||
ohos:text_color_on="#FF1773EF"
|
||||
ohos:text_size="23vp"
|
||||
ohos:weight="8"/>
|
||||
</RadioContainer>
|
||||
</DirectionalLayout>
|
||||
|
||||
<DirectionalLayout
|
||||
ohos:height="match_parent"
|
||||
ohos:width="match_parent"
|
||||
ohos:layout_alignment="center"
|
||||
ohos:orientation="horizontal"
|
||||
ohos:weight="1"
|
||||
>
|
||||
|
||||
<Button
|
||||
ohos:id="$+id:stop_locating"
|
||||
ohos:height="match_parent"
|
||||
ohos:width="match_parent"
|
||||
ohos:layout_alignment="center"
|
||||
ohos:margin="1vp"
|
||||
ohos:text="停止定位"
|
||||
ohos:text_color="#FFFF0000"
|
||||
ohos:text_size="20vp"
|
||||
ohos:weight="1.5"
|
||||
/>
|
||||
|
||||
<Button
|
||||
ohos:id="$+id:save_button"
|
||||
ohos:height="match_parent"
|
||||
ohos:width="match_parent"
|
||||
ohos:layout_alignment="center"
|
||||
ohos:margin="1vp"
|
||||
ohos:text="保存"
|
||||
ohos:text_color="#FF8800FF"
|
||||
ohos:text_size="20vp"
|
||||
ohos:weight="1.5"
|
||||
/>
|
||||
|
||||
<Button
|
||||
ohos:id="$+id:sddk_button"
|
||||
ohos:height="match_parent"
|
||||
ohos:width="match_parent"
|
||||
ohos:background_element="#F8ACA3A3"
|
||||
ohos:layout_alignment="center"
|
||||
ohos:margin="1vp"
|
||||
ohos:text="点击打卡"
|
||||
ohos:text_color="#FF152D00"
|
||||
ohos:text_size="22vp"
|
||||
ohos:weight="2"
|
||||
/>
|
||||
</DirectionalLayout>
|
||||
|
||||
<DirectionalLayout
|
||||
ohos:height="match_parent"
|
||||
ohos:width="match_parent"
|
||||
ohos:layout_alignment="center"
|
||||
ohos:orientation="horizontal"
|
||||
ohos:weight="2"
|
||||
>
|
||||
|
||||
<Text
|
||||
ohos:height="match_parent"
|
||||
ohos:width="match_parent"
|
||||
ohos:layout_alignment="center"
|
||||
ohos:margin="1vp"
|
||||
ohos:multiple_lines="true"
|
||||
ohos:text="打卡状态"
|
||||
ohos:text_color="black"
|
||||
ohos:text_size="20vp"
|
||||
ohos:weight="2"
|
||||
/>
|
||||
|
||||
<Text
|
||||
ohos:id="$+id:dkjg"
|
||||
ohos:height="match_parent"
|
||||
ohos:width="match_parent"
|
||||
ohos:layout_alignment="center"
|
||||
ohos:margin="1vp"
|
||||
ohos:multiple_lines="true"
|
||||
ohos:text_color="#FF30FA2D"
|
||||
ohos:text_size="20vp"
|
||||
ohos:weight="4"
|
||||
/>
|
||||
</DirectionalLayout>
|
||||
</DirectionalLayout>
|
BIN
DaKa/entry/src/main/resources/base/media/icon.png
Normal file
BIN
DaKa/entry/src/main/resources/base/media/icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 21 KiB |
@@ -0,0 +1 @@
|
||||
你自己的agconnect-services.json文件
|
@@ -0,0 +1,14 @@
|
||||
package com.xcl.location;
|
||||
|
||||
import ohos.aafwk.ability.delegation.AbilityDelegatorRegistry;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class ExampleOhosTest {
|
||||
@Test
|
||||
public void testBundleName() {
|
||||
final String actualBundleName = AbilityDelegatorRegistry.getArguments().getTestBundleName();
|
||||
assertEquals("com.xcl.location", actualBundleName);
|
||||
}
|
||||
}
|
@@ -0,0 +1,9 @@
|
||||
package com.xcl.location;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class ExampleTest {
|
||||
@Test
|
||||
public void onStart() {
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user