Merge pull request #141 from pavelpoley/task/toggle-app-name

Allow toggling app name labels
This commit is contained in:
Tibor Kaputa 2022-06-06 23:28:59 +02:00 committed by GitHub
commit a477479e07
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 19 additions and 2 deletions

View File

@ -22,7 +22,6 @@ import com.simplemobiletools.commons.models.Release
import com.simplemobiletools.commons.views.MyGridLayoutManager
import com.simplemobiletools.commons.views.MyRecyclerView
import kotlinx.android.synthetic.main.activity_main.*
import java.util.*
class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
private val MAX_COLUMN_COUNT = 20
@ -94,6 +93,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
override fun onOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) {
R.id.sort -> showSortingDialog()
R.id.toggle_app_name -> toggleAppName()
R.id.increase_column_count -> increaseColumnCount()
R.id.reduce_column_count -> reduceColumnCount()
R.id.settings -> launchSettings()
@ -167,6 +167,11 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
}
}
private fun toggleAppName() {
config.showAppName = !config.showAppName
launchers_grid.adapter?.notifyDataSetChanged()
}
private fun increaseColumnCount() {
val newColumnCount = ++(launchers_grid.layoutManager as MyGridLayoutManager).spanCount
if (portrait) {

View File

@ -4,6 +4,7 @@ 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
@ -25,7 +26,6 @@ import com.simplemobiletools.commons.interfaces.StartReorderDragListener
import com.simplemobiletools.commons.views.MyRecyclerView
import kotlinx.android.synthetic.main.item_launcher.view.*
import java.util.*
import kotlin.collections.ArrayList
class LaunchersAdapter(
activity: SimpleActivity, val launchers: ArrayList<AppLauncher>, val listener: RefreshRecyclerViewListener?,
@ -193,6 +193,8 @@ class LaunchersAdapter(
if (isSelected) {
launcher_check?.background?.applyColorFilter(adjustedPrimaryColor)
}
launcher_label.isVisible = activity.config.showAppName
}
}

View File

@ -24,4 +24,8 @@ class Config(context: Context) : BaseConfig(context) {
var landscapeColumnCnt: Int
get() = prefs.getInt(LANDSCAPE_COLUMN_COUNT, context.resources.getInteger(R.integer.landscape_column_count))
set(landscapeColumnCnt) = prefs.edit().putInt(LANDSCAPE_COLUMN_COUNT, landscapeColumnCnt).apply()
var showAppName: Boolean
get() = prefs.getBoolean(SHOW_APP_NAME, true)
set(showAppLabel) = prefs.edit().putBoolean(SHOW_APP_NAME, showAppLabel).apply()
}

View File

@ -4,6 +4,7 @@ const val WAS_REMOVE_INFO_SHOWN = "was_remove_info_shown"
const val CLOSE_APP = "close_app"
const val PORTRAIT_COLUMN_COUNT = "portrait_column_count"
const val LANDSCAPE_COLUMN_COUNT = "landscape_column_count"
const val SHOW_APP_NAME = "show_app_name"
val predefinedPackageNames = arrayListOf(
"com.simplemobiletools.calculator",

View File

@ -6,6 +6,11 @@
android:icon="@drawable/ic_sort_vector"
android:title="@string/sort_by"
app:showAsAction="ifRoom" />
<item
android:id="@+id/toggle_app_name"
android:icon="@drawable/ic_label_vector"
android:title="@string/toggle_app_name"
app:showAsAction="ifRoom" />
<item
android:id="@+id/increase_column_count"
android:title="@string/increase_column_count"