Home | History | Annotate | Download | only in DemoKit
      1 package com.google.android.DemoKit;
      2 
      3 import android.graphics.drawable.Drawable;
      4 import android.os.Bundle;
      5 import android.view.View;
      6 import android.view.View.OnClickListener;
      7 import android.widget.LinearLayout;
      8 import android.widget.TextView;
      9 
     10 public class DemoKitPhone extends BaseActivity implements OnClickListener {
     11 	static final String TAG = "DemoKitPhone";
     12 	/** Called when the activity is first created. */
     13 	TextView mInputLabel;
     14 	TextView mOutputLabel;
     15 	LinearLayout mInputContainer;
     16 	LinearLayout mOutputContainer;
     17 	Drawable mFocusedTabImage;
     18 	Drawable mNormalTabImage;
     19 	OutputController mOutputController;
     20 
     21 	@Override
     22 	protected void hideControls() {
     23 		super.hideControls();
     24 		mOutputController = null;
     25 	}
     26 
     27 	public void onCreate(Bundle savedInstanceState) {
     28 		mFocusedTabImage = getResources().getDrawable(
     29 				R.drawable.tab_focused_holo_dark);
     30 		mNormalTabImage = getResources().getDrawable(
     31 				R.drawable.tab_normal_holo_dark);
     32 		super.onCreate(savedInstanceState);
     33 	}
     34 
     35 	protected void showControls() {
     36 		super.showControls();
     37 
     38 		mOutputController = new OutputController(this, false);
     39 		mOutputController.accessoryAttached();
     40 		mInputLabel = (TextView) findViewById(R.id.inputLabel);
     41 		mOutputLabel = (TextView) findViewById(R.id.outputLabel);
     42 		mInputContainer = (LinearLayout) findViewById(R.id.inputContainer);
     43 		mOutputContainer = (LinearLayout) findViewById(R.id.outputContainer);
     44 		mInputLabel.setOnClickListener(this);
     45 		mOutputLabel.setOnClickListener(this);
     46 
     47 		showTabContents(true);
     48 	}
     49 
     50 	void showTabContents(Boolean showInput) {
     51 		if (showInput) {
     52 			mInputContainer.setVisibility(View.VISIBLE);
     53 			mInputLabel.setBackgroundDrawable(mFocusedTabImage);
     54 			mOutputContainer.setVisibility(View.GONE);
     55 			mOutputLabel.setBackgroundDrawable(mNormalTabImage);
     56 		} else {
     57 			mInputContainer.setVisibility(View.GONE);
     58 			mInputLabel.setBackgroundDrawable(mNormalTabImage);
     59 			mOutputContainer.setVisibility(View.VISIBLE);
     60 			mOutputLabel.setBackgroundDrawable(mFocusedTabImage);
     61 		}
     62 	}
     63 
     64 	public void onClick(View v) {
     65 		int vId = v.getId();
     66 		switch (vId) {
     67 		case R.id.inputLabel:
     68 			showTabContents(true);
     69 			break;
     70 
     71 		case R.id.outputLabel:
     72 			showTabContents(false);
     73 			break;
     74 		}
     75 	}
     76 
     77 }