Bug 1369817 - Clean up webapp manifest handling r=droeh

MozReview-Commit-ID: 4ImLBrlGzBc
This commit is contained in:
James Willcox 2017-08-08 11:26:50 -05:00
Родитель 76426c6cb7
Коммит c9189d44e9
1 изменённых файлов: 19 добавлений и 18 удалений

Просмотреть файл

@ -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;