diff options
author | Herbert von Broeuschmeul <Herbert.Broeuschmeul@gmail.com> | 2010-12-03 02:36:59 +0100 |
---|---|---|
committer | Herbert von Broeuschmeul <Herbert.Broeuschmeul@gmail.com> | 2010-12-03 02:36:59 +0100 |
commit | f223acbfd9d2e832211f65cad82a69c64b31c346 (patch) | |
tree | f0e1a9b7cacc04b055aa7a3bc37ea60929339ea7 /src/org/broeuschmeul/android/gps/bluetooth | |
parent | 209c8bd571998d3d1639c56c5ad02fba0b6f9fe5 (diff) | |
parent | 173e2bd256382e33de5ece287a1ec5667196a2e4 (diff) | |
download | BlueGPS-f223acbfd9d2e832211f65cad82a69c64b31c346.zip BlueGPS-f223acbfd9d2e832211f65cad82a69c64b31c346.tar.gz BlueGPS-f223acbfd9d2e832211f65cad82a69c64b31c346.tar.bz2 |
Merge branch 'dev_1.1.x' into dev_1.2.x
Diffstat (limited to 'src/org/broeuschmeul/android/gps/bluetooth')
-rw-r--r-- | src/org/broeuschmeul/android/gps/bluetooth/provider/BluetoothGpsActivity.java | 44 | ||||
-rw-r--r-- | src/org/broeuschmeul/android/gps/bluetooth/provider/BluetoothGpsProviderService.java | 1 |
2 files changed, 43 insertions, 2 deletions
diff --git a/src/org/broeuschmeul/android/gps/bluetooth/provider/BluetoothGpsActivity.java b/src/org/broeuschmeul/android/gps/bluetooth/provider/BluetoothGpsActivity.java index ad35864..0551913 100644 --- a/src/org/broeuschmeul/android/gps/bluetooth/provider/BluetoothGpsActivity.java +++ b/src/org/broeuschmeul/android/gps/bluetooth/provider/BluetoothGpsActivity.java @@ -20,8 +20,10 @@ package org.broeuschmeul.android.gps.bluetooth.provider;
+import java.util.HashSet;
import java.util.Set;
+import android.app.AlertDialog;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.content.Intent;
@@ -34,7 +36,10 @@ import android.preference.Preference; import android.preference.PreferenceActivity;
import android.preference.PreferenceManager;
import android.preference.Preference.OnPreferenceChangeListener;
+import android.text.method.LinkMovementMethod;
import android.util.Log;
+import android.view.View;
+import android.widget.TextView;
/**
* A PreferenceActivity Class used to configure, start and stop the NMEA tracker service.
@@ -58,6 +63,14 @@ public class BluetoothGpsActivity extends PreferenceActivity implements OnPrefer sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
sharedPref.registerOnSharedPreferenceChangeListener(this);
bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
+ Preference pref = findPreference(BluetoothGpsProviderService.PREF_ABOUT);
+ pref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
+ @Override
+ public boolean onPreferenceClick(Preference preference) {
+ BluetoothGpsActivity.this.displayAboutDialog();
+ return true;
+ }
+ });
}
/* (non-Javadoc)
@@ -85,7 +98,10 @@ public class BluetoothGpsActivity extends PreferenceActivity implements OnPrefer updateDevicePreferenceSummary();
// update bluetooth device list
ListPreference prefDevices = (ListPreference)findPreference(BluetoothGpsProviderService.PREF_BLUETOOTH_DEVICE);
- Set<BluetoothDevice> pairedDevices = bluetoothAdapter.getBondedDevices();
+ Set<BluetoothDevice> pairedDevices = new HashSet<BluetoothDevice>();
+ if (bluetoothAdapter != null){
+ pairedDevices = bluetoothAdapter.getBondedDevices();
+ }
String[] entryValues = new String[pairedDevices.size()];
String[] entries = new String[pairedDevices.size()];
int i = 0;
@@ -118,7 +134,7 @@ public class BluetoothGpsActivity extends PreferenceActivity implements OnPrefer pref.setSummary(s);
Log.v(LOG_TAG, "loc. provider: "+s);
Log.v(LOG_TAG, "loc. provider: "+pref.getSummary());
- }
+ }
this.onContentChanged();
}
@@ -127,6 +143,30 @@ public class BluetoothGpsActivity extends PreferenceActivity implements OnPrefer super.onDestroy();
sharedPref.unregisterOnSharedPreferenceChangeListener(this);
}
+
+ private void displayAboutDialog(){
+ View messageView = getLayoutInflater().inflate(R.layout.about, null, false);
+ // we need this to enable html links
+ TextView textView = (TextView) messageView.findViewById(R.id.about_license);
+ textView.setMovementMethod(LinkMovementMethod.getInstance());
+ // When linking text, force to always use default color. This works
+ // around a pressed color state bug.
+ int defaultColor = textView.getTextColors().getDefaultColor();
+ textView.setTextColor(defaultColor);
+ textView = (TextView) messageView.findViewById(R.id.about_sources);
+ textView.setTextColor(defaultColor);
+
+ AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ builder.setTitle(R.string.about_title);
+ builder.setIcon(R.drawable.gplv3_icon);
+ builder.setView(messageView);
+
+
+// CharSequence styledText = Html.fromHtml(getString(R.string.about));
+// builder.setMessage(R.string.about);
+// builder.setMessage(styledText);
+ builder.show();
+ }
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
diff --git a/src/org/broeuschmeul/android/gps/bluetooth/provider/BluetoothGpsProviderService.java b/src/org/broeuschmeul/android/gps/bluetooth/provider/BluetoothGpsProviderService.java index c772e94..a2f1c8d 100644 --- a/src/org/broeuschmeul/android/gps/bluetooth/provider/BluetoothGpsProviderService.java +++ b/src/org/broeuschmeul/android/gps/bluetooth/provider/BluetoothGpsProviderService.java @@ -70,6 +70,7 @@ public class BluetoothGpsProviderService extends Service implements NmeaListener public static final String PREF_TRACK_FILE_DIR = "trackFileDirectory";
public static final String PREF_TRACK_FILE_PREFIX = "trackFilePrefix";
public static final String PREF_BLUETOOTH_DEVICE = "bluetoothDevice";
+ public static final String PREF_ABOUT = "about";
private static final String LOG_TAG = "BlueGPS";
// private static final String LOG_TAG = BluetoothGpsProviderService.class.getSimpleName();
|