Commit cdde8627 authored by fallenstardust's avatar fallenstardust

发送版本号和下载地址供更新直达

parent 0167d4a0
...@@ -156,7 +156,7 @@ public interface Constants { ...@@ -156,7 +156,7 @@ public interface Constants {
String URL_DONATE = "https://afdian.net/@ygomobile"; String URL_DONATE = "https://afdian.net/@ygomobile";
String URL_MASTER_RULE_CN = "https://ocg-rule.readthedocs.io/"; String URL_MASTER_RULE_CN = "https://ocg-rule.readthedocs.io/";
String WIKI_SEARCH_URL = "https://ygocdb.com/card/"; String WIKI_SEARCH_URL = "https://ygocdb.com/card/";
String URL_HOME_VERSION = "https://ygomobile.top/version.txt"; String URL_HOME_VERSION = "https://ygomobile.top/verndwnload.txt";
String URL_YGO233_DOWNLOAD_LINK = "https://ygo233.com/download/ygomobile"; String URL_YGO233_DOWNLOAD_LINK = "https://ygo233.com/download/ygomobile";
String URL_YGO233_ADVANCE = "https://ygo233.com/pre"; String URL_YGO233_ADVANCE = "https://ygo233.com/pre";
String URL_YGO233_DATAVER = "https://ygo233.com/pre/dataver"; String URL_YGO233_DATAVER = "https://ygo233.com/pre/dataver";
......
...@@ -47,6 +47,7 @@ public abstract class HomeActivity extends BaseActivity implements BottomNavigat ...@@ -47,6 +47,7 @@ public abstract class HomeActivity extends BaseActivity implements BottomNavigat
long exitLasttime = 0; long exitLasttime = 0;
public static String Version; public static String Version;
public static String Cache_link;
private static final int TYPE_GET_VERSION_OK = 0; private static final int TYPE_GET_VERSION_OK = 0;
private static final int TYPE_GET_VERSION_FAILED = 1; private static final int TYPE_GET_VERSION_FAILED = 1;
...@@ -71,15 +72,16 @@ public abstract class HomeActivity extends BaseActivity implements BottomNavigat ...@@ -71,15 +72,16 @@ public abstract class HomeActivity extends BaseActivity implements BottomNavigat
super.handleMessage(msg); super.handleMessage(msg);
switch (msg.what) { switch (msg.what) {
case TYPE_GET_VERSION_OK: case TYPE_GET_VERSION_OK:
Version = msg.obj.toString(); Version = msg.obj.toString().substring(0, msg.obj.toString().indexOf("|"));//截取版本号
Log.i(BuildConfig.VERSION_NAME, Version); Cache_link = msg.obj.toString().substring(msg.obj.toString().indexOf("|") + 1);
if (!Version.equals(BuildConfig.VERSION_NAME) && !Version.isEmpty()) { Log.i(BuildConfig.VERSION_NAME, Version + "和" + Cache_link);
if (!Version.equals(BuildConfig.VERSION_NAME) && !Version.isEmpty() && !Cache_link.isEmpty()) {
DialogPlus dialog = new DialogPlus(getActivity()); DialogPlus dialog = new DialogPlus(getActivity());
dialog.setMessage(R.string.Found_Update); dialog.setMessage(R.string.Found_Update);
dialog.setLeftButtonText(R.string.download_home); dialog.setLeftButtonText(R.string.download_home);
dialog.setLeftButtonListener((dlg, s) -> { dialog.setLeftButtonListener((dlg, s) -> {
Intent intent = new Intent(Intent.ACTION_VIEW); Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("https://netdisk.link/YGOMobile_" + Version + ".apk/links")); intent.setData(Uri.parse(Cache_link));
startActivity(intent); startActivity(intent);
dialog.dismiss(); dialog.dismiss();
}); });
...@@ -174,7 +176,7 @@ public abstract class HomeActivity extends BaseActivity implements BottomNavigat ...@@ -174,7 +176,7 @@ public abstract class HomeActivity extends BaseActivity implements BottomNavigat
private void showNewsCounts() { private void showNewsCounts() {
mTextBadgeItem = new TextBadgeItem() mTextBadgeItem = new TextBadgeItem()
.setBorderWidth(4)//文本大小 .setBorderWidth(4)//文本大小
.setGravity(Gravity.LEFT )//位置 默认右上 .setGravity(Gravity.LEFT)//位置 默认右上
.setBackgroundColorResource(R.color.holo_orange_bright)//背景颜色 .setBackgroundColorResource(R.color.holo_orange_bright)//背景颜色
.setAnimationDuration(200)//动画时间 .setAnimationDuration(200)//动画时间
.setText("3") .setText("3")
...@@ -356,12 +358,12 @@ public abstract class HomeActivity extends BaseActivity implements BottomNavigat ...@@ -356,12 +358,12 @@ public abstract class HomeActivity extends BaseActivity implements BottomNavigat
message.what = TYPE_GET_VERSION_FAILED; message.what = TYPE_GET_VERSION_FAILED;
message.obj = e; message.obj = e;
handlerHome.sendMessage(message); handlerHome.sendMessage(message);
Log.i(BuildConfig.VERSION_NAME, "error" + e);
} }
@Override @Override
public void onResponse(Call call, Response response) throws IOException { public void onResponse(Call call, Response response) throws IOException {
String json = response.body().string(); String json = response.body().string();
Log.i(BuildConfig.VERSION_NAME, json);
Message message = new Message(); Message message = new Message();
message.what = TYPE_GET_VERSION_OK; message.what = TYPE_GET_VERSION_OK;
message.obj = json; message.obj = json;
......
...@@ -93,6 +93,7 @@ public class SettingFragment extends PreferenceFragmentPlus { ...@@ -93,6 +93,7 @@ public class SettingFragment extends PreferenceFragmentPlus {
private static final int TYPE_SETTING_GET_VERSION_FAILED = 1; private static final int TYPE_SETTING_GET_VERSION_FAILED = 1;
private AppsSettings mSettings; private AppsSettings mSettings;
public static String Version; public static String Version;
public static String Cache_link;
private boolean isInit = true; private boolean isInit = true;
public SettingFragment() { public SettingFragment() {
...@@ -106,15 +107,16 @@ public class SettingFragment extends PreferenceFragmentPlus { ...@@ -106,15 +107,16 @@ public class SettingFragment extends PreferenceFragmentPlus {
super.handleMessage(msg); super.handleMessage(msg);
switch (msg.what) { switch (msg.what) {
case TYPE_SETTING_GET_VERSION_OK: case TYPE_SETTING_GET_VERSION_OK:
Version = msg.obj.toString(); Version = msg.obj.toString().substring(0, msg.obj.toString().indexOf("|"));//截取版本号
Log.i(BuildConfig.VERSION_NAME, Version); Cache_link = msg.obj.toString().substring(msg.obj.toString().indexOf("|") + 1);
if (!Version.equals(BuildConfig.VERSION_NAME) && !Version.isEmpty()) { Log.i(BuildConfig.VERSION_NAME, Version + "和" + Cache_link);
DialogPlus dialog = new DialogPlus(getContext()); if (!Version.equals(BuildConfig.VERSION_NAME) && !Version.isEmpty() && !Cache_link.isEmpty()) {
DialogPlus dialog = new DialogPlus(getActivity());
dialog.setMessage(R.string.Found_Update); dialog.setMessage(R.string.Found_Update);
dialog.setLeftButtonText(R.string.download_home); dialog.setLeftButtonText(R.string.download_home);
dialog.setLeftButtonListener((dlg, s) -> { dialog.setLeftButtonListener((dlg, s) -> {
Intent intent = new Intent(Intent.ACTION_VIEW); Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("https://netdisk.link/YGOMobile_" + Version + ".apk/links")); intent.setData(Uri.parse(Cache_link));
startActivity(intent); startActivity(intent);
dialog.dismiss(); dialog.dismiss();
}); });
...@@ -134,7 +136,7 @@ public class SettingFragment extends PreferenceFragmentPlus { ...@@ -134,7 +136,7 @@ public class SettingFragment extends PreferenceFragmentPlus {
@Override @Override
protected SharedPreferences getSharedPreferences() { protected SharedPreferences getSharedPreferences() {
return mSettings.getSharedPreferences(); return AppsSettings.get().getSharedPreferences();
} }
@Override @Override
...@@ -250,7 +252,6 @@ public class SettingFragment extends PreferenceFragmentPlus { ...@@ -250,7 +252,6 @@ public class SettingFragment extends PreferenceFragmentPlus {
} }
} }
mSettings.setDataLanguage(Integer.valueOf(listPreference.getValue())); mSettings.setDataLanguage(Integer.valueOf(listPreference.getValue()));
Log.i(BuildConfig.VERSION_NAME, mSettings.getDataLanguage() + preference.getKey() + listPreference.getValue());
Toast.makeText(getContext(), R.string.restart_app, Toast.LENGTH_LONG).show(); Toast.makeText(getContext(), R.string.restart_app, Toast.LENGTH_LONG).show();
DataManager.get().load(true); DataManager.get().load(true);
} }
...@@ -287,12 +288,12 @@ public class SettingFragment extends PreferenceFragmentPlus { ...@@ -287,12 +288,12 @@ public class SettingFragment extends PreferenceFragmentPlus {
message.what = TYPE_SETTING_GET_VERSION_FAILED; message.what = TYPE_SETTING_GET_VERSION_FAILED;
message.obj = e; message.obj = e;
handler.sendMessage(message); handler.sendMessage(message);
Log.i(BuildConfig.VERSION_NAME, "error" + e);
} }
@Override @Override
public void onResponse(Call call, Response response) throws IOException { public void onResponse(Call call, Response response) throws IOException {
String json = response.body().string(); String json = response.body().string();
Log.i(BuildConfig.VERSION_NAME, json);
Message message = new Message(); Message message = new Message();
message.what = TYPE_SETTING_GET_VERSION_OK; message.what = TYPE_SETTING_GET_VERSION_OK;
message.obj = json; message.obj = json;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment