diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..39fb081 --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +*.iml +.gradle +/local.properties +/.idea/workspace.xml +/.idea/libraries +.DS_Store +/build +/captures +.externalNativeBuild diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..96cc43e --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml new file mode 100644 index 0000000..e7bedf3 --- /dev/null +++ b/.idea/copyright/profiles_settings.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..97626ba --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..fe72da5 --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,19 @@ + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..5d19981 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..c503577 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..ace5310 --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,33 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 24 + buildToolsVersion "24.0.2" + defaultConfig { + applicationId "net.plil.clubinfo.etunicorn" + minSdkVersion 21 + targetSdkVersion 24 + versionCode 1 + versionName "1.0" + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + compile fileTree(dir: 'libs', include: ['*.jar']) + androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { + exclude group: 'com.android.support', module: 'support-annotations' + }) + compile 'com.android.support:appcompat-v7:24.2.1' + compile 'com.android.support:design:24.2.1' + compile 'com.android.volley:volley:1.0.0' + compile 'com.google.code.gson:gson:2.4' + compile 'com.android.support:support-v4:24.2.1' + testCompile 'junit:junit:4.12' +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..5b85e92 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,17 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in C:\Users\badet\AppData\Local\Android\Sdk/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} diff --git a/app/src/androidTest/java/net/plil/clubinfo/etunicorn/ExampleInstrumentedTest.java b/app/src/androidTest/java/net/plil/clubinfo/etunicorn/ExampleInstrumentedTest.java new file mode 100644 index 0000000..04a78e2 --- /dev/null +++ b/app/src/androidTest/java/net/plil/clubinfo/etunicorn/ExampleInstrumentedTest.java @@ -0,0 +1,26 @@ +package net.plil.clubinfo.etunicorn; + +import android.content.Context; +import android.support.test.InstrumentationRegistry; +import android.support.test.runner.AndroidJUnit4; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.junit.Assert.*; + +/** + * Instrumentation test, which will execute on an Android device. + * + * @see Testing documentation + */ +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + @Test + public void useAppContext() throws Exception { + // Context of the app under test. + Context appContext = InstrumentationRegistry.getTargetContext(); + + assertEquals("net.plil.clubinfo.etunicorn", appContext.getPackageName()); + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..910aef6 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file 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 new file mode 100644 index 0000000..c3b8b35 --- /dev/null +++ b/app/src/main/java/net/plil/clubinfo/etunicorn/app/Crediter.java @@ -0,0 +1,108 @@ +package net.plil.clubinfo.etunicorn.app; + +import android.content.Context; +import android.content.Intent; +import android.net.Uri; +import android.nfc.NdefMessage; +import android.nfc.NfcAdapter; +import android.nfc.NfcEvent; +import android.os.Bundle; +import android.os.Parcelable; +import android.support.design.widget.Snackbar; +import android.support.v4.app.Fragment; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.Toast; + +import net.plil.clubinfo.etunicorn.R; + +/** + * 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 Fragment { + NfcAdapter mNfcAdapter; + + + + private OnFragmentInteractionListener mListener; + + public Crediter() { + // Required empty public constructor + } + + /** + * Use this factory method to create a new instance of + * this fragment using the provided parameters. + * + * @return A new instance of fragment Crediter. + */ + public static Crediter newInstance(String param1, String param2) { + Crediter fragment = new Crediter(); + return fragment; + } + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + mNfcAdapter = NfcAdapter.getDefaultAdapter(getContext()); + if (mNfcAdapter == null) { + Toast.makeText(getActivity(), "NFC is not available", Toast.LENGTH_LONG).show(); + return; + } + if (!mNfcAdapter.isEnabled()){ + Toast.makeText(getActivity(), "NFC is not enabled, please turn it on", Toast.LENGTH_LONG).show(); + } + + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + // Inflate the layout for this fragment + return inflater.inflate(R.layout.fragment_crediter, container, false); + } + + + @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; + } + + public void processNFC(){ + Toast.makeText(getContext(), "HELLO NFC", Toast.LENGTH_LONG).show(); + } + + + /** + * 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/Debiter.java b/app/src/main/java/net/plil/clubinfo/etunicorn/app/Debiter.java new file mode 100644 index 0000000..c4d3f01 --- /dev/null +++ b/app/src/main/java/net/plil/clubinfo/etunicorn/app/Debiter.java @@ -0,0 +1,109 @@ +package net.plil.clubinfo.etunicorn.app; + +import android.content.Context; +import android.net.Uri; +import android.os.Bundle; +import android.support.v4.app.Fragment; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import net.plil.clubinfo.etunicorn.R; + +/** + * 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 Fragment { + // TODO: Rename parameter arguments, choose names that match + // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER + private static final String ARG_PARAM1 = "param1"; + private static final String ARG_PARAM2 = "param2"; + + // TODO: Rename and change types of parameters + private String mParam1; + private String mParam2; + + private OnFragmentInteractionListener mListener; + + public Debiter() { + // Required empty public constructor + } + + /** + * Use this factory method to create a new instance of + * this fragment using the provided parameters. + * + * @param param1 Parameter 1. + * @param param2 Parameter 2. + * @return A new instance of fragment Debiter. + */ + // TODO: Rename and change types and number of parameters + public static Debiter newInstance(String param1, String param2) { + Debiter fragment = new Debiter(); + Bundle args = new Bundle(); + args.putString(ARG_PARAM1, param1); + args.putString(ARG_PARAM2, param2); + fragment.setArguments(args); + return fragment; + } + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + if (getArguments() != null) { + mParam1 = getArguments().getString(ARG_PARAM1); + mParam2 = getArguments().getString(ARG_PARAM2); + } + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + // Inflate the layout for this fragment + return inflater.inflate(R.layout.fragment_debiter, container, false); + } + + // TODO: Rename method, update argument and hook method into UI event + public void onButtonPressed(Uri uri) { + if (mListener != null) { + mListener.onFragmentInteraction(uri); + } + } + + @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; + } + + /** + * 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/LoginActivity.java b/app/src/main/java/net/plil/clubinfo/etunicorn/app/LoginActivity.java new file mode 100644 index 0000000..d337ef8 --- /dev/null +++ b/app/src/main/java/net/plil/clubinfo/etunicorn/app/LoginActivity.java @@ -0,0 +1,197 @@ +package net.plil.clubinfo.etunicorn.app; + +import android.animation.Animator; +import android.animation.AnimatorListenerAdapter; +import android.annotation.TargetApi; +import android.app.DownloadManager; +import android.content.Intent; +import android.content.pm.PackageManager; +import android.support.annotation.NonNull; +import android.support.design.widget.Snackbar; +import android.support.v7.app.AppCompatActivity; +import android.app.LoaderManager.LoaderCallbacks; + +import android.content.CursorLoader; +import android.content.Loader; +import android.database.Cursor; +import android.net.Uri; +import android.os.AsyncTask; + +import android.os.Build; +import android.os.Bundle; +import android.provider.ContactsContract; +import android.text.TextUtils; +import android.view.KeyEvent; +import android.view.View; +import android.view.View.OnClickListener; +import android.view.inputmethod.EditorInfo; +import android.widget.ArrayAdapter; +import android.widget.Button; +import android.widget.EditText; +import android.widget.TextView; +import android.widget.Toast; + +import com.android.volley.Request; +import com.android.volley.RequestQueue; +import com.android.volley.Response; +import com.android.volley.VolleyError; +import com.android.volley.toolbox.JsonObjectRequest; +import com.google.gson.Gson; + +import net.plil.clubinfo.etunicorn.R; +import net.plil.clubinfo.etunicorn.data.Personne; +import net.plil.clubinfo.etunicorn.utils.VolleyUtils; + +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.ArrayList; +import java.util.List; + +import static android.Manifest.permission.READ_CONTACTS; + +/** + * A login screen that offers login via email/password. + */ +public class LoginActivity extends AppCompatActivity { + + /** + * Id to identity READ_CONTACTS permission request. + */ + private static final int REQUEST_READ_CONTACTS = 0; + + /** + * Keep track of the login task to ensure we can cancel it if requested. + */ + + // UI references. + private EditText mUsernameView; + private EditText mPasswordView; + private View mProgressView; + private View mLoginFormView; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_login); + // Set up the login form. + mUsernameView = (EditText) findViewById(R.id.username); + + mPasswordView = (EditText) findViewById(R.id.password); + mPasswordView.setOnEditorActionListener(new TextView.OnEditorActionListener() { + @Override + public boolean onEditorAction(TextView textView, int id, KeyEvent keyEvent) { + if (id == R.id.login || id == EditorInfo.IME_NULL) { + attemptLogin(); + return true; + } + return false; + } + }); + + Button mEmailSignInButton = (Button) findViewById(R.id.email_sign_in_button); + mEmailSignInButton.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View view) { + attemptLogin(); + } + }); + + mLoginFormView = findViewById(R.id.login_form); + mProgressView = findViewById(R.id.login_progress); + } + + + /** + * Attempts to sign in or register the account specified by the login form. + * If there are form errors (invalid email, missing fields, etc.), the + * errors are presented and no actual login attempt is made. + */ + private void attemptLogin() { + + // Reset errors. + mUsernameView.setError(null); + mPasswordView.setError(null); + + // Store values at the time of the login attempt. + String email = mUsernameView.getText().toString(); + String username = mPasswordView.getText().toString(); + + + showProgress(true); + tryLogin(email, username); + } + + /** + * Shows the progress UI and hides the login form. + */ + @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2) + private void showProgress(final boolean show) { + // On Honeycomb MR2 we have the ViewPropertyAnimator APIs, which allow + // for very easy animations. If available, use these APIs to fade-in + // the progress spinner. + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) { + int shortAnimTime = getResources().getInteger(android.R.integer.config_shortAnimTime); + + mLoginFormView.setVisibility(show ? View.GONE : View.VISIBLE); + mLoginFormView.animate().setDuration(shortAnimTime).alpha( + show ? 0 : 1).setListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationEnd(Animator animation) { + mLoginFormView.setVisibility(show ? View.GONE : View.VISIBLE); + } + }); + + mProgressView.setVisibility(show ? View.VISIBLE : View.GONE); + mProgressView.animate().setDuration(shortAnimTime).alpha( + show ? 1 : 0).setListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationEnd(Animator animation) { + mProgressView.setVisibility(show ? View.VISIBLE : View.GONE); + } + }); + } else { + // The ViewPropertyAnimator APIs are not available, so simply show + // and hide the relevant UI components. + mProgressView.setVisibility(show ? View.VISIBLE : View.GONE); + mLoginFormView.setVisibility(show ? View.GONE : View.VISIBLE); + } + } + + /** + * You need a polytech Lille Account + * + * @param username The username of the person + * @param password The password of the person + */ + private void tryLogin (String username, String password){ + JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.POST, VolleyUtils.baseUri + "/login?login=" + username + "&password=" + password , null, new Response.Listener() { + @Override + public void onResponse(JSONObject response) { + showProgress(false); + try { + Personne p = new Gson().fromJson(response.getJSONObject("").toString(), Personne.class); + Intent intent = new Intent(getApplicationContext(), MainActivity.class); + startActivity(intent); + } catch (JSONException e) { + e.printStackTrace(); + } + } + }, new Response.ErrorListener() { + @Override + public void onErrorResponse(VolleyError error) { + showProgress(false); + Toast.makeText(getApplicationContext(), error.getMessage(), Toast.LENGTH_SHORT).show(); + + //TODO remove this line + Intent intent = new Intent(getApplicationContext(), MainActivity.class); + startActivity(intent); + // END + } + } + ); + + VolleyUtils.getInstance(getApplicationContext()).addToRequestQueue(jsonObjectRequest); + } +} + 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 new file mode 100644 index 0000000..5a7cd7b --- /dev/null +++ b/app/src/main/java/net/plil/clubinfo/etunicorn/app/MainActivity.java @@ -0,0 +1,212 @@ +package net.plil.clubinfo.etunicorn.app; + +import android.app.PendingIntent; +import android.content.Intent; +import android.nfc.NdefMessage; +import android.nfc.NfcAdapter; +import android.nfc.Tag; +import android.os.Parcelable; +import android.support.design.widget.TabLayout; +import android.support.design.widget.FloatingActionButton; +import android.support.design.widget.Snackbar; +import android.support.v7.app.AppCompatActivity; +import android.support.v7.widget.Toolbar; + +import android.support.v4.app.Fragment; +import android.support.v4.app.FragmentManager; +import android.support.v4.app.FragmentPagerAdapter; +import android.support.v4.view.ViewPager; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; +import android.view.ViewGroup; + +import android.widget.TextView; +import android.widget.Toast; + +import net.plil.clubinfo.etunicorn.R; + +import java.util.List; + +public class MainActivity extends AppCompatActivity { + + /** + * The {@link android.support.v4.view.PagerAdapter} that will provide + * fragments for each of the sections. We use a + * {@link FragmentPagerAdapter} derivative, which will keep every + * loaded fragment in memory. If this becomes too memory intensive, it + * may be best to switch to a + * {@link android.support.v4.app.FragmentStatePagerAdapter}. + */ + private SectionsPagerAdapter mSectionsPagerAdapter; + + /** + * The {@link ViewPager} that will host the section contents. + */ + private ViewPager mViewPager; + + + NfcAdapter mAdapter; + PendingIntent mPendingIntent; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + + Toolbar 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()); + + // Set up the ViewPager with the sections adapter. + mViewPager = (ViewPager) findViewById(R.id.container); + mViewPager.setAdapter(mSectionsPagerAdapter); + + TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs); + tabLayout.setupWithViewPager(mViewPager); + + + mAdapter = NfcAdapter.getDefaultAdapter(this); + if (mAdapter == null) { + //nfc not support your device. + return; + } + mPendingIntent = PendingIntent.getActivity(this, 0, new Intent(this, + getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0); + + } + + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + // Inflate the menu; this adds items to the action bar if it is present. + getMenuInflater().inflate(R.menu.menu_main, menu); + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + // Handle action bar item clicks here. The action bar will + // automatically handle clicks on the Home/Up button, so long + // as you specify a parent activity in AndroidManifest.xml. + int id = item.getItemId(); + + //noinspection SimplifiableIfStatement + if (id == R.id.action_settings) { + return true; + } + + return super.onOptionsItemSelected(item); + } + + @Override + protected void onNewIntent(Intent intent) { + super.onNewIntent(intent); + Toast.makeText(getBaseContext(), mViewPager.getCurrentItem()+" NFC WORKING", Toast.LENGTH_LONG).show(); + Toast.makeText(getBaseContext(), intent.getParcelableExtra(NfcAdapter.EXTRA_TAG) + "", Toast.LENGTH_LONG).show(); + + } + + @Override + public void onResume(){ + super.onResume(); + mAdapter.enableForegroundDispatch(this, mPendingIntent, null, null); + } + + @Override + public void onPause(){ + super.onPause(); + if (mAdapter != null) { + mAdapter.disableForegroundDispatch(this); + } + } + + /** + * A placeholder fragment containing a simple view. + */ + public static class PlaceholderFragment extends Fragment { + /** + * The fragment argument representing the section number for this + * fragment. + */ + private static final String ARG_SECTION_NUMBER = "section_number"; + + public PlaceholderFragment() { + } + + /** + * Returns a new instance of this fragment for the given section + * number. + */ + public static PlaceholderFragment newInstance(int sectionNumber) { + PlaceholderFragment fragment = new PlaceholderFragment(); + Bundle args = new Bundle(); + args.putInt(ARG_SECTION_NUMBER, sectionNumber); + fragment.setArguments(args); + return fragment; + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + View rootView; + if (getArguments().getInt(ARG_SECTION_NUMBER) == Action.DEBITER.getValue()) + rootView = inflater.inflate(R.layout.fragment_debiter, container, false); + else if (getArguments().getInt(ARG_SECTION_NUMBER) == Action.CREDITER.getValue()) + rootView = inflater.inflate(R.layout.fragment_crediter, container, false); + else + rootView = inflater.inflate(R.layout.fragment_main, container, false); + return rootView; + } + } + + /** + * A {@link FragmentPagerAdapter} that returns a fragment corresponding to + * one of the sections/tabs/pages. + */ + public class SectionsPagerAdapter extends FragmentPagerAdapter { + + public SectionsPagerAdapter(FragmentManager fm) { + super(fm); + } + + @Override + public Fragment getItem(int position) { + // getItem is called to instantiate the fragment for the given page. + // Return a PlaceholderFragment (defined as a static inner class below). + return PlaceholderFragment.newInstance(position + 1); + } + + @Override + public int getCount() { + // Show 3 total pages. + return 3; + } + + @Override + public CharSequence getPageTitle(int position) { + if(position == Action.DEBITER.getValue()) + return "Debiter"; + else if (position == Action.CREDITER.getValue()) + return "Crediter"; + return null; + } + } + + private enum Action { + DEBITER(0), CREDITER(1); + + private final int value; + Action(int value) { + this.value = value; + } + + public int getValue() { + return value; + } + } +} diff --git a/app/src/main/java/net/plil/clubinfo/etunicorn/data/Personne.java b/app/src/main/java/net/plil/clubinfo/etunicorn/data/Personne.java new file mode 100644 index 0000000..1dfc372 --- /dev/null +++ b/app/src/main/java/net/plil/clubinfo/etunicorn/data/Personne.java @@ -0,0 +1,55 @@ +package net.plil.clubinfo.etunicorn.data; + + +import java.sql.Date; + +public class Personne { + private int idPersonne; + private int idCarte; + private Date naissance; + private int solde = 0; + private String loginPoly; + + public Personne() { + } + + public int getIdPersonne() { + return idPersonne; + } + + public void setIdPersonne(int idPersonne) { + this.idPersonne = idPersonne; + } + + public int getIdCarte() { + return idCarte; + } + + public void setIdCarte(int idCarte) { + this.idCarte = idCarte; + } + + public Date getNaissance() { + return naissance; + } + + public void setNaissance(Date naissance) { + this.naissance = naissance; + } + + public int getSolde() { + return solde; + } + + public void setSolde(int solde) { + this.solde = solde; + } + + public String getLoginPoly() { + return loginPoly; + } + + public void setLoginPoly(String loginPoly) { + this.loginPoly = loginPoly; + } +} diff --git a/app/src/main/java/net/plil/clubinfo/etunicorn/utils/VolleyUtils.java b/app/src/main/java/net/plil/clubinfo/etunicorn/utils/VolleyUtils.java new file mode 100644 index 0000000..6f2f845 --- /dev/null +++ b/app/src/main/java/net/plil/clubinfo/etunicorn/utils/VolleyUtils.java @@ -0,0 +1,73 @@ +package net.plil.clubinfo.etunicorn.utils; + +import android.content.Context; +import android.graphics.Bitmap; +import android.util.LruCache; + +import com.android.volley.Request; +import com.android.volley.RequestQueue; +import com.android.volley.toolbox.ImageLoader; +import com.android.volley.toolbox.Volley; + +/** + * Created by badetitou on 28/01/2017. + */ + +public class VolleyUtils { + + private static final String uri = "https://etunicorn.plil.net/"; + private static final String version = "v1"; + + public static final String baseUri = VolleyUtils.uri + VolleyUtils.version + "/"; + + private static VolleyUtils mInstance; + private RequestQueue mRequestQueue; + private ImageLoader mImageLoader; + private static Context mCtx; + + private VolleyUtils(Context context) { + mCtx = context; + mRequestQueue = getRequestQueue(); + + mImageLoader = new ImageLoader(mRequestQueue, + new ImageLoader.ImageCache() { + private final LruCache + cache = new LruCache(20); + + @Override + public Bitmap getBitmap(String url) { + return cache.get(url); + } + + @Override + public void putBitmap(String url, Bitmap bitmap) { + cache.put(url, bitmap); + } + }); + } + + public static synchronized VolleyUtils getInstance(Context context) { + if (mInstance == null) { + mInstance = new VolleyUtils(context); + } + return mInstance; + } + + public RequestQueue getRequestQueue() { + if (mRequestQueue == null) { + // getApplicationContext() is key, it keeps you from leaking the + // Activity or BroadcastReceiver if someone passes one in. + mRequestQueue = Volley.newRequestQueue(mCtx.getApplicationContext()); + } + return mRequestQueue; + } + + public void addToRequestQueue(Request req) { + getRequestQueue().add(req); + } + + public ImageLoader getImageLoader() { + return mImageLoader; + } +} + diff --git a/app/src/main/res/layout/activity_login.xml b/app/src/main/res/layout/activity_login.xml new file mode 100644 index 0000000..3eb8996 --- /dev/null +++ b/app/src/main/res/layout/activity_login.xml @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + + + + + + + +