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 4279c89..d97bc31 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/RouteDetailFragment.java b/app/src/main/java/com/a1/nextlocation/fragments/RouteDetailFragment.java index 4dfbfb9..cbf4598 100644 --- a/app/src/main/java/com/a1/nextlocation/fragments/RouteDetailFragment.java +++ b/app/src/main/java/com/a1/nextlocation/fragments/RouteDetailFragment.java @@ -11,18 +11,15 @@ import android.view.ViewGroup; import android.widget.ImageButton; import android.widget.Button; import android.widget.TextView; -import android.widget.Toast; import com.a1.nextlocation.R; import com.a1.nextlocation.data.Route; -import com.a1.nextlocation.data.RouteHandler; -import com.a1.nextlocation.data.StaticData; -import com.a1.nextlocation.network.ApiHandler; public class RouteDetailFragment extends Fragment { private Route route; private TextView routeDetailText; + private TextView routeName; private ImageButton imageButton; @Override @@ -38,10 +35,11 @@ public class RouteDetailFragment extends Fragment { this.route = getArguments().getParcelable("route"); } - this.routeDetailText = view.findViewById(R.id.routeDetailText); - this.routeDetailText.setText(this.route.getName()); - Button startButton = view.findViewById(R.id.start_route_button); - startButton.setOnClickListener(this::startRoute); + this.routeName = view.findViewById(R.id.route_title); + this.routeName.setText(this.route.getName()); + + this.routeDetailText = view.findViewById(R.id.reoute_detail_tekst); + this.routeDetailText.setText(this.route.getDescription()); this.imageButton = view.findViewById(R.id.route_detail_back_button); this.imageButton.setOnClickListener(v -> { @@ -52,12 +50,4 @@ public class RouteDetailFragment extends Fragment { return view; } - - public void startRoute(View view) { - ApiHandler.INSTANCE.getDirections(route); - RouteHandler.INSTANCE.followRoute(route); - Toast.makeText(requireContext(),"Route started!",Toast.LENGTH_SHORT).show(); - ((FragmentActivity) view.getContext()).getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, new HomeFragment()).addToBackStack(null).commit(); - - } } \ No newline at end of file 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 6838387..ff52861 100644 --- a/app/src/main/java/com/a1/nextlocation/fragments/SettingsFragment.java +++ b/app/src/main/java/com/a1/nextlocation/fragments/SettingsFragment.java @@ -7,6 +7,7 @@ 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 androidx.fragment.app.FragmentTransaction; @@ -30,6 +31,8 @@ public class SettingsFragment extends Fragment { private ImageView imageButton; + SwitchCompat fontChanger; + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -50,6 +53,35 @@ public class SettingsFragment extends Fragment { ((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(); + }); + return view; } 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 \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_location_detail.xml b/app/src/main/res/layout/fragment_location_detail.xml index 289ffd9..468aa89 100644 --- a/app/src/main/res/layout/fragment_location_detail.xml +++ b/app/src/main/res/layout/fragment_location_detail.xml @@ -10,12 +10,13 @@ @@ -30,16 +31,27 @@ app:layout_constraintTop_toBottomOf="@+id/detail_location_name" tools:src="@tools:sample/avatars" /> - + app:layout_constraintTop_toBottomOf="@+id/detail_location_image"> + + + + + diff --git a/app/src/main/res/layout/fragment_route_detail.xml b/app/src/main/res/layout/fragment_route_detail.xml index 735dbcf..477aa5c 100644 --- a/app/src/main/res/layout/fragment_route_detail.xml +++ b/app/src/main/res/layout/fragment_route_detail.xml @@ -22,9 +22,10 @@ android:id="@+id/route_title" android:layout_width="wrap_content" android:layout_height="wrap_content" + android:textColor="@color/white" + android:textSize="30sp" + app:layout_constraintBottom_toTopOf="@+id/route_detail_image" android:text="" - android:textSize="20sp" - app:layout_constraintBottom_toTopOf="@+id/routeDetailImage" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> @@ -33,16 +34,16 @@ android:layout_width="250dp" android:layout_height="250dp" android:layout_margin="40dp" - android:id="@+id/routeDetailImage" + android:id="@+id/route_detail_image" app:layout_constraintTop_toBottomOf="@id/route_detail_back_button" app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintBottom_toTopOf="@id/routeDetailText" + app:layout_constraintBottom_toTopOf="@id/reoute_detail_tekst" /> + app:layout_constraintTop_toBottomOf="@id/route_detail_image" />