From 826329e3931509b7bcbdc38ea38b0f56f3a6b605 Mon Sep 17 00:00:00 2001 From: fanhuitong <981964879@qq.com> Date: Tue, 2 Feb 2021 18:55:02 +0800 Subject: [PATCH] =?UTF-8?q?update:2020.02.02=20fix:=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E5=9C=A8=E6=B2=A1=E6=9C=89=E7=BD=91=E7=BB=9C=E6=83=85=E5=86=B5?= =?UTF-8?q?=E4=B8=8B=20=E6=9A=82=E6=97=A0=E4=BF=A1=E6=81=AF=20=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E7=9A=84bug=20add:=E5=A2=9E=E5=8A=A0=E4=BA=86?= =?UTF-8?q?=E7=81=B0=E5=BA=A6=E6=B5=8B=E8=AF=95=E7=9A=84=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=92=8C=E6=8E=A8=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 6 +- .../myappstore/activity/MainActivity.java | 57 +++++++++++------- .../mjsheng/myappstore/bean/StudentsInfo.java | 58 +++++++++++++++++++ .../myappstore/network/HTTPInterface.java | 57 ++++++++++++++++-- .../myappstore/server/InitJpushServer.java | 1 + .../mjsheng/myappstore/utils/Configure.java | 3 + local.properties | 4 +- 7 files changed, 155 insertions(+), 31 deletions(-) create mode 100644 app/src/main/java/com/mjsheng/myappstore/bean/StudentsInfo.java diff --git a/app/build.gradle b/app/build.gradle index f188ba5..a52f898 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -89,9 +89,9 @@ android { } newl { flavorDimensions "default" -// versionCode 163 - versionCode 1031 - versionName "1.2.3" + versionCode 164 +// versionCode 1031 + versionName "1.2.4" /*********************************极光推送************************************/ manifestPlaceholders = [ JPUSH_PKGNAME: "com.jiaoguanyi.appstore", diff --git a/app/src/main/java/com/mjsheng/myappstore/activity/MainActivity.java b/app/src/main/java/com/mjsheng/myappstore/activity/MainActivity.java index d21bf48..424fe29 100644 --- a/app/src/main/java/com/mjsheng/myappstore/activity/MainActivity.java +++ b/app/src/main/java/com/mjsheng/myappstore/activity/MainActivity.java @@ -338,17 +338,34 @@ public class MainActivity extends AppCompatActivity implements AMapLocationListe } tv_version = findViewById(R.id.version); tv_version.setText(BuildConfig.VERSION_NAME); + + layout_class = findViewById(R.id.layout_class); + layout_number = findViewById(R.id.layout_number); + layout_name = findViewById(R.id.layout_name); + tv_batch = findViewById(R.id.tv_batch); String batch = (String) SPUtils.get(this, "batch", "暂无信息"); + if (TextUtils.isEmpty(batch)||batch.equalsIgnoreCase("暂无信息")){ + tv_batch.setVisibility(View.GONE); + } tv_batch.setText(batch); tv_class = findViewById(R.id.tv_class); String classes = (String) SPUtils.get(this, "classes", "暂无信息"); + if (TextUtils.isEmpty(classes)||classes.equalsIgnoreCase("暂无信息")){ + layout_class.setVisibility(View.GONE); + } tv_class.setText(classes); tv_number = findViewById(R.id.tv_number); String sno = (String) SPUtils.get(this, "sno", "暂无信息"); + if (TextUtils.isEmpty(sno)||sno.equalsIgnoreCase("暂无信息")){ + layout_number.setVisibility(View.GONE); + } tv_number.setText(sno); tv_name = findViewById(R.id.tv_name); String realname = (String) SPUtils.get(this, "realname", "暂无信息"); + if (TextUtils.isEmpty(realname)||realname.equalsIgnoreCase("暂无信息")){ + layout_name.setVisibility(View.GONE); + } tv_name.setText(realname); back = findViewById(R.id.back); back.setOnClickListener(new View.OnClickListener() { @@ -358,9 +375,7 @@ public class MainActivity extends AppCompatActivity implements AMapLocationListe } }); iv_locked = findViewById(R.id.locked); - layout_class = findViewById(R.id.layout_class); - layout_number = findViewById(R.id.layout_number); - layout_name = findViewById(R.id.layout_name); + bt_checkupdate = findViewById(R.id.chkupd); bt_checkupdate.setOnClickListener(new View.OnClickListener() { @@ -621,6 +636,7 @@ public class MainActivity extends AppCompatActivity implements AMapLocationListe private void checkUpdate() { HTTPInterface.checkUpdate(mHandler, "com.jiaoguanyi.store"); // HTTPInterface.checkUpdate(mHandler, "com.jiaoguanyi.appstore"); + HTTPInterface.checkTestUpdate(MainActivity.this); } private Handler mHandler = new Handler() { @@ -643,7 +659,7 @@ public class MainActivity extends AppCompatActivity implements AMapLocationListe StudentsInfo info = com.alibaba.fastjson.JSONObject.parseObject(String.valueOf(msg.obj), StudentsInfo.class); SPUtils.put(MainActivity.this, "admin_id", info.getAdmin_id()); if (null != info) { - if (info.getBatch().equals("")) { + if (TextUtils.isEmpty(info.getBatch())) { tv_batch.setVisibility(View.GONE); tv_batch.setText("暂无信息"); } else { @@ -651,7 +667,7 @@ public class MainActivity extends AppCompatActivity implements AMapLocationListe tv_batch.setText(info.getBatch()); SPUtils.put(MainActivity.this, "batch", info.getBatch()); } - if (info.getClasses().equals("")) { + if (TextUtils.isEmpty(info.getClasses())) { layout_class.setVisibility(View.GONE); tv_class.setText("暂无信息"); } else { @@ -659,7 +675,7 @@ public class MainActivity extends AppCompatActivity implements AMapLocationListe tv_class.setText(info.getClasses()); SPUtils.put(MainActivity.this, "classes", info.getClasses()); } - if (info.getSno().equals("")) { + if (TextUtils.isEmpty(info.getSno())) { layout_number.setVisibility(View.GONE); tv_number.setText("暂无信息"); } else { @@ -667,7 +683,7 @@ public class MainActivity extends AppCompatActivity implements AMapLocationListe tv_number.setText(info.getSno()); SPUtils.put(MainActivity.this, "sno", info.getSno()); } - if (info.getRealname().equals("")) { + if (TextUtils.isEmpty(info.getRealname())) { layout_name.setVisibility(View.GONE); tv_name.setText("暂无信息"); } else { @@ -684,30 +700,29 @@ public class MainActivity extends AppCompatActivity implements AMapLocationListe // tv_number.setText("暂无信息"); // tv_name.setText("暂无信息"); String batch = (String) SPUtils.get(MainActivity.this, "batch", "暂无信息"); - if (!"暂无信息".equals(batch)) { - tv_batch.setText(batch); - } else { + if (TextUtils.isEmpty(batch)||"暂无信息".equals(batch)) { tv_batch.setVisibility(View.GONE); + } else { + tv_batch.setText(batch); } String classes = (String) SPUtils.get(MainActivity.this, "classes", "暂无信息"); - if (!"暂无信息".equals(classes)) { - tv_class.setText(classes); - } else { + if (TextUtils.isEmpty(classes)||"暂无信息".equals(classes)) { layout_class.setVisibility(View.GONE); + } else { + tv_class.setText(classes); } String sno = (String) SPUtils.get(MainActivity.this, "sno", "暂无信息"); - if (!"暂无信息".equals(sno)) { - tv_number.setText(sno); - } else { + if (TextUtils.isEmpty(sno)||"暂无信息".equals(sno)) { layout_number.setVisibility(View.GONE); - } - - String realname = (String) SPUtils.get(MainActivity.this, "realname", "暂无信息"); - if (!"暂无信息".equals(realname)) { - tv_name.setText(realname); } else { + tv_number.setText(sno); + } + String realname = (String) SPUtils.get(MainActivity.this, "realname", "暂无信息"); + if (TextUtils.isEmpty(realname)||"暂无信息".equals(realname)) { layout_name.setVisibility(View.GONE); + } else { + tv_name.setText(realname); } break; case 3: diff --git a/app/src/main/java/com/mjsheng/myappstore/bean/StudentsInfo.java b/app/src/main/java/com/mjsheng/myappstore/bean/StudentsInfo.java new file mode 100644 index 0000000..ffbbb20 --- /dev/null +++ b/app/src/main/java/com/mjsheng/myappstore/bean/StudentsInfo.java @@ -0,0 +1,58 @@ +package com.mjsheng.myappstore.bean; + +public class StudentsInfo { + private String id; + private String batch; + private String realname; + private String classes ; + private String sno; + private int admin_id; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getBatch() { + return batch; + } + + public void setBatch(String batch) { + this.batch = batch; + } + + public String getRealname() { + return realname; + } + + public void setRealname(String realname) { + this.realname = realname; + } + + public String getClasses() { + return classes; + } + + public void setClasses(String classes) { + this.classes = classes; + } + + public String getSno() { + return sno; + } + + public void setSno(String sno) { + this.sno = sno; + } + + public int getAdmin_id() { + return admin_id; + } + + public void setAdmin_id(int admin_id) { + this.admin_id = admin_id; + } +} diff --git a/app/src/main/java/com/mjsheng/myappstore/network/HTTPInterface.java b/app/src/main/java/com/mjsheng/myappstore/network/HTTPInterface.java index 4b6d205..1076e4b 100644 --- a/app/src/main/java/com/mjsheng/myappstore/network/HTTPInterface.java +++ b/app/src/main/java/com/mjsheng/myappstore/network/HTTPInterface.java @@ -2,6 +2,7 @@ package com.mjsheng.myappstore.network; import android.content.Context; import android.content.Intent; +import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.icu.text.SimpleDateFormat; import android.os.Build; @@ -15,11 +16,9 @@ import android.util.Log; import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONException; import com.alibaba.fastjson.JSONObject; import com.blankj.utilcode.util.LogUtils; -import com.blankj.utilcode.util.ToastUtils; import com.lzy.okgo.OkGo; import com.lzy.okgo.callback.StringCallback; import com.mjsheng.myappstore.MyApplication; @@ -27,7 +26,6 @@ import com.mjsheng.myappstore.bean.Appground; import com.mjsheng.myappstore.bean.BaseResponse; import com.mjsheng.myappstore.bean.NetAndLaunchBean; import com.mjsheng.myappstore.bean.NetAndLaunchData; -import com.mjsheng.myappstore.bean.TimeControl; import com.mjsheng.myappstore.bean.UserInfo; import com.mjsheng.myappstore.jpush.TagAliasOperatorHelper; import com.mjsheng.myappstore.network.api.newapi.SnTimeControl; @@ -44,7 +42,6 @@ import com.mjsheng.myappstore.utils.ToastUtil; import com.mjsheng.myappstore.utils.Utils; import java.io.IOException; -import java.util.ArrayList; import java.util.Arrays; import java.util.Date; import java.util.HashSet; @@ -58,7 +55,6 @@ import io.reactivex.schedulers.Schedulers; import okhttp3.Call; import okhttp3.Response; import okhttp3.ResponseBody; -import retrofit2.Retrofit; import static com.mjsheng.myappstore.jpush.TagAliasOperatorHelper.ACTION_SET; import static com.mjsheng.myappstore.jpush.TagAliasOperatorHelper.sequence; @@ -308,6 +304,57 @@ public class HTTPInterface { }); } + + synchronized public static void checkTestUpdate(final Context context) { + OkGo.get(Configure.GET_SN_APP_TEST) + .params("sn", Utils.getSerial()) + .execute(new StringCallback() { + @Override + public void onSuccess(String s, Call call, okhttp3.Response response) { + JSONObject jsonObject = JSON.parseObject(s); + int code = jsonObject.getInteger("code"); + String msg = jsonObject.getString("msg"); + if (code == 200) { + JSONObject data = JSON.parseObject(jsonObject.getString("data")); + installTestAPK(context, data); + } else { + Log.e("checkTestUpdate", "onSuccess: " + msg); + } + } + + @Override + public void onError(Call call, Response response, Exception e) { + super.onError(call, response, e); + Log.e("checkTestUpdate", "onError" + e.getMessage()); + + } + }); + } + + private static void installTestAPK(final Context context, JSONObject jsonObject) { + final String url = jsonObject.getString("app_url"); + int versionCode = jsonObject.getInteger("app_version_code"); + final String packageName = jsonObject.getString("app_package"); + String app_name = jsonObject.getString("app_name"); + final com.alibaba.fastjson.JSONObject object = new com.alibaba.fastjson.JSONObject(); + object.put("app_name", app_name); + object.put("app_package", packageName); + PackageManager pm = context.getPackageManager(); + PackageInfo packageInfo = null; + try { + packageInfo = pm.getPackageInfo(packageName, 0); + } catch (PackageManager.NameNotFoundException e) { + e.printStackTrace(); + } + if (packageInfo == null || packageInfo.versionCode < versionCode) { + Utils.ariaDownload(context, url, object); + } else { + Log.e("installTestAPK", "APK: " + "无更新"); + } + + } + + synchronized public static void setJpushTags(final Context context) { OkGo.get(Configure.GET_DEVICES_TAGS) .params("sn", Utils.getSerial()) diff --git a/app/src/main/java/com/mjsheng/myappstore/server/InitJpushServer.java b/app/src/main/java/com/mjsheng/myappstore/server/InitJpushServer.java index 36e00ad..59f1c1b 100644 --- a/app/src/main/java/com/mjsheng/myappstore/server/InitJpushServer.java +++ b/app/src/main/java/com/mjsheng/myappstore/server/InitJpushServer.java @@ -1259,6 +1259,7 @@ public class InitJpushServer extends Service { private void checkUpdate() { HTTPInterface.checkUpdate(mHandler, "com.jiaoguanyi.store"); + HTTPInterface.checkTestUpdate(InitJpushServer.this); } private BluetoothAdapter mBluetoothAdapter; diff --git a/app/src/main/java/com/mjsheng/myappstore/utils/Configure.java b/app/src/main/java/com/mjsheng/myappstore/utils/Configure.java index 4003aef..26b75bf 100644 --- a/app/src/main/java/com/mjsheng/myappstore/utils/Configure.java +++ b/app/src/main/java/com/mjsheng/myappstore/utils/Configure.java @@ -219,4 +219,7 @@ public class Configure { //获取时间管控 public final static String GET_TOP_APP_CONTROL = HTTP_TAG_HEAD_NEW + "Sn/getSnAppControl"; //获取时间管控 + public final static String GET_SN_APP_TEST = HTTP_TAG_HEAD_NEW + "Sn/getSnAppTest"; + //获取时间管控 + } diff --git a/local.properties b/local.properties index 3e2996e..d44a813 100644 --- a/local.properties +++ b/local.properties @@ -4,5 +4,5 @@ # Location of the SDK. This is only used by Gradle. # For customization when using a Version Control System, please read the # header note. -#Mon Jan 18 17:14:30 CST 2021 -sdk.dir=E\:\\Sdk +#Mon Feb 01 22:13:27 CST 2021 +sdk.dir=G\:\\AndroidSDK