-
-
Notifications
You must be signed in to change notification settings - Fork 745
Add option to set HA as launcher #5348
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
ef632b8
to
1712549
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm personally still not convinced this feature needs to be added to the companion app.
app/src/main/res/xml/preferences.xml
Outdated
@@ -37,6 +37,11 @@ | |||
</PreferenceCategory> | |||
<PreferenceCategory | |||
android:title="@string/other_settings"> | |||
<Preference |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need this amount of promotion (in settings! the first item!) for a feature 99% of users will not use?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I decided to position it there since it's somewhat related to fullscreen, screen orientation and keep screen on, in the sense that it changes how the device behaves.
I can move it below those 3.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although this largely compliments most of the apps WebView features this feels like a big behavior change for a device that not every user will want to enable on every device. Maybe a new category is a good idea for this so we can also describe why a user may want to set the app as the launcher? They may not understand that they will need to do things like updating the dashboard to add links to apps etc...
One of the reasons why its not good to list it at the top is that users may enable it on accident and that may not lead to a good experience.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another thought: make the launcher an activity-alias that can be enabled/disabled and require the user to opt-in to the setting to choose HA as a launcher (= enable the activity alias). We should avoid the possibility that users accidentally set HA as a launcher.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make the launcher an activity-alias that can be enabled/disabled
@jpelgrom I can create a new SwitchPreference for this.
Maybe a new category is a good idea for this
@dshokouhi, would it be acceptable if I add the switch and based on the state show or hide the current Preference item that navigates to the settings? The new category could be simply named "Launcher" or "Kiosk", although for it to be truly a kiosk app, a few other things need to be implemented.
Another option is to open a new page like "Manage Sensors" or "Notification History", but I'm not sure if it makes sense to have an entire page just for one option. Additionally if the app is being slowly converted to JetpackCompose, adding another fragment does not help :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dshokouhi, would it be acceptable if I add the switch and based on the state show or hide the current Preference item that navigates to the settings?
Yup sounds good with me, I like @jpelgrom suggestion to make it explicit opt-in
The new category could be simply named "Launcher" or "Kiosk", although for it to be truly a kiosk app, a few other things need to be implemented.
Could be a good start to a set of new features ;) We can maybe leave it as generic and update it if anything else gets added to compliment it.
Another option is to open a new page like "Manage Sensors" or "Notification History", but I'm not sure if it makes sense to have an entire page just for one option. Additionally if the app is being slowly converted to JetpackCompose, adding another fragment does not help :)
That is an option and in fact some of the sub settings pages have already been converted to Compose so we can interchange them. For now with just 1 option it may not make sense. However a dedicated page is a good place for an extended description if required.
@@ -58,6 +58,8 @@ import kotlinx.coroutines.sync.Mutex | |||
import kotlinx.coroutines.sync.withLock | |||
import timber.log.Timber | |||
|
|||
private const val UNKNOWN_LAUNCHER_LABEL = "unknown app" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be translated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Absolutely, thanks for pointing it out.
app/src/main/kotlin/io/homeassistant/companion/android/settings/SettingsPresenterImpl.kt
Fixed
Show fixed
Hide fixed
app/src/main/kotlin/io/homeassistant/companion/android/settings/SettingsPresenterImpl.kt
Fixed
Show fixed
Hide fixed
.../src/main/kotlin/io/homeassistant/companion/android/common/data/prefs/PrefsRepositoryImpl.kt
Fixed
Show fixed
Hide fixed
.../src/main/kotlin/io/homeassistant/companion/android/common/data/prefs/PrefsRepositoryImpl.kt
Fixed
Show fixed
Hide fixed
e5411e8
to
eed5c27
Compare
Here's an updated video of the feature: I'm not too confident about the icons and I'm open to suggestions :) |
eed5c27
to
59b0721
Compare
59b0721
to
8c153fc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good I've played with it a bit. The only thing that is a bit weird is that when your back stack is empty when you press back it reloads the app. We could capture this in the WebViewActivity, but at the same time it's kinda nice when we are in launcher mode to be able to refresh the app.
I'll let @jpelgrom the final word on the PR 👍🏻
findPreference<SwitchPreference>("enable_ha_launcher")?.let { switchPreference -> | ||
switchPreference.setOnPreferenceClickListener { | ||
findPreference<Preference>("set_launcher_app")?.isVisible = switchPreference.isChecked | ||
true | ||
} | ||
} | ||
|
||
findPreference<Preference>("set_launcher_app")?.let { | ||
it.isVisible = findPreference<SwitchPreference>("enable_ha_launcher")?.isChecked ?: false | ||
it.summary = getString(commonR.string.default_launcher_prompt_def, getDefaultLauncherInfo()) | ||
it.setOnPreferenceClickListener { | ||
val intent = Intent(Settings.ACTION_HOME_SETTINGS) | ||
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) | ||
startActivity(intent) | ||
true | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The class is already quite big (same for the function itself) I would be in favor of grouping this two findPref into one private method.
view.getPackageManager()?.setComponentEnabledSetting( | ||
launcherAliasComponent, | ||
if (enable) PackageManager.COMPONENT_ENABLED_STATE_ENABLED else PackageManager.COMPONENT_ENABLED_STATE_DISABLED, | ||
PackageManager.DONT_KILL_APP |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make sense to keep this flag when we set the state to disable?
Summary
This PR is related to #5023 where it was discussed to allow HA Companion app to become a launcher.
A new option was added to the preference settings, under "Other Settings" Preference Category.
Checklist
Screenshots
Any other notes