commit
a7b03734bd
|
@ -21,6 +21,7 @@ import android.support.v7.app.AppCompatActivity;
|
|||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
@ -30,10 +31,10 @@ import java.util.Random;
|
|||
public class MainActivity extends AppCompatActivity {
|
||||
final String TAG = "Amadeus";
|
||||
final int REQUEST_PERMISSION_RECORD_AUDIO = 1;
|
||||
TextView subtitles;
|
||||
ImageView kurisu;
|
||||
AnimationDrawable animation;
|
||||
Handler handler;
|
||||
Handler speechHandler;
|
||||
Boolean isLoop = false;
|
||||
Boolean isSpeaking = false;
|
||||
ArrayList<VoiceLine> voiceLines = new ArrayList<>();
|
||||
|
@ -46,8 +47,8 @@ public class MainActivity extends AppCompatActivity {
|
|||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
kurisu = (ImageView) findViewById(R.id.imageView_kurisu);
|
||||
subtitles = (TextView) findViewById(R.id.textView_subtitles);
|
||||
handler = new Handler();
|
||||
speechHandler = new Handler();
|
||||
setupLines();
|
||||
speak(voiceLines.get(0));
|
||||
|
||||
|
@ -81,7 +82,7 @@ public class MainActivity extends AppCompatActivity {
|
|||
if (permissionCheck == PackageManager.PERMISSION_GRANTED) {
|
||||
promptSpeechInput();
|
||||
} else {
|
||||
speak(new VoiceLine(R.raw.daga_kotowaru, Mood.PISSED));
|
||||
speak(new VoiceLine(R.raw.daga_kotowaru, Mood.PISSED, R.string.line_but_i_refuse));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -139,6 +140,7 @@ public class MainActivity extends AppCompatActivity {
|
|||
MediaPlayer m = MediaPlayer.create(getApplicationContext(), line.getId());
|
||||
|
||||
kurisu.setImageResource(line.getMood());
|
||||
subtitles.setText(line.getSubtitle());
|
||||
|
||||
animation = (AnimationDrawable) kurisu.getDrawable();
|
||||
|
||||
|
@ -272,7 +274,7 @@ public class MainActivity extends AppCompatActivity {
|
|||
}
|
||||
|
||||
private void setupLines() {
|
||||
voiceLines.add(new VoiceLine(R.raw.hello, Mood.HAPPY));
|
||||
voiceLines.add(new VoiceLine(R.raw.hello, Mood.HAPPY, R.string.line_hello));
|
||||
voiceLines.add(new VoiceLine(R.raw.daga_kotowaru, Mood.ANNOYED));
|
||||
voiceLines.add(new VoiceLine(R.raw.devilish_pervert, Mood.ANGRY));
|
||||
voiceLines.add(new VoiceLine(R.raw.i_guess, Mood.INDIFFERENT));
|
||||
|
|
|
@ -7,10 +7,12 @@ package com.example.yink.amadeus;
|
|||
class VoiceLine {
|
||||
final private int id;
|
||||
final private int mood;
|
||||
final private int subtitle;
|
||||
|
||||
VoiceLine(int id, int mood) {
|
||||
VoiceLine(int id, int mood, int subtitle) {
|
||||
this.id = id;
|
||||
this.mood = mood;
|
||||
this.subtitle = subtitle;
|
||||
}
|
||||
|
||||
int getId(){
|
||||
|
@ -20,4 +22,8 @@ class VoiceLine {
|
|||
int getMood() {
|
||||
return mood;
|
||||
}
|
||||
|
||||
int getSubtitle() {
|
||||
return subtitle;
|
||||
}
|
||||
}
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 296 KiB |
|
@ -36,4 +36,31 @@
|
|||
android:scaleY="2.5"
|
||||
android:src="@drawable/amadeus_icon_smaller" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView_subtitles"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/subtitle_frame"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentStart="true" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView_subtitles"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="90dp"
|
||||
android:fontFamily="monospace"
|
||||
android:text="@string/subtitles"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat"
|
||||
android:textColor="#FFF"
|
||||
android:textSize="16.0sp"
|
||||
android:typeface="monospace"
|
||||
android:shadowColor="#000"
|
||||
android:shadowRadius="2"
|
||||
android:layout_marginStart="35dp"
|
||||
android:layout_marginLeft="35dp"
|
||||
android:layout_alignTop="@+id/imageView_subtitles"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginTop="11dp" />
|
||||
|
||||
</RelativeLayout>
|
|
@ -4,4 +4,8 @@
|
|||
<string name="connecting">Connecting...</string>
|
||||
<string name="disconnected">Disconnected.</string>
|
||||
<integer name="duration">40</integer>
|
||||
|
||||
<string name="subtitles">宇宙に始まりはあるが終わりはない。 —-無限 星にもまた始まりはあるが、自らの力をもって滅び逝く。 —-有限</string>
|
||||
<string name="line_hello">ハロー。</string>
|
||||
<string name="line_but_i_refuse">だが断る。</string>
|
||||
</resources>
|
||||
|
|
Loading…
Reference in New Issue