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