From 01212adb190506f7597bb2fbe9e62656d0de5611 Mon Sep 17 00:00:00 2001 From: marianne-butaye Date: Thu, 7 Apr 2016 22:13:19 +0200 Subject: [PATCH] Application android du projet 10p5 avec gestion de la carte NFC. Version sans récupération du login lille 1 (Mifare Classic pas compatible avec tablette NEXUS 7 2013). Fichiers modifiés par rapport à une application vide : - MainActivity.java - AndroidManifest.xml - Rajout d'un dossier xml dans Resources/ - Ajout d'un fichier tech.xml dans le dossier xml/ ci-dessus --- App10p5/.gitignore | 8 ++++++++ App10p5/.idea/.name | 1 + App10p5/.idea/compiler.xml | 22 ++++++++++++++++++++++ App10p5/.idea/copyright/profiles_settings.xml | 3 +++ App10p5/.idea/gradle.xml | 19 +++++++++++++++++++ App10p5/.idea/misc.xml | 46 ++++++++++++++++++++++++++++++++++++++++++++++ App10p5/.idea/modules.xml | 9 +++++++++ App10p5/.idea/runConfigurations.xml | 12 ++++++++++++ App10p5/.idea/vcs.xml | 6 ++++++ App10p5/app/.gitignore | 1 + App10p5/app/build.gradle | 27 +++++++++++++++++++++++++++ App10p5/app/proguard-rules.pro | 17 +++++++++++++++++ App10p5/app/src/androidTest/java/net/plil/clubinfo/app10p5/ApplicationTest.java | 13 +++++++++++++ App10p5/app/src/main/AndroidManifest.xml | 40 ++++++++++++++++++++++++++++++++++++++++ App10p5/app/src/main/java/net/plil/clubinfo/app10p5/MainActivity.java | 126 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ App10p5/app/src/main/res/layout/activity_main.xml | 34 ++++++++++++++++++++++++++++++++++ App10p5/app/src/main/res/layout/content_main.xml | 19 +++++++++++++++++++ App10p5/app/src/main/res/menu/menu_main.xml | 10 ++++++++++ App10p5/app/src/main/res/mipmap-hdpi/ic_launcher.png | Bin 0 -> 3418 bytes App10p5/app/src/main/res/mipmap-mdpi/ic_launcher.png | Bin 0 -> 2206 bytes App10p5/app/src/main/res/mipmap-xhdpi/ic_launcher.png | Bin 0 -> 4842 bytes App10p5/app/src/main/res/mipmap-xxhdpi/ic_launcher.png | Bin 0 -> 7718 bytes App10p5/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png | Bin 0 -> 10486 bytes App10p5/app/src/main/res/values-v21/styles.xml | 9 +++++++++ App10p5/app/src/main/res/values-w820dp/dimens.xml | 6 ++++++ App10p5/app/src/main/res/values/colors.xml | 6 ++++++ App10p5/app/src/main/res/values/dimens.xml | 6 ++++++ App10p5/app/src/main/res/values/strings.xml | 4 ++++ App10p5/app/src/main/res/values/styles.xml | 20 ++++++++++++++++++++ App10p5/app/src/main/res/xml/tech.xml | 13 +++++++++++++ App10p5/app/src/test/java/net/plil/clubinfo/app10p5/ExampleUnitTest.java | 15 +++++++++++++++ App10p5/build.gradle | 23 +++++++++++++++++++++++ App10p5/gradle.properties | 18 ++++++++++++++++++ App10p5/gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 53637 bytes App10p5/gradle/wrapper/gradle-wrapper.properties | 6 ++++++ App10p5/gradlew | 160 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ App10p5/gradlew.bat | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ App10p5/settings.gradle | 1 + 38 files changed, 790 insertions(+), 0 deletions(-) create mode 100644 App10p5/.gitignore create mode 100644 App10p5/.idea/.name create mode 100644 App10p5/.idea/compiler.xml create mode 100644 App10p5/.idea/copyright/profiles_settings.xml create mode 100644 App10p5/.idea/gradle.xml create mode 100644 App10p5/.idea/misc.xml create mode 100644 App10p5/.idea/modules.xml create mode 100644 App10p5/.idea/runConfigurations.xml create mode 100644 App10p5/.idea/vcs.xml create mode 100644 App10p5/app/.gitignore create mode 100644 App10p5/app/build.gradle create mode 100644 App10p5/app/proguard-rules.pro create mode 100644 App10p5/app/src/androidTest/java/net/plil/clubinfo/app10p5/ApplicationTest.java create mode 100644 App10p5/app/src/main/AndroidManifest.xml create mode 100644 App10p5/app/src/main/java/net/plil/clubinfo/app10p5/MainActivity.java create mode 100644 App10p5/app/src/main/res/layout/activity_main.xml create mode 100644 App10p5/app/src/main/res/layout/content_main.xml create mode 100644 App10p5/app/src/main/res/menu/menu_main.xml create mode 100644 App10p5/app/src/main/res/mipmap-hdpi/ic_launcher.png create mode 100644 App10p5/app/src/main/res/mipmap-mdpi/ic_launcher.png create mode 100644 App10p5/app/src/main/res/mipmap-xhdpi/ic_launcher.png create mode 100644 App10p5/app/src/main/res/mipmap-xxhdpi/ic_launcher.png create mode 100644 App10p5/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png create mode 100644 App10p5/app/src/main/res/values-v21/styles.xml create mode 100644 App10p5/app/src/main/res/values-w820dp/dimens.xml create mode 100644 App10p5/app/src/main/res/values/colors.xml create mode 100644 App10p5/app/src/main/res/values/dimens.xml create mode 100644 App10p5/app/src/main/res/values/strings.xml create mode 100644 App10p5/app/src/main/res/values/styles.xml create mode 100644 App10p5/app/src/main/res/xml/tech.xml create mode 100644 App10p5/app/src/test/java/net/plil/clubinfo/app10p5/ExampleUnitTest.java create mode 100644 App10p5/build.gradle create mode 100644 App10p5/gradle.properties create mode 100644 App10p5/gradle/wrapper/gradle-wrapper.jar create mode 100644 App10p5/gradle/wrapper/gradle-wrapper.properties create mode 100755 App10p5/gradlew create mode 100644 App10p5/gradlew.bat create mode 100644 App10p5/settings.gradle diff --git a/App10p5/.gitignore b/App10p5/.gitignore new file mode 100644 index 0000000..c6cbe56 --- /dev/null +++ b/App10p5/.gitignore @@ -0,0 +1,8 @@ +*.iml +.gradle +/local.properties +/.idea/workspace.xml +/.idea/libraries +.DS_Store +/build +/captures diff --git a/App10p5/.idea/.name b/App10p5/.idea/.name new file mode 100644 index 0000000..da27beb --- /dev/null +++ b/App10p5/.idea/.name @@ -0,0 +1 @@ +App10p5 \ No newline at end of file diff --git a/App10p5/.idea/compiler.xml b/App10p5/.idea/compiler.xml new file mode 100644 index 0000000..96cc43e --- /dev/null +++ b/App10p5/.idea/compiler.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/App10p5/.idea/copyright/profiles_settings.xml b/App10p5/.idea/copyright/profiles_settings.xml new file mode 100644 index 0000000..e7bedf3 --- /dev/null +++ b/App10p5/.idea/copyright/profiles_settings.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/App10p5/.idea/gradle.xml b/App10p5/.idea/gradle.xml new file mode 100644 index 0000000..261ec28 --- /dev/null +++ b/App10p5/.idea/gradle.xml @@ -0,0 +1,19 @@ + + + + + + \ No newline at end of file diff --git a/App10p5/.idea/misc.xml b/App10p5/.idea/misc.xml new file mode 100644 index 0000000..1a3eaff --- /dev/null +++ b/App10p5/.idea/misc.xml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/App10p5/.idea/modules.xml b/App10p5/.idea/modules.xml new file mode 100644 index 0000000..ed1f492 --- /dev/null +++ b/App10p5/.idea/modules.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/App10p5/.idea/runConfigurations.xml b/App10p5/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/App10p5/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/App10p5/.idea/vcs.xml b/App10p5/.idea/vcs.xml new file mode 100644 index 0000000..6564d52 --- /dev/null +++ b/App10p5/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/App10p5/app/.gitignore b/App10p5/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/App10p5/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/App10p5/app/build.gradle b/App10p5/app/build.gradle new file mode 100644 index 0000000..bdae348 --- /dev/null +++ b/App10p5/app/build.gradle @@ -0,0 +1,27 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 23 + buildToolsVersion "23.0.3" + + defaultConfig { + applicationId "net.plil.clubinfo.app10p5" + minSdkVersion 15 + targetSdkVersion 23 + versionCode 1 + versionName "1.0" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + compile fileTree(dir: 'libs', include: ['*.jar']) + testCompile 'junit:junit:4.12' + compile 'com.android.support:appcompat-v7:23.2.1' + compile 'com.android.support:design:23.2.1' +} diff --git a/App10p5/app/proguard-rules.pro b/App10p5/app/proguard-rules.pro new file mode 100644 index 0000000..6aeb49d --- /dev/null +++ b/App10p5/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 /home/marianne/Applications/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/App10p5/app/src/androidTest/java/net/plil/clubinfo/app10p5/ApplicationTest.java b/App10p5/app/src/androidTest/java/net/plil/clubinfo/app10p5/ApplicationTest.java new file mode 100644 index 0000000..8685071 --- /dev/null +++ b/App10p5/app/src/androidTest/java/net/plil/clubinfo/app10p5/ApplicationTest.java @@ -0,0 +1,13 @@ +package net.plil.clubinfo.app10p5; + +import android.app.Application; +import android.test.ApplicationTestCase; + +/** + * Testing Fundamentals + */ +public class ApplicationTest extends ApplicationTestCase { + public ApplicationTest() { + super(Application.class); + } +} \ No newline at end of file diff --git a/App10p5/app/src/main/AndroidManifest.xml b/App10p5/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..341027e --- /dev/null +++ b/App10p5/app/src/main/AndroidManifest.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/App10p5/app/src/main/java/net/plil/clubinfo/app10p5/MainActivity.java b/App10p5/app/src/main/java/net/plil/clubinfo/app10p5/MainActivity.java new file mode 100644 index 0000000..6e5593a --- /dev/null +++ b/App10p5/app/src/main/java/net/plil/clubinfo/app10p5/MainActivity.java @@ -0,0 +1,126 @@ +package net.plil.clubinfo.app10p5; + +import android.app.PendingIntent; +import android.content.Intent; +import android.content.IntentFilter; +import android.nfc.NfcAdapter; +import android.nfc.tech.NfcA; +import android.os.Bundle; +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.view.Menu; +import android.view.MenuItem; +import android.view.View; + +public class MainActivity extends AppCompatActivity { + + private NfcAdapter mNfcAdapter; + private PendingIntent mPendingIntent; + private IntentFilter[] mFilters; + private String[][] mTechLists; + + public void onResume() { + super.onResume(); + if(mNfcAdapter != null) + mNfcAdapter.enableForegroundDispatch(this, mPendingIntent, mFilters, mTechLists); + } + + // Convertit l'array de byte en chaîne hexadécimale. + private String ByteArrayToHexString(byte [] inarray) { + int i, j, in; + String [] hex = {"0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"}; + String out= ""; + for(j = 0 ; j < inarray.length ; ++j) + { + in = (int) inarray[j] & 0xff; + i = (in >> 4) & 0x0f; + out += hex[i]; + i = in & 0x0f; + out += hex[i]; + } + return out; + } + + //La fonction se lance une fois au démarrage de l'application. + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); + setSupportActionBar(toolbar); + + FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); + fab.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) + .setAction("Action", null).show(); + } + }); + + ////Code NFC -- Nécessaire + mNfcAdapter = NfcAdapter.getDefaultAdapter(this); + + mPendingIntent = PendingIntent.getActivity(this, 0, + new Intent(this, getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0); + + IntentFilter ndef = new IntentFilter(NfcAdapter.ACTION_TECH_DISCOVERED); + + try { + ndef.addDataType("text/plain"); + } catch (IntentFilter.MalformedMimeTypeException e) { + throw new RuntimeException("fail", e); + } + mFilters = new IntentFilter[] { + ndef, + }; + + // Setup a tech list for all NfcF tags + mTechLists = new String[][]{new String[]{NfcA.class.getName()}}; + } + + @Override + public void onNewIntent(Intent intent) { + if (NfcAdapter.ACTION_TECH_DISCOVERED.equals(intent.getAction())) { + String id_carte = ByteArrayToHexString(intent.getByteArrayExtra(NfcAdapter.EXTRA_ID)); + System.out.println("NFC Tag : " + id_carte); + taFonction(id_carte); + } + } + + public void taFonction(String id_carte) + { + //code fonction + } + + @Override + public void onPause() { + super.onPause(); + if(mNfcAdapter != null) + mNfcAdapter.disableForegroundDispatch(this); + } + + @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); + } +} diff --git a/App10p5/app/src/main/res/layout/activity_main.xml b/App10p5/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..65b7f15 --- /dev/null +++ b/App10p5/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + diff --git a/App10p5/app/src/main/res/layout/content_main.xml b/App10p5/app/src/main/res/layout/content_main.xml new file mode 100644 index 0000000..f274141 --- /dev/null +++ b/App10p5/app/src/main/res/layout/content_main.xml @@ -0,0 +1,19 @@ + + + + + diff --git a/App10p5/app/src/main/res/menu/menu_main.xml b/App10p5/app/src/main/res/menu/menu_main.xml new file mode 100644 index 0000000..34859b0 --- /dev/null +++ b/App10p5/app/src/main/res/menu/menu_main.xml @@ -0,0 +1,10 @@ + + + diff --git a/App10p5/app/src/main/res/mipmap-hdpi/ic_launcher.png b/App10p5/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..cde69bc Binary files /dev/null and b/App10p5/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/App10p5/app/src/main/res/mipmap-mdpi/ic_launcher.png b/App10p5/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..c133a0c Binary files /dev/null and b/App10p5/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/App10p5/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/App10p5/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..bfa42f0 Binary files /dev/null and b/App10p5/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/App10p5/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/App10p5/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..324e72c Binary files /dev/null and b/App10p5/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/App10p5/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/App10p5/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..aee44e1 Binary files /dev/null and b/App10p5/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/App10p5/app/src/main/res/values-v21/styles.xml b/App10p5/app/src/main/res/values-v21/styles.xml new file mode 100644 index 0000000..251fb9f --- /dev/null +++ b/App10p5/app/src/main/res/values-v21/styles.xml @@ -0,0 +1,9 @@ +> + + + diff --git a/App10p5/app/src/main/res/values-w820dp/dimens.xml b/App10p5/app/src/main/res/values-w820dp/dimens.xml new file mode 100644 index 0000000..63fc816 --- /dev/null +++ b/App10p5/app/src/main/res/values-w820dp/dimens.xml @@ -0,0 +1,6 @@ + + + 64dp + diff --git a/App10p5/app/src/main/res/values/colors.xml b/App10p5/app/src/main/res/values/colors.xml new file mode 100644 index 0000000..3ab3e9c --- /dev/null +++ b/App10p5/app/src/main/res/values/colors.xml @@ -0,0 +1,6 @@ + + + #3F51B5 + #303F9F + #FF4081 + diff --git a/App10p5/app/src/main/res/values/dimens.xml b/App10p5/app/src/main/res/values/dimens.xml new file mode 100644 index 0000000..812cb7b --- /dev/null +++ b/App10p5/app/src/main/res/values/dimens.xml @@ -0,0 +1,6 @@ + + + 16dp + 16dp + 16dp + diff --git a/App10p5/app/src/main/res/values/strings.xml b/App10p5/app/src/main/res/values/strings.xml new file mode 100644 index 0000000..0911c51 --- /dev/null +++ b/App10p5/app/src/main/res/values/strings.xml @@ -0,0 +1,4 @@ + + App10p5 + Settings + diff --git a/App10p5/app/src/main/res/values/styles.xml b/App10p5/app/src/main/res/values/styles.xml new file mode 100644 index 0000000..545b9c6 --- /dev/null +++ b/App10p5/app/src/main/res/values/styles.xml @@ -0,0 +1,20 @@ + + + + + + + +