Show application on lock screen #1928

Merged
starsep merged 3 commits from show_on_lock_screen into master 2022-02-08 05:59:13 +00:00
starsep commented 2022-01-23 16:28:26 +00:00 (Migrated from github.com)

Allows to show app on lock screen, enabled in the settings.
Closes #558

For me it's useful while using a phone in navigation mode on a bicycle inside phone case/enclosure.

Description of steps in the video:

  1. Settings shown -> Show application on lock screen disabled.
  2. I click power button twice -> screen is turned off and then lock screen is shown.
  3. I unlock the phone.
  4. Show application on lock screen enabled.
  5. I click power button twice -> screen blinks and instead of lock screen Organic Maps is shown.
  6. I move the map a bit to show that it is possible to use the app.
  7. I make a gesture to show home (equivalent to clicking middle onscreen button).
  8. Lock screen now is shown (because I tried to switch to a different app than Organic Maps).

https://user-images.githubusercontent.com/2798728/152066003-0085a98f-45a1-4377-9abd-f77627e60b3f.mp4

Allows to show app on lock screen, enabled in the settings. Closes #558 For me it's useful while using a phone in navigation mode on a bicycle inside phone case/enclosure. Description of steps in the video: 1. Settings shown -> `Show application on lock screen` disabled. 2. I click power button twice -> screen is turned off and then lock screen is shown. 3. I unlock the phone. 4. `Show application on lock screen` enabled. 5. I click power button twice -> screen blinks and instead of lock screen Organic Maps is shown. 6. I move the map a bit to show that it is possible to use the app. 7. I make a gesture to show home (equivalent to clicking middle onscreen button). 8. Lock screen now is shown (because I tried to switch to a different app than Organic Maps). https://user-images.githubusercontent.com/2798728/152066003-0085a98f-45a1-4377-9abd-f77627e60b3f.mp4
biodranik (Migrated from github.com) reviewed 2022-01-23 21:03:49 +00:00
biodranik (Migrated from github.com) commented 2022-01-23 21:03:12 +00:00

When is this case possible?

When is this case possible?
starsep (Migrated from github.com) reviewed 2022-01-23 21:11:05 +00:00
starsep (Migrated from github.com) commented 2022-01-23 21:11:05 +00:00

I think only if there is a bug: either called before preferences have been initialized or there is no such preference in xml defined.
I copied it from other preference case

I think only if there is a bug: either called before preferences have been initialized or there is no such preference in xml defined. I copied it from other preference case
biodranik (Migrated from github.com) reviewed 2022-01-23 21:26:31 +00:00
biodranik (Migrated from github.com) commented 2022-01-23 21:26:31 +00:00

I would prefer a clear crash if it is caused by the wrong code instead of silent return and complaining users. What does git blame say for another preference case?

I would prefer a clear crash if it is caused by the wrong code instead of silent return and complaining users. What does git blame say for another preference case?
starsep (Migrated from github.com) reviewed 2022-01-23 21:35:06 +00:00
starsep (Migrated from github.com) commented 2022-01-23 21:35:06 +00:00

Checking for nulls was added in 3547acb16c

Checking for nulls was added in 3547acb16c60d24008a0d081813a1c45e1434576
biodranik (Migrated from github.com) reviewed 2022-01-23 22:04:55 +00:00
biodranik (Migrated from github.com) commented 2022-01-23 22:04:55 +00:00

This could be related: https://github.com/mapsme/omim/pull/4558#discussion_r88602086

