Calling Screen
|
@ -9,6 +9,11 @@
|
|||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme">
|
||||
<activity android:name=".MainActivity">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity android:name=".LaunchActivity">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
package com.example.yink.amadeus;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
|
||||
public class LaunchActivity extends AppCompatActivity {
|
||||
ImageView connect;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_launch);
|
||||
connect = (ImageView) findViewById(R.id.imageView_connect);
|
||||
connect.setImageResource(R.drawable.connect_unselect);
|
||||
connect.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
connect.setImageResource(R.drawable.connect_select);
|
||||
Intent intent = new Intent(LaunchActivity.this,MainActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume(){
|
||||
connect.setImageResource(R.drawable.connect_unselect);
|
||||
super.onResume();
|
||||
}
|
||||
}
|
|
@ -1,8 +1,10 @@
|
|||
package com.example.yink.amadeus;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.graphics.drawable.AnimationDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Handler;
|
||||
import android.speech.tts.TextToSpeech;
|
||||
import android.speech.tts.UtteranceProgressListener;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
|
@ -11,16 +13,19 @@ import android.util.Log;
|
|||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.Random;
|
||||
|
||||
|
||||
|
||||
public class MainActivity extends AppCompatActivity implements TextToSpeech.OnInitListener{
|
||||
String TAG = "Amadeus";
|
||||
TextToSpeech tts;
|
||||
ImageView kurisu;
|
||||
AnimationDrawable animation;
|
||||
HashMap<String, String> map;
|
||||
int state = 0;
|
||||
private final int eyes_closed = 0;
|
||||
private final int normal = 1;
|
||||
private final int sad = 2;
|
||||
|
@ -34,11 +39,21 @@ public class MainActivity extends AppCompatActivity implements TextToSpeech.OnIn
|
|||
private final int blush = 10;
|
||||
private final int side = 11;
|
||||
|
||||
ArrayList<VoiceLine> voiceLines = new ArrayList<>();
|
||||
|
||||
|
||||
@Override
|
||||
public void onWindowFocusChanged(boolean hasFocus){
|
||||
if(hasFocus)
|
||||
speak(new VoiceLine("Hallo.",happy));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
kurisu = (ImageView) findViewById(R.id.imageView_kurisu);
|
||||
setupLines();
|
||||
map = new HashMap<String, String>();
|
||||
tts = new TextToSpeech(this, this);
|
||||
kurisu.setImageResource(R.drawable.kurisu_1);
|
||||
|
@ -46,10 +61,9 @@ public class MainActivity extends AppCompatActivity implements TextToSpeech.OnIn
|
|||
kurisu.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
speak("Konban wa, Okabe. Okaeri!",state);
|
||||
state=(state+1)%12;}
|
||||
|
||||
});
|
||||
Random randomgen = new Random();
|
||||
speak(voiceLines.get(randomgen.nextInt(voiceLines.size())));
|
||||
}});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -74,6 +88,7 @@ public class MainActivity extends AppCompatActivity implements TextToSpeech.OnIn
|
|||
@Override
|
||||
public void run() {
|
||||
animation.stop();
|
||||
kurisu.setImageDrawable(animation.getFrame(0));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -86,8 +101,8 @@ public class MainActivity extends AppCompatActivity implements TextToSpeech.OnIn
|
|||
}
|
||||
}
|
||||
|
||||
public void speak(String text, int state){
|
||||
switch (state){
|
||||
public void speak(VoiceLine line){
|
||||
switch (line.getState()){
|
||||
case eyes_closed:
|
||||
kurisu.setImageResource(R.drawable.kurisu_1);
|
||||
break;
|
||||
|
@ -113,12 +128,15 @@ public class MainActivity extends AppCompatActivity implements TextToSpeech.OnIn
|
|||
kurisu.setImageResource(R.drawable.kurisu_8);
|
||||
break;
|
||||
case happy:
|
||||
tts.setPitch(1.5f);
|
||||
kurisu.setImageResource(R.drawable.kurisu_9);
|
||||
break;
|
||||
case angry:
|
||||
kurisu.setImageResource(R.drawable.kurisu_10);
|
||||
break;
|
||||
case blush:
|
||||
tts.setPitch(1.5f);
|
||||
tts.setSpeechRate(1.3f);
|
||||
kurisu.setImageResource(R.drawable.kurisu_11);
|
||||
break;
|
||||
case side:
|
||||
|
@ -129,7 +147,9 @@ public class MainActivity extends AppCompatActivity implements TextToSpeech.OnIn
|
|||
}
|
||||
animation = (AnimationDrawable) kurisu.getDrawable();
|
||||
map.put(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID,"UniqueID");
|
||||
tts.speak(text,TextToSpeech.QUEUE_FLUSH,map);
|
||||
tts.speak(line.getText(),TextToSpeech.QUEUE_FLUSH,map);
|
||||
tts.setPitch(1.05f);
|
||||
tts.setSpeechRate(1.0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -137,4 +157,12 @@ public class MainActivity extends AppCompatActivity implements TextToSpeech.OnIn
|
|||
tts.shutdown();
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
protected void setupLines(){
|
||||
voiceLines.add(new VoiceLine("Konban wa, Okabe. Okaeri!",happy));
|
||||
voiceLines.add(new VoiceLine("Okabe, sabishi des!",sad));
|
||||
voiceLines.add(new VoiceLine("Tsumaranai",indifferent));
|
||||
voiceLines.add(new VoiceLine("Okabe ga ski",blush));
|
||||
voiceLines.add(new VoiceLine("Chigau",angry));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
package com.example.yink.amadeus;
|
||||
|
||||
/**
|
||||
* Created by Yink on 28.02.2017.
|
||||
*/
|
||||
|
||||
public class VoiceLine {
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public int getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
final private String text;
|
||||
final private int state;
|
||||
|
||||
public VoiceLine(String text, int state){
|
||||
this.text = text;
|
||||
this.state = state;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/activity_launch"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||
android:paddingTop="@dimen/activity_vertical_margin"
|
||||
android:background="@color/colorPrimaryDark"
|
||||
tools:context="com.example.yink.amadeus.LaunchActivity">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView_logo"
|
||||
android:src="@drawable/amadeus_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="98dp"
|
||||
android:scaleX="2.5"
|
||||
android:scaleY="2.5"
|
||||
android:adjustViewBounds="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_centerHorizontal="true" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView_connect"
|
||||
android:src="@drawable/connect_unselect"
|
||||
android:layout_height="40dp"
|
||||
android:layout_marginBottom="120dp"
|
||||
android:adjustViewBounds="false"
|
||||
android:cropToPadding="false"
|
||||
android:layout_width="180dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_centerHorizontal="true" />
|
||||
|
||||
<TextView
|
||||
android:text="@string/call"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="35dp"
|
||||
android:id="@+id/textView_call"
|
||||
android:layout_above="@+id/imageView_connect"
|
||||
android:layout_alignParentStart="true"
|
||||
android:typeface="monospace"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat"
|
||||
android:textSize="22sp"
|
||||
android:fontFamily="monospace"
|
||||
android:textColor="#dec752" />
|
||||
|
||||
</RelativeLayout>
|
|
@ -24,4 +24,16 @@
|
|||
android:layout_height="match_parent"
|
||||
android:scaleType="centerCrop" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView_logo_small"
|
||||
android:src="@drawable/amadeus_icon_smaller"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:scaleX="2.5"
|
||||
android:scaleY="2.5"
|
||||
android:layout_marginEnd="35dp"
|
||||
android:layout_marginBottom="33dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentEnd="true" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
|
Before Width: | Height: | Size: 6.3 KiB After Width: | Height: | Size: 7.0 KiB |
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 3.6 KiB |
Before Width: | Height: | Size: 9.5 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 25 KiB |
|
@ -1,3 +1,4 @@
|
|||
<resources>
|
||||
<string name="app_name">Amadeus</string>
|
||||
<string name="call">Connect to Kurisu?</string>
|
||||
</resources>
|
||||
|
|