From 521c7ed4a01e9494fd0edc00b0aa6b581b4ffc76 Mon Sep 17 00:00:00 2001 From: ZineeEddine Date: Wed, 15 Feb 2023 14:52:14 +0100 Subject: [PATCH 1/6] Add_Activity_Morse_Activity_with_Translator --- app/build.gradle | 2 + app/src/main/AndroidManifest.xml | 399 ++++++++---------- .../flashlight/MorseFlashActivity.kt | 95 +++++ .../flashlight/activities/MainActivity.kt | 6 + app/src/main/res/drawable/ic_morse.xml | 36 ++ app/src/main/res/layout/activity_main.xml | 12 + .../main/res/layout/activity_morse_flash.xml | 49 +++ build.gradle | 2 +- 8 files changed, 388 insertions(+), 213 deletions(-) create mode 100644 app/src/main/java/com/simplemobiletools/flashlight/MorseFlashActivity.kt create mode 100644 app/src/main/res/drawable/ic_morse.xml create mode 100644 app/src/main/res/layout/activity_morse_flash.xml diff --git a/app/build.gradle b/app/build.gradle index 4286e810..3676ac02 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -65,4 +65,6 @@ dependencies { implementation 'com.github.SimpleMobileTools:Simple-Commons:8bcb4d3851' implementation 'org.greenrobot:eventbus:3.3.1' implementation 'androidx.constraintlayout:constraintlayout:2.1.4' + implementation 'androidx.appcompat:appcompat:1.6.1' + implementation 'com.google.android.material:material:1.4.0' } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 0043c09e..6a937b86 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -7,9 +7,7 @@ - - @@ -26,7 +24,10 @@ android:roundIcon="@mipmap/ic_launcher" android:supportsRtl="true" android:theme="@style/AppTheme"> - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + - + - - + - - + - - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/java/com/simplemobiletools/flashlight/MorseFlashActivity.kt b/app/src/main/java/com/simplemobiletools/flashlight/MorseFlashActivity.kt new file mode 100644 index 00000000..fc405fa6 --- /dev/null +++ b/app/src/main/java/com/simplemobiletools/flashlight/MorseFlashActivity.kt @@ -0,0 +1,95 @@ +package com.simplemobiletools.flashlight + +import androidx.appcompat.app.AppCompatActivity +import android.os.Bundle +import android.widget.EditText +import kotlinx.android.synthetic.main.activity_morse_flash.* + +class MorseFlashActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_morse_flash) + + + val editText_InputUser = findViewById(R.id.editText_User) + + val morseAlphabet = mapOf( + // les minuscule + + 'a' to ".-", + 'b' to "-...", + 'c' to "-.-.", + 'd' to "-..", + 'e' to ".", + 'f' to "..-.", + 'g' to "--.", + 'h' to "....", + 'i' to "..", + 'j' to ".---", + 'k' to "-.-", + 'l' to ".-..", + 'm' to "--", + 'n' to "-.", + 'o' to "---", + 'p' to ".--.", + 'q' to "--.-", + 'r' to ".-.", + 's' to "...", + 't' to "-", + 'u' to "..-", + 'v' to "...-", + 'w' to ".--", + 'x' to "-..-", + 'y' to "-.--", + 'z' to "--..", + // les majuscules + 'A' to ".-", + 'B' to "-...", + 'C' to "-.-.", + 'D' to "-..", + 'E' to ".", + 'F' to "..-.", + 'G' to "--.", + 'H' to "....", + 'I' to "..", + 'J' to ".---", + 'K' to "-.-", + 'L' to ".-..", + 'M' to "--", + 'N' to "-.", + 'O' to "---", + 'P' to ".--.", + 'Q' to "--.-", + 'R' to ".-.", + 'S' to "...", + 'T' to "-", + 'U' to "..-", + 'V' to "...-", + 'W' to ".--", + 'X' to "-..-", + 'Y' to "-.--", + 'Z' to "--..", + // les nombres + '1' to ".----", + '2' to "..---", + '3' to "...--", + '4' to "....-", + '5' to ".....", + '6' to "-....", + '7' to "--...", + '8' to "---..", + '9' to "----.", + '0' to "-----" + ) + // Lors de l'appuie sur le bouton le texte de l'user est traduit en Morse + //RESTE A UTILISER LA TRADUCTION DES . et des -, POUR UTILISER LE FLASH + + button_morseFlash.setOnClickListener{ + val text_user = editText_InputUser.text + System.out.println(text_user) + val result = text_user.map { if (it == ' ') "/" else morseAlphabet[it] }.joinToString(" ") + System.out.println(result) + textView_translation.setText(result) + } + } +} diff --git a/app/src/main/kotlin/com/simplemobiletools/flashlight/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/flashlight/activities/MainActivity.kt index 1313ed1c..a3b1f682 100644 --- a/app/src/main/kotlin/com/simplemobiletools/flashlight/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/flashlight/activities/MainActivity.kt @@ -16,6 +16,7 @@ import com.simplemobiletools.commons.helpers.isNougatMR1Plus import com.simplemobiletools.commons.helpers.isNougatPlus import com.simplemobiletools.commons.models.FAQItem import com.simplemobiletools.flashlight.BuildConfig +import com.simplemobiletools.flashlight.MorseFlashActivity import com.simplemobiletools.flashlight.R import com.simplemobiletools.flashlight.extensions.config import com.simplemobiletools.flashlight.helpers.CameraTorchListener @@ -65,6 +66,11 @@ class MainActivity : SimpleActivity() { toggleStroboscope(true) } + morse_btn.setOnClickListener { + System.out.println("Ouverture de l'Activité MORSE CODE FLASH") + startActivity(Intent(applicationContext, MorseFlashActivity::class.java)) + } + stroboscope_btn.setOnClickListener { toggleStroboscope(false) } diff --git a/app/src/main/res/drawable/ic_morse.xml b/app/src/main/res/drawable/ic_morse.xml new file mode 100644 index 00000000..d2e54ebd --- /dev/null +++ b/app/src/main/res/drawable/ic_morse.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 1547162d..6bc47d2a 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -83,6 +83,18 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/sos_btn" /> + + + + + + + + + + + + + + +