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.analytics.Analytics
|
||||
import com.microsoft.appcenter.crashes.Crashes
|
||||
import com.microsoft.appcenter.distribute.Distribute
|
||||
import com.microsoft.appcenter.distribute.DistributeListener
|
||||
import com.microsoft.appcenter.distribute.ReleaseDetails
|
||||
import com.microsoft.appcenter.distribute.UpdateAction
|
||||
import com.microsoft.appcenter.distribute.*
|
||||
import org.intellij.lang.annotations.RegExp
|
||||
import org.litepal.LitePal
|
||||
import java.util.*
|
||||
|
|
@ -80,6 +77,7 @@ class BaseApplication : Application(), IApp {
|
|||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||
setWebViewPath(this)
|
||||
}
|
||||
Distribute.setUpdateTrack(if (appPreferences.checkCIUpdate) UpdateTrack.PRIVATE else UpdateTrack.PUBLIC)
|
||||
Distribute.setListener(MyDistributeListener())
|
||||
AppCenter.start(
|
||||
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.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.animation.LayoutTransition
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
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;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
class AboutActivity : BaseActivity() {
|
||||
var lastClickTime: Long = 0
|
||||
var clickCount: Int = 0
|
||||
|
||||
import com.huanchengfly.tieba.post.R;
|
||||
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;
|
||||
|
||||
public class AboutActivity extends BaseActivity {
|
||||
@Override
|
||||
public int getLayoutId() {
|
||||
return R.layout.activity_about;
|
||||
override fun getLayoutId(): Int {
|
||||
return R.layout.activity_about
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
ThemeUtil.setTranslucentThemeBackground(findViewById(R.id.background));
|
||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
RelativeLayout mainView = (RelativeLayout) findViewById(R.id.main);
|
||||
View headerView = View.inflate(this, R.layout.header_about, null);
|
||||
((ViewGroup) headerView).setLayoutTransition(new LayoutTransition());
|
||||
setSupportActionBar(toolbar);
|
||||
ActionBar actionBar = getSupportActionBar();
|
||||
if (actionBar != null) {
|
||||
actionBar.setTitle(R.string.title_about);
|
||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
ThemeUtil.setTranslucentThemeBackground(findViewById(R.id.background))
|
||||
val toolbar = findViewById(R.id.toolbar) as Toolbar
|
||||
val mainView = findViewById(R.id.main) as RelativeLayout
|
||||
val headerView = View.inflate(this, R.layout.header_about, null)
|
||||
(headerView as ViewGroup).layoutTransition = LayoutTransition()
|
||||
setSupportActionBar(toolbar)
|
||||
supportActionBar?.apply {
|
||||
setTitle(R.string.title_about)
|
||||
setDisplayHomeAsUpEnabled(true)
|
||||
}
|
||||
int colorIcon = ThemeUtils.getColorByAttr(this, R.attr.colorAccent);
|
||||
new AboutPage(this)
|
||||
.setHeaderView(headerView)
|
||||
.addTitle("应用信息", colorIcon)
|
||||
.addItem(new AboutPage.Item("当前版本", VersionUtil.getVersionName(this), R.drawable.ic_round_info, colorIcon))
|
||||
.addItem(new AboutPage.Item("源代码").setIcon(R.drawable.ic_codepen, colorIcon).setOnClickListener(v -> WebViewActivity.launch(v.getContext(), "https://github.com/HuanCheng65/TiebaLite")))
|
||||
.into(mainView);
|
||||
val colorIcon = ThemeUtils.getColorByAttr(this, R.attr.colorAccent)
|
||||
AboutPage(this)
|
||||
.setHeaderView(headerView)
|
||||
.addTitle("应用信息", colorIcon)
|
||||
.addItem(
|
||||
AboutPage.Item(
|
||||
"当前版本",
|
||||
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"
|
||||
)
|
||||
|
||||
var checkBetaUpdate by SharedPreferenceDelegates.boolean(
|
||||
defaultValue = false,
|
||||
key = "check_beta_update"
|
||||
var checkCIUpdate by SharedPreferenceDelegates.boolean(
|
||||
defaultValue = false
|
||||
)
|
||||
|
||||
var collectThreadSeeLz by SharedPreferenceDelegates.boolean(
|
||||
|
|
|
|||
|
|
@ -488,4 +488,6 @@
|
|||
<string name="title_dialog_error_detail">错误详情</string>
|
||||
<string name="button_copy_detail">复制详情</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>
|
||||
|
|
|
|||
Loading…
Reference in New Issue