Skip to content

Commit

Permalink
make about dialog get version from package info
Browse files Browse the repository at this point in the history
  • Loading branch information
fowles committed Dec 27, 2009
1 parent 564b893 commit ed2343d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
3 changes: 2 additions & 1 deletion res/layout/about.xml
Expand Up @@ -36,9 +36,10 @@
style="@style/Detail"
/>
<TextView
android:id='@+about/version_field'
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text='@string/app_ver'
android:text='UNKNOWN'
style="@style/Detail"
/>
</LinearLayout>
Expand Down
1 change: 0 additions & 1 deletion res/values/strings.xml
Expand Up @@ -2,7 +2,6 @@
<resources>
<string name="app_name">Dice Roller</string>
<string name="version">Version</string>
<string name="app_ver">1.4.0</string>
<string name="app_copyright">Copyright &#169; 2009 Matt Fowles</string>
<string name="app_copyright_rights">All rights reserved</string>
<string name="source_url">http://wiki.github.com/fowles/dice-roller</string>
Expand Down
11 changes: 11 additions & 0 deletions src/com/roller/MainWindow.java
Expand Up @@ -4,6 +4,8 @@
import android.app.Dialog;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Bundle;
import android.os.PowerManager;
import android.view.ContextMenu;
Expand All @@ -15,6 +17,7 @@
import android.widget.CompoundButton;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;

import com.roller.generic.GenericSystem;
import com.roller.whitewolf.darkness.WorldOfDarknessSystem;
Expand Down Expand Up @@ -195,6 +198,14 @@ public void onCheckedChanged(final RadioGroup group, final int checkedId) {
d = new Dialog(this);
d.setTitle("About");
d.setContentView(id);

final TextView version = (TextView) d.findViewById(R.about.version_field);
final PackageManager p = getPackageManager();
try {
version.setText(p.getPackageInfo(getClass().getPackage().getName(), 0).versionName);
} catch (final NameNotFoundException e) {
version.setText("UNKNOWN");
}
break;
default:
d = null;
Expand Down

0 comments on commit ed2343d

Please sign in to comment.