diff --git a/app/src/main/java/com/a1/nextlocation/data/Route.java b/app/src/main/java/com/a1/nextlocation/data/Route.java index baf6016..1e10a1c 100644 --- a/app/src/main/java/com/a1/nextlocation/data/Route.java +++ b/app/src/main/java/com/a1/nextlocation/data/Route.java @@ -15,21 +15,14 @@ public class Route implements Parcelable { @NonNull private String name; - - + private String description; private List locations; - - private float totalDistance; - - private int totalTime; public Route(@NotNull String name) { - this.name = name; this.locations = new ArrayList<>(); - } protected Route(Parcel in) { @@ -103,4 +96,12 @@ public class Route implements Parcelable { parcel.writeFloat(totalDistance); parcel.writeInt(totalTime); } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } } diff --git a/app/src/main/java/com/a1/nextlocation/fragments/CouponFragment.java b/app/src/main/java/com/a1/nextlocation/fragments/CouponFragment.java index 984e38c..c822134 100644 --- a/app/src/main/java/com/a1/nextlocation/fragments/CouponFragment.java +++ b/app/src/main/java/com/a1/nextlocation/fragments/CouponFragment.java @@ -41,18 +41,18 @@ public class CouponFragment extends Fragment { this.couponRecyclerView.setHasFixedSize(true); this.layoutManager = new LinearLayoutManager(this.getContext()); - this.imageButton = view.findViewById(R.id.coupon_back_button); - this.imageButton.setOnClickListener(v -> { - StatisticFragment statisticFragment = new StatisticFragment(); - ((FragmentActivity) view.getContext()).getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, statisticFragment).addToBackStack(null).commit(); - }); - CouponListManager.INSTANCE.setContext(this.getContext()); CouponListManager.INSTANCE.load(); this.couponList = CouponListManager.INSTANCE.getCouponList(); this.couponAdapter = new CouponAdapter(this.getContext(), this.couponList, clickedPosition -> showPopup(this.couponList.get(clickedPosition))); + this.imageButton = view.findViewById(R.id.coupon_back_button); + this.imageButton.setOnClickListener(v -> { + StatisticFragment statisticFragment = new StatisticFragment(); + ((FragmentActivity) view.getContext()).getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, statisticFragment).addToBackStack(null).commit(); + }); + this.couponRecyclerView.setLayoutManager(this.layoutManager); this.couponRecyclerView.setAdapter(this.couponAdapter); return view; diff --git a/app/src/main/java/com/a1/nextlocation/fragments/LocationFragment.java b/app/src/main/java/com/a1/nextlocation/fragments/LocationFragment.java index 03afb8e..067c759 100644 --- a/app/src/main/java/com/a1/nextlocation/fragments/LocationFragment.java +++ b/app/src/main/java/com/a1/nextlocation/fragments/LocationFragment.java @@ -1,5 +1,6 @@ package com.a1.nextlocation.fragments; +import android.media.Image; import android.os.Bundle; import androidx.fragment.app.Fragment; @@ -52,8 +53,10 @@ public class LocationFragment extends Fragment { this.locationAdapter = new LocationAdapter(this.getContext(), this.locationList, clickedPosition -> { LocationDetailFragment locationDetailFragment = new LocationDetailFragment(); + locationDetailFragment.setLocation(this.locationList.get(clickedPosition)); Bundle locationBundle = new Bundle(); locationBundle.putParcelable("location", this.locationList.get(clickedPosition)); + locationDetailFragment.setLocation(this.locationList.get(clickedPosition)); locationDetailFragment.setArguments(locationBundle); ((FragmentActivity) view.getContext()).getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, locationDetailFragment).addToBackStack(null).commit(); }); diff --git a/app/src/main/java/com/a1/nextlocation/fragments/RouteFragment.java b/app/src/main/java/com/a1/nextlocation/fragments/RouteFragment.java index 71184c8..2369e6d 100644 --- a/app/src/main/java/com/a1/nextlocation/fragments/RouteFragment.java +++ b/app/src/main/java/com/a1/nextlocation/fragments/RouteFragment.java @@ -13,6 +13,7 @@ import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.ImageButton; import com.a1.nextlocation.R; import com.a1.nextlocation.data.Route; @@ -33,6 +34,7 @@ public class RouteFragment extends Fragment { private RecyclerView.LayoutManager layoutManager; private List routeList; private RouteAdapter routeAdapter; + private ImageButton imageButton; @Override public void onCreate(Bundle savedInstanceState) { @@ -60,6 +62,12 @@ public class RouteFragment extends Fragment { ((FragmentActivity) view.getContext()).getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, routeDetailFragment).addToBackStack(null).commit(); }); + this.imageButton = view.findViewById(R.id.route_back_button); + this.imageButton.setOnClickListener(v -> { + HomeFragment homeFragment = new HomeFragment(); + ((FragmentActivity) view.getContext()).getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, homeFragment).addToBackStack(null).commit(); + }); + this.routeRecyclerView.setLayoutManager(this.layoutManager); this.routeRecyclerView.setAdapter(this.routeAdapter); return view; diff --git a/app/src/main/java/com/a1/nextlocation/fragments/SettingsFragment.java b/app/src/main/java/com/a1/nextlocation/fragments/SettingsFragment.java index 721ba3e..7fbe6a3 100644 --- a/app/src/main/java/com/a1/nextlocation/fragments/SettingsFragment.java +++ b/app/src/main/java/com/a1/nextlocation/fragments/SettingsFragment.java @@ -1,15 +1,19 @@ package com.a1.nextlocation.fragments; +import android.content.SharedPreferences; import android.os.Bundle; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.appcompat.widget.SwitchCompat; import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentActivity; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; +import android.widget.ImageView; import android.widget.Spinner; import com.a1.nextlocation.MainActivity; @@ -17,6 +21,10 @@ import com.a1.nextlocation.R; public class SettingsFragment extends Fragment { + private ImageView imageButton; + + SwitchCompat fontChanger; + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -36,6 +44,41 @@ public class SettingsFragment extends Fragment { // Inflate the layout for this fragment Spinner dropdown = view.findViewById(R.id.dropdown_menu_Settings); + this.imageButton = view.findViewById(R.id.settings_back_button); + this.imageButton.setOnClickListener(v -> { + HomeFragment homeFragment = new HomeFragment(); + ((FragmentActivity) view.getContext()).getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, homeFragment).addToBackStack(null).commit(); + }); + + + fontChanger = view.findViewById(R.id.BigFont); + + SharedPreferences sharedPreferences = requireActivity().getSharedPreferences("com.a1.nextlocation",0); + SharedPreferences.Editor editor = sharedPreferences.edit(); + fontChanger.setChecked(sharedPreferences.getBoolean("switch", false)); + + if (fontChanger.isChecked()){ + requireActivity().setTheme(R.style.Theme_NextLocationBig); + }else if (!fontChanger.isChecked()){ + requireActivity().setTheme(R.style.Theme_NextLocation); + } + + fontChanger.setOnClickListener(view1 -> { + if(fontChanger.isChecked()) + { + requireActivity().setTheme(R.style.Theme_NextLocationBig); + editor.putBoolean("switch",true); + editor.apply(); + } + if(!fontChanger.isChecked()) + { + requireActivity().setTheme(R.style.Theme_NextLocation); + editor.putBoolean("switch",false); + editor.apply(); + } + editor.commit(); + }); + String[] items = new String[]{"Nederlands", "Engels", "Chinees"}; ArrayAdapter arrayAdapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_spinner_dropdown_item, items); diff --git a/app/src/main/java/com/a1/nextlocation/fragments/StatisticFragment.java b/app/src/main/java/com/a1/nextlocation/fragments/StatisticFragment.java index 83e3a07..a2cc87a 100644 --- a/app/src/main/java/com/a1/nextlocation/fragments/StatisticFragment.java +++ b/app/src/main/java/com/a1/nextlocation/fragments/StatisticFragment.java @@ -26,6 +26,7 @@ public class StatisticFragment extends Fragment { private List couponList; private ImageView imageButton; + private ImageView couponButton; @Override @@ -50,6 +51,18 @@ public class StatisticFragment extends Fragment { couponNumber.setText(String.valueOf(adapter.getItemCount())); + this.imageButton = view.findViewById(R.id.statistics_back_button); + this.imageButton.setOnClickListener(v -> { + HomeFragment homeFragment = new HomeFragment(); + ((FragmentActivity) view.getContext()).getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, homeFragment).addToBackStack(null).commit(); + }); + + this.couponButton = view.findViewById(R.id.coupon_button); + this.couponButton.setOnClickListener(v -> { + CouponFragment couponFragment = new CouponFragment(); + ((FragmentActivity) view.getContext()).getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, couponFragment).addToBackStack(null).commit(); + }); + ConstraintLayout constraintLayout = view.findViewById(R.id.Box4); constraintLayout.setOnClickListener(v -> { CouponFragment couponFragment = new CouponFragment(); diff --git a/app/src/main/java/com/a1/nextlocation/recyclerview/LocationAdapter.java b/app/src/main/java/com/a1/nextlocation/recyclerview/LocationAdapter.java index b39feae..897aa27 100644 --- a/app/src/main/java/com/a1/nextlocation/recyclerview/LocationAdapter.java +++ b/app/src/main/java/com/a1/nextlocation/recyclerview/LocationAdapter.java @@ -4,6 +4,7 @@ import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.ImageView; import android.widget.TextView; import androidx.annotation.NonNull; @@ -27,10 +28,12 @@ public class LocationAdapter extends RecyclerView.Adapter location, OnItemClickListener listener){ @@ -62,6 +72,7 @@ public class LocationAdapter extends RecyclerView.Adapter diff --git a/app/src/main/res/layout-land/fragment_route_detail.xml b/app/src/main/res/layout-land/fragment_route_detail.xml index ebd2b7e..48263eb 100644 --- a/app/src/main/res/layout-land/fragment_route_detail.xml +++ b/app/src/main/res/layout-land/fragment_route_detail.xml @@ -7,6 +7,19 @@ android:background="@color/primaryColour" tools:context=".fragments.RouteDetailFragment"> +