Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(216)

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/preferences/SearchEnginePreference.java

Issue 2543023004: [Android] Handle different phones using different layouts for PreferenceFragment (Closed)
Patch Set: Update based on Dan's comment. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.chrome.browser.preferences; 5 package org.chromium.chrome.browser.preferences;
6 6
7 import android.os.Bundle; 7 import android.os.Bundle;
8 import android.preference.PreferenceFragment; 8 import android.preference.PreferenceFragment;
9 import android.widget.LinearLayout.LayoutParams; 9 import android.view.ViewGroup.LayoutParams;
10 import android.widget.FrameLayout;
11 import android.widget.LinearLayout;
10 import android.widget.ListView; 12 import android.widget.ListView;
11 13
12 import org.chromium.base.VisibleForTesting; 14 import org.chromium.base.VisibleForTesting;
13 import org.chromium.chrome.R; 15 import org.chromium.chrome.R;
14 16
15 /** 17 /**
16 * A preference fragment for selecting a default search engine. 18 * A preference fragment for selecting a default search engine.
17 */ 19 */
18 public class SearchEnginePreference extends PreferenceFragment { 20 public class SearchEnginePreference extends PreferenceFragment {
19 private ListView mListView; 21 private ListView mListView;
(...skipping 21 matching lines...) Expand all
41 getActivity().setTitle(R.string.prefs_search_engine); 43 getActivity().setTitle(R.string.prefs_search_engine);
42 mSearchEngineAdapter = new SearchEngineAdapter(getActivity()); 44 mSearchEngineAdapter = new SearchEngineAdapter(getActivity());
43 } 45 }
44 46
45 @Override 47 @Override
46 public void onActivityCreated(Bundle savedInstanceState) { 48 public void onActivityCreated(Bundle savedInstanceState) {
47 super.onActivityCreated(savedInstanceState); 49 super.onActivityCreated(savedInstanceState);
48 mListView = (ListView) getView().findViewById(android.R.id.list); 50 mListView = (ListView) getView().findViewById(android.R.id.list);
49 int marginTop = getActivity().getResources().getDimensionPixelSize( 51 int marginTop = getActivity().getResources().getDimensionPixelSize(
50 R.dimen.search_engine_list_margin_top); 52 R.dimen.search_engine_list_margin_top);
51 LayoutParams layoutParams = 53 LayoutParams layoutParams = mListView.getLayoutParams();
52 new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_P ARENT); 54 if (layoutParams instanceof FrameLayout.LayoutParams) {
53 layoutParams.setMargins(0, marginTop, 0, 0); 55 ((FrameLayout.LayoutParams) layoutParams).setMargins(0, marginTop, 0 , 0);
gone 2016/12/02 22:39:55 Don't need to do this. Both FrameLayout.LayoutPar
ltian 2016/12/02 23:09:04 Done.
56 } else {
57 ((LinearLayout.LayoutParams) layoutParams).setMargins(0, marginTop, 0, 0);
58 }
54 mListView.setLayoutParams(layoutParams); 59 mListView.setLayoutParams(layoutParams);
55 mListView.setAdapter(mSearchEngineAdapter); 60 mListView.setAdapter(mSearchEngineAdapter);
56 mListView.setDivider(null); 61 mListView.setDivider(null);
57 } 62 }
58 63
59 @Override 64 @Override
60 public void onResume() { 65 public void onResume() {
61 super.onResume(); 66 super.onResume();
62 /** 67 /**
63 * Handle UI update when location setting for a search engine is changed . 68 * Handle UI update when location setting for a search engine is changed .
64 */ 69 */
65 mSearchEngineAdapter.notifyDataSetChanged(); 70 mSearchEngineAdapter.notifyDataSetChanged();
66 } 71 }
67 } 72 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698