diff --git a/.gradle/7.3.3/checksums/checksums.lock b/.gradle/7.3.3/checksums/checksums.lock index d6d1dd0..719934a 100644 Binary files a/.gradle/7.3.3/checksums/checksums.lock and b/.gradle/7.3.3/checksums/checksums.lock differ diff --git a/.gradle/7.3.3/checksums/md5-checksums.bin b/.gradle/7.3.3/checksums/md5-checksums.bin index cd2e325..0073822 100644 Binary files a/.gradle/7.3.3/checksums/md5-checksums.bin and b/.gradle/7.3.3/checksums/md5-checksums.bin differ diff --git a/.gradle/7.3.3/checksums/sha1-checksums.bin b/.gradle/7.3.3/checksums/sha1-checksums.bin index 013a5fd..27303ea 100644 Binary files a/.gradle/7.3.3/checksums/sha1-checksums.bin and b/.gradle/7.3.3/checksums/sha1-checksums.bin differ diff --git a/.gradle/7.3.3/executionHistory/executionHistory.bin b/.gradle/7.3.3/executionHistory/executionHistory.bin index d8a7ba8..582032a 100644 Binary files a/.gradle/7.3.3/executionHistory/executionHistory.bin and b/.gradle/7.3.3/executionHistory/executionHistory.bin differ diff --git a/.gradle/7.3.3/executionHistory/executionHistory.lock b/.gradle/7.3.3/executionHistory/executionHistory.lock index a14a774..3923acc 100644 Binary files a/.gradle/7.3.3/executionHistory/executionHistory.lock and b/.gradle/7.3.3/executionHistory/executionHistory.lock differ diff --git a/.gradle/7.3.3/fileHashes/fileHashes.bin b/.gradle/7.3.3/fileHashes/fileHashes.bin index ece0a02..fd062c5 100644 Binary files a/.gradle/7.3.3/fileHashes/fileHashes.bin and b/.gradle/7.3.3/fileHashes/fileHashes.bin differ diff --git a/.gradle/7.3.3/fileHashes/fileHashes.lock b/.gradle/7.3.3/fileHashes/fileHashes.lock index 1e2a6c0..3773b4e 100644 Binary files a/.gradle/7.3.3/fileHashes/fileHashes.lock and b/.gradle/7.3.3/fileHashes/fileHashes.lock differ diff --git a/.gradle/7.3.3/fileHashes/resourceHashesCache.bin b/.gradle/7.3.3/fileHashes/resourceHashesCache.bin index c97b593..637df9e 100644 Binary files a/.gradle/7.3.3/fileHashes/resourceHashesCache.bin and b/.gradle/7.3.3/fileHashes/resourceHashesCache.bin differ diff --git a/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/.gradle/buildOutputCleanup/buildOutputCleanup.lock index 8b6d2d4..a41c9f1 100644 Binary files a/.gradle/buildOutputCleanup/buildOutputCleanup.lock and b/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ diff --git a/.gradle/buildOutputCleanup/outputFiles.bin b/.gradle/buildOutputCleanup/outputFiles.bin index 5cce5c1..0253b43 100644 Binary files a/.gradle/buildOutputCleanup/outputFiles.bin and b/.gradle/buildOutputCleanup/outputFiles.bin differ diff --git a/.gradle/file-system.probe b/.gradle/file-system.probe index 709f9ce..d063028 100644 Binary files a/.gradle/file-system.probe and b/.gradle/file-system.probe differ diff --git a/app/build.gradle b/app/build.gradle index 45e44bf..19be278 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -70,7 +70,7 @@ android { dependencies { //视频播放器 - implementation 'com.github.CarGuo.GSYVideoPlayer:GSYVideoPlayer:v8.2.0-release-jitpack' +// implementation 'com.github.CarGuo.GSYVideoPlayer:GSYVideoPlayer:v8.2.0-release-jitpack' //权限申请 implementation 'com.guolindev.permissionx:permissionx:1.6.1' implementation "androidx.room:room-runtime:2.4.0" @@ -94,7 +94,6 @@ dependencies { implementation 'com.kongzue.stacklabel:stacklabelview:1.1.9' implementation files('libs/editor_0.8.aar') implementation project(path: ':assistantCoreLibrary') - implementation project(path: ':networkApi') implementation 'com.afollestad.material-dialogs:bottomsheets:3.3.0' implementation 'com.afollestad.material-dialogs:input:3.3.0' @@ -104,9 +103,9 @@ dependencies { implementation 'com.github.QuadFlask:colorpicker:0.0.15' implementation 'cat.ereza:customactivityoncrash:2.3.0' implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0" - implementation 'androidx.appcompat:appcompat:1.3.1' + implementation 'androidx.appcompat:appcompat:1.4.0' implementation 'androidx.core:core-splashscreen:1.0.0-beta01' - implementation 'com.google.android.material:material:1.5.0' + implementation 'com.google.android.material:material:1.6.1' implementation 'androidx.constraintlayout:constraintlayout:2.0.4' implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5' implementation 'androidx.navigation:navigation-ui-ktx:2.3.5' diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 7a19002..0928761 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -23,6 +23,9 @@ android:supportsRtl="true" android:theme="@style/Theme.rust.Concept" android:usesCleartextTraffic="true"> + diff --git a/app/src/main/java/com/coldmint/rust/pro/CreationWizardActivity.kt b/app/src/main/java/com/coldmint/rust/pro/CreationWizardActivity.kt new file mode 100644 index 0000000..d84b2c4 --- /dev/null +++ b/app/src/main/java/com/coldmint/rust/pro/CreationWizardActivity.kt @@ -0,0 +1,110 @@ +package com.coldmint.rust.pro + +import android.content.Intent +import androidx.appcompat.app.AppCompatActivity +import android.os.Bundle +import androidx.recyclerview.widget.LinearLayoutManager +import androidx.recyclerview.widget.RecyclerView +import com.coldmint.rust.pro.adapters.GuideAdapter +import com.coldmint.rust.pro.base.BaseActivity +import com.coldmint.rust.pro.databean.GuideData +import com.coldmint.rust.pro.databinding.ActivityCreationWizardBinding +import com.coldmint.rust.pro.tool.AppSettings + +class CreationWizardActivity : BaseActivity() { + //创建向导类型(模组,模板包) + lateinit var type: String + override fun whenCreateActivity(savedInstanceState: Bundle?, canUseView: Boolean) { + setReturnButton() + title = getString(R.string.creation_wizard) + val temType = intent.getStringExtra("type") + if (temType.isNullOrBlank()) { + showToast("请传入类型") + finish() + return + } + type = temType + viewBinding.recyclerView.layoutManager = LinearLayoutManager(this) + when (temType) { + "mod" -> { + val dataList = ArrayList() + dataList.add( + GuideData( + R.string.create_mod_lable, + R.string.create_mod_describe, + R.drawable.ic_outline_create_24 + ) + ) + dataList.add( + GuideData( + R.string.import_mod, + R.string.import_mod_from_file_manager_describe, + R.drawable.folder + ) + ) + dataList.add( + GuideData( + R.string.import_mod_from_package_directory, + R.string.import_mod_from_package_directory_describe, + R.drawable.zip + ) + ) + dataList.add( + GuideData( + R.string.import_mod_from_recycle_bin, + R.string.import_mod_from_recycle_bin_describe, + R.drawable.auto_delete + ) + ) + val adapter = GuideAdapter(this, dataList) + adapter.setItemEvent { i, itemGuideBinding, viewHolder, guideData -> + itemGuideBinding.root.setOnClickListener { + finish() + when (guideData.titleRes) { + R.string.create_mod_lable -> { + startActivity( + Intent( + this, + CreateModActivity::class.java + ) + ) + } + R.string.import_mod -> { + val startIntent = + Intent(this, FileManagerActivity::class.java) + val fileBundle = Bundle() + fileBundle.putString("type", "selectFile") + startIntent.putExtra("data", fileBundle) + startActivity(startIntent) + } + R.string.import_mod_from_package_directory -> { + val startIntent = + Intent(this, FileManagerActivity::class.java) + val fileBundle = Bundle() + fileBundle.putString("type", "selectFile") + val packDirectory = appSettings.getValue( + AppSettings.Setting.PackDirectory, + AppSettings.dataRootDirectory + "/bin/" + ) + fileBundle.putString("path", packDirectory) + fileBundle.putString("rootpath", packDirectory) + startIntent.putExtra("data", fileBundle) + startActivity(startIntent) + } + R.string.import_mod_from_recycle_bin -> { + startActivity(Intent(this, RecyclingStationActivity::class.java)) + } + } + } + } + + viewBinding.recyclerView.adapter = adapter + } + } + } + + override fun getViewBindingObject(): ActivityCreationWizardBinding { + return ActivityCreationWizardBinding.inflate(layoutInflater) + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/coldmint/rust/pro/FileManagerActivity.kt b/app/src/main/java/com/coldmint/rust/pro/FileManagerActivity.kt index 0cf116a..3bd3ced 100644 --- a/app/src/main/java/com/coldmint/rust/pro/FileManagerActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/FileManagerActivity.kt @@ -156,8 +156,6 @@ class FileManagerActivity : BaseActivity() { else -> { val ints = intArrayOf( R.string.open_action1, - R.string.open_action2, - R.string.open_action3, R.string.open_action4 ) val items = FileAdapter.conversionSymbol( @@ -235,18 +233,19 @@ class FileManagerActivity : BaseActivity() { //加载文件 fun loadFiles(file: File) { executorService.submit { + if (!file.exists()) { + runOnUiThread { + viewBinding.fileList.isVisible = false + viewBinding.progressBar.isVisible = false + viewBinding.fileError.isVisible = true + viewBinding.fileError.setText(R.string.unable_to_open_this_directory) + viewBinding.fab.hide() + } + return@submit + } + if (file.isDirectory) { val files = file.listFiles() - if (files == null || !file.exists()) { - runOnUiThread { - viewBinding.fileList.isVisible = false - viewBinding.progressBar.isVisible = false - viewBinding.fileError.isVisible = true - viewBinding.fileError.setText(R.string.unable_to_open_this_directory) - viewBinding.fab.hide() - } - return@submit - } directs = file val fileArrayList: ArrayList = ArrayList(listOf(*files)) if (file.absolutePath != mRoot.absolutePath) { @@ -472,7 +471,6 @@ class FileManagerActivity : BaseActivity() { } - /** * 解析文件路径 * diff --git a/app/src/main/java/com/coldmint/rust/pro/LoginActivity.kt b/app/src/main/java/com/coldmint/rust/pro/LoginActivity.kt index b64a825..9f6a812 100644 --- a/app/src/main/java/com/coldmint/rust/pro/LoginActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/LoginActivity.kt @@ -106,34 +106,28 @@ class LoginActivity : BaseActivity() { } val appId = appSettings.getValue(AppSettings.Setting.AppID, ""); isLogin = true - viewBinding.button.setBackgroundColor( - GlobalMethod.getThemeColor( - this@LoginActivity, - R.attr.colorPrimaryVariant - ) - ) viewBinding.button.setText(R.string.request_data) User.login(LoginRequestData(account, passWord, appId), object : ApiCallBack { override fun onResponse(userData: UserData) { isLogin = false - viewBinding.button.setBackgroundColor(GlobalMethod.getColorPrimary(this@LoginActivity)) viewBinding.button.setText(R.string.login) if (userData.code == ServerConfiguration.Success_Code) { appSettings.forceSetValue( AppSettings.Setting.Account, - userData.data.account + account ) appSettings.forceSetValue(AppSettings.Setting.PassWord, passWord) appSettings.forceSetValue( - AppSettings.Setting.UserName, - userData.data.userName + AppSettings.Setting.Token, + userData.data.token ) GlobalMethod.isActive = userData.data.activation //更新本地激活时间 val expirationTime = userData.data.expirationTime val time = ServerConfiguration.toLongTime(expirationTime) appSettings.forceSetValue(AppSettings.Setting.ExpirationTime, time) + appSettings.forceSetValue(AppSettings.Setting.LoginStatus,true) startActivity(Intent(this@LoginActivity, MainActivity::class.java)) finish() } else { diff --git a/app/src/main/java/com/coldmint/rust/pro/MainActivity.kt b/app/src/main/java/com/coldmint/rust/pro/MainActivity.kt index d0f3ea0..f637cc9 100644 --- a/app/src/main/java/com/coldmint/rust/pro/MainActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/MainActivity.kt @@ -314,62 +314,9 @@ class MainActivity : BaseActivity() { val templateItem = getString(R.string.template_title) when (item) { warehouseItem -> { - val popupMenu = PopupMenu(this@MainActivity, viewBinding.mainButton) - popupMenu.menu.add(R.string.create_mod_lable) - val fileManagerMenu = popupMenu.menu.addSubMenu(R.string.open_action2) - fileManagerMenu.add(R.string.file_manager) - fileManagerMenu.add(R.string.packaged_mod) - if (AppOperator.isAppInstalled(this, GlobalMethod.ADM_PACKAGE)) { - fileManagerMenu.add(R.string.from_adm) - } - popupMenu.setOnMenuItemClickListener { item -> - when (item.title.toString()) { - getString(R.string.create_mod_lable) -> { - startActivity( - Intent( - this@MainActivity, - CreateModActivity::class.java - ) - ) - } - getString(R.string.file_manager) -> { - val startIntent = - Intent(this@MainActivity, FileManagerActivity::class.java) - val fileBundle = Bundle() - fileBundle.putString("type", "selectFile") - startIntent.putExtra("data", fileBundle) - startActivityForResult(startIntent, 1) - } - getString(R.string.packaged_mod) -> { - val startIntent = - Intent(this@MainActivity, FileManagerActivity::class.java) - val fileBundle = Bundle() - fileBundle.putString("type", "selectFile") - val packDirectory = appSettings.getValue( - AppSettings.Setting.PackDirectory, - AppSettings.dataRootDirectory + "/bin/" - ) - fileBundle.putString("path", packDirectory) - fileBundle.putString("rootpath", packDirectory) - startIntent.putExtra("data", fileBundle) - startActivityForResult(startIntent, 1) - } - getString(R.string.from_adm) -> { - val startIntent = - Intent(this@MainActivity, FileManagerActivity::class.java) - val fileBundle = Bundle() - fileBundle.putString("type", "selectFile") - val packDirectory = - Environment.getExternalStorageDirectory().absolutePath + "/ADM" - fileBundle.putString("path", packDirectory) - fileBundle.putString("rootpath", packDirectory) - startIntent.putExtra("data", fileBundle) - startActivityForResult(startIntent, 1) - } - } - true - } - popupMenu.show() + val intent = Intent(this, CreationWizardActivity::class.java) + intent.putExtra("type", "mod") + startActivity(intent) } templateItem -> { val popupMenu = PopupMenu(this@MainActivity, viewBinding.mainButton) diff --git a/app/src/main/java/com/coldmint/rust/pro/RecyclingStationActivity.kt b/app/src/main/java/com/coldmint/rust/pro/RecyclingStationActivity.kt index 0714fec..fd0857c 100644 --- a/app/src/main/java/com/coldmint/rust/pro/RecyclingStationActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/RecyclingStationActivity.kt @@ -22,8 +22,8 @@ class RecyclingStationActivity : BaseActivity() override fun whenCreateActivity(savedInstanceState: Bundle?, canUseView: Boolean) { if (canUseView) { - viewBinding.toolbar.setTitle(R.string.enable_the_recovery_station) setReturnButton() + title = getString(R.string.enable_the_recovery_station) viewBinding.backupList.layoutManager = LinearLayoutManager(this@RecyclingStationActivity) val workFolderPath = appSettings.getValue( @@ -69,7 +69,8 @@ class RecyclingStationActivity : BaseActivity() if (file == null) { return@setOnClickListener } - val popupMenu = PopupMenu(this@RecyclingStationActivity, fileItemBinding.more) + val popupMenu = + PopupMenu(this@RecyclingStationActivity, fileItemBinding.more) popupMenu.menu.add(R.string.recovery_file) popupMenu.menu.add(R.string.delete_title) popupMenu.setOnMenuItemClickListener(PopupMenu.OnMenuItemClickListener { item -> diff --git a/app/src/main/java/com/coldmint/rust/pro/RegisterActivity.kt b/app/src/main/java/com/coldmint/rust/pro/RegisterActivity.kt index b0cdd90..91fa8a3 100644 --- a/app/src/main/java/com/coldmint/rust/pro/RegisterActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/RegisterActivity.kt @@ -450,7 +450,7 @@ class RegisterActivity : BaseActivity() { override fun whenCreateActivity(savedInstanceState: Bundle?, canUseView: Boolean) { if (canUseView) { - viewBinding.toolbar.setTitle(R.string.register) + title = getString(R.string.register) setReturnButton() initAction() } diff --git a/app/src/main/java/com/coldmint/rust/pro/RustApplication.kt b/app/src/main/java/com/coldmint/rust/pro/RustApplication.kt index 3c1090d..b46f696 100644 --- a/app/src/main/java/com/coldmint/rust/pro/RustApplication.kt +++ b/app/src/main/java/com/coldmint/rust/pro/RustApplication.kt @@ -3,6 +3,8 @@ package com.coldmint.rust.pro import android.app.Application import android.content.Context import cat.ereza.customactivityoncrash.config.CaocConfig +import com.google.android.material.color.DynamicColors +import com.google.android.material.color.DynamicColorsOptions class RustApplication : Application() { @@ -14,6 +16,7 @@ class RustApplication : Application() { override fun onCreate() { super.onCreate() // UMConfigure.preInit(this, appId, channel) +// DynamicColors.applyToActivitiesIfAvailable(this) CaocConfig.Builder.create() .backgroundMode(CaocConfig.BACKGROUND_MODE_SILENT) //default: CaocConfig.BACKGROUND_MODE_SHOW_CUSTOM .enabled(true) //default: true diff --git a/app/src/main/java/com/coldmint/rust/pro/UserHomePageActivity.kt b/app/src/main/java/com/coldmint/rust/pro/UserHomePageActivity.kt index 9d404e5..a6c9f0a 100644 --- a/app/src/main/java/com/coldmint/rust/pro/UserHomePageActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/UserHomePageActivity.kt @@ -32,9 +32,6 @@ import com.google.android.material.snackbar.Snackbar import com.google.android.material.tabs.TabLayout import com.google.android.material.tabs.TabLayoutMediator import com.gyf.immersionbar.ktx.immersionBar -import com.shuyu.gsyvideoplayer.builder.GSYVideoOptionBuilder -import com.shuyu.gsyvideoplayer.utils.GSYVideoHelper -import com.shuyu.gsyvideoplayer.utils.GSYVideoType class UserHomePageActivity : BaseActivity() { @@ -46,9 +43,6 @@ class UserHomePageActivity : BaseActivity() { val userHomeStateAdapter by lazy { UserHomeStateAdapter(this, userId) } - val videoHelper by lazy { - GSYVideoHelper(this) - } val appID by lazy { @@ -95,23 +89,9 @@ class UserHomePageActivity : BaseActivity() { } initButton() - loadVideo() } - fun loadVideo() { - viewBinding.coverView.visibility = View.INVISIBLE - viewBinding.appBar.setBackgroundResource(R.drawable.transparent) - viewBinding.tabLayout.setBackgroundResource(R.drawable.transparent) - viewBinding.videoView.setUp("http://39.105.229.249/resources/mp4/vicious.mp4", true, null) - videoHelper.setGsyVideoOptionBuilder( - GSYVideoHelper.GSYVideoHelperBuilder().setHideActionBar(true).setHideStatusBar(false) - ) - GSYVideoType.setShowType(GSYVideoType.SCREEN_TYPE_FULL) - viewBinding.videoView.isLooping = true - viewBinding.videoView.isAutoFullWithSize = true - viewBinding.videoView.startPlayLogic() - } /** * 打开用户列表 diff --git a/app/src/main/java/com/coldmint/rust/pro/adapters/GuideAdapter.kt b/app/src/main/java/com/coldmint/rust/pro/adapters/GuideAdapter.kt new file mode 100644 index 0000000..d394a91 --- /dev/null +++ b/app/src/main/java/com/coldmint/rust/pro/adapters/GuideAdapter.kt @@ -0,0 +1,33 @@ +package com.coldmint.rust.pro.adapters + +import android.content.Context +import android.view.LayoutInflater +import android.view.ViewGroup +import com.coldmint.rust.pro.base.BaseAdapter +import com.coldmint.rust.pro.databean.GuideData +import com.coldmint.rust.pro.databinding.ItemGuideBinding + +/** + * 向导适配器 + */ +class GuideAdapter(context: Context, dataList: MutableList) : + BaseAdapter(context, dataList) { + override fun getViewBindingObject( + layoutInflater: LayoutInflater, + parent: ViewGroup, + viewType: Int + ): ItemGuideBinding { + return ItemGuideBinding.inflate(layoutInflater, parent, false) + } + + override fun onBingView( + data: GuideData, + viewBinding: ItemGuideBinding, + viewHolder: ViewHolder, + position: Int + ) { + viewBinding.iconView.setImageResource(data.imageRes) + viewBinding.titleView.setText(data.titleRes) + viewBinding.describeView.setText(data.describeRes) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/coldmint/rust/pro/base/BaseActivity.kt b/app/src/main/java/com/coldmint/rust/pro/base/BaseActivity.kt index b820d91..a901136 100644 --- a/app/src/main/java/com/coldmint/rust/pro/base/BaseActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/base/BaseActivity.kt @@ -17,6 +17,7 @@ import androidx.lifecycle.ViewModelProvider import androidx.viewbinding.ViewBinding import com.afollestad.materialdialogs.MaterialDialog import com.coldmint.rust.pro.R +import com.google.android.material.appbar.MaterialToolbar import com.google.android.material.snackbar.Snackbar import com.google.android.material.textfield.TextInputLayout import java.util.* @@ -43,15 +44,12 @@ abstract class BaseActivity : } override fun onCreate(savedInstanceState: Bundle?) { -// WindowCompat.setDecorFitsSystemWindows(window, false) - whenCreateActivity(savedInstanceState, false) + WindowCompat.setDecorFitsSystemWindows(window, false) super.onCreate(savedInstanceState) + whenCreateActivity(savedInstanceState, false) setContentView(viewBinding.root) - val toolBar = findViewById(R.id.toolbar) - if (toolBar == null) { - MaterialDialog(this).title(R.string.app_name).message(text = "启动失败,未找到标题栏") - .positiveButton(text = "确定").cancelable(false).show() - } else { + val toolBar = findViewById(R.id.toolbar) + if (toolBar != null) { setSupportActionBar(toolBar) } whenCreateActivity(savedInstanceState, true) diff --git a/app/src/main/java/com/coldmint/rust/pro/databean/GuideData.kt b/app/src/main/java/com/coldmint/rust/pro/databean/GuideData.kt new file mode 100644 index 0000000..11d79cd --- /dev/null +++ b/app/src/main/java/com/coldmint/rust/pro/databean/GuideData.kt @@ -0,0 +1,9 @@ +package com.coldmint.rust.pro.databean + +/** + * 向导数据 + * @property titleRes Int + * @property imageRes Int + * @constructor + */ +class GuideData(val titleRes: Int, val describeRes: Int, val imageRes: Int) \ No newline at end of file diff --git a/app/src/main/java/com/coldmint/rust/pro/fragments/UserInfoFragment.kt b/app/src/main/java/com/coldmint/rust/pro/fragments/UserInfoFragment.kt index 7175a2a..c0e31b3 100644 --- a/app/src/main/java/com/coldmint/rust/pro/fragments/UserInfoFragment.kt +++ b/app/src/main/java/com/coldmint/rust/pro/fragments/UserInfoFragment.kt @@ -7,6 +7,7 @@ import android.widget.Toast import androidx.recyclerview.widget.GridLayoutManager import com.bumptech.glide.Glide import com.bumptech.glide.request.RequestOptions +import com.coldmint.rust.core.dataBean.user.ActivationInfo import com.coldmint.rust.core.dataBean.user.UserData import com.coldmint.rust.core.interfaces.ApiCallBack import com.coldmint.rust.core.web.ServerConfiguration @@ -103,8 +104,19 @@ class UserInfoFragment : BaseFragment() { super.onResume() if (account.isNotBlank()) { - User.getInfo(account, object : ApiCallBack { - override fun onResponse(t: UserData) { + User.getUserActivationInfo(account, object : ApiCallBack { + + + override fun onFailure(e: Exception) { + viewBinding.nameView.text = account + loadRecyclerView(3) +// val localTime = +// appSettings.getValue(AppSettings.Setting.ExpirationTime, 0.toLong()) +// viewBinding.expirationTimeView.text = +// ServerConfiguration.toStringTime(localTime) + } + + override fun onResponse(t: ActivationInfo) { if (t.code == ServerConfiguration.Success_Code) { viewBinding.nameView.text = t.data.userName val icon = t.data.headIcon @@ -121,15 +133,6 @@ class UserInfoFragment : BaseFragment() { } } - override fun onFailure(e: Exception) { - viewBinding.nameView.text = account - loadRecyclerView(3) -// val localTime = -// appSettings.getValue(AppSettings.Setting.ExpirationTime, 0.toLong()) -// viewBinding.expirationTimeView.text = -// ServerConfiguration.toStringTime(localTime) - } - }) } } @@ -148,7 +151,7 @@ class UserInfoFragment : BaseFragment() { } viewBinding.logOutButton.setOnClickListener { - requireActivity().finish() + appSettings.setValue(AppSettings.Setting.LoginStatus, false) startActivity(Intent(requireContext(), LoginActivity::class.java)) } } diff --git a/app/src/main/java/com/coldmint/rust/pro/tool/AppSettings.kt b/app/src/main/java/com/coldmint/rust/pro/tool/AppSettings.kt index 4cddc60..82a34bc 100644 --- a/app/src/main/java/com/coldmint/rust/pro/tool/AppSettings.kt +++ b/app/src/main/java/com/coldmint/rust/pro/tool/AppSettings.kt @@ -43,7 +43,7 @@ class AppSettings private constructor(val mContext: Context) { private val editor: SharedPreferences.Editor = sharedPreferences.edit() enum class Setting { - DatabaseDirectory, DatabasePath, TemplateDirectory, AppLanguage, DeveloperMode, CustomSymbol, AutoCreateNomedia, OnlyLoadConantLanguageTemple, NightMode, GamePackage, KeepRwmodFile, EnableRecoveryStation, RecoveryStationFileSaveDays, RecoveryStationFolder, IndependentFolder, SetGameStorage, PackDirectory, IdentifiersPromptNumber, UserName, UseJetBrainsMonoFont, AppID, Account, PassWord, ExpirationTime, CheckBetaUpdate, UpdateData, ShareTip, AgreePolicy, EnglishEditingMode, NightModeFollowSystem, UseMobileNetwork, MapFolder, ModFolder, UseTheCommunityAsTheLaunchPage, AutoSave,ServerAddress + DatabaseDirectory, DatabasePath, TemplateDirectory, AppLanguage, DeveloperMode, CustomSymbol, AutoCreateNomedia, OnlyLoadConantLanguageTemple, NightMode, GamePackage, KeepRwmodFile, EnableRecoveryStation, RecoveryStationFileSaveDays, RecoveryStationFolder, IndependentFolder, SetGameStorage, PackDirectory, IdentifiersPromptNumber, UserName, UseJetBrainsMonoFont, AppID, Account, PassWord, ExpirationTime, CheckBetaUpdate, UpdateData, ShareTip, AgreePolicy, EnglishEditingMode, NightModeFollowSystem, UseMobileNetwork, MapFolder, ModFolder, UseTheCommunityAsTheLaunchPage, AutoSave, ServerAddress, Token, LoginStatus } @@ -303,5 +303,7 @@ class AppSettings private constructor(val mContext: Context) { map[Setting.UpdateData] = "UpdateData" map[Setting.ShareTip] = "ShareTip" map[Setting.AgreePolicy] = "AgreePolicy" + map[Setting.LoginStatus] = "LoginStatus" + map[Setting.Token] = "Token" } } \ No newline at end of file diff --git a/app/src/main/java/com/coldmint/rust/pro/tool/GlobalMethod.kt b/app/src/main/java/com/coldmint/rust/pro/tool/GlobalMethod.kt index a1be197..364de20 100644 --- a/app/src/main/java/com/coldmint/rust/pro/tool/GlobalMethod.kt +++ b/app/src/main/java/com/coldmint/rust/pro/tool/GlobalMethod.kt @@ -51,7 +51,6 @@ object GlobalMethod { const val DEFAULT_GAME_PACKAGE = "com.corrodinggames.rts" const val DEBUG_SIGN = "963dfd616924b27f9247a35e45bc130a" const val RELEASE_SIGN = "5320b24894fe7ed449842a81a2dfceda" - const val ADM_PACKAGE = "com.dv.adm.pay" /** @@ -157,6 +156,7 @@ object GlobalMethod { * @param resId 资源id * @return 成功返回值,失败返回-1 */ + @Deprecated("废弃") fun getThemeColor(context: Context, resId: Int): Int { val typedValue = TypedValue() return if (context.theme.resolveAttribute(resId, typedValue, true)) { @@ -172,6 +172,7 @@ object GlobalMethod { * @param context 上下文环境 * @return 整数 */ + @Deprecated("废弃") fun getColorPrimary(context: Context): Int { return getThemeColor(context, R.attr.colorPrimary) } diff --git a/app/src/main/java/com/coldmint/rust/pro/viewmodel/StartViewModel.kt b/app/src/main/java/com/coldmint/rust/pro/viewmodel/StartViewModel.kt index 190626b..3021a5e 100644 --- a/app/src/main/java/com/coldmint/rust/pro/viewmodel/StartViewModel.kt +++ b/app/src/main/java/com/coldmint/rust/pro/viewmodel/StartViewModel.kt @@ -22,6 +22,8 @@ import com.afollestad.materialdialogs.MaterialDialog import com.coldmint.rust.core.CompressionManager import com.coldmint.rust.core.DataSet import com.coldmint.rust.core.dataBean.LoginRequestData +import com.coldmint.rust.core.dataBean.user.ActivationInfo +import com.coldmint.rust.core.dataBean.user.SocialInfoData import com.coldmint.rust.core.dataBean.user.UserData import com.coldmint.rust.core.database.code.CodeDataBase import com.coldmint.rust.core.interfaces.ApiCallBack @@ -59,7 +61,7 @@ class StartViewModel(application: Application) : BaseAndroidViewModel(applicatio * 用户数据的LiveData */ val userLiveData by lazy { - MutableLiveData() + MutableLiveData() } /** @@ -126,34 +128,17 @@ class StartViewModel(application: Application) : BaseAndroidViewModel(applicatio * 验证用户信息 */ fun verifyingUserInfo() { + val status = appSettings.getValue(AppSettings.Setting.LoginStatus, false) + if (!status) { + needLoginLiveData.value = true + return + } //验证登录 - val account = appSettings.getValue(AppSettings.Setting.Account, "") - val passWord = appSettings.getValue(AppSettings.Setting.PassWord, "") - if (account.isBlank() || passWord.isBlank()) { + val token = appSettings.getValue(AppSettings.Setting.Token, "") + if (token.isBlank()) { needLoginLiveData.value = true } else { - User.login(LoginRequestData( - account, - passWord, appSettings.getValue(AppSettings.Setting.AppID, "") - ), object : ApiCallBack { - override fun onResponse(userData: UserData) { - if (userData.code == ServerConfiguration.Success_Code) { - userLiveData.value = userData - //更新本地激活时间 - val expirationTime = userData.data.expirationTime - val time = ServerConfiguration.toLongTime(expirationTime) - appSettings.forceSetValue( - AppSettings.Setting.ExpirationTime, - time - ) - isActivationLiveData.value = userData.data.activation - } else { -// 用户登录失败 - verifyErrorMsgLiveData.value = userData.message - Log.d("验证失败", userData.message) - } - } - + User.getUserActivationInfo(token, object : ApiCallBack { override fun onFailure(e: Exception) { val localTime = appSettings.getValue( AppSettings.Setting.ExpirationTime, @@ -167,6 +152,25 @@ class StartViewModel(application: Application) : BaseAndroidViewModel(applicatio isActivationLiveData.value = localTime > nowTime } } + + + override fun onResponse(activationInfo: ActivationInfo) { + if (activationInfo.code == ServerConfiguration.Success_Code) { + userLiveData.value = activationInfo + //更新本地激活时间 + val expirationTime = activationInfo.data.expirationTime + val time = ServerConfiguration.toLongTime(expirationTime) + appSettings.forceSetValue( + AppSettings.Setting.ExpirationTime, + time + ) + isActivationLiveData.value = activationInfo.data.activation + } else { +// 用户登录失败 + verifyErrorMsgLiveData.value = activationInfo.message + Log.d("验证失败", activationInfo.message) + } + } }) } } @@ -396,6 +400,7 @@ class StartViewModel(application: Application) : BaseAndroidViewModel(applicatio ) appSettings.initSetting(AppSettings.Setting.AutoSave, true) appSettings.initSetting(AppSettings.Setting.AgreePolicy, false) + appSettings.initSetting(AppSettings.Setting.LoginStatus, false) } /** diff --git a/app/src/main/res/drawable/ic_baseline_chevron_right_24.xml b/app/src/main/res/drawable/ic_baseline_chevron_right_24.xml new file mode 100644 index 0000000..f988e7d --- /dev/null +++ b/app/src/main/res/drawable/ic_baseline_chevron_right_24.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml index 054a28c..0846000 100644 --- a/app/src/main/res/drawable/ic_launcher_background.xml +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -5,7 +5,7 @@ android:viewportHeight="108" android:viewportWidth="108" xmlns:android="http://schemas.android.com/apk/res/android"> - diff --git a/app/src/main/res/drawable/ic_outline_create_24.xml b/app/src/main/res/drawable/ic_outline_create_24.xml new file mode 100644 index 0000000..5b5fa7a --- /dev/null +++ b/app/src/main/res/drawable/ic_outline_create_24.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/drawable/round_background_true.xml b/app/src/main/res/drawable/round_background_true.xml index b361216..c95d1b1 100644 --- a/app/src/main/res/drawable/round_background_true.xml +++ b/app/src/main/res/drawable/round_background_true.xml @@ -1,6 +1,6 @@ - + + android:color="?attr/colorOnPrimary" /> \ No newline at end of file diff --git a/app/src/main/res/layout/activity_about.xml b/app/src/main/res/layout/activity_about.xml index 69a9e84..a5cc0a4 100644 --- a/app/src/main/res/layout/activity_about.xml +++ b/app/src/main/res/layout/activity_about.xml @@ -6,11 +6,10 @@ android:layout_height="match_parent" android:orientation="vertical"> - + android:layout_height="?attr/actionBarSize" /> - + android:fitsSystemWindows="true" + tools:context=".MainActivity"> - - - + android:layout_height="?attr/actionBarSize" /> @@ -42,7 +36,7 @@ android:layout_height="match_parent" android:orientation="vertical"> - - + - - - + android:layout_height="wrap_content" + android:fitsSystemWindows="true"> - \ No newline at end of file + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_creation_wizard.xml b/app/src/main/res/layout/activity_creation_wizard.xml new file mode 100644 index 0000000..05a74e8 --- /dev/null +++ b/app/src/main/res/layout/activity_creation_wizard.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_edit.xml b/app/src/main/res/layout/activity_edit.xml index 5cec56c..ddf2de1 100644 --- a/app/src/main/res/layout/activity_edit.xml +++ b/app/src/main/res/layout/activity_edit.xml @@ -27,8 +27,7 @@ android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" - android:theme="?attr/actionBarStyle" - app:popupTheme="@style/ThemeOverlay.rust.Concept.popupTheme" /> + android:theme="?attr/actionBarStyle" /> - + android:fitsSystemWindows="true" + tools:context=".MainActivity"> - - - - + android:fitsSystemWindows="true"> - + + + + + + + android:layout_alignParentTop="true" + android:text="@string/error_title" + android:textSize="16dp" /> - + - - - + android:layout_height="wrap_content" + android:layout_below="@id/subTitleView" + android:layout_marginTop="8dp"> - + android:layout_height="wrap_content" + android:hint="@string/error_description" + android:imeOptions="actionDone" + android:inputType="textMultiLine" + android:maxLines="5" /> - + - - + - + -