FindMyPhone: better activity lifecycle handling
ClosedPublic

Authored by di72nn on Feb 10 2017, 1:11 PM.

Details

Summary

There are some minor problems with current implementation: if device configuration changes (screen orientation, etc.) while the "FindMyPhone" ringtone is playing, the activity gets recreated and starts to play a new ringtone again, but the first ringtone is not stopped.
Also if the user leaves the activity the ringtone continues to play, the user has no way to get back to the activity to stop it.

With these changes the ringtone starts playing when the activity becomes visible and stops when the activity is being hidden/destroyed. If the user leaves the activity (without destroying it) and then presses "Ring my phone" button again, the activity becomes visible again and starts to play the ringtone.

There are other ways to improve it that I did not touch: use a Service to play the ringtone (so not to depend on the activity's lifecycle) or handle configuration changes in activity (so it is not recreated on orientation changes).

Test Plan

Activate "Find My Phone" feature and try to turn phone or leave activity.

Diff Detail

Repository
R225 KDE Connect - Android application
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
di72nn updated this revision to Diff 11170.Feb 10 2017, 1:11 PM
di72nn retitled this revision from to FindMyPhone: better activity lifecycle handling.
di72nn updated this object.
di72nn edited the test plan for this revision. (Show Details)
di72nn added a reviewer: albertvaka.
di72nn set the repository for this revision to R225 KDE Connect - Android application.
di72nn added a project: KDE Connect.
albertvaka accepted this revision.Feb 10 2017, 1:48 PM
albertvaka edited edge metadata.

Looks good. Ship it!

This revision is now accepted and ready to land.Feb 10 2017, 1:48 PM

Do you have commit permissions?

di72nn updated this revision to Diff 11177.Feb 10 2017, 2:06 PM
di72nn edited edge metadata.

Added android:configChanges="orientation|screenSize" to keep activity intact on orientation changes.

I'm new to Phabricator so I'm not sure about my permissions. But I created my account a couple of hours ago, so I presume I have no special permissions.

Ok, no worries. I'm out for the weekend but I will merge this as soon as I get back. Thanks for the patch!

About the permissions thing: After you submit a few patches and they are accepted, you can ask for permissions so you can push them yourself. Until then, I will merge the patches you send :)

Nice, thanks for the clarification.

I forgot to ask: I need your email address in order to submit the patch!

di72nn at gmail.

This revision was automatically updated to reflect the committed changes.