Skip to content

Commit

Permalink
add support for tablet in Android 12L
Browse files Browse the repository at this point in the history
  • Loading branch information
kidozh committed Dec 16, 2021
1 parent 1f98dca commit 879e2a9
Show file tree
Hide file tree
Showing 18 changed files with 169 additions and 78 deletions.
1 change: 1 addition & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 7 additions & 6 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ android {
applicationId "com.kidozh.discuzhub"
minSdkVersion 24
targetSdkVersion 31
versionCode 42
versionName "4.12"
versionCode 43
versionName "5.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
manifestPlaceholders = [
discuz_title: "NOT_IMPLEMENTED",
Expand Down Expand Up @@ -207,6 +207,11 @@ dependencies {
}
// okhttp
implementation 'com.squareup.okhttp3:okhttp:4.4.0'
// larger screen support
implementation("androidx.window:window:1.0.0-beta04")
implementation("androidx.startup:startup-runtime:1.1.0")




}
Expand Down
12 changes: 12 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,18 @@
<meta-data
android:name="discuz_title"
android:value="${discuz_title}" />

<provider
android:authorities="${applicationId}.androidx-startup"
android:name="androidx.startup.InitializationProvider"
android:exported="false"
tools:node="merge"
>
<meta-data android:name="com.kidozh.discuzhub.embedding.TabletWindowInitializer"
android:value="androidx.startup"/>
</provider>
</application>



</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import androidx.core.content.ContextCompat
import androidx.lifecycle.ViewModelProvider
import androidx.preference.PreferenceManager
import androidx.recyclerview.widget.ConcatAdapter
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.google.android.material.dialog.MaterialAlertDialogBuilder
Expand Down Expand Up @@ -306,17 +305,17 @@ class ForumActivity : BaseStatusActivity(), OnRefreshBtnListener, OnLinkClickedL


private fun configureRecyclerview() {
binding.bbsForumSublist.setHasFixedSize(true)
binding.bbsForumSublist.itemAnimator = getRecyclerviewAnimation(this)
binding.bbsForumSublist.layoutManager = GridLayoutManager(this, 4)
// binding.bbsForumSublist.setHasFixedSize(true)
// binding.bbsForumSublist.itemAnimator = getRecyclerviewAnimation(this)
// binding.bbsForumSublist.layoutManager = GridLayoutManager(this, 4)
subForumAdapter = SubForumAdapter(bbsInfo, user)
binding.bbsForumSublist.adapter = getAnimatedAdapter(this, subForumAdapter)
// binding.bbsForumSublist.adapter = getAnimatedAdapter(this, subForumAdapter)
binding.bbsForumThreadRecyclerview.setHasFixedSize(true)
binding.bbsForumThreadRecyclerview.itemAnimator = getRecyclerviewAnimation(this)
val linearLayoutManager = LinearLayoutManager(this)
binding.bbsForumThreadRecyclerview.layoutManager = linearLayoutManager
adapter = ThreadAdapter(null, bbsInfo!!, user)
concatAdapter = ConcatAdapter(adapter, networkIndicatorAdapter)
concatAdapter = ConcatAdapter(subForumAdapter,adapter, networkIndicatorAdapter)
binding.bbsForumThreadRecyclerview.adapter = getAnimatedAdapter(this, concatAdapter!!)
binding.bbsForumThreadRecyclerview.addOnScrollListener(object :
RecyclerView.OnScrollListener() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ private void configureRecyclerview(){
adapter.setInformation(bbsInfo,userBriefInfo);
mViewModel.getFavoriteItemListData().observe(getViewLifecycleOwner(),adapter::submitList);
binding.favoriteThreadRecyclerview.setAdapter(AnimationUtils.INSTANCE.getAnimatedAdapter(getContext(),adapter));
binding.favoriteThreadRecyclerview.addItemDecoration(new DividerItemDecoration(getContext(),DividerItemDecoration.VERTICAL));
//binding.favoriteThreadRecyclerview.addItemDecoration(new DividerItemDecoration(getContext(),DividerItemDecoration.VERTICAL));
}

private void configureSwipeRefreshLayout(){
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.kidozh.discuzhub.embedding

import android.content.Context
import androidx.startup.Initializer
import androidx.window.core.ExperimentalWindowApi
import androidx.window.embedding.SplitController
import com.kidozh.discuzhub.R

@ExperimentalWindowApi
class TabletWindowInitializer : Initializer<SplitController> {
override fun create(context: Context): SplitController {
SplitController.initialize(context, R.xml.main_split_config)
return SplitController.getInstance()
}

override fun dependencies(): List<Class<out Initializer<*>>> {
return emptyList()
}
}
50 changes: 15 additions & 35 deletions app/src/main/res/layout/activity_bbs_show_forum.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,42 +11,22 @@
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<com.google.android.material.appbar.CollapsingToolbarLayout
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar"
style="@style/Material3ActionBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_scrollFlags="scroll|enterAlways|enterAlwaysCollapsed">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar"
style="@style/Material3ActionBar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:textAlignment="center"
app:subtitleCentered="true"
app:titleCentered="true" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/bbs_forum_sublist"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:itemCount="1"/>
</LinearLayout>





</LinearLayout>
</com.google.android.material.appbar.CollapsingToolbarLayout>
android:layout_height="?attr/actionBarSize"
android:textAlignment="center"
app:subtitleCentered="true"
app:titleCentered="true" />

<!-- <com.google.android.material.appbar.CollapsingToolbarLayout-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- app:layout_scrollFlags="scroll|enterAlways|enterAlwaysCollapsed">-->
<!-- -->
<!-- -->
<!-- </com.google.android.material.appbar.CollapsingToolbarLayout>-->


<!-- <com.google.android.material.appbar.CollapsingToolbarLayout-->
Expand Down
11 changes: 8 additions & 3 deletions app/src/main/res/layout/item_bbs_notification_detail.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,21 @@
android:layout_height="wrap_content"
android:orientation="vertical">

<androidx.cardview.widget.CardView
<com.google.android.material.card.MaterialCardView
android:id="@+id/bbs_notification_cardview"
style="?attr/materialCardViewElevatedStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:foreground="?attr/selectableItemBackground"
app:cardElevation="1dp"
app:cardMaxElevation="2dp"
app:cardPreventCornerOverlap="true"
app:cardUseCompatPadding="true"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
app:layout_constraintTop_toTopOf="parent"
app:state_dragged="false">

<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
Expand Down Expand Up @@ -90,5 +95,5 @@
app:layout_constraintStart_toEndOf="@+id/bbs_notification_author"
app:layout_constraintTop_toTopOf="@+id/bbs_notification_author" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
</com.google.android.material.card.MaterialCardView>
</androidx.constraintlayout.widget.ConstraintLayout>
6 changes: 4 additions & 2 deletions app/src/main/res/layout/item_favorite_forum.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
android:layout_width="match_parent"
android:layout_height="wrap_content">

<androidx.cardview.widget.CardView
<com.google.android.material.card.MaterialCardView
android:id="@+id/bbs_favorite_forum_cardview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
app:state_dragged="false"
style="?attr/materialCardViewElevatedStyle"
android:foreground="?attr/selectableItemBackground"
app:cardCornerRadius="0dp"
app:cardElevation="0dp"
Expand Down Expand Up @@ -88,5 +90,5 @@
tools:visibility="visible" />

</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
</com.google.android.material.card.MaterialCardView>
</androidx.constraintlayout.widget.ConstraintLayout>
12 changes: 7 additions & 5 deletions app/src/main/res/layout/item_favorite_thread.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,19 @@
android:layout_height="wrap_content"
android:orientation="vertical">

<androidx.cardview.widget.CardView
<com.google.android.material.card.MaterialCardView
android:id="@+id/bbs_favorite_thread_cardview"
style="?attr/materialCardViewElevatedStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:foreground="?attr/selectableItemBackground"
app:cardCornerRadius="0dp"
app:cardElevation="0dp"
app:cardPreventCornerOverlap="true"
app:cardUseCompatPadding="true"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
app:layout_constraintTop_toTopOf="parent"
app:state_dragged="false">

<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
Expand Down Expand Up @@ -110,5 +112,5 @@
app:layout_constraintStart_toEndOf="@+id/favorite_thread_reply"
app:layout_constraintTop_toTopOf="@+id/favorite_thread_reply" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
</com.google.android.material.card.MaterialCardView>
</androidx.constraintlayout.widget.ConstraintLayout>
6 changes: 4 additions & 2 deletions app/src/main/res/layout/item_hot_forum.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
android:layout_width="match_parent"
android:layout_height="wrap_content">

<androidx.cardview.widget.CardView
<com.google.android.material.card.MaterialCardView
android:id="@+id/hot_forum_cardview"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:clickable="true"
app:state_dragged="false"
style="?attr/materialCardViewElevatedStyle"
android:foreground="?attr/selectableItemBackground"
app:cardUseCompatPadding="true"
app:layout_constraintEnd_toEndOf="parent"
Expand Down Expand Up @@ -76,6 +78,6 @@
app:layout_constraintTop_toBottomOf="@+id/item_hot_forum_name"
tools:text="@tools:sample/first_names" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
</com.google.android.material.card.MaterialCardView>

</androidx.constraintlayout.widget.ConstraintLayout>
6 changes: 4 additions & 2 deletions app/src/main/res/layout/item_manage_bbs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">

<androidx.cardview.widget.CardView
<com.google.android.material.card.MaterialCardView
android:id="@+id/item_bbs_card"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:foreground="?attr/selectableItemBackground"
app:state_dragged="false"
style="?attr/materialCardViewElevatedStyle"
app:cardUseCompatPadding="true">

<androidx.constraintlayout.widget.ConstraintLayout
Expand Down Expand Up @@ -95,7 +97,7 @@
app:layout_constraintTop_toTopOf="@+id/item_bbs_https" />

</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
</com.google.android.material.card.MaterialCardView>


</layout>
1 change: 1 addition & 0 deletions app/src/main/res/layout/item_portal_forum_catagory.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

<ImageView
android:id="@+id/bbs_forum_imageview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:layout_marginTop="8dp"
Expand Down
6 changes: 4 additions & 2 deletions app/src/main/res/layout/item_public_message.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@
android:layout_width="match_parent"
android:layout_height="wrap_content">

<androidx.cardview.widget.CardView
<com.google.android.material.card.MaterialCardView
android:id="@+id/item_public_message_cardview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:foreground="?attr/selectableItemBackground"
app:cardCornerRadius="0dp"
app:cardElevation="8dp"
app:state_dragged="false"
style="?attr/materialCardViewElevatedStyle"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
Expand Down Expand Up @@ -68,5 +70,5 @@
app:layout_constraintTop_toBottomOf="@+id/item_public_message_username"
tools:text="@tools:sample/lorem" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
</com.google.android.material.card.MaterialCardView>
</androidx.constraintlayout.widget.ConstraintLayout>
Loading

0 comments on commit 879e2a9

Please sign in to comment.