Commit 4576f45f by cuiliang.shi

恒锋信息 定位

1 parent ff327440
Showing with 1237 additions and 423 deletions
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<Objective-C-extensions>
<file>
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Import" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Macro" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Typedef" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Enum" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Constant" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Global" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Struct" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="FunctionPredecl" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Function" />
</file>
<class>
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Property" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Synthesize" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InitMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="StaticMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InstanceMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="DeallocMethod" />
</class>
<extensions>
<pair source="cpp" header="h" fileNamingConvention="NONE" />
<pair source="c" header="h" fileNamingConvention="NONE" />
</extensions>
</Objective-C-extensions>
</code_scheme>
</component>
\ No newline at end of file
<component name="ProjectDictionaryState">
<dictionary name="Administrator">
<words>
<w>feng</w>
<w>heng</w>
<w>hengfeng</w>
<w>imsi</w>
<w>meid</w>
</words>
</dictionary>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" addBOMForNewFiles="with NO BOM" />
</project>
\ No newline at end of file
......@@ -3,7 +3,7 @@ apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.agenew.location_server.application"
applicationId "com.toscl.location.hengfeng"
minSdkVersion 23
targetSdkVersion 28
versionCode 11
......
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":7,"versionName":"1.7","enabled":true,"outputFile":"LocationServer.apk","fullName":"release","baseName":"release"},"path":"LocationServer.apk","properties":{}}]
\ No newline at end of file
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":11,"versionName":"2.1","enabled":true,"outputFile":"LocationServer_2.1.apk","fullName":"release","baseName":"release"},"path":"LocationServer_2.1.apk","properties":{}}]
\ No newline at end of file
package com.agenew.location_server.application;
package com.toscl.location.hengfeng;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import android.util.Log;
import com.amap.api.maps2d.AMapUtils;
import com.amap.api.maps2d.model.LatLng;
......@@ -10,8 +11,6 @@ import com.amap.api.maps2d.model.LatLng;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
......@@ -19,18 +18,25 @@ import static org.junit.Assert.*;
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
private String TAG = "ExampleInstrumentedTest" ;
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("com.example.john.myapplication", appContext.getPackageName());
//
// LatLng wifiLatLng = new LatLng(mWifiLatitude, mWifiLongitude);
// LatLng gpsLatLng = new LatLng(mGpsLatitude, mGpsLongitude);
//
// float distance = AMapUtils.calculateLineDistance(wifiLatLng, gpsLatLng);
// assertEquals("com.example.john.myapplication", appContext.getPackageName());
LatLng wifiLatLng = new LatLng(29.673439, 121.431411);
LatLng gpsLatLng = new LatLng(29.67364583333333, 121.43255967881944);
float distance = AMapUtils.calculateLineDistance(wifiLatLng, gpsLatLng);
Log.d(TAG, "distance: " + distance);
}
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.agenew.location_server.application">
xmlns:tools="http://schemas.android.com/tools"
package="com.toscl.location.hengfeng">
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"></uses-permission>
......@@ -15,7 +16,6 @@
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.READ_CONTACTS"/>
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />
......@@ -26,16 +26,14 @@
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
android:theme="@style/AppTheme"
android:name="com.toscl.location.hengfeng.AppApplication"
tools:ignore="GoogleAppIndexingWarning">
<meta-data android:name="com.amap.api.v2.apikey" android:value="2e40c8d145f8a0d4f9bb1cc7590594e7">
</meta-data>
<activity android:name="com.agenew.location_server.application.MainActivity"
<activity android:name="com.toscl.location.hengfeng.activity.ServiceSettingActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<!--<category android:name="android.intent.category.LAUNCHER" />-->
</intent-filter>
<!--<intent-filter>-->
<!--<action android:name="com.android.settings.action.EXTRA_SETTINGS" />-->
......@@ -47,29 +45,34 @@
<!--<meta-data android:name="com.android.settings.title"-->
<!--android:resource="@string/app_name" />-->
</activity>
<activity android:name="com.toscl.location.hengfeng.activity.NavActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.toscl.location.hengfeng.activity.ServiceInfoActivity">
</activity>
<activity android:name="com.toscl.location.hengfeng.activity.ServiceApplyActivity" />
<activity android:name="com.toscl.location.hengfeng.activity.ServiceStopActivity" />
<service android:name="com.amap.api.location.APSService" />
<receiver android:name="com.agenew.location_server.application.LocationReceiver"
<receiver android:name="com.toscl.location.hengfeng.recevier.LocationReceiver"
android:permission="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS">
<intent-filter>
<action android:name="com.bird.send_sos" />
<action android:name="com.bird.close_sos" />
</intent-filter>
</receiver>
<service android:name="com.agenew.location_server.application.BirdService"
<service android:name="com.toscl.location.hengfeng.LocationService"
android:enabled="true"
android:exported="true">
</service>
<receiver android:name="com.agenew.location_server.application.AlarmReceiver"></receiver>
<!-- <receiver android:name=".BirdService$NetWorkChangReceiver" >
<intent-filter>
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
<action android:name="android.net.wifi.WIFI_STATE_CHANGED" />
<action android:name="android.net.wifi.STATE_CHANGE" />
</intent-filter>
</receiver>-->
<receiver android:name="com.toscl.location.hengfeng.recevier.AlarmReceiver" />
</application>
</manifest>
\ No newline at end of file
package com.agenew.location_server.application;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Build;
import android.support.v4.content.SharedPreferencesCompat;
import java.util.Set;
public class DevicePreferences {
private static DevicePreferences sDevicePreferences;
private final SharedPreferences mShareferences;
private final SharedPreferences.Editor mEditor;
private DevicePreferences(Context context) {
mShareferences = context.getSharedPreferences(context.getPackageName(), Context.MODE_PRIVATE);
mEditor = mShareferences.edit();
}
public static synchronized DevicePreferences getInstance(Context context) {
if (null == sDevicePreferences) {
sDevicePreferences = new DevicePreferences(context.getApplicationContext());
}
return sDevicePreferences;
}
public void putInt(final String key, final int value) {
mEditor.putInt(key, value);
SharedPreferencesCompat.EditorCompat.getInstance().apply(mEditor);
}
public void putLong(final String key, final long value) {
mEditor.putLong(key, value);
SharedPreferencesCompat.EditorCompat.getInstance().apply(mEditor);
}
public void putString(final String key, final String value) {
mEditor.putString(key, value);
SharedPreferencesCompat.EditorCompat.getInstance().apply(mEditor);
}
public void putFloat(final String key, final float value) {
mEditor.putFloat(key, value);
SharedPreferencesCompat.EditorCompat.getInstance().apply(mEditor);
}
public void putBoolean(final String key, final boolean value) {
mEditor.putBoolean(key, value);
SharedPreferencesCompat.EditorCompat.getInstance().apply(mEditor);
}
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void putStringSet(final String key, final Set<String> values) {
mEditor.putStringSet(key, values);
SharedPreferencesCompat.EditorCompat.getInstance().apply(mEditor);
}
public int getInt(final String key, final int defaultValue) {
return mShareferences.getInt(key, defaultValue);
}
public long getLong(final String key, final long defaultValue) {
return mShareferences.getLong(key, defaultValue);
}
public String getString(final String key, final String defaultValue) {
return mShareferences.getString(key, defaultValue);
}
public float getFloat(final String key, final float defaultValue) {
return mShareferences.getFloat(key, defaultValue);
}
public boolean getBoolean(final String key, final boolean defaultValue) {
return mShareferences.getBoolean(key, defaultValue);
}
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public Set<String> getStringSet(final String key) {
return mShareferences.getStringSet(key, null);
}
}
package com.agenew.location_server.application;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.support.annotation.RequiresApi;
import android.util.Log;
public class LocationReceiver extends BroadcastReceiver{
private String TAG = "LocationReceiver";
@RequiresApi(api = Build.VERSION_CODES.O)
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
Log.d(TAG, "action:" + action);
if (action.equals("com.bird.send_sos")){
if (BirdService.status != 1){
Log.d("qqh","bird_sos_open");
Intent intentThree = new Intent(context, BirdService.class);
DevicePreferences.getInstance(context).putBoolean("is_need_notification", true);
context.startForegroundService(intentThree);
BirdService.status = 1;
}
}else if (action.equals("com.bird.close_sos")){
Intent intentThree = new Intent(context, BirdService.class);
context.stopService(intentThree);
BirdService.status = -1;
}
}
}
package com.agenew.location_server.application;
import android.Manifest;
import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import com.agenew.location_server.application.permission.MPermission;
import com.agenew.location_server.application.permission.annotation.OnMPermissionDenied;
import com.agenew.location_server.application.permission.annotation.OnMPermissionGranted;
import com.agenew.location_server.application.permission.annotation.OnMPermissionNeverAskAgain;
public class MainActivity extends Activity implements View.OnClickListener {
private static final String TAG="BirdService";
private SharedPreferences sp;
private LocationReceiver locationRecevier;
private Context mContext;
private final static String DEFAULTPATH = "http://202.100.190.58:8090/api/cstmzPosition";
private final static long DEFAULTINTERVAL = 30;
private EditText url_et;
private EditText interval_et;
private Button btnCannel;
private Button btnSave;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.location_msg);
mContext = this;
String url = DevicePreferences.getInstance(mContext).getString("bird_location_upload_url", DEFAULTPATH);
Long interval = DevicePreferences.getInstance(mContext).getLong("bird_location_upload_interval",DEFAULTINTERVAL);
Log.d("qqh","interval"+interval);
url_et = findViewById(R.id.url_value);
interval_et =findViewById(R.id.interval_value);
url_et.setText(url);
interval_et.setText(String.valueOf(interval));
btnCannel = findViewById(R.id.bt_cancel);
btnSave = findViewById(R.id.bt_save);
btnCannel.setOnClickListener(this);
btnSave.setOnClickListener(this);
sp = getSharedPreferences("config", MODE_PRIVATE);
requestBasicPermission();
// locationRecevier = new LocationReceiver();
// IntentFilter filter = new IntentFilter();
// filter.addAction("com.bird.send_sos");
// filter.addAction("com.bird.close_sos");
// registerReceiver(locationRecevier, filter);
Log.d("qqh","main___start");
//sendBroadcast(new Intent("com.bird.send_sos"));
// Intent intentThree = new Intent(this, BirdService.class);
// startForegroundService(intentThree);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
finish();
break;
}
return true;
}
@Override
public void onClick(View v) {
Log.d("qqh","click"+v.getId());
switch (v.getId()) {
case R.id.bt_cancel:
Toast.makeText(mContext, R.string.save_cacel, Toast.LENGTH_SHORT).show();
finish();
break;
case R.id.bt_save:
String url_temp =url_et.getText().toString().trim();
String interval_temp =interval_et.getText().toString();
if(url_temp == null || "".equals(url_temp)|| url_temp.isEmpty()){
Toast.makeText(this, getString(R.string.server_prompt), Toast.LENGTH_SHORT).show();
break;
}
if(interval_temp == null || "".equals(interval_temp)|| interval_temp.isEmpty()){
Toast.makeText(this, getString(R.string.interval_prompt), Toast.LENGTH_SHORT).show();
break;
}
Long t=Long.valueOf(interval_temp);
Log.d(TAG,"time---"+t);
DevicePreferences.getInstance(MainActivity.this).putString("bird_location_upload_url",url_temp );
DevicePreferences.getInstance(MainActivity.this).putLong("bird_location_upload_interval",t);
Toast.makeText(mContext, R.string.save_tips, Toast.LENGTH_SHORT).show();
finish();
break;
}
}
@Override
protected void onDestroy() {
super.onDestroy();
// unregisterReceiver(locationRecevier);
}
private static final int BASIC_PERMISSION_REQUEST_CODE = 100;
private static final String[] BASIC_PERMISSIONS = new String[]{
Manifest.permission.WRITE_EXTERNAL_STORAGE,
Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.CAMERA,
Manifest.permission.READ_PHONE_STATE,
Manifest.permission.ACCESS_COARSE_LOCATION,
Manifest.permission.ACCESS_FINE_LOCATION,
Manifest.permission.SEND_SMS
};
private void requestBasicPermission() {
MPermission.printMPermissionResult(true, this, BASIC_PERMISSIONS);
MPermission.with(MainActivity.this)
.setRequestCode(BASIC_PERMISSION_REQUEST_CODE)
.permissions(BASIC_PERMISSIONS)
.request();
}
@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
MPermission.onRequestPermissionsResult(this, requestCode, permissions, grantResults);
}
@OnMPermissionGranted(BASIC_PERMISSION_REQUEST_CODE)
public void onBasicPermissionSuccess() {
// Toast.makeText(this, "success to get permission", Toast.LENGTH_SHORT).show();
}
@OnMPermissionDenied(BASIC_PERMISSION_REQUEST_CODE)
@OnMPermissionNeverAskAgain(BASIC_PERMISSION_REQUEST_CODE)
public void onBasicPermissionFailed() {
// Toast.makeText(this, "fail to get permission", Toast.LENGTH_SHORT).show();
}
}
package com.toscl.location.hengfeng;
import android.app.Application;
import com.toscl.location.hengfeng.api.IotApi;
public class AppApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
IotApi.init();
}
}
package com.toscl.location.hengfeng.activity;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;
import com.toscl.location.hengfeng.R;
import com.toscl.location.hengfeng.util.PhoneUtils;
import com.toscl.location.hengfeng.util.PreferencesUtil;
public class NavActivity extends Activity implements View.OnClickListener {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.location_nav);
setTitle(getString(R.string.title_nav));
findViewById(R.id.service_info).setOnClickListener(this);
findViewById(R.id.service_setting).setOnClickListener(this);
findViewById(R.id.service_apply).setOnClickListener(this);
findViewById(R.id.service_stop).setOnClickListener(this);
}
@Override
public void onClick(View v) {
int id = v.getId();
switch (id) {
case R.id.service_info:
startActivity(new Intent(this, ServiceInfoActivity.class));
break;
case R.id.service_setting:
if (PreferencesUtil.getInstance(this).getBoolean(PreferencesUtil.HENG_FENG_IS_OEPN, false)
&& PhoneUtils.hengdaServiceAvailable()) {
startActivity(new Intent(this, ServiceSettingActivity.class));
} else {
Toast.makeText(this, getString(R.string.toast_tips_unavailable), Toast.LENGTH_SHORT).show();
}
break;
case R.id.service_stop:
if (PreferencesUtil.getInstance(this).getBoolean(PreferencesUtil.HENG_FENG_IS_OEPN, false)
&& PhoneUtils.hengdaServiceAvailable()) {
startActivity(new Intent(this, ServiceStopActivity.class));
} else {
Toast.makeText(this, getString(R.string.toast_tips_unavailable), Toast.LENGTH_SHORT).show();
}
break;
case R.id.service_apply:
startActivity(new Intent(this, ServiceApplyActivity.class));
break;
}
}
}
package com.toscl.location.hengfeng.activity;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;
import com.toscl.location.hengfeng.R;
import com.toscl.location.hengfeng.api.IotApi;
import com.toscl.location.hengfeng.api.IotNetApiCallback;
import com.toscl.location.hengfeng.util.PreferencesUtil;
import com.toscl.location.hengfeng.util.PhoneUtils;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import org.json.JSONException;
import org.json.JSONObject;
public class ServiceApplyActivity extends Activity implements View.OnClickListener {
private EditText mPhoneNumber;
private final String TAG = getClass().getName();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.service_apply);
setTitle(getString(R.string.title_apply));
mPhoneNumber = findViewById(R.id.phone_number);
mPhoneNumber.setText(PhoneUtils.getLocalNumber(this, PreferencesUtil.HENG_FENG_DEFAULT_SLOT));
findViewById(R.id.bt_cancel).setOnClickListener(this);
findViewById(R.id.bt_save).setOnClickListener(this);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.bt_cancel:
finish();
break;
case R.id.bt_save:
String phoneNumber = mPhoneNumber.getText().toString();
apiPostServiceApply(phoneNumber);
break;
}
}
private void apiPostServiceApply(String phoneNumber) {
JSONObject jsonBody = new JSONObject();
try {
jsonBody.put(PreferencesUtil.HENG_FENG_REQ_SERVER_MEID, PhoneUtils.getPhoneMEID(getApplicationContext()));
jsonBody.put(PreferencesUtil.HENG_FENG_REQ_SERVER_IMSI, PhoneUtils.getSubId(getApplicationContext(), PreferencesUtil.HENG_FENG_DEFAULT_SLOT));
jsonBody.put(PreferencesUtil.HENG_FENG_REQ_SERVER_TEL, phoneNumber);
jsonBody.put(PreferencesUtil.HENG_FENG_REQ_SERVER_TIME, System.currentTimeMillis());
jsonBody.put(PreferencesUtil.HENG_FENG_REQ_SERVER_SIGN, PhoneUtils.getHengdaSign(jsonBody));
} catch (JSONException x) {
x.printStackTrace();
}
IotApi.hengfeng_service_apply(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();
Toast.makeText(ServiceApplyActivity.this, msg, Toast.LENGTH_SHORT).show();
if (code == 0) {
JsonObject data = resp.get(PreferencesUtil.HENG_FENG_SERVER_RESPONSE_DATA).getAsJsonObject();
/*
* server data response
* */
String url = data.get(PreferencesUtil.HENG_FENG_SERVER_URL).getAsString();
String dataStart = data.get(PreferencesUtil.HENG_FENG_SERVER_DATA_START).getAsString();
String dataEnd = data.get(PreferencesUtil.HENG_FENG_SERVER_DATA_END).getAsString();
PreferencesUtil.getInstance(getApplicationContext())
.putString(PreferencesUtil.HENG_FENG_PHONE, phoneNumber);
PreferencesUtil.getInstance(getApplicationContext())
.putString(PreferencesUtil.HENG_FENG_URL, url);
PreferencesUtil.getInstance(getApplicationContext())
.putString(PreferencesUtil.HENG_FENG_DATA_START, dataStart);
PreferencesUtil.getInstance(getApplicationContext())
.putString(PreferencesUtil.HENG_FENG_DATA_END, dataEnd);
PreferencesUtil.getInstance(getApplicationContext())
.putBoolean(PreferencesUtil.HENG_FENG_IS_OEPN, true);
}
}
@Override
public void onFailed(Exception e) {
PreferencesUtil.getInstance(getApplicationContext())
.putBoolean(PreferencesUtil.HENG_FENG_IS_OEPN, false);
Toast.makeText(ServiceApplyActivity.this,
getResources().getString(R.string.toast_tips_server_unavailable), Toast.LENGTH_SHORT).show();
}
});
}
}
package com.toscl.location.hengfeng.activity;
import android.app.Activity;
import android.os.Bundle;
import com.toscl.location.hengfeng.R;
public class ServiceInfoActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.service_info);
setTitle(getString(R.string.title_server_info));
}
}
package com.toscl.location.hengfeng.activity;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.Toast;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.toscl.location.hengfeng.R;
import com.toscl.location.hengfeng.api.IotApi;
import com.toscl.location.hengfeng.api.IotNetApiCallback;
import com.toscl.location.hengfeng.util.PhoneUtils;
import com.toscl.location.hengfeng.util.PreferencesUtil;
import org.json.JSONException;
import org.json.JSONObject;
public class ServiceSettingActivity extends Activity implements View.OnClickListener {
private static final String TAG = "ServiceSettingActivity";
private Spinner mSpinnerForStartDate;
private Spinner mSpinnerForEndDate;
private EditText mEtFrequency;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.service_settting);
setTitle(getString(R.string.title_service_setting));
findViewById(R.id.bt_cancel).setOnClickListener(this);
findViewById(R.id.bt_save).setOnClickListener(this);
ArrayAdapter<CharSequence> adapter =
ArrayAdapter.createFromResource(this,
R.array.date,
android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource
(android.R.layout.simple_spinner_dropdown_item);
EditText etServiceStatus = findViewById(R.id.service_available_status);
if (PreferencesUtil.getInstance(this).getBoolean(PreferencesUtil.HENG_FENG_IS_OEPN, false)) {
etServiceStatus.setText(getString(R.string.service_status_available));
} else {
etServiceStatus.setText(getString(R.string.service_status_unavailable));
}
String dateStart = PreferencesUtil.getInstance(this)
.getString(PreferencesUtil.HENG_FENG_DATA_START, "");
String dateEnd = PreferencesUtil.getInstance(this)
.getString(PreferencesUtil.HENG_FENG_DATA_END, "");
EditText etServiceAvailableDate = findViewById(R.id.service_available_date);
if (dateStart.equals("")) {
etServiceAvailableDate.setText(getString(R.string.server_status_unavailable));
} else {
etServiceAvailableDate.setText(String.format(getResources().getString(R.string.service_available_date), dateStart, dateEnd));
}
EditText etPhoneNumber = findViewById(R.id.phone_number);
etPhoneNumber.setText(PreferencesUtil.getInstance(this)
.getString(PreferencesUtil.HENG_FENG_PHONE, ""));
mEtFrequency = findViewById(R.id.service_frequency);
mEtFrequency.setText(String.valueOf(PreferencesUtil.getInstance(this)
.getInt(PreferencesUtil.HENG_FENG_FREQUENCY, PreferencesUtil.HENG_FENG_DEFAULT_FREQUENCY)));
mSpinnerForStartDate = findViewById(R.id.service_upload_start);
mSpinnerForStartDate.setAdapter(adapter);
mSpinnerForEndDate = findViewById(R.id.service_upload_end);
mSpinnerForEndDate.setAdapter(adapter);
mSpinnerForEndDate.setSelection(PreferencesUtil.getInstance(this)
.getInt(PreferencesUtil.HENG_FENG_BEGIN, PreferencesUtil.HENG_FENG_DEFAULT_BEGIN));
mSpinnerForEndDate.setSelection(PreferencesUtil.getInstance(this)
.getInt(PreferencesUtil.HENG_FENG_END, PreferencesUtil.HENG_FENG_DEFAULT_END));
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.bt_cancel:
finish();
break;
case R.id.bt_save:
saveSetting();
break;
}
}
private void saveSetting() {
int startIndex = mSpinnerForStartDate.getSelectedItemPosition();
int endIndex = mSpinnerForEndDate.getSelectedItemPosition();
int frequency = Integer.parseInt(mEtFrequency.getText().toString());
String begin = startIndex + ":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();
}
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();
if (code == 0){
PreferencesUtil.getInstance(getApplicationContext())
.putInt(PreferencesUtil.HENG_FENG_BEGIN, startIndex);
PreferencesUtil.getInstance(getApplicationContext())
.putInt(PreferencesUtil.HENG_FENG_END, endIndex);
PreferencesUtil.getInstance(getApplicationContext())
.putInt(PreferencesUtil.HENG_FENG_FREQUENCY, frequency);
}
Toast.makeText(ServiceSettingActivity.this, msg, 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();
}
});
}
}
package com.toscl.location.hengfeng.activity;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.toscl.location.hengfeng.R;
import com.toscl.location.hengfeng.api.IotApi;
import com.toscl.location.hengfeng.api.IotNetApiCallback;
import com.toscl.location.hengfeng.util.PhoneUtils;
import com.toscl.location.hengfeng.util.PreferencesUtil;
import org.json.JSONException;
import org.json.JSONObject;
public class ServiceStopActivity extends Activity implements View.OnClickListener {
private EditText mEtPhoneNumber;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.service_stop);
setTitle(getResources().getString(R.string.title_server_stop));
findViewById(R.id.bt_cancel).setOnClickListener(this);
findViewById(R.id.bt_save).setOnClickListener(this);
mEtPhoneNumber = findViewById(R.id.phone_number);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.bt_cancel:
finish();
break;
case R.id.bt_save:
if (mEtPhoneNumber.getText().toString()
.equals(PreferencesUtil.getInstance(this).getString(PreferencesUtil.HENG_FENG_PHONE, ""))) {
apiStopService();
}else{
Toast.makeText(this, getResources().getString(R.string.tips_phone_unvalid), Toast.LENGTH_SHORT).show();
}
break;
}
}
private void apiStopService() {
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, "06:00");
jsonBody.put(PreferencesUtil.HENG_FENG_SERVER_END, "22:00");
jsonBody.put(PreferencesUtil.HENG_FENG_SERVER_FREQUENCY, 9999);
jsonBody.put(PreferencesUtil.HENG_FENG_REQ_SERVER_SIGN, PhoneUtils.getHengdaSign(jsonBody));
} catch (JSONException x) {
x.printStackTrace();
}
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();
if (code == 0){
PreferencesUtil.getInstance(getApplicationContext()).putBoolean(PreferencesUtil.HENG_FENG_IS_OEPN, false);
}
Toast.makeText(getApplicationContext(), msg, Toast.LENGTH_SHORT).show();
}
@Override
public void onFailed(Exception e) {
Toast.makeText(getApplicationContext(),
getResources().getString(R.string.toast_tips_server_unavailable), Toast.LENGTH_SHORT).show();
}
});
}
}
package com.agenew.location_server.application.api;
package com.toscl.location.hengfeng.api;
import okhttp3.Call;
import okhttp3.Callback;
......
package com.agenew.location_server.application.api;
package com.toscl.location.hengfeng.api;
import android.util.Log;
......@@ -40,15 +40,15 @@ public class IotApi {
.writeTimeout(TIME_OUT_WRITE, TimeUnit.SECONDS)
.connectTimeout(TIME_OUT_CONNECT, TimeUnit.SECONDS);
/* try{
try {
MyOkHttpRetryInterceptor myOkHttpRetryInterceptor = new MyOkHttpRetryInterceptor.Builder()
.executionCount(3)
.retryInterval(1000)
.build();
okHttpClientBuilder.addInterceptor(myOkHttpRetryInterceptor);
}catch (Exception e){
} catch (Exception e) {
Log.d(TAG, e.toString());
}*/
}
sHttpExecutor = new HttpExecutor(okHttpClientBuilder.build());
}
......@@ -59,8 +59,11 @@ public class IotApi {
* @param requestBodyString the request body string
* @param callback the callback
*/
public static void post(String url, String requestBodyString, IotNetApiCallback callback){
public static void post(String url, String requestBodyString, IotNetApiCallback callback) {
RequestBody requestBody = RequestBody.create(JSON, requestBodyString);
if (IotApi.sDebug) {
Log.d(TAG, "url: " + url + ", requestBody: " + requestBodyString);
}
sHttpExecutor.post(url, requestBody, new IotApiCallbackAdapter(callback));
}
......@@ -75,8 +78,16 @@ public class IotApi {
Log.d(TAG, "get:" + url);
}
public static void postLocationInfo(String url, JSONObject requestContent, IotNetApiCallback callback) {
post(url, requestContent.toString() , callback);
public static void hengfeng_service_apply(JSONObject requestContent, IotNetApiCallback callback) {
post("https://api.vserve365.com/phone_baihe/open", requestContent.toString(), callback);
}
public static void hengfeng_service_post(JSONObject requestContent, IotNetApiCallback callback) {
post("https://api.vserve365.com/phone_baihe/position", requestContent.toString(), callback);
}
public static void hengfeng_service_setting(JSONObject requestContent, IotNetApiCallback callback) {
post("https://api.vserve365.com/phone_baihe/config", requestContent.toString(), callback);
}
......
package com.agenew.location_server.application.api;
package com.toscl.location.hengfeng.api;
import android.os.Bundle;
import android.os.Handler;
......@@ -32,7 +32,14 @@ class IotApiCallbackAdapter implements Callback {
if (mIotNetApiCallback != null) {
Bundle b = msg.getData();
String response = b.getString("response");
mIotNetApiCallback.onSuccess(response);
if (IotApi.sDebug) {
Log.d("Iot", "response: " + response);
}
try{
mIotNetApiCallback.onSuccess(response);
}catch (Exception e){
Log.d("Iot", e.toString());
}
}
break;
......@@ -41,6 +48,9 @@ class IotApiCallbackAdapter implements Callback {
Bundle b = msg.getData();
Exception e = (Exception) b.getSerializable("exception");
mIotNetApiCallback.onFailed(e);
if (IotApi.sDebug) {
Log.d("Iot", "response failed exception: " + e.toString());
}
}
break;
}
......
package com.agenew.location_server.application.api;
package com.toscl.location.hengfeng.api;
public interface IotNetApiCallback {
......
package com.agenew.location_server.application.api;
package com.toscl.location.hengfeng.api;
import java.io.IOException;
......@@ -12,6 +12,7 @@ import okhttp3.Response;
public class MyOkHttpRetryInterceptor implements Interceptor {
public int executionCount;//最大重试次数
private long retryInterval;//重试的间隔
MyOkHttpRetryInterceptor(Builder builder) {
this.executionCount = builder.executionCount;
this.retryInterval = builder.retryInterval;
......@@ -34,7 +35,7 @@ public class MyOkHttpRetryInterceptor implements Interceptor {
// retry the request
response = doRequest(chain, request);
}
if (response == null){
if (response == null) {
return chain.proceed(request);
}
return response;
......@@ -59,20 +60,22 @@ public class MyOkHttpRetryInterceptor implements Interceptor {
public static final class Builder {
private int executionCount;
private long retryInterval;
public Builder() {
executionCount = 3;
retryInterval = 1000;
}
public MyOkHttpRetryInterceptor.Builder executionCount(int executionCount){
this.executionCount =executionCount;
public MyOkHttpRetryInterceptor.Builder executionCount(int executionCount) {
this.executionCount = executionCount;
return this;
}
public MyOkHttpRetryInterceptor.Builder retryInterval(long retryInterval){
this.retryInterval =retryInterval;
public MyOkHttpRetryInterceptor.Builder retryInterval(long retryInterval) {
this.retryInterval = retryInterval;
return this;
}
public MyOkHttpRetryInterceptor build() {
return new MyOkHttpRetryInterceptor(this);
}
......
package com.agenew.location_server.application.permission;
package com.toscl.location.hengfeng.permission;
import android.annotation.TargetApi;
import android.app.Activity;
......
package com.agenew.location_server.application.permission;
package com.toscl.location.hengfeng.permission;
import android.annotation.TargetApi;
import android.app.Activity;
......@@ -7,9 +7,9 @@ import android.os.Build;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import com.agenew.location_server.application.permission.annotation.OnMPermissionDenied;
import com.agenew.location_server.application.permission.annotation.OnMPermissionGranted;
import com.agenew.location_server.application.permission.annotation.OnMPermissionNeverAskAgain;
import com.toscl.location.hengfeng.permission.annotation.OnMPermissionDenied;
import com.toscl.location.hengfeng.permission.annotation.OnMPermissionGranted;
import com.toscl.location.hengfeng.permission.annotation.OnMPermissionNeverAskAgain;
import java.lang.annotation.Annotation;
import java.lang.reflect.InvocationTargetException;
......
package com.agenew.location_server.application.permission.annotation;
package com.toscl.location.hengfeng.permission.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
......
package com.agenew.location_server.application.permission.annotation;
package com.toscl.location.hengfeng.permission.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
......
package com.agenew.location_server.application.permission.annotation;
package com.toscl.location.hengfeng.permission.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
......
package com.agenew.location_server.application;
package com.toscl.location.hengfeng.recevier;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
public class AlarmReceiver extends BroadcastReceiver {
public class AlarmReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Log.d("BirdService","receiver--"+System.currentTimeMillis());
/* Intent i = new Intent(context,BirdService.class);
DevicePreferences.getInstance(context).putBoolean("is_need_notification", false);
context.startService(i);*/
Log.d("AlarmReceiver", "sendBroadcast com.bird.open_gps_alarm");
Intent intent2 = new Intent("com.bird.open_gps_alarm");
intent2.addFlags(0x01000000);
......
package com.toscl.location.hengfeng.recevier;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.util.Log;
import com.toscl.location.hengfeng.LocationService;
import com.toscl.location.hengfeng.util.PhoneUtils;
import com.toscl.location.hengfeng.util.PreferencesUtil;
public class LocationReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
String TAG = "LocationReceiver";
String action = intent.getAction();
Log.d(TAG, "action:" + action);
if (action != null && action.equals("com.bird.send_sos")) {
if (PreferencesUtil.getInstance(context)
.getBoolean(PreferencesUtil.HENG_FENG_PREFIX + "is_open", false)) {
if (PhoneUtils.hengdaServiceAvailable()) {
Intent intentForService = new Intent(context, LocationService.class);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
context.startForegroundService(intentForService);
} else {
context.startService(intentForService);
}
PreferencesUtil.getInstance(context)
.putBoolean(PreferencesUtil.HENG_FENG_PREFIX + "is_open", true);
} else {
PreferencesUtil.getInstance(context)
.putBoolean(PreferencesUtil.HENG_FENG_PREFIX + "is_open", false);
Intent intentThree = new Intent(context, LocationService.class);
context.stopService(intentThree);
}
}
} else if (action != null && action.equals("com.bird.close_sos")) {
PreferencesUtil.getInstance(context)
.putBoolean(PreferencesUtil.HENG_FENG_PREFIX + "is_open", false);
Intent intentThree = new Intent(context, LocationService.class);
context.stopService(intentThree);
}
}
}
package com.toscl.location.hengfeng.util;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Build;
import java.util.Set;
public class PreferencesUtil {
public final static String HENG_FENG_PREFIX = "hengfeng_sos_";
/*
* server request key
* */
public final static String HENG_FENG_REQ_SERVER_MEID = "meid";
public final static String HENG_FENG_REQ_SERVER_IMSI = "imsi";
public final static String HENG_FENG_REQ_SERVER_TEL = "tel";
public final static String HENG_FENG_REQ_SERVER_TIME = "time";
public final static String HENG_FENG_REQ_SERVER_LONGITUDE = "lng";
public final static String HENG_FENG_REQ_SERVER_LATITUDE = "lat";
// Geographical coordinate system
public final static String HENG_FENG_REQ_SERVER_GCS = "gcs";
public final static String HENG_FENG_REQ_SERVER_SIGN = "sign";
/*
* Server response
* */
public final static String HENG_FENG_SERVER_DATA_START = "dateStart";
public final static String HENG_FENG_SERVER_DATA_END = "dateEnd";
public final static String HENG_FENG_SERVER_URL = "url";
public final static String HENG_FENG_SERVER_BEGIN = "begin";
public final static String HENG_FENG_SERVER_END = "end";
public final static String HENG_FENG_SERVER_FREQUENCY = "frequency";
public final static String HENG_FENG_SERVER_CODE = "code";
public final static String HENG_FENG_SERVER_MSG = "msg";
public final static String HENG_FENG_SERVER_RESPONSE_DATA = "data";
/*
* Local sharedPreference storage key.
* */
public final static String HENG_FENG_DATA_START = HENG_FENG_PREFIX + HENG_FENG_SERVER_DATA_START;
public final static String HENG_FENG_DATA_END = HENG_FENG_PREFIX + HENG_FENG_SERVER_DATA_END;
public final static String HENG_FENG_URL = HENG_FENG_PREFIX + HENG_FENG_SERVER_URL;
public final static String HENG_FENG_BEGIN = HENG_FENG_PREFIX + HENG_FENG_SERVER_BEGIN;
public final static String HENG_FENG_END = HENG_FENG_PREFIX + HENG_FENG_SERVER_END;
public final static String HENG_FENG_FREQUENCY = HENG_FENG_PREFIX + HENG_FENG_SERVER_FREQUENCY;
public final static String HENG_FENG_PHONE = HENG_FENG_PREFIX + "phone";
public final static String HENG_FENG_IS_OEPN = HENG_FENG_PREFIX + "is_open";
/*
* For default value
* */
public final static int HENG_FENG_DEFAULT_FREQUENCY = 10;
public final static int HENG_FENG_DEFAULT_BEGIN = 6;
public final static int HENG_FENG_DEFAULT_END = 22;
public final static int HENG_FENG_DEFAULT_SLOT = 0;
private static PreferencesUtil sDevicePreferences;
private final SharedPreferences mSharePferences;
private final SharedPreferences.Editor mEditor;
private PreferencesUtil(Context context) {
mSharePferences = context.getSharedPreferences(context.getPackageName(), Context.MODE_PRIVATE);
mEditor = mSharePferences.edit();
}
public static synchronized PreferencesUtil getInstance(Context context) {
if (null == sDevicePreferences) {
sDevicePreferences = new PreferencesUtil(context.getApplicationContext());
}
return sDevicePreferences;
}
public void putInt(final String key, final int value) {
mEditor.putInt(key, value);
mEditor.commit();
}
public void putLong(final String key, final long value) {
mEditor.putLong(key, value);
mEditor.commit();
}
public void putString(final String key, final String value) {
mEditor.putString(key, value);
mEditor.commit();
}
public void putFloat(final String key, final float value) {
mEditor.putFloat(key, value);
mEditor.commit();
}
public void putBoolean(final String key, final boolean value) {
mEditor.putBoolean(key, value);
mEditor.commit();
}
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void putStringSet(final String key, final Set<String> values) {
mEditor.putStringSet(key, values);
mEditor.commit();
}
public int getInt(final String key, final int defaultValue) {
return mSharePferences.getInt(key, defaultValue);
}
public long getLong(final String key, final long defaultValue) {
return mSharePferences.getLong(key, defaultValue);
}
public String getString(final String key, final String defaultValue) {
return mSharePferences.getString(key, defaultValue);
}
public float getFloat(final String key, final float defaultValue) {
return mSharePferences.getFloat(key, defaultValue);
}
public boolean getBoolean(final String key, final boolean defaultValue) {
return mSharePferences.getBoolean(key, defaultValue);
}
public Set<String> getStringSet(final String key) {
return mSharePferences.getStringSet(key, null);
}
}
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#FFFFFF" />
<corners
android:bottomLeftRadius="5dp"
android:bottomRightRadius="5dp"
android:topLeftRadius="5dp"
android:topRightRadius="5dp" />
<stroke
android:width="1dp"
android:color="#B9B8B8" />
</shape>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:padding="5px">
<Button
android:layout_gravity="center_vertical"
android:focusable="true"
android:id="@+id/service_apply"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/title_apply"
android:textSize="25px"/>
</LinearLayout>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:padding="5px">
<Button
android:layout_gravity="center_vertical"
android:focusable="true"
android:id="@+id/service_stop"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/title_server_stop"
android:textSize="25px"/>
</LinearLayout>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:padding="5px">
<Button
android:layout_gravity="center_vertical"
android:focusable="true"
android:id="@+id/service_setting"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/title_service_setting"
android:textSize="25px"/>
</LinearLayout>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:padding="5px">
<Button
android:layout_gravity="center_vertical"
android:focusable="true"
android:id="@+id/service_info"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/title_server_info"
android:textSize="25px"/>
</LinearLayout>
</LinearLayout>
\ No newline at end of file
......@@ -4,87 +4,71 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10dp"
android:orientation="vertical">
<TextView
android:id="@+id/interval"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/interval"
android:textSize="18dp"
tools:layout_editor_absoluteX="4dp"
tools:layout_editor_absoluteY="0dp" />
<EditText
android:id="@+id/interval_value"
android:layout_gravity="center"
android:textSize="24px"
android:padding="10px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/time_inter_tips"
android:inputType="number"
/>
android:text="请输入在营业厅申请的套餐手机号"
tools:ignore="MissingConstraints" />
<TextView
android:id="@+id/url"
<LinearLayout
style="@style/InputBoxStyle"
android:layout_marginTop="20px"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/url"
android:textSize="18dp" />
<EditText
android:hint="@string/server_tips"
android:id="@+id/url_value"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<!--<TextView-->
<!--android:layout_marginTop="20dp"-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="wrap_content"-->
<!--android:text="@string/user_tips_title"/>-->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/user_tips_content"/>
android:layout_height="wrap_content">
<!--<EditText-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content"-->
<!--android:text="@string/other_tips"/>-->
<EditText
android:id="@+id/phone_number"
android:cursorVisible="true"
android:hint="输入手机号码"
android:textCursorDrawable="@color/colorPrimary"
android:text="0"
android:focusable="true"
android:focusableInTouchMode="true"
android:minWidth="330px"
android:textSize="28px"
style="@style/EditTextStyle"
android:inputType="number"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_marginTop="50dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:orientation="horizontal"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_gravity="bottom">
<Button
android:layout_gravity="center_vertical"
android:focusable="true"
android:id="@+id/bt_cancel"
android:id="@+id/bt_save"
android:layout_gravity="center_vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/dialog_cancel"
android:textSize="25sp"/>
android:text="@string/dialog_save"
android:textSize="25sp" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_gravity="bottom">
<Button
android:focusable="true"
android:id="@+id/bt_save"
android:layout_gravity="center_vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/dialog_save"
android:textSize="25sp" />
<Button
android:layout_gravity="center_vertical"
android:focusable="true"
android:id="@+id/bt_cancel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/dialog_cancel"
android:textSize="25sp"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:padding="10px"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textSize="24px"
android:text="@string/service_info"/>
</ScrollView>
</android.support.constraint.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="套餐手机号:"
android:textSize="18px" />
<LinearLayout
style="@style/InputBoxStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/phone_number"
android:text="17895507717"
android:focusable="false"
android:focusableInTouchMode="false"
android:minWidth="330px"
android:textSize="18px"
style="@style/EditTextStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<TextView
android:layout_marginTop="10px"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/interval"
android:textSize="18px" />
<LinearLayout
style="@style/InputBoxStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/service_frequency"
android:cursorVisible="true"
android:hint="@string/time_inter_tips"
android:textCursorDrawable="@color/colorPrimary"
android:text="0"
android:focusable="true"
android:focusableInTouchMode="true"
android:minWidth="330px"
android:textSize="14px"
style="@style/EditTextStyle"
android:inputType="number"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<TextView
android:layout_marginTop="10px"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="每天上传时间:"
android:textSize="18px" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18px"
android:text="从 "/>
<Spinner
android:focusable="true"
android:nextFocusRight="@id/service_upload_end"
android:nextFocusDown="@id/service_upload_end"
android:id="@+id/service_upload_start"
android:layout_width="wrap_content"
android:textSize="25px"
android:layout_height="wrap_content"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18px"
android:text=" 到 "/>
<Spinner
android:nextFocusLeft="@id/service_upload_start"
android:nextFocusUp="@id/service_upload_start"
android:id="@+id/service_upload_end"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="25px"/>
</LinearLayout>
<TextView
android:layout_marginTop="10px"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="状态:"
android:textSize="18px" />
<LinearLayout
style="@style/InputBoxStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/service_available_status"
android:cursorVisible="true"
android:hint="@string/time_inter_tips"
android:textCursorDrawable="@color/colorPrimary"
android:text="开通"
android:textStyle="bold"
android:focusable="false"
android:focusableInTouchMode="false"
android:minWidth="330px"
android:textSize="18px"
style="@style/EditTextStyle"
android:inputType="number"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<TextView
android:layout_marginTop="10px"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="有效日期:"
android:textSize="18px" />
<LinearLayout
style="@style/InputBoxStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/service_available_date"
android:cursorVisible="true"
android:hint="@string/time_inter_tips"
android:textCursorDrawable="@color/colorPrimary"
android:text="从 2019.10.1 到 2021.9.30"
android:textStyle="bold"
android:focusable="false"
android:focusableInTouchMode="false"
android:minWidth="330px"
android:textSize="14px"
style="@style/EditTextStyle"
android:inputType="number"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15px">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_weight="1">
<Button
android:id="@+id/bt_save"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:focusable="true"
android:text="@string/dialog_save"
android:textSize="25sp" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_weight="1"
android:orientation="horizontal">
<Button
android:id="@+id/bt_cancel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:focusable="true"
android:text="@string/dialog_cancel"
android:textSize="25sp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_gravity="center"
android:textSize="22px"
android:padding="10px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="您在营业厅申请的套餐手机号为0,请再次输入该号码以确认停止定位服务"
tools:ignore="MissingConstraints" />
<LinearLayout
style="@style/InputBoxStyle"
android:layout_marginTop="5px"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<EditText
android:cursorVisible="true"
android:hint="输入手机号码"
android:textCursorDrawable="@color/colorPrimary"
android:text="0"
android:focusable="true"
android:focusableInTouchMode="true"
android:minWidth="330px"
android:textSize="28px"
style="@style/EditTextStyle"
android:inputType="number"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_marginTop="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_gravity="bottom">
<Button
android:focusable="true"
android:id="@+id/bt_save"
android:layout_gravity="center_vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/dialog_save"
android:textSize="25sp" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_gravity="bottom">
<Button
android:layout_gravity="center_vertical"
android:focusable="true"
android:id="@+id/bt_cancel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/dialog_cancel"
android:textSize="25sp"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">设置</string>
<string name="dialog_cancel">取消</string>
<string name="app_name">定位服务</string>
<string name="dialog_cancel">返回</string>
<string name="url">"上传地址:"</string>>
<string name="interval">"时间间隔(分钟):"</string>
<string name="dialog_save">"保存"</string>
<string name="interval">"上传频率(分钟):"</string>
<string name="dialog_save">"确定"</string>
<string name="interval_prompt">"请设置间隔时长"</string>
<string name="server_prompt">"请设置服务器地址"</string>
<string name="error_msg_1">"经纬度信息无效"</string>
......
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="date">
<item>1点</item>
<item>2点</item>
<item>3点</item>
<item>4点</item>
<item>5点</item>
<item>6点</item>
<item>7点</item>
<item>8点</item>
<item>9点</item>
<item>10点</item>
<item>11点</item>
<item>12点</item>
<item>13点</item>
<item>14点</item>
<item>15点</item>
<item>16点</item>
<item>17点</item>
<item>18点</item>
<item>19点</item>
<item>20点</item>
<item>21点</item>
<item>22点</item>
<item>23点</item>
<item>24点</item>
</string-array>
</resources>
\ No newline at end of file
<resources>
<string name="app_name">Setting</string>
<string name="app_name">Location Service</string>
<string name="dialog_cancel">Cancel</string>
<string name="url">"Upload address:"</string>>
......@@ -10,11 +10,28 @@
<string name="error_msg_1">"Latitude and longitude information is invalid"</string>
<string name="error_msg_2">"Invalid MEID"</string>
<string name="error_msg_3">"Internal processing error"</string>
<string name="save_tips">保存成功</string>
<string name="save_tips" translatable="false">保存成功</string>
<string name="save_cacel">取消</string>
<string name="time_inter_tips">请输入时间间隔</string>
<string name="server_tips">请输入当前服务器接口地址</string>
<string name="user_tips_title">使用说明:</string>
<string name="user_tips_content">每次重启开机后均会发送定位信息,可保存后重启手机测试。</string>
<string name="other_tips">测试接口: http://202.100.179.139:8088/api 正式接口: http://202.100.190.58:8090/api/cstmzPosition</string>
<string name="service_info">\t本定位服务面向在通信运营商处申请开通了特定套餐的用户。\n\t当您进行了“申请开通”的操作后,即表示您在套餐服务有效的时间段内授权本服务获取您的位置。\n\t请您下载“颐关爱”APP查看本手机的定位信息、设置电子围栏范围、收取跨越电子围栏的报警信息。\t本定位的准确性和及时性与手机性能、定位信号强度、信息上传频率、网络情况等诸多因素有关,故本定位服务只起到辅助监护作用,不承担因定位不准确或不及时导致的任何责任,特此声明。</string>
<string name="title_nav">定位服务</string>
<string name="toast_tips_unavailable">未开通定位服务</string>
<string name="title_server_info">服务说明</string>
<string name="title_apply">申请开通</string>
<string name="server_status_unavailable">服务未开通</string>
<string name="service_available_date">从 %s 到 %s</string>
<string name="service_status_available">开通</string>
<string name="service_status_unavailable">停止</string>
<string name="title_service_setting" translatable="false">定位设置</string>
<string name="tips_input_unvaild">输入不合法</string>
<string name="tips_frequency_unvalid">上传频率请设置 1-1440 之间</string>
<string name="tips_save_success">保存成功</string>
<string name="tips_phone_unvalid">套餐手机号输入错误,请重新输入</string>
<string name="tips_service_stop">定位服务已停止</string>
<string name="title_server_stop">停止服务</string>
<string name="toast_tips_server_unavailable">服务器连接错误,请重试</string>
</resources>
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<style name="AppTheme" parent="@style/ThemeOverlay.AppCompat.ActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="InputBoxStyle">
<item name="android:layout_centerHorizontal">true</item>
<item name="android:layout_marginLeft">18dp</item>
<item name="android:layout_marginRight">18dp</item>
<item name="android:background">@drawable/border_input_box</item>
<item name="android:gravity">center</item>
<item name="android:orientation">horizontal</item>
</style>
<style name="EditTextStyle">
<item name="android:layout_marginTop">5dp</item>
<item name="android:layout_marginRight">10dp</item>
<item name="android:layout_marginBottom">5dp</item>
<item name="android:layout_marginLeft">10dp</item>
<item name="android:background">@null</item>
</style>
</resources>
package com.agenew.location_server.application;
package com.toscl.location.hengfeng;
import org.junit.Test;
......
......@@ -7,7 +7,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.2'
classpath 'com.android.tools.build:gradle:3.4.1'
// NOTE: Do not place your application dependencies here; they belong
......
#Thu Apr 04 16:04:06 CST 2019
#Wed Jun 26 09:18:27 CST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
No preview for this file type
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!