|
@@ -1,6 +1,7 @@
|
|
|
package com.xzjmyk.pm.activity.ui.me;
|
|
package com.xzjmyk.pm.activity.ui.me;
|
|
|
|
|
|
|
|
import android.annotation.TargetApi;
|
|
import android.annotation.TargetApi;
|
|
|
|
|
+import android.app.ActivityManager;
|
|
|
import android.app.AlertDialog;
|
|
import android.app.AlertDialog;
|
|
|
import android.app.ProgressDialog;
|
|
import android.app.ProgressDialog;
|
|
|
import android.content.DialogInterface;
|
|
import android.content.DialogInterface;
|
|
@@ -15,6 +16,7 @@ import android.view.View;
|
|
|
import android.widget.Button;
|
|
import android.widget.Button;
|
|
|
import android.widget.RelativeLayout;
|
|
import android.widget.RelativeLayout;
|
|
|
import android.widget.TextView;
|
|
import android.widget.TextView;
|
|
|
|
|
+import android.widget.Toast;
|
|
|
|
|
|
|
|
import com.baidu.android.pushservice.PushManager;
|
|
import com.baidu.android.pushservice.PushManager;
|
|
|
import com.baidu.autoupdatesdk.AppUpdateInfo;
|
|
import com.baidu.autoupdatesdk.AppUpdateInfo;
|
|
@@ -42,6 +44,8 @@ import com.xzjmyk.pm.activity.util.ToastUtil;
|
|
|
|
|
|
|
|
import java.io.File;
|
|
import java.io.File;
|
|
|
|
|
|
|
|
|
|
+import basepedo.ui.MyPedometerActivity;
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 设置
|
|
* 设置
|
|
|
*/
|
|
*/
|
|
@@ -54,6 +58,12 @@ public class SettingActivity extends ActionBackActivity implements View.OnClickL
|
|
|
@ViewInject(R.id.cb_task_reply)
|
|
@ViewInject(R.id.cb_task_reply)
|
|
|
private SwitchView cb_task_reply;
|
|
private SwitchView cb_task_reply;
|
|
|
|
|
|
|
|
|
|
+ @ViewInject(R.id.uu_step_rl)
|
|
|
|
|
+ private RelativeLayout uu_step_rl;
|
|
|
|
|
+
|
|
|
|
|
+ @ViewInject(R.id.uu_step_reply)
|
|
|
|
|
+ private SwitchView uu_step_reply;
|
|
|
|
|
+
|
|
|
@ViewInject(R.id.rl_app_update)
|
|
@ViewInject(R.id.rl_app_update)
|
|
|
private RelativeLayout rl_app_update;
|
|
private RelativeLayout rl_app_update;
|
|
|
@ViewInject(R.id.version_value)
|
|
@ViewInject(R.id.version_value)
|
|
@@ -62,6 +72,7 @@ public class SettingActivity extends ActionBackActivity implements View.OnClickL
|
|
|
private RelativeLayout close_push_rl;
|
|
private RelativeLayout close_push_rl;
|
|
|
private ProgressDialog dialog;
|
|
private ProgressDialog dialog;
|
|
|
private RelativeLayout share_rl;
|
|
private RelativeLayout share_rl;
|
|
|
|
|
+ private String uustep_service_name = "basepedo.service.StepService";
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
@@ -80,6 +91,7 @@ public class SettingActivity extends ActionBackActivity implements View.OnClickL
|
|
|
mExitBtn = (Button) findViewById(R.id.exit_btn);
|
|
mExitBtn = (Button) findViewById(R.id.exit_btn);
|
|
|
//share_rl.setVisibility(View.GONE);
|
|
//share_rl.setVisibility(View.GONE);
|
|
|
int isPush = PreferenceUtils.getInt(MyApplication.getInstance(), MainActivity.BAIDU_PUSH);
|
|
int isPush = PreferenceUtils.getInt(MyApplication.getInstance(), MainActivity.BAIDU_PUSH);
|
|
|
|
|
+
|
|
|
if (isPush == -1) {//第一次进入没有配置
|
|
if (isPush == -1) {//第一次进入没有配置
|
|
|
cb_task_reply.setChecked(true);
|
|
cb_task_reply.setChecked(true);
|
|
|
} else if (isPush == 0) {//选择不推送
|
|
} else if (isPush == 0) {//选择不推送
|
|
@@ -119,8 +131,58 @@ public class SettingActivity extends ActionBackActivity implements View.OnClickL
|
|
|
long cacheSize = GetFileSizeUtil.getFileSize(new File(MyApplication.getInstance().mAppDir));
|
|
long cacheSize = GetFileSizeUtil.getFileSize(new File(MyApplication.getInstance().mAppDir));
|
|
|
mCacheTv.setText(GetFileSizeUtil.formatFileSize(cacheSize));
|
|
mCacheTv.setText(GetFileSizeUtil.formatFileSize(cacheSize));
|
|
|
uas_website_tv.setText(CommonUtil.getSharedPreferences(this, "erp_baseurl"));
|
|
uas_website_tv.setText(CommonUtil.getSharedPreferences(this, "erp_baseurl"));
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ //UU开关的根据StepService是否开启显示状态
|
|
|
|
|
+ int isStep = PreferenceUtils.getInt(MyApplication.getInstance(), MainActivity.UU_STEP);
|
|
|
|
|
+
|
|
|
|
|
+ if (isServiceRunning(uustep_service_name)){
|
|
|
|
|
+ uu_step_reply.setChecked(true);
|
|
|
|
|
+ uu_step_reply.setFocusable(false);
|
|
|
|
|
+ uu_step_reply.setClickable(false);
|
|
|
|
|
+ }else {
|
|
|
|
|
+ uu_step_reply.setChecked(false);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ uu_step_reply.setOnCheckedChangeListener(new SwitchView.OnCheckedChangeListener() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onCheckedChanged(View view, boolean isChecked) {
|
|
|
|
|
+ if (isChecked) {
|
|
|
|
|
+ PreferenceUtils.putInt(MainActivity.UU_STEP, 1);
|
|
|
|
|
+ PushManager.resumeWork(MyApplication.getInstance());
|
|
|
|
|
+ uu_step_reply.setFocusable(false);
|
|
|
|
|
+ uu_step_reply.setClickable(false);
|
|
|
|
|
+ startActivity(new Intent(mContext, MyPedometerActivity.class));
|
|
|
|
|
+ } else {
|
|
|
|
|
+ PushManager.stopWork(MyApplication.getInstance());
|
|
|
|
|
+ PreferenceUtils.putInt(MainActivity.UU_STEP, 0);
|
|
|
|
|
+// stopService(intent);
|
|
|
|
|
+ Toast.makeText(mContext, "您已关闭UU运动", Toast.LENGTH_LONG).show();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ uu_step_rl.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onClick(View v) {
|
|
|
|
|
+ int last_isStep = PreferenceUtils.getInt(MyApplication.getInstance(), MainActivity.UU_STEP);
|
|
|
|
|
+ if (isServiceRunning(uustep_service_name) && last_isStep == 1){
|
|
|
|
|
+ startActivity(new Intent(mContext, MyPedometerActivity.class));
|
|
|
|
|
+ }else {
|
|
|
|
|
+ Toast.makeText(mContext, "尚未开启UU运动", Toast.LENGTH_SHORT).show();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private boolean isServiceRunning(String servicename) { //判断某个服务是否已经运行
|
|
|
|
|
+ ActivityManager manager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
|
|
|
|
|
+ for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
|
|
|
|
|
+ if (servicename.equals(service.service.getClassName())) {
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
private void showExitDialog() {
|
|
private void showExitDialog() {
|
|
|
new AlertDialog.Builder(mContext).setTitle(R.string.app_name).setMessage(R.string.exit_tips).setNegativeButton(R.string.cancel, null)
|
|
new AlertDialog.Builder(mContext).setTitle(R.string.app_name).setMessage(R.string.exit_tips).setNegativeButton(R.string.cancel, null)
|
|
|
.setPositiveButton(R.string.sure, new DialogInterface.OnClickListener() {
|
|
.setPositiveButton(R.string.sure, new DialogInterface.OnClickListener() {
|