|
|
Chromium Code Reviews
Description[Android] Handle different phones using different layouts for PreferenceFragment
Some types of phones (such as Google Pixel) report ClassCastException
error when it populates data for SearchEnginePreference.
The reason of this bug is because SearchEnginePreference manually sets
LayoutParams for the ListView in PreferenceFragment and some types of
phones (Nexus 6P) use LinearyLayout to hold the ListView while other
types of phones (Google Pixel) use FrameLayout to hold it.
To solve this problem, get LayoutParams of ListView and cast it to
MarginLayoutParams before setting margin values of it. Because both
LinearLayout.LayoutParams and FrameLayout.LayoutParms inherit from
MarginLayoutParams.
BUG=670297
Committed: https://crrev.com/5d384037110c1034e7a61bdbbf780c33ae0b71a3
Cr-Commit-Position: refs/heads/master@{#436133}
Patch Set 1 #
Total comments: 2
Patch Set 2 : Update based on Dan's comment. #
Total comments: 2
Patch Set 3 : Update based on Dan's comment. #Messages
Total messages: 18 (9 generated)
ltian@chromium.org changed reviewers: + dfalcantara@chromium.org
Can you take a look of this CL? Thanks!
https://codereview.chromium.org/2543023004/diff/1/chrome/android/java/src/org... File chrome/android/java/src/org/chromium/chrome/browser/preferences/SearchEnginePreference.java (right): https://codereview.chromium.org/2543023004/diff/1/chrome/android/java/src/org... chrome/android/java/src/org/chromium/chrome/browser/preferences/SearchEnginePreference.java:52: R.dimen.search_engine_list_margin_top); 1) You don't have to duplicate the two lines between the two conditionals; you should just keep them outside. 2) I'm pretty sure you really only need to do this: LayoutParams layoutParams = mListView.getLayoutParams(); layoutParams.setMargins(0, marginTop, 0, 0); You might need to additionally do this, but I don't think you do: mListView.setLayoutParams(layoutParams) but it's unlikely.
https://codereview.chromium.org/2543023004/diff/1/chrome/android/java/src/org... File chrome/android/java/src/org/chromium/chrome/browser/preferences/SearchEnginePreference.java (right): https://codereview.chromium.org/2543023004/diff/1/chrome/android/java/src/org... chrome/android/java/src/org/chromium/chrome/browser/preferences/SearchEnginePreference.java:52: R.dimen.search_engine_list_margin_top); On 2016/12/02 22:22:57, dfalcantara (check my queue) wrote: > 1) You don't have to duplicate the two lines between the two conditionals; you > should just keep them outside. > > 2) I'm pretty sure you really only need to do this: > > LayoutParams layoutParams = mListView.getLayoutParams(); > layoutParams.setMargins(0, marginTop, 0, 0); > > You might need to additionally do this, but I don't think you do: > > mListView.setLayoutParams(layoutParams) but it's unlikely. Done.
https://codereview.chromium.org/2543023004/diff/20001/chrome/android/java/src... File chrome/android/java/src/org/chromium/chrome/browser/preferences/SearchEnginePreference.java (right): https://codereview.chromium.org/2543023004/diff/20001/chrome/android/java/src... chrome/android/java/src/org/chromium/chrome/browser/preferences/SearchEnginePreference.java:55: ((FrameLayout.LayoutParams) layoutParams).setMargins(0, marginTop, 0, 0); Don't need to do this. Both FrameLayout.LayoutParams and LinearLayout.LayoutParams inherit from MarginLayoutParams: https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutPa...
Description was changed from ========== [Android] Handle different phones using different layouts for PreferenceFragment Some types of phones (such as Google Pixel) report ClassCastException error when it populates data for SearchEnginePreference. The reason of this bug is because SearchEnginePreference manually sets LayoutParams for the ListView in PreferenceFragment and some types of phones (Nexus 6P) use LinearyLayout to hold the ListView while other types of phones (Google Pixel) use FrameLayout to hold it. To solve this problem, before setting LayoutParams, first checking the type of layout holding the ListView, then using different types of LayoutParams for different types of layouts. BUG=670297 ========== to ========== [Android] Handle different phones using different layouts for PreferenceFragment Some types of phones (such as Google Pixel) report ClassCastException error when it populates data for SearchEnginePreference. The reason of this bug is because SearchEnginePreference manually sets LayoutParams for the ListView in PreferenceFragment and some types of phones (Nexus 6P) use LinearyLayout to hold the ListView while other types of phones (Google Pixel) use FrameLayout to hold it. To solve this problem, get LayoutParams of ListView and cast it to MarginLayoutParams before setting margin values of it. Because both LinearLayout.LayoutParams and FrameLayout.LayoutParms inherit from MarginLayoutParams. BUG=670297 ==========
https://codereview.chromium.org/2543023004/diff/20001/chrome/android/java/src... File chrome/android/java/src/org/chromium/chrome/browser/preferences/SearchEnginePreference.java (right): https://codereview.chromium.org/2543023004/diff/20001/chrome/android/java/src... chrome/android/java/src/org/chromium/chrome/browser/preferences/SearchEnginePreference.java:55: ((FrameLayout.LayoutParams) layoutParams).setMargins(0, marginTop, 0, 0); On 2016/12/02 22:39:55, dfalcantara (check my queue) wrote: > Don't need to do this. Both FrameLayout.LayoutParams and > LinearLayout.LayoutParams inherit from MarginLayoutParams: > > https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutPa... Done.
lgtm
The CQ bit was checked by ltian@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
The CQ bit was checked by ltian@chromium.org
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
CQ is committing da patch.
Bot data: {"patchset_id": 40001, "attempt_start_ts": 1480728935764130,
"parent_rev": "e836c9ddf2a82ccd4e8a5070ecb3dda31c9197a0", "commit_rev":
"73b252333ba3d51f87a4f61f21060dca275ed72c"}
Message was sent while issue was closed.
Committed patchset #3 (id:40001)
Message was sent while issue was closed.
Description was changed from ========== [Android] Handle different phones using different layouts for PreferenceFragment Some types of phones (such as Google Pixel) report ClassCastException error when it populates data for SearchEnginePreference. The reason of this bug is because SearchEnginePreference manually sets LayoutParams for the ListView in PreferenceFragment and some types of phones (Nexus 6P) use LinearyLayout to hold the ListView while other types of phones (Google Pixel) use FrameLayout to hold it. To solve this problem, get LayoutParams of ListView and cast it to MarginLayoutParams before setting margin values of it. Because both LinearLayout.LayoutParams and FrameLayout.LayoutParms inherit from MarginLayoutParams. BUG=670297 ========== to ========== [Android] Handle different phones using different layouts for PreferenceFragment Some types of phones (such as Google Pixel) report ClassCastException error when it populates data for SearchEnginePreference. The reason of this bug is because SearchEnginePreference manually sets LayoutParams for the ListView in PreferenceFragment and some types of phones (Nexus 6P) use LinearyLayout to hold the ListView while other types of phones (Google Pixel) use FrameLayout to hold it. To solve this problem, get LayoutParams of ListView and cast it to MarginLayoutParams before setting margin values of it. Because both LinearLayout.LayoutParams and FrameLayout.LayoutParms inherit from MarginLayoutParams. BUG=670297 Committed: https://crrev.com/5d384037110c1034e7a61bdbbf780c33ae0b71a3 Cr-Commit-Position: refs/heads/master@{#436133} ==========
Message was sent while issue was closed.
Patchset 3 (id:??) landed as https://crrev.com/5d384037110c1034e7a61bdbbf780c33ae0b71a3 Cr-Commit-Position: refs/heads/master@{#436133} |
