You are on page 1of 11

Morse code translator

Mobile Application Development (22617)

INDEX
Sr. No Topic Page no.
1 Rationale

2 Aims/Benefits of the Micro-Project

3 Course Outcomes Addressed

4 Objective

5 Resource Used

6 Application UI

7 Xml code

8 Java code

9 Working of Application

10 Conclusion
Morse code Translator

1.0 Rationale:-
The rationale behind developing a Morse code translator Android micro
project lies in several factors. Firstly, Morse code, despite its age, still holds
relevance today, particularly in scenarios where communication needs to
occur in environments with limited resources or through non-verbal
means. By creating a mobile app that translates text to Morse code and vice
versa, users can leverage this universal encoding system for communication
in various situations, such as emergency signaling, language barriers, or
even as a fun educational tool.

2.0 Aims/Benefits of the Micro-Project:-


Aim:-
The aim of the Morse code translator Android micro project is to
develop a user-friendly mobile application that facilitates seamless
translation between text and Morse code. Through this project, our goal is
to provide users with a practical tool for communication that harnesses the
simplicity and universality of Morse code. By enabling users to input text
and receive its Morse code equivalent, as well as input Morse code and
receive its corresponding text, the app aims to bridge language barriers and
facilitate communication in various contexts.

Benefits:-
1. Communication Flexibility
2. Educational Tool
3. Practical Utility
4. Mobile Accessibility
5. Promotes Innovation
6. Contributes to Accessibility
7. Historical Preservation

3.0 Course Outcomes Addressed:-


The Morse code translator Android micro project addresses several course
outcomes related to mobile app development, communication systems, and
problem-solving skills. Firstly, it demonstrates proficiency in mobile app
development by applying concepts such as user interface design, event
handling, and data processing to create a functional and intuitive
application. Through the implementation of Morse code translation
algorithms, the project reinforces understanding of data encoding and
decoding techniques, emphasizing the importance of efficient
communication systems in various contexts. Additionally, by handling user
input and validating data, the project showcases skills in error handling and
user experience optimization, ensuring robustness and usability of the
application.

4.0 Objective:-
The objective of the Morse code translator Android micro project is to
develop a mobile application that facilitates efficient translation between
text and Morse code, aiming to provide users with a versatile tool for
communication and learning. By creating an intuitive user interface and
implementing robust translation algorithms, the project seeks to enable
users to easily encode and decode messages using Morse code on their
Android devices. Through this project, the primary goal is to promote
awareness and understanding of Morse code as a historic communication
method, while also showcasing proficiency in mobile app development
principles and techniques.

5.0 Resource Used:-


Sr. Name of Resource Broad Specification Quantity
No.
1 Computer system i5 Processor | 8GB Ram ---
2 Operation system Windows 11 ---
3 Development software Android studio ---
6.0 Application UI:-
7.0 Xml code:-
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:padding="1dp">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/backg"
android:scaleType="centerCrop"/>
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="5dp">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Morse Code Translator"
android:textSize="20dp"
android:textStyle="bold"
android:textColor="#493939"/>

<EditText
android:id="@+id/inputText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textMultiLine"
android:gravity="top|start"
android:lines="10"
android:padding="15dp"
android:background="#AD6C7FA3"
android:maxLines="100"
android:scrollbars="vertical"
android:hint="Enter text to translate..."
android:layout_marginTop="100dp"
android:textColorHint="#D5605656"
android:layout_marginBottom="8dp"/>

<Button
android:id="@+id/translateButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:text="Translate"
android:backgroundTint="#7E4C5D"/>

<ScrollView
android:layout_width="match_parent"
android:layout_height="300dp"
android:background="#9038363C"
>
<TextView
android:id="@+id/outputText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="25dp"
android:padding="15dp"
android:textIsSelectable="true"
android:textColor="#D3B9D3"
android:layout_marginTop="16dp"/>
</ScrollView>

</LinearLayout>

</ScrollView>

</RelativeLayout>

8.0 Java code:-


import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import java.util.HashMap;

