Bug 1369817 - Set screen orientation according to webapp manifest r=droeh

MozReview-Commit-ID: KvuPsYSalVN
This commit is contained in:
James Willcox 2017-08-08 11:17:50 -05:00
Родитель b8c43d4666
Коммит 76426c6cb7
1 изменённых файлов: 16 добавлений и 0 удалений

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

@ -12,6 +12,7 @@ import java.util.List;
import android.annotation.TargetApi;
import android.app.ActivityManager;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Build;
@ -32,6 +33,7 @@ import org.json.JSONException;
import org.mozilla.gecko.ActivityHandlerHelper;
import org.mozilla.gecko.AppConstants;
import org.mozilla.gecko.GeckoAppShell;
import org.mozilla.gecko.GeckoScreenOrientation;
import org.mozilla.gecko.GeckoView;
import org.mozilla.gecko.GeckoViewSettings;
import org.mozilla.gecko.icons.decoders.FaviconDecoder;
@ -151,6 +153,7 @@ public class WebAppActivity extends AppCompatActivity
updateStatusBarColorV21(color);
setTaskDescription(taskDescription);
updateScreenOrientation(manifestField);
} catch (IOException | JSONException e) {
Log.e(LOGTAG, "Failed to read manifest", e);
}
@ -165,6 +168,19 @@ public class WebAppActivity extends AppCompatActivity
}
}
private void updateScreenOrientation(JSONObject manifest) {
String orientString = manifest.optString("orientation", null);
if (orientString == null) {
return;
}
GeckoScreenOrientation.ScreenOrientation orientation =
GeckoScreenOrientation.screenOrientationFromString(orientString);
int activityOrientation = GeckoScreenOrientation.screenOrientationToAndroidOrientation(orientation);
setRequestedOrientation(activityOrientation);
}
private Integer readColorFromManifest(JSONObject manifest) {
final String colorStr = manifest.optString("theme_color", null);
if (colorStr != null) {