android完成1.0版本

This commit is contained in:
kerwincui
2021-07-02 22:10:52 +08:00
parent e0e9d0d42d
commit bb4a4addde
16 changed files with 112 additions and 58 deletions

View File

@@ -1 +0,0 @@
#### 集成了XUI、XUtil、XAOP、XPage、XUpdate、XHttp2、ESPTouch

View File

@@ -267,3 +267,10 @@
}
-keep class com.xuexiang.xui.widget.edittext.materialedittext.** { *; }
## 接口请求使用了gson序列化的对象
-keep class com.kerwin.wumei.entity.** { *; }
-keep class com.kerwin.wumei.entity.vo.** { *; }
-keep class com.kerwin.wumei.entity.bo.** { *; }
-keep class com.kerwin.wumei.http.request.** { *; }
-keep class com.kerwin.wumei.http.** { *; }

View File

@@ -14,6 +14,9 @@
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<application
android:name="com.kerwin.wumei.MyApp"

View File

@@ -16,11 +16,13 @@ import androidx.multidex.MultiDex;
import com.kerwin.wumei.http.interceptor.CustomLoggingInterceptor;
import com.kerwin.wumei.utils.SettingSPUtils;
import com.kerwin.wumei.utils.XToastUtils;
import com.kerwin.wumei.utils.sdkinit.ANRWatchDogInit;
import com.kerwin.wumei.utils.sdkinit.UMengInit;
import com.kerwin.wumei.utils.sdkinit.XBasicLibInit;
import com.kerwin.wumei.utils.sdkinit.XUpdateInit;
import com.xuexiang.xhttp2.XHttpSDK;
import com.xuexiang.xrouter.launcher.XRouter;
import static com.kerwin.wumei.utils.SettingUtils.getServeUrl;
@@ -101,18 +103,28 @@ public class MyApp extends Application {
//ANR监控
ANRWatchDogInit.init();
// initXRouter();
}
private void initHttp() {
XHttpSDK.init(this); //初始化网络请求框架,必须首先执行
XHttpSDK.setSuccessCode(200);
XHttpSDK.debug(); //需要调试的时候执行
XHttpSDK.debug(new CustomLoggingInterceptor()); //设置自定义的日志打印拦截器
// XHttpSDK.debug(); //需要调试的时候执行
// XHttpSDK.debug(new CustomLoggingInterceptor()); //设置自定义的日志打印拦截器
XHttpSDK.setBaseUrl(getServeUrl()); //设置网络请求的基础地址
// XHttpSDK.addInterceptor(new CustomDynamicInterceptor()); //设置动态参数添加拦截器
// XHttpSDK.addInterceptor(new CustomExpiredInterceptor()); //请求失效校验拦截器
}
private void initXRouter() {
if (BuildConfig.DEBUG) { // 这两行必须写在init之前否则这些配置在init过程中将无效
XRouter.openLog(); // 打印日志
XRouter.openDebug(); // 开启调试模式(如果在InstantRun模式下运行必须开启调试模式线上版本需要关闭,否则有安全风险)
}
XRouter.init(this);
}
/**
* @return 当前app是否是调试开发模式

View File

@@ -54,6 +54,7 @@ import java.util.List;
import butterknife.BindView;
import butterknife.OnClick;
import static com.kerwin.wumei.utils.SettingUtils.getServeUrl;
import static com.kerwin.wumei.utils.TokenUtils.clearToken;
import static com.kerwin.wumei.utils.TokenUtils.getToken;
import static com.kerwin.wumei.utils.TokenUtils.hasToken;
@@ -130,11 +131,11 @@ public class LoginFragment extends BaseFragment {
getCatpureImage();
break;
case R.id.btn_login:
if (etPhoneNumber.validate()) {
if (etVerifyCode.validate()) {
if(etPhoneNumber.getEditValue().length()==0 || etPassword.getEditValue().length()==0 || etVerifyCode.getEditValue().length()==0){
XToastUtils.error("请正确填写账号、密码和验证码");
}else {
loginByVerifyCode(etPhoneNumber.getEditValue(), etPassword.getEditValue(), etVerifyCode.getEditValue());
}
}
break;
default:
break;
@@ -176,6 +177,10 @@ public class LoginFragment extends BaseFragment {
Bitmap bitmap = BitmapFactory.decodeByteArray(decode, 0, decode.length);
imgVertifyCode.setImageBitmap(bitmap);
}
@Override
public void onError(ApiException e) {
XToastUtils.error(e.getMessage());
}
}){});
}
@@ -198,6 +203,7 @@ public class LoginFragment extends BaseFragment {
@Override
public void onError(ApiException e) {
clearToken();
XToastUtils.error(e.getMessage());
}
}){});
}

View File

@@ -37,8 +37,10 @@ import butterknife.OnClick;
import static com.kerwin.wumei.utils.SettingUtils.getApIp;
import static com.kerwin.wumei.utils.SettingUtils.getIsHttps;
import static com.kerwin.wumei.utils.SettingUtils.getServeUrl;
import static com.kerwin.wumei.utils.SettingUtils.getServerPort;
import static com.kerwin.wumei.utils.SettingUtils.getServerip;
import static com.kerwin.wumei.utils.SettingUtils.setAccount;
import static com.kerwin.wumei.utils.SettingUtils.setApIp;
import static com.kerwin.wumei.utils.SettingUtils.setServeUrl;
import static com.kerwin.wumei.utils.TokenUtils.clearToken;
@@ -108,10 +110,15 @@ public class SceneFragment extends BaseFragment {
case R.id.btn_save_serve:
setServeUrl(et_serve_ip.getEditValue(),et_port.getEditValue(),sb_https.isChecked());
clearToken();
setAccount("","");
showMessage("服务端地址信息存储成功请重新启动APP",true);
break;
case R.id.btn_connect_test:
if(et_serve_ip.getEditValue().length()==0 ||et_port.getEditValue().length()==0) {
showMessage("地址和端口不能为空",false);
}else {
getCatpureImage();
}
break;
case R.id.btn_open_ap:
if(et_ap_address.getEditValue()==null || et_ap_address.getEditValue().length()==0){
@@ -126,11 +133,9 @@ public class SceneFragment extends BaseFragment {
}
private String buildServeString(){
String address="";
String address="http://";
if(sb_https.isChecked()){
address="https://";
}else{
address="http://";
}
return address+et_serve_ip.getEditValue()+":"+et_port.getEditValue();
}

View File

@@ -19,6 +19,7 @@ import android.widget.FrameLayout;
import androidx.annotation.NonNull;
import androidx.appcompat.widget.AppCompatImageView;
import androidx.cardview.widget.CardView;
import androidx.fragment.app.FragmentActivity;
import androidx.recyclerview.widget.RecyclerView;
@@ -57,7 +58,6 @@ import me.samlss.broccoli.Broccoli;
import static com.kerwin.wumei.utils.TokenUtils.clearToken;
import static com.kerwin.wumei.utils.TokenUtils.getToken;
import static com.kerwin.wumei.utils.TokenUtils.hasToken;
import static com.xuexiang.xutil.display.DensityUtils.dip2px;
@Page(name = "设备")
public class SimpleTabFragment extends BaseFragment {
@@ -163,42 +163,43 @@ public class SimpleTabFragment extends BaseFragment {
holder.text(R.id.device_item_temp, device.getDeviceTemperature()+"");
holder.text(R.id.device_item_category, device.getCategoryName());
//图标设置状态
//状态图标
SwitchIconView radarView=holder.findViewById(R.id.device_item_radar_icon);
SwitchIconView alarmView=holder.findViewById(R.id.device_item_alarm_icon);
SwitchIconView switchIconView=holder.findViewById(R.id.device_item_switch_button);
SwitchIconView lightIconView=holder.findViewById(R.id.device_item_light_button);
if(device.getIsRadar()!=1){ radarView.setIconEnabled(false);}
if(device.getIsAlarm()!=1){ alarmView.setIconEnabled(false);}
switchIconView.setIconEnabled(device.getRelayStatus()==1?true:false);
lightIconView.setIconEnabled(device.getLightStatus()==1?true:false);
//根据分类显示图标
AppCompatImageView stateView=holder.findViewById(R.id.device_item_category_icon);
stateView.setImageDrawable(getResources().getDrawable((R.drawable.category)));
radarView.setIconEnabled(device.getIsRadar()==1 && device.getIsOnline()==1?true:false);
alarmView.setIconEnabled(device.getIsAlarm()==1 && device.getIsOnline()==1?true:false);
switchIconView.setIconEnabled(device.getRelayStatus()==1 && device.getIsOnline()==1?true:false);
lightIconView.setIconEnabled(device.getLightStatus()==1 && device.getIsOnline()==1?true:false);
//显示网络信号wifi信号强度(信号极好4格[-55—— 0]信号好3格[-70—— -55信号一般2格[-85—— -70信号差1格[-100—— -85)
AppCompatImageView wifiView=holder.findViewById(R.id.device_item_wifi_icon);
if(device.getRssi()>=-55){
if(device.getIsOnline()==1 && device.getRssi()>=-55){
wifiView.setImageDrawable(getResources().getDrawable((R.drawable.wifi_4)));
}else if(device.getRssi()>=70){
}else if(device.getIsOnline()==1 && device.getRssi()>=70){
wifiView.setImageDrawable(getResources().getDrawable((R.drawable.wifi_3)));
}else if(device.getRssi()>=-85){
}else if(device.getIsOnline()==1 && device.getRssi()>=-85){
wifiView.setImageDrawable(getResources().getDrawable((R.drawable.wifi_2)));
}else if(device.getRssi()>=-100){
}else if(device.getIsOnline()==1 && device.getRssi()>=-100){
wifiView.setImageDrawable(getResources().getDrawable((R.drawable.wifi_1)));
}else{
wifiView.setImageDrawable(getResources().getDrawable((R.drawable.wifi_0)));
}
//设置状态
//其他文字、标题和图片
FrameLayout flTitle=holder.findViewById(R.id.device_item_fl_title);
if(device.getIsOnline()==1){
holder.text(R.id.device_item_wifi, "在线");
flTitle.setBackgroundColor(Color.argb(255, 201, 243, 218));
flTitle.setBackgroundColor(Color.argb(255, 63, 208, 173));
}else{
holder.text(R.id.device_item_wifi, "离线");
flTitle.setBackgroundColor(Color.argb(255, 230, 230, 230));
flTitle.setBackgroundColor(Color.argb(255, 220, 220, 220));
//显示图标
AppCompatImageView categoryIcon=holder.findViewById(R.id.device_item_category_icon);
AppCompatImageView temp=holder.findViewById(R.id.device_item_temp_icon);
categoryIcon.setColorFilter(Color.parseColor("#909399"));
temp.setColorFilter(Color.parseColor("#909399"));
}
holder.click(R.id.device_item_light_button, v -> {

View File

@@ -45,6 +45,9 @@ import java.util.Locale;
import butterknife.BindView;
import static com.kerwin.wumei.utils.SettingUtils.getServerPort;
import static com.kerwin.wumei.utils.SettingUtils.getServerip;
@Page(anim = CoreAnim.none)
public class ProfileFragment extends BaseFragment implements SuperTextView.OnSuperTextViewClickListener {
@BindView(R.id.riv_head_pic)
@@ -53,8 +56,8 @@ public class ProfileFragment extends BaseFragment implements SuperTextView.OnSup
SuperTextView menuMessage;
@BindView(R.id.menu_logout)
SuperTextView menuLogout;
@BindView(R.id.about_list)
XUIGroupListView mAboutGroupListView;
@BindView(R.id.control_list)
XUIGroupListView mControlGroupListView;
@BindView(R.id.tv_copyright)
TextView mCopyrightTextView;
@BindView(R.id.menu_account)
@@ -83,11 +86,28 @@ public class ProfileFragment extends BaseFragment implements SuperTextView.OnSup
*/
@Override
protected void initViews() {
if(getServerip()!=null && getServerip().length()>0){
String address="http://"+getServerip();
String control=address;
String emqx=address+":18083";
if(getServerPort()!=null && getServerPort().length()>0){
control=address+":"+getServerPort();
}
String finalControl = control;
String finalEmqx=emqx;
XUIGroupListView.newSection(getContext())
.addItemView(mAboutGroupListView.createItemView(getResources().getString(R.string.about_item_author_github)), v -> AgentWebActivity.goWeb(getContext(), getString(R.string.url_author_github)))
.addItemView(mAboutGroupListView.createItemView(getResources().getString(R.string.about_item_add_qq_group)), v -> AgentWebActivity.goWeb(getContext(), getString(R.string.url_add_qq_group)))
.addItemView(mAboutGroupListView.createItemView("版本v"+AppUtils.getAppVersionName()), v -> XToastUtils.toast("官网下载最新版本"))
.addTo(mAboutGroupListView);
.addItemView(mControlGroupListView.createItemView("打开管理控制台"), v -> AgentWebActivity.goWeb(getContext(), finalControl))
.addItemView(mControlGroupListView.createItemView("打开EMQX控制台"), v -> AgentWebActivity.goWeb(getContext(), finalEmqx))
.addItemView(mControlGroupListView.createItemView(getResources().getString(R.string.about_item_add_qq_group)), v -> AgentWebActivity.goWeb(getContext(), getString(R.string.url_add_qq_group)))
.addItemView(mControlGroupListView.createItemView("应用版本 - V" + AppUtils.getAppVersionName()), v -> XToastUtils.toast("官网下载最新版本"))
.addTo(mControlGroupListView);
}else {
XUIGroupListView.newSection(getContext())
.addItemView(mControlGroupListView.createItemView(getResources().getString(R.string.about_item_add_qq_group)), v -> AgentWebActivity.goWeb(getContext(), getString(R.string.url_add_qq_group)))
.addItemView(mControlGroupListView.createItemView("应用版本 - V" + AppUtils.getAppVersionName()), v -> XToastUtils.toast("官网下载最新版本"))
.addTo(mControlGroupListView);
}
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy", Locale.CHINA);
String currentYear = dateFormat.format(new Date());

View File

@@ -73,11 +73,9 @@ public final class SettingUtils {
* 获取服务端地址
*/
public static String getServeUrl(){
String address="";
if(getIsHttps()){
String address="http://";
if(getIsHttps()==true){
address="https://";
}else{
address="http://";
}
address=address+getServerip()+":"+getServerPort();
return address;
@@ -120,7 +118,7 @@ public final class SettingUtils {
* @return
*/
public static String getServerip(){
return MMKVUtils.getString(SERVERIP,"");
return MMKVUtils.getString(SERVERIP,"wumei.live");
}
/**
@@ -128,7 +126,7 @@ public final class SettingUtils {
* @return
*/
public static String getServerPort(){
return MMKVUtils.getString(SERVERPORT,"");
return MMKVUtils.getString(SERVERPORT,"88");
}
/**

View File

@@ -39,14 +39,16 @@
android:layout_marginTop="10dp"
android:layout_marginEnd="5dp"
android:layout_marginRight="5dp"
android:background="#C9F3DA">
android:background="@color/colorAccent"
android:paddingTop="2dp"
android:paddingBottom="2dp">
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/update_device_temp_icon"
android:layout_width="@dimen/config_margin_14dp"
android:layout_height="@dimen/config_margin_14dp"
android:layout_gravity="start|center_vertical"
android:layout_marginTop="2dp"
android:layout_marginTop="0dp"
android:tint="@color/white"
app:srcCompat="@drawable/title" />
@@ -58,10 +60,10 @@
android:ellipsize="end"
android:gravity="center_vertical"
android:maxLines="1"
android:paddingTop="3dp"
android:paddingTop="0dp"
android:singleLine="true"
android:text="智能报警灯"
android:textColor="@color/xui_config_color_pure_black"
android:textColor="@color/toast_default_text_color"
android:textSize="14sp" />
</FrameLayout>

View File

@@ -216,7 +216,7 @@
android:layout_marginBottom="40dp"
android:text="返 回"
app:sCornersRadius="5dp"
app:sSolidColor="@color/app_color_theme_2" />
app:sSolidColor="@color/app_color_theme_5" />
<com.xuexiang.xui.widget.textview.supertextview.SuperButton
android:id="@+id/btn_save"

View File

@@ -45,7 +45,7 @@
android:layout_height="wrap_content"
android:layout_marginStart="70dp"
app:swb_textOff="关"
app:swb_textOn="开" />
app:swb_textOn="开" />
<TextView
android:id="@+id/textView2"
@@ -62,7 +62,7 @@
android:layout_height="wrap_content"
android:layout_marginStart="200dp"
app:swb_textOff="关"
app:swb_textOn="开" />
app:swb_textOn="开" />
</FrameLayout>
@@ -223,7 +223,7 @@
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="以下是特殊功能,建议独立使用"
android:textColor="@color/danger" />
android:textColor="@color/colorAccent" />
<FrameLayout
android:layout_width="match_parent"
@@ -313,9 +313,9 @@
android:layout_height="35dp"
android:layout_marginTop="40dp"
android:layout_marginBottom="40dp"
android:text="取 消"
android:text="返 回"
app:sCornersRadius="5dp"
app:sSolidColor="@color/app_color_theme_2" />
app:sSolidColor="@color/app_color_theme_5" />
<com.xuexiang.xui.widget.textview.supertextview.SuperButton
android:id="@+id/btn_apply_set"

View File

@@ -358,15 +358,16 @@
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.xuexiang.xui.widget.textview.supertextview.SuperButton
android:id="@+id/btn_cancle_status"
android:layout_width="100dp"
android:layout_height="35dp"
android:layout_marginTop="40dp"
android:layout_marginBottom="40dp"
android:text="取消"
android:text="返 回"
app:sCornersRadius="5dp"
app:sSolidColor="@color/app_color_theme_2" />
app:sSolidColor="@color/app_color_theme_5" />
<com.xuexiang.xui.widget.textview.supertextview.SuperButton
android:id="@+id/btn_apply_status"

View File

@@ -50,13 +50,13 @@
style="@style/InfoItem.Account"
app:sLeftTextString="消息" />
<com.xuexiang.xui.widget.grouplist.XUIGroupListView
android:id="@+id/about_list"
android:id="@+id/control_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="0dp" />
<Space
android:layout_width="match_parent"
android:layout_height="0dp"

View File

@@ -187,7 +187,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="需要设备支持并启动AP手机连接设备wifi热点"
android:textColor="@color/danger"
android:textColor="@color/colorAccent"
android:textSize="12sp" />
<FrameLayout

View File

@@ -8,7 +8,7 @@
<string name="navigation_drawer_close">Close navigation drawer</string>
<string name="menu_device">设备</string>
<string name="menu_news">官网</string>
<string name="menu_news">文档</string>
<string name="menu_scene">配置</string>
<string name="menu_add_device">添加</string>
<string name="menu_profile">我的</string>
@@ -26,7 +26,7 @@
<string name="about_copyright">© %1$s wumei-smart All rights reserved.</string>
<string name="about_item_homepage">访问官网</string>
<string name="about_item_author_github">访问源码</string>
<string name="about_item_add_qq_group">加入QQ群</string>
<string name="about_item_add_qq_group">加入QQ交流</string>
<string name="url_project_github">http://wumei.live</string>
<string name="url_author_github">https://gitee.com/kerwincui/wumei-smart</string>
<string name="url_add_qq_group">https://qm.qq.com/cgi-bin/qm/qr?k=P_oc91N6KC39zp2PEV_-BY3xMnAokeZ8</string>