Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
yueeng committed Jan 21, 2016
1 parent 5002e8d commit 0cbd563
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<string name="app_about">关于</string>
<string name="app_publish">发布页</string>
<string name="app_update">更新</string>
<string name="app_update_new">本地版本 %1$s,最新版本%2$s。</string>
<string name="app_update_new"> %1$s 升级到 %2$s。</string>
<string name="app_update_none">版本 %1$s 已经是最新版本。</string>
<string name="app_update_check">检查更新</string>
<string name="app_philosophy">哲学</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<string name="app_about">About</string>
<string name="app_publish">Publish</string>
<string name="app_update">Update</string>
<string name="app_update_new">Local version is %1$s, the new version is %2$s</string>
<string name="app_update_new">Update from %1$s to %2$s</string>
<string name="app_update_none">Version %1$s is newest.</string>
<string name="app_update_check">Check update</string>
<string name="app_philosophy">Philosophy</string>
Expand Down
15 changes: 8 additions & 7 deletions app/src/main/scala/io/github/yueeng/hacg/MainActivity.scala
Original file line number Diff line number Diff line change
Expand Up @@ -137,28 +137,29 @@ class MainActivity extends AppCompatActivity {
}

def checkVersion(toast: Boolean = false) = {
new ScalaTask[Void, Void, Option[(String, String)]] {
override def background(params: Void*): Option[(String, String)] = {
new ScalaTask[Void, Void, Option[(String, String, String)]] {
override def background(params: Void*): Option[(String, String, String)] = {
s"${HAcg.RELEASE}/latest".httpGet.jsoup {
dom => (
dom.select(".css-truncate-target").text(),
dom.select(".markdown-body").text().trim,
dom.select(".release-downloads a[href$=.apk]").headOption match {
case Some(a) => a.attr("abs:href")
case _ => null
}
)
} match {
case Some((v: String, u: String)) if Common.versionBefore(Common.version(MainActivity.this), v) => Option(v, u)
case Some((v: String, t: String, u: String)) if Common.versionBefore(Common.version(MainActivity.this), v) => Option(v, t, u)
case _ => None
}
}

override def post(result: Option[(String, String)]): Unit = {
override def post(result: Option[(String, String, String)]): Unit = {
result match {
case Some((v: String, u: String)) =>
case Some((v: String, t:String, u: String)) =>
new Builder(MainActivity.this)
.setTitle(R.string.app_update)
.setMessage(getString(R.string.app_update_new, Common.version(MainActivity.this), v))
.setTitle(getString(R.string.app_update_new, Common.version(MainActivity.this), v))
.setMessage(t)
.setPositiveButton(R.string.app_update, dialogClick { (d, w) => openWeb(MainActivity.this, u) })
.setNeutralButton(R.string.app_publish, dialogClick { (d, w) => openWeb(MainActivity.this, HAcg.RELEASE) })
.setNegativeButton(R.string.app_cancel, null)
Expand Down

0 comments on commit 0cbd563

Please sign in to comment.