Skip to content

Commit 0bb7a56

Browse files
committed
Added about dialog showing version number
1 parent c84d542 commit 0bb7a56

File tree

5 files changed

+43
-3
lines changed

5 files changed

+43
-3
lines changed

sensorhub-android-app/AndroidManifest.xml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
33
package="org.sensorhub.android"
4-
android:hardwareAccelerated="true"
5-
android:versionCode="1"
6-
android:versionName="1.0" >
4+
android:hardwareAccelerated="true">
75

86
<uses-feature android:name="android.hardware.location" />
97
<uses-feature android:name="android.hardware.sensor.compass" />

sensorhub-android-app/build.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ android {
1212
compileSdkVersion rootProject.compileSdkVersion
1313
buildToolsVersion rootProject.buildToolsVersion
1414

15+
defaultConfig {
16+
versionCode 1
17+
versionName rootProject.version
18+
}
19+
1520
packagingOptions {
1621
exclude 'META-INF/LICENSE'
1722
exclude '**/empty'

sensorhub-android-app/res/menu/main.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,10 @@
2020
android:showAsAction="never"
2121
android:title="@string/action_stop"/>
2222

23+
<item
24+
android:id="@+id/action_about"
25+
android:orderInCategory="103"
26+
android:showAsAction="never"
27+
android:title="@string/action_about"/>
28+
2329
</menu>

sensorhub-android-app/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<string name="action_settings">Settings</string>
66
<string name="action_start">Start SensorHub</string>
77
<string name="action_stop">Stop SensorHub</string>
8+
<string name="action_about">About</string>
89

910
<string-array name="video_codec_list">
1011
<item>JPEG</item>

sensorhub-android-app/src/org/sensorhub/android/MainActivity.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
package org.sensorhub.android;
1616

17+
import android.content.pm.PackageInfo;
18+
import android.content.pm.PackageManager;
1719
import android.util.Log;
1820
import java.net.MalformedURLException;
1921
import java.net.URL;
@@ -287,6 +289,10 @@ else if (id == R.id.action_stop)
287289
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
288290
return true;
289291
}
292+
else if (id == R.id.action_about)
293+
{
294+
showAboutPopup();
295+
}
290296

291297
return super.onOptionsItemSelected(item);
292298
}
@@ -330,6 +336,30 @@ public void onClick(DialogInterface dialog, int whichButton) {
330336
}
331337

332338

339+
protected void showAboutPopup()
340+
{
341+
String version = "?";
342+
343+
try
344+
{
345+
PackageInfo pInfo = this.getPackageManager().getPackageInfo(getPackageName(), 0);
346+
version = pInfo.versionName;
347+
}
348+
catch (PackageManager.NameNotFoundException e)
349+
{
350+
}
351+
352+
String message = "A software platform for building smart sensor networks and the Internet of Things\n\n";
353+
message += "Version: " + version;
354+
355+
AlertDialog.Builder alert = new AlertDialog.Builder(this);
356+
alert.setTitle("OpenSensorHub");
357+
alert.setMessage(message);
358+
alert.setIcon(R.drawable.ic_launcher);
359+
alert.show();
360+
}
361+
362+
333363
@Override
334364
public void handleEvent(Event<?> e)
335365
{

0 commit comments

Comments
 (0)