List of usage examples for android.content SharedPreferences getLong
long getLong(String key, long defValue);
From source file:de.tum.frm2.nicos_android.gui.MainActivity.java
private void onDeviceSelected(Device device) { Object limits = device.getParam("userlimits"); Object mapping = device.getParam("mapping"); if (limits == null && mapping == null) { Toast.makeText(getApplicationContext(), "Cannot move " + device.getName() + ": Limits unknown", Toast.LENGTH_SHORT).show(); return;//from w ww .j a v a 2 s . c om } _currentDevice = device; _currentDeviceTextView.setText(device.getName()); _currentDeviceValueTextView.setText(device.getFormattedValue()); _currentDeviceStatusImageView.setImageResource(DeviceStatus.getStatusResource(device.getStatus())); if (limits != null) { Object o_max = ((Object[]) limits)[1]; double max = (double) o_max; // Try to read a value from the preferences. SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); String coarseKey = _uniquePrefix + _currentDevice.getName() + "coarse"; String fineKey = _uniquePrefix + _currentDevice.getName() + "fine"; if (prefs.contains(coarseKey) && prefs.contains(fineKey)) { long dec_coarse = prefs.getLong(coarseKey, 0); long dec_fine = prefs.getLong(fineKey, 0); _coarseStepEditText.setText(String.valueOf(Double.longBitsToDouble(dec_coarse))); _fineStepEditText.setText(String.valueOf(Double.longBitsToDouble(dec_fine))); } else { // infer default steps from the max limit. _coarseStepEditText.setText(String.valueOf(max / 5)); _fineStepEditText.setText(String.valueOf(max / 10)); } } else { // TODO: Implement devices with mapping! return; } _coarseStepLeftButton.setEnabled(true); _fineStepLeftButton.setEnabled(true); _stopButton.setEnabled(true); _fineStepRightButton.setEnabled(true); _coarseStepRightButton.setEnabled(true); _slidingUpPanelLayout.setEnabled(true); }
From source file:com.nextgis.forestinspector.fragment.MapFragment.java
@Override public void onResume() { super.onResume(); final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); boolean showControls = prefs.getBoolean(SettingsConstants.KEY_PREF_SHOW_ZOOM_CONTROLS, false); showMapButtons(showControls, mMapRelativeLayout); Log.d(Constants.TAG, "KEY_PREF_SHOW_ZOOM_CONTROLS: " + (showControls ? "ON" : "OFF")); if (null != mMap) { float mMapZoom; try {// w ww .j a v a 2 s .c o m mMapZoom = prefs.getFloat(SettingsConstants.KEY_PREF_ZOOM_LEVEL, mMap.getMinZoom()); } catch (ClassCastException e) { mMapZoom = mMap.getMinZoom(); } double mMapScrollX; double mMapScrollY; try { mMapScrollX = Double.longBitsToDouble(prefs.getLong(SettingsConstants.KEY_PREF_SCROLL_X, 0)); mMapScrollY = Double.longBitsToDouble(prefs.getLong(SettingsConstants.KEY_PREF_SCROLL_Y, 0)); } catch (ClassCastException e) { mMapScrollX = 0; mMapScrollY = 0; } mMap.setZoomAndCenter(mMapZoom, new GeoPoint(mMapScrollX, mMapScrollY)); mMap.addListener(this); } mCoordinatesFormat = prefs.getInt(SettingsConstants.KEY_PREF_COORD_FORMAT + "_int", Location.FORMAT_DEGREES); if (null != mCurrentLocationOverlay) { mCurrentLocationOverlay.updateMode(PreferenceManager.getDefaultSharedPreferences(getActivity()) .getString(SettingsConstantsUI.KEY_PREF_SHOW_CURRENT_LOC, "3")); mCurrentLocationOverlay.startShowingCurrentLocation(); } if (null != mGpsEventSource) { mGpsEventSource.addListener(this); } mShowStatusPanel = prefs.getBoolean(SettingsConstantsUI.KEY_PREF_SHOW_STATUS_PANEL, true); if (null != mStatusPanel) { if (mShowStatusPanel) { mStatusPanel.setVisibility(View.VISIBLE); fillStatusPanel(null); } else { mStatusPanel.removeAllViews(); } } mCurrentCenter = null; }
From source file:com.skywomantechnology.app.guildviewer.sync.GuildViewerSyncAdapter.java
/** * Handles setting up the notification./*from w ww. ja v a2 s .co m*/ * There are two situation in which we send a notification * First if there is more recent news than the last sync * Second if the news is concerned with the favorite character * @param context to use for getting preference information * @param newsItem contains the newsItem information used to build the notification * @param notification_id identifier for the notification */ private void notifyNews(Context context, GuildViewerNewsItem newsItem, int notification_id) { // determine if we should send a notification SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); boolean notificationsEnabled = prefs.getBoolean(context.getString(R.string.pref_enable_notifications_key), Boolean.parseBoolean(context.getString(R.string.pref_enable_notifications_default))); long lastNotification = prefs.getLong(context.getString(R.string.pref_last_notification), 0L); boolean timeToNotify = newsItem.getTimestamp() > lastNotification; // we can notify for both new news and for favorite character news if (notificationsEnabled && (timeToNotify || notification_id == GUILD_VIEWER_FAVORITE_CHARACTER_NOTIFICATION)) { // build the information to put into the notification int iconId = R.drawable.ic_launcher; String title = context.getString(R.string.app_name); String news = String.format("%s %s %s", newsItem.getCharacter(), Utility.getNewsTypeVerb(context, newsItem.getType()), Utility.containsItem(newsItem.getType()) ? ((newsItem.getItem() != null) ? newsItem.getItem().getName() : "") : ((newsItem.getAchievement() != null) ? newsItem.getAchievement().getTitle() : "")); String contentText = String.format(context.getString(R.string.format_notification), news); // set the notification to clear after a click NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context).setSmallIcon(iconId) .setContentTitle(title).setContentText(contentText).setOnlyAlertOnce(true).setAutoCancel(true); // Open the app when the user clicks on the notification. Intent resultIntent = new Intent(context, NewsListActivity.class); TaskStackBuilder stackBuilder = TaskStackBuilder.create(context).addParentStack(NewsListActivity.class) .addNextIntent(resultIntent); PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); mBuilder.setContentIntent(resultPendingIntent); // we can notify for two reasons but lets just always have one notification at a time NotificationManager mNotificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); mNotificationManager.notify(GUILD_VIEWER_NOTIFICATION_ID, mBuilder.build()); } }
From source file:it.geosolutions.geocollect.android.core.mission.PendingMissionListActivity.java
@Override public void onLocationChanged(Location location) { Log.v(TAG, "Location: \n lat " + location.getLatitude() + "\n lon " + location.getLongitude()); SharedPreferences sp = getSharedPreferences(SQLiteCascadeFeatureLoader.PREF_NAME, Context.MODE_PRIVATE); // If it is the first time we get a Location, and the list is ordered by distance, refresh the list automatically boolean needRefresh = sp.getBoolean(SQLiteCascadeFeatureLoader.ORDER_BY_DISTANCE, false) && (!sp.contains(SQLiteCascadeFeatureLoader.LOCATION_X) || sp.getLong(SQLiteCascadeFeatureLoader.LOCATION_X, 0) == 0); SharedPreferences.Editor editor = sp.edit(); // Set position editor.putLong(SQLiteCascadeFeatureLoader.LOCATION_X, Double.doubleToRawLongBits(location.getLongitude())); editor.putLong(SQLiteCascadeFeatureLoader.LOCATION_Y, Double.doubleToRawLongBits(location.getLatitude())); editor.apply();/*from w w w . j a va2s. c o m*/ if (needRefresh) { PendingMissionListFragment listFragment = ((PendingMissionListFragment) getSupportFragmentManager() .findFragmentById(R.id.pendingmission_list)); if (listFragment != null) { listFragment.onRefresh(); } } }
From source file:com.geecko.QuickLyric.fragment.LyricsViewFragment.java
public void fetchLyrics(String... params) { if (getActivity() == null) return;/* ww w. j a v a 2 s . com*/ String artist = params[0]; String title = params[1]; String url = null; if (params.length > 2) url = params[2]; startRefreshAnimation(); Lyrics lyrics = null; if (artist != null && title != null) { if (url == null && (getActivity().getSharedPreferences("intro_slides", Context.MODE_PRIVATE).getBoolean("seen", false)) && (mLyrics == null || mLyrics.getFlag() != Lyrics.POSITIVE_RESULT || !("Storage".equals(mLyrics.getSource()) && mLyrics.getArtist().equalsIgnoreCase(artist) && mLyrics.getTitle().equalsIgnoreCase(title)))) lyrics = Id3Reader.getLyrics(getActivity(), artist, title); if (lyrics == null) lyrics = DatabaseHelper.getInstance(getActivity()).get(new String[] { artist, title }); if (lyrics == null) lyrics = DatabaseHelper.getInstance(getActivity()).get(DownloadThread.correctTags(artist, title)); } else if (url == null) { showFirstStart(); return; } boolean prefLRC = PreferenceManager.getDefaultSharedPreferences(getActivity()).getBoolean("pref_lrc", false); if (OnlineAccessVerifier.check(getActivity()) && (lyrics == null || (!lyrics.isLRC() && prefLRC))) { Set<String> providersSet = PreferenceManager.getDefaultSharedPreferences(getActivity()) .getStringSet("pref_providers", new TreeSet<String>()); if (PreferenceManager.getDefaultSharedPreferences(getActivity()).getBoolean("pref_lrc", false)) providersSet.add("ViewLyrics"); DownloadThread.setProviders(providersSet); if (mLyrics == null) { TextView artistTV = (TextView) getActivity().findViewById(R.id.artist); TextView songTV = (TextView) getActivity().findViewById(R.id.song); artistTV.setText(artist); songTV.setText(title); } SharedPreferences preferences = getActivity().getSharedPreferences("current_music", Context.MODE_PRIVATE); boolean positionAvailable = preferences.getLong("position", 0) != -1; if (url == null) new DownloadThread(this, positionAvailable, artist, title).start(); else new DownloadThread(this, positionAvailable, url, artist, title).start(); } else if (lyrics != null) onLyricsDownloaded(lyrics); else { lyrics = new Lyrics(Lyrics.ERROR); lyrics.setArtist(artist); lyrics.setTitle(title); onLyricsDownloaded(lyrics); } }
From source file:com.unovo.frame.utils.SharedPreferencesHelper.java
@SuppressWarnings("TryWithIdenticalCatches") private static <T> Object buildTargetFromSource(Class<T> clx, T target, String preFix, Set<String> existKeys, SharedPreferences sp) { // Each to Object if (clx == null || clx.equals(Object.class)) { return target; }/*from w ww. j a v a 2 s . c o m*/ // Create instance if (target == null) { try { target = clx.newInstance(); } catch (InstantiationException e) { e.printStackTrace(); return null; } catch (IllegalAccessException e) { e.printStackTrace(); return null; } } // Get the class fields Field[] fields = clx.getDeclaredFields(); if (fields == null || fields.length == 0) return target; // Foreach fields for (Field field : fields) { if (isContSupport(field)) continue; final String fieldName = field.getName(); Class<?> fieldType = field.getType(); // Change the Field accessible status boolean isAccessible = field.isAccessible(); if (!isAccessible) field.setAccessible(true); // Build the key String key = preFix + fieldName; // Get target value Object value = null; if (isBasicType(fieldType)) { if (existKeys.contains(key)) { // From the share map if (fieldType.equals(Byte.class) || fieldType.equals(byte.class)) { value = (byte) sp.getInt(key, 0); } else if (fieldType.equals(Short.class) || fieldType.equals(short.class)) { value = (short) sp.getInt(key, 0); } else if (fieldType.equals(Integer.class) || fieldType.equals(int.class)) { value = sp.getInt(key, 0); } else if (fieldType.equals(Long.class) || fieldType.equals(long.class)) { value = sp.getLong(key, 0); } else if (fieldType.equals(Float.class) || fieldType.equals(float.class)) { value = sp.getFloat(key, 0); } else if (fieldType.equals(Double.class) || fieldType.equals(double.class)) { value = Double.valueOf(sp.getString(key, "0.00")); } else if (fieldType.equals(Boolean.class) || fieldType.equals(boolean.class)) { value = sp.getBoolean(key, false); } else if (fieldType.equals(Character.class) || fieldType.equals(char.class)) { value = sp.getString(key, "").charAt(0); } else if (fieldType.equals(String.class)) { value = sp.getString(key, ""); } } } else { value = buildTargetFromSource(fieldType, null, preFix + fieldName + SEPARATOR, existKeys, sp); } // Set the field value if (value != null) { try { field.set(target, value); } catch (IllegalAccessException e) { e.printStackTrace(); Logger.e(TAG, String.format("Set field error, Key:%s, type:%s, value:%s", key, fieldType, value)); } } else { Logger.e(TAG, String.format("Get field value error, Key:%s, type:%s", key, fieldType)); } } // Get super class fields return buildTargetFromSource(clx.getSuperclass(), target, preFix, existKeys, sp); }
From source file:qr.cloud.qrpedia.MessageViewerActivity.java
@Override protected void onPostCreate() { SharedPreferences sharedPreferences = getCloudBackend().getSharedPreferences(); long banCheckTime = sharedPreferences.getLong(getString(R.string.check_ban_time), 0); long versionCheckTime = sharedPreferences.getLong(getString(R.string.check_ban_time), 0); boolean questionnaireCompleted = sharedPreferences .getBoolean(getString(R.string.check_questionnaire_completed), false); int codesScanned = sharedPreferences.getInt(getString(R.string.check_codes_scanned), 0); long currentTime = System.currentTimeMillis(); // show the questionnaire if they haven't already completed it on another device if (codesScanned >= 4 && !questionnaireCompleted) { // delay so we let the UI queries load first new Handler().postDelayed(new Runnable() { @Override/*from w ww. jav a2s. c o m*/ public void run() { CloudCallbackHandler<List<CloudEntity>> userQuestionnaireHandler = new CloudCallbackHandler<List<CloudEntity>>() { @Override public void onComplete(List<CloudEntity> results) { if (results == null) { return; // nothing we can do } if (results.size() == 0) { startActivity(new Intent(MessageViewerActivity.this, QuestionnaireActivity.class)); } else { // so we don't do this query again SharedPreferences sharedPreferences = getCloudBackend().getSharedPreferences(); Editor editor = sharedPreferences.edit(); editor.putBoolean(getString(R.string.check_questionnaire_completed), true); editor.commit(); } } @Override public void onError(IOException exception) { // nothing we can do } }; CloudQuery cloudQuery = new CloudQuery(QRCloudUtils.DATABASE_KIND_QUESTIONNAIRE); cloudQuery.setFilter(F.eq(CloudEntity.PROP_CREATED_BY, getPreferencesAccountName())); cloudQuery.setLimit(1); cloudQuery.setScope(Scope.PAST); getCloudBackend().list(cloudQuery, userQuestionnaireHandler); } }, NON_URGENT_QUERY_DELAY); } // TODO: is this the reason why it can be slow to load codes initially? // check for banned users if (mUserState == UserState.UNKNOWN || currentTime - banCheckTime > getResources().getInteger(R.integer.ban_check_interval)) { mUserState = UserState.CHECKING; // save the new query time (regardless of failures) SharedPreferences.Editor editor = sharedPreferences.edit(); editor.putLong(getString(R.string.check_ban_time), currentTime); editor.commit(); // delay so we let the UI queries load first new Handler().postDelayed(new Runnable() { @Override public void run() { CloudCallbackHandler<List<CloudEntity>> userStateHandler = new CloudCallbackHandler<List<CloudEntity>>() { @Override public void onComplete(List<CloudEntity> results) { if (results == null) { return; // nothing we can do (could change state to unknown again?) } mUserState = results.size() > 0 ? UserState.BANNED : UserState.ALLOWED; showBannedMessage(); } @Override public void onError(IOException exception) { // nothing we can do (could change state to unknown again?) } }; CloudQuery cloudQuery = new CloudQuery(QRCloudUtils.DATABASE_KIND_BANS); cloudQuery.setFilter(F.eq(QRCloudUtils.DATABASE_PROP_USER, getPreferencesAccountName())); cloudQuery.setLimit(1); cloudQuery.setScope(Scope.PAST); getCloudBackend().list(cloudQuery, userStateHandler); } }, NON_URGENT_QUERY_DELAY); } else { showBannedMessage(); } // check for new application versions (note that only certain versions are forced; others are just bug fixes) if (mApplicationState == ApplicationState.UNKNOWN || currentTime - versionCheckTime > getResources().getInteger(R.integer.version_check_interval)) { mApplicationState = ApplicationState.CHECKING; // save the new time (regardless of failures) SharedPreferences.Editor editor = sharedPreferences.edit(); editor.putLong(getString(R.string.check_version_time), currentTime); editor.commit(); int currentAppVersion = -1; try { PackageManager manager = getPackageManager(); PackageInfo info = manager.getPackageInfo(getPackageName(), 0); currentAppVersion = info.versionCode; } catch (Exception e) { // nothing we can do } // check if an upgrade is available if (currentAppVersion >= 0) { // delay so we let the UI queries load first final int currentVersion = currentAppVersion; new Handler().postDelayed(new Runnable() { @Override public void run() { CloudCallbackHandler<List<CloudEntity>> applicationStateHandler = new CloudCallbackHandler<List<CloudEntity>>() { @Override public void onComplete(List<CloudEntity> results) { if (results == null) { return; // nothing we can do (could change state to unknown again?) } mApplicationState = results.size() > 0 ? ApplicationState.OLD : ApplicationState.CURRENT; showUpdateMessage(); } @Override public void onError(IOException exception) { // nothing we can do (could change state to unknown again?) } }; CloudQuery cloudQuery = new CloudQuery(QRCloudUtils.DATABASE_KIND_VERSIONS); cloudQuery.setFilter(F.gt(QRCloudUtils.DATABASE_PROP_VERSION, currentVersion)); cloudQuery.setLimit(1); cloudQuery.setScope(Scope.PAST); getCloudBackend().list(cloudQuery, applicationStateHandler); } }, NON_URGENT_QUERY_DELAY); } } else { showUpdateMessage(); } }
From source file:com.tapjoy.TapjoyConnectCore.java
/** * ONLY USE FOR PAID APP INSTALLS.<br> * This method should be called in the onCreate() method of your first activity after calling * {@link #requestTapjoyConnect(Context context, String appID, String secretKey)}.<br> * Must enable a paid app Pay-Per-Action on the Tapjoy dashboard. * Starts a 15 minute timer. After which, will send an actionComplete call with the paid app PPA to * inform the Tapjoy server that the paid install PPA has been completed. * @param paidAppPayPerActionID The Pay-Per-Action ID for this paid app download action. *//*from w ww .ja v a 2 s .co m*/ public void enablePaidAppWithActionID(String paidAppPayPerActionID) { TapjoyLog.i(TAPJOY_CONNECT, "enablePaidAppWithActionID: " + paidAppPayPerActionID); paidAppActionID = paidAppPayPerActionID; SharedPreferences prefs = context.getSharedPreferences(TapjoyConstants.TJC_PREFERENCE, 0); // Load the stored elapsed time from the prefs. elapsed_time = prefs.getLong(TapjoyConstants.PREF_ELAPSED_TIME, 0); TapjoyLog.i(TAPJOY_CONNECT, "paidApp elapsed: " + elapsed_time); // If elapsed time is enough, then call the paid app PPA. if (elapsed_time >= TapjoyConstants.PAID_APP_TIME) { // If there is a valid paid app action ID, then trigger the PPA. if (paidAppActionID != null && paidAppActionID.length() > 0) { TapjoyLog.i(TAPJOY_CONNECT, "Calling PPA actionComplete..."); actionComplete(paidAppActionID); } } else // Only have 1 timer running at a time. if (timer == null) { timer = new Timer(); timer.schedule(new PaidAppTimerTask(), TapjoyConstants.TIMER_INCREMENT, TapjoyConstants.TIMER_INCREMENT); } }
From source file:com.anysoftkeyboard.AskPrefsImpl.java
public void onSharedPreferenceChanged(SharedPreferences sp, String key) { Logger.d(TAG, "**** onSharedPreferenceChanged: "); //statistics//from w ww . j a v a 2s. co m mFirstAppVersionInstalled = sp.getInt(mContext.getString(R.string.settings_key_first_app_version_installed), 0); mFirstTimeAppInstalled = sp.getLong(mContext.getString(R.string.settings_key_first_time_app_installed), 0); mFirstTimeCurrentVersionInstalled = sp .getLong(mContext.getString(R.string.settings_key_first_time_current_version_installed), 0); //now real settings mDomainText = sp.getString("default_domain_text", ".com"); Logger.d(TAG, "** mDomainText: " + mDomainText); mShowKeyPreview = sp.getBoolean(mContext.getString(R.string.settings_key_key_press_shows_preview_popup), mContext.getResources().getBoolean(R.bool.settings_default_key_press_shows_preview_popup)); Logger.d(TAG, "** mShowKeyPreview: " + mShowKeyPreview); mKeyPreviewAboveKey = sp .getString(mContext.getString(R.string.settings_key_key_press_preview_popup_position), mContext.getString(R.string.settings_default_key_press_preview_popup_position)) .equals("above_key"); Logger.d(TAG, "** mKeyPreviewAboveKey: " + mKeyPreviewAboveKey); mShowKeyboardNameText = sp.getBoolean(mContext.getString(R.string.settings_key_show_keyboard_name_text_key), mContext.getResources().getBoolean(R.bool.settings_default_show_keyboard_name_text_value)); Logger.d(TAG, "** mShowKeyboardNameText: " + mShowKeyboardNameText); mShowHintTextOnKeys = sp.getBoolean(mContext.getString(R.string.settings_key_show_hint_text_key), mContext.getResources().getBoolean(R.bool.settings_default_show_hint_text_value)); Logger.d(TAG, "** mShowHintTextOnKeys: " + mShowHintTextOnKeys); // preferences to override theme's hint position mUseCustomHintAlign = sp.getBoolean(mContext.getString(R.string.settings_key_use_custom_hint_align_key), mContext.getResources().getBoolean(R.bool.settings_default_use_custom_hint_align_value)); Logger.d(TAG, "** mUseCustomHintAlign: " + mUseCustomHintAlign); mCustomHintAlign = getIntFromString(sp, mContext.getString(R.string.settings_key_custom_hint_align_key), mContext.getString(R.string.settings_default_custom_hint_align_value)); Logger.d(TAG, "** mCustomHintAlign: " + mCustomHintAlign); mCustomHintVAlign = getIntFromString(sp, mContext.getString(R.string.settings_key_custom_hint_valign_key), mContext.getString(R.string.settings_default_custom_hint_valign_value)); Logger.d(TAG, "** mCustomHintVAlign: " + mCustomHintVAlign); mSwitchKeyboardOnSpace = sp.getBoolean(mContext.getString(R.string.settings_key_switch_keyboard_on_space), mContext.getResources().getBoolean(R.bool.settings_default_switch_to_alphabet_on_space)); Logger.d(TAG, "** mSwitchKeyboardOnSpace: " + mSwitchKeyboardOnSpace); mUseFullScreenInputInLandscape = sp.getBoolean( mContext.getString(R.string.settings_key_landscape_fullscreen), mContext.getResources().getBoolean(R.bool.settings_default_landscape_fullscreen)); Logger.d(TAG, "** mUseFullScreenInputInLandscape: " + mUseFullScreenInputInLandscape); mUseFullScreenInputInPortrait = sp.getBoolean(mContext.getString(R.string.settings_key_portrait_fullscreen), mContext.getResources().getBoolean(R.bool.settings_default_portrait_fullscreen)); Logger.d(TAG, "** mUseFullScreenInputInPortrait: " + mUseFullScreenInputInPortrait); // Fix issue 185 mUseKeyRepeat = sp.getBoolean("use_keyrepeat", true); Logger.d(TAG, "** mUseKeyRepeat: " + mUseKeyRepeat); mKeysHeightFactorInPortrait = getFloatFromString(sp, "zoom_factor_keys_in_portrait", mContext.getString(R.string.settings_default_portrait_keyboard_height_factor)); Logger.d(TAG, "** mKeysHeightFactorInPortrait: " + mKeysHeightFactorInPortrait); if (mKeysHeightFactorInPortrait > 2.0f) { mKeysHeightFactorInPortrait = 2.0f; Logger.d(TAG, "** mKeysHeightFactorInPortrait fixed to: " + mKeysHeightFactorInPortrait); } else if (mKeysHeightFactorInPortrait < 0.2f) { mKeysHeightFactorInPortrait = 0.2f; Logger.d(TAG, "** mKeysHeightFactorInPortrait fixed to: " + mKeysHeightFactorInPortrait); } mKeysHeightFactorInLandscape = getFloatFromString(sp, "zoom_factor_keys_in_landscape", mContext.getString(R.string.settings_default_landscape_keyboard_height_factor)); Logger.d(TAG, "** mKeysHeightFactorInLandscape: " + mKeysHeightFactorInLandscape); if (mKeysHeightFactorInLandscape > 2.0f) { mKeysHeightFactorInLandscape = 2.0f; Logger.d(TAG, "** mKeysHeightFactorInLandscape fixed to: " + mKeysHeightFactorInLandscape); } else if (mKeysHeightFactorInPortrait < 0.2f) { mKeysHeightFactorInPortrait = 0.2f; Logger.d(TAG, "** mKeysHeightFactorInPortrait fixed to: " + mKeysHeightFactorInLandscape); } mInsertSpaceAfterCandidatePick = sp.getBoolean("insert_space_after_word_suggestion_selection", true); Logger.d(TAG, "** mInsertSpaceAfterCandidatePick: " + mInsertSpaceAfterCandidatePick); mSwipeUpKeyCode = getIntFromSwipeConfiguration(sp, R.string.settings_key_swipe_up_action, R.string.swipe_action_value_shift); Logger.d(TAG, "** mSwipeUpKeyCode: " + mSwipeUpKeyCode); mSwipeUpFromSpaceBarKeyCode = getIntFromSwipeConfiguration(sp, R.string.settings_key_swipe_up_from_spacebar_action, R.string.swipe_action_value_utility_keyboard); Logger.d(TAG, "** mSwipeUpFromSpaceBarKeyCode: " + mSwipeUpFromSpaceBarKeyCode); mSwipeDownKeyCode = getIntFromSwipeConfiguration(sp, R.string.settings_key_swipe_down_action, R.string.swipe_action_value_hide); Logger.d(TAG, "** mSwipeDownKeyCode: " + mSwipeDownKeyCode); mSwipeLeftKeyCode = getIntFromSwipeConfiguration(sp, R.string.settings_key_swipe_left_action, R.string.swipe_action_value_next_symbols); Logger.d(TAG, "** mSwipeLeftKeyCode: " + mSwipeLeftKeyCode); mSwipeRightKeyCode = getIntFromSwipeConfiguration(sp, R.string.settings_key_swipe_right_action, R.string.swipe_action_value_next_alphabet); Logger.d(TAG, "** mSwipeRightKeyCode: " + mSwipeRightKeyCode); mPinchKeyCode = getIntFromSwipeConfiguration(sp, R.string.settings_key_pinch_gesture_action, R.string.swipe_action_value_merge_layout); Logger.d(TAG, "** mPinchKeyCode: " + mPinchKeyCode); mSeparateKeyCode = getIntFromSwipeConfiguration(sp, R.string.settings_key_separate_gesture_action, R.string.swipe_action_value_split_layout); Logger.d(TAG, "** mSeparateKeyCode: " + mSeparateKeyCode); mSwipeLeftFromSpaceBarKeyCode = getIntFromSwipeConfiguration(sp, R.string.settings_key_swipe_left_space_bar_action, R.string.swipe_action_value_next_symbols); Logger.d(TAG, "** mSwipeLeftFromSpaceBarKeyCode: " + mSwipeLeftFromSpaceBarKeyCode); mSwipeRightFromSpaceBarKeyCode = getIntFromSwipeConfiguration(sp, R.string.settings_key_swipe_right_space_bar_action, R.string.swipe_action_value_next_alphabet); Logger.d(TAG, "** mSwipeRightFromSpaceBarKeyCode: " + mSwipeRightFromSpaceBarKeyCode); mSwipeLeftWithTwoFingersKeyCode = getIntFromSwipeConfiguration(sp, R.string.settings_key_swipe_left_two_fingers_action, R.string.swipe_action_value_compact_layout_to_left); Logger.d(TAG, "** mSwipeLeftWithTwoFingersKeyCode: " + mSwipeLeftWithTwoFingersKeyCode); mSwipeRightWithTwoFingersKeyCode = getIntFromSwipeConfiguration(sp, R.string.settings_key_swipe_right_two_fingers_action, R.string.swipe_action_value_compact_layout_to_right); Logger.d(TAG, "** mSwipeRightWithTwoFingersKeyCode: " + mSwipeRightWithTwoFingersKeyCode); mActionKeyInvisibleWhenRequested = sp.getBoolean("action_key_invisible_on_disable", false); Logger.d(TAG, "** mActionKeyInvisibleWhenRequested: " + mActionKeyInvisibleWhenRequested); /*mRtlWorkaround = sp.getString("rtl_workaround_detection", "auto"); Logger.d(mTag, "** mRtlWorkaround: "+mRtlWorkaround); */ mIsDoubleSpaceChangesToPeroid = sp.getBoolean("double_space_to_period", true); Logger.d(TAG, "** mIsDoubleSpaceChangesToPeroid: " + mIsDoubleSpaceChangesToPeroid); mShouldPopupForLanguageSwitch = sp.getBoolean( mContext.getString(R.string.settings_key_lang_key_shows_popup), mContext.getResources().getBoolean(R.bool.settings_default_lang_key_shows_popup)); Logger.d(TAG, "** mShouldPopupForLanguageSwitch: " + mShouldPopupForLanguageSwitch); mHideSoftKeyboardWhenPhysicalKeyPressed = sp.getBoolean( mContext.getString(R.string.settings_key_hide_soft_when_physical), mContext.getResources().getBoolean(R.bool.settings_default_hide_soft_when_physical)); Logger.d(TAG, "** mHideSoftKeyboardWhenPhysicalKeyPressed: " + mHideSoftKeyboardWhenPhysicalKeyPressed); mSupportPasswordKeyboardMode = sp.getBoolean( mContext.getString(R.string.settings_key_support_password_keyboard_type_state), mContext.getResources() .getBoolean(R.bool.settings_default_bool_support_password_keyboard_type_state)); Logger.d(TAG, "** mSupportPasswordKeyboardMode: " + mSupportPasswordKeyboardMode); mUse16KeysSymbolsKeyboard = sp.getBoolean( mContext.getString(R.string.settings_key_use_16_keys_symbols_keyboards), mContext.getResources().getBoolean(R.bool.settings_default_use_16_keys_symbols_keyboards)); Logger.d(TAG, "** mUse16KeysSymbolsKeyboard: " + mUse16KeysSymbolsKeyboard); mUseBackword = sp.getBoolean(mContext.getString(R.string.settings_key_use_backword), mContext.getResources().getBoolean(R.bool.settings_default_use_backword)); Logger.d(TAG, "** mUseBackword: " + mUseBackword); mCycleOverAllSymbolsKeyboard = sp.getBoolean(mContext.getString(R.string.settings_key_cycle_all_symbols), mContext.getResources().getBoolean(R.bool.settings_default_cycle_all_symbols)); Logger.d(TAG, "** mCycleOverAllSymbolsKeyboard: " + mCycleOverAllSymbolsKeyboard); mUseCameraKeyForBackspaceBackword = sp.getBoolean( mContext.getString(R.string.settings_key_use_camera_key_for_backspace_backword), mContext.getResources().getBoolean(R.bool.settings_default_use_camera_key_for_backspace_backword)); Logger.d(TAG, "** mUseCameraKeyForBackspaceBackword: " + mUseCameraKeyForBackspaceBackword); mUseVolumeKeyForLeftRight = sp.getBoolean( mContext.getString(R.string.settings_key_use_volume_key_for_left_right), mContext.getResources().getBoolean(R.bool.settings_default_use_volume_key_for_left_right)); Logger.d(TAG, "** mUseVolumeKeyForLeftRight: " + mUseVolumeKeyForLeftRight); mUseContactsDictionary = sp.getBoolean(mContext.getString(R.string.settings_key_use_contacts_dictionary), mContext.getResources().getBoolean(R.bool.settings_default_contacts_dictionary)); Logger.d(TAG, "** mUseContactsDictionary: " + mUseContactsDictionary); mAutoDictionaryInsertionThreshold = getIntFromString(sp, mContext.getString(R.string.settings_key_auto_dictionary_threshold), mContext.getString(R.string.settings_default_auto_dictionary_add_threshold)); Logger.d(TAG, "** mAutoDictionaryInsertionThreshold: " + mAutoDictionaryInsertionThreshold); mIsStickyExtensionKeyboard = sp.getBoolean( mContext.getString(R.string.settings_key_is_sticky_extesion_keyboard), mContext.getResources().getBoolean(R.bool.settings_default_is_sticky_extesion_keyboard)); Logger.d(TAG, "** mIsStickyExtensionKeyboard: " + mIsStickyExtensionKeyboard); mSwipeDistanceThreshold = getIntFromString(sp, mContext.getString(R.string.settings_key_swipe_distance_threshold), mContext.getString(R.string.settings_default_swipe_distance_threshold)); Logger.d(TAG, "** mSwipeDistanceThreshold: " + mSwipeDistanceThreshold); mSwipeVelocityThreshold = getIntFromString(sp, mContext.getString(R.string.settings_key_swipe_velocity_threshold), mContext.getString(R.string.settings_default_swipe_velocity_threshold)); Logger.d(TAG, "** mSwipeVelocityThreshold: " + mSwipeVelocityThreshold); mLongPressTimeout = getIntFromString(sp, mContext.getString(R.string.settings_key_long_press_timeout), mContext.getString(R.string.settings_default_long_press_timeout)); Logger.d(TAG, "** mLongPressTimeout: " + mLongPressTimeout); mMultiTapTimeout = getIntFromString(sp, mContext.getString(R.string.settings_key_multitap_timeout), mContext.getString(R.string.settings_default_multitap_timeout)); Logger.d(TAG, "** mMultiTapTimeout: " + mMultiTapTimeout); mWorkaroundAlwaysUseDrawText = sp.getBoolean( mContext.getString(R.string.settings_key_workaround_disable_rtl_fix), getAlwaysUseDrawTextDefault()); Logger.d(TAG, "** mWorkaroundAlwaysUseDrawText: " + mWorkaroundAlwaysUseDrawText); mUseChewbacca = sp.getBoolean(mContext.getString(R.string.settings_key_show_chewbacca), mContext.getResources().getBoolean(R.bool.settings_default_show_chewbacca)); Logger.d(TAG, "** mUseChewbacca: " + mUseChewbacca); mSwapPunctuationAndSpace = sp.getBoolean( mContext.getString(R.string.settings_key_bool_should_swap_punctuation_and_space), mContext.getResources().getBoolean(R.bool.settings_default_bool_should_swap_punctuation_and_space)); Logger.d(TAG, "** mSwapPunctuationAndSpace: " + mSwapPunctuationAndSpace); String animationsLevel = sp.getString(mContext.getString(R.string.settings_key_tweak_animations_level), mContext.getString(R.string.settings_default_tweak_animations_level)); if ("none".equals(animationsLevel)) mAnimationsLevel = AnimationsLevel.None; else if ("some".equals(animationsLevel)) mAnimationsLevel = AnimationsLevel.Some; else mAnimationsLevel = AnimationsLevel.Full; Logger.d(TAG, "** mAnimationsLevel: " + mAnimationsLevel); mAlwaysUseFallBackUserDictionary = sp.getBoolean( mContext.getString(R.string.settings_key_always_use_fallback_user_dictionary), mContext.getResources().getBoolean(R.bool.settings_default_always_use_fallback_user_dictionary)); Logger.d(TAG, "** mAlwaysUseFallBackUserDictionary: " + mAlwaysUseFallBackUserDictionary); mAutomaticallySwitchToAppLayout = sp.getBoolean( mContext.getString(R.string.settings_key_persistent_layout_per_package_id), mContext.getResources().getBoolean(R.bool.settings_default_persistent_layout_per_package_id)); Logger.d(TAG, "** mAutomaticallySwitchToAppLayout: " + mAutomaticallySwitchToAppLayout); mAlwaysHideLanguageKey = sp.getBoolean(mContext.getString(R.string.settings_key_always_hide_language_key), mContext.getResources().getBoolean(R.bool.settings_default_always_hide_language_key)); Logger.d(TAG, "** mAlwaysHideLanguageKey: " + mAutomaticallySwitchToAppLayout); //Some preferences cause rebuild of the keyboard, hence changing the listeners list final LinkedList<OnSharedPreferenceChangeListener> disconnectedList = new LinkedList<>( mPreferencesChangedListeners); for (OnSharedPreferenceChangeListener listener : disconnectedList) { //before notifying, we'll ensure that the listener is still interested in the callback if (mPreferencesChangedListeners.contains(listener)) { listener.onSharedPreferenceChanged(sp, key); } } }
From source file:de.ub0r.android.websms.WebSMS.java
/** * Generates unique id for the next message. * * @param context Current context//w w w . j a v a 2s.c o m * @return message id */ private static synchronized long nextMsgId(final Context context) { final SharedPreferences p = PreferenceManager.getDefaultSharedPreferences(context); long nextMsgId = p.getLong(PREFS_LAST_MSG_ID, 0) + 1; SharedPreferences.Editor editor = p.edit(); editor.putLong(PREFS_LAST_MSG_ID, nextMsgId); editor.apply(); return nextMsgId; }