@Override
  public void onClick(View v) {
    SharedPreferences gameSettings = getSharedPreferences(GAME_SETTING_PREFS, 0);
    SharedPreferences.Editor editor = gameSettings.edit();

    if (v.getId() == R.id.playBtn) {
      Intent nextIntent;

      SharedPreferences gameState = getSharedPreferences(GameActivity.GAME_STATE_PREFS, 0);
      final int currLevel = gameState.getInt(GameActivity.STATE_LEVEL, 0);

      nextIntent = new Intent(this, GameActivity.class);
      MediaController.stopLoopingSound();

      // startNext intent
      startActivity(nextIntent);
    } else if (v.getId() == R.id.settings_btn) {
      RelativeLayout settingsWrap = (RelativeLayout) findViewById(R.id.other_settings_buttons_wrap);
      if (View.GONE == settingsWrap.getVisibility()) {
        settingsWrap.setVisibility(View.VISIBLE);
      } else {
        settingsWrap.setVisibility(View.GONE);
      }
    } else if (v.getId() == R.id.toggle_sound) {
      boolean soundEdit = gameSettings.getBoolean(SOUND_PREF, true);
      editor.putBoolean(SOUND_PREF, !soundEdit);
      editor.commit();

      if (soundEdit) {
        Toast.makeText(getApplicationContext(), "Sound is turned off", Toast.LENGTH_SHORT).show();
        MediaController.stopLoopingSound();
      } else {
        Toast.makeText(getApplicationContext(), "Sound is turned on", Toast.LENGTH_SHORT).show();
        MediaController.playSoundClip(this, R.raw.background_intro, true);
      }
    } else if (v.getId() == R.id.toggle_vibration) {
      boolean vibrateEdit = gameSettings.getBoolean(VIBRATE_PREF, true);
      editor.putBoolean(VIBRATE_PREF, !vibrateEdit);

      String vibrateState = (!vibrateEdit) ? "on" : "off";
      Toast.makeText(
              getApplicationContext(), "Vibration is turned " + vibrateState, Toast.LENGTH_SHORT)
          .show();
    } else if (v.getId() == R.id.show_credits) {
      new GameAlertDialogBuilder(this)
          .setTitle("Credits")
          .setMessage(this.getResources().getString(R.string.credits))
          .setPositiveButton(
              android.R.string.no,
              new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                  dialog.cancel();
                }
              })
          .show();
    }
    editor.commit();

    updateColorOfSettingsButtons();
  }
Beispiel #2
0
  public int onStartCommand(Intent intent, int flags, int startId) {
    Log.i("unidevel.UnlockService", "onStartCommand");
    if (intent != null && intent.hasExtra("lock") && intent.hasExtra("unlock")) {
      boolean lock = intent.getBooleanExtra("lock", false);
      boolean unlock = intent.getBooleanExtra("unlock", true);
      SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
      if (pref != null) {
        SharedPreferences.Editor edit = pref.edit();
        edit.putBoolean("aunlocker.lock", lock);
        edit.putBoolean("aunlocker.unlock", unlock);
        edit.commit();
      }
    }
    if (this.receiver == null) {
      Log.i("unidevel.UnlockService", "onStartCommand.registerReceiver");
      this.receiver = new ScreenReceiver();
      this.receiver.setService(this);
      IntentFilter it = new IntentFilter();
      it.addAction(Intent.ACTION_SCREEN_OFF);
      it.addAction(Intent.ACTION_SCREEN_ON);
      registerReceiver(this.receiver, it);

      PowerManager pm = (PowerManager) getSystemService(POWER_SERVICE);
      if (!pm.isScreenOn()) {
        Log.i("unidevel.UnlockService", "onStartCommand init with screen off");
        onScreenOff();
      } else {
        Log.i("unidevel.UnlockService", "onStartCommand init with screen on");
        onScreenOn();
      }
    }
    return Service.START_STICKY;
  }
  @Override
  public void onReceive(Context context, Intent intent) {

    Log.i("WifiO", "RecvTempDisable");

    LogWO logg = new LogWO(context);
    logg.log("WifiOpti Service disabled for 5m");

    SharedPreferences sett = context.getSharedPreferences("WifiOpti", 2);
    SharedPreferences.Editor settEditor = sett.edit();

    settEditor.putBoolean("WifiOptiServiced", false);
    settEditor.putBoolean("WifiOptiTempDisabled", true);
    settEditor.commit();

    // Turn off service
    Intent serviceIntent = new Intent(context, WifiOptiService.class);
    context.stopService(serviceIntent);

    // Schedule restart
    Intent alarmIntent = new Intent(context, RecvTempResume.class);
    AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
    PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, alarmIntent, 0);

    Calendar cal = Calendar.getInstance();
    cal.setTimeInMillis(System.currentTimeMillis());
    cal.add(Calendar.MINUTE, 5);

    Log.d("WifiO", " -> " + cal.getTime().toString());

    am.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), pendingIntent);
  }
