-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
174 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package net.justdave.mcstatus; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.InputStreamReader; | ||
|
||
import android.app.Dialog; | ||
import android.content.Context; | ||
import android.content.pm.PackageInfo; | ||
import android.content.pm.PackageManager.NameNotFoundException; | ||
import android.os.Bundle; | ||
import android.text.Html; | ||
import android.text.util.Linkify; | ||
import android.util.Log; | ||
import android.graphics.Color; | ||
import android.view.View; | ||
import android.widget.Button; | ||
import android.widget.TextView; | ||
|
||
public class AboutDialog extends Dialog { | ||
private static Context mContext = null; | ||
private static final String TAG = AboutDialog.class.getSimpleName(); | ||
|
||
public AboutDialog(Context context) { | ||
super(context); | ||
mContext = context; | ||
} | ||
|
||
@Override | ||
public void onCreate(Bundle savedInstanceState) { | ||
setContentView(R.layout.about); | ||
|
||
PackageInfo p; | ||
String version = "???"; | ||
int vCode = 0; | ||
TextView tv = (TextView) findViewById(R.id.info_text); | ||
tv.setText(Html.fromHtml(readRawTextFile(R.raw.about_info))); | ||
tv.setLinkTextColor(Color.BLUE); | ||
Linkify.addLinks(tv, Linkify.ALL); | ||
TextView ver = (TextView) findViewById(R.id.version_string); | ||
Context aContext = mContext.getApplicationContext(); | ||
try { | ||
p = aContext.getPackageManager().getPackageInfo(aContext.getPackageName(), 0); | ||
version = p.versionName; | ||
vCode = p.versionCode; | ||
} catch (NameNotFoundException e) { | ||
Log.i(TAG, "Failed to retrieve package name"); | ||
e.printStackTrace(); | ||
} | ||
ver.setText(aContext.getResources().getString(R.string.about_version, version, vCode)); | ||
Button button = (Button) findViewById(R.id.about_ok_button); | ||
button.setOnClickListener(new View.OnClickListener() { | ||
public void onClick(View v) { | ||
dismiss(); | ||
} | ||
}); | ||
|
||
} | ||
|
||
public static String readRawTextFile(int id) { | ||
|
||
InputStream inputStream = mContext.getResources().openRawResource(id); | ||
|
||
InputStreamReader in = new InputStreamReader(inputStream); | ||
BufferedReader buf = new BufferedReader(in); | ||
|
||
String line; | ||
|
||
StringBuilder text = new StringBuilder(); | ||
try { | ||
while ((line = buf.readLine()) != null) | ||
text.append(line); | ||
} catch (IOException e) { | ||
return null; | ||
} | ||
|
||
return text.toString(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="fill_parent" | ||
android:layout_height="fill_parent" | ||
android:fillViewport="true" | ||
android:scrollbars="vertical" > | ||
|
||
<TableLayout | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="5dp" | ||
android:gravity="center" | ||
android:stretchColumns="*" > | ||
|
||
<TableRow> | ||
|
||
<ImageView | ||
android:layout_width="64dp" | ||
android:layout_height="64dp" | ||
android:layout_gravity="left|center" | ||
android:contentDescription="@string/icon" | ||
android:src="@drawable/meterblocks" /> | ||
|
||
<LinearLayout | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="left|center" | ||
android:orientation="vertical" > | ||
|
||
<TextView | ||
android:layout_width="fill_parent" | ||
android:layout_height="wrap_content" | ||
android:gravity="center" | ||
android:text="@string/app_name" | ||
android:textSize="18sp" /> | ||
|
||
<TextView | ||
android:id="@+id/version_string" | ||
android:layout_width="fill_parent" | ||
android:layout_height="wrap_content" | ||
android:gravity="center" | ||
android:textSize="18sp" /> | ||
</LinearLayout> | ||
</TableRow> | ||
|
||
<TableRow> | ||
|
||
<TextView | ||
android:id="@+id/info_text" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_margin="8dip" | ||
android:layout_span="2" | ||
android:textAlignment="center" | ||
android:textColor="#444444" | ||
android:textSize="12sp" | ||
android:textStyle="italic" /> | ||
</TableRow> | ||
|
||
<TableRow> | ||
|
||
<Button | ||
android:id="@+id/about_ok_button" | ||
android:layout_width="fill_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_margin="8dip" | ||
android:layout_span="2" | ||
android:gravity="center" | ||
android:text="@string/ok" /> | ||
</TableRow> | ||
</TableLayout> | ||
|
||
</ScrollView> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
To request new features or file bug reports, please visit<br> | ||
<b>https://github.com/justdave/MCStatus</b><br> | ||
<br> | ||
Copyright 2014-2015 David D. Miller<br> | ||
<br> | ||
Licensed under the MIT License<br> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters