mirror of
https://github.com/SimpleMobileTools/Simple-App-Launcher.git
synced 2025-04-01 12:00:12 +02:00
scale icon sizes depending on column count
This commit is contained in:
parent
e6fde9f487
commit
9341817da2
app/src/main
kotlin/com/simplemobiletools/applauncher
res
@ -174,6 +174,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
||||
private fun columnCountChanged() {
|
||||
invalidateOptionsMenu()
|
||||
getGridAdapter()?.apply {
|
||||
calculateIconWidth()
|
||||
notifyItemRangeChanged(0, launchers.size)
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ import com.simplemobiletools.commons.dialogs.ConfirmationDialog
|
||||
import com.simplemobiletools.commons.extensions.applyColorFilter
|
||||
import com.simplemobiletools.commons.extensions.beInvisibleIf
|
||||
import com.simplemobiletools.commons.extensions.beVisibleIf
|
||||
import com.simplemobiletools.commons.extensions.realScreenSize
|
||||
import com.simplemobiletools.commons.helpers.SORT_BY_CUSTOM
|
||||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||
import com.simplemobiletools.commons.interfaces.ItemMoveCallback
|
||||
@ -35,10 +36,12 @@ class LaunchersAdapter(
|
||||
) : MyRecyclerViewAdapter(activity, recyclerView, itemClick), ItemTouchHelperContract, RecyclerViewFastScroller.OnPopupTextUpdate {
|
||||
|
||||
private var isChangingOrder = false
|
||||
private var iconPadding = 0
|
||||
private var startReorderDragListener: StartReorderDragListener
|
||||
|
||||
init {
|
||||
setupDragListener(true)
|
||||
calculateIconWidth()
|
||||
|
||||
val touchHelper = ItemTouchHelper(ItemMoveCallback(this, true))
|
||||
touchHelper.attachToRecyclerView(recyclerView)
|
||||
@ -130,6 +133,11 @@ class LaunchersAdapter(
|
||||
}
|
||||
}
|
||||
|
||||
fun calculateIconWidth() {
|
||||
val iconWidth = activity.realScreenSize.x / activity.config.columnCnt
|
||||
iconPadding = (iconWidth * 0.1f).toInt()
|
||||
}
|
||||
|
||||
private fun askConfirmRemove() {
|
||||
ConfirmationDialog(activity, "", R.string.remove_explanation, R.string.ok, R.string.cancel) {
|
||||
activity.config.wasRemoveInfoShown = true
|
||||
@ -166,6 +174,7 @@ class LaunchersAdapter(
|
||||
launcher_label.text = launcher.title
|
||||
launcher_label.setTextColor(textColor)
|
||||
launcher_icon.setImageDrawable(launcher.drawable!!)
|
||||
launcher_icon.setPadding(iconPadding, iconPadding, iconPadding, 0)
|
||||
|
||||
launcher_drag_handle.beVisibleIf(isChangingOrder)
|
||||
if (isChangingOrder) {
|
||||
|
@ -6,25 +6,25 @@
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:paddingLeft="@dimen/small_margin"
|
||||
android:paddingStart="@dimen/small_margin"
|
||||
android:paddingTop="@dimen/medium_margin"
|
||||
android:paddingRight="@dimen/small_margin"
|
||||
android:paddingEnd="@dimen/small_margin"
|
||||
android:paddingBottom="@dimen/small_margin">
|
||||
|
||||
<ImageView
|
||||
<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:padding="@dimen/tiny_margin" />
|
||||
android:layout_gravity="center_horizontal|bottom" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/launcher_label"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/launcher_icon"
|
||||
android:layout_marginTop="@dimen/tiny_margin"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center_horizontal|top"
|
||||
android:maxLines="2"
|
||||
android:textSize="@dimen/smaller_text_size" />
|
||||
|
||||
<ImageView
|
||||
|
@ -1,3 +1,3 @@
|
||||
<resources>
|
||||
<integer name="column_count">5</integer>
|
||||
<integer name="column_count">6</integer>
|
||||
</resources>
|
||||
|
@ -1,4 +1,4 @@
|
||||
<resources>
|
||||
<integer name="default_sorting">2048</integer>
|
||||
<integer name="column_count">4</integer>
|
||||
<integer name="column_count">5</integer>
|
||||
</resources>
|
||||
|
Loading…
x
Reference in New Issue
Block a user