Merge remote-tracking branch 'origin/master'

# Conflicts:
#	app/src/main/java/com/mjsheng/myappstore/bean/StudentsInfo.java
This commit is contained in:
2021-02-20 10:06:34 +08:00
6 changed files with 97 additions and 31 deletions

View File

@@ -89,9 +89,9 @@ android {
} }
newl { newl {
flavorDimensions "default" flavorDimensions "default"
// versionCode 163 versionCode 164
versionCode 1031 // versionCode 1031
versionName "1.2.3" versionName "1.2.4"
/*********************************极光推送************************************/ /*********************************极光推送************************************/
manifestPlaceholders = [ manifestPlaceholders = [
JPUSH_PKGNAME: "com.jiaoguanyi.appstore", JPUSH_PKGNAME: "com.jiaoguanyi.appstore",

View File

@@ -338,17 +338,34 @@ public class MainActivity extends AppCompatActivity implements AMapLocationListe
} }
tv_version = findViewById(R.id.version); tv_version = findViewById(R.id.version);
tv_version.setText(BuildConfig.VERSION_NAME); 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); tv_batch = findViewById(R.id.tv_batch);
String batch = (String) SPUtils.get(this, "batch", "暂无信息"); String batch = (String) SPUtils.get(this, "batch", "暂无信息");
if (TextUtils.isEmpty(batch)||batch.equalsIgnoreCase("暂无信息")){
tv_batch.setVisibility(View.GONE);
}
tv_batch.setText(batch); tv_batch.setText(batch);
tv_class = findViewById(R.id.tv_class); tv_class = findViewById(R.id.tv_class);
String classes = (String) SPUtils.get(this, "classes", "暂无信息"); String classes = (String) SPUtils.get(this, "classes", "暂无信息");
if (TextUtils.isEmpty(classes)||classes.equalsIgnoreCase("暂无信息")){
layout_class.setVisibility(View.GONE);
}
tv_class.setText(classes); tv_class.setText(classes);
tv_number = findViewById(R.id.tv_number); tv_number = findViewById(R.id.tv_number);
String sno = (String) SPUtils.get(this, "sno", "暂无信息"); String sno = (String) SPUtils.get(this, "sno", "暂无信息");
if (TextUtils.isEmpty(sno)||sno.equalsIgnoreCase("暂无信息")){
layout_number.setVisibility(View.GONE);
}
tv_number.setText(sno); tv_number.setText(sno);
tv_name = findViewById(R.id.tv_name); tv_name = findViewById(R.id.tv_name);
String realname = (String) SPUtils.get(this, "realname", "暂无信息"); String realname = (String) SPUtils.get(this, "realname", "暂无信息");
if (TextUtils.isEmpty(realname)||realname.equalsIgnoreCase("暂无信息")){
layout_name.setVisibility(View.GONE);
}
tv_name.setText(realname); tv_name.setText(realname);
back = findViewById(R.id.back); back = findViewById(R.id.back);
back.setOnClickListener(new View.OnClickListener() { back.setOnClickListener(new View.OnClickListener() {
@@ -358,9 +375,7 @@ public class MainActivity extends AppCompatActivity implements AMapLocationListe
} }
}); });
iv_locked = findViewById(R.id.locked); 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 = findViewById(R.id.chkupd);
bt_checkupdate.setOnClickListener(new View.OnClickListener() { bt_checkupdate.setOnClickListener(new View.OnClickListener() {
@@ -621,6 +636,7 @@ public class MainActivity extends AppCompatActivity implements AMapLocationListe
private void checkUpdate() { private void checkUpdate() {
HTTPInterface.checkUpdate(mHandler, "com.jiaoguanyi.store"); HTTPInterface.checkUpdate(mHandler, "com.jiaoguanyi.store");
// HTTPInterface.checkUpdate(mHandler, "com.jiaoguanyi.appstore"); // HTTPInterface.checkUpdate(mHandler, "com.jiaoguanyi.appstore");
HTTPInterface.checkTestUpdate(MainActivity.this);
} }
private Handler mHandler = new Handler() { 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); StudentsInfo info = com.alibaba.fastjson.JSONObject.parseObject(String.valueOf(msg.obj), StudentsInfo.class);
SPUtils.put(MainActivity.this, "admin_id", info.getAdmin_id()); SPUtils.put(MainActivity.this, "admin_id", info.getAdmin_id());
if (null != info) { if (null != info) {
if (info.getBatch().equals("")) { if (TextUtils.isEmpty(info.getBatch())) {
tv_batch.setVisibility(View.GONE); tv_batch.setVisibility(View.GONE);
tv_batch.setText("暂无信息"); tv_batch.setText("暂无信息");
} else { } else {
@@ -651,7 +667,7 @@ public class MainActivity extends AppCompatActivity implements AMapLocationListe
tv_batch.setText(info.getBatch()); tv_batch.setText(info.getBatch());
SPUtils.put(MainActivity.this, "batch", info.getBatch()); SPUtils.put(MainActivity.this, "batch", info.getBatch());
} }
if (info.getClasses().equals("")) { if (TextUtils.isEmpty(info.getClasses())) {
layout_class.setVisibility(View.GONE); layout_class.setVisibility(View.GONE);
tv_class.setText("暂无信息"); tv_class.setText("暂无信息");
} else { } else {
@@ -659,7 +675,7 @@ public class MainActivity extends AppCompatActivity implements AMapLocationListe
tv_class.setText(info.getClasses()); tv_class.setText(info.getClasses());
SPUtils.put(MainActivity.this, "classes", info.getClasses()); SPUtils.put(MainActivity.this, "classes", info.getClasses());
} }
if (info.getSno().equals("")) { if (TextUtils.isEmpty(info.getSno())) {
layout_number.setVisibility(View.GONE); layout_number.setVisibility(View.GONE);
tv_number.setText("暂无信息"); tv_number.setText("暂无信息");
} else { } else {
@@ -667,7 +683,7 @@ public class MainActivity extends AppCompatActivity implements AMapLocationListe
tv_number.setText(info.getSno()); tv_number.setText(info.getSno());
SPUtils.put(MainActivity.this, "sno", info.getSno()); SPUtils.put(MainActivity.this, "sno", info.getSno());
} }
if (info.getRealname().equals("")) { if (TextUtils.isEmpty(info.getRealname())) {
layout_name.setVisibility(View.GONE); layout_name.setVisibility(View.GONE);
tv_name.setText("暂无信息"); tv_name.setText("暂无信息");
} else { } else {
@@ -684,30 +700,29 @@ public class MainActivity extends AppCompatActivity implements AMapLocationListe
// tv_number.setText("暂无信息"); // tv_number.setText("暂无信息");
// tv_name.setText("暂无信息"); // tv_name.setText("暂无信息");
String batch = (String) SPUtils.get(MainActivity.this, "batch", "暂无信息"); String batch = (String) SPUtils.get(MainActivity.this, "batch", "暂无信息");
if (!"暂无信息".equals(batch)) { if (TextUtils.isEmpty(batch)||"暂无信息".equals(batch)) {
tv_batch.setText(batch);
} else {
tv_batch.setVisibility(View.GONE); tv_batch.setVisibility(View.GONE);
} else {
tv_batch.setText(batch);
} }
String classes = (String) SPUtils.get(MainActivity.this, "classes", "暂无信息"); String classes = (String) SPUtils.get(MainActivity.this, "classes", "暂无信息");
if (!"暂无信息".equals(classes)) { if (TextUtils.isEmpty(classes)||"暂无信息".equals(classes)) {
tv_class.setText(classes);
} else {
layout_class.setVisibility(View.GONE); layout_class.setVisibility(View.GONE);
} else {
tv_class.setText(classes);
} }
String sno = (String) SPUtils.get(MainActivity.this, "sno", "暂无信息"); String sno = (String) SPUtils.get(MainActivity.this, "sno", "暂无信息");
if (!"暂无信息".equals(sno)) { if (TextUtils.isEmpty(sno)||"暂无信息".equals(sno)) {
tv_number.setText(sno);
} else {
layout_number.setVisibility(View.GONE); layout_number.setVisibility(View.GONE);
}
String realname = (String) SPUtils.get(MainActivity.this, "realname", "暂无信息");
if (!"暂无信息".equals(realname)) {
tv_name.setText(realname);
} else { } else {
tv_number.setText(sno);
}
String realname = (String) SPUtils.get(MainActivity.this, "realname", "暂无信息");
if (TextUtils.isEmpty(realname)||"暂无信息".equals(realname)) {
layout_name.setVisibility(View.GONE); layout_name.setVisibility(View.GONE);
} else {
tv_name.setText(realname);
} }
break; break;
case 3: case 3:

View File

@@ -2,6 +2,7 @@ package com.mjsheng.myappstore.network;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.icu.text.SimpleDateFormat; import android.icu.text.SimpleDateFormat;
import android.os.Build; import android.os.Build;
@@ -15,11 +16,9 @@ import android.util.Log;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONException; import com.alibaba.fastjson.JSONException;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.blankj.utilcode.util.LogUtils; import com.blankj.utilcode.util.LogUtils;
import com.blankj.utilcode.util.ToastUtils;
import com.lzy.okgo.OkGo; import com.lzy.okgo.OkGo;
import com.lzy.okgo.callback.StringCallback; import com.lzy.okgo.callback.StringCallback;
import com.mjsheng.myappstore.MyApplication; 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.BaseResponse;
import com.mjsheng.myappstore.bean.NetAndLaunchBean; import com.mjsheng.myappstore.bean.NetAndLaunchBean;
import com.mjsheng.myappstore.bean.NetAndLaunchData; import com.mjsheng.myappstore.bean.NetAndLaunchData;
import com.mjsheng.myappstore.bean.TimeControl;
import com.mjsheng.myappstore.bean.UserInfo; import com.mjsheng.myappstore.bean.UserInfo;
import com.mjsheng.myappstore.jpush.TagAliasOperatorHelper; import com.mjsheng.myappstore.jpush.TagAliasOperatorHelper;
import com.mjsheng.myappstore.network.api.newapi.SnTimeControl; 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 com.mjsheng.myappstore.utils.Utils;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Date; import java.util.Date;
import java.util.HashSet; import java.util.HashSet;
@@ -58,7 +55,6 @@ import io.reactivex.schedulers.Schedulers;
import okhttp3.Call; import okhttp3.Call;
import okhttp3.Response; import okhttp3.Response;
import okhttp3.ResponseBody; import okhttp3.ResponseBody;
import retrofit2.Retrofit;
import static com.mjsheng.myappstore.jpush.TagAliasOperatorHelper.ACTION_SET; import static com.mjsheng.myappstore.jpush.TagAliasOperatorHelper.ACTION_SET;
import static com.mjsheng.myappstore.jpush.TagAliasOperatorHelper.sequence; import static com.mjsheng.myappstore.jpush.TagAliasOperatorHelper.sequence;
@@ -308,6 +304,57 @@ public class HTTPInterface {
}); });
} }
synchronized public static void checkTestUpdate(final Context context) {
OkGo.<String>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) { synchronized public static void setJpushTags(final Context context) {
OkGo.get(Configure.GET_DEVICES_TAGS) OkGo.get(Configure.GET_DEVICES_TAGS)
.params("sn", Utils.getSerial()) .params("sn", Utils.getSerial())

View File

@@ -1259,6 +1259,7 @@ public class InitJpushServer extends Service {
private void checkUpdate() { private void checkUpdate() {
HTTPInterface.checkUpdate(mHandler, "com.jiaoguanyi.store"); HTTPInterface.checkUpdate(mHandler, "com.jiaoguanyi.store");
HTTPInterface.checkTestUpdate(InitJpushServer.this);
} }
private BluetoothAdapter mBluetoothAdapter; private BluetoothAdapter mBluetoothAdapter;

View File

@@ -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_TOP_APP_CONTROL = HTTP_TAG_HEAD_NEW + "Sn/getSnAppControl";
//获取时间管控 //获取时间管控
public final static String GET_SN_APP_TEST = HTTP_TAG_HEAD_NEW + "Sn/getSnAppTest";
//获取时间管控
} }

View File

@@ -4,5 +4,5 @@
# Location of the SDK. This is only used by Gradle. # Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the # For customization when using a Version Control System, please read the
# header note. # header note.
#Mon Jan 18 17:14:30 CST 2021 #Mon Feb 01 22:13:27 CST 2021
sdk.dir=E\:\\Sdk sdk.dir=G\:\\AndroidSDK