Beispiel #4
0
  public void actionLogin(View button) {

    final EditText txtpass = (EditText) findViewById(R.id.txtpass);
    if (txtpass.getText().toString().length() < 1) {
      txtpass.setError(getResources().getString(R.string.login_passwd_err));
      return;
    }

    if (firstlogin) {

      final CheckBox chkBoxpass = (CheckBox) findViewById(R.id.chkPass);

      SharedPreferences.Editor editor = preferences.edit();
      editor.putBoolean("firstlogin", false);
      editor.putBoolean("checkpass", chkBoxpass.isChecked());
      editor.putString("dbpassword", StringEncoder.encode(this, txtpass.getText().toString()));
      editor.putString("currency", "€");
      editor.putLong("currency_id", 1);
      editor.commit();

      MyExApp app = (MyExApp) getApplication();
      app.reloadPreferences();
      app.reloadDataManager();
      app.initData();

    } else {

      String password = StringEncoder.decode(this, preferences.getString("dbpassword", ""));
      if (!password.equals(txtpass.getText().toString())) {
        txtpass.setError(getResources().getString(R.string.login_passwd_err2));
        return;
      }
    }
    startMainFragment();
  }
Beispiel #5
0
  // constructor//////////////////////////////////////////////////////////////////////////////////////
  private RecordManager(Context context) {
    try {
      db = db.getInstance(context);
      if (BuildConfig.DEBUG) if (BuildConfig.DEBUG) Log.d("CoCoin", "db.getInstance(context) S");
    } catch (IOException e) {
      e.printStackTrace();
    }
    if (FIRST_TIME) {
      // if the app starts firstly, create
      // tags///////////////////////////////////////////////////////////
      SharedPreferences preferences = context.getSharedPreferences("Values", Context.MODE_PRIVATE);
      if (preferences.getBoolean("FIRST_TIME", true)) {
        createTags();
        SharedPreferences.Editor editor =
            context.getSharedPreferences("Values", Context.MODE_PRIVATE).edit();
        editor.putBoolean("FIRST_TIME", false);
        editor.commit();
      }
    }
    if (RANDOM_DATA) {

      SharedPreferences preferences = context.getSharedPreferences("Values", Context.MODE_PRIVATE);
      if (preferences.getBoolean("RANDOM", false)) {
        return;
      }

      randomDataCreater();

      SharedPreferences.Editor editor =
          context.getSharedPreferences("Values", Context.MODE_PRIVATE).edit();
      editor.putBoolean("RANDOM", true);
      editor.commit();
    }
  }
Beispiel #6
0
 public void servicioGuardarPosicion() {
   if (recuperarPreferenciaBoolean("servicio1")
       && (!recuperarPreferenciaBoolean("servicioActivo") || sp == null)) {
     Log.d("TabsActivity", "Activar servicio");
     SharedPreferences sp =
         this.getSharedPreferences("es.nervion.maps.activity_preferences", Context.MODE_PRIVATE);
     SharedPreferences.Editor spe = sp.edit();
     spe.putBoolean("pref_servicioActivo", true);
     spe.commit();
     Intent msgIntent = new Intent(this, SubirPosicionIntentService.class);
     msgIntent.setAction(SubirPosicionIntentService.BROADCAST_ACTION);
     msgIntent.putExtra("vivo", true);
     msgIntent.putExtra("refresco", 30000);
     msgIntent.putExtra("nombre", recuperarPreferenciaString("nombre"));
     msgIntent.putExtra("estado", recuperarPreferenciaString("estado"));
     msgIntent.putExtra("radio", recuperarPreferenciaInteger("radio"));
     startService(msgIntent);
   } else if (!recuperarPreferenciaBoolean("servicio1")
       && recuperarPreferenciaBoolean("servicioActivo")) {
     Log.d("TabsActivity", "Desactivar servicio");
     Intent intentPararServicio = new Intent(this, SubirPosicionIntentService.class);
     intentPararServicio.setAction(SubirPosicionIntentService.BROADCAST_MUERE);
     stopService(intentPararServicio);
     SharedPreferences sp =
         this.getSharedPreferences("es.nervion.maps.activity_preferences", Context.MODE_PRIVATE);
     SharedPreferences.Editor spe = sp.edit();
     spe.putBoolean("pref_servicioActivo", false);
     spe.commit();
   }
 }
Beispiel #7
0
  @Override
  protected void onDestroy() {
    CSensorStates lSenStates = mSenStates;
    CLocProvStates lLPStates = mLPStates;

    // Write the preferences
    SharedPreferences lPrefs = getSharedPreferences("DatLogPrefs", MODE_PRIVATE);
    SharedPreferences.Editor lPrefEd = lPrefs.edit();

    // Gps prefs
    for (int i = 0; i < lLPStates.getNum(); i++) {
      lPrefEd.putBoolean(lLPStates.getName(i), lLPStates.getActive(i));
      lPrefEd.putFloat(lLPStates.getName(i) + "_mindist", lLPStates.getMinDist(i));
      lPrefEd.putLong(lLPStates.getName(i) + "_mintime", lLPStates.getMinTime(i));
    }
    lPrefEd.putBoolean("gps_status", mGPSState);

    // Sensor prefs
    for (int i = 0; i < lSenStates.getNum(); i++) {
      lPrefEd.putBoolean(lSenStates.getName(i), lSenStates.getActive(i));
      lPrefEd.putInt(lSenStates.getName(i) + "_rate", lSenStates.getRate(i));
    }

    lPrefEd.commit();

    super.onDestroy();
  }
