diff --git a/app/build.gradle b/app/build.gradle index 9e8094fa..f1c88eed 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -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 diff --git a/app/src/main/java/com/bonait/bnframework/business/ConfigData.java b/app/src/main/java/com/bonait/bnframework/business/ConfigData.java index 9068bf18..5a280c0e 100644 --- a/app/src/main/java/com/bonait/bnframework/business/ConfigData.java +++ b/app/src/main/java/com/bonait/bnframework/business/ConfigData.java @@ -241,7 +241,7 @@ public class ConfigData { } /** - * 更新版本 + * 更新版本检测 */ public void UpdateVersion() { diff --git a/app/src/main/java/com/bonait/bnframework/common/constant/ConfigName.java b/app/src/main/java/com/bonait/bnframework/common/constant/ConfigName.java index ff4a9803..9f0a001a 100644 --- a/app/src/main/java/com/bonait/bnframework/common/constant/ConfigName.java +++ b/app/src/main/java/com/bonait/bnframework/common/constant/ConfigName.java @@ -98,7 +98,7 @@ public class ConfigName { //region 版本信息 /** - * 版本更新 + * 版本更新,当前版本 */ public String Version="1.0"; //endregion diff --git a/app/src/main/java/com/bonait/bnframework/common/db/QueryDB.java b/app/src/main/java/com/bonait/bnframework/common/db/QueryDB.java index 4cad7432..44f39217 100644 --- a/app/src/main/java/com/bonait/bnframework/common/db/QueryDB.java +++ b/app/src/main/java/com/bonait/bnframework/common/db/QueryDB.java @@ -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 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 菜单表 diff --git a/app/src/main/java/com/bonait/bnframework/common/utils/UpdateAppUtils.java b/app/src/main/java/com/bonait/bnframework/common/utils/UpdateAppUtils.java index 4ed6c4cf..899028f5 100644 --- a/app/src/main/java/com/bonait/bnframework/common/utils/UpdateAppUtils.java +++ b/app/src/main/java/com/bonait/bnframework/common/utils/UpdateAppUtils.java @@ -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.post(getNewVersionUrl) + VersionMode mode=new VersionMode(); + mode.productCode="1668085292913659904"; + mode.moduleCode="naichaji"; + mode.serverCode="1668175205545807872"; + mode.branchCode="1668801915890962433"; + String msg= new Json().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.post(getNewVersionUrl) .tag(context) - .execute(new JsonDialogCallback(context) { + .upRequestBody(body) + .execute(new JsonDialogCallback(context) { @Override - public void onSuccess(Response response) { - UpdateAppPo updateAppPo = response.body(); - if (updateAppPo != null) { - serviceVersionCode = updateAppPo.getVersion(); - description = updateAppPo.getDescription(); - serviceApkId = updateAppPo.getApkId(); + public void onSuccess(Response 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; + } } diff --git a/app/src/main/java/com/bonait/bnframework/modules/mine/fragment/MyFragment.java b/app/src/main/java/com/bonait/bnframework/modules/mine/fragment/MyFragment.java index 57bb185d..cc2f68ee 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/mine/fragment/MyFragment.java +++ b/app/src/main/java/com/bonait/bnframework/modules/mine/fragment/MyFragment.java @@ -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(); + } + }); } /** * 跳转登录界面 diff --git a/app/src/main/java/com/bonait/bnframework/modules/mine/fragment/from/NoticeActivity.java b/app/src/main/java/com/bonait/bnframework/modules/mine/fragment/from/NoticeActivity.java index 094ac651..5f191250 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/mine/fragment/from/NoticeActivity.java +++ b/app/src/main/java/com/bonait/bnframework/modules/mine/fragment/from/NoticeActivity.java @@ -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("信息通知栏"); diff --git a/app/src/main/java/com/bonait/bnframework/modules/welcome/activity/LoginActivity.java b/app/src/main/java/com/bonait/bnframework/modules/welcome/activity/LoginActivity.java index 1c8fbd1b..ed81eb49 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/welcome/activity/LoginActivity.java +++ b/app/src/main/java/com/bonait/bnframework/modules/welcome/activity/LoginActivity.java @@ -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.>post(url) // .tag(this) // .params("username",userAccount) diff --git a/app/src/main/res/layout/activity_notice.xml b/app/src/main/res/layout/activity_notice.xml index 9f8efe87..a1cdf58d 100644 --- a/app/src/main/res/layout/activity_notice.xml +++ b/app/src/main/res/layout/activity_notice.xml @@ -1,70 +1,4 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - android:layout_height="match_parent" android:background="@color/qmui_config_color_white"> - + android:text="通知信息"/> \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_my.xml b/app/src/main/res/layout/fragment_my.xml index b84068cb..78c46716 100644 --- a/app/src/main/res/layout/fragment_my.xml +++ b/app/src/main/res/layout/fragment_my.xml @@ -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" />