List of usage examples for android.content SharedPreferences contains
boolean contains(String key);
From source file:net.czlee.debatekeeper.DebatingActivity.java
/** * Gets the preferences from the shared preferences file and applies them. *///from w w w. ja v a 2 s. c o m private void applyPreferences() { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); boolean silentMode, vibrateMode, overtimeBellsEnabled; boolean poiBuzzerEnabled, poiVibrateEnabled, prepTimerEnabled; int firstOvertimeBell, overtimeBellPeriod; String userCountDirectionValue, userPrepTimeCountDirectionValue, poiFlashScreenModeValue, backgroundColourAreaValue; FlashScreenMode flashScreenMode, poiFlashScreenMode; Resources res = getResources(); final String TAG = "applyPreferences"; try { // The boolean preferences silentMode = prefs.getBoolean(res.getString(R.string.pref_silentMode_key), res.getBoolean(R.bool.prefDefault_silentMode)); vibrateMode = prefs.getBoolean(res.getString(R.string.pref_vibrateMode_key), res.getBoolean(R.bool.prefDefault_vibrateMode)); overtimeBellsEnabled = prefs.getBoolean(res.getString(R.string.pref_overtimeBellsEnable_key), res.getBoolean(R.bool.prefDefault_overtimeBellsEnable)); mSpeechKeepScreenOn = prefs.getBoolean(res.getString(R.string.pref_keepScreenOn_key), res.getBoolean(R.bool.prefDefault_keepScreenOn)); mPrepTimeKeepScreenOn = prefs.getBoolean(res.getString(R.string.pref_prepTimer_keepScreenOn_key), res.getBoolean(R.bool.prefDefault_prepTimer_keepScreenOn)); mPoiTimerEnabled = prefs.getBoolean(res.getString(R.string.pref_poiTimer_enable_key), res.getBoolean(R.bool.prefDefault_poiTimer_enable)); poiBuzzerEnabled = prefs.getBoolean(res.getString(R.string.pref_poiTimer_buzzerEnable_key), res.getBoolean(R.bool.prefDefault_poiTimer_buzzerEnable)); poiVibrateEnabled = prefs.getBoolean(res.getString(R.string.pref_poiTimer_vibrateEnable_key), res.getBoolean(R.bool.prefDefault_poiTimer_vibrateEnable)); prepTimerEnabled = prefs.getBoolean(res.getString(R.string.pref_prepTimer_enable_key), res.getBoolean(R.bool.prefDefault_prepTimer_enable)); // Overtime bell integers if (overtimeBellsEnabled) { firstOvertimeBell = prefs.getInt(res.getString(R.string.pref_firstOvertimeBell_key), res.getInteger(R.integer.prefDefault_firstOvertimeBell)); overtimeBellPeriod = prefs.getInt(res.getString(R.string.pref_overtimeBellPeriod_key), res.getInteger(R.integer.prefDefault_overtimeBellPeriod)); } else { firstOvertimeBell = 0; overtimeBellPeriod = 0; } // List preference: POI flash screen mode poiFlashScreenModeValue = prefs.getString(res.getString(R.string.pref_poiTimer_flashScreenMode_key), res.getString(R.string.prefDefault_poiTimer_flashScreenMode)); poiFlashScreenMode = FlashScreenMode.toEnum(poiFlashScreenModeValue); // List preference: Count direction // - Backwards compatibility measure // This changed in version 0.9, to remove the generallyUp and generallyDown options. // Therefore, if we find either of those, we need to replace it with alwaysUp or // alwaysDown, respectively. userCountDirectionValue = prefs.getString(res.getString(R.string.pref_countDirection_key), res.getString(R.string.prefDefault_countDirection)); if (userCountDirectionValue.equals("generallyUp") || userCountDirectionValue.equals("generallyDown")) { // Replace the preference with alwaysUp or alwaysDown, respectively. SharedPreferences.Editor editor = prefs.edit(); String newValue = (userCountDirectionValue.equals("generallyUp")) ? "alwaysUp" : "alwaysDown"; editor.putString(res.getString(R.string.pref_countDirection_key), newValue); editor.apply(); Log.i(TAG, "countDirection: replaced " + userCountDirectionValue + " with " + newValue); userCountDirectionValue = newValue; } mCountDirection = CountDirection.toEnum(userCountDirectionValue); // List preference: Count direction for prep time userPrepTimeCountDirectionValue = prefs.getString( res.getString(R.string.pref_prepTimer_countDirection_key), res.getString(R.string.prefDefault_prepTimer_countDirection)); mPrepTimeCountDirection = CountDirection.toEnum(userPrepTimeCountDirectionValue); // List preference: Background colour area BackgroundColourArea oldBackgroundColourArea = mBackgroundColourArea; backgroundColourAreaValue = prefs.getString(res.getString(R.string.pref_backgroundColourArea_key), res.getString(R.string.prefDefault_backgroundColourArea)); mBackgroundColourArea = BackgroundColourArea.toEnum(backgroundColourAreaValue); if (oldBackgroundColourArea != mBackgroundColourArea) { Log.v(TAG, "background colour preference changed - refreshing"); resetBackgroundColoursToTransparent(); ((DebateTimerDisplayPagerAdapter) mViewPager.getAdapter()).refreshBackgroundColours(); } // List preference: Flash screen mode // - Backwards compatibility measure // This changed from a boolean to a list preference in version 0.6, so there is // backwards compatibility to take care of. Backwards compatibility applies if // (a) the list preference is NOT present AND (b) the boolean preference IS present. // In this case, retrieve the boolean preference, delete it and write the corresponding // list preference. In all other cases, just take the list preference (using the // normal default mechanism if it isn't present, i.e. neither are present). if (!prefs.contains(res.getString(R.string.pref_flashScreenMode_key)) && prefs.contains(res.getString(R.string.pref_flashScreenBool_key))) { // Boolean preference. // First, get the string and convert it to an enum. boolean flashScreenModeBool = prefs.getBoolean(res.getString(R.string.pref_flashScreenBool_key), false); flashScreenMode = (flashScreenModeBool) ? FlashScreenMode.SOLID_FLASH : FlashScreenMode.OFF; // Then, convert that enum to the list preference value (a string) and write that // back to the preferences. Also, remove the old boolean preference. String flashStringModePrefValue = flashScreenMode.toPrefValue(); SharedPreferences.Editor editor = prefs.edit(); editor.putString(res.getString(R.string.pref_flashScreenMode_key), flashStringModePrefValue); editor.remove(res.getString(R.string.pref_flashScreenBool_key)); editor.apply(); Log.i(TAG, "flashScreenMode: replaced boolean preference with list preference: " + flashStringModePrefValue); } else { // List preference. // Get the string and convert it to an enum. String flashScreenModeValue; flashScreenModeValue = prefs.getString(res.getString(R.string.pref_flashScreenMode_key), res.getString(R.string.prefDefault_flashScreenMode)); flashScreenMode = FlashScreenMode.toEnum(flashScreenModeValue); } } catch (ClassCastException e) { Log.e(TAG, "caught ClassCastException!"); return; } if (mDebateManager != null) { mDebateManager.setOvertimeBells(firstOvertimeBell, overtimeBellPeriod); mDebateManager.setPrepTimeEnabled(prepTimerEnabled); applyPrepTimeBells(); // This is necessary if the debate structure has changed, i.e. if prep time has been // enabled or disabled. mViewPager.getAdapter().notifyDataSetChanged(); } else { Log.v(TAG, "Couldn't restore overtime bells, mDebateManager doesn't yet exist"); } if (mBinder != null) { AlertManager am = mBinder.getAlertManager(); // Volume control stream is linked to silent mode am.setSilentMode(silentMode); setVolumeControlStream((silentMode) ? AudioManager.STREAM_RING : AudioManager.STREAM_MUSIC); am.setVibrateMode(vibrateMode); am.setFlashScreenMode(flashScreenMode); am.setPoiBuzzerEnabled(poiBuzzerEnabled); am.setPoiVibrateEnabled(poiVibrateEnabled); am.setPoiFlashScreenMode(poiFlashScreenMode); this.updateKeepScreenOn(); Log.v(TAG, "successfully applied"); } else { Log.v(TAG, "Couldn't restore AlertManager preferences; mBinder doesn't yet exist"); } }
From source file:com.ferdi2005.secondgram.NotificationsController.java
private void showOrUpdateNotification(boolean notifyAboutLast) { if (!UserConfig.isClientActivated() || pushMessages.isEmpty()) { dismissNotification();/*from w w w . j a v a2 s . c om*/ return; } try { ConnectionsManager.getInstance().resumeNetworkMaybe(); MessageObject lastMessageObject = pushMessages.get(0); SharedPreferences preferences = ApplicationLoader.applicationContext .getSharedPreferences("Notifications", Context.MODE_PRIVATE); int dismissDate = preferences.getInt("dismissDate", 0); if (lastMessageObject.messageOwner.date <= dismissDate) { dismissNotification(); return; } long dialog_id = lastMessageObject.getDialogId(); long override_dialog_id = dialog_id; if (lastMessageObject.messageOwner.mentioned) { override_dialog_id = lastMessageObject.messageOwner.from_id; } int mid = lastMessageObject.getId(); int chat_id = lastMessageObject.messageOwner.to_id.chat_id != 0 ? lastMessageObject.messageOwner.to_id.chat_id : lastMessageObject.messageOwner.to_id.channel_id; int user_id = lastMessageObject.messageOwner.to_id.user_id; if (user_id == 0) { user_id = lastMessageObject.messageOwner.from_id; } else if (user_id == UserConfig.getClientUserId()) { user_id = lastMessageObject.messageOwner.from_id; } TLRPC.User user = MessagesController.getInstance().getUser(user_id); TLRPC.Chat chat = null; if (chat_id != 0) { chat = MessagesController.getInstance().getChat(chat_id); } TLRPC.FileLocation photoPath = null; boolean notifyDisabled = false; int needVibrate = 0; String choosenSoundPath = null; int ledColor = 0xff0000ff; boolean inAppSounds; boolean inAppVibrate; boolean inAppPreview = false; boolean inAppPriority; int priority = 0; int priorityOverride; int vibrateOverride; int notifyOverride = getNotifyOverride(preferences, override_dialog_id); if (!notifyAboutLast || notifyOverride == 2 || (!preferences.getBoolean("EnableAll", true) || chat_id != 0 && !preferences.getBoolean("EnableGroup", true)) && notifyOverride == 0) { notifyDisabled = true; } if (!notifyDisabled && dialog_id == override_dialog_id && chat != null) { int notifyMaxCount; int notifyDelay; if (preferences.getBoolean("custom_" + dialog_id, false)) { notifyMaxCount = preferences.getInt("smart_max_count_" + dialog_id, 2); notifyDelay = preferences.getInt("smart_delay_" + dialog_id, 3 * 60); } else { notifyMaxCount = 2; notifyDelay = 3 * 60; } if (notifyMaxCount != 0) { Point dialogInfo = smartNotificationsDialogs.get(dialog_id); if (dialogInfo == null) { dialogInfo = new Point(1, (int) (System.currentTimeMillis() / 1000)); smartNotificationsDialogs.put(dialog_id, dialogInfo); } else { int lastTime = dialogInfo.y; if (lastTime + notifyDelay < System.currentTimeMillis() / 1000) { dialogInfo.set(1, (int) (System.currentTimeMillis() / 1000)); } else { int count = dialogInfo.x; if (count < notifyMaxCount) { dialogInfo.set(count + 1, (int) (System.currentTimeMillis() / 1000)); } else { notifyDisabled = true; } } } } } String defaultPath = Settings.System.DEFAULT_NOTIFICATION_URI.getPath(); if (!notifyDisabled) { inAppSounds = preferences.getBoolean("EnableInAppSounds", true); inAppVibrate = preferences.getBoolean("EnableInAppVibrate", true); inAppPreview = preferences.getBoolean("EnableInAppPreview", true); inAppPriority = preferences.getBoolean("EnableInAppPriority", false); boolean custom; if (custom = preferences.getBoolean("custom_" + dialog_id, false)) { vibrateOverride = preferences.getInt("vibrate_" + dialog_id, 0); priorityOverride = preferences.getInt("priority_" + dialog_id, 3); choosenSoundPath = preferences.getString("sound_path_" + dialog_id, null); } else { vibrateOverride = 0; priorityOverride = 3; choosenSoundPath = null; } boolean vibrateOnlyIfSilent = false; if (chat_id != 0) { if (choosenSoundPath != null && choosenSoundPath.equals(defaultPath)) { choosenSoundPath = null; } else if (choosenSoundPath == null) { choosenSoundPath = preferences.getString("GroupSoundPath", defaultPath); } needVibrate = preferences.getInt("vibrate_group", 0); priority = preferences.getInt("priority_group", 1); ledColor = preferences.getInt("GroupLed", 0xff0000ff); } else if (user_id != 0) { if (choosenSoundPath != null && choosenSoundPath.equals(defaultPath)) { choosenSoundPath = null; } else if (choosenSoundPath == null) { choosenSoundPath = preferences.getString("GlobalSoundPath", defaultPath); } needVibrate = preferences.getInt("vibrate_messages", 0); priority = preferences.getInt("priority_group", 1); ledColor = preferences.getInt("MessagesLed", 0xff0000ff); } if (custom) { if (preferences.contains("color_" + dialog_id)) { ledColor = preferences.getInt("color_" + dialog_id, 0); } } if (priorityOverride != 3) { priority = priorityOverride; } if (needVibrate == 4) { vibrateOnlyIfSilent = true; needVibrate = 0; } if (needVibrate == 2 && (vibrateOverride == 1 || vibrateOverride == 3) || needVibrate != 2 && vibrateOverride == 2 || vibrateOverride != 0 && vibrateOverride != 4) { needVibrate = vibrateOverride; } if (!ApplicationLoader.mainInterfacePaused) { if (!inAppSounds) { choosenSoundPath = null; } if (!inAppVibrate) { needVibrate = 2; } if (!inAppPriority) { priority = 0; } else if (priority == 2) { priority = 1; } } if (vibrateOnlyIfSilent && needVibrate != 2) { try { int mode = audioManager.getRingerMode(); if (mode != AudioManager.RINGER_MODE_SILENT && mode != AudioManager.RINGER_MODE_VIBRATE) { needVibrate = 2; } } catch (Exception e) { FileLog.e(e); } } } Intent intent = new Intent(ApplicationLoader.applicationContext, LaunchActivity.class); intent.setAction("com.tmessages.openchat" + Math.random() + Integer.MAX_VALUE); intent.setFlags(32768); if ((int) dialog_id != 0) { if (pushDialogs.size() == 1) { if (chat_id != 0) { intent.putExtra("chatId", chat_id); } else if (user_id != 0) { intent.putExtra("userId", user_id); } } if (AndroidUtilities.needShowPasscode(false) || UserConfig.isWaitingForPasscodeEnter) { photoPath = null; } else { if (pushDialogs.size() == 1) { if (chat != null) { if (chat.photo != null && chat.photo.photo_small != null && chat.photo.photo_small.volume_id != 0 && chat.photo.photo_small.local_id != 0) { photoPath = chat.photo.photo_small; } } else if (user != null) { if (user.photo != null && user.photo.photo_small != null && user.photo.photo_small.volume_id != 0 && user.photo.photo_small.local_id != 0) { photoPath = user.photo.photo_small; } } } } } else { if (pushDialogs.size() == 1) { intent.putExtra("encId", (int) (dialog_id >> 32)); } } PendingIntent contentIntent = PendingIntent.getActivity(ApplicationLoader.applicationContext, 0, intent, PendingIntent.FLAG_ONE_SHOT); String name; boolean replace = true; if ((int) dialog_id == 0 || pushDialogs.size() > 1 || AndroidUtilities.needShowPasscode(false) || UserConfig.isWaitingForPasscodeEnter) { name = LocaleController.getString("AppName", R.string.AppName); replace = false; } else { if (chat != null) { name = chat.title; } else { name = UserObject.getUserName(user); } } String detailText; if (pushDialogs.size() == 1) { detailText = LocaleController.formatPluralString("NewMessages", total_unread_count); } else { detailText = LocaleController.formatString("NotificationMessagesPeopleDisplayOrder", R.string.NotificationMessagesPeopleDisplayOrder, LocaleController.formatPluralString("NewMessages", total_unread_count), LocaleController.formatPluralString("FromChats", pushDialogs.size())); } NotificationCompat.Builder mBuilder = new NotificationCompat.Builder( ApplicationLoader.applicationContext).setContentTitle(name) .setSmallIcon(R.drawable.notification).setAutoCancel(true).setNumber(total_unread_count) .setContentIntent(contentIntent).setGroup("messages").setGroupSummary(true) .setColor(0xff2ca5e0); mBuilder.setCategory(NotificationCompat.CATEGORY_MESSAGE); if (chat == null && user != null && user.phone != null && user.phone.length() > 0) { mBuilder.addPerson("tel:+" + user.phone); } int silent = 2; String lastMessage = null; boolean hasNewMessages = false; if (pushMessages.size() == 1) { MessageObject messageObject = pushMessages.get(0); String message = lastMessage = getStringForMessage(messageObject, false); silent = messageObject.messageOwner.silent ? 1 : 0; if (message == null) { return; } if (replace) { if (chat != null) { message = message.replace(" @ " + name, ""); } else { message = message.replace(name + ": ", "").replace(name + " ", ""); } } mBuilder.setContentText(message); mBuilder.setStyle(new NotificationCompat.BigTextStyle().bigText(message)); } else { mBuilder.setContentText(detailText); NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle(); inboxStyle.setBigContentTitle(name); int count = Math.min(10, pushMessages.size()); for (int i = 0; i < count; i++) { MessageObject messageObject = pushMessages.get(i); String message = getStringForMessage(messageObject, false); if (message == null || messageObject.messageOwner.date <= dismissDate) { continue; } if (silent == 2) { lastMessage = message; silent = messageObject.messageOwner.silent ? 1 : 0; } if (pushDialogs.size() == 1) { if (replace) { if (chat != null) { message = message.replace(" @ " + name, ""); } else { message = message.replace(name + ": ", "").replace(name + " ", ""); } } } inboxStyle.addLine(message); } inboxStyle.setSummaryText(detailText); mBuilder.setStyle(inboxStyle); } Intent dismissIntent = new Intent(ApplicationLoader.applicationContext, NotificationDismissReceiver.class); dismissIntent.putExtra("messageDate", lastMessageObject.messageOwner.date); mBuilder.setDeleteIntent(PendingIntent.getBroadcast(ApplicationLoader.applicationContext, 1, dismissIntent, PendingIntent.FLAG_UPDATE_CURRENT)); if (photoPath != null) { BitmapDrawable img = ImageLoader.getInstance().getImageFromMemory(photoPath, null, "50_50"); if (img != null) { mBuilder.setLargeIcon(img.getBitmap()); } else { try { float scaleFactor = 160.0f / AndroidUtilities.dp(50); BitmapFactory.Options options = new BitmapFactory.Options(); options.inSampleSize = scaleFactor < 1 ? 1 : (int) scaleFactor; Bitmap bitmap = BitmapFactory .decodeFile(FileLoader.getPathToAttach(photoPath, true).toString(), options); if (bitmap != null) { mBuilder.setLargeIcon(bitmap); } } catch (Throwable e) { //ignore } } } if (!notifyAboutLast || silent == 1) { mBuilder.setPriority(NotificationCompat.PRIORITY_LOW); } else { if (priority == 0) { mBuilder.setPriority(NotificationCompat.PRIORITY_DEFAULT); } else if (priority == 1) { mBuilder.setPriority(NotificationCompat.PRIORITY_HIGH); } else if (priority == 2) { mBuilder.setPriority(NotificationCompat.PRIORITY_MAX); } } if (silent != 1 && !notifyDisabled) { if (ApplicationLoader.mainInterfacePaused || inAppPreview) { if (lastMessage.length() > 100) { lastMessage = lastMessage.substring(0, 100).replace('\n', ' ').trim() + "..."; } mBuilder.setTicker(lastMessage); } if (!MediaController.getInstance().isRecordingAudio()) { if (choosenSoundPath != null && !choosenSoundPath.equals("NoSound")) { if (choosenSoundPath.equals(defaultPath)) { mBuilder.setSound(Settings.System.DEFAULT_NOTIFICATION_URI, AudioManager.STREAM_NOTIFICATION); } else { mBuilder.setSound(Uri.parse(choosenSoundPath), AudioManager.STREAM_NOTIFICATION); } } } if (ledColor != 0) { mBuilder.setLights(ledColor, 1000, 1000); } if (needVibrate == 2 || MediaController.getInstance().isRecordingAudio()) { mBuilder.setVibrate(new long[] { 0, 0 }); } else if (needVibrate == 1) { mBuilder.setVibrate(new long[] { 0, 100, 0, 100 }); } else if (needVibrate == 0 || needVibrate == 4) { mBuilder.setDefaults(NotificationCompat.DEFAULT_VIBRATE); } else if (needVibrate == 3) { mBuilder.setVibrate(new long[] { 0, 1000 }); } } else { mBuilder.setVibrate(new long[] { 0, 0 }); } if (Build.VERSION.SDK_INT < 24 && UserConfig.passcodeHash.length() == 0 && hasMessagesToReply()) { Intent replyIntent = new Intent(ApplicationLoader.applicationContext, PopupReplyReceiver.class); if (Build.VERSION.SDK_INT <= 19) { mBuilder.addAction(R.drawable.ic_ab_reply2, LocaleController.getString("Reply", R.string.Reply), PendingIntent.getBroadcast(ApplicationLoader.applicationContext, 2, replyIntent, PendingIntent.FLAG_UPDATE_CURRENT)); } else { mBuilder.addAction(R.drawable.ic_ab_reply, LocaleController.getString("Reply", R.string.Reply), PendingIntent.getBroadcast(ApplicationLoader.applicationContext, 2, replyIntent, PendingIntent.FLAG_UPDATE_CURRENT)); } } showExtraNotifications(mBuilder, notifyAboutLast); notificationManager.notify(1, mBuilder.build()); scheduleNotificationRepeat(); } catch (Exception e) { FileLog.e(e); } }
From source file:com.zoffcc.applications.zanavi.Navit.java
private static void getPrefs() { // if (Navit.METHOD_DEBUG) Navit.my_func_name(0); // save old pref values --------------- ZANaviPrefs.deep_copy(p, p_old);/*from w w w .j a va2 s . com*/ // save old pref values --------------- // Get the xml/preferences.xml preferences SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_); p.PREF_use_fast_provider = prefs.getBoolean("use_fast_provider", true); p.PREF_allow_gui_internal = prefs.getBoolean("allow_gui_internal", false); p.PREF_follow_gps = prefs.getBoolean("follow_gps", true); p.PREF_use_compass_heading_base = prefs.getBoolean("use_compass_heading_base", false); p.PREF_use_compass_heading_always = prefs.getBoolean("use_compass_heading_always", false); p.PREF_use_compass_heading_fast = prefs.getBoolean("use_compass_heading_fast", false); p.PREF_use_anti_aliasing = prefs.getBoolean("use_anti_aliasing", true); p.PREF_use_map_filtering = prefs.getBoolean("use_map_filtering", true); p.PREF_gui_oneway_arrows = prefs.getBoolean("gui_oneway_arrows", true); p.PREF_c_linedrawing = prefs.getBoolean("c_linedrawing", false); p.PREF_show_debug_messages = prefs.getBoolean("show_debug_messages", false); p.PREF_show_3d_map = prefs.getBoolean("show_3d_map", false); send_data_to_plugin_bg(PLUGIN_MSG_CAT_3d_mode, String.valueOf(p.PREF_show_3d_map)); p.PREF_use_smooth_drawing = prefs.getBoolean("use_smooth_drawing", true); p.PREF_use_more_smooth_drawing = prefs.getBoolean("use_more_smooth_drawing", false); if (p.PREF_use_smooth_drawing == false) { p.PREF_use_more_smooth_drawing = false; } if (p.PREF_use_more_smooth_drawing == true) { p.PREF_use_smooth_drawing = true; } boolean b1 = prefs.getBoolean("show_real_gps_pos", false); if (b1 == false) { p.PREF_show_real_gps_pos = 0; } else { p.PREF_show_real_gps_pos = 1; } if (p.PREF_use_more_smooth_drawing) { NavitGraphics.Vehicle_delay_real_gps_position = 595; } else { NavitGraphics.Vehicle_delay_real_gps_position = 450; } p.PREF_use_lock_on_roads = prefs.getBoolean("use_lock_on_roads", true); p.PREF_use_route_highways = prefs.getBoolean("use_route_highways", true); p.PREF_save_zoomlevel = prefs.getBoolean("save_zoomlevel", true); p.PREF_search_country = prefs.getInt("search_country_id", 1); // default=*ALL* p.PREF_zoomlevel_num = prefs.getInt("zoomlevel_num", 174698); // default zoom level = 174698 // shows almost the whole world p.PREF_show_sat_status = prefs.getBoolean("show_sat_status", true); p.PREF_use_agps = prefs.getBoolean("use_agps", true); p.PREF_enable_debug_functions = prefs.getBoolean("enable_debug_functions", false); p.PREF_show_turn_restrictions = prefs.getBoolean("show_turn_restrictions", false); p.PREF_auto_night_mode = prefs.getBoolean("auto_night_mode", true); if (FDBL) { try { if (!prefs.contains("enable_debug_crashdetect")) { prefs.edit().putBoolean("enable_debug_crashdetect", true).commit(); System.out.println("setting default value of enable_debug_crashdetect to \"true\""); } } catch (Exception e4) { } p.PREF_enable_debug_crashdetect = prefs.getBoolean("enable_debug_crashdetect", true); } else { if (PLAYSTORE_VERSION_CRASHDETECT) { try { if (!prefs.contains("enable_debug_crashdetect")) { prefs.edit().putBoolean("enable_debug_crashdetect", true).commit(); System.out.println("setting default value of enable_debug_crashdetect to \"true\""); } } catch (Exception e4) { } } p.PREF_enable_debug_crashdetect = prefs.getBoolean("enable_debug_crashdetect", PLAYSTORE_VERSION_CRASHDETECT); } // System.out.println("night mode=" + p.PREF_auto_night_mode); try { // recreate the menu items Message msg = Navit_progress_h.obtainMessage(); Bundle b = new Bundle(); msg.what = 29; msg.setData(b); Navit_progress_h.sendMessage(msg); } catch (Exception e) { e.printStackTrace(); } p.PREF_enable_debug_write_gpx = prefs.getBoolean("enable_debug_write_gpx", false); p.PREF_enable_debug_enable_comm = prefs.getBoolean("enable_debug_enable_comm", false); p.PREF_speak_street_names = prefs.getBoolean("speak_street_names", true); p.PREF_use_custom_font = prefs.getBoolean("use_custom_font", true); p.PREF_draw_polyline_circles = prefs.getBoolean("draw_polyline_circles", true); p.PREF_streetsearch_r = prefs.getString("streetsearch_r", "2"); p.PREF_route_style = prefs.getString("route_style", "3"); p.PREF_item_dump = prefs.getBoolean("item_dump", false); p.PREF_show_route_rects = prefs.getBoolean("show_route_rects", false); p.PREF_trafficlights_delay = prefs.getString("trafficlights_delay", "0"); boolean tmp = prefs.getBoolean("avoid_sharp_turns", false); p.PREF_avoid_sharp_turns = "0"; //if (tmp) //{ // p.PREF_avoid_sharp_turns = "1"; //} p.PREF_autozoom_flag = prefs.getBoolean("autozoom_flag", true); p.PREF_show_multipolygons = prefs.getBoolean("show_multipolygons", true); p.PREF_use_index_search = true; // prefs.getBoolean("use_index_search", true); // PREF_show_2d3d_toggle = prefs.getBoolean("show_2d3d_toggle", true); p.PREF_show_2d3d_toggle = true; // PREF_show_vehicle_3d = prefs.getBoolean("show_vehicle_3d", true); p.PREF_show_vehicle_3d = true; p.PREF_speak_filter_special_chars = prefs.getBoolean("speak_filter_special_chars", true); try { p.PREF_routing_engine = Integer.parseInt(prefs.getString("routing_engine", "0")); } catch (Exception e) { p.PREF_routing_engine = 0; } // send to C code -------- NavitGraphics.CallbackMessageChannel(55598, "" + p.PREF_routing_engine); // send to C code -------- p.PREF_routing_profile = prefs.getString("routing_profile", "car"); p.PREF_road_priority_001 = (prefs.getInt("road_priority_001", (68 - 10)) + 10); // must ADD minimum value!! p.PREF_road_priority_002 = (prefs.getInt("road_priority_002", (329 - 10)) + 10); // must ADD minimum value!! p.PREF_road_priority_003 = (prefs.getInt("road_priority_003", (5000 - 10)) + 10); // must ADD minimum value!! p.PREF_road_priority_004 = (prefs.getInt("road_priority_004", (5 - 0)) + 0); // must ADD minimum value!! p.PREF_night_mode_lux = (prefs.getInt("night_mode_lux", (10 - 1)) + 1); // must ADD minimum value!! p.PREF_night_mode_buffer = (prefs.getInt("night_mode_buffer", (20 - 1)) + 1); // must ADD minimum value!! // p.PREF_road_prio_weight_street_1_city = (prefs.getInt("road_prio_weight_street_1_city", (30 - 10)) + 10); // must ADD minimum value!! p.PREF_traffic_speed_factor = (prefs.getInt("traffic_speed_factor", (83 - 20)) + 20); // must ADD minimum value!! p.PREF_tracking_connected_pref = (prefs.getInt("tracking_connected_pref", (250 - 0)) + 0); // must ADD minimum value!! p.PREF_tracking_angle_pref = (prefs.getInt("tracking_angle_pref", (40 - 0)) + 0); // must ADD minimum value!! p.PREF_streets_only = prefs.getBoolean("streets_only", false); p.PREF_show_status_bar = prefs.getBoolean("show_status_bar", true); p.PREF_show_poi_on_map = prefs.getBoolean("show_poi_on_map", false); p.PREF_last_selected_dir_gpxfiles = prefs.getString("last_selected_dir_gpxfiles", MAP_FILENAME_PATH + "/../"); p.PREF_roadspeed_warning = prefs.getBoolean("roadspeed_warning", false); p.PREF_lane_assist = prefs.getBoolean("lane_assist", false); try { p.PREF_roadspeed_warning_margin = Integer.parseInt(prefs.getString("roadspeed_warning_margin", "20")); } catch (Exception e) { p.PREF_roadspeed_warning_margin = 20; } p.PREF_StreetSearchStrings = loadArray("xxStrtSrhStrxx", STREET_SEARCH_STRINGS_SAVE_COUNT); try { p.PREF_drawatorder = Integer.parseInt(prefs.getString("drawatorder", "0")); } catch (Exception e) { p.PREF_drawatorder = 0; } //try //{ // PREF_cancel_map_drawing_timeout = Integer.parseInt(prefs.getString("cancel_map_drawing_timeout", "1")); //} //catch (Exception e) //{ p.PREF_cancel_map_drawing_timeout = 1; //} try { p.PREF_map_font_size = Integer.parseInt(prefs.getString("map_font_size", "3")); } catch (Exception e) { p.PREF_map_font_size = 2; } Navit_last_address_search_country_id = p.PREF_search_country; Navit_last_address_search_country_iso2_string = NavitAddressSearchCountrySelectActivity.CountryList_Human[p.PREF_search_country][0]; if (!p.PREF_follow_gps) { // no compass turning without follow mode! p.PREF_use_compass_heading_base = false; } if (!p.PREF_use_compass_heading_base) { // child is always "false" when parent is "false" !! p.PREF_use_compass_heading_always = false; } p.PREF_show_maps_debug_view = prefs.getBoolean("show_maps_debug_view", false); p.PREF_show_vehicle_in_center = prefs.getBoolean("show_vehicle_in_center", false); p.PREF_use_imperial = prefs.getBoolean("use_imperial", false); Navit.cur_max_speed = -1; // to update speedwarning graphics // System.out.println("get settings"); // System.out.println("PREF_search_country=" + PREF_search_country); // System.out.println("PREF_follow_gps=" + PREF_follow_gps); // System.out.println("PREF_use_fast_provider=" + PREF_use_fast_provider); // System.out.println("PREF_allow_gui_internal=" + PREF_allow_gui_internal); // System.out.println("PREF_use_compass_heading_base=" + PREF_use_compass_heading_base); // System.out.println("PREF_use_compass_heading_always=" + PREF_use_compass_heading_always); // System.out.println("PREF_show_vehicle_in_center=" + PREF_show_vehicle_in_center); // System.out.println("PREF_use_imperial=" + PREF_use_imperial); // if (Navit.METHOD_DEBUG) Navit.my_func_name(1); }