Skip to content

Commit 994a835

Browse files
committed
AboutUs Dialog Fragment
1 parent d41a7c7 commit 994a835

File tree

7 files changed

+147
-1
lines changed

7 files changed

+147
-1
lines changed

app/src/main/java/org/app/txema/ghiblifilms/MainActivity.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import android.os.Bundle;
88
import android.support.design.widget.AppBarLayout;
99
import android.support.design.widget.CollapsingToolbarLayout;
10+
import android.support.v4.app.DialogFragment;
1011
import android.support.v7.app.AppCompatActivity;
1112
import android.support.v7.widget.Toolbar;
1213
import android.util.Log;
@@ -21,6 +22,7 @@
2122
import com.google.android.gms.ads.AdView;
2223

2324
import org.app.txema.ghiblifilms.di.App;
25+
import org.app.txema.ghiblifilms.view.fragment.AboutUsFragment;
2426

2527
public class MainActivity extends AppCompatActivity {
2628
private static final String TAG = MainActivity.class.getSimpleName();
@@ -116,7 +118,8 @@ public boolean onOptionsItemSelected(MenuItem item) {
116118

117119
//noinspection SimplifiableIfStatement
118120
if (id == R.id.action_about_us) {
119-
Toast.makeText(getApplicationContext(), "About us action is selected!", Toast.LENGTH_SHORT).show();
121+
DialogFragment newFragment = new AboutUsFragment();
122+
newFragment.show(getSupportFragmentManager(), "aboutUs");
120123
return true;
121124
}
122125

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package org.app.txema.ghiblifilms.view.fragment;
2+
3+
import android.app.Dialog;
4+
import android.content.DialogInterface;
5+
import android.os.Bundle;
6+
import android.support.v4.app.DialogFragment;
7+
import android.support.v7.app.AlertDialog;
8+
import android.view.LayoutInflater;
9+
10+
import org.app.txema.ghiblifilms.R;
11+
12+
/**
13+
* Created by Txema on 20/09/2017.
14+
*/
15+
16+
public class AboutUsFragment extends DialogFragment {
17+
@Override
18+
public Dialog onCreateDialog(Bundle savedInstanceState) {
19+
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
20+
// Get the layout inflater
21+
LayoutInflater inflater = getActivity().getLayoutInflater();
22+
23+
// Inflate and set the layout for the dialog
24+
// Pass null as the parent view because its going in the dialog layout
25+
builder.setView(inflater.inflate(R.layout.fragment_about_us, null))
26+
// Add action buttons
27+
.setNegativeButton(R.string.close, new DialogInterface.OnClickListener() {
28+
public void onClick(DialogInterface dialog, int id) {
29+
AboutUsFragment.this.getDialog().cancel();
30+
}
31+
});
32+
return builder.create();
33+
}
34+
}
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<RelativeLayout
3+
android:layout_width="match_parent"
4+
android:layout_height="wrap_content"
5+
android:padding="@dimen/default_padding"
6+
xmlns:android="http://schemas.android.com/apk/res/android">
7+
8+
<!-- logo -->
9+
<ImageView
10+
android:id="@+id/logo"
11+
android:layout_width="@dimen/about_icon_size"
12+
android:layout_height="@dimen/about_icon_size"
13+
android:adjustViewBounds="false"
14+
android:contentDescription="@string/app_name"
15+
android:layout_centerHorizontal="true"
16+
android:padding="@dimen/default_padding"
17+
android:scaleType="fitXY"
18+
android:gravity="center"
19+
android:src="@mipmap/ic_launcher" />
20+
21+
<TextView
22+
android:id="@+id/title"
23+
android:layout_width="match_parent"
24+
android:layout_height="wrap_content"
25+
android:padding="@dimen/large_padding"
26+
android:text="@string/app_name"
27+
android:textColor="@color/title_color"
28+
android:textSize="@dimen/large_title_textSize"
29+
android:layout_below="@+id/logo"
30+
android:gravity="center"/>
31+
32+
<!-- description -->
33+
<TextView
34+
android:id="@+id/description"
35+
android:layout_width="match_parent"
36+
android:layout_height="wrap_content"
37+
android:padding="@dimen/large_padding"
38+
android:text="@string/app_description"
39+
android:textColor="@color/title_color"
40+
android:textSize="@dimen/title_textSize"
41+
android:layout_below="@+id/title"
42+
android:gravity="center"/>
43+
44+
<!-- email -->
45+
<TextView
46+
android:id="@+id/email"
47+
android:layout_width="match_parent"
48+
android:layout_height="wrap_content"
49+
android:paddingBottom="@dimen/large_padding"
50+
android:text="@string/my_email"
51+
android:textColor="@color/title_color"
52+
android:textSize="@dimen/title_textSize"
53+
android:layout_below="@+id/description"
54+
android:gravity="center"/>
55+
56+
<!-- github link-->
57+
<TextView
58+
android:id="@+id/github"
59+
android:layout_width="match_parent"
60+
android:layout_height="wrap_content"
61+
android:paddingBottom="@dimen/large_padding"
62+
android:text="@string/my_github"
63+
android:textColor="@color/title_color"
64+
android:textSize="@dimen/title_textSize"
65+
android:layout_below="@+id/email"
66+
android:gravity="center">
67+
68+
</TextView>
69+
70+
<!-- api link -->
71+
<TextView
72+
android:id="@+id/api"
73+
android:layout_width="match_parent"
74+
android:layout_height="wrap_content"
75+
android:paddingBottom="@dimen/large_padding"
76+
android:text="@string/api_link"
77+
android:textColor="@color/title_color"
78+
android:textSize="@dimen/title_textSize"
79+
android:layout_below="@+id/github"
80+
android:gravity="center"/>
81+
82+
</RelativeLayout>

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,10 @@
1010
<string name="action_about_us">Acerca de</string>
1111
<string name="action_rate_app">Puntua esta app</string>
1212
<string name="reload">Recargar</string>
13+
<string name="app_description">GhibliFilms es un proyecto Open Source creado por TxemaSV.</string>
14+
<string name="version">Version 1.3</string>
15+
<string name="my_email">txemasv@gmail.com</string>
16+
<string name="my_github">github.com/txemasv</string>
17+
<string name="api_link">ghibliapi.herokuapp.com</string>
18+
<string name="close">Ok</string>
1319
</resources>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@
66
<color name="viewBg">#f1f5f8</color>
77
<color name="film_title_color">#4c4c4c</color>
88
<color name="textShadow">#7F000000</color>
9+
<color name="title_color">#4c4c4c</color>
910
</resources>

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,23 @@
88
<dimen name="film_poster_height">210dp</dimen>
99

1010
<dimen name="default_padding">16dp</dimen>
11+
<dimen name="large_padding">32dp</dimen>
1112
<dimen name="default_textSize">16sp</dimen>
1213
<dimen name="title_textSize">16sp</dimen>
1314
<dimen name="description_textSize">14sp</dimen>
1415

1516
<dimen name="detail_backdrop_height">250dp</dimen>
17+
18+
<dimen name="thumbnail_width">180dp</dimen>
19+
<dimen name="thumbnail_height">180dp</dimen>
20+
21+
<dimen name="poster_width">300dp</dimen>
22+
<dimen name="poster_height">300dp</dimen>
23+
24+
<dimen name="large_title_textSize">20sp</dimen>
25+
26+
27+
<dimen name="about_icon_size">120dp</dimen>
28+
29+
1630
</resources>

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,10 @@
1010
<string name="action_about_us">About us</string>
1111
<string name="action_rate_app">Rate app</string>
1212
<string name="reload" >Reload</string>
13+
<string name="app_description">GhibliFilms is an Open Source Project created by TxemaSV.</string>
14+
<string name="version">Version 1.3</string>
15+
<string name="my_email">txemasv@gmail.com</string>
16+
<string name="my_github">github.com/txemasv</string>
17+
<string name="api_link">ghibliapi.herokuapp.com</string>
18+
<string name="close">Ok</string>
1319
</resources>

0 commit comments

Comments
 (0)