@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();
  }
Example #2
1
    @Override
    public boolean onContextItemSelected(MenuItem item) {

      int posn = (int) ((AdapterContextMenuInfo) item.getMenuInfo()).position;
      Codec c = codecs.elementAt(posn);
      if (item.getItemId() == MENU_UP) {
        if (posn == 0) return super.onContextItemSelected(item);
        Codec tmp = codecs.elementAt(posn - 1);
        codecs.set(posn - 1, c);
        codecs.set(posn, tmp);
      } else if (item.getItemId() == MENU_DOWN) {
        if (posn == codecs.size() - 1) return super.onContextItemSelected(item);
        Codec tmp = codecs.elementAt(posn + 1);
        codecs.set(posn + 1, c);
        codecs.set(posn, tmp);
      }
      PreferenceScreen ps = getPreferenceScreen();
      SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(Receiver.mContext);
      String v = "";
      SharedPreferences.Editor e = sp.edit();

      for (Codec d : codecs) v = v + d.number() + " ";
      e.putString(Settings.PREF_CODECS, v);
      e.commit();
      ps.removeAll();
      addPreferences(ps);
      return super.onContextItemSelected(item);
    }
Example #3
0
  @Override
  protected void onPause() {
    super.onPause();

    SharedPreferences hints = getSharedPreferences("MyPref", Context.MODE_PRIVATE);
    SharedPreferences.Editor hintchanger = hints.edit();

    hintchanger.putInt("hints", hints.getInt("hints", 10));
    hintchanger.commit();

    SharedPreferences pref = getSharedPreferences("MyPref", Context.MODE_PRIVATE);
    SharedPreferences.Editor editor = pref.edit();
    editor.putInt("SoundNumber", pref.getInt("SoundNumber", 0));
    editor.commit();

    SharedPreferences pagenumber = getSharedPreferences("MyPref", Context.MODE_PRIVATE);
    SharedPreferences.Editor changer = pagenumber.edit();
    changer.putInt("PageNumber", pagenumber.getInt("PageNumber", 0));
    changer.commit();

    SharedPreferences correctcounter = getSharedPreferences("MyPref", Context.MODE_PRIVATE);
    SharedPreferences.Editor counterchanger = correctcounter.edit();
    counterchanger.putInt("correctno", correctcounter.getInt("correctno", 0));
    counterchanger.commit();
  }
Example #4
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();
    }
  }
Example #5
0
  // Go Back to Title Screen
  @Override
  public void onBackPressed() {

    // Get New Values
    int theme = themeSpinner.getSelectedItemPosition();
    int controls = controlsSpinner.getSelectedItemPosition();
    int view = viewSpinner.getSelectedItemPosition();
    int speed = speedSpinner.getSelectedItemPosition();

    // Save in Settings
    // Speed Setting is Stored in a Different File Because It Should Not Be Synced Across Devices
    userPreferencesEditor = userPreferences.edit();
    userPreferencesEditor.putInt("theme", theme);
    userPreferencesEditor.putInt("controls", controls);
    userPreferencesEditor.putInt("view", view);
    speedSettingEditor = speedSetting.edit();
    speedSettingEditor.putInt("speed", speed);
    userPreferencesEditor.commit();
    speedSettingEditor.commit();

    // Call for Backup
    BackupManager backupManager = new BackupManager(this);
    backupManager.dataChanged();

    // Go Home & Close Options Screen
    Intent intent = new Intent(this, TitleScreen.class);
    startActivity(intent);
    this.finish();
  }