This check looks unnecessary for me, and it would be great to find this bug (if it's still there).

A TODO about removing this check (everywhere) could be added, or you can do it in another commit.

This could be related: https://github.com/mapsme/omim/pull/4558#discussion_r88602086 This check looks unnecessary for me, and it would be great to find this bug (if it's still there). A TODO about removing this check (everywhere) could be added, or you can do it in another commit.
rtsisyk reviewed 2022-02-01 09:05:53 +00:00

Hi @starsep, thanks for the contribution! I have tried this patch on my Android 11 and Android 12 devices and found absolutely no difference with this option enabled. I don't see the app on the lock screen.

According to documentation, this flag is deprecated in API level 27.

Does it work for you? What version of Android do you use? Please attach a video, if you can. Thanks!

Hi @starsep, thanks for the contribution! I have tried this patch on my Android 11 and Android 12 devices and found absolutely no difference with this option enabled. I don't see the app on the lock screen. According to documentation, [this flag is deprecated](https://developer.android.com/reference/android/view/WindowManager.LayoutParams#FLAG_SHOW_WHEN_LOCKED) in API level 27. Does it work for you? What version of Android do you use? Please attach a video, if you can. Thanks!
biodranik (Migrated from github.com) reviewed 2022-02-01 10:32:16 +00:00
biodranik (Migrated from github.com) commented 2022-02-01 10:32:16 +00:00

Ideally, the code should use a non-deprecated flag on 27+

Ideally, the code should use a non-deprecated flag on 27+
starsep (Migrated from github.com) reviewed 2022-02-01 12:09:29 +00:00
starsep (Migrated from github.com) commented 2022-02-01 12:09:29 +00:00

Flag is deprecated because setShowWhenLocked has been added.
I use it just above for API 27+. This approach allows to support all Android versions.

I use Android 11, I will share video in the evening.

Flag is deprecated because `setShowWhenLocked` has been added. I use it just above for API 27+. This approach allows to support all Android versions. I use Android 11, I will share video in the evening.
starsep (Migrated from github.com) reviewed 2022-02-01 23:08:59 +00:00
starsep (Migrated from github.com) commented 2022-02-01 23:08:59 +00:00

I added video in the description of pull request

I added video in the description of pull request
biodranik (Migrated from github.com) reviewed 2022-02-02 00:16:07 +00:00
biodranik (Migrated from github.com) commented 2022-02-02 00:16:07 +00:00

Shouldn't flags be set once in onCreate?

Shouldn't flags be set once in onCreate?
biodranik (Migrated from github.com) requested changes 2022-02-02 00:52:47 +00:00
biodranik (Migrated from github.com) left a comment

Thank you, I tested and it works well! The most confusing part was the wording, so even we, developers, didn't understand that feature :) I tried to reword the setting to make it more clear for our users.

Thank you, I tested and it works well! The most confusing part was the wording, so even we, developers, didn't understand that feature :) I tried to reword the setting to make it more clear for our users.
biodranik (Migrated from github.com) commented 2022-02-02 00:28:53 +00:00
    en = Show Organic Maps on the lock screen
    be = Паказваць Organic Maps на экране блакіроўкі
```suggestion en = Show Organic Maps on the lock screen be = Паказваць Organic Maps на экране блакіроўкі ```
biodranik (Migrated from github.com) commented 2022-02-02 00:35:32 +00:00
    pl = Pokazuj Organic Maps na ekranie blokady
    ru = Показывать Organic Maps на экране блокировки
    uk = Показувати Organic Maps на заблокованому екрані
```suggestion pl = Pokazuj Organic Maps na ekranie blokady ru = Показывать Organic Maps на экране блокировки uk = Показувати Organic Maps на заблокованому екрані ```
biodranik (Migrated from github.com) commented 2022-02-02 00:51:27 +00:00
    en = When enabled, you don't need to unlock your device every time while the app is running.
    be = Калі ўключана, вам не трэба разблакіраваць прыладу кожны раз падчас працы дадатку.
    pl = Po włączeniu nie musisz odblokowywać urządzenia za każdym razem, gdy aplikacja jest uruchomiona.
    ru = Если эта функция включена, вам не нужно каждый раз разблокировать устройство во время работы приложения.
    uk = Якщо ввімкнено, вам не потрібно щоразу розблоковувати пристрій під час роботи програми.
```suggestion en = When enabled, you don't need to unlock your device every time while the app is running. be = Калі ўключана, вам не трэба разблакіраваць прыладу кожны раз падчас працы дадатку. pl = Po włączeniu nie musisz odblokowywać urządzenia za każdym razem, gdy aplikacja jest uruchomiona. ru = Если эта функция включена, вам не нужно каждый раз разблокировать устройство во время работы приложения. uk = Якщо ввімкнено, вам не потрібно щоразу розблоковувати пристрій під час роботи програми. ```
rtsisyk requested changes 2022-02-05 09:25:48 +00:00
rtsisyk left a comment
Owner

I don't understand how to use this feature. It doesn't work on my Android 11/Android 12 device. Please help.

I don't understand how to use this feature. It doesn't work on my Android 11/Android 12 device. Please help.

Thanks for the video. I still don't see any UX changes on my Android 11/Android 12 devices. I lock the screen while running the app and nothing happens. I see absolutely no difference with or without flag enabled.

Thanks for the video. I still don't see any UX changes on my Android 11/Android 12 devices. I lock the screen while running the app and nothing happens. I see absolutely no difference with or without flag enabled.
biodranik commented 2022-02-05 12:36:46 +00:00 (Migrated from github.com)

I don't understand how to use this feature. It doesn't work on my Android 11/Android 12 device. Please help.

@rtsisyk

When this setting is OFF:

  1. Run the OM app.
  2. Press the lock button to lock the device.
  3. Press the lock button to unlock the device.
  4. Input your password/gesture/fingerprint/eyescan
  5. See/use OM app.

When this setting is ON:

  1. Run the OM app.
  2. Press the lock button to lock the device.
  3. Press the lock button to unlock the device.
  4. See/use OM app.

There is no "unlock your device with your … " step 4. Please confirm that you tried it and what actually happens on your devices.

> I don't understand how to use this feature. It doesn't work on my Android 11/Android 12 device. Please help. @rtsisyk When this setting is OFF: 1. Run the OM app. 2. Press the lock button to lock the device. 3. Press the lock button to unlock the device. 4. Input your password/gesture/fingerprint/eyescan 5. See/use OM app. When this setting is ON: 1. Run the OM app. 2. Press the lock button to lock the device. 3. Press the lock button to unlock the device. 4. See/use OM app. There is no "unlock your device with your … " step 4. Please confirm that you tried it and what actually happens on your devices.
rtsisyk approved these changes 2022-02-07 06:42:35 +00:00
rtsisyk left a comment
Owner

It finally works for me after playing with security settings on the device. Good feature! My proposal is to enable this feature globally without adding new configuration options. Do we need a config option at all?

It finally works for me after playing with security settings on the device. Good feature! My proposal is to enable this feature globally without adding new configuration options. Do we need a config option at all?
@ -77,2 +77,4 @@
android:defaultValue="false"
android:order="16"/>
<SwitchPreferenceCompat

Do we need this option at all? Just enable this feature by default without adding the option.

Do we need this option at all? Just enable this feature by default without adding the option.

I was able to get it working after playing with "Lock" settings on Samsung. Good feature, thanks!

I was able to get it working after playing with "Lock" settings on Samsung. Good feature, thanks!
biodranik (Migrated from github.com) reviewed 2022-02-07 18:21:19 +00:00
@ -77,2 +77,4 @@
android:defaultValue="false"
android:order="16"/>
<SwitchPreferenceCompat
biodranik (Migrated from github.com) commented 2022-02-07 18:21:18 +00:00

We need it for security.

We need it for security.
biodranik (Migrated from github.com) approved these changes 2022-02-07 18:22:42 +00:00
biodranik (Migrated from github.com) left a comment

@starsep can you please fix the suggestions? We plan to make a release soon.
Or we can help if you're busy.

@starsep can you please fix the suggestions? We plan to make a release soon. Or we can help if you're busy.
starsep (Migrated from github.com) reviewed 2022-02-07 18:27:15 +00:00
@ -77,2 +77,4 @@
android:defaultValue="false"
android:order="16"/>
<SwitchPreferenceCompat
starsep (Migrated from github.com) commented 2022-02-07 18:27:15 +00:00

I also think it should be configurable. This behaviour is surprising to the user. Therefore I think it should be opt-in and preference title/description is good place to let user know what will happen once enabled.

I also think it should be configurable. This behaviour is surprising to the user. Therefore I think it should be opt-in and preference title/description is good place to let user know what will happen once enabled.
starsep commented 2022-02-07 18:32:32 +00:00 (Migrated from github.com)

@starsep can you please fix the suggestions? We plan to make a release soon. Or we can help if you're busy.

I will fix them, I am indeed a bit busy. The only one which seems to need not-trivial effort is checking for nulls.
I agree it would be great long-term to check whether it's needed and find a bug if it still can be triggered.
Maybe let's do that as a follow-up and just check for null for now? I would just create separate issue to explain this problem.

> @starsep can you please fix the suggestions? We plan to make a release soon. Or we can help if you're busy. I will fix them, I am indeed a bit busy. The only one which seems to need not-trivial effort is checking for nulls. I agree it would be great long-term to check whether it's needed and find a bug if it still can be triggered. Maybe let's do that as a follow-up and just check for null for now? I would just create separate issue to explain this problem.
starsep (Migrated from github.com) reviewed 2022-02-07 23:36:56 +00:00
starsep (Migrated from github.com) commented 2022-02-07 23:36:56 +00:00

I think it's needed.
Such scenario

  1. Preference is off
  2. Open settings
  3. Enable preference
  4. Go back to map activity
  5. I believe onCreate wouldn't be called and therefore flags are in a state before preference change.
    As always with questions about Android/Activity lifecycle it's not obvious.
    I haven't actually tested whether onCreate is called - I think it would be only if the system decided to kill this activity which shouldn't be the case for an active app.
I think it's needed. Such scenario 1. Preference is off 2. Open settings 3. Enable preference 4. Go back to map activity 5. I believe `onCreate` wouldn't be called and therefore flags are in a state before preference change. As always with questions about Android/Activity lifecycle it's not obvious. I haven't actually tested whether `onCreate` is called - I think it would be only if the system decided to kill this activity which shouldn't be the case for an active app.
starsep (Migrated from github.com) reviewed 2022-02-07 23:41:05 +00:00
starsep (Migrated from github.com) commented 2022-02-07 23:41:04 +00:00

I added TODO and created an issue organicmaps/organicmaps#2049. It would be done in a separate PR. Is it ok?

I added TODO and created an issue https://git.omaps.dev/organicmaps/organicmaps/issues/2049. It would be done in a separate PR. Is it ok?
This repo is archived. You cannot comment on pull requests.
No labels
Accessibility
Accessibility
Address
Address
Android
Android
Android Auto
Android Auto
Android Automotive (AAOS)
Android Automotive (AAOS)
API
API
AppGallery
AppGallery
AppStore
AppStore
Battery and Performance
Battery and Performance
Blocker
Blocker
Bookmarks and Tracks
Bookmarks and Tracks
Borders
Borders
Bug
Bug
Build
Build
CarPlay
CarPlay
Classificator
Classificator
Community
Community
Core
Core
CrashReports
CrashReports
Cycling
Cycling
Desktop
Desktop
DevEx
DevEx
DevOps
DevOps
dev_sandbox
dev_sandbox
Directions
Directions
Documentation
Documentation
Downloader
Downloader
Drape
Drape
Driving
Driving
Duplicate
Duplicate
Editor
Editor
Elevation
Elevation
Enhancement
Enhancement
Epic
Epic
External Map Datasets
External Map Datasets
F-Droid
F-Droid
Fonts
Fonts
Frequently User Reported
Frequently User Reported
Fund
Fund
Generator
Generator
Good first issue
Good first issue
Google Play
Google Play
GPS
GPS
GSoC
GSoC
iCloud
iCloud
Icons
Icons
iOS
iOS
Legal
Legal
Linux Desktop
Linux Desktop
Linux packaging
Linux packaging
Linux Phone
Linux Phone
Mac OS
Mac OS
Map Data
Map Data
Metro
Metro
Navigation
Navigation
Need Feedback
Need Feedback
Night Mode
Night Mode
NLnet 2024-06-281
NLnet 2024-06-281
No Feature Parity
No Feature Parity
Opening Hours
Opening Hours
Outdoors
Outdoors
POI Info
POI Info
Privacy
Privacy
Public Transport
Public Transport
Raw Idea
Raw Idea
Refactoring
Refactoring
Regional
Regional
Regression
Regression
Releases
Releases
RoboTest
RoboTest
Route Planning
Route Planning
Routing
Routing
Ruler
Ruler
Search
Search
Security
Security
Styles
Styles
Tests
Tests
Track Recording
Track Recording
Translations
Translations
TTS
TTS
UI
UI
UX
UX
Walk Navigation
Walk Navigation
Watches
Watches
Web
Web
Wikipedia
Wikipedia
Windows
Windows
Won't fix
Won't fix
World Map
World Map
No milestone
No project
No assignees
2 participants
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: organicmaps/organicmaps-tmp#1928
No description provided.