mirror of
https://github.com/SimpleMobileTools/Simple-Launcher.git
synced 2025-04-26 07:38:52 +02:00
add a Wallpapers menu button at Widgets too
This commit is contained in:
parent
647b1cce18
commit
4b9c235750
@ -6,6 +6,7 @@ import android.app.Activity
|
|||||||
import android.appwidget.AppWidgetHost
|
import android.appwidget.AppWidgetHost
|
||||||
import android.appwidget.AppWidgetManager
|
import android.appwidget.AppWidgetManager
|
||||||
import android.appwidget.AppWidgetProviderInfo
|
import android.appwidget.AppWidgetProviderInfo
|
||||||
|
import android.content.ActivityNotFoundException
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
@ -346,13 +347,14 @@ class MainActivity : SimpleActivity(), FlingListener {
|
|||||||
private fun showMainLongPressMenu(x: Float, y: Float) {
|
private fun showMainLongPressMenu(x: Float, y: Float) {
|
||||||
home_screen_grid.hideResizeLines()
|
home_screen_grid.hideResizeLines()
|
||||||
home_screen_popup_menu_anchor.x = x
|
home_screen_popup_menu_anchor.x = x
|
||||||
home_screen_popup_menu_anchor.y = y - resources.getDimension(R.dimen.long_press_anchor_button_offset_y)
|
home_screen_popup_menu_anchor.y = y - resources.getDimension(R.dimen.long_press_anchor_button_offset_y) * 2
|
||||||
val contextTheme = ContextThemeWrapper(this, getPopupMenuTheme())
|
val contextTheme = ContextThemeWrapper(this, getPopupMenuTheme())
|
||||||
PopupMenu(contextTheme, home_screen_popup_menu_anchor, Gravity.TOP or Gravity.END).apply {
|
PopupMenu(contextTheme, home_screen_popup_menu_anchor, Gravity.TOP or Gravity.END).apply {
|
||||||
inflate(R.menu.menu_home_screen)
|
inflate(R.menu.menu_home_screen)
|
||||||
setOnMenuItemClickListener { item ->
|
setOnMenuItemClickListener { item ->
|
||||||
when (item.itemId) {
|
when (item.itemId) {
|
||||||
R.id.widgets -> showWidgetsFragment()
|
R.id.widgets -> showWidgetsFragment()
|
||||||
|
R.id.wallpapers -> launchWallpapersIntent()
|
||||||
}
|
}
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
@ -409,6 +411,18 @@ class MainActivity : SimpleActivity(), FlingListener {
|
|||||||
showFragment(widgets_fragment)
|
showFragment(widgets_fragment)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun launchWallpapersIntent() {
|
||||||
|
try {
|
||||||
|
Intent(Intent.ACTION_SET_WALLPAPER).apply {
|
||||||
|
startActivity(this)
|
||||||
|
}
|
||||||
|
} catch (e: ActivityNotFoundException) {
|
||||||
|
toast(R.string.no_app_found)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
showErrorToast(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private class MyGestureListener(private val flingListener: FlingListener) : GestureDetector.SimpleOnGestureListener() {
|
private class MyGestureListener(private val flingListener: FlingListener) : GestureDetector.SimpleOnGestureListener() {
|
||||||
override fun onSingleTapUp(event: MotionEvent): Boolean {
|
override fun onSingleTapUp(event: MotionEvent): Boolean {
|
||||||
(flingListener as MainActivity).homeScreenClicked(event.x, event.y)
|
(flingListener as MainActivity).homeScreenClicked(event.x, event.y)
|
||||||
|
@ -5,4 +5,8 @@
|
|||||||
android:id="@+id/widgets"
|
android:id="@+id/widgets"
|
||||||
android:title="@string/widgets"
|
android:title="@string/widgets"
|
||||||
app:showAsAction="always" />
|
app:showAsAction="always" />
|
||||||
|
<item
|
||||||
|
android:id="@+id/wallpapers"
|
||||||
|
android:title="@string/wallpapers"
|
||||||
|
app:showAsAction="always" />
|
||||||
</menu>
|
</menu>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user