OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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.bookmarks; | 5 package org.chromium.chrome.browser.bookmarks; |
6 | 6 |
7 import android.app.Activity; | 7 import android.app.Activity; |
8 import android.content.res.Resources; | 8 import android.content.res.Resources; |
9 import android.view.View; | 9 import android.view.View; |
10 import android.view.ViewGroup.MarginLayoutParams; | 10 import android.view.ViewGroup.MarginLayoutParams; |
11 | 11 |
12 import org.chromium.base.ApiCompatibilityUtils; | 12 import org.chromium.base.ApiCompatibilityUtils; |
13 import org.chromium.chrome.R; | 13 import org.chromium.chrome.R; |
14 import org.chromium.chrome.browser.NativePage; | 14 import org.chromium.chrome.browser.NativePage; |
15 import org.chromium.chrome.browser.UrlConstants; | 15 import org.chromium.chrome.browser.UrlConstants; |
16 import org.chromium.chrome.browser.bookmarks.BookmarkDelegate.BookmarkStateChang
eListener; | 16 import org.chromium.chrome.browser.bookmarks.BookmarkDelegate.BookmarkStateChang
eListener; |
17 import org.chromium.chrome.browser.offlinepages.OfflinePageUtils; | |
18 import org.chromium.chrome.browser.tab.Tab; | 17 import org.chromium.chrome.browser.tab.Tab; |
19 import org.chromium.content_public.browser.LoadUrlParams; | 18 import org.chromium.content_public.browser.LoadUrlParams; |
20 | 19 |
21 /** | 20 /** |
22 * A native page holding a {@link BookmarkManager} on _tablet_. | 21 * A native page holding a {@link BookmarkManager} on _tablet_. |
23 */ | 22 */ |
24 public class BookmarkPage implements NativePage, BookmarkStateChangeListener { | 23 public class BookmarkPage implements NativePage, BookmarkStateChangeListener { |
25 private final Activity mActivity; | 24 private final Activity mActivity; |
26 private final Tab mTab; | 25 private final Tab mTab; |
27 private final String mTitle; | 26 private final String mTitle; |
28 private final int mBackgroundColor; | 27 private final int mBackgroundColor; |
29 private final int mThemeColor; | 28 private final int mThemeColor; |
30 private BookmarkManager mManager; | 29 private BookmarkManager mManager; |
31 private String mCurrentUrl; | 30 private String mCurrentUrl; |
32 | 31 |
33 /** | 32 /** |
34 * Create a new instance of the bookmarks page. | 33 * Create a new instance of the bookmarks page. |
35 * @param activity The activity to get context and manage fragments. | 34 * @param activity The activity to get context and manage fragments. |
36 * @param tab The tab to load urls. | 35 * @param tab The tab to load urls. |
37 */ | 36 */ |
38 public BookmarkPage(Activity activity, Tab tab) { | 37 public BookmarkPage(Activity activity, Tab tab) { |
39 mActivity = activity; | 38 mActivity = activity; |
40 mTab = tab; | 39 mTab = tab; |
41 mTitle = activity.getString(OfflinePageUtils.getStringId(R.string.bookma
rks)); | 40 mTitle = activity.getString(R.string.bookmarks); |
42 mBackgroundColor = ApiCompatibilityUtils.getColor(activity.getResources(
), | 41 mBackgroundColor = ApiCompatibilityUtils.getColor(activity.getResources(
), |
43 R.color.default_primary_color); | 42 R.color.default_primary_color); |
44 mThemeColor = ApiCompatibilityUtils.getColor( | 43 mThemeColor = ApiCompatibilityUtils.getColor( |
45 activity.getResources(), R.color.default_primary_color); | 44 activity.getResources(), R.color.default_primary_color); |
46 | 45 |
47 mManager = new BookmarkManager(mActivity, false); | 46 mManager = new BookmarkManager(mActivity, false); |
48 Resources res = mActivity.getResources(); | 47 Resources res = mActivity.getResources(); |
49 | 48 |
50 MarginLayoutParams layoutParams = new MarginLayoutParams( | 49 MarginLayoutParams layoutParams = new MarginLayoutParams( |
51 MarginLayoutParams.MATCH_PARENT, MarginLayoutParams.MATCH_PARENT
); | 50 MarginLayoutParams.MATCH_PARENT, MarginLayoutParams.MATCH_PARENT
); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 mManager.destroy(); | 97 mManager.destroy(); |
99 mManager = null; | 98 mManager = null; |
100 } | 99 } |
101 | 100 |
102 @Override | 101 @Override |
103 public void onBookmarkUIStateChange(String url) { | 102 public void onBookmarkUIStateChange(String url) { |
104 if (url.equals(mCurrentUrl)) return; | 103 if (url.equals(mCurrentUrl)) return; |
105 mTab.loadUrl(new LoadUrlParams(url)); | 104 mTab.loadUrl(new LoadUrlParams(url)); |
106 } | 105 } |
107 } | 106 } |
OLD | NEW |