Skip to content

Commit

Permalink
fix home scrolling; fix docs
Browse files Browse the repository at this point in the history
  • Loading branch information
moehriegitt committed Oct 8, 2024
1 parent 5684693 commit f644e8e
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 21 deletions.
5 changes: 4 additions & 1 deletion PRIVACY.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ policy, i.e., this file will be updated if the policy changes.

NeatLauncher uses standard Android mechanisms (SharedPreferences) to
make its configuration (pinning, app visibility on the drawer, theme
selection, weather configuration) persistently across app or device
selection, weather configuration) persistent across app or device
restarts. I.e., the configuration is stored in persistent memory like
the sdcard or internal device memory.

Expand Down Expand Up @@ -73,6 +73,9 @@ which will process them.
If you search for a new location, then NeatLauncher sends your search
string to the server on the Internet and receives the list of results.

While inactive (e.g., while the device is locked), NeatLauncher does
not query weather information.

## Location Services

Location services require permission for which Android devices ask the
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ colourful, distracting, inefficient, and full of non-sensical
icons.

Clarity by efficient and elegant design based on text. With
onfigurable quick access to apps, shortcuts, or contacts via a
configurable quick access to apps, shortcuts, or contacts via a
list or by gestures.

Supports app shortcuts, both static and dynamic.
Expand Down
2 changes: 1 addition & 1 deletion TRANSLATE.html
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ <h1>'NeatLauncher' Translations
inefficient, and full of non-sensical icons.

Clarity by efficient and elegant design based on
text. With onfigurable quick access to apps,
text. With configurable quick access to apps,
shortcuts, or contacts via a list or by gestures.

