зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1369817 - Clean up webapp manifest handling r=droeh
MozReview-Commit-ID: 4ImLBrlGzBc
This commit is contained in:
Родитель
76426c6cb7
Коммит
c9189d44e9
|
@ -125,14 +125,6 @@ public class WebAppActivity extends AppCompatActivity
|
|||
}
|
||||
|
||||
private void loadManifest(String manifestPath) {
|
||||
if (AppConstants.Versions.feature21Plus) {
|
||||
loadManifestV21(manifestPath);
|
||||
}
|
||||
}
|
||||
|
||||
// The customisations defined in the manifest only work on Android API 21+
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
private void loadManifestV21(String manifestPath) {
|
||||
if (TextUtils.isEmpty(manifestPath)) {
|
||||
Log.e(LOGTAG, "Missing manifest");
|
||||
return;
|
||||
|
@ -142,16 +134,10 @@ public class WebAppActivity extends AppCompatActivity
|
|||
final File manifestFile = new File(manifestPath);
|
||||
final JSONObject manifest = FileUtils.readJSONObjectFromFile(manifestFile);
|
||||
final JSONObject manifestField = manifest.getJSONObject("manifest");
|
||||
final Integer color = readColorFromManifest(manifestField);
|
||||
final String name = readNameFromManifest(manifestField);
|
||||
final Bitmap icon = readIconFromManifest(manifest);
|
||||
mScope = readScopeFromManifest(manifest, manifestPath);
|
||||
final ActivityManager.TaskDescription taskDescription = (color == null)
|
||||
? new ActivityManager.TaskDescription(name, icon)
|
||||
: new ActivityManager.TaskDescription(name, icon, color);
|
||||
|
||||
updateStatusBarColorV21(color);
|
||||
setTaskDescription(taskDescription);
|
||||
if (AppConstants.Versions.feature21Plus) {
|
||||
loadManifestV21(manifest, manifestField);
|
||||
}
|
||||
|
||||
updateScreenOrientation(manifestField);
|
||||
} catch (IOException | JSONException e) {
|
||||
|
@ -159,6 +145,21 @@ public class WebAppActivity extends AppCompatActivity
|
|||
}
|
||||
}
|
||||
|
||||
// The customisations defined in the manifest only work on Android API 21+
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
private void loadManifestV21(JSONObject manifest, JSONObject manifestField) {
|
||||
final Integer color = readColorFromManifest(manifestField);
|
||||
final String name = readNameFromManifest(manifestField);
|
||||
final Bitmap icon = readIconFromManifest(manifest);
|
||||
mScope = readScopeFromManifest(manifest);
|
||||
final ActivityManager.TaskDescription taskDescription = (color == null)
|
||||
? new ActivityManager.TaskDescription(name, icon)
|
||||
: new ActivityManager.TaskDescription(name, icon, color);
|
||||
|
||||
updateStatusBarColorV21(color);
|
||||
setTaskDescription(taskDescription);
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
private void updateStatusBarColorV21(final Integer themeColor) {
|
||||
if (themeColor != null) {
|
||||
|
@ -213,7 +214,7 @@ public class WebAppActivity extends AppCompatActivity
|
|||
return loadIconResult.getBestBitmap(GeckoAppShell.getPreferredIconSize());
|
||||
}
|
||||
|
||||
private Uri readScopeFromManifest(JSONObject manifest, String manifestPath) {
|
||||
private Uri readScopeFromManifest(JSONObject manifest) {
|
||||
final String scopeStr = manifest.optString("scope", null);
|
||||
if (scopeStr == null) {
|
||||
return null;
|
||||
|
|
Загрузка…
Ссылка в новой задаче