From 1c0e673854580cdbbdd2bf85c6c917ec1bebee73 Mon Sep 17 00:00:00 2001
From: Aline Bonnet <aline.bonnet@savoirfairelinux.com>
Date: Wed, 26 Apr 2017 14:39:26 -0400
Subject: [PATCH] about: add missing elements

This commit adds two missing elements on the about screen:
- a short description of Ring
- the authors and artists list

Change-Id: Id141bfa77378449b08d165a7b32688fe34f45f19
Reviewed-by: Hadrien De Sousa <hadrien.desousa@savoirfairelinux.com>
Tuleap: #1574
---
 .../about/AboutBottomSheetDialogFragment.java | 61 +++++++++++++++++++
 .../java/cx/ring/about/AboutFragment.java     | 13 +++-
 .../app/src/main/res/layout/dialog_about.xml  | 57 +++++++++++++++++
 .../app/src/main/res/layout/frag_about.xml    | 28 +++++++--
 .../app/src/main/res/values/strings.xml       |  9 +++
 5 files changed, 163 insertions(+), 5 deletions(-)
 create mode 100644 ring-android/app/src/main/java/cx/ring/about/AboutBottomSheetDialogFragment.java
 create mode 100644 ring-android/app/src/main/res/layout/dialog_about.xml

