mirror of
https://github.com/SimpleMobileTools/Simple-App-Launcher.git
synced 2025-03-04 19:37:57 +01:00
lets use a different layout for icons without bottom labels
This commit is contained in:
parent
0b61b08525
commit
213216762e
@ -169,7 +169,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
||||
|
||||
private fun toggleAppName() {
|
||||
config.showAppName = !config.showAppName
|
||||
launchers_grid.adapter?.notifyDataSetChanged()
|
||||
setupAdapter(displayedLaunchers)
|
||||
}
|
||||
|
||||
private fun increaseColumnCount() {
|
||||
|
@ -4,7 +4,6 @@ import android.view.Menu
|
||||
import android.view.MotionEvent
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.recyclerview.widget.ItemTouchHelper
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller
|
||||
@ -24,7 +23,7 @@ import com.simplemobiletools.commons.interfaces.ItemTouchHelperContract
|
||||
import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener
|
||||
import com.simplemobiletools.commons.interfaces.StartReorderDragListener
|
||||
import com.simplemobiletools.commons.views.MyRecyclerView
|
||||
import kotlinx.android.synthetic.main.item_launcher.view.*
|
||||
import kotlinx.android.synthetic.main.item_launcher_label.view.*
|
||||
import java.util.*
|
||||
|
||||
class LaunchersAdapter(
|
||||
@ -69,7 +68,15 @@ class LaunchersAdapter(
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = createViewHolder(R.layout.item_launcher, parent)
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||
val layoutId = if (activity.config.showAppName) {
|
||||
R.layout.item_launcher_label
|
||||
} else {
|
||||
R.layout.item_launcher_no_label
|
||||
}
|
||||
|
||||
return createViewHolder(layoutId, parent)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||
val launcher = launchers[position]
|
||||
@ -174,11 +181,18 @@ class LaunchersAdapter(
|
||||
view.apply {
|
||||
val isSelected = selectedKeys.contains(launcher.packageName.hashCode())
|
||||
launcher_check?.beInvisibleIf(!isSelected)
|
||||
launcher_label.text = launcher.title
|
||||
launcher_label.setTextColor(textColor)
|
||||
launcher_label?.text = launcher.title
|
||||
launcher_label?.setTextColor(textColor)
|
||||
launcher_label?.beVisibleIf(activity.config.showAppName)
|
||||
launcher_icon.setImageDrawable(launcher.drawable!!)
|
||||
launcher_icon.setPadding(iconPadding, iconPadding, iconPadding, 0)
|
||||
|
||||
val bottomPadding = if (activity.config.showAppName) {
|
||||
0
|
||||
} else {
|
||||
iconPadding
|
||||
}
|
||||
|
||||
launcher_icon.setPadding(iconPadding, iconPadding, iconPadding, bottomPadding)
|
||||
launcher_drag_handle.beVisibleIf(isChangingOrder)
|
||||
if (isChangingOrder) {
|
||||
launcher_drag_handle.applyColorFilter(textColor)
|
||||
@ -193,8 +207,6 @@ class LaunchersAdapter(
|
||||
if (isSelected) {
|
||||
launcher_check?.background?.applyColorFilter(properPrimaryColor)
|
||||
}
|
||||
|
||||
launcher_label.isVisible = activity.config.showAppName
|
||||
}
|
||||
}
|
||||
|
||||
|
41
app/src/main/res/layout/item_launcher_no_label.xml
Normal file
41
app/src/main/res/layout/item_launcher_no_label.xml
Normal file
@ -0,0 +1,41 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/launcher_holder"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:padding="@dimen/small_margin">
|
||||
|
||||
<com.simplemobiletools.commons.views.MySquareImageView
|
||||
android:id="@+id/launcher_icon"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/launcher_icon_size"
|
||||
android:layout_gravity="center"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="fitCenter" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/launcher_check"
|
||||
android:layout_width="@dimen/selection_check_size"
|
||||
android:layout_height="@dimen/selection_check_size"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_margin="@dimen/small_margin"
|
||||
android:background="@drawable/circle_background"
|
||||
android:padding="@dimen/tiny_margin"
|
||||
android:src="@drawable/ic_check_vector"
|
||||
android:visibility="invisible" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/launcher_drag_handle"
|
||||
android:layout_width="@dimen/drag_handle_size"
|
||||
android:layout_height="@dimen/drag_handle_size"
|
||||
android:layout_below="@+id/launcher_check"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:padding="@dimen/small_margin"
|
||||
android:src="@drawable/ic_drag_handle_vector"
|
||||
android:visibility="gone" />
|
||||
|
||||
</RelativeLayout>
|
Loading…
x
Reference in New Issue
Block a user