Пример #1
0
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    if (D) Log.d(TAG, "onCreateOptionsMenu()");
    super.onCreateOptionsMenu(menu);

    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.dashboard_menu, menu);
    return true;
  }
Пример #2
0
  @Override
  public void onStop() {
    if (D) Log.d(TAG, "onStop()");
    super.onStop();

    SharedPreferences.Editor editor = mPrefs.edit();
    editor.putInt("dashboardviewmode", mViewMode);
    editor.commit();
  }
Пример #3
0
  public void onServiceConnected(ComponentName name, IBinder service) {
    if (D) Log.d(TAG, "onServiceConnected()");
    super.onServiceConnected(name, service);

    if (!mService.isPolling()) mService.startPoll();

    mHD.addHarleyDataDashboardListener(mHarleyDroidDashboardView);
    mHarleyDroidDashboardView.drawAll(mHD);
  }
Пример #4
0
  @Override
  public void onConfigurationChanged(Configuration newConfig) {
    if (D) Log.d(TAG, "onConfigurationChanged()");
    super.onConfigurationChanged(newConfig);

    if (mOrientation == ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) {
      mHarleyDroidDashboardView.changeView(
          mViewMode, newConfig.orientation == Configuration.ORIENTATION_PORTRAIT, mUnitMetric);
      mHarleyDroidDashboardView.drawAll(mHD);
    }
  }
Пример #5
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    if (D) Log.d(TAG, "onCreate()");
    super.onCreate(savedInstanceState);

    mHarleyDroidDashboardView = new HarleyDroidDashboardView(this);
    mHarleyDroidDashboardView.changeView(
        mViewMode,
        getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT,
        mUnitMetric);
  }
Пример #6
0
  @Override
  public void onStart() {
    if (D) Log.d(TAG, "onStart()");
    super.onStart();

    mViewMode = mPrefs.getInt("dashboardviewmode", HarleyDroidDashboardView.VIEW_GRAPHIC);
    mHarleyDroidDashboardView.changeView(
        mViewMode,
        mOrientation == ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED
            ? getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT
            : mOrientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT ? true : false,
        mUnitMetric);
    mHarleyDroidDashboardView.drawAll(mHD);
  }
Пример #7
0
  @Override
  public boolean onPrepareOptionsMenu(Menu menu) {
    if (D) Log.d(TAG, "onPrepareOptionsMenu()");
    super.onPrepareOptionsMenu(menu);

    menu.findItem(R.id.startstop_menu).setEnabled((mBluetoothID == null) ? false : true);

    if (mService != null) {
      menu.findItem(R.id.startstop_menu).setIcon(R.drawable.ic_menu_stop);
      menu.findItem(R.id.startstop_menu).setTitle(R.string.disconnect_label);
    } else {
      menu.findItem(R.id.startstop_menu).setIcon(R.drawable.ic_menu_play_clip);
      menu.findItem(R.id.startstop_menu).setTitle(R.string.connect_label);
    }
    if (mViewMode == HarleyDroidDashboardView.VIEW_GRAPHIC)
      menu.findItem(R.id.mode_menu).setTitle(R.string.mode_labelraw);
    else menu.findItem(R.id.mode_menu).setTitle(R.string.mode_labelgr);

    return true;
  }
Пример #8
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    if (D) Log.d(TAG, "onOptionsItemSelected");
    super.onOptionsItemSelected(item);

    switch (item.getItemId()) {
      case R.id.startstop_menu:
        if (mService == null) startHDS();
        else stopHDS();
        return true;
      case R.id.mode_menu:
        if (mViewMode == HarleyDroidDashboardView.VIEW_GRAPHIC)
          mViewMode = HarleyDroidDashboardView.VIEW_TEXT;
        else mViewMode = HarleyDroidDashboardView.VIEW_GRAPHIC;
        mHarleyDroidDashboardView.changeView(
            mViewMode,
            getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT,
            mUnitMetric);
        mHarleyDroidDashboardView.drawAll(mHD);
        return true;
      case R.id.diag_menu:
        Intent diagnosticsActivity = new Intent(getBaseContext(), HarleyDroidDiagnostics.class);
        startActivity(diagnosticsActivity);
        return true;
      case R.id.preferences_menu:
        Intent settingsActivity = new Intent(getBaseContext(), HarleyDroidSettings.class);
        startActivity(settingsActivity);
        return true;
      case R.id.reset_menu:
        if (mHD != null) mHD.resetCounters();
        return true;
      case R.id.about_menu:
        About.about(this);
        return true;
      default:
        return super.onOptionsItemSelected(item);
    }
  }
Пример #9
0
  public void onServiceDisconnected(ComponentName name) {
    if (D) Log.d(TAG, "onServiceDisconnected()");
    super.onServiceDisconnected(name);

    mHD.removeHarleyDataDashboardListener(mHarleyDroidDashboardView);
  }