diff --git a/ring-android/app/src/main/java/cx/ring/about/AboutBottomSheetDialogFragment.java b/ring-android/app/src/main/java/cx/ring/about/AboutBottomSheetDialogFragment.java
new file mode 100644
index 000000000..d1287916a
--- /dev/null
+++ b/ring-android/app/src/main/java/cx/ring/about/AboutBottomSheetDialogFragment.java
@@ -0,0 +1,61 @@
+/*
+ *  Copyright (C) 2017 Savoir-faire Linux Inc.
+ *
+ *  Author: Aline Bonnet <aline.bonnet@savoirfairelinux.com>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package cx.ring.about;
+
+import android.app.Dialog;
+import android.support.annotation.NonNull;
+import android.support.design.widget.BottomSheetBehavior;
+import android.support.design.widget.BottomSheetDialogFragment;
+import android.support.design.widget.CoordinatorLayout;
+import android.view.View;
+
+import cx.ring.R;
+
+public class AboutBottomSheetDialogFragment extends BottomSheetDialogFragment {
+
+    private BottomSheetBehavior.BottomSheetCallback mCallback = new BottomSheetBehavior.BottomSheetCallback() {
+        @Override
+        public void onStateChanged(@NonNull View bottomSheet, int newState) {
+            if (newState == BottomSheetBehavior.STATE_HIDDEN) {
+                dismiss();
+            }
+        }
+
+        @Override
+        public void onSlide(@NonNull View bottomSheet, float slideOffset) {
+
+        }
+    };
+
+    @Override
+    public void setupDialog(Dialog dialog, int style) {
+        super.setupDialog(dialog, style);
+        View contentView = View.inflate(getContext(), R.layout.dialog_about, null);
+        dialog.setContentView(contentView);
+
+        CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) ((View) contentView.getParent()).getLayoutParams();
+        CoordinatorLayout.Behavior behavior = params.getBehavior();
+
+        if (behavior != null && behavior instanceof BottomSheetBehavior) {
+            ((BottomSheetBehavior) behavior).setBottomSheetCallback(mCallback);
+        }
+    }
+}
diff --git a/ring-android/app/src/main/java/cx/ring/about/AboutFragment.java b/ring-android/app/src/main/java/cx/ring/about/AboutFragment.java
index 7fa80c192..ea1c538be 100644
--- a/ring-android/app/src/main/java/cx/ring/about/AboutFragment.java
+++ b/ring-android/app/src/main/java/cx/ring/about/AboutFragment.java
@@ -24,14 +24,16 @@ import android.content.Intent;
 import android.content.pm.PackageManager;
 import android.net.Uri;
 import android.os.Bundle;
+import android.support.design.widget.BottomSheetDialogFragment;
 import android.support.design.widget.Snackbar;
+import android.support.v7.app.AppCompatActivity;
 import android.text.Html;
 import android.view.LayoutInflater;
 import android.view.Menu;
 import android.view.MenuInflater;
-import android.view.MenuItem;
 import android.view.View;
 import android.view.ViewGroup;
+import android.widget.Button;
 import android.widget.ImageView;
 import android.widget.TextView;
 
@@ -75,6 +77,9 @@ public class AboutFragment extends Fragment implements AboutView {
     @BindView(R.id.logo)
     ImageView mImageViewSFLLogo;
 
+    @BindView(R.id.credits)
+    Button mCredits;
+
     private Unbinder mUnbinder;
 
     @Override
@@ -155,6 +160,12 @@ public class AboutFragment extends Fragment implements AboutView {
         launchSystemIntent(emailIntent, getString(R.string.email_chooser_title), getString(R.string.no_email_app_installed));
     }
 
+    @OnClick(R.id.credits)
+    public void creditsClicked() {
+        BottomSheetDialogFragment dialog = new AboutBottomSheetDialogFragment();
+        dialog.show(((AppCompatActivity) getActivity()).getSupportFragmentManager(), dialog.getTag());
+    }
+
     private void launchSystemIntent(Intent intentToLaunch,
                                     String intentChooserTitle,
                                     String intentMissingTitle) {
diff --git a/ring-android/app/src/main/res/layout/dialog_about.xml b/ring-android/app/src/main/res/layout/dialog_about.xml
new file mode 100644
index 000000000..7ac4ac49a
--- /dev/null
+++ b/ring-android/app/src/main/res/layout/dialog_about.xml
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="utf-8"?>
+<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent">
+
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:orientation="vertical"
+        android:padding="@dimen/padding_medium">
+
+        <TextView
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginLeft="5dp"
+            android:layout_marginRight="5dp"
+            android:layout_marginTop="5dp"
+            android:text="@string/developed_by"
+            android:textColor="@color/color_primary_dark"
+            android:textSize="18sp" />
+
+        <TextView
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginBottom="5dp"
+            android:layout_marginLeft="5dp"
+            android:layout_marginRight="5dp"
+            android:text="@string/credits_developer"
+            android:textAppearance="?android:attr/textAppearanceSmall" />
+
+        <View
+            android:layout_width="match_parent"
+            android:layout_height="1dp"
+            android:background="@color/darker_gray" />
+
+        <TextView
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginLeft="5dp"
+            android:layout_marginRight="5dp"
+            android:layout_marginTop="5dp"
+            android:text="@string/designed_by"
+            android:textColor="@color/color_primary_dark"
+            android:textSize="18sp" />
+
+        <TextView
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginBottom="5dp"
+            android:layout_marginLeft="5dp"
+            android:layout_marginRight="5dp"
+            android:text="@string/credits_designer"
+            android:textAppearance="?android:attr/textAppearanceSmall" />
+
+    </LinearLayout>
+
+</ScrollView>
\ No newline at end of file
diff --git a/ring-android/app/src/main/res/layout/frag_about.xml b/ring-android/app/src/main/res/layout/frag_about.xml
index b750046e1..5f8582af2 100644
--- a/ring-android/app/src/main/res/layout/frag_about.xml
+++ b/ring-android/app/src/main/res/layout/frag_about.xml
@@ -21,7 +21,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
     android:layout_width="match_parent"
     android:layout_height="match_parent">
 
-    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    <LinearLayout
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:orientation="vertical"
@@ -37,6 +37,14 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
             android:maxWidth="250dp"
             android:scaleType="fitCenter" />
 
+        <TextView
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_marginBottom="16dp"
+            android:layout_marginTop="16dp"
+            android:text="@string/description"
+            android:textAlignment="center" />
+
         <LinearLayout
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
@@ -68,9 +76,9 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
             android:id="@+id/contribute_container"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
+            android:layout_margin="5dp"
             android:background="?attr/selectableItemBackground"
             android:clickable="true"
-            android:layout_margin="5dp"
             android:gravity="center_vertical"
             android:orientation="vertical">
 
@@ -125,9 +133,9 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
             android:id="@+id/license_container"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
+            android:layout_margin="5dp"
             android:background="?attr/selectableItemBackground"
             android:clickable="true"
-            android:layout_margin="5dp"
             android:gravity="center_vertical"
             android:orientation="vertical">
 
@@ -173,7 +181,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
                 android:id="@+id/email_report"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
-                android:clickable="false"/>
+                android:clickable="false" />
 
         </LinearLayout>
 
@@ -209,5 +217,17 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
         </LinearLayout>
 
+        <android.support.v7.widget.AppCompatButton
+            android:id="@+id/credits"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_gravity="center_horizontal"
+            android:paddingLeft="24dp"
+            android:paddingRight="24dp"
+            android:text="@string/credits"
+            android:theme="@style/ButtonColoredInverse" />
+
     </LinearLayout>
 </ScrollView>
+
+
diff --git a/ring-android/app/src/main/res/values/strings.xml b/ring-android/app/src/main/res/values/strings.xml
index a5cf2ff22..872299d1d 100644
--- a/ring-android/app/src/main/res/values/strings.xml
+++ b/ring-android/app/src/main/res/values/strings.xml
@@ -20,6 +20,7 @@ along with this program; if not, write to the Free Software
 -->
 <resources>
 
+    <!-- About -->
     <string name="app_name" translatable="false">Ring</string>
     <string name="app_author" translatable="false">Savoir-faire Linux Inc.</string>
     <string name="app_release" translatable="false">Gaston Miron Beta 2 - %1$s</string>
@@ -41,6 +42,14 @@ along with this program; if not, write to the Free Software
     <string name="website_chooser_title">View website using…</string>
     <string name="license">This software is provided \"as is\", without warranty of any kind. For details, see
 &lt;u>GNU General Public License version 3 or later&lt;/u></string>
+    <string name="description">Ring is free software for universal communication which respects the freedoms and privacy of its users.</string>
+    <string name="credits">Credits</string>
+
+    <!-- About dialog -->
+    <string name="developed_by">Developed by</string>
+    <string name="designed_by">Designed by</string>
+    <string name="credits_developer" translatable="false">Adrien Béraud\nAlexandr Sergheev\nAlexandre Lision\nAlexandre Viau\nAline Bonnet\nAndreas Traczyk\nAnthony Léonard\nCyrille Béraud\nEdric Milaret\nÉloi Bail\nEmmanuel Lepage-Vallée\nFrédéric Guimont\nGuillaume Roguez\nJulien Grossholtz\nLoïc Siret\nNicolas Jäger\nNicolas Reynaud\nOlivier Gregoire\nOlivier Soldano\nPatrick Keroulas\nPhilippe Gorley\nRomain Bertozzi\nSeva Ivanov\nSimon Désaulniers\nStepan Salenikovich\nSimon Zeni\nThibault Wittemberg\nBased on the SFLPhone project</string>
+    <string name="credits_designer" translatable="false">Marianne Forget</string>
 
     <!-- RingActivity -->
     <string name="title_activity_sflphone_home">Ring</string>
-- 
GitLab