mirror of
https://github.com/jrpie/Launcher.git
synced 2025-02-23 14:31:30 +01:00
feature: set launcher as home screen
This commit is contained in:
parent
977c4618ef
commit
3935afa40d
7 changed files with 49 additions and 2 deletions
|
@ -8,6 +8,11 @@
|
||||||
tools:ignore="QueryAllPackagesPermission" />
|
tools:ignore="QueryAllPackagesPermission" />
|
||||||
|
|
||||||
|
|
||||||
|
<queries>
|
||||||
|
<intent>
|
||||||
|
<category android:name="android.intent.category.HOME"/>
|
||||||
|
</intent>
|
||||||
|
</queries>
|
||||||
<application
|
<application
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
android:icon="@mipmap/ic_launcher"
|
android:icon="@mipmap/ic_launcher"
|
||||||
|
@ -40,6 +45,7 @@
|
||||||
android:screenOrientation="portrait"
|
android:screenOrientation="portrait"
|
||||||
tools:ignore="LockedOrientationActivity">
|
tools:ignore="LockedOrientationActivity">
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
|
@ -2,10 +2,12 @@ package de.jrpie.android.launcher
|
||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.app.AlertDialog
|
import android.app.AlertDialog
|
||||||
|
import android.content.ComponentName
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
|
import android.content.pm.ResolveInfo
|
||||||
import android.graphics.BlendMode
|
import android.graphics.BlendMode
|
||||||
import android.graphics.BlendModeColorFilter
|
import android.graphics.BlendModeColorFilter
|
||||||
import android.graphics.ColorMatrix
|
import android.graphics.ColorMatrix
|
||||||
|
@ -19,6 +21,7 @@ import android.os.Bundle
|
||||||
import android.os.SystemClock
|
import android.os.SystemClock
|
||||||
import android.provider.Settings
|
import android.provider.Settings
|
||||||
import android.util.DisplayMetrics
|
import android.util.DisplayMetrics
|
||||||
|
import android.util.Log
|
||||||
import android.view.KeyEvent
|
import android.view.KeyEvent
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.Window
|
import android.view.Window
|
||||||
|
@ -101,6 +104,20 @@ fun getPreferences(context: Context): SharedPreferences{
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun setDefaultHomeScreen(context: Context, checkDefault: Boolean = false) {
|
||||||
|
if(checkDefault) {
|
||||||
|
val testIntent = Intent(Intent.ACTION_MAIN)
|
||||||
|
testIntent.addCategory(Intent.CATEGORY_HOME)
|
||||||
|
val defaultHome = testIntent.resolveActivity(context.packageManager)?.packageName
|
||||||
|
if(defaultHome == context.packageName){
|
||||||
|
// Launcher is already the default home app
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val intent = Intent(Settings.ACTION_HOME_SETTINGS)
|
||||||
|
context.startActivity(intent)
|
||||||
|
}
|
||||||
|
|
||||||
/* Activity related */
|
/* Activity related */
|
||||||
|
|
||||||
fun isInstalled(uri: String, context: Context): Boolean {
|
fun isInstalled(uri: String, context: Context): Boolean {
|
||||||
|
|
|
@ -7,9 +7,8 @@ import android.view.ViewGroup
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import de.jrpie.android.launcher.PREF_SEARCH_AUTO_KEYBOARD
|
import de.jrpie.android.launcher.PREF_SEARCH_AUTO_KEYBOARD
|
||||||
import de.jrpie.android.launcher.R
|
|
||||||
import de.jrpie.android.launcher.databinding.ListAppsBinding
|
|
||||||
import de.jrpie.android.launcher.UIObject
|
import de.jrpie.android.launcher.UIObject
|
||||||
|
import de.jrpie.android.launcher.databinding.ListAppsBinding
|
||||||
import de.jrpie.android.launcher.getPreferences
|
import de.jrpie.android.launcher.getPreferences
|
||||||
import de.jrpie.android.launcher.list.ListActivity
|
import de.jrpie.android.launcher.list.ListActivity
|
||||||
import de.jrpie.android.launcher.list.forGesture
|
import de.jrpie.android.launcher.list.forGesture
|
||||||
|
|
|
@ -31,6 +31,7 @@ import de.jrpie.android.launcher.setWindowFlags
|
||||||
import de.jrpie.android.launcher.settings.intendedSettingsPause
|
import de.jrpie.android.launcher.settings.intendedSettingsPause
|
||||||
import de.jrpie.android.launcher.vibrantColor
|
import de.jrpie.android.launcher.vibrantColor
|
||||||
import de.jrpie.android.launcher.databinding.SettingsLauncherBinding
|
import de.jrpie.android.launcher.databinding.SettingsLauncherBinding
|
||||||
|
import de.jrpie.android.launcher.setDefaultHomeScreen
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -57,6 +58,7 @@ class SettingsFragmentLauncher : Fragment(), UIObject {
|
||||||
|
|
||||||
override fun applyTheme() {
|
override fun applyTheme() {
|
||||||
|
|
||||||
|
setButtonColor(binding.settingsLauncherButtonChooseHomescreen, vibrantColor)
|
||||||
setSwitchColor(binding.settingsLauncherSwitchScreenTimeout, vibrantColor)
|
setSwitchColor(binding.settingsLauncherSwitchScreenTimeout, vibrantColor)
|
||||||
setSwitchColor(binding.settingsLauncherSwitchScreenFull, vibrantColor)
|
setSwitchColor(binding.settingsLauncherSwitchScreenFull, vibrantColor)
|
||||||
setSwitchColor(binding.settingsLauncherSwitchAutoLaunch, vibrantColor)
|
setSwitchColor(binding.settingsLauncherSwitchAutoLaunch, vibrantColor)
|
||||||
|
@ -83,6 +85,10 @@ class SettingsFragmentLauncher : Fragment(), UIObject {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
binding.settingsLauncherButtonChooseHomescreen.setOnClickListener {
|
||||||
|
setDefaultHomeScreen(requireContext(), checkDefault = false)
|
||||||
|
}
|
||||||
|
|
||||||
binding.settingsLauncherButtonChooseWallpaper.setOnClickListener {
|
binding.settingsLauncherButtonChooseWallpaper.setOnClickListener {
|
||||||
// https://github.com/LineageOS/android_packages_apps_Trebuchet/blob/6caab89b21b2b91f0a439e1fd8c4510dcb255819/src/com/android/launcher3/views/OptionsPopupView.java#L271
|
// https://github.com/LineageOS/android_packages_apps_Trebuchet/blob/6caab89b21b2b91f0a439e1fd8c4510dcb255819/src/com/android/launcher3/views/OptionsPopupView.java#L271
|
||||||
val intent = Intent(Intent.ACTION_SET_WALLPAPER)
|
val intent = Intent(Intent.ACTION_SET_WALLPAPER)
|
||||||
|
|
|
@ -54,6 +54,8 @@ class TutorialFragmentFinish : Fragment(), UIObject {
|
||||||
.apply()
|
.apply()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
context?.let { setDefaultHomeScreen(it, checkDefault = true) }
|
||||||
|
|
||||||
activity?.finish()
|
activity?.finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,21 @@
|
||||||
android:paddingRight="32sp"
|
android:paddingRight="32sp"
|
||||||
tools:context=".settings.meta.SettingsFragmentMeta">
|
tools:context=".settings.meta.SettingsFragmentMeta">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="16sp"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/settings_launcher_button_choose_homescreen"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/settings_launcher_choose_homescreen"
|
||||||
|
android:textAllCaps="false" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/settings_launcher_section_appearance"
|
android:id="@+id/settings_launcher_section_appearance"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
|
@ -102,6 +102,8 @@
|
||||||
<string name="settings_launcher_choose_wallpaper">Choose a wallpaper</string>
|
<string name="settings_launcher_choose_wallpaper">Choose a wallpaper</string>
|
||||||
<string name="settings_launcher_change_wallpaper">Change wallpaper</string>
|
<string name="settings_launcher_change_wallpaper">Change wallpaper</string>
|
||||||
|
|
||||||
|
<string name="settings_launcher_choose_homescreen">Set μLauncher as home screen</string>
|
||||||
|
|
||||||
<string name="settings_launcher_section_display">Display</string>
|
<string name="settings_launcher_section_display">Display</string>
|
||||||
|
|
||||||
<string name="settings_launcher_disable_timeout">Keep screen on</string>
|
<string name="settings_launcher_disable_timeout">Keep screen on</string>
|
||||||
|
|
Loading…
Add table
Reference in a new issue