| 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.webapps; | 5 package org.chromium.chrome.browser.webapps; |
| 6 | 6 |
| 7 import android.content.pm.ApplicationInfo; | 7 import android.content.pm.ApplicationInfo; |
| 8 import android.content.pm.PackageManager; | 8 import android.content.pm.PackageManager; |
| 9 import android.content.res.Resources; | 9 import android.content.res.Resources; |
| 10 import android.graphics.Bitmap; | 10 import android.graphics.Bitmap; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 resources = packageManager.getResourcesForApplication(webApkPackageN
ame); | 47 resources = packageManager.getResourcesForApplication(webApkPackageN
ame); |
| 48 } catch (PackageManager.NameNotFoundException e) { | 48 } catch (PackageManager.NameNotFoundException e) { |
| 49 return null; | 49 return null; |
| 50 } | 50 } |
| 51 Bitmap icon = BitmapFactory.decodeResource(resources, metaData.iconId); | 51 Bitmap icon = BitmapFactory.decodeResource(resources, metaData.iconId); |
| 52 String encodedIcon = ShortcutHelper.encodeBitmapAsString(icon); | 52 String encodedIcon = ShortcutHelper.encodeBitmapAsString(icon); |
| 53 | 53 |
| 54 return WebApkInfo.create(WebApkConstants.WEBAPK_ID_PREFIX + webApkPackag
eName, url, | 54 return WebApkInfo.create(WebApkConstants.WEBAPK_ID_PREFIX + webApkPackag
eName, url, |
| 55 metaData.scope, encodedIcon, metaData.name, metaData.shortName, | 55 metaData.scope, encodedIcon, metaData.name, metaData.shortName, |
| 56 metaData.displayMode, metaData.orientation, source, metaData.the
meColor, | 56 metaData.displayMode, metaData.orientation, source, metaData.the
meColor, |
| 57 metaData.backgroundColor, metaData.iconUrlAndIconMurmur2HashMap.
isEmpty(), | 57 metaData.backgroundColor, webApkPackageName); |
| 58 webApkPackageName); | |
| 59 } | 58 } |
| 60 | 59 |
| 61 /** | 60 /** |
| 62 * Populates {@link WebApkMetaData} with meta data extracted from WebAPK's A
ndroid Manifest. | 61 * Populates {@link WebApkMetaData} with meta data extracted from WebAPK's A
ndroid Manifest. |
| 63 * @param webApkPackageName Package name of the WebAPK to extract meta data
from. | 62 * @param webApkPackageName Package name of the WebAPK to extract meta data
from. |
| 64 */ | 63 */ |
| 65 public static WebApkMetaData extractMetaDataFromWebApk(String webApkPackageN
ame) { | 64 public static WebApkMetaData extractMetaDataFromWebApk(String webApkPackageN
ame) { |
| 66 PackageManager packageManager = ContextUtils.getApplicationContext().get
PackageManager(); | 65 PackageManager packageManager = ContextUtils.getApplicationContext().get
PackageManager(); |
| 67 ApplicationInfo appInfo; | 66 ApplicationInfo appInfo; |
| 68 try { | 67 try { |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 return ScreenOrientationValues.PORTRAIT; | 226 return ScreenOrientationValues.PORTRAIT; |
| 228 } else if (orientation.equals("portrait-primary")) { | 227 } else if (orientation.equals("portrait-primary")) { |
| 229 return ScreenOrientationValues.PORTRAIT_PRIMARY; | 228 return ScreenOrientationValues.PORTRAIT_PRIMARY; |
| 230 } else if (orientation.equals("portrait-secondary")) { | 229 } else if (orientation.equals("portrait-secondary")) { |
| 231 return ScreenOrientationValues.PORTRAIT_SECONDARY; | 230 return ScreenOrientationValues.PORTRAIT_SECONDARY; |
| 232 } else { | 231 } else { |
| 233 return ScreenOrientationValues.DEFAULT; | 232 return ScreenOrientationValues.DEFAULT; |
| 234 } | 233 } |
| 235 } | 234 } |
| 236 } | 235 } |
| OLD | NEW |