Skip to content
This repository was archived by the owner on Feb 3, 2025. It is now read-only.

Commit 4e5bb29

Browse files
author
syl
committed
Add version number in about view
1 parent 5ccef8f commit 4e5bb29

File tree

4 files changed

+60
-3
lines changed

4 files changed

+60
-3
lines changed

Net-Auto-Off/src/main/AndroidManifest.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
xmlns:tools="http://schemas.android.com/tools"
44
package="fr.ewilly.NetAutoOff"
55
android:installLocation="internalOnly"
6-
android:versionCode="8"
7-
android:versionName="3.4">
6+
android:versionCode="9"
7+
android:versionName="3.5">
88

99
<uses-sdk
1010
android:minSdkVersion="19"

Net-Auto-Off/src/main/java/fr/ewilly/NetAutoOff/Activity_Main.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,16 @@
77
import android.app.FragmentManager;
88
import android.app.FragmentTransaction;
99
import android.content.Intent;
10+
import android.content.pm.PackageInfo;
11+
import android.content.pm.PackageManager;
1012
import android.os.Bundle;
1113
import android.preference.PreferenceManager;
1214
import android.provider.Settings;
1315
import android.support.v13.app.FragmentPagerAdapter;
1416
import android.support.v4.view.ViewPager;
1517
import android.view.Menu;
1618
import android.view.MenuItem;
19+
import android.widget.TextView;
1720
import android.widget.Toast;
1821

1922
import java.util.Locale;
@@ -110,10 +113,20 @@ public boolean onOptionsItemSelected(MenuItem item) {
110113
return true;
111114
}
112115
if (id == R.id.about) {
116+
// Show the dialog box
113117
Dialog box = new Dialog(this);
114118
box.setContentView(R.layout.about);
115119
box.setTitle(R.string.about_title);
116120
box.show();
121+
// Change the app version
122+
TextView t = (TextView) box.findViewById(R.id.version);
123+
PackageInfo pkg;
124+
try {
125+
pkg = getPackageManager().getPackageInfo(getPackageName(), 0);
126+
t.setText(String.format(getString(R.string.about_text_version), pkg.versionName));
127+
} catch (PackageManager.NameNotFoundException e) {
128+
e.printStackTrace();
129+
}
117130
}
118131
return super.onOptionsItemSelected(item);
119132
}

Net-Auto-Off/src/main/res/layout/about.xml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,44 @@
2727
android:text="@string/about_text_intro" />
2828
</LinearLayout>
2929

30+
<TextView
31+
android:layout_width="wrap_content"
32+
android:layout_height="wrap_content"
33+
android:text="@string/about_text_version_title"
34+
android:textStyle="bold" />
35+
36+
<TextView
37+
android:layout_width="fill_parent"
38+
android:layout_height="wrap_content"
39+
android:layout_marginBottom="16dp"
40+
android:layout_marginLeft="16dp"
41+
android:layout_marginRight="16dp"
42+
android:layout_marginTop="8dp"
43+
android:orientation="horizontal"
44+
android:id="@+id/version"/>
45+
46+
<TextView
47+
android:layout_width="wrap_content"
48+
android:layout_height="wrap_content"
49+
android:text="@string/about_text_thanks_title"
50+
android:textStyle="bold" />
51+
52+
<TextView
53+
android:layout_width="fill_parent"
54+
android:layout_height="wrap_content"
55+
android:layout_marginBottom="16dp"
56+
android:layout_marginLeft="16dp"
57+
android:layout_marginRight="16dp"
58+
android:layout_marginTop="8dp"
59+
android:orientation="horizontal"
60+
android:text="@string/about_text_thanks" />
61+
62+
<TextView
63+
android:layout_width="wrap_content"
64+
android:layout_height="wrap_content"
65+
android:text="@string/about_text_legal_title"
66+
android:textStyle="bold" />
67+
3068
<TextView
3169
android:layout_width="fill_parent"
3270
android:layout_height="wrap_content"
@@ -36,4 +74,5 @@
3674
android:layout_marginTop="8dp"
3775
android:orientation="horizontal"
3876
android:text="@string/about_text_legal" />
77+
3978
</LinearLayout>

Net-Auto-Off/src/main/res/values/strings.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@
1313
<string name="about">About</string>
1414
<string name="about_title">About</string>
1515
<string name="about_text_intro">Hello. Thank you for using this App. My name is Sylvain Arnould (ewilly) and I have written this App for fun and in my spare time. Its also Open Source, so you can grab the Source Code and modify it as you want.\n<b>https://github.com/ewilly/Net-Auto-Off</b></string>
16-
<string name="about_text_legal">Thanks to Bence Béky (https://github.com/bencebeky/MMSKeeper).\nThanks to Thomas Hoffmann (https://github.com/j4velin/WiFi-Auto-Off).\n\nThis App is licensed under the Apache license. A copy of this can be downloaded here:\n<b>http://www.apache.org/licenses/LICENSE-2.0</b></string>
16+
<string name="about_text_version_title">App Version</string>
17+
<string name="about_text_version">v%1$s</string>
18+
<string name="about_text_thanks_title">Acknowledgement</string>
19+
<string name="about_text_thanks">Thanks to Bence Béky (https://github.com/bencebeky/MMSKeeper).\nThanks to Thomas Hoffmann (https://github.com/j4velin/WiFi-Auto-Off).</string>
20+
<string name="about_text_legal_title">Legal information</string>
21+
<string name="about_text_legal">This App is licensed under the Apache license. A copy of this can be downloaded here:\n<b>http://www.apache.org/licenses/LICENSE-2.0</b></string>
1722

1823
<string name="auto_off">Enable or disable auto off for all receiver &#8230;</string>
1924
<string name="auto_off_off">DISABLE</string>

0 commit comments

Comments
 (0)