diff --git a/TP05/EX01_Reticule/.gitignore b/TP05/EX01_Reticule/.gitignore new file mode 100644 index 0000000..aa724b7 --- /dev/null +++ b/TP05/EX01_Reticule/.gitignore @@ -0,0 +1,15 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/TP05/EX01_Reticule/.idea/.gitignore b/TP05/EX01_Reticule/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/TP05/EX01_Reticule/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/TP05/EX01_Reticule/.idea/.name b/TP05/EX01_Reticule/.idea/.name new file mode 100644 index 0000000..fe46826 --- /dev/null +++ b/TP05/EX01_Reticule/.idea/.name @@ -0,0 +1 @@ +TP05EX01_Reticule \ No newline at end of file diff --git a/TP05/EX01_Reticule/.idea/compiler.xml b/TP05/EX01_Reticule/.idea/compiler.xml new file mode 100644 index 0000000..b589d56 --- /dev/null +++ b/TP05/EX01_Reticule/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/TP05/EX01_Reticule/.idea/gradle.xml b/TP05/EX01_Reticule/.idea/gradle.xml new file mode 100644 index 0000000..a2d7c21 --- /dev/null +++ b/TP05/EX01_Reticule/.idea/gradle.xml @@ -0,0 +1,19 @@ + + + + + + + \ No newline at end of file diff --git a/TP05/EX01_Reticule/.idea/misc.xml b/TP05/EX01_Reticule/.idea/misc.xml new file mode 100644 index 0000000..773fe0f --- /dev/null +++ b/TP05/EX01_Reticule/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/TP05/EX01_Reticule/.idea/vcs.xml b/TP05/EX01_Reticule/.idea/vcs.xml new file mode 100644 index 0000000..b2bdec2 --- /dev/null +++ b/TP05/EX01_Reticule/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/TP05/EX01_Reticule/app/.gitignore b/TP05/EX01_Reticule/app/.gitignore new file mode 100644 index 0000000..42afabf --- /dev/null +++ b/TP05/EX01_Reticule/app/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/TP05/EX01_Reticule/app/build.gradle b/TP05/EX01_Reticule/app/build.gradle new file mode 100644 index 0000000..d871754 --- /dev/null +++ b/TP05/EX01_Reticule/app/build.gradle @@ -0,0 +1,40 @@ +plugins { + id 'com.android.application' +} + +android { + namespace 'fr.iutfbleau.wamster.dev45.tp05ex01_reticule' + compileSdk 33 + + defaultConfig { + applicationId "fr.iutfbleau.wamster.dev45.tp05ex01_reticule" + minSdk 19 + targetSdk 33 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + buildToolsVersion '34.0.0' +} + +dependencies { + + implementation 'androidx.appcompat:appcompat:1.6.1' + implementation 'com.google.android.material:material:1.5.0' + implementation 'androidx.constraintlayout:constraintlayout:2.1.4' + testImplementation 'junit:junit:4.13.2' + androidTestImplementation 'androidx.test.ext:junit:1.1.5' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' +} \ No newline at end of file diff --git a/TP05/EX01_Reticule/app/proguard-rules.pro b/TP05/EX01_Reticule/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /dev/null +++ b/TP05/EX01_Reticule/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# 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 *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/TP05/EX01_Reticule/app/src/androidTest/java/fr/iutfbleau/wamster/dev45/tp05ex01_reticule/ExampleInstrumentedTest.java b/TP05/EX01_Reticule/app/src/androidTest/java/fr/iutfbleau/wamster/dev45/tp05ex01_reticule/ExampleInstrumentedTest.java new file mode 100644 index 0000000..ae22a7a --- /dev/null +++ b/TP05/EX01_Reticule/app/src/androidTest/java/fr/iutfbleau/wamster/dev45/tp05ex01_reticule/ExampleInstrumentedTest.java @@ -0,0 +1,26 @@ +package fr.iutfbleau.wamster.dev45.tp05ex01_reticule; + +import android.content.Context; + +import androidx.test.platform.app.InstrumentationRegistry; +import androidx.test.ext.junit.runners.AndroidJUnit4; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.junit.Assert.*; + +/** + * Instrumented test, which will execute on an Android device. + * + * @see Testing documentation + */ +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + @Test + public void useAppContext() { + // Context of the app under test. + Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); + assertEquals("fr.iutfbleau.wamster.dev45.tp05ex01_reticule", appContext.getPackageName()); + } +} \ No newline at end of file diff --git a/TP05/EX01_Reticule/app/src/main/AndroidManifest.xml b/TP05/EX01_Reticule/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..659fd64 --- /dev/null +++ b/TP05/EX01_Reticule/app/src/main/AndroidManifest.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/TP05/EX01_Reticule/app/src/main/java/fr/iutfbleau/wamster/dev45/tp05ex01_reticule/Dessin.java b/TP05/EX01_Reticule/app/src/main/java/fr/iutfbleau/wamster/dev45/tp05ex01_reticule/Dessin.java new file mode 100644 index 0000000..608d79f --- /dev/null +++ b/TP05/EX01_Reticule/app/src/main/java/fr/iutfbleau/wamster/dev45/tp05ex01_reticule/Dessin.java @@ -0,0 +1,55 @@ +package fr.iutfbleau.wamster.dev45.tp05ex01_reticule; + +import android.content.Context; +import android.graphics.Canvas; +import android.graphics.Paint; +import android.graphics.Path; +import android.util.AttributeSet; +import android.view.View; + +public class Dessin extends View { + private float rayon; + private float x; + private float y; + private final Paint pinceau; + public Dessin(Context context, AttributeSet attrs) { + super(context, attrs); + this.pinceau = new Paint(); + this.pinceau.setStyle(Paint.Style.STROKE); + this.pinceau.setStrokeWidth(20.0f); + this.pinceau.setColor(0xfffc6600); + this.rayon = 100f; + this.x = -1; + this.y = -1; + } + + public void addVecteur(float x, float y){ + this.x += x; + this.y += y; + this.invalidate(); + } + public void setCoordonnee(float x, float y){ + this.x = x; + this.y = y; + this.invalidate(); + } + public float getX(){ + return this.x; + } + public float getY(){ + return this.y; + } + + @Override + public void onDraw(Canvas canvas){ + if (this.x < 0){ + this.x = getWidth()/2f; + } + if (this.y < 0){ + this.y = getHeight()/2f; + } + canvas.drawCircle(this.x, this.y, this.rayon, this.pinceau); + canvas.drawLine(this.x,this.y-(1.5f*this.rayon), this.x, this.y+(1.5f*this.rayon), this.pinceau); + canvas.drawLine(this.x-(1.5f*this.rayon),this.y, this.x+(1.5f*this.rayon), this.y, this.pinceau); + } +} diff --git a/TP05/EX01_Reticule/app/src/main/java/fr/iutfbleau/wamster/dev45/tp05ex01_reticule/Evenement.java b/TP05/EX01_Reticule/app/src/main/java/fr/iutfbleau/wamster/dev45/tp05ex01_reticule/Evenement.java new file mode 100644 index 0000000..78a1af2 --- /dev/null +++ b/TP05/EX01_Reticule/app/src/main/java/fr/iutfbleau/wamster/dev45/tp05ex01_reticule/Evenement.java @@ -0,0 +1,53 @@ +package fr.iutfbleau.wamster.dev45.tp05ex01_reticule; + +import android.util.Log; +import android.view.MotionEvent; +import android.view.View; + +public class Evenement implements View.OnTouchListener{ + + private Dessin dessin; + private boolean mouvementEnCours; + private float debutX; + private float debutY; + + public Evenement(Dessin dessin){ + this.dessin = dessin; + this.mouvementEnCours = false; + } + + @Override + public boolean onTouch(View v, MotionEvent event) { + int action = event.getActionMasked(); + + switch (action) { + case MotionEvent.ACTION_DOWN: + this.debutX = event.getX(); + this.debutY = event.getY(); + this.mouvementEnCours = true; + break; + + case MotionEvent.ACTION_POINTER_DOWN: + this.mouvementEnCours = false; + break; + + case MotionEvent.ACTION_MOVE: + if (this.mouvementEnCours){ + float dx = event.getX()- this.debutX; + float dy = event.getY()- this.debutY; + this.debutX = event.getX(); + this.debutY = event.getY(); + this.dessin.addVecteur(dx, dy); + } + break; + + case MotionEvent.ACTION_UP: + this.mouvementEnCours = false; + break; + case MotionEvent.ACTION_CANCEL: + this.mouvementEnCours = false; + break; + } + return true; + } +} diff --git a/TP05/EX01_Reticule/app/src/main/java/fr/iutfbleau/wamster/dev45/tp05ex01_reticule/MainActivity.java b/TP05/EX01_Reticule/app/src/main/java/fr/iutfbleau/wamster/dev45/tp05ex01_reticule/MainActivity.java new file mode 100644 index 0000000..a080c3a --- /dev/null +++ b/TP05/EX01_Reticule/app/src/main/java/fr/iutfbleau/wamster/dev45/tp05ex01_reticule/MainActivity.java @@ -0,0 +1,32 @@ +package fr.iutfbleau.wamster.dev45.tp05ex01_reticule; + +import androidx.appcompat.app.AppCompatActivity; + +import android.os.Bundle; + +public class MainActivity extends AppCompatActivity { + private Dessin dessin; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + + this.dessin = findViewById(R.id.zoneDeDessin); + Evenement ecouteurDoigt = new Evenement(this.dessin); + this.dessin.setOnTouchListener(ecouteurDoigt); + } + + @Override + protected void onSaveInstanceState(Bundle outState) { + super.onSaveInstanceState(outState); + outState.putFloat("x",this.dessin.getX()); + outState.putFloat("y",this.dessin.getY()); + } + + @Override + protected void onRestoreInstanceState(Bundle inState) { + super.onSaveInstanceState(inState); + this.dessin.setCoordonnee(inState.getFloat("x",-1), inState.getFloat("y",-1)); + } +} \ No newline at end of file diff --git a/TP05/EX01_Reticule/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/TP05/EX01_Reticule/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/TP05/EX01_Reticule/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/TP05/EX01_Reticule/app/src/main/res/drawable/ic_launcher_background.xml b/TP05/EX01_Reticule/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/TP05/EX01_Reticule/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/TP05/EX01_Reticule/app/src/main/res/layout/activity_main.xml b/TP05/EX01_Reticule/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..4c9a1bc --- /dev/null +++ b/TP05/EX01_Reticule/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,14 @@ + + + + + + \ No newline at end of file diff --git a/TP05/EX01_Reticule/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/TP05/EX01_Reticule/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..6f3b755 --- /dev/null +++ b/TP05/EX01_Reticule/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/TP05/EX01_Reticule/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/TP05/EX01_Reticule/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..6f3b755 --- /dev/null +++ b/TP05/EX01_Reticule/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/TP05/EX01_Reticule/app/src/main/res/mipmap-hdpi/ic_launcher.webp b/TP05/EX01_Reticule/app/src/main/res/mipmap-hdpi/ic_launcher.webp new file mode 100644 index 0000000..c209e78 Binary files /dev/null and b/TP05/EX01_Reticule/app/src/main/res/mipmap-hdpi/ic_launcher.webp differ diff --git a/TP05/EX01_Reticule/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/TP05/EX01_Reticule/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp new file mode 100644 index 0000000..b2dfe3d Binary files /dev/null and b/TP05/EX01_Reticule/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp differ diff --git a/TP05/EX01_Reticule/app/src/main/res/mipmap-mdpi/ic_launcher.webp b/TP05/EX01_Reticule/app/src/main/res/mipmap-mdpi/ic_launcher.webp new file mode 100644 index 0000000..4f0f1d6 Binary files /dev/null and b/TP05/EX01_Reticule/app/src/main/res/mipmap-mdpi/ic_launcher.webp differ diff --git a/TP05/EX01_Reticule/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/TP05/EX01_Reticule/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp new file mode 100644 index 0000000..62b611d Binary files /dev/null and b/TP05/EX01_Reticule/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp differ diff --git a/TP05/EX01_Reticule/app/src/main/res/mipmap-xhdpi/ic_launcher.webp b/TP05/EX01_Reticule/app/src/main/res/mipmap-xhdpi/ic_launcher.webp new file mode 100644 index 0000000..948a307 Binary files /dev/null and b/TP05/EX01_Reticule/app/src/main/res/mipmap-xhdpi/ic_launcher.webp differ diff --git a/TP05/EX01_Reticule/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/TP05/EX01_Reticule/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..1b9a695 Binary files /dev/null and b/TP05/EX01_Reticule/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp differ diff --git a/TP05/EX01_Reticule/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/TP05/EX01_Reticule/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp new file mode 100644 index 0000000..28d4b77 Binary files /dev/null and b/TP05/EX01_Reticule/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp differ diff --git a/TP05/EX01_Reticule/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/TP05/EX01_Reticule/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..9287f50 Binary files /dev/null and b/TP05/EX01_Reticule/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp differ diff --git a/TP05/EX01_Reticule/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/TP05/EX01_Reticule/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp new file mode 100644 index 0000000..aa7d642 Binary files /dev/null and b/TP05/EX01_Reticule/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp differ diff --git a/TP05/EX01_Reticule/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/TP05/EX01_Reticule/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..9126ae3 Binary files /dev/null and b/TP05/EX01_Reticule/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp differ diff --git a/TP05/EX01_Reticule/app/src/main/res/values-night/themes.xml b/TP05/EX01_Reticule/app/src/main/res/values-night/themes.xml new file mode 100644 index 0000000..b0cadcb --- /dev/null +++ b/TP05/EX01_Reticule/app/src/main/res/values-night/themes.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/TP05/EX01_Reticule/app/src/main/res/values/colors.xml b/TP05/EX01_Reticule/app/src/main/res/values/colors.xml new file mode 100644 index 0000000..c8524cd --- /dev/null +++ b/TP05/EX01_Reticule/app/src/main/res/values/colors.xml @@ -0,0 +1,5 @@ + + + #FF000000 + #FFFFFFFF + \ No newline at end of file diff --git a/TP05/EX01_Reticule/app/src/main/res/values/strings.xml b/TP05/EX01_Reticule/app/src/main/res/values/strings.xml new file mode 100644 index 0000000..943eb75 --- /dev/null +++ b/TP05/EX01_Reticule/app/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + TP05EX01_Reticule + \ No newline at end of file diff --git a/TP05/EX01_Reticule/app/src/main/res/values/themes.xml b/TP05/EX01_Reticule/app/src/main/res/values/themes.xml new file mode 100644 index 0000000..1c02994 --- /dev/null +++ b/TP05/EX01_Reticule/app/src/main/res/values/themes.xml @@ -0,0 +1,9 @@ + + + + + + \ No newline at end of file diff --git a/TP05/EX02_ArcEnCiel/app/src/main/res/values/colors.xml b/TP05/EX02_ArcEnCiel/app/src/main/res/values/colors.xml new file mode 100644 index 0000000..c8524cd --- /dev/null +++ b/TP05/EX02_ArcEnCiel/app/src/main/res/values/colors.xml @@ -0,0 +1,5 @@ + + + #FF000000 + #FFFFFFFF + \ No newline at end of file diff --git a/TP05/EX02_ArcEnCiel/app/src/main/res/values/strings.xml b/TP05/EX02_ArcEnCiel/app/src/main/res/values/strings.xml new file mode 100644 index 0000000..8397920 --- /dev/null +++ b/TP05/EX02_ArcEnCiel/app/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + TP05EX02_ArcEnCiel + \ No newline at end of file diff --git a/TP05/EX02_ArcEnCiel/app/src/main/res/values/themes.xml b/TP05/EX02_ArcEnCiel/app/src/main/res/values/themes.xml new file mode 100644 index 0000000..b041b43 --- /dev/null +++ b/TP05/EX02_ArcEnCiel/app/src/main/res/values/themes.xml @@ -0,0 +1,9 @@ + + + + +