Ejemplo n.º 1
0
  @Override
  public void onResume() {

    try {

      QSLog.d(CLASS_NAME, "En onResume");
      super.onResume();
      initActivity();

    } catch (Exception e) {
      if (QSLog.DEBUG_E)
        QSLog.e(CLASS_NAME, ExceptionUtils.exceptionTraceToString(e.toString(), e.getStackTrace()));
    }
  }
  /**
   * Put the mobile in normal mode (audio and vibrate), important: normal mode such the user defined
   * previously (before to put the mobile in silence)
   */
  private void putRingerModeNormal() {

    try {
      if (QSLog.DEBUG_D) QSLog.d(CLASS_NAME, "Poniendo el movil en modo normal");

      AudioManager audioManager =
          (AudioManager) ConfigAppValues.getContext().getSystemService(Context.AUDIO_SERVICE);
      audioManager.setRingerMode(AudioManager.RINGER_MODE_NORMAL);

      ConfigAppValues.processIdleCall = false;

    } catch (Exception e) {
      if (QSLog.DEBUG_E)
        QSLog.e(CLASS_NAME, ExceptionUtils.exceptionTraceToString(e.toString(), e.getStackTrace()));
    }
  }
  /** Put the vibrator in mode On */
  private void vibrateOn() {

    try {

      String vibratorService = Context.VIBRATOR_SERVICE;
      Vibrator vibrator = (Vibrator) ConfigAppValues.getContext().getSystemService(vibratorService);

      vibrator.vibrate(1000);

    } catch (Exception e) {
      if (QSLog.DEBUG_E)
        QSLog.e(CLASS_NAME, ExceptionUtils.exceptionTraceToString(e.toString(), e.getStackTrace()));
    }
  }
Ejemplo n.º 4
0
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {

    try {
      MenuInflater menuInflater = getMenuInflater();
      menuInflater.inflate(R.menu.informationmenu, menu);

      return true;

    } catch (Exception e) {
      if (QSLog.DEBUG_E)
        QSLog.e(CLASS_NAME, ExceptionUtils.exceptionTraceToString(e.toString(), e.getStackTrace()));
      return false;
    }
  }
Ejemplo n.º 5
0
  /**
   * Function that depends the serviceToggleButton state try to start the QuiteSleep incoming call
   * service or stop it.
   */
  private void startStopServiceProcess() {

    try {

      boolean result =
          StartStopServicesOperations.startStopQuiteSleepService(serviceToggleButton.isChecked());

      if (serviceToggleButton.isChecked()) {

        /* Deactivate the notification toast because now use the
         * status bar notification
         */
        /*
        if (result)

        	//All right, start the service was ok!
        	Toast.makeText(
                     		this,
                     		this.getString(
                     				R.string.settings_toast_start_service),
                     		Toast.LENGTH_SHORT).show();

        else
        	//An error has ocurred!!
        	Toast.makeText(
                     		this,
                     		this.getString(
                     				R.string.settings_toast_fail_service),
                     		Toast.LENGTH_SHORT).show();
                */
      } else {
        if (result)
          // All right, stop the service was ok!
          if (QSToast.RELEASE)
            QSToast.r(
                this, this.getString(R.string.settings_toast_stop_service), Toast.LENGTH_SHORT);
          else
          // An error has ocurred!!
          if (QSToast.RELEASE)
            QSToast.r(
                this, this.getString(R.string.settings_toast_fail_service), Toast.LENGTH_SHORT);
      }
    } catch (Exception e) {
      if (QSLog.DEBUG_E)
        QSLog.e(CLASS_NAME, ExceptionUtils.exceptionTraceToString(e.toString(), e.getStackTrace()));
    }
  }
Ejemplo n.º 6
0
  /**
   * Create the activity dialogs used for it
   *
   * @param id
   * @return the dialog for the option specified
   * @see Dialog
   */
  @Override
  protected Dialog onCreateDialog(int id) {

    Dialog dialog;

    switch (id) {
      case ABOUT_DIALOG:
        if (QSLog.DEBUG_D) QSLog.d(CLASS_NAME, "Create about dialog for 1st time");
        dialog = showWebviewDialog(IDialogs.ABOUT_URI);
        break;
      case HELP_DIALOG:
        dialog = showWebviewDialog(IDialogs.HELP_SETTINGS_URI);
        break;
      default:
        dialog = null;
    }

    return dialog;
  }
Ejemplo n.º 7
0
  /**
   * Create the webview dialog using the file (uri) specified to show the information.
   *
   * @return
   */
  public Dialog showWebviewDialog(String uri) {

    try {
      View contentView = getLayoutInflater().inflate(R.layout.webview_dialog, null, false);
      WebView webView = (WebView) contentView.findViewById(R.id.webview_content);
      webView.getSettings().setJavaScriptEnabled(true);

      webView.loadUrl(uri);

      return new AlertDialog.Builder(this)
          .setCustomTitle(null)
          .setPositiveButton(android.R.string.ok, null)
          .setView(contentView)
          .create();

    } catch (Exception e) {
      if (QSLog.DEBUG_E)
        QSLog.e(CLASS_NAME, ExceptionUtils.exceptionTraceToString(e.toString(), e.getStackTrace()));
      return null;
    }
  }
Ejemplo n.º 8
0
  /**
   * @param item
   * @return boolean
   */
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {

    try {

      switch (item.getItemId()) {
        case aboutMenuId:
          showDialog(ABOUT_DIALOG);
          break;
        case helpMenuId:
          showDialog(HELP_DIALOG);
          break;
        default:
          break;
      }
      return false;

    } catch (Exception e) {
      if (QSLog.DEBUG_E)
        QSLog.e(CLASS_NAME, ExceptionUtils.exceptionTraceToString(e.toString(), e.getStackTrace()));
      return false;
    }
  }
Ejemplo n.º 9
0
  /** Put the ddbb saved data in the activity widgets */
  private void initActivity() {

    try {
      ClientDDBB clientDDBB = new ClientDDBB();

      // Togglebutton (QuuiteSleep service) check
      Settings settings = clientDDBB.getSelects().selectSettings();
      if (settings != null) {
        serviceToggleButton.setChecked(settings.isQuiteSleepServiceState());
      } else serviceToggleButton.setChecked(false);

      // Mute or hangup radio buttons check
      if (ConfigAppValues.getMuteOrHangup() == null) {
        MuteOrHangUp muteOrHangup = clientDDBB.getSelects().selectMuteOrHangUp();
        if (muteOrHangup != null) {
          if (muteOrHangup.isMute()) muteRButton.setChecked(true);
          else if (muteOrHangup.isHangUp()) hangUpRButton.setChecked(true);
        }
        // If MuteOrHangUp object is not created. Should not occur
        else {
          muteOrHangup = new MuteOrHangUp();
          clientDDBB.getInserts().insertMuteOrHangUp(muteOrHangup);
          clientDDBB.commit();
        }

      } else {
        if (ConfigAppValues.getMuteOrHangup()) hangUpRButton.setChecked(true);
        else muteRButton.setChecked(true);
      }
      clientDDBB.close();

    } catch (Exception e) {
      if (QSLog.DEBUG_E)
        QSLog.e(CLASS_NAME, ExceptionUtils.exceptionTraceToString(e.toString(), e.getStackTrace()));
    }
  }
Ejemplo n.º 10
0
  /**
   * This function save the user option regarding both mute or hang up in the ddbb.
   *
   * @param optionValue
   */
  private void saveMuteOrHangUpOption(boolean optionValue) {

    try {

      ClientDDBB clientDDBB = new ClientDDBB();
      MuteOrHangUp muteOrHangup = clientDDBB.getSelects().selectMuteOrHangUp();
      if (muteOrHangup != null) {

        // If is true, then the hangup option is established
        if (optionValue) {
          muteOrHangup.setHangUp(true);
          ConfigAppValues.setMuteOrHangup(true);
        }
        // If is false, then the mute mode is set to true
        else {
          muteOrHangup.setMute(true);
          ConfigAppValues.setMuteOrHangup(false);
        }

        clientDDBB.getUpdates().insertMuteOrHangUp(muteOrHangup);
        clientDDBB.commit();
      }

      // If MuteOrHangUp object is not created.
      else {
        muteOrHangup = new MuteOrHangUp();
        clientDDBB.getInserts().insertMuteOrHangUp(muteOrHangup);
        clientDDBB.commit();
      }
      clientDDBB.close();

    } catch (Exception e) {
      if (QSLog.DEBUG_E)
        QSLog.e(CLASS_NAME, ExceptionUtils.exceptionTraceToString(e.toString(), e.getStackTrace()));
    }
  }