Home | History | Annotate | Download | only in incallui
      1 /*
      2  * Copyright (C) 2016 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.android.incallui;
     18 
     19 import android.os.Bundle;
     20 import android.support.v4.app.Fragment;
     21 import android.support.v7.app.AppCompatActivity;
     22 import android.view.MenuItem;
     23 
     24 /** Shows the {@link ConferenceManagerFragment} */
     25 public class ManageConferenceActivity extends AppCompatActivity {
     26 
     27   private boolean isVisible;
     28 
     29   public boolean isVisible() {
     30     return isVisible;
     31   }
     32 
     33   @Override
     34   public void onCreate(Bundle savedInstanceState) {
     35     super.onCreate(savedInstanceState);
     36     InCallPresenter.getInstance().setManageConferenceActivity(this);
     37 
     38     getSupportActionBar().setDisplayHomeAsUpEnabled(true);
     39 
     40     setContentView(R.layout.activity_manage_conference);
     41     Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.manageConferencePanel);
     42     if (fragment == null) {
     43       fragment = new ConferenceManagerFragment();
     44       getSupportFragmentManager()
     45           .beginTransaction()
     46           .replace(R.id.manageConferencePanel, fragment)
     47           .commit();
     48     }
     49   }
     50 
     51   @Override
     52   protected void onDestroy() {
     53     super.onDestroy();
     54     if (isFinishing()) {
     55       InCallPresenter.getInstance().setManageConferenceActivity(null);
     56     }
     57   }
     58 
     59   @Override
     60   public boolean onOptionsItemSelected(MenuItem item) {
     61     final int itemId = item.getItemId();
     62     if (itemId == android.R.id.home) {
     63       onBackPressed();
     64       return true;
     65     }
     66     return super.onOptionsItemSelected(item);
     67   }
     68 
     69   @Override
     70   public void onBackPressed() {
     71     InCallPresenter.getInstance().bringToForeground(false);
     72     finish();
     73   }
     74 
     75   @Override
     76   protected void onStart() {
     77     super.onStart();
     78     isVisible = true;
     79   }
     80 
     81   @Override
     82   protected void onStop() {
     83     super.onStop();
     84     isVisible = false;
     85   }
     86 }
     87