@Override public boolean onOptionsItemSelected(MenuItem item) { // Handle item selection switch (item.getItemId()) { case android.R.id.home: ChangeLog cl = new ChangeLog(this); cl.getFullLogDialog().show(); return true; case R.id.menu_exit: System.exit(0); case R.id.menu_share: shareLog(); return true; case R.id.menu_connect: // bail if no bluetooth adapter if (bt == null) return false; if (item.getTitle() .toString() .equalsIgnoreCase(getResources().getString(R.string.menu_connect))) { showDevices(); } else { disconnect(); Editor edit = prefs.edit(); edit.putString("prefs_remote_name", ""); edit.putString("prefs_remote_mac", ""); edit.commit(); } return false; case R.id.menu_prefs: startActivity(new Intent(this, AdaptivePreferences.class)); return true; default: return super.onOptionsItemSelected(item); } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ctx = this; prefs = PreferenceManager.getDefaultSharedPreferences(ctx); adaptiveFragment = getFragmentManager().findFragmentById(R.id.frag_adaptive); gaugesFragment = getFragmentManager().findFragmentById(R.id.frag_gauges); fuelFragment = getFragmentManager().findFragmentById(R.id.frag_fuel); ActionBar bar = getActionBar(); bar.addTab(bar.newTab().setText(R.string.tab_adaptive).setTabListener(this), false); bar.addTab(bar.newTab().setText(R.string.tab_gauges).setTabListener(this), false); bar.addTab(bar.newTab().setText("Fuel Map").setTabListener(this), false); mActionBarView = getLayoutInflater().inflate(R.layout.action_bar_custom, null); bar.setCustomView(mActionBarView); bar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_USE_LOGO); bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); bar.setDisplayShowHomeEnabled(true); txtData = (TextView) findViewById(R.id.txtData); lvDevices = (ListView) findViewById(R.id.lvDevices); layoutDevices = (RelativeLayout) findViewById(R.id.layoutDevices); imgStatus = (ImageView) findViewById(R.id.imgStatus); txtFuelLearn = (TextView) findViewById(R.id.fuellearn); imgIWait = (ImageView) findViewById(R.id.imgIWait); imgIRpm = (ImageView) findViewById(R.id.imgIRpm); imgILoad = (ImageView) findViewById(R.id.imgILoad); imgFWait = (ImageView) findViewById(R.id.imgFWait); imgFRpm = (ImageView) findViewById(R.id.imgFRpm); imgFLoad = (ImageView) findViewById(R.id.imgFLoad); imgIat = (ImageView) findViewById(R.id.iat); gridData = (GridView) findViewById(R.id.gridData); dataArray = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1); dataArray.add("RPM\n ----"); dataArray.add("MAP\n ---"); dataArray.add("MAT\n ---\u00B0"); dataArray.add("AFR\n --.-"); dataArray.add("TAFR\n --.-"); dataArray.add("WAT\n ---\u00B0"); gridData.setAdapter(dataArray); lvDevices.setOnItemClickListener(DevicesClickListener); waterNeedle = (GaugeNeedle) findViewById(R.id.waterneedle); iatNeedle = (GaugeNeedle) findViewById(R.id.iatneedle); mapNeedle = (GaugeNeedle) findViewById(R.id.mapneedle); afrNeedle = (GaugeNeedle) findViewById(R.id.afrneedle); targetAfrNeedle = (GaugeNeedle) findViewById(R.id.targetafrneedle); rpmNeedle = (GaugeNeedle) findViewById(R.id.rpmneedle); waterNeedle.setPivotPoint(.65f); waterNeedle.setMinValue(100); waterNeedle.setMaxValue(240); waterNeedle.setMinDegrees(-50); waterNeedle.setMaxDegrees(55); afrNeedle.setPivotPoint(.5f); afrNeedle.setMinValue(AFR_MIN); afrNeedle.setMaxValue(AFR_MAX); afrNeedle.setMinDegrees(-180); afrNeedle.setMaxDegrees(90); targetAfrNeedle.setPivotPoint(.5f); targetAfrNeedle.setMinValue(AFR_MIN); targetAfrNeedle.setMaxValue(AFR_MAX); targetAfrNeedle.setMinDegrees(-180); targetAfrNeedle.setMaxDegrees(90); mapNeedle.setPivotPoint(.5f); mapNeedle.setMinValue(0); mapNeedle.setMaxValue(200); mapNeedle.setMinDegrees(-150); mapNeedle.setMaxDegrees(140); rpmNeedle.setPivotPoint(.5f); rpmNeedle.setMinValue(0); rpmNeedle.setMaxValue(9000); rpmNeedle.setMinDegrees(-130); rpmNeedle.setMaxDegrees(157); ChangeLog cl = new ChangeLog(this); if (cl.firstRun()) { cl.getLogDialog().show(); } LinearLayout group = (LinearLayout) findViewById(R.id.linearLayoutTchart); chart = new TChart(this); chart.setAutoRepaint(false); group.addView(chart); ThemesList.applyTheme(chart.getChart(), 1); chart.removeAllSeries(); ser = new Surface(chart.getChart()); chart.getAspect().setView3D(true); ser.setIrregularGrid(true); ser.setUseColorRange(false); ser.setUsePalette(true); ser.setPaletteStyle(PaletteStyle.RAINBOW); chart.getPanel().setBorderRound(7); chart.getAspect().setView3D(true); chart.getAspect().setChart3DPercent(100); chart.getAspect().setOrthogonal(false); chart.getAspect().setZoom(75); chart.getAspect().setRotation(350); chart.getAspect().setElevation(350); chart.getAspect().setPerspective(37); chart.getAxes().getDepth().setVisible(true); chart.getLegend().setVisible(false); chart.getHeader().setText("Fuel Map #1 (VE)"); chart.getHeader().getFont().setSize(18); chart.getHeader().getFont().setBold(true); ser.setColor(com.steema.teechart.drawing.Color.darkGray); new Rotate(chart.getChart()); // EVAN mUsbDetachedFilter.addAction(UsbManager.ACTION_USB_DEVICE_DETACHED); registerReceiver(mUsbReceiver, mUsbDetachedFilter); // END EVAN }