NavigationBarView.java revision 8956dbbc5f292d8b79072ae73b25f2114c8c7479
1/* 2 * Copyright (C) 2008 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.android.systemui.statusbar.phone; 18 19import android.content.Context; 20import android.util.AttributeSet; 21import android.view.Display; 22import android.view.KeyEvent; 23import android.view.View; 24import android.view.Surface; 25import android.view.WindowManager; 26import android.widget.LinearLayout; 27import android.content.res.Configuration; 28 29import com.android.systemui.R; 30 31public class NavigationBarView extends LinearLayout { 32 final Display mDisplay; 33 View[] mRotatedViews = new View[4]; 34 35 public NavigationBarView(Context context, AttributeSet attrs) { 36 super(context, attrs); 37 mDisplay = ((WindowManager)context.getSystemService( 38 Context.WINDOW_SERVICE)).getDefaultDisplay(); 39 } 40 41 public void onFinishInflate() { 42 mRotatedViews[Surface.ROTATION_0] = 43 mRotatedViews[Surface.ROTATION_180] = findViewById(R.id.rot0); 44 45 mRotatedViews[Surface.ROTATION_90] = findViewById(R.id.rot90); 46 47 mRotatedViews[Surface.ROTATION_270] = findViewById(R.id.rot270); 48 } 49 50 public void reorient() { 51 final int rot = mDisplay.getRotation(); 52 for (int i=0; i<4; i++) { 53 mRotatedViews[i].setVisibility(View.GONE); 54 } 55 mRotatedViews[rot].setVisibility(View.VISIBLE); 56 57 android.util.Log.d("NavigationBarView", "reorient(): rot=" + mDisplay.getRotation()); 58 } 59} 60