Commit 53be020d authored by jordan.dalby's avatar jordan.dalby

Added book museum page and back buttons

parent a51d3fde
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<codeStyleSettings language="XML">
<option name="FORCE_REARRANGE_MODE" value="1" />
<indentOptions>
<option name="CONTINUATION_INDENT_SIZE" value="4" />
</indentOptions>
<arrangement>
<rules>
<section>
<rule>
<match>
<AND>
<NAME>xmlns:android</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>xmlns:.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:id</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:name</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>name</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>style</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
<order>ANDROID_ATTRIBUTE_ORDER</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>.*</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
</rules>
</arrangement>
</codeStyleSettings>
</code_scheme>
</component>
\ No newline at end of file
<component name="ProjectCodeStyleConfiguration">
<state>
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
</state>
</component>
\ No newline at end of file
...@@ -9,7 +9,10 @@ ...@@ -9,7 +9,10 @@
android:roundIcon="@mipmap/ic_launcher_round" android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/Theme.MuseumApp"> android:theme="@style/Theme.MuseumApp">
<activity android:name=".MuseumPage"></activity> <activity android:name=".BookSouvenir"></activity>
<activity android:name=".BookCafe" />
<activity android:name=".BookMuseum" />
<activity android:name=".MuseumPage" />
<activity android:name=".MuseumList" /> <activity android:name=".MuseumList" />
<activity android:name=".LoginPage" /> <activity android:name=".LoginPage" />
<activity android:name=".MainActivity"> <activity android:name=".MainActivity">
......
package com.yorksj.museumapp;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
public class BookCafe extends AppCompatActivity
{
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_book_cafe);
}
}
\ No newline at end of file
package com.yorksj.museumapp;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.MenuItem;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CalendarView;
import android.widget.Spinner;
import com.yorksj.museumapp.book.BookPacket;
import com.yorksj.museumapp.book.Time;
import com.yorksj.museumapp.home.HomeButton;
import com.yorksj.museumapp.museums.MuseumPacket;
import java.lang.reflect.Array;
import java.sql.Date;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Calendar;
public class BookMuseum extends AppCompatActivity
{
private MuseumPacket activeMuseum;
private HomeButton homeButton;
private CalendarView calendarView;
private Spinner spinnerTime;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_book_museum);
getActiveMuseum();
homeButton = new HomeButton(this, BookMuseum.this, MuseumPage.class);
homeButton.getIntent().putExtra("packet", activeMuseum);
setUpCalendar();
setUpDropdown();
}
private void setUpCalendar()
{
calendarView = findViewById(R.id.dateSelect);
LocalDate date = LocalDateTime.now().toLocalDate();
Calendar calendar = Calendar.getInstance();
calendar.set(date.getYear(), date.getMonth().getValue(), date.getDayOfMonth());
calendarView.setMinDate(calendar.getTimeInMillis());
// uncomment to allow booking only 3 weeks in advance
//calendar.add(Calendar.DAY_OF_MONTH, 21);
//calendarView.setMaxDate(calendar.getTimeInMillis());
}
private void setUpDropdown()
{
spinnerTime = findViewById(R.id.spinnerTime);
Time[] vals = Time.values();
String[] times = new String[vals.length];
for (int i = 0; i < vals.length; i++)
{
times[i] = vals[i].name;
}
ArrayAdapter<String> adapter1 = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item, times);
spinnerTime.setAdapter(adapter1);
}
private void initialiseOnClick()
{
Button button = findViewById(R.id.bookingContinue);
button.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
BookMuseum.this.onClick();
}
});
}
private void onClick()
{
long date = calendarView.getDate();
Time time = Time.NINE_TO_ELEVEN.getTimeFromString(spinnerTime.getSelectedItem().toString());
BookPacket packet = new BookPacket(activeMuseum, date, time);
Intent intent = new Intent(BookMuseum.this, BookCafe.class);
intent.putExtra("packet", packet);
startActivity(intent);
}
private void getActiveMuseum()
{
Intent intent = getIntent();
Bundle extras = intent.getExtras();
activeMuseum = (MuseumPacket) extras.get("packet");
}
@Override
public boolean onOptionsItemSelected(MenuItem item)
{
if (!homeButton.onClick(item))
{
super.onOptionsItemSelected(item);
return false;
}
return true;
}
}
\ No newline at end of file
package com.yorksj.museumapp;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
public class BookSouvenir extends AppCompatActivity
{
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_book_souvenir);
}
}
\ No newline at end of file
...@@ -7,10 +7,12 @@ import android.os.Bundle; ...@@ -7,10 +7,12 @@ import android.os.Bundle;
import com.yorksj.museumapp.museums.MuseumPacket; import com.yorksj.museumapp.museums.MuseumPacket;
import com.yorksj.museumapp.recycler.RecyclerManager; import com.yorksj.museumapp.recycler.RecyclerManager;
public class MuseumList extends AppCompatActivity { public class MuseumList extends AppCompatActivity
{
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_museum_list); setContentView(R.layout.activity_museum_list);
...@@ -21,16 +23,16 @@ public class MuseumList extends AppCompatActivity { ...@@ -21,16 +23,16 @@ public class MuseumList extends AppCompatActivity {
{ {
RecyclerManager recycler = new RecyclerManager(this); RecyclerManager recycler = new RecyclerManager(this);
recycler.add(new MuseumPacket("Louvre", R.drawable.louvre, getString(R.string.louvre_description), getString(R.string.louvre_enhanced_description))); recycler.add(new MuseumPacket("Louvre", 10, R.drawable.louvre, getString(R.string.louvre_description), getString(R.string.louvre_enhanced_description)));
recycler.add(new MuseumPacket("National Museum of China", R.drawable.museumofchina, getString(R.string.china_description), getString(R.string.china_enhanced_description))); recycler.add(new MuseumPacket("National Museum of China", 10, R.drawable.museumofchina, getString(R.string.china_description), getString(R.string.china_enhanced_description)));
recycler.add(new MuseumPacket("Vatican Museums", R.drawable.vaticanmuseums, getString(R.string.vatican_description), getString(R.string.vatican_enhanced_description))); recycler.add(new MuseumPacket("Vatican Museums", 10, R.drawable.vaticanmuseums, getString(R.string.vatican_description), getString(R.string.vatican_enhanced_description)));
recycler.add(new MuseumPacket("Metropolitan Museum of Art", R.drawable.museumofart, getString(R.string.museum_oa_description), getString(R.string.museum_oa_enhanced_description))); recycler.add(new MuseumPacket("Metropolitan Museum of Art", 10, R.drawable.museumofart, getString(R.string.museum_oa_description), getString(R.string.museum_oa_enhanced_description)));
recycler.add(new MuseumPacket("British Museum", R.drawable.britishmuseum, getString(R.string.british_museum_description), getString(R.string.british_museum_enhanced_description))); recycler.add(new MuseumPacket("British Museum", 10, R.drawable.britishmuseum, getString(R.string.british_museum_description), getString(R.string.british_museum_enhanced_description)));
recycler.add(new MuseumPacket("Tate Modern", R.drawable.tatemodern, getString(R.string.tate_description), getString(R.string.tate_enhanced_description))); recycler.add(new MuseumPacket("Tate Modern", 5, R.drawable.tatemodern, getString(R.string.tate_description), getString(R.string.tate_enhanced_description)));
recycler.add(new MuseumPacket("National Gallery", R.drawable.nationalgallery, getString(R.string.gallery_description), getString(R.string.gallery_enhanced_description))); recycler.add(new MuseumPacket("National Gallery", 5, R.drawable.nationalgallery, getString(R.string.gallery_description), getString(R.string.gallery_enhanced_description)));
recycler.add(new MuseumPacket("Natural History Museum", R.drawable.naturalhistory, getString(R.string.natural_history_description), getString(R.string.natural_history_enhanced_description))); recycler.add(new MuseumPacket("Natural History Museum", 5, R.drawable.naturalhistory, getString(R.string.natural_history_description), getString(R.string.natural_history_enhanced_description)));
recycler.add(new MuseumPacket("American Museum of Natural History", R.drawable.americannaturalhistory, getString(R.string.american_natural_history_description), getString(R.string.american_natural_history_enhanced_description))); recycler.add(new MuseumPacket("American Museum of Natural History", 5, R.drawable.americannaturalhistory, getString(R.string.american_natural_history_description), getString(R.string.american_natural_history_enhanced_description)));
recycler.add(new MuseumPacket("State Hermitage Museum", R.drawable.hermitage, getString(R.string.hermitage_description), getString(R.string.hermitage_enhanced_description))); recycler.add(new MuseumPacket("State Hermitage Museum", 5, R.drawable.hermitage, getString(R.string.hermitage_description), getString(R.string.hermitage_enhanced_description)));
recycler.generateRecyclerView(); recycler.generateRecyclerView();
} }
} }
\ No newline at end of file
...@@ -4,30 +4,80 @@ import androidx.appcompat.app.AppCompatActivity; ...@@ -4,30 +4,80 @@ import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import com.yorksj.museumapp.R; import com.yorksj.museumapp.home.HomeButton;
import com.yorksj.museumapp.museums.MuseumPacket; import com.yorksj.museumapp.museums.MuseumPacket;
public class MuseumPage extends AppCompatActivity { public class MuseumPage extends AppCompatActivity
{
private MuseumPacket activeMuseum;
private HomeButton homeButton;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_museum_page); setContentView(R.layout.activity_museum_page);
homeButton = new HomeButton(this, MuseumPage.this, MuseumList.class);
Intent intent = getIntent(); Intent intent = getIntent();
Bundle extras = intent.getExtras(); Bundle extras = intent.getExtras();
MuseumPacket packet = (MuseumPacket) extras.get("packet"); MuseumPacket packet = (MuseumPacket) extras.get("packet");
activeMuseum = packet;
updatePage(packet);
initialiseBookButton();
}
private void updatePage(MuseumPacket packet)
{
TextView name = findViewById(R.id.museumName); TextView name = findViewById(R.id.museumName);
TextView description = findViewById(R.id.museumDescription); TextView description = findViewById(R.id.museumDescription);
ImageView image = findViewById(R.id.museumImage); ImageView image = findViewById(R.id.museumImage);
TextView price = findViewById(R.id.museumPrice);
String priceString = "£" + packet.entranceFee + ".00";
name.setText(packet.name); name.setText(packet.name);
description.setText(packet.enhancedDescription); description.setText(packet.enhancedDescription);
image.setImageResource(packet.image); image.setImageResource(packet.image);
price.setText(priceString);
}
private void initialiseBookButton()
{
Button button = findViewById(R.id.bookMuseum);
button.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
Intent intent = new Intent(MuseumPage.this, BookMuseum.class);
intent.putExtra("packet", activeMuseum);
startActivity(intent);
}
});
}
@Override
public boolean onOptionsItemSelected(MenuItem item)
{
if (!homeButton.onClick(item))
{
super.onOptionsItemSelected(item);
return false;
}
return true;
} }
} }
\ No newline at end of file
package com.yorksj.museumapp.book;
import com.yorksj.museumapp.museums.MuseumPacket;
import java.io.Serializable;
import java.text.SimpleDateFormat;
public class BookPacket implements Serializable
{
public MuseumPacket museumPacket;
public long date;
public Time time;
public BookPacket(MuseumPacket _museumPacket, long _date, Time _time)
{
museumPacket = _museumPacket;
date = _date;
time = _time;
}
public String getDateFormatted()
{
SimpleDateFormat format = new SimpleDateFormat("dd-MM-yy");
return format.format(date);
}
}
package com.yorksj.museumapp.book;
public enum Time
{
NINE_TO_ELEVEN("9am-11am"),
ELEVEN_TO_ONE("11am-1pm"),
ONE_TO_THREE("1pm-3pm"),
THREE_TO_FIVE("3pm-5pm");
public String name;
Time(String _name)
{
name = _name;
}
public Time getTimeFromString(String s)
{
for (Time time : Time.values())
{
if (time.name.equals(s))
{
return time;
}
}
return Time.NINE_TO_ELEVEN;
}
}
package com.yorksj.museumapp.home;
import android.content.Context;
import android.content.Intent;
import android.view.MenuItem;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
public class HomeButton
{
private Context context;
private Class c;
private Intent intent;
public HomeButton(AppCompatActivity _activity, Context _context, Class _c)
{
context = _context;
c = _c;
ActionBar bar = _activity.getSupportActionBar();
bar.setHomeButtonEnabled(true);
bar.setDisplayHomeAsUpEnabled(true);
intent = new Intent(context, c);
}
public Intent getIntent()
{
return intent;
}
public boolean onClick(MenuItem item)
{
switch (item.getItemId())
{
case android.R.id.home:
context.startActivity(intent);
return true;
default:
return false;
}
}
}
...@@ -8,13 +8,15 @@ public class MuseumPacket implements Serializable ...@@ -8,13 +8,15 @@ public class MuseumPacket implements Serializable
{ {
public String name; public String name;
public int entranceFee;
public int image; // id public int image; // id
public String description; public String description;
public String enhancedDescription; public String enhancedDescription;
public MuseumPacket(String _name, int _image, String _description, String _enhancedDescription) public MuseumPacket(String _name, int _entranceFee, int _image, String _description, String _enhancedDescription)
{ {
name = _name; name = _name;
entranceFee = _entranceFee;
image = _image; image = _image;
description = _description; description = _description;
enhancedDescription = _enhancedDescription; enhancedDescription = _enhancedDescription;
......
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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"
tools:context=".BookCafe">
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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"
tools:context=".BookMuseum">
<TextView
android:id="@+id/textView"
android:layout_width="fill_parent"
android:layout_height="24dp"
android:layout_marginStart="4dp"
android:layout_marginTop="16dp"
android:text="MuseumName"
android:textAlignment="center"
android:textStyle="bold"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/textView3"
android:layout_width="fill_parent"
android:layout_height="22dp"
android:layout_marginStart="4dp"
android:text="Select a date and time"
android:textAlignment="center"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView" />
<CalendarView
android:id="@+id/dateSelect"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.491"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView3" />
<Spinner
android:id="@+id/spinnerTime"
android:layout_width="296dp"
android:layout_height="33dp"
android:layout_marginTop="12dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.483"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/dateSelect" />
<Button
android:id="@+id/bookingContinue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:text="Continue"
app:iconTint="#FFFFFF"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.943"
app:layout_constraintStart_toStartOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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"
tools:context=".BookSouvenir">
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
app:layout_constraintStart_toStartOf="parent" /> app:layout_constraintStart_toStartOf="parent" />
<TextView <TextView
android:id="@+id/textView3" android:id="@+id/museumPrice"
android:layout_width="84dp" android:layout_width="84dp"
android:layout_height="23dp" android:layout_height="23dp"
android:text="£10" android:text="£10"
...@@ -67,20 +67,9 @@ ...@@ -67,20 +67,9 @@
android:text="Cost" android:text="Cost"
android:textAlignment="textEnd" android:textAlignment="textEnd"
android:textStyle="bold" android:textStyle="bold"
app:layout_constraintBottom_toTopOf="@+id/textView3" app:layout_constraintBottom_toTopOf="@+id/museumPrice"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.94" app:layout_constraintHorizontal_bias="0.94"
app:layout_constraintStart_toStartOf="parent" /> app:layout_constraintStart_toStartOf="parent" />
<Button
android:id="@+id/button3"
android:layout_width="76dp"
android:layout_height="70dp"
android:background="#00FFFFFF"
app:icon="@drawable/home"
app:iconPadding="0dp"
app:iconTint="#000000"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<menu xmlns:android="http://schemas.android.com/apk/res/android" <menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"> xmlns:app="http://schemas.android.com/apk/res-auto">
<!-- "Mark Favorite", should appear as action button if possible -->
<item <item
android:id="@+id/action_favorite" android:id="@+id/action_home"
android:icon="@drawable/home" android:icon="@drawable/home"
android:title="test" android:title="Home"
app:showAsAction="ifRoom"/> app:showAsAction="ifRoom"/>
</menu> </menu>
\ No newline at end of file
...@@ -20,4 +20,11 @@ ...@@ -20,4 +20,11 @@
<string name="american_natural_history_enhanced_description">The American Museum of Natural History is located in US, New York. The museum contains over 34,000,000 specimens including human remains.</string> <string name="american_natural_history_enhanced_description">The American Museum of Natural History is located in US, New York. The museum contains over 34,000,000 specimens including human remains.</string>
<string name="hermitage_description">Located in Saint Petersburg, Russia. \n£5 entrance fee.</string> <string name="hermitage_description">Located in Saint Petersburg, Russia. \n£5 entrance fee.</string>
<string name="hermitage_enhanced_description">The State Hermitage Museum is located in Saint Petersburg, Russia. It has the largest collections of paintings in the world. </string> <string name="hermitage_enhanced_description">The State Hermitage Museum is located in Saint Petersburg, Russia. It has the largest collections of paintings in the world. </string>
<string-array name="book_times">
<item>9am-11am</item>
<item>11am-1pm</item>
<item>1pm-3pm</item>
<item>3pm-5pm</item>
</string-array>
</resources> </resources>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment