コード例 #1
0
  /**
   * Based on change in alarm scheduling related preferences, pop up a toast message telling the
   * user if the alarm is ready to go or not
   *
   * @param wakeupEnabled true if the "enable wake-up" box is checked
   */
  private void alarmSchedulingPreferenceUpdated(boolean wakeupEnabled) {

    if (wakeupEnabled) {

      if (Alarms.getEnabledAlarmsQuery(getContentResolver()).getCount() != 0) {
        int wakeupEnabledResorts = 0;
        for (Resort r : mResortManager.getResorts()) {
          if (r.isWakeupEnabled()) {
            wakeupEnabledResorts++;
          }
        }
        Toast toast;
        if (wakeupEnabledResorts != 0) {
          toast = Toast.makeText(this, R.string.alarm_updated, Toast.LENGTH_SHORT);
        } else {
          toast = Toast.makeText(this, R.string.please_enable_wakeup_on_resort, Toast.LENGTH_SHORT);
        }
        toast.show();
      } else {
        Log.d("No alarm configured");
        Toast toast = Toast.makeText(this, R.string.alarm_not_set, Toast.LENGTH_SHORT);
        toast.show();
      }
    } else {
      Log.d("Alarm is not enabled");
      Toast toast = Toast.makeText(this, R.string.wakeup_disabled, Toast.LENGTH_SHORT);
      toast.show();
    }
  }
コード例 #2
0
 @Override
 public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
   if (preference == mAlarmSettingsPreference) {
     startActivityForResult(
         new Intent(this, WakeMeSkiAlarmCustomization.getInstance().getAlarmClock()),
         ALARM_CONFIGURE);
   }
   if (preference == mAlarmEnablePreference) {
     updateAlarmPreferences();
   } else if (preference == mDashboardPreference) {
     startActivity(new Intent(Intent.ACTION_MAIN, null, this, WakeMeSkiDashboard.class));
   } else if (preference == mResortsPreference) {
     startActivity(new Intent(Intent.ACTION_MAIN, null, this, ResortListActivity.class));
   } else if (preference == mSendLogsPreference) {
     File logFile = Log.getInstance().getLogFile();
     if (logFile == null) {
       Toast toast =
           Toast.makeText(this, R.string.log_file_not_available_insert_sdcard, Toast.LENGTH_SHORT);
       toast.show();
     } else {
       Resort[] resorts =
           WakeMeSkiFactory.getInstance(this.getApplicationContext())
               .getRestortManager()
               .getResorts();
       Log.d("Configured resorts:");
       for (Resort resort : resorts) {
         Log.d(resort + " isWakeupEnabled= " + resort.isWakeupEnabled());
       }
       Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
       emailIntent.setType("plain/text");
       emailIntent.putExtra(
           android.content.Intent.EXTRA_EMAIL, new String[] {"*****@*****.**"});
       emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "WakeMeSki debug log");
       emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Description of problem:");
       emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + logFile.getAbsolutePath()));
       startActivity(Intent.createChooser(emailIntent, this.getString(R.string.send_mail)));
     }
   }
   return super.onPreferenceTreeClick(preferenceScreen, preference);
 }