Skip to content

Commit

Permalink
*Added about menu with GPLv2 license
Browse files Browse the repository at this point in the history
  • Loading branch information
kconger committed Jan 26, 2015
1 parent 0488d59 commit ea13b4d
Show file tree
Hide file tree
Showing 6 changed files with 408 additions and 1 deletion.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/import-summary.txt
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
2 changes: 1 addition & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Current features:
* Sensor discovery
* Screen rotation
* Runs in the background
* Optional data logging in csv format to /sdcard/mtpms
* Optional data logging in csv format to /sdcard/mTPMS
* English language, please contact me if you would like to help with a translation

How to use:
Expand Down
31 changes: 31 additions & 0 deletions app/src/main/java/org/thecongers/mtpms/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ of the License, or (at your option) any later version.
import android.widget.TextView;
import android.widget.Toast;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Method;
import java.util.Set;
import java.util.UUID;
Expand Down Expand Up @@ -512,6 +514,14 @@ public boolean onOptionsItemSelected(MenuItem item)
settings.edit().remove("prefFrontID").apply();
settings.edit().remove("prefRearID").apply();
return true;
case R.id.action_about:
// About was selected
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(getResources().getString(R.string.alert_about_title));
builder.setMessage(readRawTextFile(this, R.raw.about));
builder.setPositiveButton(getResources().getString(R.string.alert_about_button), null);
builder.show();
return true;
case R.id.action_exit:
// Exit menu item was selected
if (logger != null){
Expand Down Expand Up @@ -731,6 +741,27 @@ public void run() {
}
}

// Read raw text file
private static String readRawTextFile(Context ctx, int resId)
{
InputStream inputStream = ctx.getResources().openRawResource(resId);

InputStreamReader inputreader = new InputStreamReader(inputStream);
BufferedReader buffreader = new BufferedReader(inputreader);
String line;
StringBuilder text = new StringBuilder();

try {
while (( line = buffreader.readLine()) != null) {
text.append(line);
text.append('\n');
}
} catch (IOException e) {
return null;
}
return text.toString();
}

//Send Notification
private void Notify(String notificationMessage)
{
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/menu/main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
android:orderInCategory="100"
app:showAsAction="never"
android:title="@string/action_sensorReset"/>
<item
android:id="@+id/action_about"
android:orderInCategory="100"
app:showAsAction="never"
android:title="@string/action_about"/>
<item
android:id="@+id/action_exit"
android:orderInCategory="100"
Expand Down
Loading

0 comments on commit ea13b4d

Please sign in to comment.