mirror of
https://github.com/jrpie/Launcher.git
synced 2025-02-23 06:21:31 +01:00
Add button to choose default launcher
This commit is contained in:
parent
04c46fe429
commit
7e57d6208b
2 changed files with 45 additions and 4 deletions
|
@ -7,9 +7,13 @@ import android.content.DialogInterface
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.provider.Settings
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
|
import android.widget.Toast
|
||||||
|
import androidx.annotation.RequiresApi
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
|
||||||
|
|
||||||
|
@ -70,6 +74,29 @@ class SettingsActivity : AppCompatActivity() {
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun setLauncher(view: View) {
|
||||||
|
// on newer sdk: choose launcher
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||||
|
val callHomeSettingIntent = Intent(Settings.ACTION_HOME_SETTINGS)
|
||||||
|
startActivity(callHomeSettingIntent)
|
||||||
|
}
|
||||||
|
// on older sdk: open launcher
|
||||||
|
else {
|
||||||
|
val pm = applicationContext.packageManager
|
||||||
|
val intent: Intent? = pm.getLaunchIntentForPackage("com.sec.android.app.launcher")
|
||||||
|
|
||||||
|
if (intent!=null){
|
||||||
|
applicationContext.startActivity(intent)
|
||||||
|
} else {
|
||||||
|
Toast.makeText(
|
||||||
|
this,
|
||||||
|
"Open settings to choose an app for this action",
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Show a dialog prompting for confirmation
|
// Show a dialog prompting for confirmation
|
||||||
fun resetSettingsClick(view: View) {
|
fun resetSettingsClick(view: View) {
|
||||||
AlertDialog.Builder(this)
|
AlertDialog.Builder(this)
|
||||||
|
|
|
@ -62,6 +62,7 @@
|
||||||
android:id="@+id/btn_choose_up"
|
android:id="@+id/btn_choose_up"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:alpha=".8"
|
||||||
android:onClick="chooseUpApp"
|
android:onClick="chooseUpApp"
|
||||||
android:text="Choose App" />
|
android:text="Choose App" />
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
@ -82,6 +83,7 @@
|
||||||
android:id="@+id/btn_choose_down"
|
android:id="@+id/btn_choose_down"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:alpha=".8"
|
||||||
android:onClick="chooseDownApp"
|
android:onClick="chooseDownApp"
|
||||||
android:text="Choose App" />
|
android:text="Choose App" />
|
||||||
|
|
||||||
|
@ -103,6 +105,7 @@
|
||||||
android:id="@+id/btn_choose_left"
|
android:id="@+id/btn_choose_left"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:alpha=".8"
|
||||||
android:onClick="chooseLeftApp"
|
android:onClick="chooseLeftApp"
|
||||||
android:text="Choose App" />
|
android:text="Choose App" />
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
@ -123,6 +126,7 @@
|
||||||
android:id="@+id/btn_choose_right"
|
android:id="@+id/btn_choose_right"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:alpha=".8"
|
||||||
android:onClick="chooseRightApp"
|
android:onClick="chooseRightApp"
|
||||||
android:text="Choose App" />
|
android:text="Choose App" />
|
||||||
|
|
||||||
|
@ -144,6 +148,7 @@
|
||||||
android:id="@+id/btn_choose_volume_up"
|
android:id="@+id/btn_choose_volume_up"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:alpha=".8"
|
||||||
android:onClick="chooseVolumeUpApp"
|
android:onClick="chooseVolumeUpApp"
|
||||||
android:text="Choose App" />
|
android:text="Choose App" />
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
@ -164,6 +169,7 @@
|
||||||
android:id="@+id/btn_choose_volume_down"
|
android:id="@+id/btn_choose_volume_down"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:alpha=".8"
|
||||||
android:onClick="chooseVolumeDownApp"
|
android:onClick="chooseVolumeDownApp"
|
||||||
android:text="Choose App" />
|
android:text="Choose App" />
|
||||||
|
|
||||||
|
@ -172,13 +178,14 @@
|
||||||
</TableLayout>
|
</TableLayout>
|
||||||
|
|
||||||
<TableLayout
|
<TableLayout
|
||||||
android:id="@+id/buttons"
|
android:id="@+id/buttonsdanger"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/actionschooser">
|
app:layout_constraintTop_toBottomOf="@+id/actionschooser"
|
||||||
|
app:layout_constraintVertical_bias="0.48000002">
|
||||||
|
|
||||||
<TableRow
|
<TableRow
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -186,14 +193,21 @@
|
||||||
android:gravity="center">
|
android:gravity="center">
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/button2"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:alpha=".3"
|
||||||
android:onClick="resetSettingsClick"
|
android:onClick="resetSettingsClick"
|
||||||
android:text="Reset" />
|
android:text="Reset" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/button3"
|
android:id="@+id/button2"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:alpha=".3"
|
||||||
|
android:onClick="setLauncher"
|
||||||
|
android:text="Choose Launcher" />
|
||||||
|
|
||||||
|
<Button
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:onClick="backHome"
|
android:onClick="backHome"
|
||||||
|
|
Loading…
Add table
Reference in a new issue