Explorar el Código

更新

tags/old_version_1
fyf hace 1 año
padre
commit
e6e9ae16e7
Se han modificado 14 ficheros con 348 adiciones y 120 borrados
  1. +6
    -0
      app/build.gradle
  2. +1
    -1
      app/src/main/java/com/bonait/bnframework/business/ConfigData.java
  3. +1
    -1
      app/src/main/java/com/bonait/bnframework/common/constant/ConfigName.java
  4. +63
    -0
      app/src/main/java/com/bonait/bnframework/common/db/QueryDB.java
  5. +121
    -24
      app/src/main/java/com/bonait/bnframework/common/utils/UpdateAppUtils.java
  6. +126
    -1
      app/src/main/java/com/bonait/bnframework/modules/mine/fragment/MyFragment.java
  7. +11
    -11
      app/src/main/java/com/bonait/bnframework/modules/mine/fragment/from/NoticeActivity.java
  8. +16
    -5
      app/src/main/java/com/bonait/bnframework/modules/welcome/activity/LoginActivity.java
  9. +2
    -76
      app/src/main/res/layout/activity_notice.xml
  10. +1
    -1
      app/src/main/res/layout/fragment_my.xml
  11. BIN
     
  12. BIN
     
  13. BIN
     
  14. BIN
     

+ 6
- 0
app/build.gradle Ver fichero

@@ -25,6 +25,12 @@ android {
resValue("bool","superAdminTest","true")
}
}

