Upstream version 8.36.161.0
[platform/framework/web/crosswalk.git] / src / xwalk / app / android / app_template / src / org / xwalk / app / template / AppTemplateActivity.java
1 // Copyright (c) 2013 Intel Corporation. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 package org.xwalk.app.template;
6
7 import android.graphics.Color;
8 import android.os.Build.VERSION;
9 import android.os.Build.VERSION_CODES;
10 import android.os.Bundle;
11 import android.view.WindowManager;
12 import android.view.View;
13 import android.widget.TextView;
14
15 import org.xwalk.app.XWalkRuntimeActivityBase;
16
17 public class AppTemplateActivity extends XWalkRuntimeActivityBase {
18     @Override
19     public void onCreate(Bundle savedInstanceState) {
20         super.onCreate(savedInstanceState);
21     }
22
23     @Override
24     protected void didTryLoadRuntimeView(View runtimeView) {
25         if (runtimeView != null) {
26             setContentView(runtimeView);
27             getRuntimeView().loadAppFromUrl("file:///android_asset/www/index.html");
28         } else {
29             TextView msgText = new TextView(this);
30             msgText.setText("Crosswalk failed to initialize.");
31             msgText.setTextSize(36);
32             msgText.setTextColor(Color.BLACK);
33             setContentView(msgText);
34         }
35     }
36
37     private void enterFullscreen() {
38         if (VERSION.SDK_INT >= VERSION_CODES.KITKAT &&
39                 ((getWindow().getAttributes().flags &
40                         WindowManager.LayoutParams.FLAG_FULLSCREEN) != 0)) {
41             View decorView = getWindow().getDecorView();
42             decorView.setSystemUiVisibility(
43                     View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
44                     View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
45                     View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
46                     View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
47                     View.SYSTEM_UI_FLAG_FULLSCREEN |
48                     View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
49         }
50     }
51
52     public void setIsFullscreen(boolean isFullscreen) {
53         if (isFullscreen) {
54             enterFullscreen();
55         }
56     }
57
58 }