Merge remote-tracking branch 'origin/develop' into develop
This commit is contained in:
@@ -53,7 +53,8 @@ public class CouponFragment extends Fragment {
|
||||
this.backButton = view.findViewById(R.id.coupon_back_button);
|
||||
this.backButton.setOnClickListener(v -> {
|
||||
StatisticFragment statisticFragment = new StatisticFragment();
|
||||
((FragmentActivity) view.getContext()).getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, statisticFragment).addToBackStack(null).commit();
|
||||
if (getActivity() != null)
|
||||
getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, statisticFragment).addToBackStack(null).commit();
|
||||
});
|
||||
|
||||
this.couponRecyclerView.setLayoutManager(this.layoutManager);
|
||||
|
||||
@@ -91,7 +91,8 @@ public class HomeFragment extends Fragment implements LocationListener {
|
||||
this.imageButton = view.findViewById(R.id.location_list_button);
|
||||
this.imageButton.setOnClickListener(v -> {
|
||||
LocationFragment locationFragment = new LocationFragment();
|
||||
((FragmentActivity) view.getContext()).getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, locationFragment).addToBackStack(null).commit();
|
||||
if (getActivity() != null)
|
||||
getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, locationFragment).addToBackStack(null).commit();
|
||||
});
|
||||
|
||||
// set up the route stop button
|
||||
|
||||
@@ -12,7 +12,6 @@ import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
|
||||
import com.a1.nextlocation.R;
|
||||
import com.a1.nextlocation.data.Data;
|
||||
@@ -50,20 +49,20 @@ public class LocationDetailFragment extends Fragment {
|
||||
this.titelText.setText(location.getName());
|
||||
|
||||
double currentDistanceToLocation = 0.0;
|
||||
if(Data.INSTANCE.getLocation() != null){
|
||||
if (Data.INSTANCE.getLocation() != null) {
|
||||
currentDistanceToLocation = Location.getDistance(Data.INSTANCE.getLocation().getLatitude(), Data.INSTANCE.getLocation().getLongitude(), this.location.getLat(), this.location.getLong());
|
||||
}
|
||||
|
||||
//Adds distance text from the current distance of the user to the opened location
|
||||
String detailText;
|
||||
if(getContext().getSharedPreferences("Settings", Context.MODE_PRIVATE).getBoolean("imperialSwitch", false)){
|
||||
if(currentDistanceToLocation > 1609)
|
||||
detailText = location.getDescription() + String.format("%.3f",currentDistanceToLocation * 0.000621371192) + "mi";
|
||||
if (getContext().getSharedPreferences("Settings", Context.MODE_PRIVATE).getBoolean("imperialSwitch", false)) {
|
||||
if (currentDistanceToLocation > 1609)
|
||||
detailText = location.getDescription() + String.format("%.3f", currentDistanceToLocation * 0.000621371192) + "mi";
|
||||
else
|
||||
detailText = location.getDescription() + String.format("%.2f",currentDistanceToLocation * 1.0936133) + "yd";
|
||||
detailText = location.getDescription() + String.format("%.2f", currentDistanceToLocation * 1.0936133) + "yd";
|
||||
} else {
|
||||
if(currentDistanceToLocation > 1000)
|
||||
detailText = location.getDescription() + String.format("%.3f",currentDistanceToLocation / 1000) + "km";
|
||||
if (currentDistanceToLocation > 1000)
|
||||
detailText = location.getDescription() + String.format("%.3f", currentDistanceToLocation / 1000) + "km";
|
||||
else
|
||||
detailText = location.getDescription() + currentDistanceToLocation + "m";
|
||||
}
|
||||
@@ -74,7 +73,8 @@ public class LocationDetailFragment extends Fragment {
|
||||
this.backButton = view.findViewById(R.id.detail_location_back_button);
|
||||
this.backButton.setOnClickListener(v -> {
|
||||
LocationFragment locationFragment = new LocationFragment();
|
||||
((FragmentActivity) view.getContext()).getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, locationFragment).addToBackStack(null).commit();
|
||||
if (getActivity() != null)
|
||||
getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, locationFragment).addToBackStack(null).commit();
|
||||
});
|
||||
|
||||
//Logs the location
|
||||
|
||||
@@ -43,7 +43,8 @@ public class LocationFragment extends Fragment {
|
||||
this.backButton = view.findViewById(R.id.location_back_button);
|
||||
this.backButton.setOnClickListener(v -> {
|
||||
HomeFragment homeFragment = new HomeFragment();
|
||||
((FragmentActivity) view.getContext()).getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, homeFragment).addToBackStack(null).commit();
|
||||
if (getActivity() != null)
|
||||
getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, homeFragment).addToBackStack(null).commit();
|
||||
});
|
||||
|
||||
//Loads the location list
|
||||
@@ -58,7 +59,8 @@ public class LocationFragment extends Fragment {
|
||||
//Gives the clicked location to the adapter
|
||||
locationBundle.putParcelable("location", this.locationList.get(clickedPosition));
|
||||
locationDetailFragment.setArguments(locationBundle);
|
||||
((FragmentActivity) view.getContext()).getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, locationDetailFragment).addToBackStack(null).commit();
|
||||
if (getActivity() != null)
|
||||
getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, locationDetailFragment).addToBackStack(null).commit();
|
||||
});
|
||||
|
||||
this.locationRecyclerView.setLayoutManager(this.layoutManager);
|
||||
|
||||
@@ -14,7 +14,6 @@ import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
|
||||
import com.a1.nextlocation.R;
|
||||
import com.a1.nextlocation.data.Location;
|
||||
@@ -63,10 +62,10 @@ public class RouteDetailFragment extends Fragment {
|
||||
|
||||
TextView routeDetailText = view.findViewById(R.id.route_detail_tekst);
|
||||
StringBuilder locations = new StringBuilder();
|
||||
for(Location location : this.route.getLocations()){
|
||||
for (Location location : this.route.getLocations()) {
|
||||
locations.append("<br>•").append(location.getName());
|
||||
}
|
||||
String detailText = this.route.getDescription() + "<br><br><b>" + getResources().getString(R.string.following_locations) + "</b>" + locations + "<br><br><b>" + getResources().getString(R.string.start_location) + ": </b>" + route.getLocations().get(0).getName() + "<br>" + "<b>" + getResources().getString(R.string.end_location) + ": </b>" + route.getLocations().get(route.getLocations().size()-1).getName();
|
||||
String detailText = this.route.getDescription() + "<br><br><b>" + getResources().getString(R.string.following_locations) + "</b>" + locations + "<br><br><b>" + getResources().getString(R.string.start_location) + ": </b>" + route.getLocations().get(0).getName() + "<br>" + "<b>" + getResources().getString(R.string.end_location) + ": </b>" + route.getLocations().get(route.getLocations().size() - 1).getName();
|
||||
routeDetailText.setText(Html.fromHtml(detailText));
|
||||
|
||||
|
||||
@@ -79,7 +78,8 @@ public class RouteDetailFragment extends Fragment {
|
||||
ImageButton backButton = view.findViewById(R.id.route_detail_back_button);
|
||||
backButton.setOnClickListener(v -> {
|
||||
RouteFragment routeFragment = new RouteFragment();
|
||||
((FragmentActivity) view.getContext()).getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, routeFragment).addToBackStack(null).commit();
|
||||
if (getActivity() != null)
|
||||
getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, routeFragment).addToBackStack(null).commit();
|
||||
});
|
||||
|
||||
Button startButton = view.findViewById(R.id.start_route_button);
|
||||
|
||||
@@ -9,7 +9,6 @@ import android.widget.ImageButton;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
@@ -49,13 +48,15 @@ public class RouteFragment extends Fragment {
|
||||
Bundle routeBundle = new Bundle();
|
||||
routeBundle.putParcelable("route", this.routeList.get(clickedPosition));
|
||||
routeDetailFragment.setArguments(routeBundle);
|
||||
((FragmentActivity) view.getContext()).getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, routeDetailFragment).addToBackStack(null).commit();
|
||||
if (getActivity() != null)
|
||||
getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, routeDetailFragment).addToBackStack(null).commit();
|
||||
});
|
||||
|
||||
ImageButton backButton = view.findViewById(R.id.route_back_button);
|
||||
backButton.setOnClickListener(v -> {
|
||||
HomeFragment homeFragment = new HomeFragment();
|
||||
((FragmentActivity) view.getContext()).getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, homeFragment).addToBackStack(null).commit();
|
||||
if (getActivity() != null)
|
||||
getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, homeFragment).addToBackStack(null).commit();
|
||||
});
|
||||
|
||||
routeRecyclerView.setLayoutManager(layoutManager);
|
||||
|
||||
@@ -5,7 +5,6 @@ import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Configuration;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@@ -17,10 +16,8 @@ import android.widget.Spinner;
|
||||
import androidx.appcompat.app.AppCompatDelegate;
|
||||
import androidx.appcompat.widget.SwitchCompat;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
|
||||
import com.a1.nextlocation.MainActivity;
|
||||
import com.a1.nextlocation.R;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -66,7 +63,8 @@ public class SettingsFragment extends Fragment {
|
||||
ImageView backButton = view.findViewById(R.id.settings_back_button);
|
||||
backButton.setOnClickListener(v -> {
|
||||
HomeFragment homeFragment = new HomeFragment();
|
||||
((FragmentActivity) view.getContext()).getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, homeFragment).addToBackStack(null).commit();
|
||||
if (getActivity() != null)
|
||||
getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, homeFragment).addToBackStack(null).commit();
|
||||
});
|
||||
|
||||
SharedPreferences sharedPreferences = getContext().getSharedPreferences("Settings", Context.MODE_PRIVATE);
|
||||
@@ -87,17 +85,16 @@ public class SettingsFragment extends Fragment {
|
||||
fontSwitch.setChecked(sharedPreferences.getBoolean("fontSwitch", false));
|
||||
|
||||
//Initial check to see what setting was last chosen
|
||||
if (fontSwitch.isChecked()){
|
||||
if (fontSwitch.isChecked()) {
|
||||
requireActivity().setTheme(R.style.Theme_NextLocationBig);
|
||||
}else if (!fontSwitch.isChecked()){
|
||||
} else if (!fontSwitch.isChecked()) {
|
||||
requireActivity().setTheme(R.style.Theme_NextLocation);
|
||||
}
|
||||
|
||||
//Changes the font settings depending on the state of the toggle
|
||||
|
||||
fontSwitch.setOnClickListener(view1 -> {
|
||||
if(fontSwitch.isChecked())
|
||||
{
|
||||
if (fontSwitch.isChecked()) {
|
||||
requireActivity().setTheme(R.style.Theme_NextLocationBig);
|
||||
getActivity().recreate();
|
||||
}
|
||||
@@ -106,7 +103,7 @@ public class SettingsFragment extends Fragment {
|
||||
requireActivity().setTheme(R.style.Theme_NextLocation);
|
||||
getActivity().recreate();
|
||||
}
|
||||
editor.putBoolean("fontSwitch",fontSwitch.isChecked());
|
||||
editor.putBoolean("fontSwitch", fontSwitch.isChecked());
|
||||
editor.apply();
|
||||
editor.commit();
|
||||
});
|
||||
@@ -119,12 +116,12 @@ public class SettingsFragment extends Fragment {
|
||||
editor.apply();
|
||||
editor.commit();
|
||||
|
||||
if (colorBlindMode.isChecked()){
|
||||
if (colorBlindMode.isChecked()) {
|
||||
requireActivity().setTheme(R.style.Theme_NextLocation);
|
||||
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
|
||||
getActivity().recreate();
|
||||
System.out.println("AAN");
|
||||
}else if (!colorBlindMode.isChecked()){
|
||||
} else if (!colorBlindMode.isChecked()) {
|
||||
requireActivity().setTheme(R.style.Theme_NextLocation);
|
||||
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
|
||||
getActivity().recreate();
|
||||
|
||||
@@ -58,21 +58,24 @@ public class StatisticFragment extends Fragment {
|
||||
ImageView backButton = view.findViewById(R.id.statistics_back_button);
|
||||
backButton.setOnClickListener(v -> {
|
||||
HomeFragment homeFragment = new HomeFragment();
|
||||
((FragmentActivity) view.getContext()).getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, homeFragment).addToBackStack(null).commit();
|
||||
if (getActivity() != null)
|
||||
getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, homeFragment).addToBackStack(null).commit();
|
||||
});
|
||||
|
||||
//Initialises the coupon button
|
||||
ImageView couponButton = view.findViewById(R.id.coupon_button);
|
||||
couponButton.setOnClickListener(v -> {
|
||||
CouponFragment couponFragment = new CouponFragment();
|
||||
((FragmentActivity) view.getContext()).getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, couponFragment).addToBackStack(null).commit();
|
||||
if (getActivity() != null)
|
||||
getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, couponFragment).addToBackStack(null).commit();
|
||||
});
|
||||
|
||||
//Makes the constraintlayout clickable and opens the same layout as the coupon button
|
||||
ConstraintLayout constraintLayout = view.findViewById(R.id.Box4);
|
||||
constraintLayout.setOnClickListener(v -> {
|
||||
CouponFragment couponFragment = new CouponFragment();
|
||||
((FragmentActivity) view.getContext()).getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, couponFragment).addToBackStack(null).commit();
|
||||
if (getActivity() != null)
|
||||
getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, couponFragment).addToBackStack(null).commit();
|
||||
});
|
||||
return view;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user