Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
L
location share white
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wanglei
location share white
Commits
c4077fee
Commit
c4077fee
authored
Oct 23, 2024
by
wanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
...
parent
2999b426
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
260 additions
and
15 deletions
+260
-15
ViewerBean.kt
.../main/java/com/base/locationsharewhite/bean/ViewerBean.kt
+11
-0
Viewing.kt
...src/main/java/com/base/locationsharewhite/bean/Viewing.kt
+16
-0
LocationLoginUtils.kt
...om/base/locationsharewhite/location/LocationLoginUtils.kt
+5
-2
LocationPositionUtils.kt
...base/locationsharewhite/location/LocationPositionUtils.kt
+3
-0
LocationShareListUtils.kt
...ase/locationsharewhite/location/LocationShareListUtils.kt
+78
-0
LocationShareUtils.kt
...om/base/locationsharewhite/location/LocationShareUtils.kt
+74
-0
LocationCodeActivity.kt
...m/base/locationsharewhite/ui/main/LocationCodeActivity.kt
+11
-0
LocationShareActivity.kt
.../base/locationsharewhite/ui/main/LocationShareActivity.kt
+46
-8
bg_cursor_3c93e2.xml
app/src/main/res/drawable/bg_cursor_3c93e2.xml
+5
-0
activity_location_code.xml
app/src/main/res/layout/activity_location_code.xml
+2
-0
activity_location_share.xml
app/src/main/res/layout/activity_location_share.xml
+7
-4
item_language.xml
app/src/main/res/layout/item_language.xml
+1
-1
strings.xml
app/src/main/res/values/strings.xml
+1
-0
No files found.
app/src/main/java/com/base/locationsharewhite/bean/ViewerBean.kt
0 → 100644
View file @
c4077fee
package
com.base.locationsharewhite.bean
/**
* 谁可以看我,可更改对我的可见状态
*/
data class
Viewer
(
val
nickName
:
String
,
val
status
:
Int
,
val
device
:
String
,
)
app/src/main/java/com/base/locationsharewhite/bean/Viewing.kt
0 → 100644
View file @
c4077fee
package
com.base.locationsharewhite.bean
/**
* 我可以看谁,自身无法切换状态
*/
data class
ViewingBean
(
val
nickname
:
String
,
val
status
:
Int
=
-
1
,
val
locatDate
:
LocationDate
?
=
null
,
)
data class
LocationDate
(
val
longitude
:
Double
,
val
latitude
:
Double
,
val
power
:
Double
,
)
\ No newline at end of file
app/src/main/java/com/base/locationsharewhite/location/LocationLoginUtils.kt
View file @
c4077fee
...
...
@@ -9,6 +9,9 @@ import com.base.locationsharewhite.utils.AppPreferences
import
com.base.locationsharewhite.utils.LogEx
import
org.json.JSONObject
/**
* 登录
*/
object
LocationLoginUtils
{
var
invitationCodeSp
=
""
...
...
@@ -28,7 +31,7 @@ object LocationLoginUtils {
AppPreferences
.
getInstance
().
put
(
"nickNameSp"
,
value
,
true
)
}
private
val
TAG
=
"Location
Request
Utils"
private
val
TAG
=
"Location
Login
Utils"
private
const
val
DATA_KEY
=
"data"
private
val
url
by
lazy
{
...
...
@@ -79,7 +82,7 @@ object LocationLoginUtils {
}
private
fun
extractData
(
response
:
String
):
String
?
{
fun
extractData
(
response
:
String
):
String
?
{
val
regex
=
Regex
(
"\"$DATA_KEY\":\"(.*?)\""
)
val
match
=
regex
.
find
(
response
)
return
match
?.
groupValues
?.
get
(
1
)
...
...
app/src/main/java/com/base/locationsharewhite/location/LocationPositionUtils.kt
View file @
c4077fee
...
...
@@ -10,6 +10,9 @@ import com.base.locationsharewhite.utils.LogEx
import
com.google.android.gms.maps.model.LatLng
import
org.json.JSONObject
/**
* 上报自身位置
*/
object
LocationPositionUtils
{
private
val
TAG
=
"LocationPositionUtils"
...
...
app/src/main/java/com/base/locationsharewhite/location/LocationShareListUtils.kt
0 → 100644
View file @
c4077fee
package
com.base.locationsharewhite.location
import
android.os.Build
import
com.base.locationsharewhite.BuildConfig
import
com.base.locationsharewhite.bean.Viewer
import
com.base.locationsharewhite.bean.ViewingBean
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
LocationShareListUtils
{
private
val
TAG
=
"LocationListUtils"
/**
* 分享关系列表
*/
private
val
url
by
lazy
{
val
pkg
=
ConfigHelper
.
packageName
val
url
=
StringBuilder
(
"${ConfigHelper.apiUrl}/dingwei/${pkg.filter { it.isLowerCase() }.substring(4, 9)}ac"
)
url
.
append
(
"?pkg=$pkg"
)
url
.
toString
()
}
fun
getShareList
(
viewerListCallBack
:
((
viewerList
:
List
<
Viewer
>)
->
Unit
)?
=
null
,
viewingListCallBack
:
((
viewingList
:
List
<
ViewingBean
>)
->
Unit
)?
=
null
)
{
Thread
{
val
pkg
=
ConfigHelper
.
packageName
val
data
=
JSONObject
()
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
)
val
result
=
ReportUtils
.
doPost
(
url
,
HashMap
(),
paramJson
)
val
responseData
=
LocationLoginUtils
.
extractData
(
result
)
if
(
responseData
!=
null
)
{
val
decryptedData
=
AESHelper
.
decrypt
(
responseData
)
parseShareListData
(
decryptedData
,
viewerListCallBack
,
viewingListCallBack
)
}
}.
start
()
}
private
fun
parseShareListData
(
decryptedData
:
String
,
viewerListCallBack
:
((
viewerList
:
List
<
Viewer
>)
->
Unit
)?
=
null
,
viewingListCallBack
:
((
viewingList
:
List
<
ViewingBean
>)
->
Unit
)?
=
null
)
{
val
jsonObject
=
JSONObject
(
decryptedData
)
val
viewerListJson
=
jsonObject
.
getJSONArray
(
"viewerList"
).
toString
()
LogEx
.
logDebug
(
TAG
,
"viewerListJson=$viewerListJson"
)
val
viewingListJson
=
jsonObject
.
getJSONArray
(
"viewingList"
).
toString
()
LogEx
.
logDebug
(
TAG
,
"viewingListJson=$viewingListJson"
)
}
}
\ No newline at end of file
app/src/main/java/com/base/locationsharewhite/location/LocationShareUtils.kt
0 → 100644
View file @
c4077fee
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.location.LocationLoginUtils.extractData
import
com.base.locationsharewhite.utils.AppPreferences
import
com.base.locationsharewhite.utils.LogEx
import
org.json.JSONObject
/**
* 通过邀请码建立分享关系
*/
object
LocationShareUtils
{
private
val
TAG
=
"ShareLocationUtils"
const
val
SHARE_STATE_FAILED
=
0
const
val
SHARE_STATE_SUCCESS
=
1
const
val
SHARE_STATE_SHARED
=
2
const
val
SHARE_STATE_MYSELF
=
3
/**
* 分享位置接口
*/
private
val
url
by
lazy
{
val
pkg
=
ConfigHelper
.
packageName
val
url
=
StringBuilder
(
"${ConfigHelper.apiUrl}/dingwei/${pkg.filter { it.isLowerCase() }.substring(4, 9)}m"
)
url
.
append
(
"?pkg=$pkg"
)
url
.
toString
()
}
fun
shareMyLocationByInvitationCode
(
invitationCode
:
String
,
callBack
:
(
state
:
Int
)
->
Unit
)
{
Thread
{
val
pkg
=
ConfigHelper
.
packageName
val
data
=
JSONObject
()
data
.
put
(
"invitationCode"
,
invitationCode
)
LogEx
.
logDebug
(
TAG
,
"invitationCode=${invitationCode}"
)
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
)
LogEx
.
logDebug
(
TAG
,
"uuid=${AppPreferences.getInstance().getString("
uuid
", "")}"
)
val
body
=
JSONObject
()
.
put
(
"data"
,
data
)
.
put
(
"bp"
,
bp
)
.
toString
()
val
paramJson
=
AESHelper
.
encrypt
(
body
)
val
result
=
ReportUtils
.
doPost
(
url
,
HashMap
(),
paramJson
)
val
responseData
=
extractData
(
result
)
if
(
responseData
!=
null
)
{
val
state
=
AESHelper
.
decrypt
(
responseData
).
toInt
()
callBack
.
invoke
(
state
)
}
else
{
callBack
.
invoke
(
0
)
}
}.
start
()
}
}
\ No newline at end of file
app/src/main/java/com/base/locationsharewhite/ui/main/LocationCodeActivity.kt
View file @
c4077fee
...
...
@@ -3,9 +3,14 @@ package com.base.locationsharewhite.ui.main
import
android.graphics.Color
import
androidx.activity.addCallback
import
androidx.core.view.updatePadding
import
com.base.locationsharewhite.R
import
com.base.locationsharewhite.databinding.ActivityLocationCodeBinding
import
com.base.locationsharewhite.helper.BaseActivity
import
com.base.locationsharewhite.location.LocationLoginUtils
import
com.base.locationsharewhite.utils.BarUtils
import
com.base.locationsharewhite.utils.ClipboardUtils.copyText
import
com.base.locationsharewhite.utils.ToastUtils.toast
class
LocationCodeActivity
:
BaseActivity
<
ActivityLocationCodeBinding
>()
{
...
...
@@ -18,6 +23,12 @@ class LocationCodeActivity : BaseActivity<ActivityLocationCodeBinding>() {
BarUtils
.
setStatusBarLightMode
(
this
,
true
)
BarUtils
.
setStatusBarColor
(
this
,
Color
.
WHITE
)
binding
.
root
.
updatePadding
(
top
=
BarUtils
.
getStatusBarHeight
())
binding
.
tvCode
.
text
=
LocationLoginUtils
.
invitationCodeSp
binding
.
tvCopy
.
setOnClickListener
{
copyText
(
"MyLocationCode"
,
binding
.
tvCode
.
text
.
toString
())
toast
(
resources
.
getString
(
R
.
string
.
copy
))
}
}
override
fun
initListener
()
{
...
...
app/src/main/java/com/base/locationsharewhite/ui/main/LocationShareActivity.kt
View file @
c4077fee
...
...
@@ -3,14 +3,20 @@ package com.base.locationsharewhite.ui.main
import
android.graphics.Color
import
androidx.activity.addCallback
import
androidx.core.view.updatePadding
import
com.base.locationsharewhite.R
import
com.base.locationsharewhite.databinding.ActivityLocationShareBinding
import
com.base.locationsharewhite.helper.BaseActivity
import
com.base.locationsharewhite.location.LocationLoginUtils
import
com.base.locationsharewhite.location.LocationShareListUtils
import
com.base.locationsharewhite.location.LocationShareUtils
import
com.base.locationsharewhite.location.LocationShareUtils.SHARE_STATE_FAILED
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.utils.BarUtils
import
com.base.locationsharewhite.utils.ClipboardUtils.copyText
import
com.base.locationsharewhite.utils.ToastUtils.toast
/**
* 添加谁可以看我
*/
class
LocationShareActivity
:
BaseActivity
<
ActivityLocationShareBinding
>()
{
override
val
binding
:
ActivityLocationShareBinding
by
lazy
{
...
...
@@ -23,13 +29,10 @@ class LocationShareActivity : BaseActivity<ActivityLocationShareBinding>() {
BarUtils
.
setStatusBarColor
(
this
,
Color
.
WHITE
)
binding
.
root
.
updatePadding
(
top
=
BarUtils
.
getStatusBarHeight
())
binding
.
tvCode
.
text
=
LocationLoginUtils
.
invitationCodeSp
binding
.
ivCopy
.
setOnClickListener
{
copyText
(
"MyLocationCode"
,
binding
.
tvCode
.
text
.
toString
())
toast
(
resources
.
getString
(
R
.
string
.
copy
))
}
initShareData
()
}
override
fun
initListener
()
{
super
.
initListener
()
onBackPressedDispatcher
.
addCallback
{
...
...
@@ -38,6 +41,41 @@ class LocationShareActivity : BaseActivity<ActivityLocationShareBinding>() {
binding
.
flFanhui
.
setOnClickListener
{
onBackPressedDispatcher
.
onBackPressed
()
}
binding
.
tvShare
.
setOnClickListener
{
val
code
=
binding
.
editCode
.
text
.
toString
()
if
(
code
.
length
>=
8
)
{
LocationShareUtils
.
shareMyLocationByInvitationCode
(
code
)
{
status
->
runOnUiThread
{
when
(
status
)
{
SHARE_STATE_FAILED
->
{
toast
(
"Code verification failed"
)
}
SHARE_STATE_SUCCESS
->
{
toast
(
"Code verification success"
)
}
SHARE_STATE_SHARED
->
{
toast
(
"Sharing code has been added"
)
}
SHARE_STATE_MYSELF
->
{
toast
(
"Sharing code is yourself code"
)
}
}
}
}
}
else
{
toast
(
"code verification failed"
)
}
}
}
private
fun
initShareData
()
{
LocationShareListUtils
.
getShareList
(
viewerListCallBack
=
{
})
}
...
...
app/src/main/res/drawable/bg_cursor_3c93e2.xml
0 → 100644
View file @
c4077fee
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<solid
android:color=
"#3C93E2"
/>
<size
android:width=
"1dp"
/>
</shape>
\ No newline at end of file
app/src/main/res/layout/activity_location_code.xml
View file @
c4077fee
...
...
@@ -69,6 +69,7 @@
android:background=
"@drawable/bg_stroke_dash_03b988_15"
>
<TextView
android:id=
"@+id/tv_code"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center"
...
...
@@ -78,6 +79,7 @@
tools:text=
"AZEQFOU2"
/>
<ImageView
android:id=
"@+id/tv_copy"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"end"
...
...
app/src/main/res/layout/activity_location_share.xml
View file @
c4077fee
...
...
@@ -28,7 +28,7 @@
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"@string/
my
_location_code"
android:text=
"@string/
share
_location_code"
android:textColor=
"#001725"
android:textSize=
"22sp"
android:textStyle=
"bold"
...
...
@@ -68,18 +68,20 @@
android:layout_marginTop=
"30dp"
android:background=
"@drawable/bg_stroke_dash_03b988_15"
>
<
TextView
android:id=
"@+id/
tv
_code"
<
EditText
android:id=
"@+id/
edit
_code"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center"
android:layout_marginHorizontal=
"
4
0dp"
android:layout_marginHorizontal=
"
8
0dp"
android:background=
"@null"
android:gravity=
"center"
android:hint=
"@string/enter_others_location_code"
android:maxLength=
"8"
android:maxLines=
"2"
android:textColor=
"#3C93E2"
android:textColorHint=
"#98C3F0"
android:textCursorDrawable=
"@drawable/bg_cursor_3c93e2"
android:textSize=
"26sp"
android:textStyle=
"bold"
tools:ignore=
"Autofill,TextFields"
/>
...
...
@@ -96,6 +98,7 @@
<TextView
android:id=
"@+id/tv_share"
android:layout_width=
"match_parent"
android:layout_height=
"50dp"
android:layout_marginHorizontal=
"16dp"
...
...
app/src/main/res/layout/item_language.xml
View file @
c4077fee
...
...
@@ -2,7 +2,7 @@
<FrameLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:tools=
"http://schemas.android.com/tools"
android:id=
"@+id/fl"
android:layout_width=
"1
85
dp"
android:layout_width=
"1
60
dp"
android:layout_height=
"76dp"
android:layout_margin=
"6dp"
android:background=
"@drawable/bg_language_selector"
>
...
...
app/src/main/res/values/strings.xml
View file @
c4077fee
...
...
@@ -4,6 +4,7 @@
<string
name=
"friend_location_map"
>
Friend Location Map
</string>
<string
name=
"view_friend_locations_on_the_map"
>
View friend locations on the map
</string>
<string
name=
"my_location_code"
>
My Location code
</string>
<string
name=
"share_location_code"
>
Share My Location
</string>
<string
name=
"share_my_location"
>
Share my location
</string>
<string
name=
"how_to_use"
>
How to use?
</string>
<string
name=
"settings"
>
Settings
</string>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment