diff --git a/TP06/EX01_Desoxyribonucleique/.gitignore b/TP06/EX01_Desoxyribonucleique/.gitignore new file mode 100644 index 0000000..aa724b7 --- /dev/null +++ b/TP06/EX01_Desoxyribonucleique/.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/TP06/EX01_Desoxyribonucleique/.idea/.gitignore b/TP06/EX01_Desoxyribonucleique/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/TP06/EX01_Desoxyribonucleique/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/TP06/EX01_Desoxyribonucleique/.idea/.name b/TP06/EX01_Desoxyribonucleique/.idea/.name new file mode 100644 index 0000000..df3891f --- /dev/null +++ b/TP06/EX01_Desoxyribonucleique/.idea/.name @@ -0,0 +1 @@ +TP06EX01_Desoxyribonucleique \ No newline at end of file diff --git a/TP06/EX01_Desoxyribonucleique/.idea/compiler.xml b/TP06/EX01_Desoxyribonucleique/.idea/compiler.xml new file mode 100644 index 0000000..b589d56 --- /dev/null +++ b/TP06/EX01_Desoxyribonucleique/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/TP06/EX01_Desoxyribonucleique/.idea/gradle.xml b/TP06/EX01_Desoxyribonucleique/.idea/gradle.xml new file mode 100644 index 0000000..a2d7c21 --- /dev/null +++ b/TP06/EX01_Desoxyribonucleique/.idea/gradle.xml @@ -0,0 +1,19 @@ + + + + + + + \ No newline at end of file diff --git a/TP06/EX01_Desoxyribonucleique/.idea/misc.xml b/TP06/EX01_Desoxyribonucleique/.idea/misc.xml new file mode 100644 index 0000000..773fe0f --- /dev/null +++ b/TP06/EX01_Desoxyribonucleique/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/TP06/EX01_Desoxyribonucleique/.idea/vcs.xml b/TP06/EX01_Desoxyribonucleique/.idea/vcs.xml new file mode 100644 index 0000000..b2bdec2 --- /dev/null +++ b/TP06/EX01_Desoxyribonucleique/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/TP06/EX01_Desoxyribonucleique/app/.gitignore b/TP06/EX01_Desoxyribonucleique/app/.gitignore new file mode 100644 index 0000000..42afabf --- /dev/null +++ b/TP06/EX01_Desoxyribonucleique/app/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/TP06/EX01_Desoxyribonucleique/app/build.gradle b/TP06/EX01_Desoxyribonucleique/app/build.gradle new file mode 100644 index 0000000..b99162b --- /dev/null +++ b/TP06/EX01_Desoxyribonucleique/app/build.gradle @@ -0,0 +1,40 @@ +plugins { + id 'com.android.application' +} + +android { + namespace 'fr.iutfbleau.dev41.wamster.tp06ex01_desoxyribonucleique' + compileSdk 33 + + defaultConfig { + applicationId "fr.iutfbleau.dev41.wamster.tp06ex01_desoxyribonucleique" + 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/TP06/EX01_Desoxyribonucleique/app/proguard-rules.pro b/TP06/EX01_Desoxyribonucleique/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /dev/null +++ b/TP06/EX01_Desoxyribonucleique/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/TP06/EX01_Desoxyribonucleique/app/src/androidTest/java/fr/iutfbleau/dev41/wamster/tp06ex01_desoxyribonucleique/ExampleInstrumentedTest.java b/TP06/EX01_Desoxyribonucleique/app/src/androidTest/java/fr/iutfbleau/dev41/wamster/tp06ex01_desoxyribonucleique/ExampleInstrumentedTest.java new file mode 100644 index 0000000..23cd964 --- /dev/null +++ b/TP06/EX01_Desoxyribonucleique/app/src/androidTest/java/fr/iutfbleau/dev41/wamster/tp06ex01_desoxyribonucleique/ExampleInstrumentedTest.java @@ -0,0 +1,26 @@ +package fr.iutfbleau.dev41.wamster.tp06ex01_desoxyribonucleique; + +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.dev41.wamster.tp06ex01_desoxyribonucleique", appContext.getPackageName()); + } +} \ No newline at end of file diff --git a/TP06/EX01_Desoxyribonucleique/app/src/main/AndroidManifest.xml b/TP06/EX01_Desoxyribonucleique/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..cbf54f6 --- /dev/null +++ b/TP06/EX01_Desoxyribonucleique/app/src/main/AndroidManifest.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/TP06/EX01_Desoxyribonucleique/app/src/main/java/fr/iutfbleau/dev41/wamster/tp06ex01_desoxyribonucleique/EventButton.java b/TP06/EX01_Desoxyribonucleique/app/src/main/java/fr/iutfbleau/dev41/wamster/tp06ex01_desoxyribonucleique/EventButton.java new file mode 100644 index 0000000..ebf15ec --- /dev/null +++ b/TP06/EX01_Desoxyribonucleique/app/src/main/java/fr/iutfbleau/dev41/wamster/tp06ex01_desoxyribonucleique/EventButton.java @@ -0,0 +1,30 @@ +package fr.iutfbleau.dev41.wamster.tp06ex01_desoxyribonucleique; + +import android.view.View; +import android.widget.Button; +import android.widget.EditText; + +public class EventButton implements View.OnClickListener{ + + private EditText output; + private Button[] listButton; + + public EventButton(Button[] listButton, EditText output){ + this.listButton = listButton; + this.output = output; + } + + @Override + public void onClick(View v){ + for (Button button : listButton) { + if (((Button) v).equals(button)) { + String texteBouton = ((Button) v).getText().toString(); + this.addText(texteBouton); + } + } + } + + public void addText(String text){ + this.output.setText(this.output.getText()+text); + } +} diff --git a/TP06/EX01_Desoxyribonucleique/app/src/main/java/fr/iutfbleau/dev41/wamster/tp06ex01_desoxyribonucleique/MainActivity.java b/TP06/EX01_Desoxyribonucleique/app/src/main/java/fr/iutfbleau/dev41/wamster/tp06ex01_desoxyribonucleique/MainActivity.java new file mode 100644 index 0000000..fa9ad82 --- /dev/null +++ b/TP06/EX01_Desoxyribonucleique/app/src/main/java/fr/iutfbleau/dev41/wamster/tp06ex01_desoxyribonucleique/MainActivity.java @@ -0,0 +1,76 @@ +package fr.iutfbleau.dev41.wamster.tp06ex01_desoxyribonucleique; + +import androidx.appcompat.app.AppCompatActivity; + +import android.content.Intent; +import android.content.SharedPreferences; +import android.os.Bundle; +import android.preference.Preference; +import android.preference.PreferenceFragment; +import android.preference.PreferenceManager; +import android.util.Log; +import android.view.Menu; +import android.view.MenuItem; +import android.widget.Button; +import android.widget.EditText; +import androidx.appcompat.widget.Toolbar; + +public class MainActivity extends AppCompatActivity { + + private Button[] listButton; + private EditText output; + + public static final int BOUTON_A = 0; + public static final int BOUTON_C = 1; + public static final int BOUTON_G = 2; + public static final int BOUTON_T = 3; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + + //ligne de fou + Toolbar toolbar = findViewById(R.id.toolbar); + setSupportActionBar(toolbar); + + this.listButton = new Button[4]; + this.listButton[MainActivity.BOUTON_A] = findViewById(R.id.buttonA); + this.listButton[MainActivity.BOUTON_C] = findViewById(R.id.buttonC); + this.listButton[MainActivity.BOUTON_G] = findViewById(R.id.buttonG); + this.listButton[MainActivity.BOUTON_T] = findViewById(R.id.buttonT); + this.output = findViewById(R.id.output); + + EventButton eventButton = new EventButton(this.listButton, this.output); + for (Button button : this.listButton) { + button.setOnClickListener(eventButton); + } + + SharedPreferences preference = PreferenceManager.getDefaultSharedPreferences(this); + this.listButton[MainActivity.BOUTON_A].setEnabled(preference.getBoolean("buttonA", true)); + this.listButton[MainActivity.BOUTON_C].setEnabled(preference.getBoolean("buttonC", true)); + this.listButton[MainActivity.BOUTON_G].setEnabled(preference.getBoolean("buttonG", true)); + this.listButton[MainActivity.BOUTON_T].setEnabled(preference.getBoolean("buttonT", true)); + } + + @Override + public boolean onCreateOptionsMenu(Menu menu){ + this.getMenuInflater().inflate(R.menu.menu_parametre, menu); + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item){ + int id = item.getItemId(); + if (id == R.id.test){ + Intent intention = new Intent(this, SettingsActivity.class); + intention.putExtra("idBtnA", this.listButton[MainActivity.BOUTON_A].getId()); + intention.putExtra("idBtnC", this.listButton[MainActivity.BOUTON_C].getId()); + intention.putExtra("idBtnG", this.listButton[MainActivity.BOUTON_G].getId()); + intention.putExtra("idBtnT", this.listButton[MainActivity.BOUTON_T].getId()); + this.startActivity(intention); + return true; + } + return super.onOptionsItemSelected(item); + } +} \ No newline at end of file diff --git a/TP06/EX01_Desoxyribonucleique/app/src/main/java/fr/iutfbleau/dev41/wamster/tp06ex01_desoxyribonucleique/ObservateurParametre.java b/TP06/EX01_Desoxyribonucleique/app/src/main/java/fr/iutfbleau/dev41/wamster/tp06ex01_desoxyribonucleique/ObservateurParametre.java new file mode 100644 index 0000000..f6c72d0 --- /dev/null +++ b/TP06/EX01_Desoxyribonucleique/app/src/main/java/fr/iutfbleau/dev41/wamster/tp06ex01_desoxyribonucleique/ObservateurParametre.java @@ -0,0 +1,24 @@ +package fr.iutfbleau.dev41.wamster.tp06ex01_desoxyribonucleique; + +import android.content.SharedPreferences; +import android.util.Log; + +public class ObservateurParametre implements SharedPreferences.OnSharedPreferenceChangeListener { + + private + + public void onSharedPreferenceChanged(SharedPreferences prefs, String key){ + if (key.equals("keyBtnA")){ + Log.v("test", "clic btn A"); + } + else if (key.equals("keyBtnC")){ + Log.v("test", "clic btn C"); + } + else if (key.equals("keyBtnG")){ + Log.v("test", "clic btn G"); + } + else if (key.equals("keyBtnT")){ + Log.v("test", "clic btn T"); + } + } +} \ No newline at end of file diff --git a/TP06/EX01_Desoxyribonucleique/app/src/main/java/fr/iutfbleau/dev41/wamster/tp06ex01_desoxyribonucleique/SettingsActivity.java b/TP06/EX01_Desoxyribonucleique/app/src/main/java/fr/iutfbleau/dev41/wamster/tp06ex01_desoxyribonucleique/SettingsActivity.java new file mode 100644 index 0000000..b4317a7 --- /dev/null +++ b/TP06/EX01_Desoxyribonucleique/app/src/main/java/fr/iutfbleau/dev41/wamster/tp06ex01_desoxyribonucleique/SettingsActivity.java @@ -0,0 +1,24 @@ +package fr.iutfbleau.dev41.wamster.tp06ex01_desoxyribonucleique; + +import androidx.appcompat.app.AppCompatActivity; + +import android.content.SharedPreferences; +import android.os.Bundle; +import android.preference.PreferenceActivity; +import android.preference.PreferenceManager; + +public class SettingsActivity extends PreferenceActivity { + + private ObservateurParametre observateurParametre; + private boolean[] + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + this.addPreferencesFromResource(R.xml.preferences); + + this.observateurParametre = new ObservateurParametre(); + PreferenceManager.setDefaultValues(this, R.xml.preferences, false); + this.getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this.observateurParametre); + } +} \ No newline at end of file diff --git a/TP06/EX01_Desoxyribonucleique/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/TP06/EX01_Desoxyribonucleique/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/TP06/EX01_Desoxyribonucleique/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/TP06/EX01_Desoxyribonucleique/app/src/main/res/drawable/ic_launcher_background.xml b/TP06/EX01_Desoxyribonucleique/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/TP06/EX01_Desoxyribonucleique/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/TP06/EX01_Desoxyribonucleique/app/src/main/res/layout/activity_main.xml b/TP06/EX01_Desoxyribonucleique/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..853ac74 --- /dev/null +++ b/TP06/EX01_Desoxyribonucleique/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,70 @@ + + + + + + + + +