version act 赋值
This commit is contained in:
parent
abe2f0ab90
commit
47e4d3dba5
|
|
@ -4,10 +4,8 @@ import android.app.Activity
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import androidx.activity.viewModels
|
import androidx.activity.viewModels
|
||||||
import androidx.core.view.ViewCompat
|
|
||||||
import androidx.core.view.WindowInsetsCompat
|
|
||||||
import androidx.core.view.updatePadding
|
|
||||||
import com.ama.core.architecture.appBase.AppViewsActivity
|
import com.ama.core.architecture.appBase.AppViewsActivity
|
||||||
|
import com.ama.core.architecture.util.AndroidUtil
|
||||||
import com.gamedog.vididin.R
|
import com.gamedog.vididin.R
|
||||||
import com.gamedog.vididin.main.interfaces.OnTabStyleListener
|
import com.gamedog.vididin.main.interfaces.OnTabStyleListener
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
|
|
@ -28,17 +26,15 @@ class VersionActivity : AppViewsActivity<ViewBinding, UiState, ViewModel>(), OnT
|
||||||
with(binding) {
|
with(binding) {
|
||||||
titlebar.setBackIconColor(R.color.black)
|
titlebar.setBackIconColor(R.color.black)
|
||||||
titlebar.setTitleText(R.string.version, R.color.black)
|
titlebar.setTitleText(R.string.version, R.color.black)
|
||||||
|
|
||||||
|
|
||||||
|
tvVersion.text = AndroidUtil.getAppVersionInfo()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun ViewBinding.initWindowInsets() {
|
override fun ViewBinding.initWindowInsets() {
|
||||||
ViewCompat.setOnApplyWindowInsetsListener(contentRoot) { v, insets ->
|
setImmerseRootView(contentRoot)
|
||||||
val systemBars =
|
|
||||||
insets.getInsets(WindowInsetsCompat.Type.systemBars() or WindowInsetsCompat.Type.displayCutout())
|
|
||||||
v.updatePadding(top = systemBars.top)
|
|
||||||
insets
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun ViewBinding.initListeners() {
|
override fun ViewBinding.initListeners() {
|
||||||
|
|
|
||||||
|
|
@ -13,194 +13,32 @@
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="0dp"
|
||||||
android:layout_marginHorizontal="15dp"
|
android:layout_weight="1"
|
||||||
|
android:layout_marginTop="50dp"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatTextView
|
|
||||||
android:id="@+id/tv_date_win"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="15dp"
|
|
||||||
android:textSize="12sp"
|
|
||||||
android:textColor="@color/gray6"
|
|
||||||
android:text="2025/10/31"
|
|
||||||
/>
|
|
||||||
|
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal"
|
android:layout_marginHorizontal="15dp">
|
||||||
android:background="@drawable/bg_records_win"
|
<androidx.appcompat.widget.AppCompatTextView
|
||||||
android:layout_marginTop="5dp"
|
android:layout_width="wrap_content"
|
||||||
android:gravity="center_vertical"
|
android:layout_height="wrap_content"
|
||||||
android:paddingVertical="5dp"
|
android:textSize="15sp"
|
||||||
>
|
android:textColor="@color/gray6"
|
||||||
|
android:text="@string/cur_version"
|
||||||
<androidx.appcompat.widget.AppCompatImageView
|
|
||||||
android:id="@+id/iv_left_win"
|
|
||||||
android:layout_width="45dp"
|
|
||||||
android:layout_height="45dp"
|
|
||||||
android:src="@mipmap/record_win"
|
|
||||||
android:layout_centerVertical="true"
|
|
||||||
android:layout_marginLeft="15dp"
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<LinearLayout
|
<androidx.appcompat.widget.AppCompatTextView
|
||||||
|
android:id="@+id/tv_version"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"
|
|
||||||
android:layout_marginHorizontal="10dp"
|
|
||||||
android:layout_toRightOf="@+id/iv_left_win"
|
|
||||||
android:layout_toLeftOf="@+id/ll_right_win"
|
|
||||||
android:layout_centerVertical="true"
|
|
||||||
>
|
|
||||||
<androidx.appcompat.widget.AppCompatTextView
|
|
||||||
android:id="@+id/tv_title_win"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:textSize="15sp"
|
|
||||||
android:textColor="@color/white"
|
|
||||||
android:text="@string/record_win_item_title"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatTextView
|
|
||||||
android:id="@+id/tv_desc_win"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="5dp"
|
|
||||||
android:textSize="14sp"
|
|
||||||
android:textColor="@color/white_alpha_99"
|
|
||||||
android:text="@string/record_win_item_desc"
|
|
||||||
/>
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/ll_right_win"
|
|
||||||
android:layout_width="75dp"
|
|
||||||
android:layout_height="75dp"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:layout_alignParentRight="true"
|
|
||||||
android:layout_centerVertical="true"
|
|
||||||
android:layout_marginRight="5dp"
|
|
||||||
android:background="@mipmap/bg_record_win_rgiht"
|
|
||||||
android:paddingHorizontal="6dp"
|
|
||||||
android:gravity="center_horizontal"
|
|
||||||
>
|
|
||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatTextView
|
|
||||||
android:id="@+id/tv_win_right_top"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="10dp"
|
|
||||||
android:textStyle="bold"
|
|
||||||
android:textSize="15sp"
|
|
||||||
android:textColor="@color/yellow_00"
|
|
||||||
android:text="Ganhar"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatTextView
|
|
||||||
android:id="@+id/tv_win_right_bottom"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="11dp"
|
|
||||||
android:textSize="10sp"
|
|
||||||
android:textColor="@color/green_54"
|
|
||||||
android:text="Ver detalhes"
|
|
||||||
/>
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</RelativeLayout>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatTextView
|
|
||||||
android:id="@+id/tv_date_lost"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="15dp"
|
|
||||||
android:textSize="12sp"
|
|
||||||
android:textColor="@color/gray6"
|
|
||||||
android:text="2025/10/31"
|
|
||||||
/>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<RelativeLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="horizontal"
|
|
||||||
android:background="@drawable/bg_records_lost"
|
|
||||||
android:layout_marginTop="5dp"
|
|
||||||
android:gravity="center_vertical"
|
|
||||||
android:paddingVertical="5dp"
|
|
||||||
>
|
|
||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatImageView
|
|
||||||
android:id="@+id/iv_left_lost"
|
|
||||||
android:layout_width="45dp"
|
|
||||||
android:layout_height="45dp"
|
|
||||||
android:src="@mipmap/record_lost"
|
|
||||||
android:layout_centerVertical="true"
|
|
||||||
android:layout_marginLeft="15dp"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:layout_marginHorizontal="10dp"
|
|
||||||
android:layout_toRightOf="@+id/iv_left_lost"
|
|
||||||
android:layout_toLeftOf="@+id/ll_right_lost"
|
|
||||||
android:layout_centerVertical="true"
|
|
||||||
>
|
|
||||||
<androidx.appcompat.widget.AppCompatTextView
|
|
||||||
android:id="@+id/tv_title_lost"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:textSize="15sp"
|
|
||||||
android:textColor="@color/white"
|
|
||||||
android:text="@string/record_lost_item_title"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatTextView
|
|
||||||
android:id="@+id/tv_desc_lost"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="5dp"
|
|
||||||
android:textSize="14sp"
|
|
||||||
android:textColor="@color/white_alpha_99"
|
|
||||||
android:text="@string/record_lost_item_desc"
|
|
||||||
/>
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
|
|
||||||
<FrameLayout
|
|
||||||
android:id="@+id/ll_right_lost"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:layout_alignParentEnd="true"
|
android:layout_alignParentEnd="true"
|
||||||
android:layout_centerVertical="true"
|
android:textSize="13sp"
|
||||||
android:layout_marginEnd="5dp"
|
android:textStyle="bold"
|
||||||
android:background="@mipmap/bg_record_lost_rgiht"
|
android:textColor="@color/black"
|
||||||
android:paddingHorizontal="6dp"
|
/>
|
||||||
android:gravity="center"
|
|
||||||
>
|
|
||||||
<androidx.appcompat.widget.AppCompatTextView
|
|
||||||
android:id="@+id/tv_lost_right_top"
|
|
||||||
android:layout_width="75dp"
|
|
||||||
android:layout_height="75dp"
|
|
||||||
android:textStyle="bold"
|
|
||||||
android:gravity="center"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:textSize="15sp"
|
|
||||||
android:textColor="@color/gray9"
|
|
||||||
android:text="@string/not_win"
|
|
||||||
/>
|
|
||||||
</FrameLayout>
|
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -106,4 +106,6 @@
|
||||||
<string name="box_subtask_hint_3_3">Participar de 10 compras gratuitas</string>
|
<string name="box_subtask_hint_3_3">Participar de 10 compras gratuitas</string>
|
||||||
<string name="has_claim_box_cash_hint">Has claimed %f cash successfully.</string>
|
<string name="has_claim_box_cash_hint">Has claimed %f cash successfully.</string>
|
||||||
|
|
||||||
|
<string name="cur_version">Current Version:</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
@ -3,6 +3,7 @@ package com.ama.core.architecture.util
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.Intent.FLAG_ACTIVITY_NEW_TASK
|
import android.content.Intent.FLAG_ACTIVITY_NEW_TASK
|
||||||
|
import android.content.pm.PackageManager
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
|
@ -64,9 +65,28 @@ class AndroidUtil private constructor() {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
fun getAppVersionInfo(): String {
|
||||||
|
return try {
|
||||||
|
val context = BaseApp.appContext()
|
||||||
|
val packageManager = context.packageManager
|
||||||
|
val packageInfo = packageManager.getPackageInfo(context.packageName, 0)
|
||||||
|
val versionName = packageInfo.versionName
|
||||||
|
val versionCode = if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.P) {
|
||||||
|
packageInfo.longVersionCode.toString() // 在 Android 9.0 (Pie) 及以上使用 longVersionCode
|
||||||
|
} else {
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
|
packageInfo.versionCode.toString()
|
||||||
|
}
|
||||||
|
//"$versionName ($versionCode)"
|
||||||
|
"$versionName"
|
||||||
|
} catch (e: PackageManager.NameNotFoundException) {
|
||||||
|
"Failed to get app version: ${e.message}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue