diff --git a/app/src/main/java/net/plil/clubinfo/etunicorn/app/Crediter.java b/app/src/main/java/net/plil/clubinfo/etunicorn/app/Crediter.java index 8b38cec..7bfe1e5 100644 --- a/app/src/main/java/net/plil/clubinfo/etunicorn/app/Crediter.java +++ b/app/src/main/java/net/plil/clubinfo/etunicorn/app/Crediter.java @@ -22,19 +22,8 @@ import net.plil.clubinfo.etunicorn.utils.VolleyUtils; import org.json.JSONException; import org.json.JSONObject; -/** - * A simple {@link Fragment} subclass. - * Activities that contain this fragment must implement the - * {@link Crediter.OnFragmentInteractionListener} interface - * to handle interaction events. - * Use the {@link Crediter#newInstance} factory method to - * create an instance of this fragment. - */ public class Crediter extends FragmentNFC { - - private OnFragmentInteractionListener mListener; - private EditText mMoneyEditText; private ProgressBar mProgressBar; @@ -66,18 +55,11 @@ public class Crediter extends FragmentNFC { @Override public void onAttach(Context context) { super.onAttach(context); - if (context instanceof OnFragmentInteractionListener) { - mListener = (OnFragmentInteractionListener) context; - } else { - throw new RuntimeException(context.toString() - + " must implement OnFragmentInteractionListener"); - } } @Override public void onDetach() { super.onDetach(); - mListener = null; } @Override @@ -106,19 +88,4 @@ public class Crediter extends FragmentNFC { VolleyUtils.getInstance(getContext()).addToRequestQueue(jsonObjectRequest); } - - - /** - * This interface must be implemented by activities that contain this - * fragment to allow an interaction in this fragment to be communicated - * to the activity and potentially other fragments contained in that - * activity. - *

- * See the Android Training lesson Communicating with Other Fragments for more information. - */ - public interface OnFragmentInteractionListener { - void onFragmentInteraction(Uri uri); - } } diff --git a/app/src/main/java/net/plil/clubinfo/etunicorn/app/Debiter.java b/app/src/main/java/net/plil/clubinfo/etunicorn/app/Debiter.java index 7450a82..63dc126 100644 --- a/app/src/main/java/net/plil/clubinfo/etunicorn/app/Debiter.java +++ b/app/src/main/java/net/plil/clubinfo/etunicorn/app/Debiter.java @@ -27,21 +27,12 @@ import net.plil.clubinfo.etunicorn.utils.VolleyUtils; import org.json.JSONException; import org.json.JSONObject; -/** - * A simple {@link Fragment} subclass. - * Activities that contain this fragment must implement the - * {@link Debiter.OnFragmentInteractionListener} interface - * to handle interaction events. - * Use the {@link Debiter#newInstance} factory method to - * create an instance of this fragment. - */ public class Debiter extends FragmentNFC { private EditText mMoneyEditText; private ProgressBar mProgressBar; - private OnFragmentInteractionListener mListener; public Debiter() { // Required empty public constructor @@ -71,18 +62,11 @@ public class Debiter extends FragmentNFC { @Override public void onAttach(Context context) { super.onAttach(context); - if (context instanceof OnFragmentInteractionListener) { - mListener = (OnFragmentInteractionListener) context; - } else { - throw new RuntimeException(context.toString() - + " must implement OnFragmentInteractionListener"); - } } @Override public void onDetach() { super.onDetach(); - mListener = null; } @Override @@ -111,19 +95,4 @@ public class Debiter extends FragmentNFC { VolleyUtils.getInstance(getContext()).addToRequestQueue(jsonObjectRequest); } - - /** - * This interface must be implemented by activities that contain this - * fragment to allow an interaction in this fragment to be communicated - * to the activity and potentially other fragments contained in that - * activity. - *

- * See the Android Training lesson Communicating with Other Fragments for more information. - */ - public interface OnFragmentInteractionListener { - // TODO: Update argument type and name - void onFragmentInteraction(Uri uri); - } } diff --git a/app/src/main/java/net/plil/clubinfo/etunicorn/app/MainActivity.java b/app/src/main/java/net/plil/clubinfo/etunicorn/app/MainActivity.java index d7358f0..92d3ee7 100644 --- a/app/src/main/java/net/plil/clubinfo/etunicorn/app/MainActivity.java +++ b/app/src/main/java/net/plil/clubinfo/etunicorn/app/MainActivity.java @@ -5,6 +5,7 @@ import android.content.Intent; import android.net.Uri; import android.nfc.NfcAdapter; import android.os.Bundle; +import android.support.design.widget.AppBarLayout; import android.support.design.widget.TabLayout; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; @@ -14,14 +15,19 @@ import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.view.Menu; import android.view.MenuItem; +import android.view.Window; +import android.view.WindowManager; import net.plil.clubinfo.etunicorn.R; import net.plil.clubinfo.etunicorn.app.consommation.FragmentConsommation; import net.plil.clubinfo.etunicorn.app.consommation.PaiementConsommation; import net.plil.clubinfo.etunicorn.data.Consommation; +import java.util.ArrayList; +import java.util.List; -public class MainActivity extends AppCompatActivity implements Crediter.OnFragmentInteractionListener, Debiter.OnFragmentInteractionListener, FragmentConsommation.OnListFragmentInteractionListener{ + +public class MainActivity extends AppCompatActivity implements FragmentConsommation.OnListFragmentInteractionListener{ /** * The {@link android.support.v4.view.PagerAdapter} that will provide @@ -37,7 +43,10 @@ public class MainActivity extends AppCompatActivity implements Crediter.OnFragme * The {@link ViewPager} that will host the section contents. */ private ViewPager mViewPager; + private Toolbar toolbar; + private AppBarLayout appBarLayout; + private List consommationsToModify = new ArrayList<>(); NfcAdapter mAdapter; PendingIntent mPendingIntent; @@ -47,8 +56,11 @@ public class MainActivity extends AppCompatActivity implements Crediter.OnFragme super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); - Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); + appBarLayout = (AppBarLayout) findViewById(R.id.appbar); + + toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); + // Create the adapter that will return a fragment for each of the three // primary sections of the activity. mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); @@ -116,11 +128,6 @@ public class MainActivity extends AppCompatActivity implements Crediter.OnFragme } } - @Override - public void onFragmentInteraction(Uri uri) { - - } - @Override public void onListFragmentInteraction(Consommation item) { @@ -128,6 +135,11 @@ public class MainActivity extends AppCompatActivity implements Crediter.OnFragme paiementConsommation.show(getSupportFragmentManager(), "paiementConsommation"); } + @Override + public void onListFragmentInteractionLong(Consommation item) { + + } + /** * A {@link FragmentPagerAdapter} that returns a fragment corresponding to * one of the sections/tabs/pages. diff --git a/app/src/main/java/net/plil/clubinfo/etunicorn/app/consommation/ConsommationRecyclerViewAdapter.java b/app/src/main/java/net/plil/clubinfo/etunicorn/app/consommation/ConsommationRecyclerViewAdapter.java index 05a4aee..a0733ff 100644 --- a/app/src/main/java/net/plil/clubinfo/etunicorn/app/consommation/ConsommationRecyclerViewAdapter.java +++ b/app/src/main/java/net/plil/clubinfo/etunicorn/app/consommation/ConsommationRecyclerViewAdapter.java @@ -1,7 +1,13 @@ package net.plil.clubinfo.etunicorn.app.consommation; +import android.app.Activity; +import android.content.Context; +import android.support.v7.app.AppCompatActivity; +import android.support.v7.widget.PopupMenu; import android.support.v7.widget.RecyclerView; +import android.view.ContextMenu; import android.view.LayoutInflater; +import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; @@ -17,10 +23,12 @@ public class ConsommationRecyclerViewAdapter extends RecyclerView.Adapter mValues; private final FragmentConsommation.OnListFragmentInteractionListener mListener; + private final Context context; - public ConsommationRecyclerViewAdapter(List items, FragmentConsommation.OnListFragmentInteractionListener listener) { + public ConsommationRecyclerViewAdapter(List items, FragmentConsommation.OnListFragmentInteractionListener listener, Context context) { mValues = items; mListener = listener; + this.context = context; } @Override @@ -50,10 +58,37 @@ public class ConsommationRecyclerViewAdapter extends RecyclerView.Adapter() { + @Override + public void onResponse(JSONObject response) { + mProgressBar.setVisibility(View.GONE); + Toast.makeText(getContext(), R.string.delete_done, Toast.LENGTH_LONG).show(); + dismiss(); + } + }, new Response.ErrorListener() { + @Override + public void onErrorResponse(VolleyError error) { + mProgressBar.setVisibility(View.GONE); + Toast.makeText(getContext(), R.string.delete_refused, Toast.LENGTH_LONG).show(); + dismiss(); + } + } + ); + + VolleyUtils.getInstance(getContext()).addToRequestQueue(jsonObjectRequest); + } + }) + .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + + } + }); + return builder.create(); + } + + +} diff --git a/app/src/main/java/net/plil/clubinfo/etunicorn/app/consommation/FragmentConsommation.java b/app/src/main/java/net/plil/clubinfo/etunicorn/app/consommation/FragmentConsommation.java index 86a5043..6e09baa 100644 --- a/app/src/main/java/net/plil/clubinfo/etunicorn/app/consommation/FragmentConsommation.java +++ b/app/src/main/java/net/plil/clubinfo/etunicorn/app/consommation/FragmentConsommation.java @@ -10,18 +10,9 @@ import android.view.View; import android.view.ViewGroup; import android.widget.Toast; -import com.android.volley.Request; -import com.android.volley.Response; -import com.android.volley.VolleyError; -import com.android.volley.toolbox.JsonObjectRequest; - import net.plil.clubinfo.etunicorn.R; import net.plil.clubinfo.etunicorn.app.FragmentNFC; import net.plil.clubinfo.etunicorn.data.Consommation; -import net.plil.clubinfo.etunicorn.utils.VolleyUtils; - -import org.json.JSONException; -import org.json.JSONObject; import java.util.ArrayList; import java.util.List; @@ -75,7 +66,7 @@ public class FragmentConsommation extends FragmentNFC { c1.setPrix(42.407); consommationList.add(c1); } - recyclerView.setAdapter(new ConsommationRecyclerViewAdapter(consommationList, mListener)); + recyclerView.setAdapter(new ConsommationRecyclerViewAdapter(consommationList, mListener, this.getActivity())); FloatingActionButton fAB = (FloatingActionButton) view.findViewById(R.id.consomation_add); fAB.setOnClickListener(new View.OnClickListener() { @@ -112,7 +103,7 @@ public class FragmentConsommation extends FragmentNFC { PaiementConsommation paiementConsommation = (PaiementConsommation) getFragmentManager().findFragmentByTag("paiementConsommation"); if (paiementConsommation == null){ - Toast.makeText(getContext(), R.string.payment_consomation_alert_no_selection, Toast.LENGTH_LONG).show(); + Toast.makeText(getContext(), R.string.payment_consumable_alert_no_selection, Toast.LENGTH_LONG).show(); } else { paiementConsommation.processNFC(); @@ -131,5 +122,6 @@ public class FragmentConsommation extends FragmentNFC { */ public interface OnListFragmentInteractionListener { void onListFragmentInteraction(Consommation item); + void onListFragmentInteractionLong(Consommation item); } } diff --git a/app/src/main/res/drawable/selected_row.xml b/app/src/main/res/drawable/selected_row.xml deleted file mode 100644 index cc210f7..0000000 --- a/app/src/main/res/drawable/selected_row.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 5fa6811..bcd6569 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -21,6 +21,7 @@ android:background="?attr/colorPrimary" app:layout_scrollFlags="enterAlways" app:popupTheme="@style/AppTheme.PopupOverlay" + android:minHeight="?attr/actionBarSize" android:layout_height="64dp"> diff --git a/app/src/main/res/layout/fragment_consomation_item.xml b/app/src/main/res/layout/fragment_consomation_item.xml index d87b0e8..29fa455 100644 --- a/app/src/main/res/layout/fragment_consomation_item.xml +++ b/app/src/main/res/layout/fragment_consomation_item.xml @@ -1,10 +1,10 @@ + android:foreground="?attr/selectableItemBackground"> + android:layout_toRightOf="@id/consomation_id" + tools:ignore="RtlHardcoded" /> + android:layout_toRightOf="@id/consomation_name" + tools:ignore="RelativeOverlap,RtlHardcoded" /> + + diff --git a/app/src/main/res/layout/fragment_delete_consomation.xml b/app/src/main/res/layout/fragment_delete_consomation.xml new file mode 100644 index 0000000..1359def --- /dev/null +++ b/app/src/main/res/layout/fragment_delete_consomation.xml @@ -0,0 +1,17 @@ + + + + + + diff --git a/app/src/main/res/menu/menu_main.xml b/app/src/main/res/menu/menu_main.xml index a7973b9..b705d67 100644 --- a/app/src/main/res/menu/menu_main.xml +++ b/app/src/main/res/menu/menu_main.xml @@ -2,6 +2,8 @@ xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" tools:context="net.plil.clubinfo.etunicorn.app.MainActivity"> + + +

+ + + \ No newline at end of file diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 3cb3c5c..7cc4085 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -16,4 +16,8 @@ OK Etunicorn - Bonjour Paiement d\'un Consommable + Paiement accepté + Paiement refusé + Selectionné un produit avant de payer + Supprimer \ No newline at end of file diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 927f6e1..907584f 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -3,6 +3,7 @@ #F44336 #C62828 #2196F3 + #1565C0 #4d90fe #ffffff diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 32e186b..b857cae 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -18,7 +18,16 @@ Price Etunicorn - Hello Consumable Payment - Select a product before paying + Select a product before paying Payment done Payment refused + Delete + Modifier + Delete + + + Hello blank fragment + Are you sure ? + Delete done + Delete refused -- libgit2 0.21.2