mirror of
https://github.com/jrpie/Launcher.git
synced 2025-02-23 14:31:30 +01:00
add layout preference for app list
This commit is contained in:
parent
c3a31a97ef
commit
a9e9f34260
7 changed files with 130 additions and 9 deletions
|
@ -14,6 +14,7 @@ import java.util.stream.Collectors;
|
||||||
import de.jrpie.android.launcher.R;
|
import de.jrpie.android.launcher.R;
|
||||||
import de.jrpie.android.launcher.apps.AppInfo;
|
import de.jrpie.android.launcher.apps.AppInfo;
|
||||||
import de.jrpie.android.launcher.actions.lock.LockMethod;
|
import de.jrpie.android.launcher.actions.lock.LockMethod;
|
||||||
|
import de.jrpie.android.launcher.preferences.theme.AppListLayout;
|
||||||
import de.jrpie.android.launcher.preferences.theme.Background;
|
import de.jrpie.android.launcher.preferences.theme.Background;
|
||||||
import de.jrpie.android.launcher.preferences.theme.ColorTheme;
|
import de.jrpie.android.launcher.preferences.theme.ColorTheme;
|
||||||
import de.jrpie.android.launcher.preferences.theme.Font;
|
import de.jrpie.android.launcher.preferences.theme.Font;
|
||||||
|
@ -39,6 +40,9 @@ import eu.jonahbauer.android.preference.annotations.serializer.PreferenceSeriali
|
||||||
@Preference(name = "custom_names", type = HashMap.class, serializer = LauncherPreferences$Config.MapAppInfoStringSerializer.class),
|
@Preference(name = "custom_names", type = HashMap.class, serializer = LauncherPreferences$Config.MapAppInfoStringSerializer.class),
|
||||||
@Preference(name = "hide_bound_apps", type = boolean.class, defaultValue = "false"),
|
@Preference(name = "hide_bound_apps", type = boolean.class, defaultValue = "false"),
|
||||||
}),
|
}),
|
||||||
|
@PreferenceGroup(name = "list_apps", prefix = "settings_list_apps_", suffix = "_key", value = {
|
||||||
|
@Preference(name = "layout", type = AppListLayout.class, defaultValue = "TEXT")
|
||||||
|
}),
|
||||||
@PreferenceGroup(name = "gestures", prefix = "settings_gesture_", suffix = "_key", value = {
|
@PreferenceGroup(name = "gestures", prefix = "settings_gesture_", suffix = "_key", value = {
|
||||||
}),
|
}),
|
||||||
@PreferenceGroup(name = "general", prefix = "settings_general_", suffix = "_key", value = {
|
@PreferenceGroup(name = "general", prefix = "settings_general_", suffix = "_key", value = {
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
package de.jrpie.android.launcher.preferences.theme
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
|
import android.content.Context
|
||||||
|
import android.util.DisplayMetrics
|
||||||
|
import androidx.recyclerview.widget.GridLayoutManager
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import de.jrpie.android.launcher.R
|
||||||
|
import de.jrpie.android.launcher.ui.list.apps.AppsRecyclerAdapter
|
||||||
|
|
||||||
|
|
||||||
|
// TODO: move this to de.jrpie.android.launcher.ui.list.apps ?
|
||||||
|
@Suppress("unused")
|
||||||
|
enum class AppListLayout(
|
||||||
|
val layoutManager: (context: Context) -> RecyclerView.LayoutManager,
|
||||||
|
val layoutResource: Int,
|
||||||
|
val prepareView: (viewHolder: AppsRecyclerAdapter.ViewHolder) -> Unit,
|
||||||
|
|
||||||
|
) {
|
||||||
|
DEFAULT(
|
||||||
|
{ c -> LinearLayoutManager(c) },
|
||||||
|
R.layout.list_apps_row,
|
||||||
|
{ v -> }
|
||||||
|
),
|
||||||
|
|
||||||
|
// TODO work profile indicator
|
||||||
|
TEXT(
|
||||||
|
{ c -> LinearLayoutManager(c) },
|
||||||
|
R.layout.list_apps_row_variant_text,
|
||||||
|
{ v ->
|
||||||
|
}
|
||||||
|
),
|
||||||
|
GRID(
|
||||||
|
{ c ->
|
||||||
|
val displayMetrics = c.resources.displayMetrics
|
||||||
|
val width_sp = displayMetrics.widthPixels / displayMetrics.scaledDensity
|
||||||
|
GridLayoutManager(c, (width_sp / 90).toInt()) },
|
||||||
|
R.layout.list_apps_row_variant_grid,
|
||||||
|
{ v ->
|
||||||
|
}
|
||||||
|
),
|
||||||
|
}
|
|
@ -21,6 +21,7 @@ import com.google.android.material.snackbar.Snackbar
|
||||||
import de.jrpie.android.launcher.R
|
import de.jrpie.android.launcher.R
|
||||||
import de.jrpie.android.launcher.REQUEST_CHOOSE_APP
|
import de.jrpie.android.launcher.REQUEST_CHOOSE_APP
|
||||||
import de.jrpie.android.launcher.actions.AppAction
|
import de.jrpie.android.launcher.actions.AppAction
|
||||||
|
import de.jrpie.android.launcher.actions.LauncherDeviceAdmin
|
||||||
import de.jrpie.android.launcher.apps.AppFilter
|
import de.jrpie.android.launcher.apps.AppFilter
|
||||||
import de.jrpie.android.launcher.apps.AppInfo
|
import de.jrpie.android.launcher.apps.AppInfo
|
||||||
import de.jrpie.android.launcher.apps.DetailedAppInfo
|
import de.jrpie.android.launcher.apps.DetailedAppInfo
|
||||||
|
@ -28,6 +29,7 @@ import de.jrpie.android.launcher.appsList
|
||||||
import de.jrpie.android.launcher.loadApps
|
import de.jrpie.android.launcher.loadApps
|
||||||
import de.jrpie.android.launcher.openAppSettings
|
import de.jrpie.android.launcher.openAppSettings
|
||||||
import de.jrpie.android.launcher.preferences.LauncherPreferences
|
import de.jrpie.android.launcher.preferences.LauncherPreferences
|
||||||
|
import de.jrpie.android.launcher.preferences.theme.AppListLayout
|
||||||
import de.jrpie.android.launcher.transformGrayscale
|
import de.jrpie.android.launcher.transformGrayscale
|
||||||
import de.jrpie.android.launcher.ui.list.ListActivity
|
import de.jrpie.android.launcher.ui.list.ListActivity
|
||||||
import de.jrpie.android.launcher.uninstallApp
|
import de.jrpie.android.launcher.uninstallApp
|
||||||
|
@ -212,9 +214,13 @@ class AppsRecyclerAdapter(
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||||
|
|
||||||
|
val layout = LauncherPreferences.list_apps().layout()
|
||||||
val inflater = LayoutInflater.from(parent.context)
|
val inflater = LayoutInflater.from(parent.context)
|
||||||
val view: View = inflater.inflate(R.layout.list_apps_row, parent, false)
|
val view: View = inflater.inflate(layout.layoutResource, parent, false)
|
||||||
return ViewHolder(view)
|
val viewHolder = ViewHolder(view)
|
||||||
|
layout.prepareView(viewHolder)
|
||||||
|
return viewHolder
|
||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
|
|
@ -77,7 +77,7 @@ class ListFragmentApps : Fragment(), UIObject {
|
||||||
binding.listAppsRview.apply {
|
binding.listAppsRview.apply {
|
||||||
// improve performance (since content changes don't change the layout size)
|
// improve performance (since content changes don't change the layout size)
|
||||||
setHasFixedSize(true)
|
setHasFixedSize(true)
|
||||||
layoutManager = LinearLayoutManager(context)
|
layoutManager = LauncherPreferences.list_apps().layout().layoutManager(context)
|
||||||
// TODO: option to change this to GridLayoutManager(context, numCols)
|
// TODO: option to change this to GridLayoutManager(context, numCols)
|
||||||
adapter = appsRViewAdapter
|
adapter = appsRViewAdapter
|
||||||
}
|
}
|
||||||
|
|
34
app/src/main/res/layout/list_apps_row_variant_grid.xml
Normal file
34
app/src/main/res/layout/list_apps_row_variant_grid.xml
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/list_apps_row_container"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="5sp">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/list_apps_row_icon"
|
||||||
|
android:layout_width="40sp"
|
||||||
|
android:layout_height="40sp"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
tools:ignore="ContentDescription" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/list_apps_row_name"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
android:paddingTop="5dp"
|
||||||
|
android:text=""
|
||||||
|
android:textSize="11sp"
|
||||||
|
tools:text="some app"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/list_apps_row_icon"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent" />
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
34
app/src/main/res/layout/list_apps_row_variant_text.xml
Normal file
34
app/src/main/res/layout/list_apps_row_variant_text.xml
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/list_apps_row_container"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="5sp">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/list_apps_row_icon"
|
||||||
|
android:layout_width="0sp"
|
||||||
|
android:layout_height="0sp"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
android:visibility="gone"
|
||||||
|
tools:ignore="ContentDescription" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/list_apps_row_name"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
android:text=""
|
||||||
|
android:textSize="25sp"
|
||||||
|
tools:text="some app"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -13,7 +13,7 @@
|
||||||
<string name="settings_apps_hidden_key" translatable="false">apps.hidden</string>
|
<string name="settings_apps_hidden_key" translatable="false">apps.hidden</string>
|
||||||
<string name="settings_apps_custom_names_key" translatable="false">apps.custom_names</string>
|
<string name="settings_apps_custom_names_key" translatable="false">apps.custom_names</string>
|
||||||
<string name="settings_apps_hide_bound_apps_key" translatable="false">apps.hide_bound_apps</string>
|
<string name="settings_apps_hide_bound_apps_key" translatable="false">apps.hide_bound_apps</string>
|
||||||
|
<string name="settings_list_apps_layout_key" translatable="false">list.apps.layout</string>
|
||||||
<string name="settings_general_choose_home_screen_key" translatable="false">general.select_launcher</string>
|
<string name="settings_general_choose_home_screen_key" translatable="false">general.select_launcher</string>
|
||||||
<!--
|
<!--
|
||||||
-
|
-
|
||||||
|
|
Loading…
Add table
Reference in a new issue