Skip to content

Commit 978c022

Browse files
authored
Merge pull request #18 from niccokunzmann/add-about
Add about entry in the settings
2 parents 4a63bd8 + d965b21 commit 978c022

File tree

5 files changed

+113
-0
lines changed

5 files changed

+113
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package io.spaceapi.community.myhackerspace;
2+
3+
import android.content.Context;
4+
import android.util.AttributeSet;
5+
import android.view.LayoutInflater;
6+
import android.widget.LinearLayout;
7+
import android.widget.TextView;
8+
9+
import androidx.annotation.Nullable;
10+
11+
public class AboutLayout extends LinearLayout {
12+
13+
public AboutLayout(Context context) {
14+
super(context);
15+
}
16+
17+
public AboutLayout(Context context, @Nullable AttributeSet attrs) {
18+
super(context, attrs);
19+
}
20+
21+
public AboutLayout(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
22+
super(context, attrs, defStyleAttr);
23+
}
24+
25+
public AboutLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
26+
super(context, attrs, defStyleAttr, defStyleRes);
27+
}
28+
29+
public void init() {
30+
TextView version = findViewById(R.id.about_version_text);
31+
version.setText(BuildConfig.VERSION_NAME + " (" + Integer.toString(BuildConfig.VERSION_CODE) + ")");
32+
}
33+
34+
public static AboutLayout create(Context context) {
35+
LayoutInflater layoutInflater = LayoutInflater.from(context);
36+
AboutLayout about = (AboutLayout) layoutInflater.inflate(R.layout.about, null, false);
37+
about.init();
38+
return about;
39+
}
40+
}

app/src/main/java/io/spaceapi/community/myhackerspace/Prefs.java

+6
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,16 @@
55
*/
66
package io.spaceapi.community.myhackerspace;
77

8+
import static android.view.ViewGroup.LayoutParams.*;
9+
810
import android.content.SharedPreferences;
911
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
1012
import android.os.Bundle;
1113
import android.preference.PreferenceActivity;
1214
import android.preference.PreferenceScreen;
15+
import android.view.LayoutInflater;
16+
import android.view.ViewGroup;
17+
import android.widget.LinearLayout;
1318

1419
public class Prefs extends PreferenceActivity implements
1520
OnSharedPreferenceChangeListener {
@@ -31,6 +36,7 @@ public class Prefs extends PreferenceActivity implements
3136
public void onCreate(Bundle savedInstanceState) {
3237
super.onCreate(savedInstanceState);
3338
addPreferencesFromResource(R.xml.preferences);
39+
this.getListView().addFooterView(AboutLayout.create(this)); // tried addContentView
3440
PreferenceScreen ps = getPreferenceScreen();
3541
ps.getSharedPreferences()
3642
.registerOnSharedPreferenceChangeListener(this);

app/src/main/res/layout/about.xml

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<io.spaceapi.community.myhackerspace.AboutLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:layout_width="match_parent"
4+
android:layout_height="match_parent"
5+
android:paddingStart="8dp"
6+
android:paddingTop="8dp"
7+
android:orientation="vertical">
8+
9+
<LinearLayout
10+
android:layout_width="match_parent"
11+
android:layout_height="wrap_content"
12+
android:orientation="horizontal">
13+
14+
<TextView
15+
android:id="@+id/about_version_title"
16+
android:layout_width="wrap_content"
17+
android:layout_height="wrap_content"
18+
android:text="@string/about_version_title" />
19+
20+
<TextView
21+
android:id="@+id/about_version_text"
22+
android:layout_width="0dp"
23+
android:layout_height="wrap_content"
24+
android:layout_weight="1"
25+
android:layout_marginStart="2sp"
26+
android:text="{version}" />
27+
</LinearLayout>
28+
29+
<LinearLayout
30+
android:layout_width="match_parent"
31+
android:layout_height="wrap_content"
32+
android:orientation="horizontal">
33+
34+
<TextView
35+
android:id="@+id/about_license_title"
36+
android:layout_width="wrap_content"
37+
android:layout_height="wrap_content"
38+
android:text="@string/about_license_title" />
39+
40+
<TextView
41+
android:id="@+id/about_license_text"
42+
android:layout_width="0dp"
43+
android:layout_height="wrap_content"
44+
android:layout_weight="1"
45+
android:layout_marginStart="2sp"
46+
android:text="@string/about_license_text" />
47+
</LinearLayout>
48+
49+
<TextView
50+
android:id="@+id/about_repository"
51+
android:layout_width="match_parent"
52+
android:layout_height="wrap_content"
53+
android:autoLink="web"
54+
android:text="@string/about_repository_url" />
55+
56+
</io.spaceapi.community.myhackerspace.AboutLayout>

app/src/main/res/values/strings.xml

+8
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ Licensed under GNU's GPL 3, see README
4444
<string name="prefs_transparent_summary">Widget\'s background will be transparent instead of gray</string>
4545
<string name="prefs_text_title">Show status text</string>
4646
<string name="prefs_text_summary">Add a text with the status under the widget</string>
47+
<string name="prefs_about_title">About This App</string>
4748

4849
<string name="api_status">Status</string>
4950
<string name="api_lastchange">Last change: </string>
@@ -88,4 +89,11 @@ Licensed under GNU's GPL 3, see README
8889
<string name="api_sensor_radiation">Radiation</string>
8990
<string name="api_sensor_total_member_count">Member Count</string>
9091
<string name="api_sensor_account_balance">Account Balance</string>
92+
93+
94+
<string name="about_version_title">App Version:</string>
95+
<string name="about_license_title">License:</string>
96+
<string name="about_license_text">GNU GENERAL PUBLIC LICENSE Version 3</string>
97+
<string name="about_visit_repository">Visit Repository</string>
98+
<string name="about_repository_url" translatable="false">https://github.com/spaceapi-community/my-hackerspace</string>
9199
</resources>

app/src/main/res/xml/preferences.xml

+3
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,7 @@
4343
android:defaultValue="30"
4444
android:inputType="number" />
4545

46+
<PreferenceCategory android:title="@string/prefs_about_title">
47+
</PreferenceCategory>
48+
4649
</PreferenceScreen>

0 commit comments

Comments
 (0)