Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
YGOMobile
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fallenstardust
YGOMobile
Commits
75f4e4f3
Commit
75f4e4f3
authored
Sep 24, 2023
by
fallenstardust
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加备选检查更新路线
parent
e03e80e9
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
82 additions
and
62 deletions
+82
-62
mobile/src/main/java/cn/garymb/ygomobile/Constants.java
mobile/src/main/java/cn/garymb/ygomobile/Constants.java
+1
-0
mobile/src/main/java/cn/garymb/ygomobile/ui/activities/WebActivity.java
...n/java/cn/garymb/ygomobile/ui/activities/WebActivity.java
+0
-2
mobile/src/main/java/cn/garymb/ygomobile/ui/home/HomeActivity.java
...c/main/java/cn/garymb/ygomobile/ui/home/HomeActivity.java
+11
-3
mobile/src/main/java/cn/garymb/ygomobile/ui/settings/SettingFragment.java
...java/cn/garymb/ygomobile/ui/settings/SettingFragment.java
+69
-56
mobile/src/main/res/values-zh/strings.xml
mobile/src/main/res/values-zh/strings.xml
+1
-1
No files found.
mobile/src/main/java/cn/garymb/ygomobile/Constants.java
View file @
75f4e4f3
...
...
@@ -157,6 +157,7 @@ public interface Constants {
String
URL_MASTER_RULE_CN
=
"https://ocg-rule.readthedocs.io/"
;
String
WIKI_SEARCH_URL
=
"https://ygocdb.com/card/"
;
String
URL_HOME_VERSION
=
"https://ygomobile.top/version.txt"
;
String
URL_HOME_VERSION_ALT
=
"https://ygom.top/version.txt"
;
String
URL_YGO233_DOWNLOAD_LINK
=
"https://ygo233.com/download/ygomobile"
;
String
URL_YGO233_ADVANCE
=
"https://ygo233.com/pre"
;
String
URL_YGO233_DATAVER
=
"https://ygo233.com/pre/dataver"
;
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/activities/WebActivity.java
View file @
75f4e4f3
...
...
@@ -67,7 +67,6 @@ public class WebActivity extends BaseActivity implements View.OnClickListener {
private
EditText
et_context_keyword
;
private
ImageButton
btn_context_search_close
,
btn_context_search_last
,
btn_context_search_next
;
private
Button
btn_download
;
private
File
xmlFile
;
private
int
FailedCount
;
@SuppressLint
(
"HandlerLeak"
)
Handler
handler
=
new
Handler
()
{
...
...
@@ -129,7 +128,6 @@ public class WebActivity extends BaseActivity implements View.OnClickListener {
mWebViewPlus
=
$
(
R
.
id
.
webbrowser
);
find_in_page
=
$
(
R
.
id
.
find_in_page
);
et_context_keyword
=
$
(
R
.
id
.
context_keyword
);
xmlFile
=
new
File
(
this
.
getFilesDir
(),
Constants
.
SERVER_FILE
);
initButton
();
//mWebViewPlus.enableHtml5();
mWebViewPlus
.
setWebChromeClient
(
new
DefWebChromeClient
()
{
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/home/HomeActivity.java
View file @
75f4e4f3
package
cn.garymb.ygomobile.ui.home
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
URL_HOME_VERSION
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
URL_HOME_VERSION_ALT
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
URL_YGO233_FILE_ALT
;
import
android.annotation.SuppressLint
;
import
android.content.Intent
;
...
...
@@ -82,6 +84,7 @@ public abstract class HomeActivity extends BaseActivity implements BottomNavigat
public
SettingFragment
fragment_settings
;
public
MycardChatFragment
fragment_mycard_chatting_room
;
private
Bundle
mBundle
;
private
int
FailedCount
;
@SuppressLint
(
"HandlerLeak"
)
Handler
handlerHome
=
new
Handler
()
{
...
...
@@ -110,6 +113,11 @@ public abstract class HomeActivity extends BaseActivity implements BottomNavigat
}
break
;
case
TYPE_GET_VERSION_FAILED:
++
FailedCount
;
if
(
FailedCount
<=
2
)
{
Toast
.
makeText
(
getActivity
(),
R
.
string
.
Ask_to_Change_Other_Way
,
Toast
.
LENGTH_SHORT
).
show
();
checkUpgrade
(
URL_HOME_VERSION_ALT
);
}
String
error
=
msg
.
obj
.
toString
();
break
;
}
...
...
@@ -132,7 +140,7 @@ public abstract class HomeActivity extends BaseActivity implements BottomNavigat
initQbSdk
();
//
checkNotch
();
checkUpgrade
();
checkUpgrade
(
URL_HOME_VERSION
);
//showNewbieGuide("homePage");
initBottomNavigationBar
();
onNewIntent
(
getIntent
());
...
...
@@ -393,8 +401,8 @@ public abstract class HomeActivity extends BaseActivity implements BottomNavigat
protected
abstract
void
openGame
();
public
void
checkUpgrade
()
{
OkhttpUtil
.
get
(
URL_HOME_VERSION
,
new
Callback
()
{
public
void
checkUpgrade
(
String
url
)
{
OkhttpUtil
.
get
(
url
,
new
Callback
()
{
@Override
public
void
onFailure
(
Call
call
,
IOException
e
)
{
Message
message
=
new
Message
();
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/settings/SettingFragment.java
View file @
75f4e4f3
...
...
@@ -35,6 +35,7 @@ import static cn.garymb.ygomobile.Constants.SETTINGS_AVATAR;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
SETTINGS_CARD_BG
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
SETTINGS_COVER
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
URL_HOME_VERSION
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
URL_YGO233_FILE_ALT
;
import
static
cn
.
garymb
.
ygomobile
.
ui
.
home
.
HomeActivity
.
Cache_pre_release_code
;
import
static
cn
.
garymb
.
ygomobile
.
ui
.
home
.
HomeActivity
.
pre_code_list
;
import
static
cn
.
garymb
.
ygomobile
.
ui
.
home
.
HomeActivity
.
released_code_list
;
...
...
@@ -101,53 +102,16 @@ import okhttp3.Response;
public
class
SettingFragment
extends
PreferenceFragmentPlus
{
private
static
final
int
TYPE_SETTING_GET_VERSION_OK
=
0
;
private
static
final
int
TYPE_SETTING_GET_VERSION_FAILED
=
1
;
private
AppsSettings
mSettings
;
public
static
String
Version
;
public
static
String
Cache_link
;
private
AppsSettings
mSettings
;
private
boolean
isInit
=
true
;
private
int
FailedCount
;
public
SettingFragment
()
{
}
@SuppressLint
(
"HandlerLeak"
)
Handler
handler
=
new
Handler
()
{
@Override
public
void
handleMessage
(
Message
msg
)
{
super
.
handleMessage
(
msg
);
switch
(
msg
.
what
)
{
case
TYPE_SETTING_GET_VERSION_OK:
Version
=
msg
.
obj
.
toString
().
substring
(
0
,
msg
.
obj
.
toString
().
indexOf
(
"|"
));
//截取版本号
Cache_link
=
msg
.
obj
.
toString
().
substring
(
msg
.
obj
.
toString
().
indexOf
(
"|"
)
+
1
);
Cache_link
=
msg
.
obj
.
toString
().
substring
(
msg
.
obj
.
toString
().
indexOf
(
"|"
)
+
1
,
msg
.
obj
.
toString
().
indexOf
(
"\n"
));
//截取下载地址
Cache_pre_release_code
=
msg
.
obj
.
toString
().
substring
(
msg
.
obj
.
toString
().
indexOf
(
"\n"
)
+
1
);
//截取先行-正式对照文本
if
(!
Cache_pre_release_code
.
isEmpty
())
{
arrangeCodeList
(
Cache_pre_release_code
);
//转换成两个数组
}
if
(!
Version
.
equals
(
BuildConfig
.
VERSION_NAME
)
&&
!
Version
.
isEmpty
()
&&
!
Cache_link
.
isEmpty
())
{
DialogPlus
dialog
=
new
DialogPlus
(
getActivity
());
dialog
.
setMessage
(
R
.
string
.
Found_Update
);
dialog
.
setLeftButtonText
(
R
.
string
.
download_home
);
dialog
.
setLeftButtonListener
((
dlg
,
s
)
->
{
Intent
intent
=
new
Intent
(
Intent
.
ACTION_VIEW
);
intent
.
setData
(
Uri
.
parse
(
Cache_link
));
startActivity
(
intent
);
dialog
.
dismiss
();
});
dialog
.
show
();
}
else
{
Toast
.
makeText
(
getContext
(),
R
.
string
.
Already_Lastest
,
Toast
.
LENGTH_SHORT
).
show
();
}
break
;
case
TYPE_SETTING_GET_VERSION_FAILED:
String
error
=
msg
.
obj
.
toString
();
Toast
.
makeText
(
getContext
(),
getString
(
R
.
string
.
Checking_Update_Failed
)
+
error
,
Toast
.
LENGTH_SHORT
).
show
();
break
;
}
}
};
@Override
protected
SharedPreferences
getSharedPreferences
()
{
return
AppsSettings
.
get
().
getSharedPreferences
();
...
...
@@ -196,6 +160,50 @@ public class SettingFragment extends PreferenceFragmentPlus {
isInit
=
false
;
}
@SuppressLint
(
"HandlerLeak"
)
Handler
handler
=
new
Handler
()
{
@Override
public
void
handleMessage
(
Message
msg
)
{
super
.
handleMessage
(
msg
);
switch
(
msg
.
what
)
{
case
TYPE_SETTING_GET_VERSION_OK:
Version
=
msg
.
obj
.
toString
().
substring
(
0
,
msg
.
obj
.
toString
().
indexOf
(
"|"
));
//截取版本号
Cache_link
=
msg
.
obj
.
toString
().
substring
(
msg
.
obj
.
toString
().
indexOf
(
"|"
)
+
1
);
Cache_link
=
msg
.
obj
.
toString
().
substring
(
msg
.
obj
.
toString
().
indexOf
(
"|"
)
+
1
,
msg
.
obj
.
toString
().
indexOf
(
"\n"
));
//截取下载地址
Cache_pre_release_code
=
msg
.
obj
.
toString
().
substring
(
msg
.
obj
.
toString
().
indexOf
(
"\n"
)
+
1
);
//截取先行-正式对照文本
if
(!
Cache_pre_release_code
.
isEmpty
())
{
arrangeCodeList
(
Cache_pre_release_code
);
//转换成两个数组
}
if
(!
Version
.
equals
(
BuildConfig
.
VERSION_NAME
)
&&
!
Version
.
isEmpty
()
&&
!
Cache_link
.
isEmpty
())
{
DialogPlus
dialog
=
new
DialogPlus
(
getActivity
());
dialog
.
setMessage
(
R
.
string
.
Found_Update
);
dialog
.
setLeftButtonText
(
R
.
string
.
download_home
);
dialog
.
setLeftButtonListener
((
dlg
,
s
)
->
{
Intent
intent
=
new
Intent
(
Intent
.
ACTION_VIEW
);
intent
.
setData
(
Uri
.
parse
(
Cache_link
));
startActivity
(
intent
);
dialog
.
dismiss
();
});
dialog
.
show
();
}
else
{
Toast
.
makeText
(
getContext
(),
R
.
string
.
Already_Lastest
,
Toast
.
LENGTH_SHORT
).
show
();
}
break
;
case
TYPE_SETTING_GET_VERSION_FAILED:
String
error
=
msg
.
obj
.
toString
();
++
FailedCount
;
if
(
FailedCount
<=
2
)
{
Toast
.
makeText
(
getActivity
(),
R
.
string
.
Ask_to_Change_Other_Way
,
Toast
.
LENGTH_SHORT
).
show
();
checkUpgrade
(
URL_YGO233_FILE_ALT
);
}
else
{
Toast
.
makeText
(
getContext
(),
getString
(
R
.
string
.
Checking_Update_Failed
)
+
error
,
Toast
.
LENGTH_SHORT
).
show
();
}
break
;
}
}
};
@Override
public
boolean
onPreferenceChange
(
Preference
preference
,
Object
value
)
{
super
.
onPreferenceChange
(
preference
,
value
);
...
...
@@ -298,24 +306,8 @@ public class SettingFragment extends PreferenceFragmentPlus {
joinQQGroup
(
groupkey
);
}
if
(
PREF_CHECK_UPDATE
.
equals
(
key
))
{
OkhttpUtil
.
get
(
URL_HOME_VERSION
,
new
Callback
()
{
@Override
public
void
onFailure
(
Call
call
,
IOException
e
)
{
Message
message
=
new
Message
();
message
.
what
=
TYPE_SETTING_GET_VERSION_FAILED
;
message
.
obj
=
e
;
handler
.
sendMessage
(
message
);
}
checkUpgrade
(
URL_HOME_VERSION
);
@Override
public
void
onResponse
(
Call
call
,
Response
response
)
throws
IOException
{
String
json
=
response
.
body
().
string
();
Message
message
=
new
Message
();
message
.
what
=
TYPE_SETTING_GET_VERSION_OK
;
message
.
obj
=
json
;
handler
.
sendMessage
(
message
);
}
});
}
if
(
PREF_DEL_EX
.
equals
(
key
))
{
File
[]
ypks
=
new
File
(
mSettings
.
getExpansionsPath
().
getAbsolutePath
()).
listFiles
();
...
...
@@ -675,6 +667,27 @@ public class SettingFragment extends PreferenceFragmentPlus {
}
}
public
void
checkUpgrade
(
String
url
)
{
OkhttpUtil
.
get
(
url
,
new
Callback
()
{
@Override
public
void
onFailure
(
Call
call
,
IOException
e
)
{
Message
message
=
new
Message
();
message
.
what
=
TYPE_SETTING_GET_VERSION_FAILED
;
message
.
obj
=
e
;
handler
.
sendMessage
(
message
);
}
@Override
public
void
onResponse
(
Call
call
,
Response
response
)
throws
IOException
{
String
json
=
response
.
body
().
string
();
Message
message
=
new
Message
();
message
.
what
=
TYPE_SETTING_GET_VERSION_OK
;
message
.
obj
=
json
;
handler
.
sendMessage
(
message
);
}
});
}
private
void
arrangeCodeList
(
String
code
)
{
BufferedReader
br
=
new
BufferedReader
(
new
StringReader
(
code
));
try
{
...
...
mobile/src/main/res/values-zh/strings.xml
View file @
75f4e4f3
...
...
@@ -268,7 +268,7 @@
<string
name=
"Checking_Update"
>
检查更新中,请稍候
</string>
<string
name=
"Found_Update"
>
发现新版本,前往下载?
</string>
<string
name=
"Checking_Update_Failed"
>
检查更新失败
</string>
<string
name=
"Ask_to_Change_Other_Way"
>
主线
下载
失败,尝试备选线路中...
</string>
<string
name=
"Ask_to_Change_Other_Way"
>
主线
获取
失败,尝试备选线路中...
</string>
<string
name=
"DuelAssistant"
>
决斗助手启用中
</string>
<string
name=
"masterrule"
>
学习大师规则
</string>
<string
name=
"tutorial"
>
查看软件教程
</string>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment