1/* 2 * Copyright (C) 2017 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 17package com.example.android.leanback; 18 19import android.app.Activity; 20import android.app.FragmentTransaction; 21import android.content.Context; 22import android.content.Intent; 23import android.content.pm.PackageManager; 24import android.os.Build; 25import android.os.Bundle; 26 27/** 28 * Activity that hosts VideoConsumptionExampleFragment. 29 * 30 * The main purpose to add this activity is to observe the bug b/28003943 31 */ 32public class VideoActivityWithDetailedCard extends Activity { 33 34 public static final String TAG = "VideoExampleActivity"; 35 36 @Override 37 public void onCreate(Bundle savedInstanceState) { 38 super.onCreate(savedInstanceState); 39 setContentView(R.layout.video_activity_detailed_card); 40 41 if (savedInstanceState == null) { 42 FragmentTransaction ft = getFragmentManager().beginTransaction(); 43 ft.add(R.id.videoFragment, new VideoConsumptionWithDetailCardFragment(), 44 VideoConsumptionWithDetailCardFragment.TAG); 45 ft.commit(); 46 } 47 } 48 49 @Override 50 protected void onNewIntent(Intent intent) { 51 super.onNewIntent(intent); 52 // This part is necessary to ensure that getIntent returns the latest intent when 53 // VideoExampleActivity is started. By default, getIntent() returns the initial intent 54 // that was set from another activity that started VideoExampleActivity. However, we need 55 // to update this intent when for example, user clicks on another video when the currently 56 // playing video is in PIP mode, and a new video needs to be started. 57 setIntent(intent); 58 } 59 60 /** 61 * Helper function to determine if picture in picture mode is supported or not 62 * @param context current context 63 * @return if Picture in Picture mode is supported or not 64 */ 65 public static boolean supportsPictureInPicture(Context context) { 66 return Build.VERSION.SDK_INT >= 24 67 && context.getPackageManager().hasSystemFeature( 68 PackageManager.FEATURE_PICTURE_IN_PICTURE); 69 } 70} 71 72