Advertisement
mateorod

external_gps_port.packages_apps_Settings.diff

May 15th, 2013
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.92 KB | None | 0 0
  1. mateor@mateor-HP-Pavilion-dv6700:~/android/system/CM10b/packages/apps/Settings$ git diff 625e239c73327bb71dda2ff3e460d1609c2bd73d
  2. diff --git a/res/values/arrays.xml b/res/values/arrays.xml
  3. index 88dbdfd..c7c9116 100644
  4. --- a/res/values/arrays.xml
  5. +++ b/res/values/arrays.xml
  6. @@ -1119,6 +1119,15 @@
  7. <item>1</item>
  8. <item>2</item>
  9. </string-array>
  10. +
  11. + <!-- GPS location port -->
  12. + <string-array name="location_entries_gps_source">
  13. + <item>Use Internal GPS</item>
  14. + </string-array>
  15. +
  16. + <string-array name="location_values_gps_source" translatable="false">
  17. + <item>0</item>
  18. + </string-array>
  19. <!-- CyanogenMod port ENDS -->
  20.  
  21. </resources>
  22. diff --git a/res/values/strings.xml b/res/values/strings.xml
  23. index 68960ba..9f23e4f 100644
  24. --- a/res/values/strings.xml
  25. +++ b/res/values/strings.xml
  26. @@ -2319,6 +2319,14 @@
  27. <!-- [CHAR LIMIT=45] Section heading for location sources -->
  28. <string name="location_sources_heading">Location sources</string>
  29.  
  30. + <!-- CyanogenMod10 feature port START-->
  31. + <!-- GPS Source selection -->
  32. + <string name="location_gps_source_title">GPS source</string>
  33. + <string name="location_gps_source_summary">Choose to use either an external
  34. + <string name="location_gps_source_notification_title">Alert</string>
  35. + <string name="location_gps_source_notification">The GPS source has been swi
  36. + <!-- CyanogenMod10 port END -->
  37. +
  38. <!-- About --> <skip />
  39. <!-- Main settings screen, setting title for the user to go into the About
  40. <string name="about_settings" product="tablet">About tablet</string>
  41. diff --git a/res/xml/location_settings.xml b/res/xml/location_settings.xml
  42. index ab212d8..c2c1c3b 100644
  43. --- a/res/xml/location_settings.xml
  44. +++ b/res/xml/location_settings.xml
  45. @@ -41,6 +41,16 @@
  46. android:dependency="location_toggle"
  47. android:persistent="false" />
  48.  
  49. + <!-- CyanogenMod10 feature port START -->
  50. + <!-- GPS Source pref -->
  51. + <ListPreference android:key="location_gps_source"
  52. + android:dialogTitle="@string/location_gps_source_title"
  53. + android:title="@string/location_gps_source_title"
  54. + android:summary="@string/location_gps_source_summary"
  55. + android:entries="@array/location_entries_gps_source"
  56. + android:entryValues="@array/location_values_gps_source" />
  57. + <!-- CyanogenMod10 feature END -->
  58. +
  59. <!-- Disabled to avoid confusion on devices with no AGPS
  60. For Google experience devices we want AGPS on by default (if supported) so
  61. <CheckBoxPreference
  62. diff --git a/src/com/android/settings/LocationSettings.java b/src/com/android/se
  63. index cfbbe26..0152601 100644
  64. --- a/src/com/android/settings/LocationSettings.java
  65. +++ b/src/com/android/settings/LocationSettings.java
  66. @@ -19,11 +19,13 @@ package com.android.settings;
  67.  
  68. import android.content.ContentQueryMap;
  69. import android.content.ContentResolver;
  70. +import android.content.DialogInterface;
  71. import android.content.Context;
  72. import android.content.Intent;
  73. import android.database.Cursor;
  74. import android.location.LocationManager;
  75. import android.preference.CheckBoxPreference;
  76. +import android.preference.ListPreference;
  77. import android.preference.Preference;
  78. import android.preference.PreferenceScreen;
  79. import android.preference.SwitchPreference;
  80. @@ -34,6 +36,14 @@ import android.widget.TextView;
  81.  
  82. import java.util.Observable;
  83. import java.util.Observer;
  84. +import java.util.ArrayList;
  85. +
  86. +import android.bluetooth.BluetoothAdapter;
  87. +import android.bluetooth.BluetoothDevice;
  88. +import android.app.AlertDialog;
  89. +import android.app.Dialog;
  90. +import android.location.LocationManager;
  91. +import android.widget.Toast;
  92.  
  93. /**
  94. * Gesture lock pattern settings.
  95. @@ -51,6 +61,7 @@ public class LocationSettings extends SettingsPreferenceFragme
  96. private CheckBoxPreference mGps;
  97. private CheckBoxPreference mAssistedGps;
  98. private SwitchPreference mLocationAccess;
  99. + private ListPreference mGPSBTPref;
  100.  
  101. // These provide support for receiving notification when Location Manager s
  102. // This is necessary because the Network Location Provider can change setti
  103. @@ -92,6 +103,31 @@ public class LocationSettings extends SettingsPreferenceFrag
  104. mAssistedGps = (CheckBoxPreference) root.findPreference(KEY_ASSISTED_GP
  105.  
  106. mLocationAccess.setOnPreferenceChangeListener(this);
  107. +
  108. + //add BT gps devices -- from CM10
  109. + mGPSBTPref = (ListPreference) findPreference("location_gps_source");
  110. + ArrayList<CharSequence> entries = new ArrayList<CharSequence>();
  111. + for (String e : getResources().getStringArray(R.array.location_entries_
  112. + entries.add(e);
  113. + }
  114. + ArrayList<CharSequence> values = new ArrayList<CharSequence>();
  115. + for (String v: getResources().getStringArray(R.array.location_values_gp
  116. + values.add(v);
  117. + }
  118. + // add known bonded BT devices
  119. + BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter
  120. + if ((mBluetoothAdapter != null) && (mBluetoothAdapter.isEnabled())) {
  121. + for (BluetoothDevice d : mBluetoothAdapter.getBondedDevices()) {
  122. + String dname = d.getName() + " - " + d.getAddress();
  123. + entries.add(dname);
  124. + values.add(d.getAddress());
  125. + }
  126. + }
  127. + mGPSBTPref.setEntries(entries.toArray(new CharSequence[entries.size()])
  128. + mGPSBTPref.setEntryValues(values.toArray(new CharSequence[values.size()
  129. + mGPSBTPref.setDefaultValue("0");
  130. + mGPSBTPref.setOnPreferenceChangeListener(this);
  131. +
  132. return root;
  133. }
  134.  
  135. @@ -180,6 +216,24 @@ public class LocationSettings extends SettingsPreferenceFra
  136. @Override
  137. public boolean onPreferenceChange(Preference pref, Object newValue) {
  138. if (pref.getKey().equals(KEY_LOCATION_TOGGLE)) {
  139. +
  140. + String oldPref = Settings.System.getString(getContentResolver(),
  141. + Settings.Secure.EXTERNAL_GPS_BT_DEVICE);
  142. + String newPref = newValue == null ? "0" : (String) newValue;
  143. + // "0" represents the internal GPS.
  144. + Settings.System.putString(getContentResolver(), Settings.Secure.EXT
  145. + newPref);
  146. + if (!oldPref.equals(newPref) && ("0".equals(oldPref) || "0".equals(
  147. + LocationManager locationManager =
  148. + (LocationManager) this.getSystemService(Context.LOCATION_SE
  149. + locationManager.setGPSSource(newPref);
  150. + // Show msg to inform user that source has been switched
  151. + Toast.makeText(this.getActivity(),
  152. + getResources().getString(R.string.location_gps_source_n
  153. + Toast.LENGTH_LONG).show();
  154. + }
  155. +
  156. + // Original action
  157. onToggleLocationAccess((Boolean) newValue);
  158. }
  159. return true;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement