Skip to content

Commit

Permalink
[A] Added the about screen to menu
Browse files Browse the repository at this point in the history
  • Loading branch information
sanchin committed Jan 3, 2018
1 parent 55b0828 commit 63f42a3
Show file tree
Hide file tree
Showing 8 changed files with 244 additions and 25 deletions.
16 changes: 12 additions & 4 deletions android/src/main/java/pmstation/AboutFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,18 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
// attributionPref.setOnPreferenceClickListener(preference -> {
// showAttribution();
// return true;
// });

view.findViewById(R.id.author_rg)
.setOnClickListener(view1 -> Utils.launchWebIntent(getContext(), "https://github.com/sanchin"));
view.findViewById(R.id.author_rj)
.setOnClickListener(view1 -> Utils.launchWebIntent(getContext(), "https://github.com/rjaros87"));
view.findViewById(R.id.author_ps)
.setOnClickListener(view1 -> Utils.launchWebIntent(getContext(), "https://github.com/pskowronek"));
view.findViewById(R.id.project_desc).setOnClickListener(
view1 -> Utils.launchWebIntent(getContext(), "https://github.com/rjaros87/pm-home-station"));
view.findViewById(R.id.lgpl3).setOnClickListener(
view1 -> Utils.launchWebIntent(getContext(), "https://www.gnu.org/licenses/gpl-3.0.en.html"));
view.findViewById(R.id.third_party).setOnClickListener(view1 -> showAttribution());
}

private void showAttribution() {
Expand Down
14 changes: 14 additions & 0 deletions android/src/main/java/pmstation/LicensesDialogFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@
package pmstation;

import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.DialogFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

public class LicensesDialogFragment extends DialogFragment {
@Override
Expand All @@ -22,4 +25,15 @@ public void onCreate(Bundle savedInstanceState) {
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_licenses, container, false);
}

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
view.findViewById(R.id.plug_icons_notice_url_1)
.setOnClickListener(view1 -> Utils.launchWebIntent(getContext(), ((TextView) view1).getText().toString()));
view.findViewById(R.id.plug_icons_notice_url_2)
.setOnClickListener(view1 -> Utils.launchWebIntent(getContext(), ((TextView) view1).getText().toString()));
view.findViewById(R.id.background_notice_url)
.setOnClickListener(view1 -> Utils.launchWebIntent(getContext(), ((TextView) view1).getText().toString()));
}
}
18 changes: 18 additions & 0 deletions android/src/main/java/pmstation/Utils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* pm-home-station
* 2017 (C) Copyright - https://github.com/rjaros87/pm-home-station
* License: GPL 3.0
*/

package pmstation;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;

public class Utils {
public static void launchWebIntent(Context context, String url) {
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
context.startActivity(browserIntent);
}
}
63 changes: 63 additions & 0 deletions android/src/main/res/layout-land/fragment_about.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/background_light">

<android.support.v7.widget.CardView
android:id="@+id/logo_bg"
android:layout_width="100dp"
android:layout_height="100dp"
app:cardBackgroundColor="@color/ic_launcher_background"
app:cardCornerRadius="10dp"
app:cardElevation="8dp"
android:layout_marginEnd="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="16dp">
<ImageView
android:id="@+id/logo"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_gravity="center"
android:src="@drawable/ic_launcher_foreground"/>
</android.support.v7.widget.CardView>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="@+id/linearLayout"
app:layout_constraintTop_toBottomOf="@+id/logo_bg"
app:layout_constraintEnd_toEndOf="@+id/logo_bg"
app:layout_constraintStart_toStartOf="@+id/logo_bg"
android:layout_marginTop="8dp"
android:gravity="center_horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/app_name"
android:textAppearance="@android:style/TextAppearance.Material.Body2"
android:textSize="18sp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/version_name"
/>
</LinearLayout>
<ScrollView
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="8dp"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginBottom="8dp"
app:layout_constraintStart_toStartOf="parent"
android:layout_marginStart="8dp"
app:layout_constraintEnd_toStartOf="@+id/logo_bg"
>
<include layout="@layout/about_body"/>

</ScrollView>
</android.support.constraint.ConstraintLayout>
77 changes: 77 additions & 0 deletions android/src/main/res/layout/about_body.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:orientation="vertical"
tools:showIn="@layout/fragment_about">
<TextView
android:text="@string/authors"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
android:layout_marginBottom="8dp"
android:textStyle="bold"
android:textSize="18sp"/>
<TextView
android:id="@+id/author_rg"
android:text="@string/rg"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<TextView
android:id="@+id/author_rj"
android:text="@string/rj"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<TextView
android:id="@+id/author_ps"
android:text="@string/ps"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<TextView
android:text="@string/copyright"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"/>
<TextView
android:text="@string/project"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
android:layout_marginBottom="8dp"
android:layout_marginTop="16dp"
android:textStyle="bold"
android:textSize="18sp"/>
<TextView
android:id="@+id/project_desc"
android:text="@string/project_desc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<TextView
android:text="@string/license"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
android:layout_marginBottom="8dp"
android:layout_marginTop="16dp"
android:textStyle="bold"
android:textSize="18sp"/>
<TextView
android:id="@+id/lgpl3"
android:text="@string/lgpl3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<TextView
android:id="@+id/third_party"
android:text="@string/third_party"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"/>
</LinearLayout>
21 changes: 15 additions & 6 deletions android/src/main/res/layout/fragment_about.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/background_light">

<android.support.v7.widget.CardView
android:id="@+id/logo"
android:id="@+id/logo_bg"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_marginStart="16dp"
Expand All @@ -18,7 +17,7 @@
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:id="@+id/imageView"
android:id="@+id/logo"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_gravity="center"
Expand All @@ -29,9 +28,9 @@
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="@id/logo"
app:layout_constraintLeft_toRightOf="@id/logo"
app:layout_constraintTop_toTopOf="@id/logo"
app:layout_constraintBottom_toBottomOf="@id/logo_bg"
app:layout_constraintLeft_toRightOf="@id/logo_bg"
app:layout_constraintTop_toTopOf="@id/logo_bg"
>
<TextView
android:layout_width="wrap_content"
Expand All @@ -45,5 +44,15 @@
android:text="@string/version_name"
/>
</LinearLayout>
<ScrollView
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginTop="16dp"
app:layout_constraintTop_toBottomOf="@+id/logo_bg">
<include layout="@layout/about_body"/>
</ScrollView>

</android.support.constraint.ConstraintLayout>
41 changes: 26 additions & 15 deletions android/src/main/res/layout/fragment_licenses.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,38 +12,49 @@
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Android logo"
android:layout_marginBottom="8dp"
android:text="@string/android_logo"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
android:text="The Android robot is reproduced or modified from work created and shared by Google and used according to terms described in the Creative Commons 3.0 Attribution License."/>

android:text="@string/android_logo_notice"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="Plug icons"
android:layout_marginBottom="8dp"
android:layout_marginTop="16dp"
android:text="@string/plug_icons"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="Plug by Creative Stall from the Noun Project\nhttps://thenounproject.com/term/plug/380956/\nhttps://thenounproject.com/term/plug/380958/"/>
android:text="@string/plug_icons_notice"/>
<TextView
android:id="@+id/plug_icons_notice_url_1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/plug_icons_notice_url_1"/>
<TextView
android:id="@+id/plug_icons_notice_url_2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/plug_icons_notice_url_2"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="Background"
android:layout_marginBottom="8dp"
android:layout_marginTop="16dp"
android:text="@string/background"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="AIR POLLUTION by 2HAPPY from stockvault\nhttp://www.stockvault.net/photo/124893/air-pollution"/>
android:text="@string/background_notice"/>
<TextView
android:id="@+id/background_notice_url"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/background_notice_url"/>
</LinearLayout>


</ScrollView>
19 changes: 19 additions & 0 deletions android/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,23 @@
<string name="pref_sampling_interval_default">1000</string>
<string name="about">About</string>
<string name="version_name">1.0.1</string>
<string name="authors">Authors</string>
<string name="rg"><font color='#008295'><u>Radosław Gabiga</u></font></string>
<string name="rj"><font color='#008295'><u>Radosław Jaros</u></font></string>
<string name="ps"><font color='#008295'><u>Piotr Skowronek</u></font></string>
<string name="copyright">Copyright © 2017 – 2018</string>
<string name="project">Project</string>
<string name="project_desc">The project details and the required equipement can be found&#160;<font color='#008295'><u>here</u></font></string>
<string name="license">License</string>
<string name="lgpl3">This application is licensed under the terms of&#160;<font color='#008295'><u>License GPL-3.0</u></font></string>
<string name="third_party"><font color='#008295'><u>Third party notices</u></font></string>
<string name="android_logo">Android logo</string>
<string name="android_logo_notice">The Android robot is reproduced or modified from work created and shared by Google and used according to terms described in the Creative Commons 3.0 Attribution License.</string>
<string name="plug_icons">Plug icons</string>
<string name="plug_icons_notice">Plug by Creative Stall from the Noun Project</string>
<string name="plug_icons_notice_url_1"><font color='#008295'><u>https://thenounproject.com/term/plug/380956/</u></font></string>
<string name="plug_icons_notice_url_2"><font color='#008295'><u>https://thenounproject.com/term/plug/380958/</u></font></string>
<string name="background">Background</string>
<string name="background_notice">AIR POLLUTION by 2HAPPY from stockvault</string>
<string name="background_notice_url"><font color='#008295'><u>http://www.stockvault.net/photo/124893/air-pollution</u></font></string>
</resources>

0 comments on commit 63f42a3

Please sign in to comment.