Closed Bug 1060470 Opened 11 years ago Closed 11 years ago

Screen rotation causes web view to reload

Categories

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

34 Branch
All
Android
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
Firefox 35

People

(Reporter: rnewman, Assigned: Margaret, Mentored)

References

Details

(Whiteboard: shovel-ready)

Attachments

(1 file)

Reissues the search. Usual bug!
Richard - can you give this bug some DXR-link love, so I can start telling the world about it?
Flags: needinfo?(rnewman)
I don't know that this is a good first bug, since I'm not sure exactly what we need to do to fix this :) I imagine it involves adding a android:configChanges property to the activity declaration in the manifest, and adding a onConfigurationChanged handler in MainActivity. However, if we decide to override the default config change behavior, we'll need to make sure we do the right thing to update the UI, recreating views as needed. It seems like the main problem here is that the web view reloads, so I'm updating the summary to reflect that.
Summary: Screen rotation causes activity redisplay → Screen rotation causes web view to reload
Whiteboard: [lang=java][good first bug] shovel-ready → shovel-ready
Yup, as Margaret notes, we'd mark in the manifest that we handle configuration changes, then we'd handle the configuration changes. Assuming the search activity is fragment-based, it should be very similar to the (thoroughly documented) code here: http://dxr.mozilla.org/mozilla-central/source/mobile/android/base/home/HomeFragment.java#275 perhaps with additional logic to avoid the reload.
Flags: needinfo?(rnewman)
i am interested in working with this , it would be helpful if someone could provide further detail on this .Thanks :)
Flags: needinfo?(margaret.leibovic)
(In reply to vikneshwar from comment #4) > i am interested in working with this , it would be helpful if someone could > provide further detail on this .Thanks :) I'm sorry, I should have reset the mentor earlier. I don't know more than what I mentioned in comment 2. I would have to look into this more to figure out how to fix it. I'd still be happy to review a patch or offer guidance if you try to figure this out on your own, though.
Mentor: margaret.leibovic → nobody
Flags: needinfo?(margaret.leibovic)
Actually, I started looking into this myself.
Assignee: nobody → margaret.leibovic
Here's a WIP based on rnewman's idea in comment 3: https://github.com/mozilla/fennec-search/pull/95 At first glance, this appeared to work, but then I found that onDestroyView was being called was the fragment was detached, but then onCreateView wasn't being called when it was re-attached, so the PostSearchFragment ended up in a busted state. Removing the onDestroyView implementation fixes this issue, but I don't know if that's a good way to approach this. Lucas, do you have any thoughts on the best way to address this issue?
Flags: needinfo?(lucasr.at.mozilla)
It's hard to know what's going on without looking a bit deeper into fennec-search's code but the issue you're seeing is likely caused by the fact that you're instantiating the fragments from a layout resource (i.e. using the 'fragment' in the layout file). The life-cycle is slightly different in this case. For instance, you can't detach a fragment that has been defined in a layout file. If one of the fragments really need to refresh its UI on device rotation, you can simply implement onConfigurationChanged() to re-inflate its views. Or you can add/remove fragments dynamically instead of creating them in the layout file.
Flags: needinfo?(lucasr.at.mozilla)
Adding an android:configChanges attribute in the manifest seems to fix the problem without us needing to do anything else. We don't have different layouts for portrait/landscape, and it appears the views are doing the right thing to resize themselves when the screen size changes.
Attachment #8492369 - Flags: review?(lucasr.at.mozilla)
Comment on attachment 8492369 [details] [diff] [review] Handle orientation changes in search activity Review of attachment 8492369 [details] [diff] [review]: ----------------------------------------------------------------- This will probably have to change once we start implementing a tablet-specific UI for search. But let's not worry about this now :-)
Attachment #8492369 - Flags: review?(lucasr.at.mozilla) → review+
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 35
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: