Skip to content

Commit

Permalink
change wording and add TTS functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
ClaudiaHosu committed Sep 21, 2016
1 parent ebc8160 commit ace7ea8
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 11 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
applicationId "uk.co.medivoice.jv"
minSdkVersion 19
targetSdkVersion 23
versionCode 2
versionName "1.0.1"
versionCode 3
versionName "1.0.2"
}

signingConfigs {
Expand Down
33 changes: 29 additions & 4 deletions app/src/main/java/uk/co/jaspalsvoice/jv/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.provider.Settings;
import android.speech.tts.TextToSpeech;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.MenuItemCompat;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.ShareActionProvider;
import android.text.Editable;
import android.text.InputType;
Expand All @@ -35,9 +34,11 @@
import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ListView;
import android.widget.PopupWindow;
import android.widget.TextView;
import android.widget.Toast;

import java.io.BufferedReader;
import java.io.IOException;
Expand All @@ -48,19 +49,18 @@
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;

import uk.co.jaspalsvoice.jv.activities.AboutMeActivity;
import uk.co.jaspalsvoice.jv.activities.AllergiesActivity;
import uk.co.jaspalsvoice.jv.activities.BaseActivity;
import uk.co.jaspalsvoice.jv.activities.DiagnosesActivity;
import uk.co.jaspalsvoice.jv.activities.DiagnosisActivity;
import uk.co.jaspalsvoice.jv.activities.FontSizeActivity;
import uk.co.jaspalsvoice.jv.activities.FoodAllergiesActivity;
import uk.co.jaspalsvoice.jv.activities.GpActivity;
import uk.co.jaspalsvoice.jv.activities.LikesDislikesActivity;
import uk.co.jaspalsvoice.jv.activities.MedicalAllergiesActivity;
import uk.co.jaspalsvoice.jv.activities.MedicinesActivity;
import uk.co.jaspalsvoice.jv.activities.PersonalDetailsActivity;
import uk.co.jaspalsvoice.jv.activities.VitalsActivity;
Expand Down Expand Up @@ -90,6 +90,8 @@ public class MainActivity extends BaseActivity implements SuggestionsAdapter.Lis

private TextView currentTextCaseView;
private EditText messageTextView;
private TextToSpeech textToSpeech;
private ImageButton ttsTextView;
private int messageTextViewLocation[] = new int[2];

private Layout messageTextLayout;
Expand Down Expand Up @@ -351,6 +353,17 @@ public void afterTextChanged(Editable s) {
}
};

private View.OnClickListener ttsListener = new View.OnClickListener() {

@Override
public void onClick(View v) {
String toSpeak = messageTextView.getText().toString();
Toast.makeText(getApplicationContext(), toSpeak,Toast.LENGTH_SHORT).show();
textToSpeech.speak(toSpeak, TextToSpeech.QUEUE_FLUSH, null);
}

};

private static HashMap<Integer, Set<Character>> keyboard;
private static Map<Character, Integer> charMapping;

Expand Down Expand Up @@ -543,6 +556,16 @@ protected void onCreate(Bundle savedInstanceState) {
Configuration configuration = getResources().getConfiguration();
configuration.fontScale = preferences.getFontSize(); //0.85 small size, 1 normal size, 1,15 big etc

//initiate the text-to-speech engine
textToSpeech =new TextToSpeech(getApplicationContext(), new TextToSpeech.OnInitListener() {
@Override
public void onInit(int status) {
if(status != TextToSpeech.ERROR) {
textToSpeech.setLanguage(Locale.UK);
}
}
});

DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
metrics.scaledDensity = configuration.fontScale * metrics.density;
Expand Down Expand Up @@ -718,6 +741,8 @@ private void initKeypadViews() {

currentTextCaseView = (TextView) keypadScene.getSceneRoot().findViewById(R.id.text_case);
messageTextView = (EditText) keypadScene.getSceneRoot().findViewById(R.id.message_text);
ttsTextView = (ImageButton) keypadScene.getSceneRoot().findViewById(R.id.text_to_speech);
ttsTextView.setOnClickListener(ttsListener);

messageTextView.setTextIsSelectable(true);
messageTextView.setCursorVisible(true);
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/layout/medical_contact_card_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@
<EditText
android:id="@+id/edit2"
style="@style/EditTextStyle"
android:minLines="1"
android:inputType="textMultiLine"
android:layout_height="wrap_content"
android:hint="@string/gp_medical_team_address" />

</android.support.design.widget.TextInputLayout>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/personal_details_activity.xml
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
<EditText
android:id="@+id/countyEdittext"
style="@style/SingleLineEditTextStyle"
android:hint="@string/personal_details_country_state_Province" />
android:hint="@string/personal_details_county_state_Province" />

</android.support.design.widget.TextInputLayout>

Expand Down
10 changes: 10 additions & 0 deletions app/src/main/res/layout/scene_keypad.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@
android:singleLine="false"
android:textSize="@dimen/text_big_size"/>

<ImageButton
android:layout_width="wrap_content"
android:layout_height="30dp"
android:background="@null"
android:layout_gravity="right"
android:src="@drawable/ic_action_av_volume_down"
android:id="@+id/text_to_speech"
android:layout_below="@+id/editText"
android:layout_centerHorizontal="true" />

<LinearLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<string name="personal_details_nhs">NHS/Health Number</string>
<string name="personal_details_street">Street Address</string>
<string name="personal_details_Town">Town Address</string>
<string name="personal_details_country_state_Province"> Country/State/Province</string>
<string name="personal_details_county_state_Province"> County/State/Province</string>
<string name="personal_details_ZIP">ZIP/Postal Code</string>
<string name="personal_details_Country">Country</string>
<string name="personal_details_main_carer">Main Carer</string>
Expand Down
2 changes: 1 addition & 1 deletion 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:2.1.2'
classpath 'com.android.tools.build:gradle:2.1.3'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Tue Jun 28 13:01:33 IST 2016
#Fri Sep 16 23:04:48 BST 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip

0 comments on commit ace7ea8

Please sign in to comment.