package com.kedi.factoryMode.ManulMode;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.AlertDialog.Builder;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.sip.SipManager;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;
import com.kedi.factoryMode.R;
public class ManulActivity extends Activity implements OnClickListener{
private Button mDisplayButton;
private Button mBacklightButton;
private Button mKeyButton;
private Button mTouchScreenButton;
private Button mVibrationButton;
private Button mSoundButton;
private Button mSdcardButton;
private Button mHeadsetButton;
private Button mBluetoothButton;
private Button mWifiButton;
private Button mChargeButton;
private Button mLightSensorButton;
private Button mCameraButton;
private Button mFlashButton;
private Button mAccelerButton;
private Button mProximityButton;
private Button mGyroscopeButton;
private Button mCompassButton;
private Button mSoundReceiverButton;
private Button mATVButton;
private Button mFMButton;
private Button mSIMButton;
private Button mGPSButton;
private int mBackground;
private boolean ifATVExit = true;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.manul);
mDisplayButton = (Button) findViewById(R.id.display);
mDisplayButton.setOnClickListener(this);
mBacklightButton = (Button) findViewById(R.id.backlight);
mBacklightButton.setOnClickListener(this);
mKeyButton = (Button) findViewById(R.id.key);
mKeyButton.setOnClickListener(this);
mTouchScreenButton = (Button) findViewById(R.id.touch_screen);
mTouchScreenButton.setOnClickListener(this);
mVibrationButton = (Button) findViewById(R.id.vibration);
mVibrationButton.setOnClickListener(this);
mSoundButton = (Button) findViewById(R.id.sound);
mSoundButton.setOnClickListener(this);
mSdcardButton = (Button) findViewById(R.id.sdCard);
mSdcardButton.setOnClickListener(this);
mHeadsetButton = (Button) findViewById(R.id.headset);
mHeadsetButton.setOnClickListener(this);
mBluetoothButton = (Button) findViewById(R.id.bluetooth);
mBluetoothButton.setOnClickListener(this);
mWifiButton = (Button) findViewById(R.id.wifi);
mWifiButton.setOnClickListener(this);
mChargeButton = (Button) findViewById(R.id.charge);
mChargeButton.setOnClickListener(this);
mLightSensorButton = (Button) findViewById(R.id.lightsensor);
mLightSensorButton.setOnClickListener(this);
mCameraButton = (Button) findViewById(R.id.camera);
mCameraButton.setOnClickListener(this);
mFlashButton = (Button) findViewById(R.id.flash);
mFlashButton.setOnClickListener(this);
mAccelerButton = (Button) findViewById(R.id.accelersensor);
mAccelerButton.setOnClickListener(this);
mProximityButton = (Button) findViewById(R.id.proximitySensor);
mProximityButton.setOnClickListener(this);
mGyroscopeButton = (Button) findViewById(R.id.gyroscope);
mGyroscopeButton.setOnClickListener(this);
mCompassButton = (Button) findViewById(R.id.compass);
mCompassButton.setOnClickListener(this);
mSoundReceiverButton = (Button) findViewById(R.id.soundreceiver);
mSoundReceiverButton.setOnClickListener(this);
mATVButton = (Button) findViewById(R.id.atv);
mATVButton.setOnClickListener(this);
mFMButton = (Button) findViewById(R.id.fmradio);
mFMButton.setOnClickListener(this);
mSIMButton = (Button) findViewById(R.id.simcard);
mSIMButton.setOnClickListener(this);
mGPSButton = (Button) findViewById(R.id.gps);
mGPSButton.setOnClickListener(this);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
Log.e("lijiaxing", requestCode + " " + resultCode + " ");
setButtonBackground(requestCode,resultCode);
}
private void setButtonBackground(int requestCode, int resultCode){
if(resultCode == 1){
mBackground = R.drawable.green_background;
}else if(resultCode == -1){
mBackground = R.drawable.red_background;
}
Builder builder;
Dialog dialog;
switch (requestCode) {
case 0:
mBacklightButton.setBackgroundResource(mBackground);
break;
case 1:
mKeyButton.setBackgroundResource(mBackground);
break;
case 2:
mDisplayButton.setBackgroundResource(mBackground);
break;
case 3:
mTouchScreenButton.setBackgroundResource(mBackground);
break;
case 4:
mVibrationButton.setBackgroundResource(mBackground);
break;
case 5:
mSoundButton.setBackgroundResource(mBackground);
break;
case 6:
mSdcardButton.setBackgroundResource(mBackground);
break;
case 7:
mHeadsetButton.setBackgroundResource(mBackground);
break;
case 8:
mBluetoothButton.setBackgroundResource(mBackground);
break;
case 9:
mWifiButton.setBackgroundResource(mBackground);
break;
case 10:
mChargeButton.setBackgroundResource(mBackground);
break;
case 11:
mLightSensorButton.setBackgroundResource(mBackground);
break;
case 12:
mCameraButton.setBackgroundResource(mBackground);
break;
case 13:
mFlashButton.setBackgroundResource(mBackground);
break;
case 14:
mAccelerButton.setBackgroundResource(mBackground);
break;
case 15:
mProximityButton.setBackgroundResource(mBackground);
break;
case 16:
mGyroscopeButton.setBackgroundResource(mBackground);
break;
case 17:
mCompassButton.setBackgroundResource(mBackground);
break;
case 18:
mSoundReceiverButton.setBackgroundResource(mBackground);
break;
case 19:
if(ifATVExit) {
builder=new AlertDialog.Builder(this).setTitle("ATV模拟电视").setMessage("模拟电视是否测试成功?").setPositiveButton("成功",
new android.content.DialogInterface.OnClickListener () {
public void onClick(DialogInterface arg0, int arg1) {
// TODO Auto-generated method stub
mBackground = R.drawable.green_background;
mATVButton.setBackgroundResource(mBackground);
}
}).setNegativeButton("失败", new android.content.DialogInterface.OnClickListener () {
public void onClick(DialogInterface arg0, int arg1) {
// TODO Auto-generated method stub
mBackground = R.drawable.red_background;
mATVButton.setBackgroundResource(mBackground);
}
});
dialog=builder.create();
dialog.setCancelable(false);
dialog.show();
}
break;
case 20:
builder=new AlertDialog.Builder(this).setTitle("FM").setMessage("FM是否测试成功?").setPositiveButton("成功",
new android.content.DialogInterface.OnClickListener () {
public void onClick(DialogInterface arg0, int arg1) {
// TODO Auto-generated method stub
mBackground = R.drawable.green_background;
mFMButton.setBackgroundResource(mBackground);
}
}).setNegativeButton("失败", new android.content.DialogInterface.OnClickListener () {
public void onClick(DialogInterface arg0, int arg1) {
// TODO Auto-generated method stub
mBackground = R.drawable.red_background;
mFMButton.setBackgroundResource(mBackground);
}
});
dialog=builder.create();
dialog.setCancelable(false);
dialog.show();
break;
case 21:
builder=new AlertDialog.Builder(this).setTitle("SIM").setMessage("SIM 是否测试成功?").setPositiveButton("成功",
new android.content.DialogInterface.OnClickListener () {
public void onClick(DialogInterface arg0, int arg1) {
// TODO Auto-
评论6
最新资源