1 package com.introlab.rtabmap;
4 import java.text.SimpleDateFormat;
5 import java.util.ArrayList;
6 import java.util.Arrays;
7 import java.util.Iterator;
8 import java.util.Map.Entry;
10 import android.Manifest;
11 import android.app.AlertDialog;
12 import android.content.DialogInterface;
13 import android.content.SharedPreferences;
14 import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
15 import android.content.pm.PackageManager;
16 import android.os.Bundle;
17 import android.preference.CheckBoxPreference;
18 import android.preference.ListPreference;
19 import android.preference.Preference;
20 import android.preference.PreferenceActivity;
21 import android.text.InputType;
22 import android.view.WindowManager;
23 import android.view.inputmethod.EditorInfo;
24 import android.widget.EditText;
25 import android.widget.Toast;
27 public class SettingsActivity extends PreferenceActivity implements OnSharedPreferenceChangeListener {
32 public void onCreate(Bundle savedInstanceState) {
33 super.onCreate(savedInstanceState);
34 addPreferencesFromResource(
R.layout.activity_settings);
36 Preference buttonReset = findPreference(getString(
R.string.pref_key_reset_button));
37 buttonReset.setOnPreferenceClickListener(
new Preference.OnPreferenceClickListener() {
39 public boolean onPreferenceClick(Preference preference) {
40 getPreferenceScreen().getSharedPreferences().edit().clear().commit();
48 Preference buttonOpen = findPreference(getString(
R.string.pref_key_open_button));
49 buttonOpen.setOnPreferenceClickListener(
new Preference.OnPreferenceClickListener() {
51 public boolean onPreferenceClick(Preference preference) {
52 File prefsdir = new File(getApplicationInfo().dataDir,
"shared_prefs");
53 if(prefsdir.exists() && prefsdir.isDirectory()){
54 ArrayList<String> filesArray = new ArrayList<String>(Arrays.asList(prefsdir.list()));
55 ArrayList<String> newList = new ArrayList<String>();
56 filesArray.remove(
"com.introlab.rtabmap_preferences.xml");
57 filesArray.remove(
"WebViewChromiumPrefs.xml");
58 for (String s : filesArray) {
59 newList.add(s.substring(0, s.length()-4));
61 final String[] files = newList.toArray(new String[filesArray.size()]);
64 AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
65 builder.setTitle(
"Choose Presets:");
66 builder.setItems(files, new DialogInterface.OnClickListener() {
67 public void onClick(DialogInterface dialog, final int which) {
69 SharedPreferences.Editor ed = getPreferenceScreen().getSharedPreferences().edit();
70 SharedPreferences sp = getActivity().getSharedPreferences(files[which], MODE_PRIVATE);
72 for(Entry<String,?> entry : sp.getAll().entrySet()){
73 Object v = entry.getValue();
74 String key = entry.getKey();
78 if(v instanceof Boolean)
81 ed.putBoolean(key, ((Boolean)v).booleanValue());
82 else if(v instanceof Float)
83 ed.putFloat(key, ((Float)v).floatValue());
84 else if(v instanceof Integer)
85 ed.putInt(key, ((Integer)v).intValue());
86 else if(v instanceof Long)
87 ed.putLong(key, ((Long)v).longValue());
88 else if(v instanceof String)
89 ed.putString(key, ((String)v));
104 Preference buttonSave = findPreference(getString(
R.string.pref_key_save_button));
105 buttonSave.setOnPreferenceClickListener(
new Preference.OnPreferenceClickListener() {
107 public boolean onPreferenceClick(Preference preference) {
108 AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
109 builder.setTitle(
"Save Presets:");
110 final EditText input = new EditText(getActivity());
111 input.setInputType(InputType.TYPE_CLASS_TEXT);
112 input.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI);
113 builder.setView(input);
114 builder.setPositiveButton(
"OK", new DialogInterface.OnClickListener() {
116 public void onClick(DialogInterface dialog, int which)
118 final String fileName = input.getText().toString();
120 if(!fileName.isEmpty())
122 File newFile = new File(getApplicationInfo().dataDir +
"/shared_prefs/" + fileName +
".xml");
125 new AlertDialog.Builder(getActivity())
126 .setTitle(
"Presets Already Exist")
127 .setMessage(
"Do you want to overwrite the existing file?")
128 .setPositiveButton(
"Yes", new DialogInterface.OnClickListener() {
129 public void onClick(DialogInterface dialog, int which) {
130 saveConfig(fileName);
133 .setNegativeButton(
"No", new DialogInterface.OnClickListener() {
134 public void onClick(DialogInterface dialog, int which) {
142 saveConfig(fileName);
147 AlertDialog alertToShow = builder.create();
148 alertToShow.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
155 Preference buttonRemove = findPreference(getString(
R.string.pref_key_remove_button));
156 buttonRemove.setOnPreferenceClickListener(
new Preference.OnPreferenceClickListener() {
158 public boolean onPreferenceClick(Preference preference) {
159 File prefsdir = new File(getApplicationInfo().dataDir,
"shared_prefs");
160 if(prefsdir.exists() && prefsdir.isDirectory()){
161 ArrayList<String> filesArray = new ArrayList<String>(Arrays.asList(prefsdir.list()));
162 ArrayList<String> newList = new ArrayList<String>();
163 filesArray.remove(
"com.introlab.rtabmap_preferences.xml");
164 filesArray.remove(
"WebViewChromiumPrefs.xml");
165 for (String s : filesArray) {
166 newList.add(s.substring(0, s.length()-4));
168 final String[] files = newList.toArray(new String[filesArray.size()]);
171 AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
172 builder.setTitle(
"Remove Presets:");
173 builder.setItems(files, new DialogInterface.OnClickListener() {
174 public void onClick(DialogInterface dialog, final int which) {
175 File file = new File(getApplicationInfo().dataDir +
"/shared_prefs/" + files[which] +
".xml");
191 Preference buttonGPS = findPreference(getString(
R.string.pref_key_gps_saved));
192 buttonGPS.setOnPreferenceClickListener(
new Preference.OnPreferenceClickListener() {
194 public boolean onPreferenceClick(Preference preference) {
195 if(((CustomSwitchPreference)preference).isChecked())
197 if (!PermissionHelper.hasPermission(getActivity(), Manifest.permission.ACCESS_FINE_LOCATION)) {
198 ((CustomSwitchPreference)preference).setChecked(false);
199 PermissionHelper.requestPermission(getActivity(), Manifest.permission.ACCESS_FINE_LOCATION);
206 if(((CustomSwitchPreference)buttonGPS).isChecked())
208 if (!PermissionHelper.hasPermission(
this, Manifest.permission.ACCESS_FINE_LOCATION)) {
209 ((CustomSwitchPreference)buttonGPS).setChecked(
false);
210 PermissionHelper.requestPermission(
this, Manifest.permission.ACCESS_FINE_LOCATION);
215 ((Preference)findPreference(getString(
R.string.pref_key_camera_driver))).setSummary(
"("+((ListPreference)findPreference(getString(
R.string.pref_key_camera_driver))).getEntry() +
") "+getString(
R.string.pref_summary_camera_driver));
216 ((Preference)findPreference(getString(
R.string.pref_key_density))).setSummary(
"("+((ListPreference)findPreference(getString(
R.string.pref_key_density))).getEntry() +
") "+getString(
R.string.pref_summary_density));
217 ((Preference)findPreference(getString(
R.string.pref_key_depth))).setSummary(
"("+((ListPreference)findPreference(getString(
R.string.pref_key_depth))).getEntry() +
") "+getString(
R.string.pref_summary_depth));
218 ((Preference)findPreference(getString(
R.string.pref_key_min_depth))).setSummary(
"("+((ListPreference)findPreference(getString(
R.string.pref_key_min_depth))).getEntry() +
") "+getString(
R.string.pref_summary_min_depth));
219 ((Preference)findPreference(getString(
R.string.pref_key_point_size))).setSummary(
"("+((ListPreference)findPreference(getString(
R.string.pref_key_point_size))).getEntry() +
") "+getString(
R.string.pref_summary_point_size));
220 ((Preference)findPreference(getString(
R.string.pref_key_angle))).setSummary(
"("+((ListPreference)findPreference(getString(
R.string.pref_key_angle))).getEntry() +
") "+getString(
R.string.pref_summary_angle));
221 ((Preference)findPreference(getString(
R.string.pref_key_triangle))).setSummary(
"("+((ListPreference)findPreference(getString(
R.string.pref_key_triangle))).getEntry() +
") "+getString(
R.string.pref_summary_triangle));
222 ((Preference)findPreference(getString(
R.string.pref_key_background_color))).setSummary(
"("+((ListPreference)findPreference(getString(
R.string.pref_key_background_color))).getEntry() +
") "+getString(
R.string.pref_summary_background_color));
223 ((Preference)findPreference(getString(
R.string.pref_key_rendering_texture_decimation))).setSummary(
"("+((ListPreference)findPreference(getString(
R.string.pref_key_rendering_texture_decimation))).getEntry() +
") "+getString(
R.string.pref_summary_rendering_texture_decimation));
225 ((Preference)findPreference(getString(
R.string.pref_key_arcore_localization_filtering_speed))).setSummary(
"("+((ListPreference)findPreference(getString(
R.string.pref_key_arcore_localization_filtering_speed))).getEntry() +
") "+getString(
R.string.pref_summary_arcore_localization_filtering_speed));
226 ((Preference)findPreference(getString(
R.string.pref_key_update_rate))).setSummary(
"("+((ListPreference)findPreference(getString(
R.string.pref_key_update_rate))).getEntry() +
") "+getString(
R.string.pref_summary_update_rate));
227 ((Preference)findPreference(getString(
R.string.pref_key_max_speed))).setSummary(
"("+((ListPreference)findPreference(getString(
R.string.pref_key_max_speed))).getEntry() +
") "+getString(
R.string.pref_summary_max_speed));
228 ((Preference)findPreference(getString(
R.string.pref_key_time_thr))).setSummary(
"("+((ListPreference)findPreference(getString(
R.string.pref_key_time_thr))).getEntry() +
") "+getString(
R.string.pref_summary_time_thr));
229 ((Preference)findPreference(getString(
R.string.pref_key_mem_thr))).setSummary(
"("+((ListPreference)findPreference(getString(
R.string.pref_key_mem_thr))).getEntry() +
") "+getString(
R.string.pref_summary_mem_thr));
230 ((Preference)findPreference(getString(
R.string.pref_key_loop_thr))).setSummary(
"("+((ListPreference)findPreference(getString(
R.string.pref_key_loop_thr))).getEntry() +
") "+getString(
R.string.pref_summary_loop_thr));
231 ((Preference)findPreference(getString(
R.string.pref_key_sim_thr))).setSummary(
"("+((ListPreference)findPreference(getString(
R.string.pref_key_sim_thr))).getEntry() +
") "+getString(
R.string.pref_summary_sim_thr));
232 ((Preference)findPreference(getString(
R.string.pref_key_min_inliers))).setSummary(
"("+((ListPreference)findPreference(getString(
R.string.pref_key_min_inliers))).getEntry() +
") "+getString(
R.string.pref_summary_min_inliers));
233 ((Preference)findPreference(getString(
R.string.pref_key_opt_error))).setSummary(
"("+((ListPreference)findPreference(getString(
R.string.pref_key_opt_error))).getEntry() +
") "+getString(
R.string.pref_summary_opt_error));
234 ((Preference)findPreference(getString(
R.string.pref_key_features_voc))).setSummary(
"("+((ListPreference)findPreference(getString(
R.string.pref_key_features_voc))).getEntry() +
") "+getString(
R.string.pref_summary_features_voc));
235 ((Preference)findPreference(getString(
R.string.pref_key_features))).setSummary(
"("+((ListPreference)findPreference(getString(
R.string.pref_key_features))).getEntry() +
") "+getString(
R.string.pref_summary_features));
236 ((Preference)findPreference(getString(
R.string.pref_key_features_type))).setSummary(
"("+((ListPreference)findPreference(getString(
R.string.pref_key_features_type))).getEntry() +
") "+getString(
R.string.pref_summary_features_type));
237 ((Preference)findPreference(getString(
R.string.pref_key_optimizer))).setSummary(
"("+((ListPreference)findPreference(getString(
R.string.pref_key_optimizer))).getEntry() +
") "+getString(
R.string.pref_summary_optimizer));
238 ((Preference)findPreference(getString(
R.string.pref_key_marker_detection))).setSummary(
"("+((ListPreference)findPreference(getString(
R.string.pref_key_marker_detection))).getEntry() +
") "+getString(
R.string.pref_summary_marker_detection));
239 ((Preference)findPreference(getString(
R.string.pref_key_marker_detection_depth_error))).setSummary(
"("+((ListPreference)findPreference(getString(
R.string.pref_key_marker_detection_depth_error))).getEntry() +
") "+getString(
R.string.pref_summary_marker_detection_depth_error));
241 ((Preference)findPreference(getString(
R.string.pref_key_cloud_voxel))).setSummary(
"("+((ListPreference)findPreference(getString(
R.string.pref_key_cloud_voxel))).getEntry() +
") "+getString(
R.string.pref_summary_cloud_voxel));
242 ((Preference)findPreference(getString(
R.string.pref_key_texture_size))).setSummary(
"("+((ListPreference)findPreference(getString(
R.string.pref_key_texture_size))).getEntry() +
") "+getString(
R.string.pref_summary_texture_size));
243 ((Preference)findPreference(getString(
R.string.pref_key_texture_count))).setSummary(
"("+((ListPreference)findPreference(getString(
R.string.pref_key_texture_count))).getEntry() +
") "+getString(
R.string.pref_summary_texture_count));
244 ((Preference)findPreference(getString(
R.string.pref_key_normal_k))).setSummary(
"("+((ListPreference)findPreference(getString(
R.string.pref_key_normal_k))).getEntry() +
") "+getString(
R.string.pref_summary_normal_k));
245 ((Preference)findPreference(getString(
R.string.pref_key_max_texture_distance))).setSummary(
"("+((ListPreference)findPreference(getString(
R.string.pref_key_max_texture_distance))).getEntry() +
") "+getString(
R.string.pref_summary_max_texture_distance));
246 ((Preference)findPreference(getString(
R.string.pref_key_min_texture_cluster_size))).setSummary(
"("+((ListPreference)findPreference(getString(
R.string.pref_key_min_texture_cluster_size))).getEntry() +
") "+getString(
R.string.pref_summary_min_texture_cluster_size));
248 ((Preference)findPreference(getString(
R.string.pref_key_opt_depth))).setSummary(
"("+((ListPreference)findPreference(getString(
R.string.pref_key_opt_depth))).getEntry() +
") "+getString(
R.string.pref_summary_opt_depth));
249 ((Preference)findPreference(getString(
R.string.pref_key_opt_color_radius))).setSummary(
"("+((ListPreference)findPreference(getString(
R.string.pref_key_opt_color_radius))).getEntry() +
") "+getString(
R.string.pref_summary_opt_color_radius));
250 ((Preference)findPreference(getString(
R.string.pref_key_opt_min_cluster_size))).setSummary(
"("+((ListPreference)findPreference(getString(
R.string.pref_key_opt_min_cluster_size))).getEntry() +
") "+getString(
R.string.pref_summary_opt_min_cluster_size));
252 ((Preference)findPreference(getString(
R.string.pref_key_cluster_ratio))).setSummary(
"("+((ListPreference)findPreference(getString(
R.string.pref_key_cluster_ratio))).getEntry() +
") "+getString(
R.string.pref_summary_cluster_ratio));
253 ((Preference)findPreference(getString(
R.string.pref_key_gain_max_radius))).setSummary(
"("+((ListPreference)findPreference(getString(
R.string.pref_key_gain_max_radius))).getEntry() +
") "+getString(
R.string.pref_summary_gain_max_radius));
257 Preference pref = findPreference(
key);
259 if (pref instanceof ListPreference) {
260 if(
key.compareTo(getString(
R.string.pref_key_camera_driver))==0) pref.setSummary(
"("+ ((ListPreference)pref).getEntry() +
") "+getString(
R.string.pref_summary_camera_driver));
261 if(
key.compareTo(getString(
R.string.pref_key_density))==0) pref.setSummary(
"("+ ((ListPreference)pref).getEntry() +
") "+getString(
R.string.pref_summary_density));
262 if(
key.compareTo(getString(
R.string.pref_key_depth))==0)
264 pref.setSummary(
"("+((ListPreference)pref).getEntry() +
") "+getString(
R.string.pref_summary_depth));
265 float maxDepth =
Float.parseFloat(((ListPreference)pref).getValue());
266 float minDepth =
Float.parseFloat(((ListPreference)findPreference(getString(
R.string.pref_key_min_depth))).getValue());
267 if(maxDepth > 0.0
f && maxDepth <= minDepth)
269 ((ListPreference)findPreference(getString(
R.string.pref_key_min_depth))).setValueIndex(0);
272 if(
key.compareTo(getString(
R.string.pref_key_min_depth))==0)
274 pref.setSummary(
"("+((ListPreference)pref).getEntry() +
") "+getString(
R.string.pref_summary_min_depth));
275 float maxDepth =
Float.parseFloat(((ListPreference)findPreference(getString(
R.string.pref_key_depth))).getValue());
276 float minDepth =
Float.parseFloat(((ListPreference)pref).getValue());
277 if(minDepth >= maxDepth)
279 ((ListPreference)findPreference(getString(
R.string.pref_key_depth))).setValueIndex(0);
282 if(
key.compareTo(getString(
R.string.pref_key_point_size))==0) pref.setSummary(
"("+((ListPreference)pref).getEntry() +
") "+getString(
R.string.pref_summary_point_size));
283 if(
key.compareTo(getString(
R.string.pref_key_angle))==0) pref.setSummary(
"("+((ListPreference)pref).getEntry() +
") "+getString(
R.string.pref_summary_angle));
284 if(
key.compareTo(getString(
R.string.pref_key_triangle))==0) pref.setSummary(
"("+((ListPreference)pref).getEntry() +
") "+getString(
R.string.pref_summary_triangle));
285 if(
key.compareTo(getString(
R.string.pref_key_background_color))==0) pref.setSummary(
"("+((ListPreference)pref).getEntry() +
") "+getString(
R.string.pref_summary_background_color));
286 if(
key.compareTo(getString(
R.string.pref_key_rendering_texture_decimation))==0) pref.setSummary(
"("+((ListPreference)pref).getEntry() +
") "+getString(
R.string.pref_summary_rendering_texture_decimation));
288 if(
key.compareTo(getString(
R.string.pref_key_arcore_localization_filtering_speed))==0) pref.setSummary(
"("+((ListPreference)pref).getEntry() +
") "+getString(
R.string.pref_summary_arcore_localization_filtering_speed));
289 if(
key.compareTo(getString(
R.string.pref_key_update_rate))==0) pref.setSummary(
"("+((ListPreference)pref).getEntry() +
") "+getString(
R.string.pref_summary_update_rate));
290 if(
key.compareTo(getString(
R.string.pref_key_max_speed))==0) pref.setSummary(
"("+((ListPreference)pref).getEntry() +
") "+getString(
R.string.pref_summary_max_speed));
291 if(
key.compareTo(getString(
R.string.pref_key_time_thr))==0) pref.setSummary(
"("+((ListPreference)pref).getEntry() +
") "+getString(
R.string.pref_summary_time_thr));
292 if(
key.compareTo(getString(
R.string.pref_key_mem_thr))==0) pref.setSummary(
"("+((ListPreference)pref).getEntry() +
") "+getString(
R.string.pref_summary_mem_thr));
293 if(
key.compareTo(getString(
R.string.pref_key_loop_thr))==0) pref.setSummary(
"("+((ListPreference)pref).getEntry() +
") "+getString(
R.string.pref_summary_loop_thr));
294 if(
key.compareTo(getString(
R.string.pref_key_sim_thr))==0) pref.setSummary(
"("+((ListPreference)pref).getEntry() +
") "+getString(
R.string.pref_summary_sim_thr));
295 if(
key.compareTo(getString(
R.string.pref_key_min_inliers))==0) pref.setSummary(
"("+((ListPreference)pref).getEntry() +
") "+getString(
R.string.pref_summary_min_inliers));
296 if(
key.compareTo(getString(
R.string.pref_key_opt_error))==0) pref.setSummary(
"("+((ListPreference)pref).getEntry() +
") "+getString(
R.string.pref_summary_opt_error));
297 if(
key.compareTo(getString(
R.string.pref_key_features_voc))==0) pref.setSummary(
"("+((ListPreference)pref).getEntry() +
") "+getString(
R.string.pref_summary_features_voc));
298 if(
key.compareTo(getString(
R.string.pref_key_features))==0) pref.setSummary(
"("+((ListPreference)pref).getEntry() +
") "+getString(
R.string.pref_summary_features));
299 if(
key.compareTo(getString(
R.string.pref_key_features_type))==0) pref.setSummary(
"("+((ListPreference)pref).getEntry() +
") "+getString(
R.string.pref_summary_features_type));
300 if(
key.compareTo(getString(
R.string.pref_key_optimizer))==0) pref.setSummary(
"("+((ListPreference)pref).getEntry() +
") "+getString(
R.string.pref_summary_optimizer));
301 if(
key.compareTo(getString(
R.string.pref_key_marker_detection))==0) pref.setSummary(
"("+((ListPreference)pref).getEntry() +
") "+getString(
R.string.pref_summary_marker_detection));
302 if(
key.compareTo(getString(
R.string.pref_key_marker_detection_depth_error))==0) pref.setSummary(
"("+((ListPreference)pref).getEntry() +
") "+getString(
R.string.pref_summary_marker_detection_depth_error));
304 if(
key.compareTo(getString(
R.string.pref_key_cloud_voxel))==0) pref.setSummary(
"("+((ListPreference)pref).getEntry() +
") "+getString(
R.string.pref_summary_cloud_voxel));
305 if(
key.compareTo(getString(
R.string.pref_key_texture_size))==0) pref.setSummary(
"("+((ListPreference)pref).getEntry() +
") "+getString(
R.string.pref_summary_texture_size));
306 if(
key.compareTo(getString(
R.string.pref_key_texture_count))==0) pref.setSummary(
"("+((ListPreference)pref).getEntry() +
") "+getString(
R.string.pref_summary_texture_count));
307 if(
key.compareTo(getString(
R.string.pref_key_normal_k))==0) pref.setSummary(
"("+((ListPreference)pref).getEntry() +
") "+getString(
R.string.pref_summary_normal_k));
308 if(
key.compareTo(getString(
R.string.pref_key_max_texture_distance))==0) pref.setSummary(
"("+((ListPreference)pref).getEntry() +
") "+getString(
R.string.pref_summary_max_texture_distance));
309 if(
key.compareTo(getString(
R.string.pref_key_min_texture_cluster_size))==0) pref.setSummary(
"("+((ListPreference)pref).getEntry() +
") "+getString(
R.string.pref_summary_min_texture_cluster_size));
311 if(
key.compareTo(getString(
R.string.pref_key_opt_depth))==0) pref.setSummary(
"("+((ListPreference)pref).getEntry() +
") "+getString(
R.string.pref_summary_opt_depth));
312 if(
key.compareTo(getString(
R.string.pref_key_opt_color_radius))==0) pref.setSummary(
"("+((ListPreference)pref).getEntry() +
") "+getString(
R.string.pref_summary_opt_color_radius));
313 if(
key.compareTo(getString(
R.string.pref_key_opt_min_cluster_size))==0) pref.setSummary(
"("+((ListPreference)pref).getEntry() +
") "+getString(
R.string.pref_summary_opt_min_cluster_size));
315 if(
key.compareTo(getString(
R.string.pref_key_cluster_ratio))==0) pref.setSummary(
"("+((ListPreference)pref).getEntry() +
") "+getString(
R.string.pref_summary_cluster_ratio));
316 if(
key.compareTo(getString(
R.string.pref_key_gain_max_radius))==0) pref.setSummary(
"("+((ListPreference)pref).getEntry() +
") "+getString(
R.string.pref_summary_gain_max_radius));
325 getPreferenceScreen().getSharedPreferences()
326 .registerOnSharedPreferenceChangeListener(
this);
333 getPreferenceScreen().getSharedPreferences()
334 .unregisterOnSharedPreferenceChangeListener(
this);
340 SharedPreferences.Editor ed = getActivity().getSharedPreferences(fileName, MODE_PRIVATE).edit();
341 SharedPreferences sp = getPreferenceScreen().getSharedPreferences();
344 for(Entry<String,?> entry : sp.getAll().entrySet()){
346 String
key = entry.getKey();
354 else if(
v instanceof
Float)
355 ed.putFloat(
key, ((
Float)
v).floatValue());
356 else if(
v instanceof Integer)
357 ed.putInt(
key, ((Integer)
v).intValue());
358 else if(
v instanceof
Long)
359 ed.putLong(
key, ((
Long)
v).longValue());
360 else if(
v instanceof String)
361 ed.putString(
key, ((String)
v));
369 switch (requestCode) {
372 if (
results.length > 0 &&
results[0] == PackageManager.PERMISSION_GRANTED) {
375 Preference buttonGPS = findPreference(getString(
R.string.pref_key_gps_saved));
380 Toast.makeText(
this,
"Location permission is needed to use GPS functionality", Toast.LENGTH_LONG).show();