• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2015 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.example.android.multiwindow;
18 
19 import android.app.ActionBar;
20 import android.app.Activity;
21 import android.graphics.Color;
22 import android.graphics.Rect;
23 import android.graphics.drawable.ColorDrawable;
24 import android.os.Bundle;
25 import android.util.Log;
26 import android.view.View;
27 import android.view.Window;
28 
29 /**
30  * A minimal application that overlays caption on the content.
31  */
32 public class CaptionOverlayActivity extends Activity
33         implements Window.OnRestrictedCaptionAreaChangedListener {
34     private static final String TAG = "CaptionOverlayActivity";
35 
36     /**
37      * Called with the activity is first created.
38      */
39     @Override
onCreate(Bundle savedInstanceState)40     public void onCreate(Bundle savedInstanceState) {
41         super.onCreate(savedInstanceState);
42         // Overlay the caption on the content.
43         //setOverlayWithDecorCaptionEnabled(true);
44         setContentView(R.layout.caption_overlay_layout);
45         getWindow().setRestrictedCaptionAreaListener(this);
46         getWindow().setResizingCaptionDrawable(new ColorDrawable(Color.BLACK));
47         getWindow().setDecorCaptionShade(Window.DECOR_CAPTION_SHADE_AUTO);
48 
49         View decorView = getWindow().getDecorView();
50         //Hide the status bar, because it likes to consume touch events.
51         int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
52         decorView.setSystemUiVisibility(uiOptions);
53         //Remember that you should never show the action bar if the
54         // status bar is hidden, so hide that too if necessary.
55         ActionBar actionBar = getActionBar();
56         actionBar.hide();
57 
58     }
59 
60     @Override
onRestrictedCaptionAreaChanged(Rect rect)61     public void onRestrictedCaptionAreaChanged(Rect rect) {
62         Log.d(TAG, "rect: " + rect);
63     }
64 }
65 
66