Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
石璀亮
/
agenew_a16_sos
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 1ab76129
authored
Aug 01, 2019
by
cuiliang.shi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
接口提示 直接延用服务端返回
1 parent
0e55d7e9
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
84 additions
and
60 deletions
app/build.gradle
app/src/main/java/com/toscl/location/hengfeng/activity/ServiceApplyActivity.java
app/src/main/java/com/toscl/location/hengfeng/activity/ServiceInfoActivity.java
app/src/main/java/com/toscl/location/hengfeng/activity/ServiceSettingActivity.java
app/src/main/java/com/toscl/location/hengfeng/activity/ServiceStopActivity.java
app/src/main/res/values/strings.xml
app/build.gradle
View file @
1ab7612
...
@@ -6,8 +6,8 @@ android {
...
@@ -6,8 +6,8 @@ android {
applicationId
"com.toscl.location.hengfeng"
applicationId
"com.toscl.location.hengfeng"
minSdkVersion
23
minSdkVersion
23
targetSdkVersion
28
targetSdkVersion
28
versionCode
5
versionCode
7
versionName
"0.
5
"
versionName
"0.
7
"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
}
}
buildTypes
{
buildTypes
{
...
...
app/src/main/java/com/toscl/location/hengfeng/activity/ServiceApplyActivity.java
View file @
1ab7612
...
@@ -124,12 +124,9 @@ public class ServiceApplyActivity extends Activity implements View.OnClickListen
...
@@ -124,12 +124,9 @@ public class ServiceApplyActivity extends Activity implements View.OnClickListen
cancelPreviousAlarmService
();
cancelPreviousAlarmService
();
sendBroadcastForNextStartService
();
sendBroadcastForNextStartService
();
Toast
.
makeText
(
ServiceApplyActivity
.
this
,
getString
(
R
.
string
.
apply_tips_success
),
Toast
.
LENGTH_SHORT
).
show
();
finish
();
finish
();
}
else
{
Toast
.
makeText
(
ServiceApplyActivity
.
this
,
msg
,
Toast
.
LENGTH_SHORT
).
show
();
}
}
Toast
.
makeText
(
ServiceApplyActivity
.
this
,
msg
,
Toast
.
LENGTH_SHORT
).
show
();
}
}
@Override
@Override
...
...
app/src/main/java/com/toscl/location/hengfeng/activity/ServiceInfoActivity.java
View file @
1ab7612
package
com
.
toscl
.
location
.
hengfeng
.
activity
;
package
com
.
toscl
.
location
.
hengfeng
.
activity
;
import
android.app.Activity
;
import
android.app.Activity
;
import
android.content.Context
;
import
android.content.pm.PackageInfo
;
import
android.content.pm.PackageManager
;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
com.toscl.location.hengfeng.R
;
import
com.toscl.location.hengfeng.R
;
...
@@ -11,6 +14,21 @@ public class ServiceInfoActivity extends Activity {
...
@@ -11,6 +14,21 @@ public class ServiceInfoActivity extends Activity {
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
service_info
);
setContentView
(
R
.
layout
.
service_info
);
setTitle
(
getString
(
R
.
string
.
title_server_info
));
setTitle
(
getString
(
R
.
string
.
title_server_info
)
+
" - "
+
packageName
(
this
)
);
}
}
public
static
String
packageName
(
Context
context
)
{
PackageManager
manager
=
context
.
getPackageManager
();
String
name
=
null
;
try
{
PackageInfo
info
=
manager
.
getPackageInfo
(
context
.
getPackageName
(),
0
);
name
=
info
.
versionName
;
}
catch
(
PackageManager
.
NameNotFoundException
e
)
{
e
.
printStackTrace
();
}
return
name
;
}
}
}
app/src/main/java/com/toscl/location/hengfeng/activity/ServiceSettingActivity.java
View file @
1ab7612
...
@@ -114,69 +114,79 @@ public class ServiceSettingActivity extends Activity implements View.OnClickList
...
@@ -114,69 +114,79 @@ public class ServiceSettingActivity extends Activity implements View.OnClickList
}
}
private
void
saveSetting
()
{
private
void
saveSetting
()
{
int
startIndex
=
mSpinnerForStartDate
.
getSelectedItemPosition
();
if
(
PreferencesUtil
.
getInstance
(
this
).
getBoolean
(
PreferencesUtil
.
HENG_FENG_IS_OEPN
,
false
)
int
endIndex
=
mSpinnerForEndDate
.
getSelectedItemPosition
();
&&
PhoneUtils
.
hengdaServiceAvailable
(
this
))
{
int
frequency
=
Integer
.
parseInt
(
mEtFrequency
.
getText
().
toString
());
int
startIndex
=
mSpinnerForStartDate
.
getSelectedItemPosition
();
int
endIndex
=
mSpinnerForEndDate
.
getSelectedItemPosition
();
int
frequency
;
try
{
frequency
=
Integer
.
parseInt
(
mEtFrequency
.
getText
().
toString
());
}
catch
(
Exception
e
){
Toast
.
makeText
(
this
,
getString
(
R
.
string
.
setting_frequency_error
),
Toast
.
LENGTH_SHORT
).
show
();
return
;
}
if
(
frequency
<
7
){
if
(
frequency
<
7
){
Toast
.
makeText
(
this
,
getString
(
R
.
string
.
setting_frequency_error
),
Toast
.
LENGTH_SHORT
).
show
();
Toast
.
makeText
(
this
,
getString
(
R
.
string
.
setting_frequency_error
),
Toast
.
LENGTH_SHORT
).
show
();
return
;
return
;
}
}
String
begin
=
startIndex
+
":00"
;
String
begin
=
startIndex
+
":00"
;
String
end
=
endIndex
+
":00"
;
String
end
=
endIndex
+
":00"
;
JSONObject
jsonBody
=
new
JSONObject
();
try
{
jsonBody
.
put
(
PreferencesUtil
.
HENG_FENG_REQ_SERVER_MEID
,
PhoneUtils
.
getPhoneMEID
(
getApplicationContext
()));
jsonBody
.
put
(
PreferencesUtil
.
HENG_FENG_REQ_SERVER_TEL
,
PreferencesUtil
.
getInstance
(
this
).
getString
(
PreferencesUtil
.
HENG_FENG_PHONE
,
""
));
jsonBody
.
put
(
PreferencesUtil
.
HENG_FENG_REQ_SERVER_TIME
,
System
.
currentTimeMillis
());
jsonBody
.
put
(
PreferencesUtil
.
HENG_FENG_SERVER_BEGIN
,
begin
);
jsonBody
.
put
(
PreferencesUtil
.
HENG_FENG_SERVER_END
,
end
);
jsonBody
.
put
(
PreferencesUtil
.
HENG_FENG_SERVER_FREQUENCY
,
frequency
);
jsonBody
.
put
(
PreferencesUtil
.
HENG_FENG_REQ_SERVER_SIGN
,
PhoneUtils
.
getHengdaSign
(
jsonBody
));
}
catch
(
JSONException
x
)
{
x
.
printStackTrace
();
}
JSONObject
jsonBody
=
new
JSONObject
();
try
{
jsonBody
.
put
(
PreferencesUtil
.
HENG_FENG_REQ_SERVER_MEID
,
PhoneUtils
.
getPhoneMEID
(
getApplicationContext
()));
jsonBody
.
put
(
PreferencesUtil
.
HENG_FENG_REQ_SERVER_TEL
,
PreferencesUtil
.
getInstance
(
this
).
getString
(
PreferencesUtil
.
HENG_FENG_PHONE
,
""
));
jsonBody
.
put
(
PreferencesUtil
.
HENG_FENG_REQ_SERVER_TIME
,
System
.
currentTimeMillis
());
jsonBody
.
put
(
PreferencesUtil
.
HENG_FENG_SERVER_BEGIN
,
begin
);
jsonBody
.
put
(
PreferencesUtil
.
HENG_FENG_SERVER_END
,
end
);
jsonBody
.
put
(
PreferencesUtil
.
HENG_FENG_SERVER_FREQUENCY
,
frequency
);
jsonBody
.
put
(
PreferencesUtil
.
HENG_FENG_REQ_SERVER_SIGN
,
PhoneUtils
.
getHengdaSign
(
jsonBody
));
}
catch
(
JSONException
x
)
{
x
.
printStackTrace
();
}
IotApi
.
hengfeng_service_setting
(
jsonBody
,
new
IotNetApiCallback
()
{
IotApi
.
hengfeng_service_setting
(
jsonBody
,
new
IotNetApiCallback
()
{
@Override
public
void
onSuccess
(
String
response
)
{
JsonObject
resp
=
new
JsonParser
().
parse
(
response
).
getAsJsonObject
();
int
code
=
resp
.
get
(
PreferencesUtil
.
HENG_FENG_SERVER_CODE
).
getAsInt
();
String
msg
=
resp
.
get
(
PreferencesUtil
.
HENG_FENG_SERVER_MSG
).
getAsString
();
@Override
Toast
.
makeText
(
ServiceSettingActivity
.
this
,
msg
,
Toast
.
LENGTH_SHORT
).
show
();
public
void
onSuccess
(
String
response
)
{
JsonObject
resp
=
new
JsonParser
().
parse
(
response
).
getAsJsonObject
();
int
code
=
resp
.
get
(
PreferencesUtil
.
HENG_FENG_SERVER_CODE
).
getAsInt
();
String
msg
=
resp
.
get
(
PreferencesUtil
.
HENG_FENG_SERVER_MSG
).
getAsString
();
if
(
code
==
0
){
if
(
code
==
0
){
PreferencesUtil
.
getInstance
(
getApplicationContext
())
PreferencesUtil
.
getInstance
(
getApplicationContext
())
.
putInt
(
PreferencesUtil
.
HENG_FENG_BEGIN
,
startIndex
);
.
putInt
(
PreferencesUtil
.
HENG_FENG_BEGIN
,
startIndex
);
PreferencesUtil
.
getInstance
(
getApplicationContext
())
PreferencesUtil
.
getInstance
(
getApplicationContext
())
.
putInt
(
PreferencesUtil
.
HENG_FENG_END
,
endIndex
);
.
putInt
(
PreferencesUtil
.
HENG_FENG_END
,
endIndex
);
PreferencesUtil
.
getInstance
(
getApplicationContext
())
PreferencesUtil
.
getInstance
(
getApplicationContext
())
.
putInt
(
PreferencesUtil
.
HENG_FENG_FREQUENCY
,
frequency
);
.
putInt
(
PreferencesUtil
.
HENG_FENG_FREQUENCY
,
frequency
);
PreferencesUtil
.
getInstance
(
getApplicationContext
())
PreferencesUtil
.
getInstance
(
getApplicationContext
())
.
putBoolean
(
PreferencesUtil
.
HENG_FENG_IS_OEPN
,
true
);
.
putBoolean
(
PreferencesUtil
.
HENG_FENG_IS_OEPN
,
true
);
cancelPreviousAlarmService
();
cancelPreviousAlarmService
();
sendBroadcastForNextStartService
();
sendBroadcastForNextStartService
();
Toast
.
makeText
(
ServiceSettingActivity
.
this
,
getString
(
R
.
string
.
setting_tips_success
),
Toast
.
LENGTH_SHORT
).
show
();
finish
();
}
}
finish
();
@Override
}
else
{
public
void
onFailed
(
Exception
e
)
{
Toast
.
makeText
(
ServiceSettingActivity
.
this
,
msg
,
Toast
.
LENGTH_SHORT
).
show
();
Toast
.
makeText
(
ServiceSettingActivity
.
this
,
getResources
().
getString
(
R
.
string
.
toast_tips_server_unavailable
),
Toast
.
LENGTH_SHORT
).
show
();
}
}
}
});
}
else
{
Toast
.
makeText
(
this
,
getString
(
R
.
string
.
toast_tips_unavailable
),
Toast
.
LENGTH_SHORT
).
show
();
}
@Override
public
void
onFailed
(
Exception
e
)
{
Toast
.
makeText
(
ServiceSettingActivity
.
this
,
getResources
().
getString
(
R
.
string
.
toast_tips_server_unavailable
),
Toast
.
LENGTH_SHORT
).
show
();
}
});
}
}
private
void
sendBroadcastForNextStartService
()
{
private
void
sendBroadcastForNextStartService
()
{
...
...
app/src/main/java/com/toscl/location/hengfeng/activity/ServiceStopActivity.java
View file @
1ab7612
...
@@ -99,15 +99,13 @@ public class ServiceStopActivity extends Activity implements View.OnClickListene
...
@@ -99,15 +99,13 @@ public class ServiceStopActivity extends Activity implements View.OnClickListene
int
code
=
resp
.
get
(
PreferencesUtil
.
HENG_FENG_SERVER_CODE
).
getAsInt
();
int
code
=
resp
.
get
(
PreferencesUtil
.
HENG_FENG_SERVER_CODE
).
getAsInt
();
String
msg
=
resp
.
get
(
PreferencesUtil
.
HENG_FENG_SERVER_MSG
).
getAsString
();
String
msg
=
resp
.
get
(
PreferencesUtil
.
HENG_FENG_SERVER_MSG
).
getAsString
();
Toast
.
makeText
(
getApplicationContext
(),
msg
,
Toast
.
LENGTH_SHORT
).
show
();
if
(
code
==
0
){
if
(
code
==
0
){
PreferencesUtil
.
getInstance
(
getApplicationContext
()).
putBoolean
(
PreferencesUtil
.
HENG_FENG_IS_OEPN
,
false
);
PreferencesUtil
.
getInstance
(
getApplicationContext
()).
putBoolean
(
PreferencesUtil
.
HENG_FENG_IS_OEPN
,
false
);
cancelPreviousAlarmService
();
cancelPreviousAlarmService
();
Toast
.
makeText
(
getApplicationContext
(),
getString
(
R
.
string
.
stop_service_tips
),
Toast
.
LENGTH_SHORT
).
show
();
finish
();
finish
();
}
else
{
Toast
.
makeText
(
getApplicationContext
(),
msg
,
Toast
.
LENGTH_SHORT
).
show
();
}
}
}
}
...
...
app/src/main/res/values/strings.xml
View file @
1ab7612
...
@@ -44,4 +44,5 @@
...
@@ -44,4 +44,5 @@
<string
name=
"location_server_unavailable"
translatable=
"false"
>
定位失败,当前服务不在有效期内
</string>
<string
name=
"location_server_unavailable"
translatable=
"false"
>
定位失败,当前服务不在有效期内
</string>
<string
name=
"stop_service_tips"
>
已停止服务
</string>
<string
name=
"stop_service_tips"
>
已停止服务
</string>
<string
name=
"setting_frequency_error"
>
上传频率不得小于7分钟
</string>
<string
name=
"setting_frequency_error"
>
上传频率不得小于7分钟
</string>
<string
name=
"setting_frequency_input"
>
请重新输入上传频率
</string>
</resources>
</resources>
Write
Preview
Markdown
is supported
Attach a file
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 post a comment