| OLD | NEW |
| 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.MarginLayoutParams; |
| 10 import android.widget.ListView; | 10 import android.widget.ListView; |
| 11 | 11 |
| 12 import org.chromium.base.VisibleForTesting; | 12 import org.chromium.base.VisibleForTesting; |
| 13 import org.chromium.chrome.R; | 13 import org.chromium.chrome.R; |
| 14 | 14 |
| 15 /** | 15 /** |
| 16 * A preference fragment for selecting a default search engine. | 16 * A preference fragment for selecting a default search engine. |
| 17 */ | 17 */ |
| 18 public class SearchEnginePreference extends PreferenceFragment { | 18 public class SearchEnginePreference extends PreferenceFragment { |
| 19 private ListView mListView; | 19 private ListView mListView; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 41 getActivity().setTitle(R.string.prefs_search_engine); | 41 getActivity().setTitle(R.string.prefs_search_engine); |
| 42 mSearchEngineAdapter = new SearchEngineAdapter(getActivity()); | 42 mSearchEngineAdapter = new SearchEngineAdapter(getActivity()); |
| 43 } | 43 } |
| 44 | 44 |
| 45 @Override | 45 @Override |
| 46 public void onActivityCreated(Bundle savedInstanceState) { | 46 public void onActivityCreated(Bundle savedInstanceState) { |
| 47 super.onActivityCreated(savedInstanceState); | 47 super.onActivityCreated(savedInstanceState); |
| 48 mListView = (ListView) getView().findViewById(android.R.id.list); | 48 mListView = (ListView) getView().findViewById(android.R.id.list); |
| 49 int marginTop = getActivity().getResources().getDimensionPixelSize( | 49 int marginTop = getActivity().getResources().getDimensionPixelSize( |
| 50 R.dimen.search_engine_list_margin_top); | 50 R.dimen.search_engine_list_margin_top); |
| 51 LayoutParams layoutParams = | 51 MarginLayoutParams layoutParams = (MarginLayoutParams) mListView.getLayo
utParams(); |
| 52 new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_P
ARENT); | |
| 53 layoutParams.setMargins(0, marginTop, 0, 0); | 52 layoutParams.setMargins(0, marginTop, 0, 0); |
| 54 mListView.setLayoutParams(layoutParams); | 53 mListView.setLayoutParams(layoutParams); |
| 55 mListView.setAdapter(mSearchEngineAdapter); | 54 mListView.setAdapter(mSearchEngineAdapter); |
| 56 mListView.setDivider(null); | 55 mListView.setDivider(null); |
| 57 } | 56 } |
| 58 | 57 |
| 59 @Override | 58 @Override |
| 60 public void onResume() { | 59 public void onResume() { |
| 61 super.onResume(); | 60 super.onResume(); |
| 62 /** | 61 /** |
| 63 * Handle UI update when location setting for a search engine is changed
. | 62 * Handle UI update when location setting for a search engine is changed
. |
| 64 */ | 63 */ |
| 65 mSearchEngineAdapter.notifyDataSetChanged(); | 64 mSearchEngineAdapter.notifyDataSetChanged(); |
| 66 } | 65 } |
| 67 } | 66 } |
| OLD | NEW |