Skip to content

Commit

Permalink
removed warnings, restructured code in p7
Browse files Browse the repository at this point in the history
  • Loading branch information
Raghuvorkady committed Jun 9, 2021
1 parent eff7cbd commit ab1dffd
Show file tree
Hide file tree
Showing 13 changed files with 75 additions and 68 deletions.
6 changes: 6 additions & 0 deletions p7-TextToSpeechApp/.idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion p7-TextToSpeechApp/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions p7-TextToSpeechApp/.idea/runConfigurations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions p7-TextToSpeechApp/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions p7-TextToSpeechApp/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
applicationId "csmp.part_a.p7"
minSdkVersion 14
targetSdkVersion 30
versionCode 1
versionName "1.0"
versionCode 2
versionName "1.0.1"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand All @@ -20,6 +20,10 @@ android {
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_1_8
}
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

import android.content.Context;

import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.platform.app.InstrumentationRegistry;

import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;

/**
* Instrumented test, which will execute on an Android device.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,51 +1,47 @@
package csmp.part_a.p7;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.speech.tts.TextToSpeech;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

import java.util.Locale;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {

EditText editText;
Button convertButton;
TextToSpeech textToSpeech;
private EditText editText;
private TextToSpeech textToSpeech;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

editText = (EditText) findViewById(R.id.editText);
convertButton = (Button) findViewById(R.id.convertButton);
editText = findViewById(R.id.editText);
Button button = findViewById(R.id.convertButton);

textToSpeech = new TextToSpeech(this, new TextToSpeech.OnInitListener() {
@Override
public void onInit(int status) {
if (status != TextToSpeech.ERROR) {
if (status != TextToSpeech.ERROR)
textToSpeech.setLanguage(Locale.US);
}
}
});

convertButton.setOnClickListener(this);
button.setOnClickListener(this);
}

@Override
public void onClick(View view) {
String string = editText.getText().toString();
if (string.equals(""))
String text = editText.getText().toString();
if (text.equals(""))
makeToast("EMPTY");
else {
makeToast(string);
textToSpeech.speak(string, TextToSpeech.QUEUE_FLUSH, null);
}
else
textToSpeech.speak(text, TextToSpeech.QUEUE_FLUSH, null);
}

private void makeToast(String toastMessage) {
Expand Down
77 changes: 35 additions & 42 deletions p7-TextToSpeechApp/app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -1,54 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<RelativeLayout
<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView
android:id="@+id/textView"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:background="@color/grey"
android:gravity="center"
android:padding="10dp"
android:text="@string/txtToSpch"
android:textAppearance="@style/TextAppearance.AppCompat.Large" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/textView"
android:layout_margin="20dp"
android:gravity="center"
android:orientation="vertical">

<EditText
android:id="@+id/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:background="@color/grey"
android:gravity="center"
android:padding="10dp"
android:text="@string/txtToSpch"
android:textAppearance="@style/TextAppearance.AppCompat.Large" />

<LinearLayout
android:layout_marginBottom="10dp"
android:ems="10"
android:hint="@string/write_something_to_listen"
android:importantForAutofill="no"
android:inputType="textPersonName" />

<Button
android:id="@+id/convertButton"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/textView"
android:layout_margin="20dp"
android:gravity="center"
android:orientation="vertical">
<EditText
android:id="@+id/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:layout_marginBottom="10dp"
android:inputType="textPersonName"
android:hint="@string/write_something_to_listen" />

<Button
android:id="@+id/convertButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="@string/convert_text_to_speech"
android:textAllCaps="false" />


</LinearLayout>

android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="@string/convert_text_to_speech"
android:textAllCaps="false" />

</RelativeLayout>
</LinearLayout>

</androidx.constraintlayout.widget.ConstraintLayout>
</RelativeLayout>
2 changes: 1 addition & 1 deletion p7-TextToSpeechApp/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
<string name="app_name">TextToSpeechApp</string>
<string name="txtToSpch">TEXT TO SPEECH APPLICATION</string>
<string name="convert_text_to_speech">Convert Text To Speech</string>
<string name="write_something_to_listen">Write something to listen...</string>
<string name="write_something_to_listen">Write something to listen</string>
</resources>
3 changes: 2 additions & 1 deletion p7-TextToSpeechApp/app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<resources>
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:forceDarkAllowed" tools:targetApi="q">false</item>
</style>

</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import org.junit.Test;

import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;

/**
* Example local unit test, which will execute on the development machine (host).
Expand Down
2 changes: 1 addition & 1 deletion p7-TextToSpeechApp/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:4.0.1"
classpath 'com.android.tools.build:gradle:4.2.1'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip

0 comments on commit ab1dffd

Please sign in to comment.