mirror of
https://github.com/jrpie/Launcher.git
synced 2025-06-07 17:59:54 +02:00
remove unused imports/functions/variables, improve naming convention, remove unused widget context
This commit is contained in:
parent
956ad9795c
commit
ced2e30531
14 changed files with 17 additions and 37 deletions
|
@ -28,7 +28,7 @@ import kotlinx.coroutines.launch
|
|||
import kotlin.system.exitProcess
|
||||
|
||||
|
||||
const val APP_WIDGET_HOST_ID = 42;
|
||||
const val APP_WIDGET_HOST_ID = 42
|
||||
|
||||
|
||||
class Application : android.app.Application() {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package de.jrpie.android.launcher.actions
|
||||
|
||||
import android.content.Context
|
||||
import android.hardware.camera2.CameraAccessException
|
||||
import android.hardware.camera2.CameraCharacteristics
|
||||
import android.hardware.camera2.CameraManager
|
||||
import android.os.Build
|
||||
|
|
|
@ -6,7 +6,6 @@ import android.widget.Button
|
|||
import androidx.appcompat.app.AlertDialog
|
||||
import de.jrpie.android.launcher.BuildConfig
|
||||
import de.jrpie.android.launcher.R
|
||||
import de.jrpie.android.launcher.actions.lock.LauncherAccessibilityService
|
||||
import de.jrpie.android.launcher.preferences.LauncherPreferences
|
||||
|
||||
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
package de.jrpie.android.launcher.preferences.legacy
|
||||
|
||||
import android.content.Context
|
||||
import de.jrpie.android.launcher.Application
|
||||
import de.jrpie.android.launcher.preferences.LauncherPreferences
|
||||
import de.jrpie.android.launcher.preferences.PREFERENCE_VERSION
|
||||
import de.jrpie.android.launcher.widgets.ClockWidget
|
||||
import de.jrpie.android.launcher.widgets.WidgetPanel
|
||||
import de.jrpie.android.launcher.widgets.WidgetPosition
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package de.jrpie.android.launcher.ui
|
||||
|
||||
import android.app.AlertDialog
|
||||
import android.app.Service
|
||||
import android.content.Context
|
||||
import android.content.pm.LauncherApps
|
||||
import android.content.pm.LauncherApps.PinItemRequest
|
||||
|
@ -45,7 +44,7 @@ class PinShortcutActivity : AppCompatActivity(), UIObject {
|
|||
binding = ActivityPinShortcutBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
||||
val launcherApps = getSystemService(Service.LAUNCHER_APPS_SERVICE) as LauncherApps
|
||||
val launcherApps = getSystemService(LAUNCHER_APPS_SERVICE) as LauncherApps
|
||||
|
||||
val request = launcherApps.getPinItemRequest(intent)
|
||||
this.request = request
|
||||
|
|
|
@ -237,9 +237,4 @@ class AppsRecyclerAdapter(
|
|||
appFilter.favoritesVisibility = v
|
||||
updateAppsList()
|
||||
}
|
||||
|
||||
fun setHiddenAppsVisibility(v: AppFilter.Companion.AppSetVisibility) {
|
||||
appFilter.hiddenVisibility = v
|
||||
updateAppsList()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -96,7 +96,6 @@ class ListFragmentApps : Fragment(), UIObject {
|
|||
if (LauncherPreferences.functionality().searchAutoCloseKeyboard()) {
|
||||
addOnScrollListener(object : RecyclerView.OnScrollListener() {
|
||||
var totalDy: Int = 0
|
||||
var threshold = (resources.displayMetrics.density * 100).toInt()
|
||||
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
|
||||
totalDy += dy
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@ import android.view.LayoutInflater
|
|||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.fragment.app.Fragment
|
||||
import de.jrpie.android.launcher.BuildConfig.VERSION_CODE
|
||||
import de.jrpie.android.launcher.databinding.Tutorial5FinishBinding
|
||||
import de.jrpie.android.launcher.preferences.LauncherPreferences
|
||||
import de.jrpie.android.launcher.requestNotificationPermission
|
||||
|
|
|
@ -61,7 +61,7 @@ open class WidgetContainerView(
|
|||
it.value.y + it.value.height
|
||||
).contains(position) == true
|
||||
}.any {
|
||||
Widget.byId(context, it.key)?.allowInteraction == false
|
||||
Widget.byId(it.key)?.allowInteraction == false
|
||||
}
|
||||
}
|
||||
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
|
||||
|
|
|
@ -9,7 +9,6 @@ import android.widget.EditText
|
|||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import de.jrpie.android.launcher.Application
|
||||
import de.jrpie.android.launcher.R
|
||||
import de.jrpie.android.launcher.databinding.ActivityManageWidgetPanelsBinding
|
||||
import de.jrpie.android.launcher.preferences.LauncherPreferences
|
||||
|
|
|
@ -5,7 +5,6 @@ import android.appwidget.AppWidgetManager
|
|||
import android.content.Intent
|
||||
import android.content.SharedPreferences
|
||||
import android.content.res.Resources
|
||||
import android.graphics.Rect
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.ViewGroup
|
||||
|
@ -21,7 +20,6 @@ import de.jrpie.android.launcher.widgets.GRID_SIZE
|
|||
import de.jrpie.android.launcher.widgets.WidgetPanel
|
||||
import de.jrpie.android.launcher.widgets.WidgetPosition
|
||||
import kotlin.math.max
|
||||
import kotlin.math.min
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
|
||||
|
@ -132,7 +130,6 @@ class ManageWidgetsActivity : UIObject, Activity() {
|
|||
|
||||
|
||||
private fun selectWidget() {
|
||||
val appWidgetHost = (application as Application).appWidgetHost
|
||||
startActivityForResult(
|
||||
Intent(this, SelectWidgetActivity::class.java).also {
|
||||
it.putExtra(
|
||||
|
|
|
@ -31,19 +31,19 @@ class WidgetManagerView(widgetPanelId: Int, context: Context, attrs: AttributeSe
|
|||
WidgetContainerView(widgetPanelId, context, attrs) {
|
||||
constructor(context: Context, attrs: AttributeSet?) : this(WidgetPanel.HOME.id, context, attrs)
|
||||
|
||||
val TOUCH_SLOP: Int
|
||||
val TOUCH_SLOP_SQUARE: Int
|
||||
val LONG_PRESS_TIMEOUT: Long
|
||||
val touchSlop: Int
|
||||
val touchSlopSquare: Int
|
||||
val longPressTimeout: Long
|
||||
|
||||
|
||||
private var overlayViewById = HashMap<Int, WidgetOverlayView>()
|
||||
|
||||
init {
|
||||
val configuration = ViewConfiguration.get(context)
|
||||
TOUCH_SLOP = configuration.scaledTouchSlop
|
||||
TOUCH_SLOP_SQUARE = TOUCH_SLOP * TOUCH_SLOP
|
||||
touchSlop = configuration.scaledTouchSlop
|
||||
touchSlopSquare = touchSlop * touchSlop
|
||||
|
||||
LONG_PRESS_TIMEOUT = ViewConfiguration.getLongPressTimeout().toLong()
|
||||
longPressTimeout = ViewConfiguration.getLongPressTimeout().toLong()
|
||||
}
|
||||
|
||||
|
||||
|
@ -127,14 +127,14 @@ class WidgetManagerView(widgetPanelId: Int, context: Context, attrs: AttributeSe
|
|||
view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS)
|
||||
endInteraction()
|
||||
}
|
||||
}, LONG_PRESS_TIMEOUT)
|
||||
}, longPressTimeout)
|
||||
}
|
||||
if (event.actionMasked == MotionEvent.ACTION_MOVE ||
|
||||
event.actionMasked == MotionEvent.ACTION_UP
|
||||
) {
|
||||
val distanceX = event.x - (currentGestureStart?.x ?: return true)
|
||||
val distanceY = event.y - (currentGestureStart?.y ?: return true)
|
||||
if (distanceX * distanceX + distanceY * distanceY > TOUCH_SLOP_SQUARE) {
|
||||
if (distanceX * distanceX + distanceY * distanceY > touchSlopSquare) {
|
||||
longPressHandler.removeCallbacksAndMessages(null)
|
||||
}
|
||||
val view = selectedWidgetOverlayView ?: return true
|
||||
|
@ -162,7 +162,7 @@ class WidgetManagerView(widgetPanelId: Int, context: Context, attrs: AttributeSe
|
|||
if (event.actionMasked == MotionEvent.ACTION_UP) {
|
||||
longPressHandler.removeCallbacksAndMessages(null)
|
||||
val id = selectedWidgetOverlayView?.widgetId ?: return true
|
||||
val widget = Widget.byId(context, id) ?: return true
|
||||
val widget = Widget.byId(id) ?: return true
|
||||
widget.position = newPosition
|
||||
endInteraction()
|
||||
updateWidget(widget)
|
||||
|
|
|
@ -54,7 +54,7 @@ class WidgetOverlayView : ViewGroup {
|
|||
var widgetId: Int = -1
|
||||
set(newId) {
|
||||
field = newId
|
||||
preview = Widget.byId(context, widgetId)?.getPreview(context)
|
||||
preview = Widget.byId(widgetId)?.getPreview(context)
|
||||
}
|
||||
|
||||
constructor(context: Context) : super(context)
|
||||
|
@ -93,13 +93,13 @@ class WidgetOverlayView : ViewGroup {
|
|||
}
|
||||
|
||||
fun showPopupMenu() {
|
||||
val widget = Widget.byId(context, widgetId)?: return
|
||||
val widget = Widget.byId(widgetId)?: return
|
||||
val menu = PopupMenu(context, popupAnchor)
|
||||
menu.menu.let {
|
||||
it.add(
|
||||
context.getString(R.string.widget_menu_remove)
|
||||
).setOnMenuItemClickListener { _ ->
|
||||
Widget.byId(context, widgetId)?.delete(context)
|
||||
Widget.byId(widgetId)?.delete(context)
|
||||
return@setOnMenuItemClickListener true
|
||||
}
|
||||
it.add(
|
||||
|
|
|
@ -38,10 +38,6 @@ sealed class Widget {
|
|||
)
|
||||
}
|
||||
|
||||
fun getPanel(): WidgetPanel? {
|
||||
return WidgetPanel.byId(panelId)
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
return id
|
||||
}
|
||||
|
@ -57,9 +53,9 @@ sealed class Widget {
|
|||
fun deserialize(serialized: String): Widget {
|
||||
return Json.decodeFromString(serialized)
|
||||
}
|
||||
fun byId(context: Context, id: Int): Widget? {
|
||||
fun byId(id: Int): Widget? {
|
||||
// TODO: do some caching
|
||||
return LauncherPreferences.widgets().widgets().firstOrNull() {
|
||||
return LauncherPreferences.widgets().widgets().firstOrNull {
|
||||
it.id == id
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue