public int[] getColor() {
    int key = 9;
    String colorPrimary;
    String colorPrimaryDark;

    settings = context.getSharedPreferences(PREFS, Context.MODE_PRIVATE);
    editor = settings.edit();

    if (!settings.contains("color")) {
      editor.putInt("color", 0).apply();
    }

    if (settings.getInt("color", 0) == 0) {
      Random randomColor = new Random();
      key = randomColor.nextInt(arrayColorPrimary.length);
    } else {
      key = settings.getInt("color", 0) - 1;
    }

    colorPrimary = arrayColorPrimary[key];
    colorPrimaryDark = arrayColorPrimaryDark[key];

    int colorPrimaryAsInt = Color.parseColor(colorPrimary);
    int colorPrimaryDarkAsInt = Color.parseColor(colorPrimaryDark);

    return new int[] {colorPrimaryAsInt, colorPrimaryDarkAsInt};
  }
Exemplo n.º 2
0
  /**
   * loads saved settings from files
   *
   * @author ricky barrette
   */
  private void loadSettings() {

    int lat =
        mSettings.getInt(Settings.LAT, 0); // mFileStream.readInteger(getString(R.string.lat));
    int lon =
        mSettings.getInt(Settings.LON, 0); // mFileStream.readInteger(getString(R.string.lon));

    // sets car geopoint up if lat and lon != 0
    if (lat != 0 && lon != 0) {
      setCar(new GeoPoint(lat, lon));
    }

    // sets measurement unit preference
    String mu = mSettings.getString(Settings.MEASUREMENT_UNIT, null);
    if (mu != null) {
      if (mu.equalsIgnoreCase("Standard")) {
        isMetric = false;
      }
      if (mu.equalsIgnoreCase("Metric")) {
        isMetric = true;
      }
    }

    // load compass options
    String compass_option = mSettings.getString(Settings.COMPASS_OPTION, "Small");
    if (compass_option.equalsIgnoreCase("Large")) {
      mMap.setCompassDrawables(R.drawable.needle_lrg, R.drawable.compass_lrg, 110, 110);
    } else if (compass_option.equalsIgnoreCase("Small")) {
      mMap.setCompassDrawables(R.drawable.needle_sm, R.drawable.compass_sm, 40, 40);
    } else {
      mMap.setCompassDrawables(R.drawable.needle_med, R.drawable.compass_med, 70, 70);
    }
  }
Exemplo n.º 3
0
 public static int getInt(String key, int defaultValue, boolean isPublic) {
   if (isPublic) {
     return mSharedPreference.getInt(key, defaultValue);
   } else {
     return mSharedPreference.getInt(userId() + key, defaultValue);
   }
 }
Exemplo n.º 4
0
  public void loadPreferences() {
    // Get the app's shared preferences
    // prefsPrivate = PreferenceManager.getDefaultSharedPreferences(this);
    prefsPrivate = getSharedPreferences("preferences", Context.MODE_PRIVATE);
    int pcounter = prefsPrivate.getInt("pcounter", 0);

    // A program counter
    prefsEditor = prefsPrivate.edit();
    prefsEditor.putInt("pcounter", ++pcounter);
    prefsEditor.commit(); // Very important

    // Facebook access
    String access_token = prefsPrivate.getString("access_token", null);
    Long access_expires = prefsPrivate.getLong("access_expires", 0);
    if (access_token != null) {
      mFacebook.setAccessToken(access_token);
    }
    if (access_expires != 0) {
      mFacebook.setAccessExpires(access_expires);
    }

    // App's private prefs
    game.setPlayer(
        new Player(
            prefsPrivate.getInt("userid", 0),
            prefsPrivate.getString("user", "Anonomous"),
            prefsPrivate.getString("pass", ""),
            prefsPrivate.getString("email", "")));

    game.setCash(prefsPrivate.getInt("cash", GameMechanics.DEFAULT_CASH));
    // Start a RegisterActivity
    /*if(pcounter <= 1 || game.getPlayer().getUserId() == 0)
    	showRegisterActivity();
    return;*/
  }
Exemplo n.º 5
0
  @Override
  public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    Log.i("TAG", "onActivityCreated");
    super.onActivityCreated(savedInstanceState);

    btn_steps = new Button[4];
    btn_steps[0] = (Button) getActivity().findViewById(R.id.step0);
    btn_steps[1] = (Button) getActivity().findViewById(R.id.step1);
    btn_steps[2] = (Button) getActivity().findViewById(R.id.step2);
    btn_steps[3] = (Button) getActivity().findViewById(R.id.step3);

    mMapManeger = new MapManager();

    mapLayout = new MapLayout(getActivity());
    mMapView = mapLayout.getMapView();
    mMapView.setDaumMapApiKey("c7e2c768ceb283cba77acced06e1203b");
    mMapView.setMapViewEventListener(this);
    mMapView.setPOIItemEventListener(this);
    mMapView.setMapType(MapView.MapType.Standard);
    ViewGroup mapViewContainer = (ViewGroup) getActivity().findViewById(R.id.map_view);
    mapViewContainer.addView(mapLayout);

    SharedPreferences sharedPreferences =
        getActivity().getSharedPreferences("GnBang", getContext().MODE_PRIVATE);
    CurrentZoomLevel = sharedPreferences.getInt("Zoomlevel", DEFAULT_ZOOM_LEVEL);
    CurrentLat = sharedPreferences.getFloat("Lat", (float) DEFAULT_LAT);
    CurrentLon = sharedPreferences.getFloat("Lon", (float) DEFAULT_LON);
    CurrentSelect = sharedPreferences.getInt("Select", DEFAULT_SELECT);
    mMapView.setMapCenterPointAndZoomLevel(
        MapPoint.mapPointWithGeoCoord(CurrentLat, CurrentLon), CurrentZoomLevel, true);

    mMapView = mMapManeger.CreateMarker(mMapView, CurrentZoomLevel);
    btn_steps = mMapManeger.SelectCity(CurrentSelect, btn_steps);
  }
    @Override
    protected Boolean doInBackground(Object... params) {
      boolean result = false;
      startingNumber = (Integer) params[1];
      String pathToQuestions =
          params[0] + "?max=" + QUESTION_BATCH_SIZE + "&start=" + startingNumber;

      SharedPreferences settings = getSharedPreferences(GAME_PREFERENCES, Context.MODE_PRIVATE);
      Integer playerId = settings.getInt(GAME_PREFERENCES_PLAYER_ID, -1);
      if (playerId != -1) {
        Log.d(DEBUG_TAG, "Updating score");
        Integer score = settings.getInt(GAME_PREFERENCES_SCORE, -1);
        if (score != -1) {
          pathToQuestions += "&updateScore=yes&updateId=" + playerId + "&score=" + score;
        }
      }

      Log.d(DEBUG_TAG, "path: " + pathToQuestions + " -- Num: " + startingNumber);

      try {
        result = loadQuestionBatch(startingNumber, pathToQuestions);
      } catch (Exception e) {
        Log.d(DEBUG_TAG, "doInBackground-loadQuestionBatch");
      }
      return result;
    }
Exemplo n.º 7
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Log.d(TAG, "onCreate Started");

    setContentView(R.layout.alarm_controller);

    prefs = PreferenceManager.getDefaultSharedPreferences(this);

    tpAlarm = (TimePicker) findViewById(R.id.tpAlarm);
    chkSnooze = (CheckBox) findViewById(R.id.chkSnooze);
    etxtSnoozeMin = (EditText) findViewById(R.id.etxtSnoozeMin);
    Button button = (Button) findViewById(R.id.btnSetAlarm);
    button.setOnClickListener(setAlarmListener);

    btnSetTone = (Button) findViewById(R.id.btnSetTone);
    btnSetTone.setOnClickListener(setTone);

    tpAlarm.setCurrentHour(prefs.getInt(M_HOUR, 0));
    tpAlarm.setCurrentMinute(prefs.getInt(M_MINT, 0));
    chkSnooze.setChecked(prefs.getBoolean(M_SNOOZE, false));
    etxtSnoozeMin.setText(prefs.getString(SNOOZE_T, "0"));

    Locale loc = new Locale("en");
    Log.i(TAG, Arrays.toString(loc.getAvailableLocales()));
  }
Exemplo n.º 8
0
  /**
   * Generic Android <code>onCreate</code> method.
   *
   * @param savedInstanceState
   */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.opt);

    // Enabling dithering for the whole window to ensure gradients shown right later.
    getWindow().setFormat(PixelFormat.RGBA_8888);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_DITHER);

    // Theme selection routine
    SharedPreferences prefs = getSharedPreferences("com.dtype.writer", MODE_PRIVATE);
    int Theme = 1;
    int Font = 1;
    int Size = 1;

    Theme = prefs.getInt("theme", Theme);
    Font = prefs.getInt("font", Font);
    Size = prefs.getInt("size", Size);

    // Selecting theme
    selectedTheme(Theme, this);

    // Selecting font
    selectedFont(Font, this);

    // Selecting font size
    selectedSize(Size, this);
  };
  public void loadSettings() {
    // if does not exist load default
    SharedPreferences settings = getActivity().getSharedPreferences(PREF_TITLE, 0);
    StringBuilder sb = new StringBuilder();
    et_serv.setText(settings.getString(PREF_URL, DEFAULT_URL));
    et_user.setText(settings.getString(PREF_USER, DEFAULT_USER));
    et_pass.setText(settings.getString(PREF_PASS, DEFAULT_PASS));
    et_thread.setText(sb.append(settings.getInt(PREF_THREAD, DEFAULT_THREAD)).toString());
    sb.setLength(0);
    sb_throttle.setProgress((int) (settings.getFloat(PREF_THROTTLE, DEFAULT_THROTTLE) * 100));
    et_scanTime.setText(sb.append(settings.getLong(PREF_SCANTIME, DEFAULT_SCANTIME)).toString());
    sb.setLength(0);
    et_retryPause.setText(
        sb.append(settings.getLong(PREF_RETRYPAUSE, DEFAULT_RETRYPAUSE)).toString());
    cb_service.setChecked(settings.getBoolean(PREF_BACKGROUND, DEFAULT_BACKGROUND));
    cb_donate.setChecked(settings.getBoolean(PREF_DONATE, DEFAULT_DONATE));

    if (settings.getInt(PREF_PRIORITY, DEFAULT_PRIORITY) == Thread.MIN_PRIORITY) {
      spn_priority.setSelection(0);
    }
    if (settings.getInt(PREF_PRIORITY, DEFAULT_PRIORITY) == Thread.NORM_PRIORITY) {
      spn_priority.setSelection(1);
    }
    if (settings.getInt(PREF_PRIORITY, DEFAULT_PRIORITY) == Thread.MAX_PRIORITY) {
      spn_priority.setSelection(2);
    }

    Toast.makeText(getActivity(), "Settings Loaded", Toast.LENGTH_SHORT).show();
  }
Exemplo n.º 10
0
  @Override
  public void initView() {
    // TODO Auto-generated method stub
    initBaseView("电台参数设置");
    Btn_Left.setOnClickListener(this);
    Btn_Right.setBackgroundResource(R.drawable.btsure);
    Btn_Right.setOnClickListener(this);

    edit_senddelay = (EditText) findViewById(R.id.edit_senddelay);
    edit_recvdelay = (EditText) findViewById(R.id.edit_recedelay);
    sp_type = (Spinner) findViewById(R.id.sp_casttype);
    sp_power = (Spinner) findViewById(R.id.sp_casrpower);

    ArrayAdapter<String> typeadapter =
        new ArrayAdapter<String>(mContext, android.R.layout.simple_spinner_dropdown_item, Type);
    sp_type.setAdapter(typeadapter);

    ArrayAdapter<String> poweradapter =
        new ArrayAdapter<String>(mContext, android.R.layout.simple_spinner_dropdown_item, Power);
    sp_power.setAdapter(poweradapter);

    edit_senddelay.setText(sp.getString(senddeley, ""));
    edit_recvdelay.setText(sp.getString(recvdeley, ""));

    sp_power.setSelection(sp.getInt(powerindex, 0));
    sp_type.setSelection(sp.getInt(typeindex, 0));
  }
Exemplo n.º 11
0
 private void readFromSharedPref(SharedPreferences prefs) {
   mStartTime = prefs.getLong(Stopwatches.PREF_START_TIME, 0);
   mAccumulatedTime = prefs.getLong(Stopwatches.PREF_ACCUM_TIME, 0);
   mState = prefs.getInt(Stopwatches.PREF_STATE, Stopwatches.STOPWATCH_RESET);
   int numLaps = prefs.getInt(Stopwatches.PREF_LAP_NUM, Stopwatches.STOPWATCH_RESET);
   if (mLapsAdapter != null) {
     long[] oldLaps = mLapsAdapter.getLapTimes();
     if (oldLaps == null || oldLaps.length < numLaps) {
       long[] laps = new long[numLaps];
       long prevLapElapsedTime = 0;
       for (int lap_i = 0; lap_i < numLaps; lap_i++) {
         String key = Stopwatches.PREF_LAP_TIME + Integer.toString(lap_i + 1);
         long lap = prefs.getLong(key, 0);
         laps[numLaps - lap_i - 1] = lap - prevLapElapsedTime;
         prevLapElapsedTime = lap;
       }
       mLapsAdapter.setLapTimes(laps);
     }
   }
   if (prefs.getBoolean(Stopwatches.PREF_UPDATE_CIRCLE, true)) {
     if (mState == Stopwatches.STOPWATCH_STOPPED) {
       doStop();
     } else if (mState == Stopwatches.STOPWATCH_RUNNING) {
       doStart(mStartTime);
     } else if (mState == Stopwatches.STOPWATCH_RESET) {
       doReset();
     }
   }
 }
  public CategoryAdapter(Context context, List<Category> categories) {
    this.mInflater = LayoutInflater.from(context);
    this.context = context;

    int filterCategories =
        ((ReadingChallengeApplication) context.getApplicationContext()).getFilterCategories();
    SharedPreferences sharedPref =
        context.getSharedPreferences("readingchallenge", Context.MODE_PRIVATE);
    // if categories read
    if (filterCategories == 1) {
      for (Category cat : categories) {
        if (sharedPref.getInt(context.getString(R.string.category_id) + cat.getId(), 0) == 1) {
          mItems.add(
              new Item(cat.getId(), cat.getLibelle_en(), cat.getLibelle_fr(), cat.getImage()));
        }
      }
    }
    // if categories unread
    else if (filterCategories == 2) {
      for (Category cat : categories) {
        if (sharedPref.getInt(context.getString(R.string.category_id) + cat.getId(), 0) == 0) {
          mItems.add(
              new Item(cat.getId(), cat.getLibelle_en(), cat.getLibelle_fr(), cat.getImage()));
        }
      }
    }
    // else all categories : no filter
    else {
      for (Category cat : categories) {
        mItems.add(new Item(cat.getId(), cat.getLibelle_en(), cat.getLibelle_fr(), cat.getImage()));
      }
    }
  }
Exemplo n.º 13
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();
  }
  public static void suggestWallpaperDimension(
      Resources res,
      final SharedPreferences sharedPrefs,
      WindowManager windowManager,
      final WallpaperManager wallpaperManager,
      boolean fallBackToDefaults) {
    final Point defaultWallpaperSize = getDefaultWallpaperSize(res, windowManager);
    // If we have saved a wallpaper width/height, use that instead

    int savedWidth = sharedPrefs.getInt(WALLPAPER_WIDTH_KEY, -1);
    int savedHeight = sharedPrefs.getInt(WALLPAPER_HEIGHT_KEY, -1);

    if (savedWidth == -1 || savedHeight == -1) {
      if (!fallBackToDefaults) {
        return;
      } else {
        savedWidth = defaultWallpaperSize.x;
        savedHeight = defaultWallpaperSize.y;
      }
    }

    if (savedWidth != wallpaperManager.getDesiredMinimumWidth()
        || savedHeight != wallpaperManager.getDesiredMinimumHeight()) {
      wallpaperManager.suggestDesiredDimensions(savedWidth, savedHeight);
    }
  }
Exemplo n.º 15
0
  public static void updateEqualizerSettings(Context context) {

    SharedPreferences mPreferences =
        context.getSharedPreferences(
            APOLLO_PREFERENCES, Context.MODE_WORLD_READABLE | Context.MODE_WORLD_WRITEABLE);

    if (mBoost != null) {
      mBoost.setEnabled(mPreferences.getBoolean("simple_eq_boost_enable", false));
      mBoost.setStrength((short) (mPreferences.getInt("simple_eq_bboost", 0) * 10));
    }

    if (mEqualizer != null) {
      mEqualizer.setEnabled(mPreferences.getBoolean("simple_eq_equalizer_enable", false));
      short numBands = mEqualizer.getNumberOfBands() <= 6 ? mEqualizer.getNumberOfBands() : 6;
      short r[] = mEqualizer.getBandLevelRange();
      short min_level = r[0];
      short max_level = r[1];
      for (int i = 0; i <= (numBands - 1); i++) {
        int new_level =
            min_level
                + (max_level - min_level)
                    * mPreferences.getInt("simple_eq_seekbars" + String.valueOf(i), 100)
                    / 100;
        mEqualizer.setBandLevel((short) i, (short) new_level);
      }
    }
  }
Exemplo n.º 16
0
 private void _showData() {
   version = bible.getVersion();
   SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
   fontsize = sp.getInt("fontsize-" + version, 0);
   if (fontsize == 0) {
     fontsize = sp.getInt("fontsize", 16);
   }
   if (fontsize > 32) {
     fontsize = 32;
   }
   if (!osis.equals("")) {
     uri = Provider.CONTENT_URI_CHAPTER.buildUpon().appendEncodedPath(osis).build();
   }
   showView(R.id.search, true);
   if (items == null || items.size() == 0) {
     showView(R.id.items, false);
     showView(R.id.book, true);
     showView(R.id.chapter, true);
     showUri();
   } else {
     showView(R.id.items, true);
     showView(R.id.book, false);
     showView(R.id.chapter, false);
     if (this.index > -1 && this.index < items.size()) {
       showItem(this.index);
     } else {
       showItem(0);
     }
   }
 }
Exemplo n.º 17
0
  public static int readPreference(Context context, String key, int defaultValue) {
    Log.d(TAG, "readPreference : key :" + key + " ; defaultValue : " + defaultValue);
    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);

    Log.d(TAG, "readPreference : key :" + key + " ; value : " + sp.getInt(key, defaultValue));
    return sp.getInt(key, defaultValue);
  }
  @Override
  public Dialog onCreateDialog(Bundle bundle) {
    pref = getActivity().getSharedPreferences(Properties.PREF_MAIN_NAME, Context.MODE_PRIVATE);
    edit = pref.edit();
    utils = new CommonUtils();
    AlertDialog.Builder callBuilder = new AlertDialog.Builder(getActivity());
    LayoutInflater callInflater =
        (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    View view = callInflater.inflate(R.layout.call_dialog_layout, null);
    SeekBar mSeekBarOnLength = (SeekBar) view.findViewById(R.id.seekbar_on_length);
    mSeekBarOnLength.setOnSeekBarChangeListener(this);
    SeekBar mSeekBarOffLength = (SeekBar) view.findViewById(R.id.seekbar_off_length);
    mSeekBarOffLength.setOnSeekBarChangeListener(this);

    btnCancel = (TextView) view.findViewById(R.id.callCancel);
    btnCancel.setOnClickListener(this);
    btnOk = (TextView) view.findViewById(R.id.callOk);
    btnOk.setOnClickListener(this);
    btnTest = (TextView) view.findViewById(R.id.callTest);
    btnTest.setOnClickListener(this);

    onLength = (TextView) view.findViewById(R.id.on_length_ms);
    offLength = (TextView) view.findViewById(R.id.off_length_ms);
    mSeekBarOnLength.setProgress(pref.getInt(Properties.PREF_CALL_ON_LENGTH_VALUE, 500) - 500);
    mSeekBarOffLength.setProgress(pref.getInt(Properties.PREF_CALL_OFF_LENGTH_VALUE, 500) - 500);
    onLength.setText(pref.getInt(Properties.PREF_CALL_ON_LENGTH_VALUE, 500) + " ms");
    offLength.setText(pref.getInt(Properties.PREF_CALL_OFF_LENGTH_VALUE, 500) + " ms");
    callBuilder.setView(view);
    /*.setTitle(R.string.call_title)
    .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {

    	@Override
    	public void onClick(DialogInterface dialog, int which) {


    	}
    })
    .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {

    	@Override
    	public void onClick(DialogInterface dialog, int which) {
    		edit.putInt(Properties.PREF_CALL_ON_LENGTH_VALUE, onProgress);
    		edit.putInt(Properties.PREF_CALL_OFF_LENGTH_VALUE, offProgress);
    		edit.commit();

    	}
    })
    .setNeutralButton(R.string.test_on, new DialogInterface.OnClickListener() {

    	@Override
    	public void onClick(DialogInterface dialog, int which) {


    	}
    });*/

    AlertDialog dialog = callBuilder.create();
    return dialog;
  }
Exemplo n.º 19
0
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    preferences = PreferenceManager.getDefaultSharedPreferences(this);
    addressField = (EditText) findViewById(addressText);
    portField = (EditText) findViewById(portText);
    intervalField = (EditText) findViewById(intervalText);

    addressField.setText(preferences.getString("address", null));
    portField.setText(Integer.toString(preferences.getInt("port", 8080)));
    intervalField.setText(Integer.toString(preferences.getInt("interval", 10)));

    startButton = (ToggleButton) findViewById(R.id.startButton);

    service = new Intent(this, LocationService.class);
    startButton.setOnCheckedChangeListener(
        new CompoundButton.OnCheckedChangeListener() {
          public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {

              /*service.putExtra("address", addressField.getText().toString());
              service.putExtra("port", Integer.parseInt(portField.getText().toString()));
              service.putExtra("interval", Integer.parseInt(intervalField.getText().toString()));*/
              updatePreferences();

              System.out.println("Starting service act");
              startService(service);
            } else {
              stopService(service);
            }
          }
        });
  }
 public static PushRegistration getLatestPushRegistration(Context context) {
   SharedPreferences preferences =
       context.getSharedPreferences(Constants.PREFS_FILE, Context.MODE_PRIVATE);
   String registrationId =
       preferences.getString(Constants.PrefKeys.PUSH_REGISTRATION_INSTANCE_ID, "");
   if (MPUtility.isEmpty(registrationId)) {
     return null;
   }
   String senderId = preferences.getString(Constants.PrefKeys.PUSH_REGISTRATION_SENDER_ID, "");
   // Check if app was updated; if so, it must clear the registration ID
   // since the existing regID is not guaranteed to work with the new
   // app version.
   int registeredVersion =
       preferences.getInt(Constants.PrefKeys.PROPERTY_APP_VERSION, Integer.MIN_VALUE);
   int currentVersion = getAppVersion(context);
   int osVersion = preferences.getInt(Constants.PrefKeys.PROPERTY_OS_VERSION, Integer.MIN_VALUE);
   if (registeredVersion != currentVersion || osVersion != Build.VERSION.SDK_INT) {
     ConfigManager.log(
         MParticle.LogLevel.DEBUG, "App or OS version changed, clearing instance ID.");
     return null;
   }
   PushRegistration registration = new PushRegistration();
   registration.instanceId = registrationId;
   registration.senderId = senderId;
   return registration;
 }
Exemplo n.º 21
0
  @Override
  protected void onResume() {
    Log.d(TAG, "onResume");
    super.onResume();

    tpAlarm.setCurrentHour(prefs.getInt(M_HOUR, 0));
    tpAlarm.setCurrentMinute(prefs.getInt(M_MINT, 0));
    chkSnooze.setChecked(prefs.getBoolean(M_SNOOZE, false));
    etxtSnoozeMin.setText(prefs.getString(SNOOZE_T, "0"));

    if (prefs.getString(TONE, null) != null) {
      String tone = prefs.getString(TONE, null);
      File f = new File("" + tone);
      btnSetTone.setText("Tone " + f.getName());
    } else btnSetTone.setText(getString(R.string.btn_SetAlarmTone));

    if (prefs.getBoolean(FIRST_LAUNCH, true)) {
      Intent checkIntent = new Intent();
      checkIntent.setAction(TextToSpeech.Engine.ACTION_CHECK_TTS_DATA);
      startActivityForResult(checkIntent, MY_DATA_CHECK_CODE);

      SharedPreferences.Editor editor = prefs.edit();

      editor.putBoolean(FIRST_LAUNCH, false);
      editor.commit();
    }
  }
Exemplo n.º 22
0
 private void readCurrentAddressAndPortNum() {
   SharedPreferences preferences =
       ApplicationLoader.applicationContext.getSharedPreferences(
           "dataconfig", Context.MODE_PRIVATE);
   currentPortNum = preferences.getInt("dc" + datacenterId + "port", 0);
   currentAddressNum = preferences.getInt("dc" + datacenterId + "address", 0);
 }
Exemplo n.º 23
0
  @Override
  public void init() {
    if (!pluginEnabled) {
      /* here should be your specific initialization code */

      SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
      frequency = prefs.getInt(EditActivity.PREF_FREQUENCY, 50);
      pluginId = prefs.getInt(EditActivity.KEY_PLUGIN_ID, -1);
      ignoreThreshold = EditActivity.getRate(frequency);

      prefs.registerOnSharedPreferenceChangeListener(this);

      // make sure not to call it twice
      sm = (SensorManager) getSystemService(SENSOR_SERVICE);
      List<Sensor> sensors = sm.getSensorList(Sensor.TYPE_ORIENTATION);
      if (sensors != null && sensors.size() > 0) {
        orientationSensor = sensors.get(0);
        sm.registerListener(this, orientationSensor, SensorManager.SENSOR_DELAY_UI);
        pluginEnabled = true;
      } else {
        Toast.makeText(
                this, "Accelerometer sensor is not available on this device!", Toast.LENGTH_SHORT)
            .show();
      }
    }
  }
Exemplo n.º 24
0
  private byte[] getSetUserSettingWithGoal() {
    String keyprefix = "health.sensor";

    //
    // Default values from device.
    //
    // Todo: need to be derived from history or preferences.
    //

    float BMR = 1507.75f;
    float distanceWalkCM = 103.00f;
    float caloriePer10000Steps = 474.75f;

    SharedPreferences sp = Simple.getSharedPrefs();

    String timeFormatString = sp.getString(keyprefix + ".units.timedisp", "24h");
    String distanceUnitString = sp.getString(keyprefix + ".units.distance", "m");
    String goalUnitString = sp.getString(keyprefix + ".goals.sensor", "steps");

    int timeFormat = timeFormatString.equals("24h") ? 1 : 0;
    int distanceUnit = distanceUnitString.equals("m") ? 1 : 0;
    int goalUnit = goalUnitString.equals("steps") ? 0 : 1;

    int goal = sp.getInt(keyprefix + ".goals.steps", 0);
    if (goalUnit == 1) goal = 100 * sp.getInt(keyprefix + ".goals.calories", 0);

    return getSetUserSettingWithGoal(
        goal, goalUnit, timeFormat, distanceUnit, distanceWalkCM, caloriePer10000Steps, BMR);
  }
Exemplo n.º 25
0
  private Bundle parserRecProgram() {
    ServiceInfoDao serInfoDao = new ServiceInfoDaoImpl(this);
    SharedPreferences spRec =
        getSharedPreferences("dvb_rec", MODE_WORLD_READABLE | MODE_WORLD_WRITEABLE);

    // parser rec programme.
    int recServiceId = spRec.getInt("rec_serviceId", 0);
    int recNumber = spRec.getInt("rec_logicalNumber", 0);
    int recServicePos = spRec.getInt("rec_servicePosition", 0);
    String recServiceName = spRec.getString("rec_serviceName", null);

    ServiceInfoBean rBean = serInfoDao.getChannelInfoByServiceId(recServiceId, recNumber);
    Bundle bundle = new Bundle();
    if (null != rBean) {
      bundle.putInt("ServicePos", recServicePos);
      bundle.putInt("LogicalNumber", recNumber);
      bundle.putInt("ServiceId", recServiceId);
      bundle.putString("ServiceName", recServiceName);
      bundle.putChar("ServiceType", serviceType);
      bundle.putString("superPwd", superPwd);
      bundle.putInt("Grade", grade);
      bundle.putBoolean("RecStatus", recStatus);
    }
    return bundle;
  }
Exemplo n.º 26
0
 public KzxTokenBean getKzxTokenBean() {
   KzxTokenBean kzxTokenBean = new KzxTokenBean();
   SharedPreferences sp = getInstance().getSharedPreferences("kzx_token_info", 0);
   if (!StringUtils.isEmpty(sp.getString("memberId", ""))) {
     kzxTokenBean.setAccountName(sp.getString("accountName", ""));
     kzxTokenBean.setCompanyName(sp.getString("companyName", ""));
     kzxTokenBean.setGrowUp(sp.getInt("growUp", 0));
     kzxTokenBean.setMedalCount(sp.getInt("medalCount", 0));
     kzxTokenBean.setMemberIcon(sp.getString("memberIcon", ""));
     kzxTokenBean.setMemberId(sp.getString("memberId", ""));
     kzxTokenBean.setEncryptMemberId(sp.getString("encryptMemberId", ""));
     kzxTokenBean.setMemberName(sp.getString("memberName", ""));
     kzxTokenBean.setPhone(sp.getString("phone", ""));
     kzxTokenBean.setEmail(sp.getString("email", ""));
     kzxTokenBean.setDepartment(sp.getString("department", ""));
     kzxTokenBean.setLeader(sp.getString("leader", ""));
     kzxTokenBean.setLeaderName(sp.getString("leaderName", ""));
     kzxTokenBean.setClientIds(sp.getString("clientIds", "[]"));
     kzxTokenBean.setAccountId(sp.getString("accountId", ""));
     kzxTokenBean.setEncryptClientIds(sp.getString("encryptClientIds", "[]"));
     kzxTokenBean.setNoReadMessageNum(sp.getString("noReadMessageNum", "0"));
     kzxTokenBean.setIsSendSms(sp.getInt("isSendSms", 1));
   }
   return kzxTokenBean;
 }
Exemplo n.º 27
0
  private boolean passLimitConstrain(int upperBound, int showType) {
    synchronized (mPrefer) {
      long current = System.currentTimeMillis();
      long start = mPrefer.getLong(NotifyAdsDef.PREFER_KEY_STARTTIME, 0);

      if (start == 0) {
        mPrefer.edit().putLong(NotifyAdsDef.PREFER_KEY_STARTTIME, current).commit();
        start = current;
        return true;
      }

      // 如果当前和原先的limit 已经超过了一天,那么就重新设置
      if (current - start > 24 * 3600 * 1000) {
        mPrefer.edit().putLong(NotifyAdsDef.PREFER_KEY_STARTTIME, 0).commit();
        mPrefer.edit().putInt(NotifyAdsDef.PREFER_KEY_NOTIFY_SUCCESS_COUNT, 0).commit();
        mPrefer.edit().putInt(NotifyAdsDef.PREFER_KEY_BUBBLE_SUCCESS_COUNT, 0).commit();
        return true;
      } else {
        // 如果在一天之内,那么我们看是否超出了上限
        if (showType == NotifyAdsDef.ADS_TYPE_NOTIFY) {
          int notifyCount = mPrefer.getInt(NotifyAdsDef.PREFER_KEY_NOTIFY_SUCCESS_COUNT, 0);
          if (notifyCount < upperBound) return true;
        } else if (showType == NotifyAdsDef.ADS_TYPE_BUBBLE) {
          int bubbleCount = mPrefer.getInt(NotifyAdsDef.PREFER_KEY_BUBBLE_SUCCESS_COUNT, 0);
          if (bubbleCount < upperBound * NotifyAdsDef.BUBBLE_LIMIT_TIMES) return true;
        }
      }

      LogUtils.logUpLimit("超过了每天接受广告的上限");
      return false;
    }
  }
Exemplo n.º 28
0
  public static void init(Context context) {
    ChitSettings.context = context;
    preferences = context.getSharedPreferences("mainconfig", Context.MODE_PRIVATE);

    GhostHelper.init(preferences);
    SkinMan.config(preferences);
    NightModeUtil.config(context, preferences);

    GhostModeEnabled = GhostHelper.isGhostEnabled();
    hideTypingState = GhostHelper.isHideTyping();

    confirmBeforeSendingSticker = getTBoolean(confirmStickerKey);
    showTabs = getTBoolean(showTabKey);
    showInviterInGroup = getTBoolean(showInviterKey);
    showMutualDot = getTBoolean(showMutualKey);
    defaultTab = preferences.getInt(defTabKey, DialogActivityH.globalDefaultSelectedTab);
    lastSelectedTab = preferences.getInt(lastSelectedTabKey, -1);

    showFantasy = getTBoolean(fantasyActivityKey);

    channelJoinShown = getBoolean(channelJoinShownKey);

    selectedWallpaper = preferences.getInt(dialogBackKey, defaultBackGround);
    selectedColor = preferences.getInt(dialogColorKey, 0);
    overRideLedColor = getBoolean(overRideLedColorKey);

    loadWallpaper();
  }
  @Override
  public boolean onKeyDown(int keyCode, KeyEvent event) {

    // Hotkeys
    if (keyCode == KeyEvent.KEYCODE_BACK) {

      // If the new interval != the old interval, we got to restart the
      // "alarm"
      if (originalInterval != sharedPreferences.getInt(Constants.SP_BL_INTERVAL_SERVICE, 0)) {

        // Get the interval
        int serviceInterval =
            sharedPreferences.getInt(
                    Constants.SP_BL_INTERVAL_SERVICE, (Constants.HOUR_IN_SECONDS / 2))
                * 1000;

        // Restart the AlarmManager
        AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
        PendingIntent pendingIntent =
            PendingIntent.getService(this, 0, new Intent(this, BattlelogService.class), 0);
        alarmManager.cancel(pendingIntent);
        alarmManager.setInexactRepeating(
            AlarmManager.ELAPSED_REALTIME, 0, serviceInterval, pendingIntent);

        Log.d(
            Constants.DEBUG_TAG,
            "Setting the service to update every " + serviceInterval / 60000 + " minutes");
      }
      startActivity(new Intent(this, DashboardActivity.class));
      finish();
      return true;
    }

    return super.onKeyDown(keyCode, event);
  }
Exemplo n.º 30
0
  /**
   * �?��定位
   *
   * @param manager 位置管理�?
   * @param listener 监听�?
   * @param updatemills 更新间隔(毫秒)
   * @param updateMiles 更新距离(�?
   * @return
   */
  public static Location startLocation(
      LocationManager manager, LocationListener listener, SharedPreferences sharedPreferences) {

    int provider = sharedPreferences.getInt("LocationType", 0);
    String bastProvider = LocationManager.GPS_PROVIDER;
    switch (provider) {
      case 0:
        Criteria criteria = getBastProvider();
        bastProvider = manager.getBestProvider(criteria, false);
        break;
      case 1:
        bastProvider = LocationManager.GPS_PROVIDER;
        break;

      case 2:
        bastProvider = LocationManager.NETWORK_PROVIDER;
        break;

      case 3:
        bastProvider = LocationManager.PASSIVE_PROVIDER;
        break;
    }
    manager.requestLocationUpdates(
        bastProvider,
        sharedPreferences.getInt("HZ_Mills", 15000),
        sharedPreferences.getInt("HZ_Miter", 0),
        listener);
    return manager.getLastKnownLocation(bastProvider);
  }