Example #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();
   }
 }
  @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;
  }
  private void updateSummaries() {
    int t = PREFS_DEFAULT_LOCATION_TIMEOUT;
    try {
      t =
          Integer.parseInt(
              prefs.getString(PREFS_KEY_LOCATION_TIMEOUT, "" + PREFS_DEFAULT_LOCATION_TIMEOUT));
      if (t < 1) {
        t = PREFS_DEFAULT_LOCATION_TIMEOUT;
        final SharedPreferences.Editor edit = prefs.edit();
        edit.putString(PREFS_KEY_LOCATION_TIMEOUT, "" + t);
        edit.commit();
      }
    } catch (final Exception e) {
      t = PREFS_DEFAULT_LOCATION_TIMEOUT;
      final SharedPreferences.Editor edit = prefs.edit();
      edit.putString(PREFS_KEY_LOCATION_TIMEOUT, "" + t);
      edit.commit();
    }
    final EditTextPreference timeout =
        (EditTextPreference) prefFrag.findPreference(PREFS_KEY_LOCATION_TIMEOUT);
    String summary = getResources().getString(R.string.pref_geolocation_timeout_summary);
    summary += "\nTimeout: '" + t + "'";
    timeout.setSummary(summary);

    final Preference povider = prefFrag.findPreference(PREFS_KEY_OPENCELLID_PROVIDER);
    final Preference gps = prefFrag.findPreference(PREFS_KEY_GPS);
    final boolean en = prefs.getBoolean(PREFS_KEY_LOCATE, PREFS_DEFAULT_LOCATE);
    povider.setEnabled(en);
    timeout.setEnabled(en);
    gps.setEnabled(en);
  }
  public void prevactivity_skipping(View view) {

    if (skip_pressed == true) {
      SharedPreferences.Editor editor = sharedpreferences.edit();
      editor.putString("Radiobuttonteaming1", "NA");
      editor.putString("Radiobuttonteaming2", "NA");
      editor.putString("Teamingskipped", "skipped");
      editor.commit();
      Intent intent = new Intent(this, RecordSkipping.class);
      intent.putExtra("activity", "prevskipping");
      intent.putExtra("TesterName", user_name);
      startActivity(intent);
    } else {
      rgrp1 = (RadioGroup) findViewById(R.id.rgrp1);
      radioButtonID1 = rgrp1.getCheckedRadioButtonId();

      rgrp2 = (RadioGroup) findViewById(R.id.rgrp2);
      radioButtonID2 = rgrp2.getCheckedRadioButtonId();
      //            if (radioButtonID1 == -1 || radioButtonID2 == -1)
      //                Toast.makeText(getBaseContext(), "Please select one option from each type
      // !", Toast.LENGTH_LONG).show();
      //            else {
      SharedPreferences.Editor editor = sharedpreferences.edit();
      editor.putInt("teamingidround1", radioButtonID1);
      editor.putInt("teamingidround2", radioButtonID2);
      editor.putString("Teamingskipped", "notskipped");
      editor.commit();
      Intent intent = new Intent(this, RecordSkipping.class);
      intent.putExtra("activity", "prevskipping");
      intent.putExtra("TesterName", user_name);
      startActivity(intent);
      // }
    }
  }
  @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;
    }
  }
 @Override
 public void onStopTrackingTouch(SeekBar seekBar) {
   // TODO Auto-generated method stub
   switch (seekBar.getId()) {
     case R.id.seekBar_minLevel:
       spe.putInt(SEEKBAR_MIN_LEVEL, seekBar.getProgress());
       while (!spe.commit()) {}
       mainFragment.rebuildSeekbar();
       break;
     case R.id.seekBar_maxLevel:
       spe.putInt(SEEKBAR_MAX_LEVEL, seekBar.getProgress());
       while (!spe.commit()) {}
       mainFragment.rebuildSeekbar();
       break;
     case R.id.seekBar_safetyLevel:
       spe.putInt(SEEKBAR_SAFETY_LEVEL, seekBar.getProgress());
       while (!spe.commit()) {}
       mainFragment.rebuildSeekbar();
       break;
     case R.id.seekBar_VolumeButtonHack:
       spe.putInt(SEEKBAR_VOLUME_BUTTON_HACK, seekBar.getProgress());
       while (!spe.commit()) {}
       Intent service = new Intent(this, MainService.class);
       service.putExtra(MainService.HEADSET_STATUS, MainActivity.TOGGLE_VOLUME_HACK);
       startService(service);
       break;
   }
 }
Example #12
0
  public static void check() {
    HashMap<String, String> old = new HashMap<String, String>(codecs.size());

    for (Codec c : codecs) {
      c.update();
      old.put(c.name(), c.getValue());
      if (!c.isLoaded()) {
        SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(Receiver.mContext);
        SharedPreferences.Editor e = sp.edit();

        e.putString(c.key(), "never");
        e.commit();
      }
    }

    for (Codec c : codecs)
      if (!old.get(c.name()).equals("never")) {
        c.init();
        if (c.isLoaded()) {
          SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(Receiver.mContext);
          SharedPreferences.Editor e = sp.edit();

          e.putString(c.key(), old.get(c.name()));
          e.commit();
          c.init();
        } else c.fail();
      }
  }
