Skip to content

Commit 5c77a23

Browse files
Fix: Fixed the touch area for HomeFragment
Signed-off-by: HeCodes2Much <wayne6324@gmail.com>
1 parent 9746141 commit 5c77a23

File tree

3 files changed

+35
-15
lines changed

3 files changed

+35
-15
lines changed

app/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ plugins {
1313

1414
android {
1515
namespace = "com.github.droidworksstudio.launcher"
16-
compileSdk = 34
16+
compileSdk = 35
1717

1818
defaultConfig {
1919
applicationId = "app.easy.launcher"
2020
minSdk = 24
21-
targetSdk = 34
21+
targetSdk = 35
2222
versionCode = 23
2323
versionName = "0.2.3"
2424

app/src/main/java/com/github/droidworksstudio/launcher/ui/home/HomeFragment.kt

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import android.os.Looper
1515
import android.text.format.DateFormat
1616
import android.util.Log
1717
import android.view.*
18+
import android.widget.LinearLayout
1819
import androidx.annotation.RequiresApi
1920
import androidx.appcompat.widget.AppCompatTextView
2021
import androidx.biometric.BiometricPrompt
@@ -191,13 +192,31 @@ class HomeFragment : Fragment(),
191192

192193
private fun setupRecyclerView() {
193194
val marginTopInPixels = 128
194-
val params: ViewGroup.MarginLayoutParams =
195-
binding.appListAdapter.layoutParams as ViewGroup.MarginLayoutParams
196-
params.topMargin = marginTopInPixels
195+
val params: ViewGroup.LayoutParams = binding.appListAdapter.layoutParams
196+
var layoutParams = if (params is LinearLayout.LayoutParams) {
197+
params
198+
} else {
199+
LinearLayout.LayoutParams(params)
200+
}
201+
layoutParams.topMargin = marginTopInPixels
202+
203+
when (preferenceHelper.homeAppAlignment) {
204+
Gravity.START -> {
205+
layoutParams.gravity = Gravity.START
206+
}
207+
208+
Gravity.CENTER -> {
209+
layoutParams.gravity = Gravity.CENTER
210+
}
211+
212+
Gravity.END -> {
213+
layoutParams.gravity = Gravity.END
214+
}
215+
}
197216

198217
binding.appListAdapter.apply {
199218
adapter = homeAdapter
200-
layoutParams = params
219+
layoutParams = layoutParams
201220
setHasFixedSize(false)
202221
layoutManager = StaggeredGridLayoutManager(1, StaggeredGridLayoutManager.VERTICAL)
203222
isNestedScrollingEnabled = false

app/src/main/res/layout/fragment_home.xml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,6 @@
99
android:orientation="vertical"
1010
tools:context=".ui.home.HomeFragment">
1111

12-
<FrameLayout
13-
android:id="@+id/touchArea"
14-
android:layout_marginVertical="20dp"
15-
android:layout_width="match_parent"
16-
android:layout_height="match_parent" />
17-
1812
<com.github.droidworksstudio.launcher.view.GestureNestedScrollView
1913
android:id="@+id/nestScrollView"
2014
android:layout_width="match_parent"
@@ -87,11 +81,18 @@
8781

8882
</androidx.appcompat.widget.LinearLayoutCompat>
8983

90-
<androidx.recyclerview.widget.RecyclerView
91-
android:id="@+id/appListAdapter"
84+
<androidx.appcompat.widget.LinearLayoutCompat
85+
android:id="@+id/touchArea"
9286
android:layout_width="match_parent"
93-
android:layout_height="wrap_content" />
87+
android:layout_height="wrap_content"
88+
android:orientation="vertical">
89+
90+
<androidx.recyclerview.widget.RecyclerView
91+
android:id="@+id/appListAdapter"
92+
android:layout_width="wrap_content"
93+
android:layout_height="wrap_content" />
9494

95+
</androidx.appcompat.widget.LinearLayoutCompat>
9596
</androidx.appcompat.widget.LinearLayoutCompat>
9697

9798
</com.github.droidworksstudio.launcher.view.GestureNestedScrollView>

0 commit comments

Comments
 (0)