Closed Bug 1048022 Opened 10 years ago Closed 10 years ago

Only reset search activity when launched from new intent

Categories

(Firefox for Android Graveyard :: Search Activity, defect, P1)

34 Branch
ARM
Android
defect

Tracking

(firefox34 verified, fennec+)

VERIFIED FIXED
Firefox 34
Tracking Status
firefox34 --- verified
fennec + ---

People

(Reporter: aaronmt, Assigned: Margaret)

References

Details

Attachments

(1 file, 1 obsolete file)

On tap of a search result, the browser is opened. If I want to return to the search results, on back press, the search is discarded.

If I press the device home button on the search results, and return back to the search results, the results are discarded.

The search results should be retained until memory pressured by Android.
Some of this is by design, in that we want to make it easy to give users a clean slate when they're starting a new search. I think that we should give the users a clean start when they launch the search activity from the swipe-up/launcher icon/widget.

However, I agree that pressing the back button from the browser should bring the user back to the search results. We should probably also keep the results there if they use the task list to switch back to the search activity.
Flags: needinfo?(ibarlow)
Flags: needinfo?(alam)
How about this behavior:

Clean state when launching from:
  Swipe-up
  Widget
  Launch icon

Restore previous state when launching from:
  Back button
  Activity switcher
(In reply to Eric Edens [:eedens] from comment #2)
> How about this behavior:
> 
> Clean state when launching from:
>   Swipe-up
>   Widget
>   Launch icon
> 
> Restore previous state when launching from:
>   Back button
>   Activity switcher

that sounds like a good start to me
Flags: needinfo?(ibarlow)
Flags: needinfo?(alam)
Assignee: nobody → margaret.leibovic
(In reply to Eric Edens [:eedens] from comment #2)

> Restore previous state when launching from:
>   Back button
>   Activity switcher

This is easy to do - all we need to do is remove the current onResume method in MainActivity.

> Clean state when launching from:
>   Swipe-up
>   Widget
>   Launch icon

This, on the other hand, appears to be harder... We can call getIntent() to find the intent that originally started the activity, but this does not change if the app is just put in the background and brought back to the foreground.

We could finish the activity when it gets put into the background, but then we wouldn't be able to have the back button/activity switcher behavior that we want.

However, the Google search app seems to be able to do exactly what we want, so maybe there's something I'm missing.
What we want to use here in onNewIntent. That gets called when the activity gets launched from a new intent (either the "assist" swipe-up or the launch icon).

http://developer.android.com/reference/android/app/Activity.html#onNewIntent%28android.content.Intent%29
Attachment #8468605 - Flags: review?(eric.edens)
Comment on attachment 8468605 [details] [diff] [review]
Only reset search activity when launched from new intent

Review of attachment 8468605 [details] [diff] [review]:
-----------------------------------------------------------------

All of this looks good -- let's also handle the case where the activity gets killed by android.  (This will also be required if we support landscape)

This looks useful: https://developer.android.com/training/basics/activity-lifecycle/recreating.html
Attachment #8468605 - Flags: review?(eric.edens) → feedback+
Updated the patch to also restore state when the activity was killed.
Attachment #8468605 - Attachment is obsolete: true
Attachment #8468766 - Flags: review?(eric.edens)
Updating the summary to make it clearer as to what this bug is about.
Priority: -- → P1
Summary: Search activity results are discarded on device home button press and returning back from the browser → Only reset search activity when launched from new intent
tracking-fennec: ? → +
Comment on attachment 8468766 [details] [diff] [review]
(v2) Only reset search activity when launched from new intent

Review of attachment 8468766 [details] [diff] [review]:
-----------------------------------------------------------------

Looks good! Worked great on 4.x device.

There was one small issue on Gingerbread, though. Here are the repro steps:

1. Perform a search
2. From search results page, tap on hardware home button.
3. Launch search activity using launch icon

Expected behavior:
  Clean state

Actual behavior:
  Remained in post-search state

Interestingly, the state is properly reset when launched through Wes's launcher widget. 

Anyway, not a huge issue -- we can address in a followup.
Attachment #8468766 - Flags: review?(eric.edens) → review+
https://github.com/ericedens/FirefoxSearch/commit/7ada5e8ccff0b5c2746475e2cf025d933fff9c8b

fx-team is closed, but I'll land there when it re-opens.
https://hg.mozilla.org/mozilla-central/rev/e981f15c5a7d
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 34
Status: RESOLVED → VERIFIED
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: