From f1bfc4e071432d53508a5106fb439a341eeb3ed7 Mon Sep 17 00:00:00 2001 From: Yutousama <583819556@qq.com> Date: Wed, 12 Jun 2019 11:40:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=AD=A3=E5=BC=8F=E4=B8=8A=E7=BA=BF2.2?= =?UTF-8?q?=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/caches/build_file_checksums.ser | Bin 698 -> 698 bytes app/build.gradle | 4 +- app/src/main/AndroidManifest.xml | 1 + .../Adapters/GameDataAdapters/WarAdapter.java | 11 +- .../jianr_mg/Adapters/MainUtilsAdapter.java | 33 +-- .../Adapters/ModListRecyclerAdapter.java | 8 +- .../java/com/yutou/jianr_mg/Application.java | 13 +- .../GameDataFragments/DropFragment.java | 49 ++-- .../GameDataFragments/WarFragment.java | 59 +++-- .../java/com/yutou/jianr_mg/Fragments/My.java | 4 +- .../com/yutou/jianr_mg/LoadingActivity.java | 2 + .../com/yutou/jianr_mg/Network/HttpApi.java | 4 +- .../com/yutou/jianr_mg/Tools/CDNTools.java | 5 +- .../com/yutou/jianr_mg/Tools/JianRUtils.java | 3 +- .../yutou/jianr_mg/views/BaseActivity.java | 4 +- .../yutou/jianr_mg/views/ExcelActivity.java | 1 - .../jianr_mg/views/GameDataActivity.java | 19 +- .../jianr_mg/views/UserDataActivity.java | 231 ++++++++++++++++++ app/src/main/res/layout/activity_userdata.xml | 10 + harmony/build.gradle | 4 +- .../harmony/Activitys/MainActivity.java | 19 ++ .../java/com/yutou/jianr_mg/plugins/Data.java | 4 +- 22 files changed, 383 insertions(+), 105 deletions(-) create mode 100644 app/src/main/java/com/yutou/jianr_mg/views/UserDataActivity.java create mode 100644 app/src/main/res/layout/activity_userdata.xml diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser index 0bad3962109a0b9dc3b5dd593e752bfa695b13e6..b81c2b1ce0313b5371734c4e91188f7dd8726c10 100644 GIT binary patch delta 64 zcmV-G0Kfmb1-b>0m;^>N!?}^1cM#l*@4j}j)F#5WrVMmXsS=YT0i2Wk0Ur>uBJG5= Wse~9i;T$yb7JLJfy#YUyEdq_p>l{}A delta 64 zcmV-G0Kfmb1-b>0m;^u{#K4i9cMz!8Ka7|MtOA|&oW5q2RSlCP0i2WY0X>ty0Ur>~ W3D{qbv@AbdE=9AY7bKsPD*}&+_8P+g diff --git a/app/build.gradle b/app/build.gradle index 0176a1c..245aff2 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -8,7 +8,7 @@ android { minSdkVersion 19 targetSdkVersion 28 versionCode 2 - versionName "2.1" + versionName "2.2" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" ndk { abiFilters "armeabi", "armeabi-v7a", "x86", "mips" @@ -147,4 +147,6 @@ dependencies { implementation 'com.qiniu:qiniu-android-sdk:7.3.15' //zip4j implementation group: 'net.lingala.zip4j', name: 'zip4j', version: '1.3.3' + //卡顿检测 + // implementation 'com.github.markzhai:blockcanary-android:1.5.0' } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 68269ee..da8051e 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -91,6 +91,7 @@ + >> { @Override public void onItemViewClick(List> data) { super.onItemViewClick(data); - // Utils.toast(getContext(),"详细内容正在咕,敬请期待"); - ModUtils utils= ModUtils.init(getContext()); - utils.notRootInstall(new File(Utils.getAppPath()+"/harmony/Cocos2dxPrefsFile.xml"),"../shared_prefs/"); - utils.notRootInstallStart(new ModInterface() { - @Override - public void onAction(boolean flag, int type) { - System.out.println("反和谐结果:"+flag); - } - },false); - + Utils.toast(getContext(),"详细内容正在咕,敬请期待"); /* JSONArray array=new JSONArray(); for (Map datum : data) { try { diff --git a/app/src/main/java/com/yutou/jianr_mg/Adapters/MainUtilsAdapter.java b/app/src/main/java/com/yutou/jianr_mg/Adapters/MainUtilsAdapter.java index a707d8b..5ddd662 100644 --- a/app/src/main/java/com/yutou/jianr_mg/Adapters/MainUtilsAdapter.java +++ b/app/src/main/java/com/yutou/jianr_mg/Adapters/MainUtilsAdapter.java @@ -43,7 +43,10 @@ public class MainUtilsAdapter extends RecyclerAdapter { @Override public void setData(MAppTools data) { super.setData(data); - imageLoader.displayImage(data.getImage(), icon); + if (data.getImage().equals("#")) { + icon.setImageResource(R.mipmap.icon_logo); + } else + imageLoader.displayImage(data.getImage(), icon); name.setText(data.getName()); } @@ -56,14 +59,13 @@ public class MainUtilsAdapter extends RecyclerAdapter { String type = data.getMainFunction().split("#")[1]; String main = data.getMainFunction().split("#")[0]; - try { - Intent intent=null; - if(!type.equals("localActivity")){ + Intent intent = null; + if (!type.equals("localActivity")) { intent = new Intent(getContext(), Application.application.getClassLoader().loadClass(main)); - if(data.getParameter()!=null){ - intent.putExtra("parameter",data.getParameter()); + if (data.getParameter() != null) { + intent.putExtra("parameter", data.getParameter()); } } switch (type) { @@ -74,21 +76,22 @@ public class MainUtilsAdapter extends RecyclerAdapter { getContext().startService(intent); break; case "localActivity": - System.out.println("数据:"+data.toString()); - intent=new Intent(getContext(), BaseActivity.class); - intent.putExtra("activityName",main); - intent.putExtra("jar",data.getUrl().split("/")[data.getUrl().split("/").length-1]); - intent.putExtra("name",data.getName()); - intent.putExtra("url",data.getUrl()); - System.out.println("插件数据:"+data.getUrl().split("/")[data.getUrl().split("/").length-1]); - if(data.getParameter()!=null){ - intent.putExtra("parameter",data.getParameter()); + System.out.println("数据:" + data.toString()); + intent = new Intent(getContext(), BaseActivity.class); + intent.putExtra("activityName", main); + intent.putExtra("jar", data.getUrl().split("/")[data.getUrl().split("/").length - 1]); + intent.putExtra("name", data.getName()); + intent.putExtra("url", data.getUrl()); + System.out.println("插件数据:" + data.getUrl().split("/")[data.getUrl().split("/").length - 1]); + if (data.getParameter() != null) { + intent.putExtra("parameter", data.getParameter()); } getContext().startActivity(intent); break; } } catch (Exception e) { e.printStackTrace(); + Utils.toast(getContext(), "启动失败,请升级至最新版本或联系管理员"); } } } diff --git a/app/src/main/java/com/yutou/jianr_mg/Adapters/ModListRecyclerAdapter.java b/app/src/main/java/com/yutou/jianr_mg/Adapters/ModListRecyclerAdapter.java index eb9464b..5a7da61 100644 --- a/app/src/main/java/com/yutou/jianr_mg/Adapters/ModListRecyclerAdapter.java +++ b/app/src/main/java/com/yutou/jianr_mg/Adapters/ModListRecyclerAdapter.java @@ -54,7 +54,13 @@ public class ModListRecyclerAdapter extends RecyclerAdapter { if (data.getIcon() != null && !"null".equals(data.getIcon())) { String url=data.getIcon(); if(!url.contains("http://")&&!url.contains("https://")){ - url=AppData.appConfig.getDownloadhome() + data.getIcon(); + try { + url=AppData.appConfig.getDownloadhome() + data.getIcon(); + }catch (Exception e){ + e.printStackTrace(); + url="#"; + } + } imageLoader.displayImage(url, icon); }else{ diff --git a/app/src/main/java/com/yutou/jianr_mg/Application.java b/app/src/main/java/com/yutou/jianr_mg/Application.java index 392a58d..6b420be 100644 --- a/app/src/main/java/com/yutou/jianr_mg/Application.java +++ b/app/src/main/java/com/yutou/jianr_mg/Application.java @@ -50,16 +50,15 @@ public class Application extends android.app.Application { public void onCreate() { super.onCreate(); Application.application = this; - // DoraemonKit.install(application); - //UMConfigure.setLogEnabled(true); + // BlockCanary.install(this, new AppBlockCanaryContext()).start(); System.out.println("开始初始化"); init(); initPlugs(); regActivity(); JianRUtils.initShipCardId(); - //initUmeng(); - // initTx(); + initUmeng(); + initTx(); System.out.println("初始化结束"); @@ -121,8 +120,8 @@ public class Application extends android.app.Application { try { Map plugsin = new HashMap<>(); - File path = new File(Utils.getAppPath() + "/plugin/"); - File dex = new File(Application.application.getFilesDir() + "/plugs/"); + File path = new File(Application.application.getFilesDir() + "/plugin/"); + File dex = new File(Application.application.getFilesDir() + "/plugin/"); if (!dex.exists()) { dex.mkdirs(); } @@ -132,7 +131,7 @@ public class Application extends android.app.Application { DexClassLoader dexClassLoader = new DexClassLoader(file.getAbsolutePath(), dex.getAbsolutePath(), null, getClassLoader()); plugsin.put(file.getName(), dexClassLoader); System.out.println("加载插件:"+file.getName()); - AppData.plugsin.put(file.getName(), dexClassLoader); + // AppData.plugsin.put(file.getName(), dexClassLoader); } } } else { diff --git a/app/src/main/java/com/yutou/jianr_mg/Fragments/GameDataFragments/DropFragment.java b/app/src/main/java/com/yutou/jianr_mg/Fragments/GameDataFragments/DropFragment.java index 03079d8..9a33d61 100644 --- a/app/src/main/java/com/yutou/jianr_mg/Fragments/GameDataFragments/DropFragment.java +++ b/app/src/main/java/com/yutou/jianr_mg/Fragments/GameDataFragments/DropFragment.java @@ -14,6 +14,7 @@ import android.widget.AdapterView; import android.widget.ArrayAdapter; import com.yutou.jianr_mg.Adapters.GameDataAdapters.DropAdapter; +import com.yutou.jianr_mg.Data.AppData; import com.yutou.jianr_mg.Databases.JianRDataDataBase; import com.yutou.jianr_mg.R; import com.yutou.jianr_mg.Tools.JianRUtils; @@ -153,26 +154,36 @@ public class DropFragment extends Fragment { if(srcTypes.size()==0){ return; } - String name = database.getNames(srcTypes.get(src.getSelectedIndex())).get(i); - List list = database.getDrops(name); - List> ldata = new ArrayList<>(); - for (JSONObject json : list) { - Map map = new ArrayMap<>(); - String cid = json.get("cid").toString(); - String title = json.getString("title"); - map.put("icon", "http://jianr.jianrmod.cn/jianr/ship/S_NORMAL_" + JianRUtils.jianCidToid(cid) + ".png"); - map.put("name", title); - /* map.put("time", new SimpleDateFormat("yyyy年MM月dd HH:mm:ss") - .format(new Date(Long.valueOf(json.getJSONObject("data").getString("createTime")))));*/ - map.put("time",SimpleDateFormat.getDateTimeInstance(DateFormat.YEAR_FIELD,DateFormat.SHORT).format(new Date(Long.valueOf(json.getJSONObject("data").getString("createTime"))))); - ldata.add(map); + new Thread(() -> { + try { + String name = database.getNames(srcTypes.get(src.getSelectedIndex())).get(i); + List list = database.getDrops(name); + List> ldata = new ArrayList<>(); + for (JSONObject json : list) { + Map map = new ArrayMap<>(); + String cid = json.get("cid").toString(); + String title = json.getString("title"); + map.put("icon", "http://jianr.jianrmod.cn/jianr/ship/S_NORMAL_" + JianRUtils.jianCidToid(cid) + ".png"); + map.put("name", title); + /* map.put("time", new SimpleDateFormat("yyyy年MM月dd HH:mm:ss") + .format(new Date(Long.valueOf(json.getJSONObject("data").getString("createTime")))));*/ + map.put("time",SimpleDateFormat.getDateTimeInstance(DateFormat.YEAR_FIELD,DateFormat.SHORT).format(new Date(Long.valueOf(json.getJSONObject("data").getString("createTime"))))); + ldata.add(map); + + } + Collections.reverse(ldata); + AppData.handler.post(() -> { + adapter.clear(); + adapter.addAll(ldata); + adapter.notifyDataSetChanged(); + recyclerView.showNoMore(); + }); + + }catch (Exception e){ + e.printStackTrace(); + } + }).start(); - } - Collections.reverse(ldata); - adapter.clear(); - adapter.addAll(ldata); - adapter.notifyDataSetChanged(); - recyclerView.showNoMore(); } catch (Exception e) { e.printStackTrace(); } diff --git a/app/src/main/java/com/yutou/jianr_mg/Fragments/GameDataFragments/WarFragment.java b/app/src/main/java/com/yutou/jianr_mg/Fragments/GameDataFragments/WarFragment.java index c090739..c7285ea 100644 --- a/app/src/main/java/com/yutou/jianr_mg/Fragments/GameDataFragments/WarFragment.java +++ b/app/src/main/java/com/yutou/jianr_mg/Fragments/GameDataFragments/WarFragment.java @@ -14,6 +14,7 @@ import android.widget.ArrayAdapter; import com.yutou.jianr_mg.Adapters.GameDataAdapters.DropAdapter; import com.yutou.jianr_mg.Adapters.GameDataAdapters.WarAdapter; +import com.yutou.jianr_mg.Data.AppData; import com.yutou.jianr_mg.Databases.JianRDataDataBase; import com.yutou.jianr_mg.R; import com.yutou.jianr_mg.Tools.Utils; @@ -58,7 +59,9 @@ public class WarFragment extends Fragment { } view = inflater.inflate(R.layout.fragment_drop, null); data = new ArrayList<>(); - + if(srcList==null){ + srcList = new ArrayList<>(); + } System.out.println("当前模式下的战斗数据:" + srcList.size()); initView(); return view; @@ -146,30 +149,40 @@ public class WarFragment extends Fragment { private void initData() { try { data.clear(); - srcList = database.getDataList(database.getTNameId((String) typeAdapter.getItem(type.getSelectedIndex()))); - for (int i = 0; i < srcList.size(); i++) { - Map maps = srcList.get(i); - JSONObject item = maps.get("data"); - if(maps.get("DealNode").getString("time").contains("2430")){ - System.out.println("此时正是430"); - } - if (item == null) { - return; - } - if(item.getInt("mapId")==999202){ - System.out.println("找到活动地图"); - } - if(Objects.requireNonNull(maps.get("DealNode")).getString("type").equals("DealNode")) { - if (item.getInt("mapId") % 10 == 2) { - getItem(i, srcList); + new Thread(() -> { + try { + srcList = database.getDataList(database.getTNameId((String) typeAdapter.getItem(type.getSelectedIndex()))); + for (int i = 0; i < srcList.size(); i++) { + Map maps = srcList.get(i); + JSONObject item = maps.get("data"); + if(maps.get("DealNode").getString("time").contains("2430")){ + System.out.println("此时正是430"); + } + if (item == null) { + return; + } + if(item.getInt("mapId")==999202){ + System.out.println("找到活动地图"); + } + if(Objects.requireNonNull(maps.get("DealNode")).getString("type").equals("DealNode")) { + if (item.getInt("mapId") % 10 == 2) { + getItem(i, srcList); + } + } } + AppData.handler.post(() -> { + adapter.clear(); + adapter.addAll(data); + adapter.notifyDataSetChanged(); + recyclerView.dismissSwipeRefresh(); + recyclerView.showNoMore(); + }); + + }catch (Exception e){ + e.printStackTrace(); } - } - adapter.clear(); - adapter.addAll(data); - adapter.notifyDataSetChanged(); - recyclerView.dismissSwipeRefresh(); - recyclerView.showNoMore(); + }).start(); + } catch (Exception e) { e.printStackTrace(); } diff --git a/app/src/main/java/com/yutou/jianr_mg/Fragments/My.java b/app/src/main/java/com/yutou/jianr_mg/Fragments/My.java index 1f928cd..9f68cb7 100644 --- a/app/src/main/java/com/yutou/jianr_mg/Fragments/My.java +++ b/app/src/main/java/com/yutou/jianr_mg/Fragments/My.java @@ -2,6 +2,7 @@ package com.yutou.jianr_mg.Fragments; import android.app.Activity; import android.content.Context; +import android.content.Intent; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; @@ -25,6 +26,7 @@ import com.yutou.jianr_mg.Network.HttpApi; import com.yutou.jianr_mg.R; import com.yutou.jianr_mg.Tools.Log; import com.yutou.jianr_mg.Tools.Utils; +import com.yutou.jianr_mg.views.UserDataActivity; import java.util.ArrayList; @@ -71,7 +73,7 @@ public class My extends Fragment { credit=view.findViewById(R.id.credit); } icon.setOnClickListener(view->{ - Utils.toast(getContext(),"个人资料...咕了!诶嘿(<ゝω·)~☆kira"); + startActivity(new Intent(getContext(), UserDataActivity.class)); }); image_top.setOnClickListener(view->Utils.toast(getContext(),"点这里不会有什么奇怪的东西啦")); imageLoader= Utils.initImageLoader(getContext()); diff --git a/app/src/main/java/com/yutou/jianr_mg/LoadingActivity.java b/app/src/main/java/com/yutou/jianr_mg/LoadingActivity.java index 78dc5fb..954966b 100644 --- a/app/src/main/java/com/yutou/jianr_mg/LoadingActivity.java +++ b/app/src/main/java/com/yutou/jianr_mg/LoadingActivity.java @@ -225,6 +225,7 @@ public class LoadingActivity extends AppCompatActivity { public void httpGetData(String string, int code) { try { JSONObject json = new JSONObject(string); + final String msg = json.getString("msg"); Log.i("LOGIN", "登录状态:" + string); if (json.getInt("code") == 100) { JSONObject data = json.getJSONObject("data").getJSONObject("data"); @@ -233,6 +234,7 @@ public class LoadingActivity extends AppCompatActivity { ConfigUtils.init().save(ConfigUtils.collection, data.getJSONArray("collection")); isLogin = true; } else { + handler.post(() -> Utils.toast(LoadingActivity.this, msg)); isLogin = false; } } catch (Exception e) { diff --git a/app/src/main/java/com/yutou/jianr_mg/Network/HttpApi.java b/app/src/main/java/com/yutou/jianr_mg/Network/HttpApi.java index 06c81f1..6602fd1 100644 --- a/app/src/main/java/com/yutou/jianr_mg/Network/HttpApi.java +++ b/app/src/main/java/com/yutou/jianr_mg/Network/HttpApi.java @@ -8,7 +8,7 @@ public class HttpApi { public static final String HOME="http://jianr.jianrmod.cn/"; // public static final String HOME = "http://192.168.31.240:8088/"; //zzz_gz wifi //public static final String HOME = "http://192.168.137.1:8088/"; //笔记本本身WIFI -// public static final String HOME = "http://192.168.1.84:8088/"; //公司 + // public static final String HOME = "http://192.168.1.84:8088/"; //公司 public static final String HOME_URL=HOME+"android/"; //服务器 public static final String MOD_ALL = "mod/all.do"; @@ -38,6 +38,8 @@ public class HttpApi { public static final String USER_RELOAD = "user/reload.do"; public static final String USER_LOGOUT = "user/logout.do"; public static final String USER_TEST = "user/test.do"; + public static final String USER_UPIMG = "user/img.do"; + public static final String USER_UPDATE = "user/update.do"; public static final String SYSTEM_UP_INFO = "system/addFeedBack.do"; public static final String SYSTEM_LICENSE = "system/license.do"; diff --git a/app/src/main/java/com/yutou/jianr_mg/Tools/CDNTools.java b/app/src/main/java/com/yutou/jianr_mg/Tools/CDNTools.java index fd658ea..c0eb7b3 100644 --- a/app/src/main/java/com/yutou/jianr_mg/Tools/CDNTools.java +++ b/app/src/main/java/com/yutou/jianr_mg/Tools/CDNTools.java @@ -39,13 +39,14 @@ public class CDNTools { uploadManager = new UploadManager(config); } - public void upload(File file,String token){ + public void upload(File file,String path,String token){ hud=Utils.showLoading(context,"正在上传","请稍后"); hud.show(); Map map=new HashMap<>(); map.put("x:uToken",AppData.Token); map.put("x:uuid",AppData.user.getId()+""); - uploadManager.put(file, AppData.user.getId()+"/gamedata/"+file.getName(), token, (key, info, response) -> { + map.put("x:qToken",token); + uploadManager.put(file, path, token, (key, info, response) -> { if(info.isOK()){ Log.i(cdn.getClass().getName(),key+"上传成功"); Utils.toast(Application.application,"上传完成"); diff --git a/app/src/main/java/com/yutou/jianr_mg/Tools/JianRUtils.java b/app/src/main/java/com/yutou/jianr_mg/Tools/JianRUtils.java index 1168a96..f97d233 100644 --- a/app/src/main/java/com/yutou/jianr_mg/Tools/JianRUtils.java +++ b/app/src/main/java/com/yutou/jianr_mg/Tools/JianRUtils.java @@ -179,7 +179,7 @@ public class JianRUtils { } private static List jianNiangs; private static List equipmnts; - public static List reloadJianNiang() { + public static void reloadJianNiang() { try { if(jianNiangs==null){ jianNiangs=new ArrayList<>(); @@ -195,7 +195,6 @@ public class JianRUtils { e.printStackTrace(); getInit(); } - return jianNiangs; } public static List reloadEquipmnts() { try { diff --git a/app/src/main/java/com/yutou/jianr_mg/views/BaseActivity.java b/app/src/main/java/com/yutou/jianr_mg/views/BaseActivity.java index 5d0b1db..13e01a4 100644 --- a/app/src/main/java/com/yutou/jianr_mg/views/BaseActivity.java +++ b/app/src/main/java/com/yutou/jianr_mg/views/BaseActivity.java @@ -15,6 +15,7 @@ import com.yutou.jianr_mg.Data.AppData; import com.yutou.jianr_mg.Interfaces.DownloadFileInerface; import com.yutou.jianr_mg.Network.HttpUtils; import com.yutou.jianr_mg.R; +import com.yutou.jianr_mg.Tools.Log; import com.yutou.jianr_mg.Tools.Utils; import Interfaces.BaseActivityInterface; @@ -52,7 +53,8 @@ public class BaseActivity extends AppCompatActivity { dialog.setMessage("这可能是一个插件,但您未安装该插件,请问是否进行下载安装操作?"); dialog.setNegativeButton("取消",view ->{dialog.dismiss();finish();}); dialog.setPositiveButton("确定",view -> { - HttpUtils.downloadFile(url, Utils.getAppPath() + "/plugin/", new DownloadFileInerface() { + Log.i("插件管理","下载插件:"+url); + HttpUtils.downloadFile(url, Application.application.getFilesDir() + "/plugin/", new DownloadFileInerface() { @Override public boolean downloading(String fileName, int current, long length) { return true; diff --git a/app/src/main/java/com/yutou/jianr_mg/views/ExcelActivity.java b/app/src/main/java/com/yutou/jianr_mg/views/ExcelActivity.java index 0ba9c95..5351dc5 100644 --- a/app/src/main/java/com/yutou/jianr_mg/views/ExcelActivity.java +++ b/app/src/main/java/com/yutou/jianr_mg/views/ExcelActivity.java @@ -34,7 +34,6 @@ public class ExcelActivity extends AppCompatActivity { protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_excel); - Intent intent = getIntent(); hud = Utils.showLoading(this, "请稍后", "文件正在下载中"); diff --git a/app/src/main/java/com/yutou/jianr_mg/views/GameDataActivity.java b/app/src/main/java/com/yutou/jianr_mg/views/GameDataActivity.java index 571ffd9..f95e6c3 100644 --- a/app/src/main/java/com/yutou/jianr_mg/views/GameDataActivity.java +++ b/app/src/main/java/com/yutou/jianr_mg/views/GameDataActivity.java @@ -139,7 +139,8 @@ public class GameDataActivity extends AppCompatActivity implements View.OnClickL upDialog.setTitle("上传数据"); upDialog.setMessage("本次预计消耗积分:" + credit); upDialog.setPositiveButton("确定", v1 -> { - CDNTools.getInstance(GameDataActivity.this).upload(new File("/data/data/" + getPackageName() + "/databases/game_data_db"), token); + File file=new File("/data/data/" + getPackageName() + "/databases/game_data_db"); + CDNTools.getInstance(GameDataActivity.this).upload(file, AppData.user.getId()+"/gamedata/"+file.getName(),token); upDialog.dismiss(); }); upDialog.setNegativeButton("取消", v1 -> { @@ -238,20 +239,4 @@ public class GameDataActivity extends AppCompatActivity implements View.OnClickL break; } } - - @Override - protected void onActivityResult(int requestCode, int resultCode, Intent data) { - super.onActivityResult(requestCode, resultCode, data); - if (resultCode == RESULT_OK) { - if (requestCode == 100) { - //如果是文件选择模式,需要获取选择的所有文件的路径集合 - List list = data.getStringArrayListExtra("paths"); - Toast.makeText(getApplicationContext(), "选中了" + list.size() + "个文件", Toast.LENGTH_SHORT).show(); - File file = new File(list.get(0)); - if (file.exists() && !StringUtil.isEmpty(token)) { - CDNTools.getInstance(this).upload(file, token); - } - } - } - } } diff --git a/app/src/main/java/com/yutou/jianr_mg/views/UserDataActivity.java b/app/src/main/java/com/yutou/jianr_mg/views/UserDataActivity.java new file mode 100644 index 0000000..7e478ea --- /dev/null +++ b/app/src/main/java/com/yutou/jianr_mg/views/UserDataActivity.java @@ -0,0 +1,231 @@ +package com.yutou.jianr_mg.views; + +import android.content.Intent; +import android.net.Uri; +import android.os.Bundle; +import android.os.Environment; +import android.support.annotation.Nullable; +import android.support.v7.app.AppCompatActivity; +import android.text.InputType; +import android.widget.ArrayAdapter; +import android.widget.EditText; +import android.widget.ImageView; +import android.widget.ListView; +import android.widget.Toast; + +import com.leon.lfilepickerlibrary.LFilePicker; +import com.nostra13.universalimageloader.core.ImageLoader; +import com.yutou.jianr_mg.Data.AppData; +import com.yutou.jianr_mg.Interfaces.HttpInterface; +import com.yutou.jianr_mg.Network.HttpApi; +import com.yutou.jianr_mg.Network.HttpUtils; +import com.yutou.jianr_mg.R; +import com.yutou.jianr_mg.Tools.ActivitysManager; +import com.yutou.jianr_mg.Tools.CDNTools; +import com.yutou.jianr_mg.Tools.Utils; + +import org.json.JSONException; +import org.json.JSONObject; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +import me.drakeet.materialdialog.MaterialDialog; + +public class UserDataActivity extends AppCompatActivity { + private ListView listView; + private ArrayAdapter adapter; + @Override + protected void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_userdata); + adapter=new ArrayAdapter<>(this,android.R.layout.simple_list_item_1,getData()); + listView=findViewById(R.id.list); + listView.setAdapter(adapter); + listView.setOnItemClickListener((parent, view, position, id) -> { + switch (position){ + case 1: + upUname(); + break; + case 2: + upEmail(); + break; + case 3: + upImg(); + break; + case 4: + logout(); + break; + } + }); + } + private List getData(){ + List list=new ArrayList<>(); + list.add("UID:"+ AppData.userdata.getUid()); + list.add("昵称:"+AppData.user.getUname()); + list.add("绑定邮箱:"+AppData.userdata.getEmail()); + list.add("更换头像"); + list.add("注销登录"); + return list; + } + private void upUname(){ + MaterialDialog dialog=new MaterialDialog(this); + dialog.setTitle("更换昵称"); + EditText editText=new EditText(this); + editText.setHint("请输入昵称"); + dialog.setContentView(editText); + dialog.setPositiveButton("提交",v -> { + String uname=editText.getText().toString(); + if(!Utils.testStringIsNull(uname)){ + try { + JSONObject json=new JSONObject(); + json.put("uname",uname); + HttpUtils.post(HttpApi.HOME_URL+HttpApi.USER_UPDATE,json,null); + AppData.user.setUname(uname); + Utils.toast(UserDataActivity.this,"更新成功"); + adapter.clear(); + adapter.addAll(getData()); + adapter.notifyDataSetChanged(); + }catch (Exception e){ + e.printStackTrace(); + } + } + dialog.dismiss(); + }); + dialog.setNegativeButton("取消",v -> dialog.dismiss()); + dialog.show(); + } + private void upEmail(){ + MaterialDialog dialog=new MaterialDialog(this); + dialog.setTitle("更换Email"); + EditText editText=new EditText(this); + editText.setHint("请输入Email"); + editText.setInputType(InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS); + dialog.setContentView(editText); + dialog.setPositiveButton("提交",v -> { + String email=editText.getText().toString(); + if(!Utils.testStringIsNull(email)){ + try { + JSONObject json=new JSONObject(); + json.put("email",email); + HttpUtils.post(HttpApi.HOME_URL+HttpApi.USER_UPDATE,json,null); + AppData.userdata.setEmail(email); + Utils.toast(UserDataActivity.this,"更新成功"); + adapter.clear(); + adapter.addAll(getData()); + adapter.notifyDataSetChanged(); + }catch (Exception e){ + e.printStackTrace(); + } + } + dialog.dismiss(); + }); + dialog.setNegativeButton("取消",v -> dialog.dismiss()); + dialog.show(); + } + private String token; + private void upImg(){ + try{ + JSONObject json=new JSONObject(); + HttpUtils.post(HttpApi.HOME_URL + HttpApi.USER_UPIMG, json, new HttpInterface() { + @Override + public void httpGetData(String string, int code) { + try { + JSONObject json=new JSONObject(string); + token=json.optString("token"); + AppData.handler.post(()->{ + new LFilePicker() + .withActivity(UserDataActivity.this) + .withRequestCode(100) + .withStartPath(Environment.getExternalStorageDirectory().getPath()+"/jianRMG")//指定初始显示路径 + .withIsGreater(false)//过滤文件大小 小于指定大小的文件 + .withMutilyMode(false) + .withFileSize(5*1024*1024)//指定文件大小为500K + .start(); + Utils.toast(UserDataActivity.this,"请选择头像"); + }); + } catch (JSONException e) { + e.printStackTrace(); + } + } + + @Override + public void httpError(Exception e) { + + } + }); + }catch (Exception e){ + e.printStackTrace(); + } + + } + private void logout(){ + MaterialDialog dialog=new MaterialDialog(this); + dialog.setTitle("退出?"); + dialog.setMessage("注销账号并退出登录"); + dialog.setPositiveButton("提交",v -> { + try { + JSONObject json=new JSONObject(); + HttpUtils.post(HttpApi.HOME_URL + HttpApi.USER_LOGOUT, json, new HttpInterface() { + @Override + public void httpGetData(String string, int code) { + AppData.handler.post(()->{ + ActivitysManager.finishAllActivity(); + System.exit(0); + }); + + } + + @Override + public void httpError(Exception e) { + + } + }); + }catch (Exception e){ + e.printStackTrace(); + } + dialog.dismiss(); + + }); + dialog.setNegativeButton("取消",v -> dialog.dismiss()); + dialog.show(); + } + @Override + protected void onActivityResult(int requestCode, int resultCode, Intent data) { + super.onActivityResult(requestCode, resultCode, data); + if (resultCode == RESULT_OK) { + if (requestCode == 100) { + //如果是文件选择模式,需要获取选择的所有文件的路径集合 + List list = data.getStringArrayListExtra("paths"); + File file=new File(list.get(0)); + if(file.exists()){ + showImgDialog(file); + } + } + } + } + private void showImgDialog(File file){ + MaterialDialog dialog=new MaterialDialog(this); + dialog.setTitle("更换头像"); + ImageView imageView=new ImageView(this); + imageView.setImageURI(Uri.fromFile(file)); + dialog.setContentView(imageView); + imageView.setOnClickListener(v -> { + dialog.dismiss(); + upImg(); + }); + dialog.setPositiveButton("提交",v -> { + try { + CDNTools.getInstance(UserDataActivity.this) + .upload(file,AppData.user.getId()+"/img/"+file.getName(),token); + }catch (Exception e){ + e.printStackTrace(); + } + dialog.dismiss(); + + }); + dialog.setNegativeButton("取消",v -> dialog.dismiss()); + dialog.show(); + } +} diff --git a/app/src/main/res/layout/activity_userdata.xml b/app/src/main/res/layout/activity_userdata.xml new file mode 100644 index 0000000..2f4f411 --- /dev/null +++ b/app/src/main/res/layout/activity_userdata.xml @@ -0,0 +1,10 @@ + + + + + \ No newline at end of file diff --git a/harmony/build.gradle b/harmony/build.gradle index a396209..bd1b918 100644 --- a/harmony/build.gradle +++ b/harmony/build.gradle @@ -34,6 +34,6 @@ dependencies { implementation 'com.leon:lfilepickerlibrary:1.8.0' //载入界面 implementation 'com.kaopiz:kprogresshud:1.1.0' - compile 'com.android.support:support-v4:28.0.0' - compile 'com.android.support:recyclerview-v7:28.0.0' + implementation 'com.android.support:support-v4:28.0.0' + implementation 'com.android.support:recyclerview-v7:28.0.0' } diff --git a/harmony/src/main/java/com/jianrmod/plugins/harmony/Activitys/MainActivity.java b/harmony/src/main/java/com/jianrmod/plugins/harmony/Activitys/MainActivity.java index b2adff6..5f297af 100644 --- a/harmony/src/main/java/com/jianrmod/plugins/harmony/Activitys/MainActivity.java +++ b/harmony/src/main/java/com/jianrmod/plugins/harmony/Activitys/MainActivity.java @@ -2,6 +2,7 @@ package com.jianrmod.plugins.harmony.Activitys; import android.content.Context; import android.content.Intent; +import android.net.Uri; import android.os.Bundle; import android.os.Handler; import android.os.Looper; @@ -97,11 +98,13 @@ public class MainActivity implements BaseActivityInterface { TextView text1 = new TextView(context); Button button = new Button(context); Button button2 = new Button(context); + Button button3=new Button(context); final Switch siwtch = new Switch(context); siwtch.setText("共存版"); text1.setText("请将proj.manifest、Cocos2dxPrefsFile.xml和压缩包放到jianRMG/harmony/文件夹中"); button.setText("创建harmony文件夹"); button2.setText("开始"); + button3.setText("不会用?点这里"); siwtch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override @@ -118,6 +121,7 @@ public class MainActivity implements BaseActivityInterface { linearLayout.addView(button); linearLayout.addView(button2); linearLayout.addView(siwtch); + linearLayout.addView(button3); button.setOnClickListener(new View.OnClickListener() { @Override @@ -126,6 +130,7 @@ public class MainActivity implements BaseActivityInterface { if (file.exists()) { Utils.toast(context, "文件夹已存在"); } else { + Utils.toast(context,"已创建harmony文件夹,请将下载好的文件放入到harmony目录中"); file.mkdirs(); } } @@ -135,6 +140,11 @@ public class MainActivity implements BaseActivityInterface { public void onClick(View v) { hud.show(); final File file = new File(Utils.getAppPath() + "/harmony/"); + if(!file.exists()){ + Utils.toast(context,"已创建harmony文件夹,请将下载好的文件放入到harmony目录中"); + file.mkdirs(); + return; + } if (file.listFiles().length == 0) { Utils.toast(context, "文件夹内为空,请放入harmony文件夹中"); return; @@ -186,6 +196,15 @@ public class MainActivity implements BaseActivityInterface { } }); + button3.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent intent = new Intent(); + intent.setAction(Intent.ACTION_VIEW); + intent.setData(Uri.parse("http://bbs.jianrmod.cn/forum.php?mod=viewthread&tid=186&extra=")); + context.startActivity(intent); + } + }); return linearLayout; } diff --git a/harmony/src/main/java/com/yutou/jianr_mg/plugins/Data.java b/harmony/src/main/java/com/yutou/jianr_mg/plugins/Data.java index 75e40b8..26ef81b 100644 --- a/harmony/src/main/java/com/yutou/jianr_mg/plugins/Data.java +++ b/harmony/src/main/java/com/yutou/jianr_mg/plugins/Data.java @@ -5,8 +5,8 @@ public class Data { public static String title="专用客户端解卡/反和谐"; public static String appId="48B9C440405E442EBE6F5512DE585DBB"; public static String url="http://aaa/harmony.jar"; - public static String image="#"; + public static String image="https://i.loli.net/2019/06/10/5cfe1f8f725b430506.png"; public static String mainFunction="com.jianrmod.plugins.harmony.Activitys.MainActivity#localActivity"; public static Integer permission=0; - public static String version="1.0"; + public static String version="2.0"; }