Skip to content

Commit 46fca71

Browse files
feat(settings): add 'Exit mLauncher' option to switch to default launcher temporarily
Added a new settings item allowing users to exit mLauncher and temporarily switch to their device's default launcher. Pressing Home brings the user back to mLauncher.
1 parent 1ad3404 commit 46fca71

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

app/src/main/java/com/github/droidworksstudio/mlauncher/ui/SettingsFragment.kt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package com.github.droidworksstudio.mlauncher.ui
22

33
import android.app.admin.DevicePolicyManager
44
import android.content.ComponentName
5+
import android.content.Intent
56
import android.content.Context
67
import android.os.Build
78
import android.os.Bundle
@@ -199,6 +200,18 @@ class SettingsFragment : Fragment() {
199200
showAdvancedSettings()
200201
},
201202
)
203+
204+
SettingsHomeItem(
205+
title = stringResource(R.string.settings_exit_mlauncher_title),
206+
description = stringResource(R.string.settings_exit_mlauncher_description),
207+
imageVector = ImageVector.vectorResource(id = R.drawable.ic_exit),
208+
titleFontSize = titleFontSize,
209+
descriptionFontSize = descriptionFontSize,
210+
iconSize = iconSize,
211+
onClick = {
212+
exitLauncher()
213+
},
214+
)
202215
}
203216
}
204217

@@ -295,4 +308,12 @@ class SettingsFragment : Fragment() {
295308
R.id.action_settingsFragment_to_settingsAdvancedFragment,
296309
)
297310
}
311+
312+
private fun exitLauncher() {
313+
val intent = Intent(Intent.ACTION_MAIN).apply {
314+
addCategory(Intent.CATEGORY_HOME)
315+
flags = Intent.FLAG_ACTIVITY_NEW_TASK
316+
}
317+
startActivity(Intent.createChooser(intent, "Choose your launcher"))
318+
}
298319
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:autoMirrored="true" android:height="24dp" android:tint="#000000" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">
2+
3+
<path android:fillColor="@android:color/white" android:pathData="M10.09,15.59L11.5,17l5,-5 -5,-5 -1.41,1.41L12.67,11H3v2h9.67l-2.58,2.59zM19,3H5c-1.11,0 -2,0.9 -2,2v4h2V5h14v14H5v-4H3v4c0,1.1 0.89,2 2,2h14c1.1,0 2,-0.9 2,-2V5c0,-1.1 -0.9,-2 -2,-2z"/>
4+
5+
</vector>

app/src/main/res/values/strings.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020

2121
<string name="settings_advanced_title">Advanced</string>
2222

23+
<string name="settings_exit_mlauncher_title">Exit mLauncher</string>
24+
<string name="settings_exit_mlauncher_description">Switch to your default launcher temporarily.</string>
25+
26+
2327
<!-- Strings used for features settings -->
2428
<string name="features_settings_title">Features</string>
2529

@@ -246,4 +250,4 @@
246250
<string name="toast_private_space_locked">Private space locked</string>
247251
<string name="toast_private_space_unlocked">Private space unlocked</string>
248252
<string name="toast_private_space_not_available">Private space is not available</string>
249-
</resources>
253+
</resources>

0 commit comments

Comments
 (0)