feat(layout): 为平板设备添加用户主页布局
- 新增 activity_user_home_page.xml 文件,用于平板设备的用户主页布局 - 修改 CommunityFragment 中的平板模式判断逻辑 - 调整 WebModInfoActivity 中的平板模式布局- 优化 item_service.xml 的布局结构 - 移除 activity_web_mod_info.xml 中的冗余属性
This commit is contained in:
parent
524270dde7
commit
a5b7954edc
|
@ -31,7 +31,7 @@ class WebModInfoActivity : BaseActivity<ActivityWebModInfoBinding>() {
|
|||
|
||||
lateinit var modId: String
|
||||
lateinit var tip: String
|
||||
val targetFile: File by lazy {
|
||||
private val targetFile: File by lazy {
|
||||
val modFolderPath = AppSettings.getValue(
|
||||
AppSettings.Setting.ModFolder,
|
||||
Environment.getExternalStorageDirectory().absolutePath + "/rustedWarfare/units/"
|
||||
|
@ -51,6 +51,7 @@ class WebModInfoActivity : BaseActivity<ActivityWebModInfoBinding>() {
|
|||
val modName: MutableLiveData<String> by lazy {
|
||||
MutableLiveData()
|
||||
}
|
||||
|
||||
@SuppressLint("CommitTransaction")
|
||||
private fun initView() {
|
||||
setReturnButton()
|
||||
|
@ -80,17 +81,21 @@ class WebModInfoActivity : BaseActivity<ActivityWebModInfoBinding>() {
|
|||
if (Tools.isTabletMode(this)) {
|
||||
adapter = ModPageDetailsAdapter(this, modId)
|
||||
supportFragmentManager.beginTransaction()
|
||||
.replace(R.id.fragment,webModDetailsFragment)
|
||||
.replace(R.id.fragment, webModDetailsFragment)
|
||||
.commit()
|
||||
viewBinding.viewPager2.adapter = adapter
|
||||
|
||||
TabLayoutMediator(viewBinding.tabLayout, viewBinding.viewPager2) { tab, i ->
|
||||
tab.text = when (i) {
|
||||
0 -> {
|
||||
getString(R.string.insert_coins)
|
||||
}
|
||||
|
||||
1 -> {
|
||||
getString(R.string.discussion)
|
||||
}else -> {
|
||||
}
|
||||
|
||||
else -> {
|
||||
getString(R.string.title)
|
||||
}
|
||||
}
|
||||
|
@ -136,7 +141,7 @@ class WebModInfoActivity : BaseActivity<ActivityWebModInfoBinding>() {
|
|||
* 下载事件
|
||||
* @param t WebModInfoData
|
||||
*/
|
||||
fun downloadAction(link: String?) {
|
||||
private fun downloadAction(link: String?) {
|
||||
if (link == null) {
|
||||
return
|
||||
}
|
||||
|
@ -239,7 +244,7 @@ class WebModInfoActivity : BaseActivity<ActivityWebModInfoBinding>() {
|
|||
* 下载工作
|
||||
* @param fileLink String
|
||||
*/
|
||||
fun downloadWork(fileLink: String) {
|
||||
private fun downloadWork(fileLink: String) {
|
||||
GlobalMethod.requestStoragePermissions(this) {
|
||||
if (it) {
|
||||
viewBinding.button.setText(R.string.installation_ing)
|
||||
|
|
|
@ -4,6 +4,7 @@ import android.os.Bundle
|
|||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.viewpager2.widget.ViewPager2
|
||||
import com.coldmint.rust.pro.R
|
||||
|
@ -36,9 +37,9 @@ class CommunityFragment : Fragment() {
|
|||
private fun onViewCreated(view: View) {
|
||||
val navigationBarView : NavigationBarView = view.findViewById(R.id.bottomnavigationView)
|
||||
val pager : ViewPager2 = view.findViewById(R.id.pager)
|
||||
if (Tools.isTabletMode(requireContext())) {
|
||||
// var navigation = navigationBarView as NavigationRailView
|
||||
// navigation.setonc
|
||||
// 是否是平板模式
|
||||
val tabletMode = Tools.isTabletMode(requireContext())
|
||||
if (tabletMode){
|
||||
}
|
||||
pager.adapter = CommunityAdapter(this)
|
||||
pager.isSaveEnabled = false
|
||||
|
@ -63,16 +64,16 @@ class CommunityFragment : Fragment() {
|
|||
navigationBarView.setOnItemSelectedListener {
|
||||
when (it.itemId) {
|
||||
R.id.action_recommended -> {
|
||||
pager.currentItem = 0
|
||||
pager.setCurrentItem(0, !tabletMode)
|
||||
}
|
||||
R.id.action_follow -> {
|
||||
pager.currentItem = 1
|
||||
pager.setCurrentItem(1, !tabletMode)
|
||||
}
|
||||
R.id.action_ranking -> {
|
||||
pager.currentItem = 2
|
||||
pager.setCurrentItem(2, !tabletMode)
|
||||
}
|
||||
R.id.action_my -> {
|
||||
pager.currentItem = 3
|
||||
pager.setCurrentItem(3, !tabletMode)
|
||||
}
|
||||
}
|
||||
true
|
||||
|
|
|
@ -34,7 +34,7 @@ class FollowFragment : BaseFragment<FragmentFollowBinding>() {
|
|||
/**
|
||||
* 加载视图如果需要更新的话
|
||||
*/
|
||||
fun loadViewIfNeed() {
|
||||
private fun loadViewIfNeed() {
|
||||
val loginStatus = AppSettings.getValue(AppSettings.Setting.LoginStatus, false)
|
||||
if (loginStatus) {
|
||||
val account = AppSettings.getValue(AppSettings.Setting.Account, "")
|
||||
|
|
309
app/src/main/res/layout-land/activity_user_home_page.xml
Normal file
309
app/src/main/res/layout-land/activity_user_home_page.xml
Normal file
|
@ -0,0 +1,309 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:baselineAligned="false"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:id="@+id/appBar"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:background="?android:windowBackground">
|
||||
|
||||
<com.google.android.material.appbar.CollapsingToolbarLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:contentScrim="?android:windowBackground"
|
||||
app:layout_scrollFlags="scroll|exitUntilCollapsed|snap"
|
||||
app:titleCollapseMode="scale"
|
||||
app:titleEnabled="false">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/coverView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="150dp"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_marginBottom="-32dp"
|
||||
android:importantForAccessibility="no"
|
||||
android:scaleType="centerCrop"
|
||||
android:transitionName="@string/transition_cover" />
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/baseInfoView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_below="@id/coverView"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:background="@drawable/user_home_background">
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/headIconView"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="100dp"
|
||||
android:layout_alignTop="@id/baseInfoView"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:src="@drawable/head_icon"
|
||||
android:theme="@style/Theme.rust.Concept" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/nameView"
|
||||
style="@style/TextAppearance.Material3.TitleMedium"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/headIconView"
|
||||
android:layout_alignStart="@id/headIconView"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="@string/name" />
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:id="@+id/cardView"
|
||||
style="@style/Widget.Material3.CardView.Filled"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="20dp"
|
||||
android:layout_alignBottom="@id/nameView"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_toEndOf="@id/nameView"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible"
|
||||
app:cardBackgroundColor="@color/blue_500"
|
||||
app:cardCornerRadius="4dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:padding="4dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/positionView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/path"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="10sp" />
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/genderView"
|
||||
android:layout_width="15dp"
|
||||
android:layout_height="15dp"
|
||||
android:layout_alignBottom="@id/cardView"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_toEndOf="@id/cardView"
|
||||
android:importantForAccessibility="no"
|
||||
android:src="@drawable/boy" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/github"
|
||||
android:layout_width="15dp"
|
||||
android:layout_height="15dp"
|
||||
android:layout_alignBottom="@id/genderView"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_toEndOf="@id/genderView"
|
||||
android:importantForAccessibility="no"
|
||||
android:src="@drawable/github" />
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/describeView"
|
||||
style="@style/TextAppearance.Material3.BodyMedium"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/nameView"
|
||||
android:layout_alignStart="@id/headIconView"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="@string/describe" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/loginTimeView"
|
||||
style="@style/TextAppearance.Material3.BodySmall"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/describeView"
|
||||
android:layout_alignStart="@id/headIconView"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="@string/user_info" />
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignTop="@id/baseInfoView"
|
||||
android:layout_alignBottom="@id/headIconView"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_toEndOf="@id/headIconView"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/numberLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="46dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:baselineAligned="false">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/fansLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/fansNumView"
|
||||
style="@style/TextAppearance.Material3.BodyLarge"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="3dp"
|
||||
android:text="0" />
|
||||
|
||||
<TextView
|
||||
style="@style/TextAppearance.Material3.BodySmall"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/fans" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/followLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/followNumView"
|
||||
style="@style/TextAppearance.Material3.BodyLarge"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="3dp"
|
||||
android:text="0" />
|
||||
|
||||
<TextView
|
||||
style="@style/TextAppearance.Material3.BodySmall"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/follow" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/praiseNumView"
|
||||
style="@style/TextAppearance.Material3.BodyLarge"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="3dp"
|
||||
android:text="0" />
|
||||
|
||||
<TextView
|
||||
style="@style/TextAppearance.Material3.BodySmall"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/praise_number" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<Button
|
||||
android:id="@+id/button"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/numberLayout"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_gravity="bottom"
|
||||
android:text="@string/request_data" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
|
||||
<com.google.android.material.appbar.MaterialToolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
app:layout_collapseMode="pin"
|
||||
app:layout_scrollFlags="scroll|enterAlways" />
|
||||
|
||||
|
||||
</com.google.android.material.appbar.CollapsingToolbarLayout>
|
||||
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.google.android.material.tabs.TabLayout
|
||||
android:id="@+id/tabLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom"
|
||||
app:layout_collapseMode="pin"
|
||||
app:layout_scrollFlags="scroll|enterAlways"
|
||||
app:tabMode="fixed"
|
||||
android:fitsSystemWindows="true"
|
||||
app:tabTextAppearance="@style/TabLayoutTextStyle" />
|
||||
|
||||
<androidx.viewpager2.widget.ViewPager2
|
||||
android:id="@+id/viewPager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/fullCoverView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:importantForAccessibility="no"
|
||||
android:scaleType="matrix"
|
||||
android:visibility="gone" />
|
||||
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/fab"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|end"
|
||||
android:layout_margin="16dp"
|
||||
android:importantForAccessibility="no"
|
||||
android:src="@drawable/add"
|
||||
android:visibility="gone" />
|
||||
|
||||
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
|
@ -9,6 +9,9 @@
|
|||
android:id="@+id/bottomnavigationView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:elevation="0dp"
|
||||
android:fitsSystemWindows="false"
|
||||
app:paddingTopSystemWindowInsets="false"
|
||||
app:menu="@menu/menu_main_bottom" />
|
||||
<androidx.viewpager2.widget.ViewPager2
|
||||
android:id="@+id/pager"
|
||||
|
|
|
@ -14,13 +14,12 @@
|
|||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_collapseMode="pin" />
|
||||
android:fitsSystemWindows="true"/>
|
||||
<com.google.android.material.tabs.TabLayout
|
||||
android:id="@+id/tabLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@android:color/transparent"
|
||||
app:layout_collapseMode="pin">
|
||||
android:background="@android:color/transparent">
|
||||
<com.google.android.material.tabs.TabItem
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="120dp"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical"
|
||||
android:padding="8dp">
|
||||
|
@ -11,6 +11,7 @@
|
|||
android:id="@+id/iconView"
|
||||
android:layout_width="46dp"
|
||||
android:layout_height="46dp"
|
||||
android:importantForAccessibility="no"
|
||||
android:src="@drawable/image"
|
||||
android:scaleType="fitXY"
|
||||
app:tint="?attr/colorControlNormal" />
|
||||
|
|
|
@ -142,6 +142,7 @@ class Dynamic private constructor() {
|
|||
val request = Request.Builder()
|
||||
.url(ServerConfiguration.website + "php/dynamic.php?action=list")
|
||||
.post(requestBody).build()
|
||||
Log.i("TAG", "getList: "+ServerConfiguration.website + "php/dynamic.php?action=list")
|
||||
val call = okHttpClient.newCall(request)
|
||||
val handler = Handler(Looper.getMainLooper())
|
||||
val gson = Gson()
|
||||
|
|
Loading…
Reference in New Issue
Block a user