aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHerbert von Broeuschmeul <Herbert.Broeuschmeul@gmail.com>2010-12-03 02:09:21 +0100
committerHerbert von Broeuschmeul <Herbert.Broeuschmeul@gmail.com>2010-12-03 02:22:25 +0100
commit173e2bd256382e33de5ece287a1ec5667196a2e4 (patch)
treed8c08a7a5e595c9a6db0c6005e1acf2fd532cb37 /src
parenta904b9153bc5b34a6b5491b885d93fdb5b0179b0 (diff)
downloadBlueGPS-173e2bd256382e33de5ece287a1ec5667196a2e4.zip
BlueGPS-173e2bd256382e33de5ece287a1ec5667196a2e4.tar.gz
BlueGPS-173e2bd256382e33de5ece287a1ec5667196a2e4.tar.bz2
add an "About window" (merge from branch dev 1.0.x)
Diffstat (limited to 'src')
-rw-r--r--src/org/broeuschmeul/android/gps/bluetooth/provider/BluetoothGpsActivity.java34
-rw-r--r--src/org/broeuschmeul/android/gps/bluetooth/provider/BluetoothGpsProviderService.java1
2 files changed, 27 insertions, 8 deletions
diff --git a/src/org/broeuschmeul/android/gps/bluetooth/provider/BluetoothGpsActivity.java b/src/org/broeuschmeul/android/gps/bluetooth/provider/BluetoothGpsActivity.java
index 76782fc..53037c1 100644
--- a/src/org/broeuschmeul/android/gps/bluetooth/provider/BluetoothGpsActivity.java
+++ b/src/org/broeuschmeul/android/gps/bluetooth/provider/BluetoothGpsActivity.java
@@ -20,6 +20,7 @@
package org.broeuschmeul.android.gps.bluetooth.provider;
+import java.util.HashSet;
import java.util.Set;
import android.app.AlertDialog;
@@ -35,6 +36,7 @@ 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;
@@ -61,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)
@@ -88,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;
@@ -121,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();
}
@@ -130,18 +143,25 @@ 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.
- TextView textView = (TextView) messageView.findViewById(R.id.about_sources);
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.aboutTitle);
+ 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);
@@ -155,9 +175,7 @@ public class BluetoothGpsActivity extends PreferenceActivity implements OnPrefer
}
@Override
- public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
- String key) {
- displayAboutDialog();
+ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
if (BluetoothGpsProviderService.PREF_START_GPS_PROVIDER.equals(key)){
boolean val = sharedPreferences.getBoolean(key, false);
CheckBoxPreference pref = (CheckBoxPreference)findPreference(key);
diff --git a/src/org/broeuschmeul/android/gps/bluetooth/provider/BluetoothGpsProviderService.java b/src/org/broeuschmeul/android/gps/bluetooth/provider/BluetoothGpsProviderService.java
index 8eccd7f..41ec34e 100644
--- a/src/org/broeuschmeul/android/gps/bluetooth/provider/BluetoothGpsProviderService.java
+++ b/src/org/broeuschmeul/android/gps/bluetooth/provider/BluetoothGpsProviderService.java
@@ -69,6 +69,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();