Skip to content

Commit

Permalink
Find course fragment #9
Browse files Browse the repository at this point in the history
Changed find course fragment, according to mockup.
  • Loading branch information
r5hej committed Apr 12, 2018
1 parent 151a8fd commit 178e7ef
Show file tree
Hide file tree
Showing 6 changed files with 152 additions and 140 deletions.
Original file line number Diff line number Diff line change
@@ -1,77 +1,65 @@
package dk.aau.sw805f18.ar.fragments;

import android.content.Context;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.Spinner;

import java.util.ArrayList;

import dk.aau.sw805f18.ar.R;
import dk.aau.sw805f18.ar.main.MainActivity;
import dk.aau.sw805f18.ar.models.Course;


public class FindCourseFragment extends Fragment {
private Button mSearchBtn;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_find_course, container, false);
}

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);

mSearchBtn = getView().findViewById(R.id.course_search_nearby);
mSearchBtn.setOnClickListener(view1 -> {
// Shows progressbar
ProgressBar pb = getView().findViewById(R.id.course_search_nearby_progressbar);
pb.setVisibility(View.VISIBLE);
mSearchBtn.setEnabled(false);

ArrayList<Course> courses = findNearbyCourses();
ListView lv = getView().findViewById(R.id.course_search_list);

// ArrayAdapter for populating listview
ArrayAdapter<Course> adapter = new ArrayAdapter<>(getContext(), R.layout.list_item_course, courses);
lv.setAdapter(adapter);

// Removing progressbar and viewing listview
pb.setVisibility(View.GONE);
lv.setVisibility(View.VISIBLE);
mSearchBtn.setEnabled(true);

lv.setOnItemClickListener((parent, view2, position, id) -> {

});
});
Spinner distance = getView().findViewById(R.id.find_course_distance_spinner);
Spinner type = getView().findViewById(R.id.find_course_type_spinner);
Spinner age = getView().findViewById(R.id.find_course_age_spinner);

ArrayAdapter<CharSequence> distanceAdapter = ArrayAdapter.createFromResource(getContext(),
R.array.find_course_distance_spinner_array,
android.R.layout.simple_spinner_item);

distanceAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
distance.setAdapter(distanceAdapter);

ArrayAdapter<CharSequence> ageAdapter = ArrayAdapter.createFromResource(getContext(),
R.array.find_course_age_spinner_array,
android.R.layout.simple_spinner_item);

ageAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
age.setAdapter(ageAdapter);

ArrayAdapter<String> typeAdapter = new ArrayAdapter<>(getContext(),
android.R.layout.simple_spinner_item,
getTypeItems());

typeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
type.setAdapter(typeAdapter);
}

