Delete Canteens and Restore Canteen List to Default
This commit is contained in:
@@ -326,6 +326,9 @@ public class MainActivity extends AppCompatActivity
|
|||||||
if (mFragmentPage == FRAGMENT_SCHEDULE) {
|
if (mFragmentPage == FRAGMENT_SCHEDULE) {
|
||||||
getMenuInflater().inflate(R.menu.options_schedule, menu);
|
getMenuInflater().inflate(R.menu.options_schedule, menu);
|
||||||
return true;
|
return true;
|
||||||
|
} else if (mFragmentPage == FRAGMENT_CANTEENS) {
|
||||||
|
getMenuInflater().inflate(R.menu.options_canteens, menu);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -337,19 +340,35 @@ public class MainActivity extends AppCompatActivity
|
|||||||
// as you specify a parent activity in AndroidManifest.xml.
|
// as you specify a parent activity in AndroidManifest.xml.
|
||||||
int id = item.getItemId();
|
int id = item.getItemId();
|
||||||
|
|
||||||
//noinspection SimplifiableIfStatement
|
if (mFragmentPage == FRAGMENT_SCHEDULE) {
|
||||||
if (id == R.id.refresh) {
|
if (id == R.id.refresh) {
|
||||||
ScheduleFragment fragment = (ScheduleFragment) mFragmentManager.findFragmentByTag(String.valueOf(FRAGMENT_SCHEDULE));
|
ScheduleFragment fragment = (ScheduleFragment) mFragmentManager.findFragmentByTag(String.valueOf(FRAGMENT_SCHEDULE));
|
||||||
if (fragment != null && fragment.isVisible()) {
|
if (fragment != null && fragment.isVisible()) {
|
||||||
fragment.invalidate(true);
|
fragment.invalidate(true);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} else if (id == R.id.go_to_today) {
|
||||||
|
ScheduleFragment fragment = (ScheduleFragment) mFragmentManager.findFragmentByTag(String.valueOf(FRAGMENT_SCHEDULE));
|
||||||
|
if (fragment != null && fragment.isVisible()) {
|
||||||
|
fragment.goToToday();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return true;
|
} else if (mFragmentPage == FRAGMENT_CANTEENS) {
|
||||||
} else if (id == R.id.go_to_today) {
|
if (id == R.id.restore) {
|
||||||
ScheduleFragment fragment = (ScheduleFragment) mFragmentManager.findFragmentByTag(String.valueOf(FRAGMENT_SCHEDULE));
|
CanteensFragment fragment = (CanteensFragment) mFragmentManager.findFragmentByTag(String.valueOf(FRAGMENT_CANTEENS));
|
||||||
if (fragment != null && fragment.isVisible()) {
|
if (fragment != null && fragment.isVisible()) {
|
||||||
fragment.goToToday();
|
fragment.restoreDefaults();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (id == R.id.delete) {
|
||||||
|
CanteensFragment fragment = (CanteensFragment) mFragmentManager.findFragmentByTag(String.valueOf(FRAGMENT_CANTEENS));
|
||||||
|
if (fragment != null && fragment.isVisible()) {
|
||||||
|
fragment.startDelete();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
|
|||||||
@@ -7,12 +7,15 @@ import android.view.ViewGroup;
|
|||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import de.sebse.fuplanner.R;
|
import de.sebse.fuplanner.R;
|
||||||
import de.sebse.fuplanner.fragments.CanteensFragment.OnCanteensFragmentInteractionListener;
|
import de.sebse.fuplanner.fragments.CanteensFragment.OnCanteensFragmentInteractionListener;
|
||||||
import de.sebse.fuplanner.services.canteen.types.Canteen;
|
import de.sebse.fuplanner.services.canteen.types.Canteen;
|
||||||
import de.sebse.fuplanner.services.canteen.types.Canteens;
|
import de.sebse.fuplanner.services.canteen.types.Canteens;
|
||||||
|
import de.sebse.fuplanner.tools.ui.CanteensViewHolder;
|
||||||
import de.sebse.fuplanner.tools.ui.CustomViewHolder;
|
import de.sebse.fuplanner.tools.ui.CustomViewHolder;
|
||||||
import de.sebse.fuplanner.tools.ui.ItemViewHolder;
|
|
||||||
import de.sebse.fuplanner.tools.ui.StringViewHolder;
|
import de.sebse.fuplanner.tools.ui.StringViewHolder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -21,8 +24,14 @@ import de.sebse.fuplanner.tools.ui.StringViewHolder;
|
|||||||
*/
|
*/
|
||||||
class CanteensAdapter extends RecyclerView.Adapter<CustomViewHolder> {
|
class CanteensAdapter extends RecyclerView.Adapter<CustomViewHolder> {
|
||||||
|
|
||||||
|
private static final int TYPE_NO_LIST_AVAILABLE = 0;
|
||||||
|
private static final int TYPE_DELETE_BUTTON = 1;
|
||||||
|
private static final int TYPE_ENTRY = 2;
|
||||||
private Canteens mValues;
|
private Canteens mValues;
|
||||||
private final OnCanteensFragmentInteractionListener mListener;
|
private final OnCanteensFragmentInteractionListener mListener;
|
||||||
|
private boolean mIsShowDeletion = false;
|
||||||
|
private ArrayList<Integer> mDeleteCanteenIds = new ArrayList<>();
|
||||||
|
private DeletionListener mDeletionListener;
|
||||||
|
|
||||||
CanteensAdapter(OnCanteensFragmentInteractionListener listener) {
|
CanteensAdapter(OnCanteensFragmentInteractionListener listener) {
|
||||||
mValues = null;
|
mValues = null;
|
||||||
@@ -37,27 +46,55 @@ class CanteensAdapter extends RecyclerView.Adapter<CustomViewHolder> {
|
|||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public CustomViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
public CustomViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||||
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) {
|
if (viewType == TYPE_NO_LIST_AVAILABLE) {
|
||||||
View view = LayoutInflater.from(parent.getContext())
|
View view = LayoutInflater.from(parent.getContext())
|
||||||
.inflate(R.layout.list_all_no_items, parent, false);
|
.inflate(R.layout.list_all_no_items, parent, false);
|
||||||
return new StringViewHolder(view);
|
return new StringViewHolder(view);
|
||||||
|
} else if (viewType == TYPE_DELETE_BUTTON) {
|
||||||
|
View view = LayoutInflater.from(parent.getContext())
|
||||||
|
.inflate(R.layout.list_canteens_btn_delete, parent, false);
|
||||||
|
return new StringViewHolder(view);
|
||||||
}
|
}
|
||||||
View view = LayoutInflater.from(parent.getContext())
|
View view = LayoutInflater.from(parent.getContext())
|
||||||
.inflate(R.layout.list_all_items, parent, false);
|
.inflate(R.layout.list_canteens_items, parent, false);
|
||||||
return new ItemViewHolder(view);
|
return new CanteensViewHolder(view);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(@NonNull CustomViewHolder holder, int position) {
|
public void onBindViewHolder(@NonNull CustomViewHolder holder, int position) {
|
||||||
if (holder instanceof StringViewHolder) {
|
int viewType = getItemViewType(position);
|
||||||
|
if (viewType == TYPE_NO_LIST_AVAILABLE) {
|
||||||
((StringViewHolder) holder).mString.setText(R.string.canteen_not_available);
|
((StringViewHolder) holder).mString.setText(R.string.canteen_not_available);
|
||||||
} else if (holder instanceof ItemViewHolder) {
|
} else if (viewType == TYPE_DELETE_BUTTON) {
|
||||||
|
((StringViewHolder) holder).mString.setOnClickListener(v -> endDeletion());
|
||||||
|
} else {
|
||||||
|
if (mIsShowDeletion) {
|
||||||
|
position--;
|
||||||
|
}
|
||||||
if (mValues == null)
|
if (mValues == null)
|
||||||
return;
|
return;
|
||||||
Canteen canteen = mValues.get(holder.getAdapterPosition());
|
Canteen canteen = mValues.get(position);
|
||||||
((ItemViewHolder) holder).mTitle.setText(canteen.getName());
|
((CanteensViewHolder) holder).mTitle.setText(canteen.getName());
|
||||||
((ItemViewHolder) holder).mSubLeft.setText(canteen.getAddress());
|
((CanteensViewHolder) holder).mSubLeft.setText(canteen.getAddress());
|
||||||
((ItemViewHolder) holder).mSubRight.setText(canteen.getCity());
|
((CanteensViewHolder) holder).mSubRight.setText(canteen.getCity());
|
||||||
|
((CanteensViewHolder) holder).mRemoveIcon.setVisibility(mIsShowDeletion ? View.VISIBLE : View.GONE);
|
||||||
|
if (mDeleteCanteenIds.contains(canteen.getId())) {
|
||||||
|
((CanteensViewHolder) holder).mRemoveIcon.setImageDrawable(holder.mView.getResources().getDrawable(R.drawable.ic_remove_circle));
|
||||||
|
} else {
|
||||||
|
((CanteensViewHolder) holder).mRemoveIcon.setImageDrawable(holder.mView.getResources().getDrawable(R.drawable.ic_remove_circle_outline));
|
||||||
|
}
|
||||||
|
((CanteensViewHolder) holder).mRemoveIcon.setOnClickListener(v -> {
|
||||||
|
if (mDeleteCanteenIds.contains(canteen.getId())) {
|
||||||
|
// Prevent calling remove with index
|
||||||
|
//noinspection SuspiciousMethodCalls
|
||||||
|
mDeleteCanteenIds.remove((Object) canteen.getId());
|
||||||
|
} else {
|
||||||
|
mDeleteCanteenIds.add(canteen.getId());
|
||||||
|
}
|
||||||
|
notifyDataSetChanged();
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
holder.mView.setOnClickListener(v -> {
|
holder.mView.setOnClickListener(v -> {
|
||||||
if (null != mListener) {
|
if (null != mListener) {
|
||||||
@@ -75,8 +112,40 @@ class CanteensAdapter extends RecyclerView.Adapter<CustomViewHolder> {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (mValues != null) {
|
if (mValues != null) {
|
||||||
return mValues.size();
|
return mIsShowDeletion ? mValues.size() + 1 : mValues.size();
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemViewType(int position) {
|
||||||
|
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) {
|
||||||
|
return TYPE_NO_LIST_AVAILABLE;
|
||||||
|
}
|
||||||
|
return mIsShowDeletion && position == 0 ? TYPE_DELETE_BUTTON : TYPE_ENTRY;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void startDeletion(DeletionListener listener) {
|
||||||
|
mDeletionListener = listener;
|
||||||
|
if (mValues.size() > 0) {
|
||||||
|
mDeleteCanteenIds.clear();
|
||||||
|
mIsShowDeletion = true;
|
||||||
|
notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void endDeletion() {
|
||||||
|
int[] canteenIds = new int[mDeleteCanteenIds.size()];
|
||||||
|
for (int i = 0; i < mDeleteCanteenIds.size(); i++) {
|
||||||
|
canteenIds[i] = mDeleteCanteenIds.get(i);
|
||||||
|
}
|
||||||
|
mDeletionListener.onDeletionFinished(canteenIds);
|
||||||
|
mDeleteCanteenIds.clear();
|
||||||
|
mIsShowDeletion = false;
|
||||||
|
notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface DeletionListener {
|
||||||
|
void onDeletionFinished(int[] canteenIds);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,10 +11,16 @@ import androidx.fragment.app.Fragment;
|
|||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
|
||||||
import de.sebse.fuplanner.MainActivity;
|
import de.sebse.fuplanner.MainActivity;
|
||||||
import de.sebse.fuplanner.R;
|
import de.sebse.fuplanner.R;
|
||||||
import de.sebse.fuplanner.services.canteen.CanteenBrowser;
|
import de.sebse.fuplanner.services.canteen.CanteenBrowser;
|
||||||
import de.sebse.fuplanner.tools.MainActivityListener;
|
import de.sebse.fuplanner.tools.MainActivityListener;
|
||||||
|
import de.sebse.fuplanner.tools.Preferences;
|
||||||
import de.sebse.fuplanner.tools.logging.Logger;
|
import de.sebse.fuplanner.tools.logging.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -104,6 +110,44 @@ public class CanteensFragment extends Fragment {
|
|||||||
mMainActivityListener = null;
|
mMainActivityListener = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void restoreDefaults() {
|
||||||
|
Preferences.setArrayInt(requireContext(), R.string.pref_canteen_selection, null);
|
||||||
|
this.refresh(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void startDelete() {
|
||||||
|
log.d("start deletion");
|
||||||
|
adapter.startDeletion(items -> {
|
||||||
|
int[] canteens = Preferences.getArrayInt(requireContext(), R.string.pref_canteen_selection);
|
||||||
|
if (canteens != null) {
|
||||||
|
ArrayList<Integer> newList = new ArrayList<>();
|
||||||
|
for (int canteen : canteens) {
|
||||||
|
boolean found = false;
|
||||||
|
for (int item : items) {
|
||||||
|
if (item == canteen) {
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!found) {
|
||||||
|
newList.add(canteen);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int[] newCants = new int[newList.size()];
|
||||||
|
for (int i = 0; i < newList.size(); i++)
|
||||||
|
newCants[i] = newList.get(i);
|
||||||
|
Preferences.setArrayInt(requireContext(), R.string.pref_canteen_selection, newCants);
|
||||||
|
}
|
||||||
|
this.refresh(true);
|
||||||
|
});
|
||||||
|
/*int[] canteens = Preferences.getArrayInt(requireContext(), R.string.pref_canteen_selection);
|
||||||
|
int[] newCants = new int[canteens.length - 1];
|
||||||
|
for (int i = 0; i < canteens.length - 1; i++)
|
||||||
|
newCants[i] = canteens[i];
|
||||||
|
Preferences.setArrayInt(requireContext(), R.string.pref_canteen_selection, newCants);
|
||||||
|
this.refresh(true);*/
|
||||||
|
}
|
||||||
|
|
||||||
public interface OnCanteensFragmentInteractionListener {
|
public interface OnCanteensFragmentInteractionListener {
|
||||||
void onCanteensFragmentInteraction(int id);
|
void onCanteensFragmentInteraction(int id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,12 +8,15 @@ import org.json.JSONException;
|
|||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.HashSet;
|
||||||
|
|
||||||
|
import de.sebse.fuplanner.R;
|
||||||
import de.sebse.fuplanner.services.canteen.types.Canteen;
|
import de.sebse.fuplanner.services.canteen.types.Canteen;
|
||||||
import de.sebse.fuplanner.services.canteen.types.CanteenListener;
|
import de.sebse.fuplanner.services.canteen.types.CanteenListener;
|
||||||
import de.sebse.fuplanner.services.canteen.types.Canteens;
|
import de.sebse.fuplanner.services.canteen.types.Canteens;
|
||||||
import de.sebse.fuplanner.services.canteen.types.Day;
|
import de.sebse.fuplanner.services.canteen.types.Day;
|
||||||
import de.sebse.fuplanner.tools.AsyncQueue;
|
import de.sebse.fuplanner.tools.AsyncQueue;
|
||||||
|
import de.sebse.fuplanner.tools.Preferences;
|
||||||
import de.sebse.fuplanner.tools.network.HTTPService;
|
import de.sebse.fuplanner.tools.network.HTTPService;
|
||||||
import de.sebse.fuplanner.tools.network.NetworkCallback;
|
import de.sebse.fuplanner.tools.network.NetworkCallback;
|
||||||
import de.sebse.fuplanner.tools.network.NetworkError;
|
import de.sebse.fuplanner.tools.network.NetworkError;
|
||||||
@@ -70,7 +73,22 @@ public class CanteenBrowser extends HTTPService {
|
|||||||
callback.onResponse(new Canteens());
|
callback.onResponse(new Canteens());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
get("https://openmensa.org/api/v2/canteens?near[lat]=52.449743&near[lng]=13.282245&near[dist]=7", null, response -> {
|
int[] visibleCanteens = Preferences.getArrayInt(context, R.string.pref_canteen_selection);
|
||||||
|
if (visibleCanteens == null) {
|
||||||
|
Preferences.setArrayInt(context, R.string.pref_canteen_selection, Canteens.availableCanteens);
|
||||||
|
visibleCanteens = Preferences.getArrayInt(context, R.string.pref_canteen_selection);
|
||||||
|
}
|
||||||
|
if (visibleCanteens == null || visibleCanteens.length == 0) {
|
||||||
|
callback.onResponse(new Canteens());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
StringBuilder ids = new StringBuilder();
|
||||||
|
ids.append(visibleCanteens[0]);
|
||||||
|
for (int i = 1; i < visibleCanteens.length; i++) ids.append(",").append(visibleCanteens[i]);
|
||||||
|
|
||||||
|
// "https://openmensa.org/api/v2/canteens?near[lat]=52.449743&near[lng]=13.282245&near[dist]=7"
|
||||||
|
get("https://openmensa.org/api/v2/canteens?ids=" + ids.toString(), null, response -> {
|
||||||
String body = response.getParsed();
|
String body = response.getParsed();
|
||||||
if (body == null) {
|
if (body == null) {
|
||||||
errorCallback.onError(new NetworkError(201101, 403, "No canteen list retrieved!"));
|
errorCallback.onError(new NetworkError(201101, 403, "No canteen list retrieved!"));
|
||||||
@@ -93,12 +111,7 @@ public class CanteenBrowser extends HTTPService {
|
|||||||
lat = coords.getDouble(0);
|
lat = coords.getDouble(0);
|
||||||
lng = coords.getDouble(1);
|
lng = coords.getDouble(1);
|
||||||
}
|
}
|
||||||
for (int cant : Canteens.availableCanteens) {
|
canteens.addCanteen(id, name, city, address, lat, lng);
|
||||||
if (cant == id) {
|
|
||||||
canteens.addCanteen(id, name, city, address, lat, lng);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package de.sebse.fuplanner.tools;
|
package de.sebse.fuplanner.tools;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
|
||||||
import androidx.annotation.ArrayRes;
|
import androidx.annotation.ArrayRes;
|
||||||
import androidx.annotation.StringRes;
|
import androidx.annotation.StringRes;
|
||||||
@@ -39,4 +40,37 @@ public class Preferences {
|
|||||||
String string = context.getResources().getString(key);
|
String string = context.getResources().getString(key);
|
||||||
PreferenceManager.getDefaultSharedPreferences(context).edit().putBoolean(string, value).apply();
|
PreferenceManager.getDefaultSharedPreferences(context).edit().putBoolean(string, value).apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int[] getArrayInt(Context context, @StringRes int key) {
|
||||||
|
String string = context.getResources().getString(key);
|
||||||
|
|
||||||
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
|
if (!prefs.contains(string + "_size")) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
int size = prefs.getInt(string + "_size", 0);
|
||||||
|
int[] array = new int[size];
|
||||||
|
for (int i = 0; i < size; i++)
|
||||||
|
array[i] = prefs.getInt(string + "_" + i, 0);
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
public static void setArrayInt(Context context, @StringRes int key, int[] value) {
|
||||||
|
String string = context.getResources().getString(key);
|
||||||
|
|
||||||
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
|
SharedPreferences.Editor editor = prefs.edit();
|
||||||
|
int oldSize = prefs.getInt(string + "_size", 0);
|
||||||
|
int newSize = 0;
|
||||||
|
if (value == null) {
|
||||||
|
editor.remove(string + "_size");
|
||||||
|
} else {
|
||||||
|
newSize = value.length;
|
||||||
|
editor.putInt(string +"_size", newSize);
|
||||||
|
}
|
||||||
|
for (int i = 0; i < newSize; i++)
|
||||||
|
editor.putInt(string + "_" + i, value[i]);
|
||||||
|
for (int i = newSize; i < oldSize; i++)
|
||||||
|
editor.remove(string + "_" + i);
|
||||||
|
editor.apply();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package de.sebse.fuplanner.tools.ui;
|
||||||
|
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import de.sebse.fuplanner.R;
|
||||||
|
|
||||||
|
public class CanteensViewHolder extends ItemViewHolder {
|
||||||
|
public final ImageView mRemoveIcon;
|
||||||
|
|
||||||
|
public CanteensViewHolder(View view) {
|
||||||
|
super(view);
|
||||||
|
mRemoveIcon = view.findViewById(R.id.remove_icon);
|
||||||
|
}
|
||||||
|
}
|
||||||
5
app/src/main/res/drawable/ic_remove_circle.xml
Normal file
5
app/src/main/res/drawable/ic_remove_circle.xml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<vector android:height="24dp" android:tint="@color/colorFURed"
|
||||||
|
android:viewportHeight="24.0" android:viewportWidth="24.0"
|
||||||
|
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<path android:fillColor="#FF000000" android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM17,13L7,13v-2h10v2z"/>
|
||||||
|
</vector>
|
||||||
5
app/src/main/res/drawable/ic_remove_circle_outline.xml
Normal file
5
app/src/main/res/drawable/ic_remove_circle_outline.xml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<vector android:height="24dp" android:tint="@color/colorFURed"
|
||||||
|
android:viewportHeight="24.0" android:viewportWidth="24.0"
|
||||||
|
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<path android:fillColor="#FF000000" android:pathData="M7,11v2h10v-2L7,11zM12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.41,0 -8,-3.59 -8,-8s3.59,-8 8,-8 8,3.59 8,8 -3.59,8 -8,8z"/>
|
||||||
|
</vector>
|
||||||
19
app/src/main/res/layout/list_canteens_btn_delete.xml
Normal file
19
app/src/main/res/layout/list_canteens_btn_delete.xml
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/string"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:padding="@dimen/text_margin"
|
||||||
|
android:text="@string/delete_items"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:typeface="sans"
|
||||||
|
android:gravity="center"
|
||||||
|
android:textColor="@color/colorFUWhite"
|
||||||
|
android:background="@color/colorFURed"
|
||||||
|
/>
|
||||||
|
</LinearLayout>
|
||||||
70
app/src/main/res/layout/list_canteens_items.xml
Normal file
70
app/src/main/res/layout/list_canteens_items.xml
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
xmlns:card_view="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal" >
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/remove_icon"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:src="@drawable/ic_remove_circle_outline"
|
||||||
|
android:contentDescription="TODO"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:padding="8dp"/>
|
||||||
|
<androidx.cardview.widget.CardView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="@dimen/cardview_margin"
|
||||||
|
card_view:cardElevation="@dimen/cardview_elevation">
|
||||||
|
<RelativeLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:padding="@dimen/cardview_padding" >
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/title"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:typeface="sans"
|
||||||
|
tools:text="Test this new stuff!" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/sub_left"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@id/title"
|
||||||
|
android:layout_marginTop="5dip"
|
||||||
|
android:textColor="#343434"
|
||||||
|
android:textSize="12sp"
|
||||||
|
tools:text="Peter Bauer" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/sub_right"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignBaseline="@id/sub_left"
|
||||||
|
android:layout_alignBottom="@id/sub_left"
|
||||||
|
android:textColor="#343434"
|
||||||
|
android:textSize="12sp"
|
||||||
|
android:layout_alignParentEnd="true"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
tools:text="20.03.18 18:42 Uhr" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/top_right"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignBaseline="@id/title"
|
||||||
|
android:layout_alignBottom="@id/title"
|
||||||
|
android:textColor="#343434"
|
||||||
|
android:textSize="12sp"
|
||||||
|
android:layout_alignParentEnd="true"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
tools:text="Room 105"
|
||||||
|
tools:ignore="RelativeOverlap" />
|
||||||
|
</RelativeLayout>
|
||||||
|
</androidx.cardview.widget.CardView>
|
||||||
|
</LinearLayout>
|
||||||
12
app/src/main/res/menu/options_canteens.xml
Normal file
12
app/src/main/res/menu/options_canteens.xml
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
<item
|
||||||
|
android:id="@+id/restore"
|
||||||
|
android:title="@string/restore"
|
||||||
|
app:showAsAction="never" />
|
||||||
|
<item
|
||||||
|
android:id="@+id/delete"
|
||||||
|
android:title="@string/delete_items"
|
||||||
|
app:showAsAction="never" />
|
||||||
|
</menu>
|
||||||
@@ -115,4 +115,6 @@
|
|||||||
<string name="network_error_parameter">Ein Netzwerkfehler ist aufgetreten: %s!</string>
|
<string name="network_error_parameter">Ein Netzwerkfehler ist aufgetreten: %s!</string>
|
||||||
<string name="rate_the_app">App bewerten!</string>
|
<string name="rate_the_app">App bewerten!</string>
|
||||||
<string name="canteen_not_available">Die Kantinenliste ist für Android 4 und darunter nicht verfügbar!</string>
|
<string name="canteen_not_available">Die Kantinenliste ist für Android 4 und darunter nicht verfügbar!</string>
|
||||||
|
<string name="restore">Einträge zurücksetzen</string>
|
||||||
|
<string name="delete_items">Einträge löschen</string>
|
||||||
</resources>
|
</resources>
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
|
<!-- Select an item -->
|
||||||
<string-array name="pref_price_group" translatable="false">
|
<string-array name="pref_price_group" translatable="false">
|
||||||
<item>@string/pref_price_group</item>
|
<item>@string/pref_price_group</item>
|
||||||
<item>@string/pref_price_group_default</item>
|
<item>@string/pref_price_group_default</item>
|
||||||
@@ -7,16 +8,20 @@
|
|||||||
<string name="pref_price_group" translatable="false">pref_price_group</string>
|
<string name="pref_price_group" translatable="false">pref_price_group</string>
|
||||||
<string name="pref_price_group_default" translatable="false">all</string>
|
<string name="pref_price_group_default" translatable="false">all</string>
|
||||||
|
|
||||||
<string name="pref_last_visited_news" translatable="false">pref_last_visited_news</string>
|
|
||||||
|
|
||||||
<string name="pref_set_auto_sync_on_startup" translatable="false">pref_set_auto_sync_on_startup</string>
|
|
||||||
|
|
||||||
<string name="pref_shib_idp_session" translatable="false">pref_shib_idp_session</string>
|
|
||||||
|
|
||||||
<string-array name="pref_sync_frequency" translatable="false">
|
<string-array name="pref_sync_frequency" translatable="false">
|
||||||
<item>@string/pref_sync_frequency</item>
|
<item>@string/pref_sync_frequency</item>
|
||||||
<item>@string/pref_sync_frequency_default</item>
|
<item>@string/pref_sync_frequency_default</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
<string name="pref_sync_frequency" translatable="false">pref_sync_frequency</string>
|
<string name="pref_sync_frequency" translatable="false">pref_sync_frequency</string>
|
||||||
<string name="pref_sync_frequency_default" translatable="false">6</string>
|
<string name="pref_sync_frequency_default" translatable="false">6</string>
|
||||||
|
|
||||||
|
<!-- Other preferences -->
|
||||||
|
|
||||||
|
<string name="pref_last_visited_news" translatable="false">pref_last_visited_news</string>
|
||||||
|
|
||||||
|
<string name="pref_set_auto_sync_on_startup" translatable="false">pref_set_auto_sync_on_startup</string>
|
||||||
|
|
||||||
|
<string name="pref_shib_idp_session" translatable="false">pref_shib_idp_session</string>
|
||||||
|
|
||||||
|
<string name="pref_canteen_selection" translatable="false">pref_canteen_selection</string>
|
||||||
</resources>
|
</resources>
|
||||||
@@ -123,4 +123,6 @@
|
|||||||
<string name="network_error_parameter">A network error occurred: %s!</string>
|
<string name="network_error_parameter">A network error occurred: %s!</string>
|
||||||
<string name="rate_the_app">Rate the App!</string>
|
<string name="rate_the_app">Rate the App!</string>
|
||||||
<string name="canteen_not_available">The canteen list is not available for Android 4 and below!</string>
|
<string name="canteen_not_available">The canteen list is not available for Android 4 and below!</string>
|
||||||
|
<string name="restore">Restore Defaults</string>
|
||||||
|
<string name="delete_items">Delete Items</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
Reference in New Issue
Block a user