mirror of
https://github.com/SimpleMobileTools/Simple-Launcher.git
synced 2025-02-18 12:30:38 +01:00
parent
dda1080ccd
commit
913cbb303d
@ -63,7 +63,7 @@ android {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'com.github.SimpleMobileTools:Simple-Commons:4c83ec8740'
|
implementation 'com.github.SimpleMobileTools:Simple-Commons:42733f39a4'
|
||||||
|
|
||||||
kapt "androidx.room:room-compiler:2.5.1"
|
kapt "androidx.room:room-compiler:2.5.1"
|
||||||
implementation "androidx.room:room-runtime:2.5.1"
|
implementation "androidx.room:room-runtime:2.5.1"
|
||||||
|
@ -219,7 +219,9 @@ class MainActivity : SimpleActivity(), FlingListener {
|
|||||||
|
|
||||||
override fun onBackPressed() {
|
override fun onBackPressed() {
|
||||||
if (isAllAppsFragmentExpanded()) {
|
if (isAllAppsFragmentExpanded()) {
|
||||||
hideFragment(all_apps_fragment)
|
if ((all_apps_fragment as? AllAppsFragment)?.onBackPressed() == false) {
|
||||||
|
hideFragment(all_apps_fragment)
|
||||||
|
}
|
||||||
} else if (isWidgetsFragmentExpanded()) {
|
} else if (isWidgetsFragmentExpanded()) {
|
||||||
hideFragment(widgets_fragment)
|
hideFragment(widgets_fragment)
|
||||||
} else if (home_screen_grid.resize_frame.isVisible) {
|
} else if (home_screen_grid.resize_frame.isVisible) {
|
||||||
|
@ -36,6 +36,7 @@ class SettingsActivity : SimpleActivity() {
|
|||||||
setupCustomizeColors()
|
setupCustomizeColors()
|
||||||
setupUseEnglish()
|
setupUseEnglish()
|
||||||
setupDrawerColumnCount()
|
setupDrawerColumnCount()
|
||||||
|
setupDrawerSearchBar()
|
||||||
setupLanguage()
|
setupLanguage()
|
||||||
setupManageHiddenIcons()
|
setupManageHiddenIcons()
|
||||||
updateTextColors(settings_holder)
|
updateTextColors(settings_holder)
|
||||||
@ -105,6 +106,15 @@ class SettingsActivity : SimpleActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun setupDrawerSearchBar() {
|
||||||
|
val useSearchBar = config.useSearchBar
|
||||||
|
settings_show_search.isChecked = useSearchBar
|
||||||
|
settings_drawer_search_holder.setOnClickListener {
|
||||||
|
settings_show_search.toggle()
|
||||||
|
config.useSearchBar = settings_show_search.isChecked
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun setupLanguage() {
|
private fun setupLanguage() {
|
||||||
settings_language.text = Locale.getDefault().displayLanguage
|
settings_language.text = Locale.getDefault().displayLanguage
|
||||||
settings_language_holder.beVisibleIf(isTiramisuPlus())
|
settings_language_holder.beVisibleIf(isTiramisuPlus())
|
||||||
|
@ -22,7 +22,7 @@ import kotlinx.android.synthetic.main.item_launcher_label.view.*
|
|||||||
|
|
||||||
class LaunchersAdapter(
|
class LaunchersAdapter(
|
||||||
val activity: SimpleActivity,
|
val activity: SimpleActivity,
|
||||||
var launchers: ArrayList<AppLauncher>,
|
launchers: ArrayList<AppLauncher>,
|
||||||
val allAppsListener: AllAppsListener,
|
val allAppsListener: AllAppsListener,
|
||||||
val itemClick: (Any) -> Unit
|
val itemClick: (Any) -> Unit
|
||||||
) : RecyclerView.Adapter<LaunchersAdapter.ViewHolder>(), RecyclerViewFastScroller.OnPopupTextUpdate {
|
) : RecyclerView.Adapter<LaunchersAdapter.ViewHolder>(), RecyclerViewFastScroller.OnPopupTextUpdate {
|
||||||
@ -30,6 +30,14 @@ class LaunchersAdapter(
|
|||||||
private var textColor = activity.getProperTextColor()
|
private var textColor = activity.getProperTextColor()
|
||||||
private var iconPadding = 0
|
private var iconPadding = 0
|
||||||
private var wereFreshIconsLoaded = false
|
private var wereFreshIconsLoaded = false
|
||||||
|
private var filterQuery: String? = null
|
||||||
|
private var filteredLaunchers: List<AppLauncher> = launchers
|
||||||
|
|
||||||
|
var launchers: ArrayList<AppLauncher> = launchers
|
||||||
|
set(value) {
|
||||||
|
field = value
|
||||||
|
updateFilter()
|
||||||
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
calculateIconWidth()
|
calculateIconWidth()
|
||||||
@ -41,10 +49,10 @@ class LaunchersAdapter(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||||
holder.bindView(launchers[position])
|
holder.bindView(filteredLaunchers[position])
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getItemCount() = launchers.size
|
override fun getItemCount() = filteredLaunchers.size
|
||||||
|
|
||||||
private fun calculateIconWidth() {
|
private fun calculateIconWidth() {
|
||||||
val currentColumnCount = activity.config.drawerColumnCount
|
val currentColumnCount = activity.config.drawerColumnCount
|
||||||
@ -57,8 +65,10 @@ class LaunchersAdapter(
|
|||||||
val itemToRemove = launchers.firstOrNull { it.getLauncherIdentifier() == item.getItemIdentifier() }
|
val itemToRemove = launchers.firstOrNull { it.getLauncherIdentifier() == item.getItemIdentifier() }
|
||||||
if (itemToRemove != null) {
|
if (itemToRemove != null) {
|
||||||
val position = launchers.indexOfFirst { it.getLauncherIdentifier() == item.getItemIdentifier() }
|
val position = launchers.indexOfFirst { it.getLauncherIdentifier() == item.getItemIdentifier() }
|
||||||
|
val filteredPosition = filteredLaunchers.indexOfFirst { it.getLauncherIdentifier() == item.getItemIdentifier() }
|
||||||
launchers.removeAt(position)
|
launchers.removeAt(position)
|
||||||
notifyItemRemoved(position)
|
updateFilter()
|
||||||
|
notifyItemRemoved(filteredPosition)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,6 +82,14 @@ class LaunchersAdapter(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun updateSearchQuery(newQuery: String?) {
|
||||||
|
if (filterQuery != newQuery) {
|
||||||
|
filterQuery = newQuery
|
||||||
|
updateFilter()
|
||||||
|
notifyDataSetChanged()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun updateTextColor(newTextColor: Int) {
|
fun updateTextColor(newTextColor: Int) {
|
||||||
if (newTextColor != textColor) {
|
if (newTextColor != textColor) {
|
||||||
textColor = newTextColor
|
textColor = newTextColor
|
||||||
@ -79,6 +97,10 @@ class LaunchersAdapter(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun updateFilter() {
|
||||||
|
filteredLaunchers = launchers.filter { filterQuery == null || it.title.contains(filterQuery!!, ignoreCase = true) }
|
||||||
|
}
|
||||||
|
|
||||||
inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
||||||
fun bindView(launcher: AppLauncher): View {
|
fun bindView(launcher: AppLauncher): View {
|
||||||
itemView.apply {
|
itemView.apply {
|
||||||
@ -107,5 +129,5 @@ class LaunchersAdapter(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onChange(position: Int) = launchers.getOrNull(position)?.getBubbleText() ?: ""
|
override fun onChange(position: Int) = filteredLaunchers.getOrNull(position)?.getBubbleText() ?: ""
|
||||||
}
|
}
|
||||||
|
@ -174,6 +174,15 @@ class AllAppsFragment(context: Context, attributeSet: AttributeSet) : MyFragment
|
|||||||
setPadding(0, topPadding, 0, 0)
|
setPadding(0, topPadding, 0, 0)
|
||||||
background = ColorDrawable(context.getProperBackgroundColor())
|
background = ColorDrawable(context.getProperBackgroundColor())
|
||||||
(all_apps_grid.adapter as? LaunchersAdapter)?.updateTextColor(context.getProperTextColor())
|
(all_apps_grid.adapter as? LaunchersAdapter)?.updateTextColor(context.getProperTextColor())
|
||||||
|
|
||||||
|
search_bar.beVisibleIf(context.config.useSearchBar)
|
||||||
|
search_bar.getToolbar()?.beGone()
|
||||||
|
search_bar.updateColors()
|
||||||
|
search_bar.setupMenu()
|
||||||
|
|
||||||
|
search_bar.onSearchTextChangedListener = {
|
||||||
|
(all_apps_grid.adapter as? LaunchersAdapter)?.updateSearchQuery(it)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onAppLauncherLongPressed(x: Float, y: Float, appLauncher: AppLauncher) {
|
override fun onAppLauncherLongPressed(x: Float, y: Float, appLauncher: AppLauncher) {
|
||||||
@ -198,4 +207,13 @@ class AllAppsFragment(context: Context, attributeSet: AttributeSet) : MyFragment
|
|||||||
activity?.showHomeIconMenu(x, y, gridItem, true)
|
activity?.showHomeIconMenu(x, y, gridItem, true)
|
||||||
ignoreTouches = true
|
ignoreTouches = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun onBackPressed(): Boolean {
|
||||||
|
if (search_bar.isSearchOpen) {
|
||||||
|
search_bar.closeSearch()
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,4 +16,8 @@ class Config(context: Context) : BaseConfig(context) {
|
|||||||
var drawerColumnCount: Int
|
var drawerColumnCount: Int
|
||||||
get() = prefs.getInt(DRAWER_COLUMN_COUNT, context.resources.getInteger(R.integer.portrait_column_count))
|
get() = prefs.getInt(DRAWER_COLUMN_COUNT, context.resources.getInteger(R.integer.portrait_column_count))
|
||||||
set(drawerColumnCount) = prefs.edit().putInt(DRAWER_COLUMN_COUNT, drawerColumnCount).apply()
|
set(drawerColumnCount) = prefs.edit().putInt(DRAWER_COLUMN_COUNT, drawerColumnCount).apply()
|
||||||
|
|
||||||
|
var useSearchBar: Boolean
|
||||||
|
get() = prefs.getBoolean(USE_SEARCH_BAR, true)
|
||||||
|
set(searchBarEnabled) = prefs.edit().putBoolean(USE_SEARCH_BAR, searchBarEnabled).apply()
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ const val WIDGET_LIST_ITEMS_HOLDER = 1
|
|||||||
// shared prefs
|
// shared prefs
|
||||||
const val WAS_HOME_SCREEN_INIT = "was_home_screen_init"
|
const val WAS_HOME_SCREEN_INIT = "was_home_screen_init"
|
||||||
const val DRAWER_COLUMN_COUNT = "drawer_column_count"
|
const val DRAWER_COLUMN_COUNT = "drawer_column_count"
|
||||||
|
const val USE_SEARCH_BAR = "use_search_bar"
|
||||||
|
|
||||||
// default home screen grid size
|
// default home screen grid size
|
||||||
const val ROW_COUNT = 6
|
const val ROW_COUNT = 6
|
||||||
|
@ -170,6 +170,22 @@
|
|||||||
tools:text="3" />
|
tools:text="3" />
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:id="@+id/settings_drawer_search_holder"
|
||||||
|
style="@style/SettingsHolderTextViewOneLinerStyle"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@drawable/ripple_bottom_corners">
|
||||||
|
|
||||||
|
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
|
||||||
|
android:id="@+id/settings_show_search"
|
||||||
|
style="@style/SettingsCheckboxStyle"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/show_search" />
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</androidx.core.widget.NestedScrollView>
|
</androidx.core.widget.NestedScrollView>
|
||||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||||
|
@ -5,10 +5,16 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<com.simplemobiletools.commons.views.MySearchMenu
|
||||||
|
android:id="@+id/search_bar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
<com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller
|
<com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller
|
||||||
android:id="@+id/all_apps_fastscroller"
|
android:id="@+id/all_apps_fastscroller"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@+id/search_bar"
|
||||||
app:fastScrollEnabled="false">
|
app:fastScrollEnabled="false">
|
||||||
|
|
||||||
<com.simplemobiletools.commons.views.MyRecyclerView
|
<com.simplemobiletools.commons.views.MyRecyclerView
|
||||||
|
Loading…
x
Reference in New Issue
Block a user