/**
* Finds courses based on GPS location.
* TODO: implement GPS functionality. Current version is mock data.
*
* @return ArrayList of Courses
*/
private ArrayList<Course> findNearbyCourses() {
ArrayList<Course> toReturn = new ArrayList<>();
toReturn.add(new Course("the cool game"));
toReturn.add(new Course("the boring game"));
toReturn.add(new Course("not actually a game"));
toReturn.add(new Course("the AR game"));
return toReturn;
private ArrayList<String> getTypeItems() {
ArrayList<String> typeArray = new ArrayList<>();
typeArray.add("night event");
typeArray.add("halloween event");
typeArray.add("christmas event");
typeArray.add("sunshine event");

return typeArray;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import android.widget.Button;

import dk.aau.sw805f18.ar.R;
import dk.aau.sw805f18.ar.main.FragmentOpener;


public class HomeFragment extends Fragment {
Expand All @@ -32,7 +33,7 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
findBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

FragmentOpener.getInstance().open(new FindCourseFragment());
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,10 @@ public boolean onOptionsItemSelected(MenuItem item) {
private void setDrawerInfo() {
NavigationView navView = findViewById(R.id.nav_view);
View headerView = navView.getHeaderView(0);

TextView navName = headerView.findViewById(R.id.drawer_header_name_textview);
TextView navTroop = headerView.findViewById(R.id.drawer_header_troop_textview);

navName.setText("Jens Birkbak");
navTroop.setText("Blue birds");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,99 +1,101 @@
<?xml version="1.0" encoding="utf-8"?>
<layout>
<FrameLayout 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=".fragments.FindCourseFragment">
<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">

<SearchView
android:id="@+id/searchView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="32dp"
android:background="@color/grey_1"
android:iconifiedByDefault="false"
android:queryHint="Moooojn"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

<android.support.design.widget.TextInputEditText
android:id="@+id/course_id_input"
android:layout_width="0dp"
android:layout_height="47dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="16dp"
android:layout_marginTop="28dp"
android:focusedByDefault="false"
android:hint="@string/course_id"
app:layout_constraintEnd_toStartOf="@+id/button"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:targetApi="o" />
<ListView
android:id="@+id/listView"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
app:layout_constraintBottom_toTopOf="@+id/find_course_divider1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/find_course_age_spinner"
app:layout_constraintVertical_bias="1.0" />

<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginStart="8dp"
android:layout_marginTop="28dp"
android:layout_weight="1"
android:text="@string/course_id_ok"
android:background="@android:color/transparent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/course_id_input"
app:layout_constraintTop_toTopOf="parent" />
<Spinner
android:id="@+id/find_course_distance_spinner"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="16dp"
app:layout_constraintEnd_toStartOf="@+id/find_course_type_spinner"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/searchView" />

<View
android:id="@+id/view"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="16dp"
android:background="@android:color/darker_gray"
android:visibility="visible"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/course_id_input" />
<Spinner
android:id="@+id/find_course_type_spinner"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="16dp"
app:layout_constraintEnd_toStartOf="@+id/find_course_age_spinner"
app:layout_constraintStart_toEndOf="@+id/find_course_distance_spinner"
app:layout_constraintTop_toBottomOf="@+id/searchView" />

<Button
android:id="@+id/course_search_nearby"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:text="@string/course_nearby"
android:background="@android:color/transparent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/view" />
<Spinner
android:id="@+id/find_course_age_spinner"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/find_course_type_spinner"
app:layout_constraintTop_toBottomOf="@+id/searchView" />

<ProgressBar
android:id="@+id/course_search_nearby_progressbar"
style="?android:attr/progressBarStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="32dp"
android:visibility="gone"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.498"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/course_search_nearby" />
<View
android:id="@+id/find_course_divider1"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginBottom="8dp"
android:background="@color/divider"
app:layout_constraintBottom_toTopOf="@+id/find_course_join_by_code" />

<ListView
android:id="@+id/course_search_list"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginBottom="16dp"
android:layout_marginEnd="16dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/course_search_nearby" />
<android.support.design.widget.TextInputEditText
android:id="@+id/find_course_join_by_code"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:layout_marginStart="8dp"
android:hint="hint"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/find_course_join_by_code_button"
app:layout_constraintStart_toStartOf="parent" />

</android.support.constraint.ConstraintLayout>
<Button
android:id="@+id/find_course_join_by_code_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:layout_marginEnd="8dp"
android:text="Button"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />

</FrameLayout>
</layout>
</android.support.constraint.ConstraintLayout>
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
<color name="divider">#BDBDBD</color>
<color name="white">#ffffff</color>
<color name="ligtblue_3">#4FC3F7</color>
<color name="grey_1">#F5F5F5</color>
</resources>

26 changes: 22 additions & 4 deletions MultiplayerAugmentedRealityKit/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,24 @@
<string name="double_press_back_exit">Press BACK again to exit</string>

<!--Find course fragment-->
<string name="find_course_title">Find Courses</string>
<string name="course_id">Enter Course ID</string>
<string name="course_nearby">Find nearby courses</string>
<string name="course_id_ok">Join</string>
<string name="find_course_search_hint">Search for course</string>
<string name="find_course_join_by_code_hint">Enter course code</string>
<string-array name="find_course_distance_spinner_array">
<item>1km</item>
<item>2km</item>
<item>5km</item>
<item>10km</item>
<item>@string/infinity</item>
</string-array>
<string-array name="find_course_age_spinner_array">
<item>3–5</item>
<item>6–7</item>
<item>8–9</item>
<item>10–12</item>
<item>13–16</item>
<item>17–23</item>
<item>24+</item>
</string-array>

<!--Group fragment-->
<string name="group_make_text">Make a new group</string>
Expand All @@ -27,4 +41,8 @@

<!--Drawer-->
<string name="drawer_header_lobby_button_text">Lobby</string>


<!--Others-->
<string name="infinity">&#8734;</string>
</resources>

0 comments on commit 178e7ef

Please sign in to comment.