Skip to content

Commit 57aaf88

Browse files
committed
Added about activity
1 parent d00a681 commit 57aaf88

File tree

6 files changed

+226
-24
lines changed

6 files changed

+226
-24
lines changed

app/src/main/AndroidManifest.xml

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<!--
1+
<?xml version="1.0" encoding="utf-8"?><!--
32
~ Copyright 2016 the Cook-E development team
43
~
54
~ This file is part of Cook-E.
@@ -16,11 +15,10 @@
1615
~
1716
~ You should have received a copy of the GNU General Public License
1817
~ along with Cook-E. If not, see <http://www.gnu.org/licenses/>.
19-
-->
20-
21-
<manifest package="org.cook_e.cook_e"
22-
xmlns:android="http://schemas.android.com/apk/res/android"
23-
xmlns:tools="http://schemas.android.com/tools">
18+
-->
19+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
20+
xmlns:tools="http://schemas.android.com/tools"
21+
package="org.cook_e.cook_e">
2422

2523
<!-- Reads external storage to get recipe images -->
2624
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
@@ -31,35 +29,32 @@
3129
android:label="@string/app_name"
3230
android:supportsRtl="true"
3331
android:theme="@style/AppTheme">
34-
35-
36-
<activity android:name=".HomeActivity"
32+
<activity
33+
android:name=".HomeActivity"
3734
android:windowSoftInputMode="stateHidden">
3835
<intent-filter>
39-
<action android:name="android.intent.action.MAIN"/>
40-
<category android:name="android.intent.category.LAUNCHER"/>
36+
<action android:name="android.intent.action.MAIN" />
37+
38+
<category android:name="android.intent.category.LAUNCHER" />
4139
</intent-filter>
4240
</activity>
43-
<activity android:name=".MealViewActivity">
44-
</activity>
41+
<activity android:name=".MealViewActivity"></activity>
4542
<activity
4643
android:name=".MealRecipeAddActivity"
4744
android:parentActivityName=".MealViewActivity"
4845
tools:ignore="UnusedAttribute">
4946
<meta-data
5047
android:name="android.support.PARENT_ACTIVITY"
51-
android:value=".MealViewActivity"/>
52-
</activity>
53-
<activity android:name=".CookActivity">
48+
android:value=".MealViewActivity" />
5449
</activity>
55-
<activity android:name=".CreateRecipe"/>
56-
50+
<activity android:name=".CookActivity"></activity>
51+
<activity android:name=".CreateRecipe" />
5752
<activity
5853
android:name=".EditRecipeActivity"
5954
android:label="recipe_name"
6055
android:parentActivityName=".HomeActivity"
61-
android:windowSoftInputMode="adjustPan">
62-
</activity>
56+
android:windowSoftInputMode="adjustPan"></activity>
57+
<activity android:name=".AboutActivity"></activity>
6358
</application>
6459

6560
</manifest>
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
/*
2+
* Copyright 2016 the Cook-E development team
3+
*
4+
* This file is part of Cook-E.
5+
*
6+
* Cook-E is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* Cook-E is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with Cook-E. If not, see <http://www.gnu.org/licenses/>.
18+
*/
19+
20+
package org.cook_e.cook_e;
21+
22+
import android.content.Intent;
23+
import android.content.pm.PackageInfo;
24+
import android.content.pm.PackageManager;
25+
import android.net.Uri;
26+
import android.support.v7.app.ActionBar;
27+
import android.support.v7.app.AppCompatActivity;
28+
import android.os.Bundle;
29+
import android.support.v7.widget.Toolbar;
30+
import android.view.View;
31+
import android.widget.Button;
32+
33+
public class AboutActivity extends AppCompatActivity {
34+
35+
@Override
36+
protected void onCreate(Bundle savedInstanceState) {
37+
super.onCreate(savedInstanceState);
38+
setContentView(R.layout.activity_about);
39+
40+
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
41+
setSupportActionBar(toolbar);
42+
setUpActionBar();
43+
44+
45+
final Button websiteButton = (Button) findViewById(R.id.website_button);
46+
websiteButton.setOnClickListener(new View.OnClickListener() {
47+
@Override
48+
public void onClick(View v) {
49+
final Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(
50+
"https://cook-e-team.github.io/Cook-E/user/"));
51+
startActivity(browserIntent);
52+
}
53+
});
54+
}
55+
56+
private void setUpActionBar() {
57+
final ActionBar bar = getSupportActionBar();
58+
if (bar != null) {
59+
bar.setDisplayHomeAsUpEnabled(true);
60+
try {
61+
final PackageInfo info = getPackageManager().getPackageInfo(getPackageName(), 0);
62+
bar.setTitle(String.format(
63+
getResources().getText(R.string.about_heading).toString(), info.versionName,
64+
info.versionCode));
65+
} catch (PackageManager.NameNotFoundException e) {
66+
bar.setTitle(R.string.app_name);
67+
}
68+
}
69+
}
70+
71+
/*
72+
* This is a workaround for inconsistent behavior.
73+
*
74+
* Pressing the system back button or calling finish() returns a result to the parent activity,
75+
* as expected. However, the default action when the up button is pressed does not send a result
76+
* to the parent. This override ensures that a result is sent when the action bar up button is
77+
* pressed.
78+
*/
79+
@Override
80+
public boolean onSupportNavigateUp() {
81+
finish();
82+
return true;
83+
}
84+
}

app/src/main/java/org/cook_e/cook_e/HomeActivity.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
package org.cook_e.cook_e;
2121

22+
import android.content.Intent;
2223
import android.os.Bundle;
2324
import android.support.design.widget.TabLayout;
2425
import android.support.design.widget.TabLayout.Tab;
@@ -27,6 +28,8 @@
2728
import android.support.v7.app.ActionBar;
2829
import android.support.v7.app.AppCompatActivity;
2930
import android.support.v7.widget.Toolbar;
31+
import android.view.Menu;
32+
import android.view.MenuItem;
3033

3134
import org.cook_e.cook_e.ui.HomePageAdapter;
3235

@@ -98,4 +101,24 @@ private void setUpActionBar() {
98101
bar.setTitle(R.string.app_name);
99102
}
100103

104+
105+
@Override
106+
public boolean onCreateOptionsMenu(Menu menu) {
107+
super.onCreateOptionsMenu(menu);
108+
109+
getMenuInflater().inflate(R.menu.topright_menu, menu);
110+
111+
final MenuItem aboutItem = menu.findItem(R.id.menu_about);
112+
aboutItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
113+
@Override
114+
public boolean onMenuItemClick(MenuItem item) {
115+
// Open the about activity
116+
final Intent intent = new Intent(HomeActivity.this, AboutActivity.class);
117+
startActivity(intent);
118+
return true;
119+
}
120+
});
121+
122+
return true;
123+
}
101124
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
~ Copyright 2016 the Cook-E development team
4+
~
5+
~ This file is part of Cook-E.
6+
~
7+
~ Cook-E is free software: you can redistribute it and/or modify
8+
~ it under the terms of the GNU General Public License as published by
9+
~ the Free Software Foundation, either version 3 of the License, or
10+
~ (at your option) any later version.
11+
~
12+
~ Cook-E is distributed in the hope that it will be useful,
13+
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
~ GNU General Public License for more details.
16+
~
17+
~ You should have received a copy of the GNU General Public License
18+
~ along with Cook-E. If not, see <http://www.gnu.org/licenses/>.
19+
-->
20+
21+
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
22+
xmlns:tools="http://schemas.android.com/tools"
23+
android:layout_width="match_parent"
24+
android:layout_height="match_parent"
25+
xmlns:app="http://schemas.android.com/apk/res-auto"
26+
tools:context="org.cook_e.cook_e.AboutActivity">
27+
28+
<android.support.v7.widget.Toolbar
29+
android:id="@+id/toolbar"
30+
android:layout_width="match_parent"
31+
android:layout_height="?attr/actionBarSize"
32+
android:background="?attr/colorPrimary"
33+
android:elevation="4dp"
34+
android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
35+
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
36+
tools:ignore="UnusedAttribute"/>
37+
38+
<ScrollView
39+
android:layout_width="wrap_content"
40+
android:layout_height="wrap_content"
41+
android:id="@+id/scrollView"
42+
android:layout_above="@+id/website_button"
43+
android:layout_below="@+id/toolbar"
44+
android:layout_margin="12dp">
45+
46+
<TextView
47+
android:layout_width="wrap_content"
48+
android:layout_height="wrap_content"
49+
android:text="@string/about_details"
50+
android:id="@+id/about_detail_view"
51+
android:autoLink="web"
52+
android:linksClickable="true"
53+
android:longClickable="true" />
54+
</ScrollView>
55+
56+
<Button
57+
android:layout_width="wrap_content"
58+
android:layout_height="wrap_content"
59+
android:text="@string/website"
60+
android:id="@+id/website_button"
61+
android:layout_alignParentBottom="true"
62+
android:layout_alignLeft="@+id/scrollView"
63+
android:layout_alignStart="@+id/scrollView"
64+
android:layout_alignRight="@+id/scrollView"
65+
android:layout_alignEnd="@+id/scrollView" />
66+
67+
</RelativeLayout>

app/src/main/res/menu/topright_menu.xml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@
2222
xmlns:app="http://schemas.android.com/apk/res-auto">
2323
<item
2424
app:showAsAction="never"
25-
android:title="Setting" />
25+
android:title="@string/settings" />
2626
<item
2727
app:showAsAction="never"
28-
android:title="Tutorial" />
28+
android:title="@string/tutorial" />
2929
<item
3030
app:showAsAction="never"
31-
android:title="About" />
31+
android:title="@string/about"
32+
android:id="@+id/menu_about"/>
3233
</menu>

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

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,36 @@
3939
<string name="create_recipe">Create Recipe</string>
4040
<string name="select_image">Select Image</string>
4141
<string name="label_continue">Continue</string>
42+
<string name="website">Website</string>
43+
<string name="about">About</string>
44+
<string name="about_heading">Cook-E %1$s (%2$d)</string>
45+
<string name="about_details"><![CDATA[
46+
Cook-E is free software: you can redistribute it and/or modify
47+
it under the terms of the GNU General Public License as published by
48+
the Free Software Foundation, either version 3 of the License, or
49+
(at your option) any later version.\n\n
50+
51+
Cook-E is distributed in the hope that it will be useful,
52+
but WITHOUT ANY WARRANTY; without even the implied warranty of
53+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
54+
GNU General Public License for more details.\n\n
55+
56+
You should have received a copy of the GNU General Public License
57+
along with Cook-E. If not, see <http://www.gnu.org/licenses/>.\n\n
58+
59+
Cook-E uses the following Free Software libraries:\n\n
60+
61+
Joda-Time:\n\n
62+
63+
This product includes software developed by
64+
Joda.org (http://www.joda.org/).\n\n
65+
66+
Joda-Time is distributed in accordance with the Apache license, version 2.0.\n\n
67+
68+
Evo Inflector:\n\n
69+
70+
Evo Inflector (https://github.com/atteo/evo-inflector/) is distributed in accordance with the Apache license, version 2.0.
71+
]]></string>
72+
<string name="settings">Settings</string>
73+
<string name="tutorial">Tutorial</string>
4274
</resources>

0 commit comments

Comments
 (0)