Commit 1ab76129 by cuiliang.shi

接口提示 直接延用服务端返回

1 parent 0e55d7e9
......@@ -6,8 +6,8 @@ android {
applicationId "com.toscl.location.hengfeng"
minSdkVersion 23
targetSdkVersion 28
versionCode 5
versionName "0.5"
versionCode 7
versionName "0.7"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
......
......@@ -124,12 +124,9 @@ public class ServiceApplyActivity extends Activity implements View.OnClickListen
cancelPreviousAlarmService();
sendBroadcastForNextStartService();
Toast.makeText(ServiceApplyActivity.this, getString(R.string.apply_tips_success), Toast.LENGTH_SHORT).show();
finish();
}else{
Toast.makeText(ServiceApplyActivity.this, msg, Toast.LENGTH_SHORT).show();
}
Toast.makeText(ServiceApplyActivity.this, msg, Toast.LENGTH_SHORT).show();
}
@Override
......
package com.toscl.location.hengfeng.activity;
import android.app.Activity;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import com.toscl.location.hengfeng.R;
......@@ -11,6 +14,21 @@ public class ServiceInfoActivity extends Activity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
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;
}
}
......@@ -114,9 +114,17 @@ public class ServiceSettingActivity extends Activity implements View.OnClickList
}
private void saveSetting() {
if (PreferencesUtil.getInstance(this).getBoolean(PreferencesUtil.HENG_FENG_IS_OEPN, false)
&& PhoneUtils.hengdaServiceAvailable(this)) {
int startIndex = mSpinnerForStartDate.getSelectedItemPosition();
int endIndex = mSpinnerForEndDate.getSelectedItemPosition();
int frequency = Integer.parseInt(mEtFrequency.getText().toString());
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){
Toast.makeText(this, getString(R.string.setting_frequency_error), Toast.LENGTH_SHORT).show();
......@@ -148,6 +156,8 @@ public class ServiceSettingActivity extends Activity implements View.OnClickList
int code = resp.get(PreferencesUtil.HENG_FENG_SERVER_CODE).getAsInt();
String msg = resp.get(PreferencesUtil.HENG_FENG_SERVER_MSG).getAsString();
Toast.makeText(ServiceSettingActivity.this, msg, Toast.LENGTH_SHORT).show();
if (code == 0){
PreferencesUtil.getInstance(getApplicationContext())
.putInt(PreferencesUtil.HENG_FENG_BEGIN, startIndex);
......@@ -163,11 +173,7 @@ public class ServiceSettingActivity extends Activity implements View.OnClickList
cancelPreviousAlarmService();
sendBroadcastForNextStartService();
Toast.makeText(ServiceSettingActivity.this, getString(R.string.setting_tips_success), Toast.LENGTH_SHORT).show();
finish();
}else{
Toast.makeText(ServiceSettingActivity.this, msg, Toast.LENGTH_SHORT).show();
}
}
......@@ -177,6 +183,10 @@ public class ServiceSettingActivity extends Activity implements View.OnClickList
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();
}
}
private void sendBroadcastForNextStartService() {
......
......@@ -99,15 +99,13 @@ public class ServiceStopActivity extends Activity implements View.OnClickListene
int code = resp.get(PreferencesUtil.HENG_FENG_SERVER_CODE).getAsInt();
String msg = resp.get(PreferencesUtil.HENG_FENG_SERVER_MSG).getAsString();
Toast.makeText(getApplicationContext(), msg, Toast.LENGTH_SHORT).show();
if (code == 0){
PreferencesUtil.getInstance(getApplicationContext()).putBoolean(PreferencesUtil.HENG_FENG_IS_OEPN, false);
cancelPreviousAlarmService();
Toast.makeText(getApplicationContext(),
getString(R.string.stop_service_tips), Toast.LENGTH_SHORT).show();
finish();
}else{
Toast.makeText(getApplicationContext(), msg, Toast.LENGTH_SHORT).show();
}
}
......
......@@ -44,4 +44,5 @@
<string name="location_server_unavailable" translatable="false">定位失败,当前服务不在有效期内</string>
<string name="stop_service_tips">已停止服务</string>
<string name="setting_frequency_error">上传频率不得小于7分钟</string>
<string name="setting_frequency_input">请重新输入上传频率</string>
</resources>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!