| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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.document; | 5 package org.chromium.chrome.browser.document; |
| 6 | 6 |
| 7 import android.annotation.TargetApi; | 7 import android.annotation.TargetApi; |
| 8 import android.app.Activity; | |
| 9 import android.app.ActivityManager; | 8 import android.app.ActivityManager; |
| 10 import android.app.ActivityManager.AppTask; | 9 import android.app.ActivityManager.AppTask; |
| 11 import android.app.ActivityManager.RecentTaskInfo; | 10 import android.app.ActivityManager.RecentTaskInfo; |
| 12 import android.content.Context; | 11 import android.content.Context; |
| 13 import android.content.Intent; | 12 import android.content.Intent; |
| 14 import android.content.pm.PackageManager; | 13 import android.content.pm.PackageManager; |
| 15 import android.content.pm.ResolveInfo; | 14 import android.content.pm.ResolveInfo; |
| 16 import android.graphics.Bitmap; | |
| 17 import android.graphics.Color; | |
| 18 import android.net.Uri; | 15 import android.net.Uri; |
| 19 import android.os.Build; | 16 import android.os.Build; |
| 20 import android.text.TextUtils; | 17 import android.text.TextUtils; |
| 21 import android.util.Log; | 18 import android.util.Log; |
| 22 | 19 |
| 23 import org.chromium.base.ApiCompatibilityUtils; | |
| 24 import org.chromium.base.ApplicationStatus; | 20 import org.chromium.base.ApplicationStatus; |
| 25 import org.chromium.chrome.browser.tab.Tab; | 21 import org.chromium.chrome.browser.tab.Tab; |
| 26 import org.chromium.chrome.browser.tabmodel.document.ActivityDelegate; | 22 import org.chromium.chrome.browser.tabmodel.document.ActivityDelegate; |
| 27 import org.chromium.chrome.browser.util.ColorUtils; | |
| 28 | 23 |
| 29 import java.util.ArrayList; | 24 import java.util.ArrayList; |
| 30 import java.util.List; | 25 import java.util.List; |
| 31 | 26 |
| 32 /** | 27 /** |
| 33 * Deals with Document-related API calls. | 28 * Deals with Document-related API calls. |
| 34 */ | 29 */ |
| 35 @TargetApi(Build.VERSION_CODES.LOLLIPOP) | 30 @TargetApi(Build.VERSION_CODES.LOLLIPOP) |
| 36 public class DocumentUtils { | 31 public class DocumentUtils { |
| 37 public static final String TAG = "DocumentUtilities"; | 32 public static final String TAG = "DocumentUtilities"; |
| 38 | 33 |
| 39 /** | 34 /** |
| 40 * Update the Recents entry for the Activity. | |
| 41 * @param activity Activity to change the entry for. | |
| 42 * @param title Title to show on the card. | |
| 43 * @param icon Icon to show on the card. | |
| 44 * @param color Color to use for the card's bar. | |
| 45 * @param useDefaultStatusBarColor Whether status bar should be set to defau
lt color. | |
| 46 */ | |
| 47 public static void updateTaskDescription(Activity activity, String title, Bi
tmap icon, | |
| 48 int color, boolean useDefaultStatusBarColor) { | |
| 49 ApiCompatibilityUtils.setTaskDescription(activity, title, icon, color); | |
| 50 int statusBarColor = useDefaultStatusBarColor | |
| 51 ? Color.BLACK : ColorUtils.getDarkenedColorForStatusBar(color); | |
| 52 ApiCompatibilityUtils.setStatusBarColor(activity.getWindow(), statusBarC
olor); | |
| 53 } | |
| 54 | |
| 55 /** | |
| 56 * Finishes tasks other than the one with the given task ID that were starte
d with the given | 35 * Finishes tasks other than the one with the given task ID that were starte
d with the given |
| 57 * tabId, leaving a unique task to own a Tab with that particular ID. | 36 * tabId, leaving a unique task to own a Tab with that particular ID. |
| 58 * @param tabId ID of the tab to remove duplicates for. | 37 * @param tabId ID of the tab to remove duplicates for. |
| 59 * @param canonicalTaskId ID of the task will be the only one left with the
ID. | 38 * @param canonicalTaskId ID of the task will be the only one left with the
ID. |
| 60 * @return Intent of one of the tasks that were finished. | 39 * @return Intent of one of the tasks that were finished. |
| 61 */ | 40 */ |
| 62 public static Intent finishOtherTasksWithTabID(int tabId, int canonicalTaskI
d) { | 41 public static Intent finishOtherTasksWithTabID(int tabId, int canonicalTaskI
d) { |
| 63 if (tabId == Tab.INVALID_TAB_ID || Build.VERSION.SDK_INT < Build.VERSION
_CODES.LOLLIPOP) { | 42 if (tabId == Tab.INVALID_TAB_ID || Build.VERSION.SDK_INT < Build.VERSION
_CODES.LOLLIPOP) { |
| 64 return null; | 43 return null; |
| 65 } | 44 } |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 return null; | 146 return null; |
| 168 } else if (baseIntent.getComponent() != null) { | 147 } else if (baseIntent.getComponent() != null) { |
| 169 return baseIntent.getComponent().getClassName(); | 148 return baseIntent.getComponent().getClassName(); |
| 170 } else { | 149 } else { |
| 171 ResolveInfo resolveInfo = pm.resolveActivity(baseIntent, 0); | 150 ResolveInfo resolveInfo = pm.resolveActivity(baseIntent, 0); |
| 172 if (resolveInfo == null) return null; | 151 if (resolveInfo == null) return null; |
| 173 return resolveInfo.activityInfo.name; | 152 return resolveInfo.activityInfo.name; |
| 174 } | 153 } |
| 175 } | 154 } |
| 176 } | 155 } |
| OLD | NEW |