public class MainActivity extends AppCompatActivity {

private EditText inputText;


//private Button translateButton;
private TextView outputText;
TextView opt;
private HashMap<Character, String> morseMap;

private Button btn;


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
inputText = findViewById(R.id.inputText);
btn = findViewById(R.id.translateButton);
outputText = findViewById(R.id.outputText);

morseMap = new HashMap<>();


// Define Morse code mappings

morseMap.put('A', ".-");
morseMap.put('B', "-...");
morseMap.put('C', "-.-.");
morseMap.put('D', "-..");
morseMap.put('E', ".");
morseMap.put('F', "..-.");
morseMap.put('G', "--.");
morseMap.put('H', "....");
morseMap.put('I', "..");
morseMap.put('J', ".---");
morseMap.put('K', "-.-");
morseMap.put('L', ".-..");
morseMap.put('M', "--");
morseMap.put('N', "-.");
morseMap.put('O', "---");
morseMap.put('P', ".--.");
morseMap.put('Q', "--.-");
morseMap.put('R', ".-.");
morseMap.put('S', "...");
morseMap.put('T', "-");
morseMap.put('U', "..-");
morseMap.put('V', "...-");
morseMap.put('W', ".--");
morseMap.put('X', "-..-");
morseMap.put('Y', "-.--");
morseMap.put('Z', "--..");
// Numbers
morseMap.put('0', "-----");
morseMap.put('1', ".----");
morseMap.put('2', "..---");
morseMap.put('3', "...--");
morseMap.put('4', "....-");
morseMap.put('5', ".....");
morseMap.put('6', "-....");
morseMap.put('7', "--...");
morseMap.put('8', "---..");
morseMap.put('9', "----.");

// Punctuation and special characters


morseMap.put('.', ".-.-.-"); // Period
morseMap.put(',', "--..--"); // Comma
morseMap.put('?', "..--.."); // Question mark
morseMap.put('\'', ".----."); // Apostrophe
morseMap.put('!', "-.-.--"); // Exclamation mark
morseMap.put('/', "-..-."); // Slash
morseMap.put('(', "-.--."); // Left parenthesis
morseMap.put(')', "-.--.-"); // Right parenthesis
morseMap.put('&', ".-..."); // Ampersand
morseMap.put(':', "---..."); // Colon
morseMap.put(';', "-.-.-."); // Semicolon
morseMap.put('=', "-...-"); // Equal sign
morseMap.put('+', ".-.-."); // Plus sign
morseMap.put('-', "-....-"); // Hyphen
morseMap.put('_', "..--.-"); // Underscore
morseMap.put('"', ".-..-."); // Quotation mark
morseMap.put('$', "...-..-"); // Dollar sign
morseMap.put('@', ".--.-.");
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String input =
inputText.getText().toString().toUpperCase();
String output = translateToMorse(input);
outputText.setText(output);
}
});
}

private String translateToMorse(String text) {


StringBuilder morseCode = new StringBuilder();
for (int i = 0; i < text.length(); i++) {
char c = text.charAt(i);
if (morseMap.containsKey(c)) {
morseCode.append(morseMap.get(c)).append(" ");
} else {
morseCode.append(" "); // Three spaces for word
separation
}
}
return morseCode.toString();
}
}

9.0 Working of Application :-


The Morse code translator Android application functions by providing
users with a straightforward interface to translate text to Morse code and
vice versa. Upon launching the app, users are presented with input fields
where they can enter either regular text or Morse code, depending on their
desired mode of communication. Once the input is provided, users initiate
the translation process by tapping a designated button.
If the user inputs regular text, the application employs an algorithm to
convert each character of the text into its corresponding Morse code
representation, following the established Morse code conventions. This
translated Morse code is then displayed in the output field for the user to
view and utilize as needed.

Conclusion
In conclusion, the Morse code translator Android micro project represents
a successful endeavor in mobile app development, communication systems,
and problem-solving. Through the creation of this application, we have
achieved our objective of providing users with a versatile tool for
translating text to Morse code and vice versa. The project's intuitive user
interface facilitates seamless interaction, allowing users to easily encode
and decode messages using Morse code on their Android devices. By
implementing robust translation algorithms and incorporating error
handling mechanisms, we have ensured the accuracy and reliability of the
application's functionality. Users can rely on the Morse code translator app
to accurately translate their messages, whether they are communicating in
Morse code or converting Morse code back into regular text.

You might also like