Supports app shortcuts, both static and dynamic.
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/java/de/theiling/neatlauncher/AutoBinding.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import android.widget.HorizontalScrollView
import android.widget.LinearLayout
import android.widget.RadioButton
import android.widget.RadioGroup
import android.widget.RelativeLayout
import android.widget.TableLayout
import android.widget.TableRow
import android.widget.TextView
Expand Down Expand Up @@ -223,6 +224,7 @@ class MainActivityBinding(
val gridS5: View,
val gridS6: View,
val homeRecycler: RecyclerView,
val homeRecyclerBox: RelativeLayout,
val mainDate: TextView,
val mainHead: LinearLayout,
val mainSearch: EditText,
Expand Down Expand Up @@ -280,6 +282,7 @@ class MainActivityBinding(
rootView.findViewById(R.id.gridS5)!!,
rootView.findViewById(R.id.gridS6)!!,
rootView.findViewById(R.id.home_recycler)!!,
rootView.findViewById(R.id.home_recycler_box)!!,
rootView.findViewById(R.id.main_date)!!,
rootView.findViewById(R.id.main_head)!!,
rootView.findViewById(R.id.main_search)!!,
Expand Down
32 changes: 23 additions & 9 deletions app/src/main/java/de/theiling/neatlauncher/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,13 @@ class MainActivity:
// the same Down. This is hacky -- dunno why it is needed.
private var allowClick = false

// To avoid fling down/up if the recyclers can still scroll, we check their
// scroll state at the down event, so that we cannot hit the edge by scrolling
// and activating the fling in the same vertical swipe motion.
private var homeCanUp = false
private var homeCanDown = false
private var drawerCanDown = false

private val minuteTick = object: BroadcastReceiver() {
override fun onReceive(ctx: Context?, intent: Intent?) {
onMinuteTick()
Expand All @@ -114,6 +121,9 @@ class MainActivity:
object: GestureDetector.SimpleOnGestureListener() {
override fun onDown(e: MotionEvent): Boolean {
allowClick = true
homeCanUp = z.homeRecycler.canScrollVertically(+1)
homeCanDown = z.homeRecycler.canScrollVertically(-1)
drawerCanDown = z.drawerRecycler.canScrollVertically(-1)
return false
}
override fun onFling(e1: MotionEvent?, e2: MotionEvent, vx: Float, vy: Float): Boolean {
Expand Down Expand Up @@ -362,21 +372,24 @@ class MainActivity:
startActivity(Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA))

private fun onFlingUp() {
if (getMode() == modePrimary()) {
upItem?.let { itemLaunch(it) } ?: run {
clearSearch()
setMode(modeSecondary())
when (getMode()) {
modePrimary() -> if (!homeCanUp) {
upItem?.let { itemLaunch(it) } ?: run {
clearSearch()
setMode(modeSecondary())
}
}
else -> Unit
}
}

private fun onFlingDown() {
when (getMode()) {
modePrimary() -> {
modePrimary() -> if (!homeCanDown) {
downItem?.let { itemLaunch(it) } ?:
startActivity(Intent(Settings.ACTION_SETTINGS))
}
modeSecondary() -> if (!z.drawerRecycler.canScrollVertically(-1)) {
modeSecondary() -> if (!drawerCanDown) {
resetView(false)
}
else -> Unit
Expand Down Expand Up @@ -678,23 +691,24 @@ class MainActivity:
}
z.mainSearch.clearFocus()
inputMethodManager.hideSoftInputFromWindow(viewGroup.windowToken, 0)
z.drawerRecycler.scrollToPosition(0)
setMode(modePrimary())
}

private fun getMode() =
when {
z.mainHead.visibility == View.GONE -> Mode.DRAWER2
z.homeRecycler.visibility == View.GONE -> Mode.DRAWER1
z.homeRecyclerBox.visibility == View.GONE -> Mode.DRAWER1
z.drawerRecycler.visibility == View.GONE -> Mode.HOME1
else -> Mode.INIT
}

private fun setMode(want: Mode) {
if (want == getMode()) return
z.mainHead.visibility = visibleIf(want != Mode.DRAWER2)
z.homeRecycler.visibility = visibleIf(want == Mode.HOME1)
z.homeRecyclerBox.visibility = visibleIf(want == Mode.HOME1)
z.drawerRecycler.visibility = visibleIf(want != Mode.HOME1)
z.drawerRecycler.scrollToPosition(0)
z.homeRecycler.scrollToPosition(0)
}

private fun resetMode() = setMode (
Expand Down
25 changes: 17 additions & 8 deletions app/src/main/res/layout/main_activity.xml
Original file line number Diff line number Diff line change
Expand Up @@ -152,20 +152,29 @@
</LinearLayout>
</LinearLayout>

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/home_recycler"
<RelativeLayout
android:id="@+id/home_recycler_box"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:layout_height="0dp"
android:layout_marginVertical="10dp"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
android:layout_gravity="center_horizontal"
android:layout_gravity="center_vertical"
android:layout_centerVertical="true"
app:layout_constraintTop_toBottomOf="@+id/main_head"
app:layout_constraintBottom_toTopOf="@+id/drawer_recycler"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
/>
>

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/home_recycler"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:layout_centerInParent="true"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
/>

</RelativeLayout>

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/drawer_recycler"
Expand All @@ -174,7 +183,7 @@
android:layout_marginVertical="10dp"
app:visibilityMode="ignore"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_constraintTop_toBottomOf="@+id/home_recycler"
app:layout_constraintTop_toBottomOf="@+id/home_recycler_box"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toTopOf="@+id/main_search"
Expand Down
2 changes: 1 addition & 1 deletion metadata/en-US/full_description.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The home app (the launcher) to replace ugly home apps that are too colourful, distracting, inefficient, and full of non-sensical icons.

Clarity by efficient and elegant design based on text. With onfigurable quick access to apps, shortcuts, or contacts via a list or by gestures.
Clarity by efficient and elegant design based on text. With configurable quick access to apps, shortcuts, or contacts via a list or by gestures.

Supports app shortcuts, both static and dynamic.

Expand Down

0 comments on commit f644e8e

Please sign in to comment.