Commit e089febf authored by wanglei's avatar wanglei

...

parent f5d694de
...@@ -2,20 +2,15 @@ ...@@ -2,20 +2,15 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"> xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.INTERNET" /> <!-- 大致位置,依赖网络 --> <uses-permission android:name="android.permission.INTERNET" /> <!-- 大致位置,依赖网络 -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <!-- 精确的位置,GPS --> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <!-- 精确的位置,GPS -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <!-- Recommended for Android 9 (API level 28) and lower. --> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <!-- Recommended for Android 9 (API level 28) and lower. -->
<!-- Required for Android 10 (API level 29) and higher. --> <!-- Required for Android 10 (API level 29) and higher. -->
<!-- <service --> <!-- <service -->
<!-- android:foregroundServiceType="location" --> <!-- android:foregroundServiceType="location" -->
<!-- android:name="MyNavigationService" /> --> <!-- android:name="MyNavigationService" /> -->
<!-- Required only when requesting background location access on Android 10 (API level 29) and higher. --> <!-- Required only when requesting background location access on Android 10 (API level 29) and higher. -->
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" /> <!-- 身体活动数据 -->
<!-- 身体活动数据 -->
<uses-permission android:name="android.permission.ACTIVITY_RECOGNITION" /> <uses-permission android:name="android.permission.ACTIVITY_RECOGNITION" />
<application <application
...@@ -29,7 +24,9 @@ ...@@ -29,7 +24,9 @@
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/Theme.LocationShareWhite" android:theme="@style/Theme.LocationShareWhite"
tools:targetApi="34"> tools:targetApi="34">
<activity
android:name=".ui.set.RenameActivity"
android:exported="false" />
<meta-data <meta-data
android:name="com.google.android.geo.API_KEY" android:name="com.google.android.geo.API_KEY"
...@@ -115,7 +112,6 @@ ...@@ -115,7 +112,6 @@
<meta-data <meta-data
android:name="com.facebook.sdk.ApplicationId" android:name="com.facebook.sdk.ApplicationId"
android:value="@string/facebook_app_id" /> android:value="@string/facebook_app_id" />
</application> </application>
</manifest> </manifest>
\ No newline at end of file
...@@ -27,6 +27,7 @@ class MyApplication : Application() { ...@@ -27,6 +27,7 @@ class MyApplication : Application() {
var setLanguage: String = Locale.getDefault().language + "_" + Locale.getDefault().country var setLanguage: String = Locale.getDefault().language + "_" + Locale.getDefault().country
var settingsLanguage: String = Locale.getDefault().language + "_" + Locale.getDefault().country var settingsLanguage: String = Locale.getDefault().language + "_" + Locale.getDefault().country
var howUseLanguage: String = Locale.getDefault().language + "_" + Locale.getDefault().country var howUseLanguage: String = Locale.getDefault().language + "_" + Locale.getDefault().country
var renameLanguage: String = Locale.getDefault().language + "_" + Locale.getDefault().country
var umpCanAd: Boolean = true var umpCanAd: Boolean = true
......
package com.base.locationsharewhite.location
import android.os.Build
import com.base.locationsharewhite.BuildConfig
import com.base.locationsharewhite.helper.AESHelper
import com.base.locationsharewhite.helper.ConfigHelper
import com.base.locationsharewhite.helper.ReportUtils
import com.base.locationsharewhite.utils.AppPreferences
import com.base.locationsharewhite.utils.LogEx
import org.json.JSONObject
object LocationNameUtils {
private val TAG = "LocationNameUtils"
private val url by lazy {
val pkg = ConfigHelper.packageName
val url = StringBuilder(
"${ConfigHelper.apiUrl}/dingwei/${pkg.filter { it.isLowerCase() }.substring(4, 9)}ggca"
)
url.append("?pkg=$pkg")
url.toString()
}
fun renameNickName(nickname: String, callBack: (flag: Boolean) -> Unit) {
Thread {
val pkg = ConfigHelper.packageName
val data = JSONObject()
data.put("nickName", nickname)
val bp = JSONObject()
// .put("${pkg}_1", "")
.put("${pkg}_5", Build.VERSION.SDK_INT)
.put("${pkg}_8", BuildConfig.VERSION_NAME)
.put("${pkg}_9", AppPreferences.getInstance().getString("uuid", ""))
.put("${pkg}_10", AppPreferences.getInstance().getString("uuid", ""))//gid
.put("${pkg}_13", "android")
.put("${pkg}_14", BuildConfig.VERSION_CODE)
.put("${pkg}_15", "google")
.put("${pkg}_24", BuildConfig.BUILD_TYPE)
val body = JSONObject()
.put("data", data)
.put("bp", bp)
.toString()
val paramJson = AESHelper.encrypt(body)
LogEx.logDebug(TAG, "url=${url}")
runCatching {
val result = ReportUtils.doPost(url, HashMap(), paramJson)
LogEx.logDebug(TAG, "result=$result")
val responseData = LocationLoginUtils.extractData(result)
LogEx.logDebug(TAG, "responseData=$responseData")
if (responseData != null) {
val state = AESHelper.decrypt(responseData).toBoolean()
callBack.invoke(state)
} else {
callBack.invoke(false)
}
}
}.start()
}
}
\ No newline at end of file
package com.base.locationsharewhite.ui.set
import android.graphics.Color
import androidx.core.view.updatePadding
import com.base.locationsharewhite.R
import com.base.locationsharewhite.databinding.ActivityRenameBinding
import com.base.locationsharewhite.helper.BaseActivity
import com.base.locationsharewhite.helper.MyApplication
import com.base.locationsharewhite.location.LocationLoginUtils
import com.base.locationsharewhite.location.LocationNameUtils
import com.base.locationsharewhite.utils.BarUtils
import com.base.locationsharewhite.utils.ToastUtils.toast
class RenameActivity : BaseActivity<ActivityRenameBinding>() {
private val TAG = "RenameActivity"
override val binding: ActivityRenameBinding by lazy {
ActivityRenameBinding.inflate(layoutInflater)
}
override fun initView() {
BarUtils.setStatusBarLightMode(this, true)
BarUtils.setStatusBarColor(this, Color.TRANSPARENT)
binding.root.updatePadding(top = BarUtils.getStatusBarHeight())
binding.editName.setText(LocationLoginUtils.nickNameSp)
}
override fun initListener() {
super.initListener()
binding.tvRename.setOnClickListener {
val newName = binding.editName.text.toString()
if (newName.isEmpty()) {
toast(getString(R.string.name_is_empty))
return@setOnClickListener
}
LocationNameUtils.renameNickName(newName) { flag ->
runCatching {
if (flag) {
toast("Rename success")
} else {
toast("Rename failed")
}
}
}
}
}
override fun onResume() {
super.onResume()
val isRecreate = updateAppLanguage(MyApplication.renameLanguage, TAG) {
MyApplication.renameLanguage = it
}
if (isRecreate) {
return
}
}
}
\ No newline at end of file
package com.base.locationsharewhite.ui.set package com.base.locationsharewhite.ui.set
import android.annotation.SuppressLint
import android.content.Intent import android.content.Intent
import android.graphics.Color import android.graphics.Color
import androidx.activity.addCallback import androidx.activity.addCallback
import androidx.core.view.updatePadding import androidx.core.view.updatePadding
import com.base.locationsharewhite.R
import com.base.locationsharewhite.databinding.ActivitySettingBinding import com.base.locationsharewhite.databinding.ActivitySettingBinding
import com.base.locationsharewhite.helper.BaseActivity import com.base.locationsharewhite.helper.BaseActivity
import com.base.locationsharewhite.helper.MyApplication import com.base.locationsharewhite.helper.MyApplication
import com.base.locationsharewhite.location.LocationLoginUtils
import com.base.locationsharewhite.ui.views.RateDialog.showRateDialog import com.base.locationsharewhite.ui.views.RateDialog.showRateDialog
import com.base.locationsharewhite.utils.BarUtils import com.base.locationsharewhite.utils.BarUtils
...@@ -17,10 +20,13 @@ class SettingActivity : BaseActivity<ActivitySettingBinding>() { ...@@ -17,10 +20,13 @@ class SettingActivity : BaseActivity<ActivitySettingBinding>() {
ActivitySettingBinding.inflate(layoutInflater) ActivitySettingBinding.inflate(layoutInflater)
} }
@SuppressLint("SetTextI18n")
override fun initView() { override fun initView() {
BarUtils.setStatusBarLightMode(this, true) BarUtils.setStatusBarLightMode(this, true)
BarUtils.setStatusBarColor(this, Color.WHITE) BarUtils.setStatusBarColor(this, Color.WHITE)
binding.root.updatePadding(top = BarUtils.getStatusBarHeight()) binding.root.updatePadding(top = BarUtils.getStatusBarHeight())
binding.tvHelloName.text = getString(R.string.hello) + ",\n" + LocationLoginUtils.nickNameSp
} }
override fun initListener() { override fun initListener() {
...@@ -40,6 +46,9 @@ class SettingActivity : BaseActivity<ActivitySettingBinding>() { ...@@ -40,6 +46,9 @@ class SettingActivity : BaseActivity<ActivitySettingBinding>() {
binding.llRateUse.setOnClickListener { binding.llRateUse.setOnClickListener {
showRateDialog(true) showRateDialog(true)
} }
binding.llRename.setOnClickListener {
startActivity(Intent(this, RenameActivity::class.java))
}
} }
override fun onResume() { override fun onResume() {
......
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#03B988" />
<size android:width="2dp" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:orientation="vertical"
tools:context=".ui.set.RenameActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="130dp"
android:gravity="center"
android:text="@string/a_simple_name_can_make_nothers_find_you_faster"
android:textColor="#001D29"
android:textSize="20sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_marginHorizontal="16dp"
android:layout_marginTop="50dp"
android:background="@drawable/bg_stroke_03b988_10"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="16dp"
android:layout_marginTop="16dp"
android:text="@string/enter_your_name"
android:textColor="#999999"
android:textSize="20sp"
android:textStyle="bold" />
<EditText
android:id="@+id/edit_name"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginHorizontal="16dp"
android:layout_weight="1"
android:background="@null"
android:gravity="center_vertical"
android:singleLine="true"
android:textColor="#1F1F1F"
android:textCursorDrawable="@drawable/bg_cursor_3c93e2"
android:textSize="20sp"
tools:ignore="Autofill,LabelFor,TextFields"
tools:text="Default" />
</LinearLayout>
<TextView
android:id="@+id/tv_rename"
android:layout_width="345dp"
android:layout_height="50dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="24dp"
android:background="@drawable/bg_03b988_10"
android:gravity="center"
android:text="@string/rename"
android:textColor="@color/white"
android:textSize="18sp"
android:textStyle="bold" />
</LinearLayout>
\ No newline at end of file
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
app:layout_constraintStart_toEndOf="@id/fl_fanhui" app:layout_constraintStart_toEndOf="@id/fl_fanhui"
app:layout_constraintTop_toTopOf="@id/fl_fanhui" /> app:layout_constraintTop_toTopOf="@id/fl_fanhui" />
<FrameLayout <LinearLayout
android:id="@+id/fl_rename" android:id="@+id/fl_rename"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="88dp" android:layout_height="88dp"
...@@ -44,15 +44,20 @@ ...@@ -44,15 +44,20 @@
app:layout_constraintTop_toBottomOf="@id/fl_fanhui"> app:layout_constraintTop_toBottomOf="@id/fl_fanhui">
<TextView <TextView
android:layout_width="wrap_content" android:id="@+id/tv_hello_name"
android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:layout_marginStart="20dp" android:layout_marginStart="20dp"
android:layout_weight="1"
android:ellipsize="end"
android:maxLines="2"
android:text="@string/hello_ndefault" android:text="@string/hello_ndefault"
android:textColor="@color/white" android:textColor="@color/white"
android:textSize="28sp" /> android:textSize="28sp" />
<LinearLayout <LinearLayout
android:id="@+id/ll_rename"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="38dp" android:layout_height="38dp"
android:layout_gravity="center_vertical|end" android:layout_gravity="center_vertical|end"
...@@ -79,7 +84,7 @@ ...@@ -79,7 +84,7 @@
android:textSize="17sp" /> android:textSize="17sp" />
</LinearLayout> </LinearLayout>
</FrameLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
......
...@@ -49,4 +49,8 @@ ...@@ -49,4 +49,8 @@
<string name="are_you_sure_you_want_to_exit_the_app">Are you sure you want to\nexit the app?</string> <string name="are_you_sure_you_want_to_exit_the_app">Are you sure you want to\nexit the app?</string>
<string name="quit">QUIT</string> <string name="quit">QUIT</string>
<string name="facebook_app_id">123456789101112</string> <string name="facebook_app_id">123456789101112</string>
<string name="hello">Hello</string>
<string name="a_simple_name_can_make_nothers_find_you_faster">A simple name can make\nothers find you faster!</string>
<string name="enter_your_name">Enter your name</string>
<string name="name_is_empty">Name is empty</string>
</resources> </resources>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment