Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add about #18

Merged
merged 2 commits into from
Apr 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package io.spaceapi.community.myhackerspace;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.Nullable;

public class AboutLayout extends LinearLayout {

public AboutLayout(Context context) {
super(context);
}

public AboutLayout(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
}

public AboutLayout(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}

public AboutLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
}

public void init() {
TextView version = findViewById(R.id.about_version_text);
version.setText(BuildConfig.VERSION_NAME + " (" + Integer.toString(BuildConfig.VERSION_CODE) + ")");
}

public static AboutLayout create(Context context) {
LayoutInflater layoutInflater = LayoutInflater.from(context);
AboutLayout about = (AboutLayout) layoutInflater.inflate(R.layout.about, null, false);
about.init();
return about;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,16 @@
*/
package io.spaceapi.community.myhackerspace;

import static android.view.ViewGroup.LayoutParams.*;

import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.os.Bundle;
import android.preference.PreferenceActivity;
import android.preference.PreferenceScreen;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import android.widget.LinearLayout;

public class Prefs extends PreferenceActivity implements
OnSharedPreferenceChangeListener {
Expand All @@ -31,6 +36,7 @@ public class Prefs extends PreferenceActivity implements
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);
this.getListView().addFooterView(AboutLayout.create(this)); // tried addContentView
PreferenceScreen ps = getPreferenceScreen();
ps.getSharedPreferences()
.registerOnSharedPreferenceChangeListener(this);
Expand Down
56 changes: 56 additions & 0 deletions app/src/main/res/layout/about.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="utf-8"?>
<io.spaceapi.community.myhackerspace.AboutLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingStart="8dp"
android:paddingTop="8dp"
android:orientation="vertical">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<TextView
android:id="@+id/about_version_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/about_version_title" />

<TextView
android:id="@+id/about_version_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginStart="2sp"
android:text="{version}" />
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<TextView
android:id="@+id/about_license_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/about_license_title" />

<TextView
android:id="@+id/about_license_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginStart="2sp"
android:text="@string/about_license_text" />
</LinearLayout>

<TextView
android:id="@+id/about_repository"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:autoLink="web"
android:text="@string/about_repository_url" />

</io.spaceapi.community.myhackerspace.AboutLayout>
8 changes: 8 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Licensed under GNU's GPL 3, see README
<string name="prefs_transparent_summary">Widget\'s background will be transparent instead of gray</string>
<string name="prefs_text_title">Show status text</string>
<string name="prefs_text_summary">Add a text with the status under the widget</string>
<string name="prefs_about_title">About This App</string>

<string name="api_status">Status</string>
<string name="api_lastchange">Last change: </string>
Expand Down Expand Up @@ -88,4 +89,11 @@ Licensed under GNU's GPL 3, see README
<string name="api_sensor_radiation">Radiation</string>
<string name="api_sensor_total_member_count">Member Count</string>
<string name="api_sensor_account_balance">Account Balance</string>


<string name="about_version_title">App Version:</string>
<string name="about_license_title">License:</string>
<string name="about_license_text">GNU GENERAL PUBLIC LICENSE Version 3</string>
<string name="about_visit_repository">Visit Repository</string>
<string name="about_repository_url" translatable="false">https://github.com/spaceapi-community/my-hackerspace</string>
</resources>
3 changes: 3 additions & 0 deletions app/src/main/res/xml/preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,7 @@
android:defaultValue="30"
android:inputType="number" />

<PreferenceCategory android:title="@string/prefs_about_title">
</PreferenceCategory>

</PreferenceScreen>