Commit 94a3bfa0 authored by 周文华's avatar 周文华

Merge remote-tracking branch 'origin/master'

parents fc5034df e089febf
......@@ -2,20 +2,15 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.INTERNET" /> <!-- 大致位置,依赖网络 -->
<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. -->
<!-- Required for Android 10 (API level 29) and higher. -->
<!-- <service -->
<!-- android:foregroundServiceType="location" -->
<!-- android:name="MyNavigationService" /> -->
<!-- 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" />
<application
......@@ -29,7 +24,9 @@
android:supportsRtl="true"
android:theme="@style/Theme.LocationShareWhite"
tools:targetApi="34">
<activity
android:name=".ui.set.RenameActivity"
android:exported="false" />
<meta-data
android:name="com.google.android.geo.API_KEY"
......@@ -115,7 +112,6 @@
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="@string/facebook_app_id" />
</application>
</manifest>
\ No newline at end of file
......@@ -6,6 +6,6 @@ package com.base.locationsharewhite.bean
*/
data class ViewerBean(
val nickName: String,
val status: Int,
var status: Int,//0不可以看 1可以看
val device: String,
)
......@@ -27,6 +27,7 @@ class MyApplication : Application() {
var setLanguage: 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 renameLanguage: String = Locale.getDefault().language + "_" + Locale.getDefault().country
var umpCanAd: Boolean = true
......
......@@ -18,7 +18,7 @@ public class ReportUtils {
HttpURLConnection conn = (HttpURLConnection) new URL(urlPath).openConnection();
conn.setRequestMethod("POST");
conn.setDoOutput(true);
conn.setConnectTimeout(600000);
conn.setConnectTimeout(5000);
if (!TextUtils.isEmpty(json)) {
conn.setRequestProperty("Content-Type", "application/json");
conn.setRequestProperty("Content-Length", Integer.toString(json.getBytes().length));
......
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.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 LocationStatusUtils {
private val TAG = "LocationStatusUtils"
/**
* 改变别人是否可以看我的状态接口
*/
private val url by lazy {
val pkg = ConfigHelper.packageName
val url = StringBuilder(
"${ConfigHelper.apiUrl}/dingwei/${pkg.filter { it.isLowerCase() }.substring(4, 9)}f"
)
url.append("?pkg=$pkg")
url.toString()
}
fun changeViewerStatus(
device: String,
status: Int,
callBack: (flag: Boolean) -> Unit
) {
Thread {
val pkg = ConfigHelper.packageName
val data = JSONObject()
data.put("device", device)
data.put("status", status)
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, "paramJson=$paramJson")
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.main
import android.annotation.SuppressLint
import android.graphics.Color
import androidx.activity.addCallback
import androidx.core.view.updatePadding
......@@ -12,13 +13,16 @@ import com.base.locationsharewhite.location.LocationShareUtils.SHARE_STATE_FAILE
import com.base.locationsharewhite.location.LocationShareUtils.SHARE_STATE_MYSELF
import com.base.locationsharewhite.location.LocationShareUtils.SHARE_STATE_SHARED
import com.base.locationsharewhite.location.LocationShareUtils.SHARE_STATE_SUCCESS
import com.base.locationsharewhite.location.LocationStatusUtils
import com.base.locationsharewhite.utils.BarUtils
import com.base.locationsharewhite.utils.LogEx
import com.base.locationsharewhite.utils.ToastUtils.toast
/**
* 添加谁可以看我
*/
class LocationShareActivity : BaseActivity<ActivityLocationShareBinding>() {
private val TAG = "LocationShareActivity"
override val binding: ActivityLocationShareBinding by lazy {
ActivityLocationShareBinding.inflate(layoutInflater)
......@@ -26,6 +30,7 @@ class LocationShareActivity : BaseActivity<ActivityLocationShareBinding>() {
private lateinit var adapter: ViewerAdapter
@SuppressLint("NotifyDataSetChanged")
override fun initView() {
BarUtils.setStatusBarLightMode(this, true)
BarUtils.setStatusBarColor(this, Color.WHITE)
......@@ -41,7 +46,18 @@ class LocationShareActivity : BaseActivity<ActivityLocationShareBinding>() {
}
binding.shimmerLayout.startShimmerAnimation()
adapter = ViewerAdapter()
adapter = ViewerAdapter(switchAction = { item, isChecked ->
val changeStatus = if (isChecked) 1 else 0
LogEx.logDebug(TAG, "device=${item.device}")
LocationStatusUtils.changeViewerStatus(item.device, changeStatus) { flag ->
runOnUiThread {
if (flag) {
item.status = changeStatus
}
adapter.notifyDataSetChanged()
}
}
})
binding.rv.adapter = adapter
......
......@@ -3,6 +3,9 @@ package com.base.locationsharewhite.ui.main
import android.content.Context
import android.view.View
import android.view.ViewGroup
import android.widget.CompoundButton
import android.widget.RadioGroup
import android.widget.RadioGroup.OnCheckedChangeListener
import androidx.recyclerview.widget.RecyclerView.ViewHolder
import com.base.locationsharewhite.R
import com.base.locationsharewhite.bean.ViewerBean
......@@ -10,7 +13,9 @@ import com.base.locationsharewhite.databinding.ItemViewerBinding
import com.base.locationsharewhite.ui.views.XmlEx.inflate
import com.chad.library.adapter4.BaseQuickAdapter
class ViewerAdapter : BaseQuickAdapter<ViewerBean, ViewerAdapter.ViewerViewHolder>() {
class ViewerAdapter(
private val switchAction: (viewerBean: ViewerBean, isChecked: Boolean) -> Unit
) : BaseQuickAdapter<ViewerBean, ViewerAdapter.ViewerViewHolder>() {
inner class ViewerViewHolder(view: View) : ViewHolder(view)
......@@ -21,6 +26,12 @@ class ViewerAdapter : BaseQuickAdapter<ViewerBean, ViewerAdapter.ViewerViewHolde
binding.tvNameCode.text = item.nickName
binding.tvTime.text = "time"
binding.tvSwitch.isChecked = item.status == 1
binding.tvSwitch.setOnCheckedChangeListener { buttonView, isChecked ->
if (!buttonView.isPressed) {
return@setOnCheckedChangeListener
}
switchAction.invoke(item, isChecked)
}
}
override fun onCreateViewHolder(context: Context, parent: ViewGroup, viewType: Int): ViewerViewHolder {
......
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
import android.annotation.SuppressLint
import android.content.Intent
import android.graphics.Color
import androidx.activity.addCallback
import androidx.core.view.updatePadding
import com.base.locationsharewhite.R
import com.base.locationsharewhite.databinding.ActivitySettingBinding
import com.base.locationsharewhite.helper.BaseActivity
import com.base.locationsharewhite.helper.MyApplication
import com.base.locationsharewhite.location.LocationLoginUtils
import com.base.locationsharewhite.ui.views.RateDialog.showRateDialog
import com.base.locationsharewhite.utils.BarUtils
......@@ -17,10 +20,13 @@ class SettingActivity : BaseActivity<ActivitySettingBinding>() {
ActivitySettingBinding.inflate(layoutInflater)
}
@SuppressLint("SetTextI18n")
override fun initView() {
BarUtils.setStatusBarLightMode(this, true)
BarUtils.setStatusBarColor(this, Color.WHITE)
binding.root.updatePadding(top = BarUtils.getStatusBarHeight())
binding.tvHelloName.text = getString(R.string.hello) + ",\n" + LocationLoginUtils.nickNameSp
}
override fun initListener() {
......@@ -40,6 +46,9 @@ class SettingActivity : BaseActivity<ActivitySettingBinding>() {
binding.llRateUse.setOnClickListener {
showRateDialog(true)
}
binding.llRename.setOnClickListener {
startActivity(Intent(this, RenameActivity::class.java))
}
}
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 @@
app:layout_constraintStart_toEndOf="@id/fl_fanhui"
app:layout_constraintTop_toTopOf="@id/fl_fanhui" />
<FrameLayout
<LinearLayout
android:id="@+id/fl_rename"
android:layout_width="match_parent"
android:layout_height="88dp"
......@@ -44,15 +44,20 @@
app:layout_constraintTop_toBottomOf="@id/fl_fanhui">
<TextView
android:layout_width="wrap_content"
android:id="@+id/tv_hello_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="20dp"
android:layout_weight="1"
android:ellipsize="end"
android:maxLines="2"
android:text="@string/hello_ndefault"
android:textColor="@color/white"
android:textSize="28sp" />
<LinearLayout
android:id="@+id/ll_rename"
android:layout_width="wrap_content"
android:layout_height="38dp"
android:layout_gravity="center_vertical|end"
......@@ -79,7 +84,7 @@
android:textSize="17sp" />
</LinearLayout>
</FrameLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
......
......@@ -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="quit">QUIT</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>
\ 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