Example #13
0
  public void saveGame(int i) {

    // This uses Android's own internal storage-system to save all
    // currently relevent information to restore the game to the
    // beginning of the next wave of creatures.
    // This is probably (read: only meant to work with) best called
    // in between levels when the NextLevel-dialog is shown.

    // Never save multiplayer-status.
    if (multiplayergame == true || survivalGame == true) return;

    if (i == 1) {
      // Log.d("GAMEINIT", "Saving game status...");
      // Save everything.
      SharedPreferences resume = getSharedPreferences("resume", 0);
      SharedPreferences.Editor editor = resume.edit();
      // editor.putInt("map",... <- this is saved above, at the if (mapChoice == 0) check.
      editor.putInt("difficulty", gameLoop.getPlayerData().getDifficulty());
      editor.putInt("health", gameLoop.getPlayerData().getHealth());
      editor.putInt("level", gameLoop.getLevelNumber());
      editor.putInt("money", gameLoop.getPlayerData().getMoney());
      editor.putInt("resumes", resume.getInt("resumes", 0));
      editor.putString("towers", gameLoop.resumeGetTowers());
      editor.commit();
      // Log.d("GAMEINIT","resumes: " + resume.getInt("resumes", 0));
    } else {
      // Log.d("GAMEINIT", "Erasing saved game status.");
      // Dont allow resume. Clears the main resume flag!
      SharedPreferences resume = getSharedPreferences("resume", 0);
      SharedPreferences.Editor editor = resume.edit();
      editor.putInt("resumes", -1);
      editor.commit();
      // Log.d("GAMEINIT","resumes: " + -1);
    }
  }
  @Override
  public void onReceive(Context context, Intent intent) {

    PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
    PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, AppTags.UFRGS_MOBILE);
    // Acquire the lock
    wl.acquire();

    prefs = context.getSharedPreferences(AppTags.LIBRARY_LOGIN_PREF, Context.MODE_PRIVATE);
    editor = prefs.edit();
    int value = prefs.getInt(AppTags.ALARM_COUNTER, 0);
    value = value + 1;
    editor.putInt(AppTags.ALARM_COUNTER, value);
    editor.commit();

    LibraryLoader loader = new LibraryLoader(context);
    loader.renewBooks(null, true);

    if (value == DAILY_RETRIES) {
      launchNotification(
          context,
          context.getString(R.string.we_tried_to_renew_your_items_notification_title),
          context.getString(R.string.verify_return_date_notification_message));
      editor.putInt(AppTags.ALARM_COUNTER, 0);
      editor.commit();
    }

    wl.release();
  }
Example #15
0
  private void saveSetting() {
    for (int i = 0; i < achievements.size(); i++) {
      data.achieveValue.set(i, achievements.get(i).getValue());
    }

    SharedPreferences sharedPreferences =
        PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    SharedPreferences.Editor editor = sharedPreferences.edit();
    editor.putBoolean("isLogin", isLogin);
    editor.putString("Username", data.getUser());
    editor.commit();

    SharedPreferences.Editor sPEditor = getPreferences(Context.MODE_PRIVATE).edit();
    String dataJasonString = convertingDataKeeperToJSONString(data);
    sPEditor.putString("DATAs" + data.getUser(), dataJasonString);
    Log.e("JasonStringSaved", dataJasonString);
    sPEditor.putString("FOODLIST", foodListJson);
    sPEditor.putString("ACTIVITYLIST", activityListJson);
    Calendar calendar = Calendar.getInstance();
    sPEditor.putInt("DAY", calendar.get(Calendar.DAY_OF_MONTH));
    sPEditor.putInt("lvl", data.getlvl());
    sPEditor.putInt("lvlexp", data.getLvlexp());
    sPEditor.commit();

    isLoad = false;
  }
 public void onClickView(View v) {
   SharedPreferences.Editor editor = spre.edit();
   int id = v.getId();
   switch (id) {
     case R.id.button_shared_1: // 获取宿主程序缓存的数据
       String str = spre.getString("Test_Shared", "默认值");
       MyToast.show(this, str);
       break;
     case R.id.button_shared_11: // 清空宿主程序缓存的数据
       editor.remove("Test_Shared");
       editor.commit();
       break;
     case R.id.button_shared_2: // 缓存插件《PluginCode》文本
       editor.putString("Plugin_Data", "PluginCode");
       editor.commit();
       break;
     case R.id.button_shared_3: // 读取插件缓存文本
       String data = spre.getString("Plugin_Data", "默认值");
       MyToast.show(this, data);
       break;
     case R.id.button_shared_4: // 清空插件缓存文本
       editor.remove("Plugin_Data");
       editor.commit();
       break;
   }
 }
Example #17
0
 /** TODO: 一定是x5吗!! */
 public boolean rebuildUrl(String url) {
   String fixedLoginUrl = "";
   String toolbarUrl = "";
   if (!url.startsWith("http")) {
     url = "http://" + url;
   }
   int idx = url.indexOf("/directLogin.w");
   if (idx == -1) {
     if (url.endsWith("/")) {
       url = url.substring(0, url.length() - 1);
     }
     fixedLoginUrl = url + "/mobileUI/portal/directLogin.w";
     toolbarUrl = url + "/mobileUI/portal/mainToolbar.w?time=" + System.currentTimeMillis();
     int respCode = getRespStatus(toolbarUrl);
     if (respCode != 200) {
       toolbarUrl = url + "/x5/mobileUI/portal/mainToolbar.w?time=" + System.currentTimeMillis();
       int code = getRespStatus(toolbarUrl);
       if (code == 200) {
         fixedLoginUrl = url + "/x5/mobileUI/portal/directLogin.w";
         sharedEditor.putString(F_FIXEDLOGINURL, fixedLoginUrl);
         sharedEditor.commit();
       } else {
         loadSuccess = false;
         return false;
       }
     } else {
       fixedLoginUrl = url + "/mobileUI/portal/directLogin.w";
       sharedEditor.putString(F_FIXEDLOGINURL, fixedLoginUrl);
       sharedEditor.commit();
     }
   }
   return true;
 }
Example #18
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == R.id.delete) {
      dbhelper.deleteMarkByID(ChalkmarkID);
      Context context = getApplicationContext();
      AlertDialog.Builder alertbox = new AlertDialog.Builder(context);
      alertbox.setMessage("The Mark Was Deleted");
      SharedPreferences.Editor editor = mPreferences.edit();
      editor.putInt("DefaultTab", 1);
      editor.commit();
      Intent intent = new Intent().setClass(MessageDetails.this, ChalkMarkTabHost.class);
      startActivity(intent);
      finish();
    } else if (item.getItemId() == R.id.map) {
      Intent i = new Intent(MessageDetails.this, MarkInfoMap.class);

      c = dbhelper.getByID(ChalkmarkID);
      c.moveToFirst();

      Double latitude = dbhelper.getLat(c);
      Double longitude = dbhelper.getLon(c);

      i.putExtra(MarkInfoMap.EXTRA_LATITUDE, latitude);
      i.putExtra(MarkInfoMap.EXTRA_LONGITUDE, longitude);
      i.putExtra(MarkInfoMap.EXTRA_NAME, dbhelper.getFromName(c));
      i.putExtra(MarkInfoMap.EXTRA_SUBJECT, dbhelper.getSubject(c));

      dbhelper.close();
      startActivity(i);
    } else if (item.getItemId() == R.id.unread) { // Make the Chalkmark unread
      c = dbhelper.getByID(ChalkmarkID);
      c.moveToFirst();
      dbhelper.updateStatus(ChalkmarkID, "unread");
    } else if (item.getItemId() == R.id.unread) { // Make the Chalkmark unread
      c = dbhelper.getByID(ChalkmarkID);
      c.moveToFirst();
      dbhelper.updateStatus(ChalkmarkID, "unread");
    } else if (item.getItemId() == R.id.repost) {
      c = dbhelper.getByID(ChalkmarkID);
      c.moveToFirst();

      SharedPreferences.Editor editor = mPreferences.edit();
      editor.putString("SavedSubject", dbhelper.getSubject(c));
      editor.putString("SavedBody", dbhelper.getBody(c));
      editor.putInt("SavedExpiration", 25);
      editor.putInt("SavedRadius", 1000);
      editor.putBoolean("SavedImageFlag", imageflag);
      editor.putString("RandomString", dbhelper.getImagePair(c));
      editor.putFloat("MarkLat", (float) dbhelper.getLat(c));
      editor.putFloat("MarkLon", (float) dbhelper.getLon(c));
      editor.commit();

      Intent i = new Intent(MessageDetails.this, MakeMark.class);
      startActivity(i);
      finish();
    }

    return (super.onOptionsItemSelected(item));
  }
Example #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;
    }
Example #20
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);
  }
Example #21
0
  /**
   * Clears the <code>doutput_preserved</code> string in the database, therefore clearing the <code>
   * EditText</code> field in {@link DTypeActivity}. It also writes the <code>cleared</code> boolean
   * to notify the {@link DTypeActivity} of the changes.
   *
   * @param view view.
   */
  public void clearText(View view) {
    SharedPreferences prefs = getSharedPreferences("com.dtype.writer", MODE_PRIVATE);
    String dOutput = "";
    SharedPreferences.Editor editor = prefs.edit();
    editor.putString("doutput_preserved", dOutput);
    editor.commit(); // apply changes

    editor.putBoolean("cleared", true);
    editor.commit(); // apply changes
  }
  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();
  }
  public void nextactivity_visualdiscrimination(View view) {
    rgrp1 = (RadioGroup) findViewById(R.id.rgrp1);
    radioButtonID1 = rgrp1.getCheckedRadioButtonId();
    rgrp2 = (RadioGroup) findViewById(R.id.rgrp2);
    radioButtonID2 = rgrp2.getCheckedRadioButtonId();
    int radioId1 = 0;
    int radioId2 = 0;
    if (!skip_pressed) {
      //            if (radioButtonID1 <= 0 || radioButtonID2 <= 0) {
      //                // Toast.makeText(getBaseContext(), "Please select one option from each type
      // !", Toast.LENGTH_LONG).show();
      //                if(radioButtonID1 <= 0)
      //                    radioButton1 = "NA";
      //                if(radioButtonID2 <= 0)
      //                     radioButton2 ="NA";
      //            }
      //            else {
      RadioButton checkedbutton = (RadioButton) findViewById(radioButtonID1);
      radioId1 = rgrp1.getCheckedRadioButtonId();
      if (radioId1 <= 0) radioButton1 = "NA";
      else radioButton1 = checkedbutton.getText().toString();

      RadioButton checkedbutton1 = (RadioButton) findViewById(radioButtonID2);
      radioId2 = rgrp2.getCheckedRadioButtonId();

      if (radioId2 <= 0) radioButton2 = "NA";
      else radioButton2 = checkedbutton1.getText().toString();

      //     }
      SharedPreferences.Editor editor = sharedpreferences.edit();
      editor.putString("Radiobuttonteaming1", radioButton1);
      editor.putString("Radiobuttonteaming2", radioButton2);
      editor.putInt("teamingidround1", radioId1);
      editor.putInt("teamingidround2", radioId2);
      editor.putString("Teamingskipped", "notskipped");
      editor.commit();
      Intent intent = new Intent(this, RecordVisualDiscrimination.class);
      intent.putExtra("activity", "nextvisualdiscrimination");
      intent.putExtra("TesterName", user_name);
      startActivity(intent);

      //    }
    } else {
      SharedPreferences.Editor editor = sharedpreferences.edit();
      editor.putString("Radiobuttonteaming1", "NA");
      editor.putString("Radiobuttonteaming2", "NA");
      editor.putString("Teamingskipped", "skipped");
      editor.commit();
      Intent intent = new Intent(this, RecordVisualDiscrimination.class);
      intent.putExtra("activity", "nextvisualdiscrimination");
      intent.putExtra("TesterName", user_name);
      startActivity(intent);
    }
  }
Example #24
0
  public synchronized void onSharedPreferenceChanged(
      SharedPreferences sharedPreferences, String key) {
    SharedPreferences.Editor prefEditor = prefs.edit();

    // If the user wants to open the last used database when we start up, store the location.
    if (prefs.getBoolean("openLastUsed", false)) {
      prefEditor.putString("Full Path", fullPath);
      prefEditor.commit();
    } else {
      prefEditor.putString("Full Path", "");
      prefEditor.commit();
    }
  }
Example #25
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    SharedPreferences preferences;
    String lang;
    String tmp_startDir;

    preferences = PreferenceManager.getDefaultSharedPreferences(this);
    lang = preferences.getString("lang", "default");
    if (lang.equals("default")) {
      locale = getResources().getConfiguration().locale.getDefault();
    } else {
      locale = new Locale(lang);
    }
    Locale.setDefault(locale);
    Configuration config = new Configuration();
    config.locale = locale;
    getBaseContext().getResources().updateConfiguration(config, null);

    if (N2DeviceInfo.EINK_ONYX) {
      tmp_startDir = preferences.getString("startDir", "/sdcard,/media/My Files");

      if (tmp_startDir.equals("/sdcard,/media/My Files")) {
        SharedPreferences.Editor editor = preferences.edit();
        editor.putString("startDir", "/mnt/storage");
        editor.commit();
      }

      tmp_startDir = preferences.getString("searchRoot", "/sdcard");
      if (tmp_startDir.equals("/sdcard")) {
        SharedPreferences.Editor editor = preferences.edit();
        editor.putString("searchRoot", "/mnt/storage");
        editor.commit();
      }
    }
    N2EpdController.n2MainActivity = this;

    app = ((ReLaunchApp) getApplicationContext());
    app.RestartIntent =
        PendingIntent.getActivity(
            this, 0, getIntent(), getIntent().getFlags() | Intent.FLAG_ACTIVITY_NEW_TASK);

    Intent intent = new Intent(Main.this, ReLaunch.class);
    intent.putExtra("home", false);
    intent.putExtra("home1", false);
    intent.putExtra("shop", false);
    intent.putExtra("library", false);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    startActivityForResult(intent, 0);
  }
Example #26
0
  // BUTTON FALSE
  public void btnfalse(View view) {

    try {
      mCountDownTimer.cancel();
      customProgress.setProgress(0);
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      if (textviewplusmines.getText().toString() == "+") {
        if (result != myrandomnumbers[0] + myrandomnumbers[1]) {
          count++;
          // moghayese behtarin result ba natijeye hale hazer
          int saved_best_result = pref.getInt("best_result_motevaset", 0);
          if (count >= saved_best_result) {
            editor.putInt("best_result_motevaset", count);
            editor.commit();
          }
          // continue
          trueorfalse();
          myprogressbar();
        } else {
          if (etmam == 1) {
            payan();
            etmam = 2;
          }
        }

      } else if (textviewplusmines.getText().toString() == "-") {
        if (result != myrandomnumbers[0] - myrandomnumbers[1]) {
          count++;
          // moghayese behtarin result ba natijeye hale hazer
          int saved_best_result = pref.getInt("best_result_motevaset", 0);
          if (count >= saved_best_result) {
            editor.putInt("best_result_motevaset", count);
            editor.commit();
          }
          // continue
          trueorfalse();
          myprogressbar();
        } else {
          if (etmam == 1) {
            payan();
            etmam = 2;
          }
        }
      }
    }
  }
Example #27
0
 private static void saveCodecPrefs(SharedPreferences sp) {
   String v = "";
   for (Codec c : codecs) v = v + c.number() + " ";
   SharedPreferences.Editor e = sp.edit();
   e.putString(Settings.PREF_CODECS, v);
   e.commit();
 }
  public static void app_launched(Context context, int days, int launches) {

    SharedPreferences prefs = context.getSharedPreferences(SHARED_PREFS_NAME, 0);

    // Check if app was already rated
    if (prefs.getBoolean("rated", false)) {
      return;
    }

    SharedPreferences.Editor editor = prefs.edit();

    // Increment launch counter
    long launch_count = prefs.getLong("launch_count", 0) + 1;
    editor.putLong("launch_count", launch_count);

    // Get date of first launch
    Long date_firstLaunch = prefs.getLong("date_firstlaunch", 0);
    if (date_firstLaunch == 0) {
      date_firstLaunch = System.currentTimeMillis();
      editor.putLong("date_firstlaunch", date_firstLaunch);
    }

    // Wait at least n days before opening
    if (launch_count >= launches) {
      if (System.currentTimeMillis() >= date_firstLaunch + (days * 24 * 60 * 60 * 1000)) {
        showRateDialog(context, editor);
      }
    }

    editor.commit();
  }
  private void useTheme(final Context context) {
    SharedPreferences preferences =
        context.getSharedPreferences(Theme.PREFS_NAME_THEME_SETTING, Context.MODE_PRIVATE);
    SharedPreferences.Editor editor = preferences.edit();
    editor.putString(Theme.PREFS_KEY_PACKAGE_NAME, entry.getPackageName());
    editor.putInt(Theme.PREFS_KEY_RESOURCE_TYPE, Theme.RESOURCES_FROM_APK);
    editor.putString(Theme.PREFS_KEY_THEME_NAME, entry.getName());
    editor.commit();

    Dialog dialog =
        new AlertDialog.Builder(context)
            .setTitle(R.string.title_dialog_alert)
            .setMessage("重启应用皮肤才能生效,确认要退出应用吗?")
            .setPositiveButton(
                R.string.btn_confirm,
                new DialogInterface.OnClickListener() {
                  @Override
                  public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                    exitApp(context);
                  }
                })
            .setNegativeButton(
                R.string.btn_cancel,
                new DialogInterface.OnClickListener() {
                  @Override
                  public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                  }
                })
            .create();
    dialog.show();
  }
  @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);
  }