lintOptions {
abortOnError false
checkReleaseBuilds false
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8


+ 1
- 1
app/src/main/java/com/bonait/bnframework/business/ConfigData.java Ver fichero

@@ -241,7 +241,7 @@ public class ConfigData {
}

/**
* 更新版本
* 更新版本检测
*/
public void UpdateVersion()
{


+ 1
- 1
app/src/main/java/com/bonait/bnframework/common/constant/ConfigName.java Ver fichero

@@ -98,7 +98,7 @@ public class ConfigName {

//region 版本信息
/**
* 版本更新
* 版本更新,当前版本
*/
public String Version="1.0";
//endregion


+ 63
- 0
app/src/main/java/com/bonait/bnframework/common/db/QueryDB.java Ver fichero

@@ -1721,6 +1721,69 @@ public class QueryDB {
else
return data.get(0);
}

/**
* ID查询用户
*
* @param id
* @return
*/
public static BPA_USER GetUserID(String id) {
try {
BPA_USER bpa_material = null;
String orderby = Desc_Time_Up;//出料顺序
String where = "isDelete=? and id=?";
String[] args = new String[]{"0", id};
ArrayList<Object> obj = Get(BPA_USER.class, where, args, orderby);
for (Object k : obj) {
bpa_material = (BPA_USER) k;
}
return bpa_material;
} catch (Exception e) {
Log.d("ID查询用户信息", "ID查询用户信息异常: " + e.getMessage());
return null;
}

}
/**
* 修改签名
* @param id
* @param data
*/
public static BPA_USER UpdateUserSign(String id, String data) {
BPA_USER user = GetUserID(id);
if (user != null) {
user.exp = data;
Update(BPA_USER.class, user);
}
return user;
}
/**
* 修改用户名
* @param id
* @param data
*/
public static BPA_USER UpdateUserName(String id, String data) {
BPA_USER user = GetUserID(id);
if (user != null) {
user.name = data;
Update(BPA_USER.class, user);
}
return user;
}
/**
* 修改密码
* @param id
* @param data
*/
public static BPA_USER UpdateUserPass(String id, String data) {
BPA_USER user = GetUserID(id);
if (user != null) {
user.pass = data;
Update(BPA_USER.class, user);
}
return user;
}
//endregion

//region BPA_MENU 菜单表


+ 121
- 24
app/src/main/java/com/bonait/bnframework/common/utils/UpdateAppUtils.java Ver fichero

@@ -4,11 +4,22 @@ import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.Message;

import androidx.core.content.FileProvider;

import com.bonait.bnframework.business.ConfigData;
import com.bonait.bnframework.common.constant.ConfigName;
import com.bonait.bnframework.common.constant.Constants;
import com.bonait.bnframework.common.constant.MessageName;
import com.bonait.bnframework.common.helper.Json;
import com.bonait.bnframework.common.helper.mode.ResVersion;
import com.bonait.bnframework.common.helper.mode.VersionMode;
import com.bonait.bnframework.common.helper.mode.VersionResponse;
import com.bonait.bnframework.common.http.callback.files.FileProgressDialogCallBack;
import com.bonait.bnframework.common.http.callback.json.JsonDialogCallback;
import com.bonait.bnframework.common.message.MessageLooper;
import com.bonait.bnframework.common.message.MessageManager;
import com.bonait.bnframework.modules.mine.model.UpdateAppPo;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.Response;
@@ -17,6 +28,9 @@ import com.qmuiteam.qmui.widget.dialog.QMUIDialogAction;

import java.io.File;

import okhttp3.MediaType;
import okhttp3.RequestBody;

/**
* Created by LY on 2019/4/1.
*/
@@ -26,19 +40,14 @@ public class UpdateAppUtils {
* apk下载地址
*/
private static String downloadUrl = "";

/**
* 获取服务器apk下载地址ID
*/
private static String serviceApkId = "";
/**
* 当前版本号
*/
private static int myVersionCode = 0;
private static String myVersionCode = "1.0";
/**
* 服务器的版本号
* 服务器的版本号
*/
private static int serviceVersionCode = 0;
private static String serviceVersionCode = "1.0";
/**
* 服务器的版本号名称
*/
@@ -48,36 +57,45 @@ public class UpdateAppUtils {
*/
private static String description = "";

private static Context context;
/**
* 更新APP版本入口
*/
public static void updateApp(Context context) {
public static void updateApp(Context _context) {
context=_context;
//获取当前app版本号
myVersionCode = AppUtils.getVersionCode(context);
myVersionCode = ConfigName.getInstance().Version;//AppUtils.getVersionCode(context);
//获取json转成Gson,并获取版本等信息
doPost(context);
doPost(_context);
}

/**
* 请求后台服务器,检查apk版本
*/
private static void doPost(final Context context) {
String getNewVersionUrl = Constants.SERVICE_IP + "/iandroid/appVersionAction!getNewVersion.do";
OkGo.<UpdateAppPo>post(getNewVersionUrl)
VersionMode mode=new VersionMode();
mode.productCode="1668085292913659904";
mode.moduleCode="naichaji";
mode.serverCode="1668175205545807872";
mode.branchCode="1668801915890962433";
String msg= new Json<VersionMode>().objectToJson(VersionMode.class, mode);
String getNewVersionUrl =ConfigName.getInstance().UpdateVersion;
MediaType JSON = MediaType.parse("application/json; charset=utf-8");
RequestBody body = RequestBody.create(JSON, String.valueOf(msg));
OkGo.<ResVersion>post(getNewVersionUrl)
.tag(context)
.execute(new JsonDialogCallback<UpdateAppPo>(context) {
.upRequestBody(body)
.execute(new JsonDialogCallback<ResVersion>(context) {
@Override
public void onSuccess(Response<UpdateAppPo> response) {
UpdateAppPo updateAppPo = response.body();
if (updateAppPo != null) {
serviceVersionCode = updateAppPo.getVersion();
description = updateAppPo.getDescription();
serviceApkId = updateAppPo.getApkId();
public void onSuccess(Response<ResVersion> response) {
ResVersion version= response.body();
if (version != null && version.data!=null) {
serviceVersionCode = version.data.versionNo;
description = version.data.description;
//获取apk下载地址
String url = Constants.SERVICE_IP + "/file-download?fileId=";
downloadUrl = url + serviceApkId;
downloadUrl = version.data.downloadLink;
// 判断Apk是否是最新版本
if (myVersionCode < serviceVersionCode) {
if (compareVersions(serviceVersionCode, myVersionCode))//需要更新
{
showUpdateDialog(context);
} else {
ToastUtils.info("当前版本已是最新版本");
@@ -130,6 +148,9 @@ public class UpdateAppUtils {
* 跳转apk安装界面
*/
public static void installApk(Context context, String filePath) {
ConfigName.getInstance().Version=serviceVersionCode;
ConfigData.getInstance().SavePZ();

Intent i = new Intent(Intent.ACTION_VIEW);
File file = new File(filePath);
if (file.length() > 0 && file.exists() && file.isFile()) {
@@ -145,4 +166,80 @@ public class UpdateAppUtils {
context.startActivity(i);
}
}

/**
* 如果版本1 大于 版本2 返回true 否则返回fasle 支持 2.2 2.2.1 比较
* 支持不同位数的比较 2.0.0.0.0.1 2.0 对比
*
* @param v1 版本服务器版本 " 1.1.2 "
* @param v2 版本 当前版本 " 1.2.1 "
* @return ture :需要更新 false : 不需要更新
*/
public static boolean compareVersions(String v1, String v2) {
//判断是否为空数据
if (v1.isEmpty() || v2.isEmpty()) {
return false;
}
String[] str1 = v1.split("\\.");
String[] str2 = v2.split("\\.");

if (str1.length == str2.length) {
for (int i = 0; i < str1.length; i++) {
if (Integer.parseInt(str1[i]) > Integer.parseInt(str2[i])) {
return true;
} else if (Integer.parseInt(str1[i]) < Integer.parseInt(str2[i])) {
return false;
} else if (Integer.parseInt(str1[i]) == Integer.parseInt(str2[i])) {

}
}
} else {
if (str1.length > str2.length) {
for (int i = 0; i < str2.length; i++) {
if (Integer.parseInt(str1[i]) > Integer.parseInt(str2[i])) {
return true;
} else if (Integer.parseInt(str1[i]) < Integer.parseInt(str2[i])) {
return false;

} else if (Integer.parseInt(str1[i]) == Integer.parseInt(str2[i])) {
if (str2.length == 1) {
continue;
}
if (i == str2.length - 1) {

for (int j = i; j < str1.length; j++) {
if (Integer.parseInt(str1[j]) != 0) {
return true;
}
if (j == str1.length - 1) {
return false;
}

}
return true;
}
}
}
} else {
for (int i = 0; i < str1.length; i++) {
if (Integer.parseInt(str1[i]) > Integer.parseInt(str2[i])) {
return true;
} else if (Integer.parseInt(str1[i]) < Integer.parseInt(str2[i])) {
return false;

} else if (Integer.parseInt(str1[i]) == Integer.parseInt(str2[i])) {
if (str1.length == 1) {
continue;
}
if (i == str1.length - 1) {
return false;

}
}

}
}
}
return false;
}
}

+ 126
- 1
app/src/main/java/com/bonait/bnframework/modules/mine/fragment/MyFragment.java Ver fichero

@@ -10,6 +10,8 @@ import android.provider.Settings;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;

import android.text.InputType;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
@@ -18,8 +20,13 @@ import android.widget.TextView;
import com.allen.library.SuperTextView;
import com.bonait.bnframework.R;
import com.bonait.bnframework.common.base.BaseFragment;
import com.bonait.bnframework.common.constant.ConfigName;
import com.bonait.bnframework.common.constant.Constants;
import com.bonait.bnframework.common.db.QueryDB;
import com.bonait.bnframework.common.db.mode.BPA_MATERIAL;
import com.bonait.bnframework.common.db.mode.BPA_USER;
import com.bonait.bnframework.common.utils.AlertDialogUtils;
import com.bonait.bnframework.common.utils.ToastUtils;
import com.bonait.bnframework.common.utils.UpdateAppUtils;
import com.bonait.bnframework.manager.ActivityLifecycleManager;
import com.bonait.bnframework.modules.mine.fragment.from.NoticeActivity;
@@ -43,6 +50,10 @@ public class MyFragment extends BaseFragment {
ImageView hHead;
@BindView(R.id.h_user_name)
TextView hUserName;
@BindView(R.id.stv_user_name)
SuperTextView stv_user_name;
@BindView(R.id.stv_user_sign)
SuperTextView stv_user_sign;
@BindView(R.id.stv_change_pwd)
SuperTextView stvChangePwd;
@BindView(R.id.stv_update)
@@ -87,8 +98,18 @@ public class MyFragment extends BaseFragment {

}

private void initData(BPA_USER user)
{
if(user!=null)
{
ConfigName.getInstance().user=user;
hUserName.setText(user.account);
stv_user_name.setRightString(user.name);//名称
stv_user_sign.setRightString(user.exp);//签名
}
}
private void initView() {

initData(ConfigName.getInstance().user);
/*
* 版本更新,点击事件
* */
@@ -118,12 +139,116 @@ public class MyFragment extends BaseFragment {
}
});

/**
* 通知按钮
*/
stvAnnouncement.setOnSuperTextViewClickListener(new SuperTextView.OnSuperTextViewClickListener() {
@Override
public void onClickListener(SuperTextView superTextView) {
skipToNoticeActivity();
}
});
/**
* 用户名点击
*/
stv_user_name.setOnSuperTextViewClickListener(new SuperTextView.OnSuperTextViewClickListener() {
@Override
public void onClickListener(SuperTextView superTextView) {
final QMUIDialog.EditTextDialogBuilder builder = new QMUIDialog.EditTextDialogBuilder(context);
builder.setTitle("用户名修改")
.setPlaceholder("在此输入用户名")
.setDefaultText(ConfigName.getInstance().user.name)
.setInputType(InputType.TYPE_CLASS_TEXT)
.addAction("取消", new QMUIDialogAction.ActionListener() {
@Override
public void onClick(QMUIDialog dialog, int index) {
dialog.dismiss();
}
})
.addAction("确定", new QMUIDialogAction.ActionListener() {
@Override
public void onClick(QMUIDialog dialog, int index) {
CharSequence text = builder.getEditText().getText();
if (text != null && text.length() > 0) {
BPA_USER user= QueryDB.UpdateUserName(ConfigName.getInstance().user.id,text.toString());
initData(user);
dialog.dismiss();
} else {
//请填入昵称
ToastUtils.info("用户名不能为空!");
}
}
})
.show();
}
});
/**
* 签名按钮点击
*/
stv_user_sign.setOnSuperTextViewClickListener(new SuperTextView.OnSuperTextViewClickListener() {
@Override
public void onClickListener(SuperTextView superTextView) {
final QMUIDialog.EditTextDialogBuilder builder = new QMUIDialog.EditTextDialogBuilder(context);
builder.setTitle("个人签名修改")
.setPlaceholder("在此输入签名")
.setDefaultText(ConfigName.getInstance().user.exp)
.setInputType(InputType.TYPE_CLASS_TEXT)
.addAction("取消", new QMUIDialogAction.ActionListener() {
@Override
public void onClick(QMUIDialog dialog, int index) {
dialog.dismiss();
}
})
.addAction("确定", new QMUIDialogAction.ActionListener() {
@Override
public void onClick(QMUIDialog dialog, int index) {
CharSequence text = builder.getEditText().getText();
if (text != null && text.length() > 0) {
BPA_USER user= QueryDB.UpdateUserSign(ConfigName.getInstance().user.id,text.toString());
initData(user);
dialog.dismiss();
} else {
//请填入昵称
ToastUtils.info("签名不能为空!");
}
}
})
.show();
}
});
/**
* 密码修改
*/
stvChangePwd.setOnSuperTextViewClickListener(new SuperTextView.OnSuperTextViewClickListener() {
@Override
public void onClickListener(SuperTextView superTextView) {
final QMUIDialog.EditTextDialogBuilder builder = new QMUIDialog.EditTextDialogBuilder(context);
builder.setTitle("个人密码修改")
.setPlaceholder("在此输入密码")
.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD)
.addAction("取消", new QMUIDialogAction.ActionListener() {
@Override
public void onClick(QMUIDialog dialog, int index) {
dialog.dismiss();
}
})
.addAction("确定", new QMUIDialogAction.ActionListener() {
@Override
public void onClick(QMUIDialog dialog, int index) {
CharSequence text = builder.getEditText().getText();
if (text != null && text.length() > 0) {
BPA_USER user= QueryDB.UpdateUserPass(ConfigName.getInstance().user.id,text.toString());
initData(user);
dialog.dismiss();
} else {
//请填入昵称
ToastUtils.info("密码不能为空!");
}
}
})
.show();
}
});
}
/**
* 跳转登录界面


+ 11
- 11
app/src/main/java/com/bonait/bnframework/modules/mine/fragment/from/NoticeActivity.java Ver fichero

@@ -28,17 +28,17 @@ public class NoticeActivity extends BaseActivity{
initTopBar();
}

@OnClick({R.id.button})
public void onViewClicked(View view) {
switch (view.getId()) {
case R.id.button:
ToastUtils.info("我是信息通知栏");
break;
case R.id.clean_password:
break;
}
}
// @OnClick({R.id.button})
// public void onViewClicked(View view) {
// switch (view.getId()) {
// case R.id.button:
// ToastUtils.info("我是信息通知栏");
// break;
// case R.id.clean_password:
//
// break;
// }
// }

private void initTopBar() {
mTopBar.setTitle("信息通知栏");


+ 16
- 5
app/src/main/java/com/bonait/bnframework/modules/welcome/activity/LoginActivity.java Ver fichero

@@ -26,6 +26,8 @@ import com.bonait.bnframework.common.base.BaseActivity;
import com.bonait.bnframework.common.constant.ConfigName;
import com.bonait.bnframework.common.constant.Constants;
import com.bonait.bnframework.common.constant.SPConstants;
import com.bonait.bnframework.common.db.QueryDB;
import com.bonait.bnframework.common.db.mode.BPA_USER;
import com.bonait.bnframework.common.utils.AlertDialogUtils;
import com.bonait.bnframework.common.utils.AnimationToolUtils;
import com.bonait.bnframework.common.utils.AppUtils;
@@ -179,11 +181,20 @@ public class LoginActivity extends BaseActivity implements Validator.ValidationL
final String password = mEtPassword.getText().toString();
//密码加密
String newPassword = AppUtils.encryptSha256(password);
ConfigName.getInstance().user.account=userAccount;
ConfigName.getInstance().user.pass=password;
ConfigData.getInstance().SavePZ();
//跳转到主页
skipToMainActivity();

BPA_USER user= QueryDB.UserLogin(userAccount,password);
if(user!=null)
{
ConfigName.getInstance().user=user;
ConfigData.getInstance().SavePZ();
//跳转到主页
skipToMainActivity();
}else
{
ToastUtils.warning("账号密码不正确!");
}


// OkGo.<BaseCodeJson<AppLoginPo>>post(url)
// .tag(this)
// .params("username",userAccount)


+ 2
- 76
app/src/main/res/layout/activity_notice.xml Ver fichero

@@ -1,70 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<!--<com.qmuiteam.qmui.widget.QMUIWindowInsetLayout xmlns:android="http://schemas.android.com/apk/res/android"-->
<!-- xmlns:app="http://schemas.android.com/apk/res-auto"-->
<!-- xmlns:tools="http://schemas.android.com/tools"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="match_parent"-->
<!-- tools:context=".modules.mine.fragment.from.NoticeActivity"-->
<!-- android:background="@color/qmui_config_color_white"-->
<!-- android:fitsSystemWindows="true"-->
<!-- android:orientation="vertical">-->
<!-- <ScrollView-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="match_parent"-->
<!-- android:layout_marginTop="?attr/qmui_topbar_height"-->
<!-- android:fillViewport="true"-->
<!-- android:fitsSystemWindows="true">-->

<!-- <LinearLayout-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:gravity="center_horizontal"-->
<!-- android:orientation="vertical"-->
<!-- android:paddingBottom="25dp"-->
<!-- android:paddingTop="70dp">-->

<!-- <ImageView-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:contentDescription="Logo"-->
<!-- android:src="@mipmap/ico"/>-->

<!-- <TextView-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_marginTop="15dp"-->
<!-- android:textColor="?attr/qmui_config_color_gray_3"-->
<!-- android:textSize="16sp"/>-->

<!-- <com.qmuiteam.qmui.widget.grouplist.QMUIGroupListView-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_marginTop="35dp"/>-->

<!-- <Space-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="0dp"-->
<!-- android:layout_weight="1"/>-->

<!-- <TextView-->
<!-- android:id="@+id/copyright"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_marginTop="25dp"-->
<!-- android:gravity="center_horizontal"-->
<!-- android:textColor="?attr/qmui_config_color_gray_7"/>-->
<!-- </LinearLayout>-->

<!-- </ScrollView>-->

<!-- <com.qmuiteam.qmui.widget.QMUITopBarLayout-->
<!-- android:id="@+id/topbar"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:fitsSystemWindows="true"/>-->
<!--</com.qmuiteam.qmui.widget.QMUIWindowInsetLayout>-->


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
@@ -83,18 +17,10 @@ android:orientation="vertical">
android:layout_height="match_parent"
android:background="@color/qmui_config_color_white">
<RelativeLayout style="@style/button_wrapper_style">
<com.qmuiteam.qmui.widget.roundwidget.QMUIRoundButton
android:id="@+id/button"
<com.qmuiteam.qmui.widget.textview.QMUILinkTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:clickable="true"
android:gravity="center"
android:padding="10dp"
android:text="我是信息通知"
android:textColor="@color/qmui_s_link_color"
app:qmui_borderColor="@color/qmui_s_link_color"
app:qmui_borderWidth="1px"/>
android:text="通知信息"/>
</RelativeLayout>
</ScrollView>
</LinearLayout>

+ 1
- 1
app/src/main/res/layout/fragment_my.xml Ver fichero

@@ -28,7 +28,7 @@
android:layout_width="90dp"
android:layout_height="90dp"
android:layout_centerInParent="true"
android:src="@drawable/icon_user_pic" />
android:src="@mipmap/tx1" />

<TextView
android:id="@+id/h_user_name"






Cargando…
Cancelar
Guardar