Beispiel #8
0
 private void writeToSharedPref(SharedPreferences prefs) {
   SharedPreferences.Editor editor = prefs.edit();
   editor.putLong(Stopwatches.PREF_START_TIME, mStartTime);
   editor.putLong(Stopwatches.PREF_ACCUM_TIME, mAccumulatedTime);
   editor.putInt(Stopwatches.PREF_STATE, mState);
   if (mLapsAdapter != null) {
     long[] laps = mLapsAdapter.getLapTimes();
     if (laps != null) {
       editor.putInt(Stopwatches.PREF_LAP_NUM, laps.length);
       for (int i = 0; i < laps.length; i++) {
         String key = Stopwatches.PREF_LAP_TIME + Integer.toString(laps.length - i);
         editor.putLong(key, laps[i]);
       }
     }
   }
   if (mState == Stopwatches.STOPWATCH_RUNNING) {
     editor.putLong(Stopwatches.NOTIF_CLOCK_BASE, mStartTime - mAccumulatedTime);
     editor.putLong(Stopwatches.NOTIF_CLOCK_ELAPSED, -1);
     editor.putBoolean(Stopwatches.NOTIF_CLOCK_RUNNING, true);
   } else if (mState == Stopwatches.STOPWATCH_STOPPED) {
     editor.putLong(Stopwatches.NOTIF_CLOCK_ELAPSED, mAccumulatedTime);
     editor.putLong(Stopwatches.NOTIF_CLOCK_BASE, -1);
     editor.putBoolean(Stopwatches.NOTIF_CLOCK_RUNNING, false);
   } else if (mState == Stopwatches.STOPWATCH_RESET) {
     editor.remove(Stopwatches.NOTIF_CLOCK_BASE);
     editor.remove(Stopwatches.NOTIF_CLOCK_RUNNING);
     editor.remove(Stopwatches.NOTIF_CLOCK_ELAPSED);
   }
   editor.putBoolean(Stopwatches.PREF_UPDATE_CIRCLE, false);
   editor.apply();
 }
Beispiel #9
0
 /** 添加闹钟 */
 public static void addTimer(Context context, String drug_id, AnTimer new_timer) {
   if (new_timer == null) return;
   ArrayList<AnTimer> array = getTimer(context, drug_id);
   int count = array.size();
   SharedPreferences.Editor prefs =
       context.getSharedPreferences(TIMER_SAVE_PATH + drug_id, Activity.MODE_PRIVATE).edit();
   prefs.putInt("count", count + 1);
   prefs.putString("id" + 0, new_timer.getId()); // 最新放在最前面
   prefs.putString("name" + 0, new_timer.getName());
   prefs.putString("text" + 0, new_timer.getText());
   prefs.putInt("hour" + 0, new_timer.getHour());
   prefs.putInt("min" + 0, new_timer.getMinute());
   prefs.putInt("method" + 0, new_timer.getMethod());
   prefs.putBoolean("enable" + 0, new_timer.isEnable());
   prefs.putString("times" + 0, new_timer.getTimes());
   AnTimer old_timer = null;
   for (int i = 0; i < count; i++) {
     old_timer = array.get(i);
     prefs.putString("id" + (i + 1), old_timer.getId());
     prefs.putString("name" + (i + 1), old_timer.getName());
     prefs.putString("text" + (i + 1), old_timer.getText());
     prefs.putInt("hour" + (i + 1), old_timer.getHour());
     prefs.putInt("min" + (i + 1), old_timer.getMinute());
     prefs.putInt("method" + (i + 1), old_timer.getMethod());
     prefs.putBoolean("enable" + (i + 1), old_timer.isEnable());
     prefs.putString("times" + (i + 1), old_timer.getTimes());
   }
   prefs.commit();
 }
  public void saveGame(android.content.SharedPreferences preferences) {

    android.content.SharedPreferences.Editor editor = preferences.edit();
    editor.putBoolean("gamesaved", true);
    editor.putInt("gametype", Game.GAME_CLASSIC);
    editor.putBoolean("SimpleGameData.enableMonolithBlocks", Block.enableMonolithBlocks);
    editor.putInt("SimpleGameData.score", this.score);
    editor.putInt("SimpleGameData.lines", this.lines);
    editor.putInt("SimpleGameData.level", this.level);
    editor.putInt("SimpleGameData.timer", this.timer);
    editor.putInt("SimpleGameData.newLevel", this.newLevel);
    editor.putInt("SimpleGameData.startingLevel", this.startingLevel);
    editor.putInt("SimpleGameData.gridMaxWidth", this.gridMaxWidth);
    editor.putInt("SimpleGameData.gridMaxHeight", this.gridMaxHeight);

    for (int y = 0; y < gridMaxHeight; y++) {
      String line = "";
      String currentChar = "";
      for (int x = 0; x < gridMaxWidth; x++) {
        if (this.grid[x][y] == -1) {
          currentChar = " ";
        } else {
          currentChar = "" + this.grid[x][y];
        }

        line = line + currentChar;
      }
      editor.putString("SimpleGameData.line" + y, line);
    }
    editor.commit();
  }
  @Override
  public int onStartCommand(Intent intent, int flags, int startId) {
    // Let it continue running until it is stopped.

    boolean isStartservice =
        ThanhNienNewsApp.preferences.getBoolean(ThanhNienNewsApp.KEY_START_SERVICE, false);
    if (isStartservice) {

      Toast.makeText(this, "Stop Service kill", Toast.LENGTH_LONG).show();

      // android.os.Process.killProcess(android.os.Process.myPid());
      // System.exit(0);
      Intent intentSplash = new Intent(getApplicationContext(), SplashActivity.class);

      intentSplash.addFlags(
          Intent.FLAG_ACTIVITY_CLEAR_TASK
              | Intent.FLAG_ACTIVITY_NEW_TASK
              | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
      intentSplash.putExtra(ThanhNienNewsApp.KEY_CATCH_LOW_MEMORY, true);
      startActivity(intentSplash);

      SharedPreferences.Editor editor = ThanhNienNewsApp.preferences.edit();
      editor.putBoolean(ThanhNienNewsApp.KEY_START_SERVICE, false);
      editor.commit();

    } else {

      Toast.makeText(this, "Service Start", Toast.LENGTH_LONG).show();

      SharedPreferences.Editor editor = ThanhNienNewsApp.preferences.edit();
      editor.putBoolean(ThanhNienNewsApp.KEY_START_SERVICE, true);
      editor.commit();
    }
    return START_STICKY;
  }
  @Override
  public boolean handleMessage(Message message) {
    switch (message.what) {
      case MSG_SAVE_CONTROLS:
        {
          SharedPreferences.Editor editor = PlaybackService.getSettings(this).edit();
          editor.putBoolean("visible_controls", mControlsVisible);
          editor.putBoolean("visible_extra_info", mExtraInfoVisible);
          editor.commit();
          break;
        }
      case MSG_UPDATE_PROGRESS:
        updateElapsedTime();
        break;
      case MSG_LOAD_EXTRA_INFO:
        loadExtraInfo();
        break;
      case MSG_COMMIT_INFO:
        {
          mGenreView.setText(mGenre);
          mTrackView.setText(mTrack);
          mYearView.setText(mYear);
          mComposerView.setText(mComposer);
          mFormatView.setText(mFormat);
          break;
        }
      case MSG_UPDATE_POSITION:
        updateQueuePosition();
        break;
      default:
        return super.handleMessage(message);
    }

    return true;
  }
  @Override
  public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {

    switch (buttonView.getId()) {
      case R.id.checkBox_toggleService:
        toggleService(isChecked);
        break;
      case R.id.checkBox_toggleSafetyLevel:
        toggleSafety(isChecked);
        break;
      case R.id.checkBox_VolumeButtonHack:
        toggleVolumeButtonHack(isChecked);
        break;
      case R.id.checkBox_musicHack:
        spe.putBoolean(CHECKBOX_MUSIC_HACK, isChecked);
        while (!spe.commit()) {}
        break;
      case R.id.checkBox_voiceCallHack:
        spe.putBoolean(CHECKBOX_VOICE_CALL_HACK, isChecked);
        while (!spe.commit()) {}
        break;
      case R.id.checkBox_ringHack:
        spe.putBoolean(CHECKBOX_RING_HACK, isChecked);
        while (!spe.commit()) {}
        break;
    }
  }
    protected void onPostExecute(AccessToken accessToken) {

      try {
        // Shared Preferences
        SharedPreferences.Editor e = sharedPrefs.edit();

        Log.v("logging_in", "this is what the token should be: " + accessToken.getToken());

        if (sharedPrefs.getInt("current_account", 1) == 1) {
          e.putString("authentication_token_1", accessToken.getToken());
          e.putString("authentication_token_secret_1", accessToken.getTokenSecret());
          e.putBoolean("is_logged_in_1", true);
        } else {
          e.putString("authentication_token_2", accessToken.getToken());
          e.putString("authentication_token_secret_2", accessToken.getTokenSecret());
          e.putBoolean("is_logged_in_2", true);
        }

        e.commit(); // save changes

        // Hide login_activity button
        btnLoginTwitter.setText(getResources().getString(R.string.initial_sync));
        btnLoginTwitter.setEnabled(true);
        title.setText(getResources().getString(R.string.second_welcome));
        summary.setText(getResources().getString(R.string.second_info));

        hideHideWebView();

      } catch (Exception e) {
        restartLogin();
      }
    }
 public void setXKCDPreference(boolean showXKCD, boolean invertXKCDColors) {
   mShowXKCD = showXKCD;
   mInvertXKCD = invertXKCDColors;
   SharedPreferences.Editor editor = mSharedPrefs.edit();
   editor.putBoolean(SHOW_XKCD, showXKCD);
   editor.putBoolean(INVERT_XKCD, invertXKCDColors);
   editor.apply();
 }
 /** Save the component's state in shared preference file before it is killed. */
 @Override
 public void onStop() {
   SharedPreferences prefs = activity.getSharedPreferences(PREF_FILE, Activity.MODE_PRIVATE);
   SharedPreferences.Editor editor = prefs.edit();
   editor.putBoolean(PREF_RCVENABLED, receivingEnabled);
   editor.putBoolean(PREF_GVENABLED, googleVoiceEnabled);
   editor.commit();
 }
  @Override
  public boolean onPreferenceChange(Preference preference, Object o) {
    SharedPreferences.Editor e =
        getSharedPreferences(getPackageName(), Context.MODE_PRIVATE).edit();
    String key = preference.getKey();
    // Вычитываем параметры
    // @todo: нужен рефакторинг повторных кусков кода
    if (key.equals(BACKGROUND_ENABLED_CHECKBOX_KEY)) {
      Boolean enabled = Boolean.parseBoolean(o.toString());
      e.putBoolean(BACKGROUND_ENABLED_CHECKBOX_KEY, enabled);
    } else if (key.equals(H_ENABLED_CHECKBOX_KEY)) {
      Boolean enabled = Boolean.parseBoolean(o.toString());
      e.putBoolean(H_ENABLED_CHECKBOX_KEY, enabled);
    } else if (key.equals(V_ENABLED_CHECKBOX_KEY)) {
      Boolean enabled = Boolean.parseBoolean(o.toString());
      e.putBoolean(V_ENABLED_CHECKBOX_KEY, enabled);
    } else if (key.equals(VF_TOUCH_ENABLED_CHECKBOX_KEY)) {
      Boolean enabled = Boolean.parseBoolean(o.toString());
      e.putBoolean(VF_TOUCH_ENABLED_CHECKBOX_KEY, enabled);
    } else if (key.equals(V_SCROLL_ENABLED_CHECKBOX_KEY)) {
      Boolean enabled = Boolean.parseBoolean(o.toString());
      e.putBoolean(V_SCROLL_ENABLED_CHECKBOX_KEY, enabled);
    } else if (key.equals(VF_COUNT_LIST_KEY)) {
      int id = Integer.parseInt(o.toString());
      e.putInt(VF_COUNT_LIST_KEY, id);
    } else if (key.equals(VB_COUNT_LIST_KEY)) {
      int id = Integer.parseInt(o.toString());
      e.putInt(VB_COUNT_LIST_KEY, id);
    } else if (key.equals(HB_COUNT_LIST_KEY)) {
      int id = Integer.parseInt(o.toString());
      e.putInt(HB_COUNT_LIST_KEY, id);
    } else if (key.equals(HF_COUNT_LIST_KEY)) {
      int id = Integer.parseInt(o.toString());
      e.putInt(HF_COUNT_LIST_KEY, id);
    } else if (key.equals(BACKGROUND_SPEED_LIST_KEY)) {
      int id = Integer.parseInt(o.toString());
      e.putInt(BACKGROUND_SPEED_LIST_KEY, id);
    } else if (key.equals(HF_SPEED_LIST_KEY)) {
      int id = Integer.parseInt(o.toString());
      e.putInt(HF_SPEED_LIST_KEY, id);
    } else if (key.equals(HB_SPEED_LIST_KEY)) {
      int id = Integer.parseInt(o.toString());
      e.putInt(HB_SPEED_LIST_KEY, id);
    } else if (key.equals(VF_SPEED_LIST_KEY)) {
      int id = Integer.parseInt(o.toString());
      e.putInt(VF_SPEED_LIST_KEY, id);
    } else if (key.equals(VB_SPEED_LIST_KEY)) {
      int id = Integer.parseInt(o.toString());
      e.putInt(VB_SPEED_LIST_KEY, id);
    } else if (key.equals(V_SCROLL_SPEED_LIST_KEY)) {
      int id = Integer.parseInt(o.toString());
      e.putInt(V_SCROLL_SPEED_LIST_KEY, id);
    }

    e.commit();

    return true;
  }
Beispiel #18
0
  // Selection-of-Menu
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    // Handle presses on the action bar items
    switch (item.getItemId()) {
      case R.id.action_refresh:
        Intent i = new Intent(Sunday.this, SundayActivity.class);
        startActivity(i);
        break;
      case R.id.action_settings:
        mySQL.DeleteAll();
        onCreate(new Bundle());
        break;
      case R.id.notification:
        Calendar calendar = Calendar.getInstance();
        int day = calendar.get(Calendar.DAY_OF_WEEK);
        Intent not_Intent;
        if (item.isChecked()) {
          item.setChecked(false);
          editor = someData.edit();
          editor.putBoolean("CHECK", false);
          editor.commit();
          nm.cancel(0);
        } else {
          item.setChecked(true);
          editor = someData.edit();
          editor.putBoolean("CHECK", true);
          editor.commit();
          if ((values.length != 0) && day == Calendar.SUNDAY) {
            nm.notify(0, n);
          } else if (day == Calendar.WEDNESDAY) {
            not_Intent = new Intent(Sunday.this, Wednesday.class);
            startActivity(not_Intent);
          } else if (day == Calendar.THURSDAY) {
            not_Intent = new Intent(Sunday.this, Thursday.class);
            startActivity(not_Intent);
          } else if (day == Calendar.FRIDAY) {
            not_Intent = new Intent(Sunday.this, Friday.class);
            startActivity(not_Intent);
          } else if (day == Calendar.TUESDAY) {
            not_Intent = new Intent(Sunday.this, Tuesday.class);
            startActivity(not_Intent);
          } else if (day == Calendar.SATURDAY) {
            not_Intent = new Intent(Sunday.this, Saturday.class);
            startActivity(not_Intent);
          } else if (day == Calendar.MONDAY) {
            not_Intent = new Intent(Sunday.this, Monday.class);
            startActivity(not_Intent);
          }

          break;
        }
    }
    if (drawertoggle.onOptionsItemSelected(item)) {
      return true;
    }
    return super.onOptionsItemSelected(item);
  }
Beispiel #19
0
    @Override
    protected Void doInBackground(Void... params) {
      // Initialize all global variables
      if (GlobalVariables.last100Conn == null) {
        GlobalVariables.last100Conn = new PastConnQueue();
      } else {
        // Clears the queue
        GlobalVariables.last100Conn.clear();
      }

      if (GlobalVariables.lastTwoSec == null) {
        GlobalVariables.lastTwoSec = new LastTwoSecQueue();
      } else {
        // Clears the queue
        GlobalVariables.lastTwoSec.clear();
      }

      SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(App.this);
      if (!prefs.getBoolean("isClassifierBuilt", false)) {
        Tranny t1 = new Tranny();
        flag = t1.build();

        SharedPreferences.Editor editor = prefs.edit();
        editor.putBoolean("isClassifierBuilt", true);
        editor.commit();
      }

      if (!prefs.getBoolean("copiedKDDTrainingDataset", false)) {
        InputStream in = null;
        OutputStream out = null;
        try {
          String appFilesDirectory = Environment.getExternalStorageDirectory().getAbsolutePath();
          String filename = "kddreduced.arff";

          in = getApplicationContext().getResources().openRawResource(R.raw.kddreduced);
          File outFile = new File(appFilesDirectory, filename);
          out = new FileOutputStream(outFile);
          copyFile(in, out);
          in.close();
          in = null;
          out.flush();
          out.close();
          out = null;

          // Mark that tcpdump has been installed
          SharedPreferences.Editor editor = prefs.edit();
          editor.putBoolean("copiedKDDTrainingDataset", true);
          editor.commit();
        } catch (IOException e) {
          Log.d("App", "File failed to copy");
        }
      }

      installTcpdumpBinary();

      return null;
    }
 /** Write the current valuse of the preferences to the SharedPreferences storage area */
 private void savePrefs() {
   SharedPreferences settings = getSharedPreferences("WhereAreYou", MODE_PRIVATE);
   SharedPreferences.Editor editor = settings.edit();
   editor.putBoolean("Active", mActive);
   editor.putString("Password", mPassword);
   editor.putInt("TimeOutSec", mTimeOutSec);
   editor.putBoolean("UseGPS", mUseGPS);
   editor.commit();
 }
  public void logoutLand(View view) {
    SharedPreferences sharedPref = getSharedPreferences(PREFRENCES_NAME, 0);
    SharedPreferences.Editor editor = sharedPref.edit();
    editor.putBoolean("isRegistered", true);
    editor.putBoolean("isLoggedin", false);
    editor.commit();

    Intent intent = new Intent(this, LoginActivity.class);
    startActivity(intent);
  }
Beispiel #22
0
 public void saveConfigOption() {
   SharedPreferences.Editor edit = mSharedPreferences.edit();
   edit.putBoolean("order", mOrder);
   edit.putInt("page_size", mPageSize);
   edit.putInt("list_pattern", mListPattern);
   edit.putInt("max_concurrent", mMaxConcurrent);
   edit.putBoolean("http_range", mEnbaleHttpRange);
   edit.putBoolean("dw_cache_clean", mEnbaleCleanDwCache);
   edit.putBoolean("http_keepalive", mEnableHttpKeepAlive);
   edit.commit();
 }
  public void saveSettings() {
    SharedPreferences settings = getActivity().getSharedPreferences(PREF_TITLE, 0);
    SharedPreferences.Editor editor = settings.edit();
    StringBuilder sb = new StringBuilder();

    if (verify() == true) {
      sb = new StringBuilder();

      String url = sb.append(et_serv.getText()).toString();
      sb.setLength(0);
      String user = sb.append(et_user.getText()).toString();
      sb.setLength(0);
      String pass = sb.append(et_pass.getText()).toString();
      sb.setLength(0);
      int threads = Integer.parseInt(sb.append(et_thread.getText()).toString());
      sb.setLength(0);
      float throttle = (float) sb_throttle.getProgress() / 100;
      sb.setLength(0);
      long scantime = Long.parseLong(sb.append(et_scanTime.getText()).toString());
      sb.setLength(0);
      long retrypause = Long.parseLong(sb.append(et_retryPause.getText()).toString());

      settings = getActivity().getSharedPreferences(PREF_TITLE, 0);
      editor = settings.edit();
      editor.putString(PREF_URL, url);
      editor.putString(PREF_USER, user);
      editor.putString(PREF_PASS, pass);
      editor.putInt(PREF_THREAD, threads);
      Log.i("LC", "Settings: Throttle: " + throttle);
      editor.putFloat(PREF_THROTTLE, throttle);
      editor.putLong(PREF_SCANTIME, scantime);
      editor.putLong(PREF_RETRYPAUSE, retrypause);
      editor.putBoolean(PREF_BACKGROUND, cb_service.isChecked());
      editor.putBoolean(PREF_DONATE, cb_donate.isChecked());

      Log.i("LC", "Settings: Pri " + (String) spn_priority.getSelectedItem());
      if (spn_priority.getSelectedItemPosition() == 0) {
        editor.putInt(PREF_PRIORITY, Thread.MIN_PRIORITY);
      }
      if (spn_priority.getSelectedItemPosition() == 1) {
        editor.putInt(PREF_PRIORITY, Thread.NORM_PRIORITY);
      }
      if (spn_priority.getSelectedItemPosition() == 2) {
        editor.putInt(PREF_PRIORITY, Thread.MAX_PRIORITY);
      }
      Log.i("LC", "Settings: Settings saved");
      editor.commit();
      Toast.makeText(getActivity(), "Settings Saved", Toast.LENGTH_SHORT).show();
    } else {
      Log.i("LC", "Settings: Invalid Input");
      Toast.makeText(getActivity(), "Settings: Errors changed to red", Toast.LENGTH_SHORT).show();
    }
    editor.commit();
  }
 /* Saves app state to SharedPreferences */
 private void saveAppState(Context context) {
   SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context);
   SharedPreferences.Editor editor = settings.edit();
   editor.putInt(TransistorKeys.PREF_STATION_ID_CURRENTLY_PLAYING, mStationIDCurrent);
   editor.putInt(TransistorKeys.PREF_STATION_ID_LAST, mStationIDLast);
   editor.putBoolean(TransistorKeys.PREF_PLAYBACK, mPlayback);
   editor.putBoolean(TransistorKeys.PREF_TIMER_RUNNING, mSleepTimerRunning);
   editor.apply();
   LogHelper.v(
       LOG_TAG,
       "Saving state (" + mStationIDCurrent + " / " + mStationIDLast + " / " + mPlayback + ")");
 }
Beispiel #25
0
  public void onClick(View v) {
    if (v.getId() == R.id.resetfontbutton) {
      SeekBar bar = (SeekBar) findViewById(R.id.fontSizeBar);
      // int size = bar.getProgress();
      bar.setProgress(SETTINGS_DEFAULTFONTSIZE);
      Utils.showToastShort(context, context.getResources().getString(R.string.fontResetDone));

    } else if (v.getId() == R.id.applybutton) {

      System.out.println("clicked on save settings button");
      // Push widget update to surface with newly set prefix
      AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
      int[] id = new int[1];
      id[0] = mAppWidgetId;
      // update the widget

      // Make sure we pass back the original appWidgetId

      //    boolean notification = false;

      RadioGroup radio = (RadioGroup) findViewById(R.id.radioGroup);
      CheckBox box = (CheckBox) findViewById(R.id.notificationBox);

      boolean showDark = (radio.getCheckedRadioButtonId() == R.id.radioDark);
      System.out.println("starting to update settings");
      SeekBar bar = (SeekBar) findViewById(R.id.fontSizeBar);

      CalendarWidget.updateSettings(
          bar.getProgress(), showDark, context, appWidgetManager, mAppWidgetId);
      System.out.println("settings updated");
      SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
      SharedPreferences.Editor ed = prefs.edit();
      ed.putBoolean(SETTINGS_showDark, showDark);
      ed.putInt(SETTINGS_FONTSIZE, bar.getProgress());
      if (box == null) {
        Toast.makeText(this, "box is null", Toast.LENGTH_LONG).show();

      } else ed.putBoolean(SETTINGS_showNotification, box.isChecked());

      ed.commit();

      System.out.println("commited stuff");

      Intent resultValue = new Intent();
      resultValue.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, mAppWidgetId);
      setResult(RESULT_OK, resultValue);
      System.out.println("created result intent value");
      Utils.showToastShort(context, context.getResources().getString(R.string.settingsSaved));
      finish();
    }
  }
Beispiel #26
0
 protected void saveSPrf() {
   // SharedPreferences에서 범례 출력 사항을 저장한다.
   if (sprf == null) {
     sprf = getSharedPreferences("list_category", MODE_PRIVATE);
   }
   SharedPreferences.Editor editor = sprf.edit();
   for (int i = 0; i < CategoryAdapter.selectedItemsIds.size(); i++) {
     editor.putBoolean(CategoryAdapter.items[i], CategoryAdapter.selectedItemsIds.get(i));
   }
   editor.putBoolean("전체", CategoryAdapter.total);
   // 저장
   editor.commit();
   Log.d(TAG, "Save: " + CategoryAdapter.selectedItemsIds.toString());
 }
  private static boolean isFavoritesMigrated(Context context) {
    SharedPreferences settings = context.getSharedPreferences("sthlmtraveling", MODE_PRIVATE);
    boolean migrated = settings.getBoolean("converted_favorites", false);
    if (migrated) {
      Log.d(TAG, "Favorites converted.");
      return true;
    }

    FavoritesDbAdapter favoritesDbAdapter = null;
    try {
      favoritesDbAdapter = new FavoritesDbAdapter(context);
      favoritesDbAdapter.open();
      Cursor favoritesCursor = favoritesDbAdapter.fetch();
      if (favoritesCursor.getCount() == 0) {
        // Also mark it as migrated to avoid sending an intent.
        SharedPreferences.Editor editor = settings.edit();
        editor.putBoolean("converted_favorites", true);
        editor.apply();
        migrated = true;
      }
    } finally {
      if (favoritesDbAdapter != null) {
        favoritesDbAdapter.close();
      }
    }
    if (migrated) {
      Log.d(TAG, "No previous favorites, treat as converted.");
      return true;
    }

    String[] projection =
        new String[] {
          Journeys._ID, // 0
        };
    ContentResolver resolver = context.getContentResolver();
    Cursor journeyCursor = resolver.query(Journeys.CONTENT_URI, projection, null, null, null);
    if (journeyCursor.getCount() > 0) {
      journeyCursor.close();
      // Also mark it as migrated to avoid sending an intent.
      SharedPreferences.Editor editor = settings.edit();
      editor.putBoolean("converted_favorites", true);
      editor.apply();

      Log.d(TAG, "Existing journeys, treat as converted.");
      return true;
    }
    journeyCursor.close();

    return false;
  }
  /** Saves the users settings persistently. */
  protected void savePreferences() {
    SharedPreferences settings = GlobalContext.getGC().getPreferences(0);
    SharedPreferences.Editor editor = settings.edit();

    editor.putBoolean(genPrefKey(LocalWorkspace.HAS_PREFS_KEY), true);

    editor.putBoolean(genPrefKey(LocalWorkspace.IS_PUBLIC_KEY), isPublic());
    editor.putStringSet(genPrefKey(LocalWorkspace.TAGS_KEY), new HashSet<>(getTags()));
    editor.putStringSet(genPrefKey(LocalWorkspace.USERACL_KEY), new HashSet<>(getUserACL()));
    editor.putInt(genPrefKey(LocalWorkspace.SIZE_KEY), getMaxSpace());

    editor.apply();

    Log.i(Constants.LOG_TAG, String.format("LocalWorkspace.savePreferences, name: %s", getName()));
  }
Beispiel #29
0
  /**
   * Saves the settings from the checkboxes & student id textbox
   *
   * @param sstudentID The id of the student
   * @param aadjustWiFi Whether the student wants the wifi to be toggled by the app
   * @param aadjustSound Whether the student wants the app to control the sound profile
   * @param aadjustBrightness Whether the student wants the app to control the brightness
   */
  public static void saveSettings(
      int sstudentID, boolean aadjustWiFi, boolean aadjustSound, boolean aadjustBrightness) {
    // saves the settings in the class fields
    adjustBrightness = aadjustBrightness;
    adjustWiFi = aadjustWiFi;
    adjustSound = aadjustSound;
    studentID = sstudentID;

    // saves the settings in the editor so they will be kept when the app will close
    editor.putInt("studentID", studentID);
    editor.putBoolean("adjustWiFi", adjustWiFi);
    editor.putBoolean("adjustSound", adjustSound);
    editor.putBoolean("adjustBrightness", adjustBrightness);
    editor.commit();
  }
Beispiel #30
0
 public void setShouldBootWithSystem(boolean value) {
   String key = this.getClass().getName();
   SharedPreferences settings = getSharedPreferences(key, 0);
   SharedPreferences.Editor editor = settings.edit();
   editor.putBoolean(SETTING_BOOT_WITH_SYSTEM, value);
   editor.commit();
 }