feat: 支持接收自动构建版本更新
This commit is contained in:
parent
aa75e42825
commit
f7f240fa51
|
|
@ -41,10 +41,7 @@ import com.huanchengfly.tieba.post.utils.QuickPreviewUtil.isThreadUrl
|
||||||
import com.microsoft.appcenter.AppCenter
|
import com.microsoft.appcenter.AppCenter
|
||||||
import com.microsoft.appcenter.analytics.Analytics
|
import com.microsoft.appcenter.analytics.Analytics
|
||||||
import com.microsoft.appcenter.crashes.Crashes
|
import com.microsoft.appcenter.crashes.Crashes
|
||||||
import com.microsoft.appcenter.distribute.Distribute
|
import com.microsoft.appcenter.distribute.*
|
||||||
import com.microsoft.appcenter.distribute.DistributeListener
|
|
||||||
import com.microsoft.appcenter.distribute.ReleaseDetails
|
|
||||||
import com.microsoft.appcenter.distribute.UpdateAction
|
|
||||||
import org.intellij.lang.annotations.RegExp
|
import org.intellij.lang.annotations.RegExp
|
||||||
import org.litepal.LitePal
|
import org.litepal.LitePal
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
@ -80,6 +77,7 @@ class BaseApplication : Application(), IApp {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||||
setWebViewPath(this)
|
setWebViewPath(this)
|
||||||
}
|
}
|
||||||
|
Distribute.setUpdateTrack(if (appPreferences.checkCIUpdate) UpdateTrack.PRIVATE else UpdateTrack.PUBLIC)
|
||||||
Distribute.setListener(MyDistributeListener())
|
Distribute.setListener(MyDistributeListener())
|
||||||
AppCenter.start(
|
AppCenter.start(
|
||||||
this, "b56debcc-264b-4368-a2cd-8c20213f6433",
|
this, "b56debcc-264b-4368-a2cd-8c20213f6433",
|
||||||
|
|
|
||||||
|
|
@ -1,46 +1,73 @@
|
||||||
package com.huanchengfly.tieba.post.activities;
|
package com.huanchengfly.tieba.post.activities
|
||||||
|
|
||||||
import android.animation.LayoutTransition;
|
import android.animation.LayoutTransition
|
||||||
import android.os.Bundle;
|
import android.os.Bundle
|
||||||
import android.view.View;
|
import android.view.View
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup
|
||||||
import android.widget.RelativeLayout;
|
import android.widget.RelativeLayout
|
||||||
|
import androidx.appcompat.widget.Toolbar
|
||||||
|
import com.huanchengfly.tieba.post.R
|
||||||
|
import com.huanchengfly.tieba.post.toastShort
|
||||||
|
import com.huanchengfly.tieba.post.ui.about.AboutPage
|
||||||
|
import com.huanchengfly.tieba.post.ui.theme.utils.ThemeUtils
|
||||||
|
import com.huanchengfly.tieba.post.utils.ThemeUtil
|
||||||
|
import com.huanchengfly.tieba.post.utils.VersionUtil
|
||||||
|
|
||||||
import androidx.appcompat.app.ActionBar;
|
class AboutActivity : BaseActivity() {
|
||||||
import androidx.appcompat.widget.Toolbar;
|
var lastClickTime: Long = 0
|
||||||
|
var clickCount: Int = 0
|
||||||
|
|
||||||
import com.huanchengfly.tieba.post.R;
|
override fun getLayoutId(): Int {
|
||||||
import com.huanchengfly.tieba.post.ui.about.AboutPage;
|
return R.layout.activity_about
|
||||||
import com.huanchengfly.tieba.post.ui.theme.utils.ThemeUtils;
|
|
||||||
import com.huanchengfly.tieba.post.utils.ThemeUtil;
|
|
||||||
import com.huanchengfly.tieba.post.utils.VersionUtil;
|
|
||||||
|
|
||||||
public class AboutActivity extends BaseActivity {
|
|
||||||
@Override
|
|
||||||
public int getLayoutId() {
|
|
||||||
return R.layout.activity_about;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
super.onCreate(savedInstanceState)
|
||||||
super.onCreate(savedInstanceState);
|
ThemeUtil.setTranslucentThemeBackground(findViewById(R.id.background))
|
||||||
ThemeUtil.setTranslucentThemeBackground(findViewById(R.id.background));
|
val toolbar = findViewById(R.id.toolbar) as Toolbar
|
||||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
val mainView = findViewById(R.id.main) as RelativeLayout
|
||||||
RelativeLayout mainView = (RelativeLayout) findViewById(R.id.main);
|
val headerView = View.inflate(this, R.layout.header_about, null)
|
||||||
View headerView = View.inflate(this, R.layout.header_about, null);
|
(headerView as ViewGroup).layoutTransition = LayoutTransition()
|
||||||
((ViewGroup) headerView).setLayoutTransition(new LayoutTransition());
|
setSupportActionBar(toolbar)
|
||||||
setSupportActionBar(toolbar);
|
supportActionBar?.apply {
|
||||||
ActionBar actionBar = getSupportActionBar();
|
setTitle(R.string.title_about)
|
||||||
if (actionBar != null) {
|
setDisplayHomeAsUpEnabled(true)
|
||||||
actionBar.setTitle(R.string.title_about);
|
|
||||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
|
||||||
}
|
}
|
||||||
int colorIcon = ThemeUtils.getColorByAttr(this, R.attr.colorAccent);
|
val colorIcon = ThemeUtils.getColorByAttr(this, R.attr.colorAccent)
|
||||||
new AboutPage(this)
|
AboutPage(this)
|
||||||
.setHeaderView(headerView)
|
.setHeaderView(headerView)
|
||||||
.addTitle("应用信息", colorIcon)
|
.addTitle("应用信息", colorIcon)
|
||||||
.addItem(new AboutPage.Item("当前版本", VersionUtil.getVersionName(this), R.drawable.ic_round_info, colorIcon))
|
.addItem(
|
||||||
.addItem(new AboutPage.Item("源代码").setIcon(R.drawable.ic_codepen, colorIcon).setOnClickListener(v -> WebViewActivity.launch(v.getContext(), "https://github.com/HuanCheng65/TiebaLite")))
|
AboutPage.Item(
|
||||||
.into(mainView);
|
"当前版本",
|
||||||
|
VersionUtil.getVersionName(this),
|
||||||
|
R.drawable.ic_round_info,
|
||||||
|
colorIcon
|
||||||
|
).setOnClickListener {
|
||||||
|
if (System.currentTimeMillis() - lastClickTime > 2000) {
|
||||||
|
clickCount = 0
|
||||||
|
} else {
|
||||||
|
clickCount++
|
||||||
|
}
|
||||||
|
if (clickCount > 5) {
|
||||||
|
if (appPreferences.checkCIUpdate) {
|
||||||
|
toastShort(R.string.toast_ci_version_disabled)
|
||||||
|
appPreferences.checkCIUpdate = false
|
||||||
|
} else {
|
||||||
|
toastShort(R.string.toast_ci_version_enabled)
|
||||||
|
appPreferences.checkCIUpdate = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.addItem(
|
||||||
|
AboutPage.Item("源代码").setIcon(R.drawable.ic_codepen, colorIcon)
|
||||||
|
.setOnClickListener { v: View ->
|
||||||
|
WebViewActivity.launch(
|
||||||
|
v.context,
|
||||||
|
"https://github.com/HuanCheng65/TiebaLite"
|
||||||
|
)
|
||||||
|
})
|
||||||
|
.into(mainView)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -18,9 +18,8 @@ open class AppPreferencesUtils(context: Context) {
|
||||||
key = "auto_sign_time"
|
key = "auto_sign_time"
|
||||||
)
|
)
|
||||||
|
|
||||||
var checkBetaUpdate by SharedPreferenceDelegates.boolean(
|
var checkCIUpdate by SharedPreferenceDelegates.boolean(
|
||||||
defaultValue = false,
|
defaultValue = false
|
||||||
key = "check_beta_update"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var collectThreadSeeLz by SharedPreferenceDelegates.boolean(
|
var collectThreadSeeLz by SharedPreferenceDelegates.boolean(
|
||||||
|
|
|
||||||
|
|
@ -488,4 +488,6 @@
|
||||||
<string name="title_dialog_error_detail">错误详情</string>
|
<string name="title_dialog_error_detail">错误详情</string>
|
||||||
<string name="button_copy_detail">复制详情</string>
|
<string name="button_copy_detail">复制详情</string>
|
||||||
<string name="snackbar_error">出现了一点小问题(%1$d)</string>
|
<string name="snackbar_error">出现了一点小问题(%1$d)</string>
|
||||||
|
<string name="toast_ci_version_enabled">已启用接收自动构建版本更新(需要 App Center 账号)</string>
|
||||||
|
<string name="toast_ci_version_disabled">已禁用接收自动构建版本更新(需要 App Center 账号)</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue