Merge pull request #33 from RIP95/master
So many changes... I want to push them all...
This commit is contained in:
commit
13ce86b002
|
@ -12,8 +12,8 @@ import android.preference.PreferenceManager;
|
|||
|
||||
import java.util.Locale;
|
||||
|
||||
public class LangContextWrapper extends ContextWrapper {
|
||||
public LangContextWrapper(Context base) {
|
||||
public class LangContext extends ContextWrapper {
|
||||
public LangContext(Context base) {
|
||||
super(base);
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,28 @@ public class LangContextWrapper extends ContextWrapper {
|
|||
} else {
|
||||
context.getResources().updateConfiguration(config, context.getResources().getDisplayMetrics());
|
||||
}
|
||||
return new LangContextWrapper(context);
|
||||
return new LangContext(context);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static Context load(Context context, String lang) {
|
||||
Configuration config = context.getResources().getConfiguration();
|
||||
|
||||
Locale locale = new Locale(lang);
|
||||
Locale.setDefault(locale);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
setSystemLocale(config, locale);
|
||||
} else {
|
||||
setSystemLocaleLegacy(config, locale);
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
||||
context = context.createConfigurationContext(config);
|
||||
} else {
|
||||
context.getResources().updateConfiguration(config, context.getResources().getDisplayMetrics());
|
||||
}
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
|
@ -77,31 +77,27 @@ public class LaunchActivity extends AppCompatActivity {
|
|||
@Override
|
||||
public void onClick(View view) {
|
||||
if (!isPressed && isAppInstalled(LaunchActivity.this, "com.google.android.googlequicksearchbox")) {
|
||||
try {
|
||||
isPressed = true;
|
||||
m = MediaPlayer.create(getApplicationContext(), R.raw.tone);
|
||||
isPressed = true;
|
||||
m = MediaPlayer.create(getApplicationContext(), R.raw.tone);
|
||||
|
||||
connect.setImageResource(R.drawable.connect_select);
|
||||
connect.setImageResource(R.drawable.connect_select);
|
||||
|
||||
m.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
|
||||
@Override
|
||||
public void onPrepared(MediaPlayer mp) {
|
||||
mp.start();
|
||||
status.setText(R.string.connecting);
|
||||
}
|
||||
});
|
||||
m.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
|
||||
@Override
|
||||
public void onPrepared(MediaPlayer mp) {
|
||||
mp.start();
|
||||
status.setText(R.string.connecting);
|
||||
}
|
||||
});
|
||||
|
||||
m.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
|
||||
@Override
|
||||
public void onCompletion(MediaPlayer mp) {
|
||||
mp.release();
|
||||
Intent intent = new Intent(LaunchActivity.this,MainActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
m.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
|
||||
@Override
|
||||
public void onCompletion(MediaPlayer mp) {
|
||||
mp.release();
|
||||
Intent intent = new Intent(LaunchActivity.this,MainActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -129,7 +125,7 @@ public class LaunchActivity extends AppCompatActivity {
|
|||
|
||||
@Override
|
||||
protected void attachBaseContext(Context newBase) {
|
||||
super.attachBaseContext(LangContextWrapper.wrap(newBase));
|
||||
super.attachBaseContext(LangContext.wrap(newBase));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -11,7 +11,6 @@ import android.content.Intent;
|
|||
import android.content.SharedPreferences;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.drawable.AnimationDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
@ -34,7 +33,6 @@ import android.widget.TextView;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Random;
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
|
@ -42,11 +40,10 @@ public class MainActivity extends AppCompatActivity {
|
|||
final int REQUEST_PERMISSION_RECORD_AUDIO = 1;
|
||||
TextView subtitles;
|
||||
ImageView kurisu;
|
||||
AnimationDrawable animation;
|
||||
Handler handler;
|
||||
Boolean isLoop = false;
|
||||
Boolean isSpeaking = false;
|
||||
ArrayList<VoiceLine> voiceLines = new ArrayList<>();
|
||||
VoiceLine[] voiceLines = VoiceLine.Line.getLines();
|
||||
AnimationDrawable animation;
|
||||
int shaman_girls = -1;
|
||||
Random randomgen = new Random();
|
||||
SharedPreferences sharedPreferences;
|
||||
|
@ -59,18 +56,17 @@ public class MainActivity extends AppCompatActivity {
|
|||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
kurisu = (ImageView) findViewById(R.id.imageView_kurisu);
|
||||
kurisu.setImageResource(R.drawable.kurisu9a);
|
||||
subtitles = (TextView) findViewById(R.id.textView_subtitles);
|
||||
ImageView imageViewSubtitles = (ImageView) findViewById(R.id.imageView_subtitles);
|
||||
ImageView subtitlesBackground = (ImageView) findViewById(R.id.imageView_subtitles);
|
||||
sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
||||
lang = sharedPreferences.getString("lang", "ja");
|
||||
recogLang = sharedPreferences.getString("recognition_lang", "ja");
|
||||
recogLang = sharedPreferences.getString("recognition_lang", "ja-JP");
|
||||
if (!sharedPreferences.getBoolean("show_subtitles", false)) {
|
||||
imageViewSubtitles.setVisibility(View.INVISIBLE);
|
||||
subtitlesBackground.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
handler = new Handler();
|
||||
setupLines();
|
||||
speak(voiceLines.get(0));
|
||||
speak(voiceLines[VoiceLine.Line.HELLO]);
|
||||
|
||||
final Handler handler = new Handler();
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
ActivityCompat.requestPermissions(MainActivity.this, new String[]{Manifest.permission.RECORD_AUDIO}, REQUEST_PERMISSION_RECORD_AUDIO);
|
||||
|
@ -82,7 +78,7 @@ public class MainActivity extends AppCompatActivity {
|
|||
@Override
|
||||
public void run() {
|
||||
if (isLoop) {
|
||||
speak(voiceLines.get(randomgen.nextInt(voiceLines.size())));
|
||||
speak(voiceLines[randomgen.nextInt(voiceLines.length)]);
|
||||
handler.postDelayed(this, 5000 + randomgen.nextInt(5) * 1000);
|
||||
}
|
||||
}
|
||||
|
@ -101,7 +97,7 @@ public class MainActivity extends AppCompatActivity {
|
|||
if (permissionCheck == PackageManager.PERMISSION_GRANTED) {
|
||||
promptSpeechInput();
|
||||
} else {
|
||||
speak(new VoiceLine(R.raw.daga_kotowaru, Mood.PISSED, R.string.line_but_i_refuse));
|
||||
speak(voiceLines[VoiceLine.Line.DAGA_KOTOWARU]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -128,7 +124,7 @@ public class MainActivity extends AppCompatActivity {
|
|||
|
||||
@Override
|
||||
protected void attachBaseContext(Context newBase) {
|
||||
super.attachBaseContext(LangContextWrapper.wrap(newBase));
|
||||
super.attachBaseContext(LangContext.wrap(newBase));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -157,17 +153,7 @@ public class MainActivity extends AppCompatActivity {
|
|||
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
|
||||
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
|
||||
RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
|
||||
switch (recogLang) {
|
||||
case "ja":
|
||||
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "ja-JP");
|
||||
break;
|
||||
case "en":
|
||||
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "en-US");
|
||||
break;
|
||||
case "ru":
|
||||
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "ru-RU");
|
||||
break;
|
||||
}
|
||||
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, recogLang);
|
||||
|
||||
/* Temporary workaround for strange bug on 4.0.3-4.0.4 */
|
||||
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
|
||||
|
@ -211,6 +197,7 @@ public class MainActivity extends AppCompatActivity {
|
|||
Resources res = getResources();
|
||||
animation = (AnimationDrawable) Drawable.createFromXml(res, res.getXml(line.getMood()));
|
||||
|
||||
|
||||
if (m.isPlaying()) {
|
||||
m.stop();
|
||||
m.release();
|
||||
|
@ -270,8 +257,6 @@ public class MainActivity extends AppCompatActivity {
|
|||
}
|
||||
public void onFftDataCapture(Visualizer visualizer, byte[] bytes, int samplingRate) { }
|
||||
}, Visualizer.getMaxCaptureRate() / 2, true, false);
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -293,7 +278,7 @@ public class MainActivity extends AppCompatActivity {
|
|||
if (packageInfo.packageName.contains(input[0].toLowerCase())) {
|
||||
Intent app = ctx.getPackageManager().getLaunchIntentForPackage(packageInfo.packageName);
|
||||
if (app != null) {
|
||||
speak(voiceLines.get(45));
|
||||
speak(voiceLines[VoiceLine.Line.OK]);
|
||||
app.addCategory(Intent.CATEGORY_LAUNCHER);
|
||||
ctx.startActivity(app);
|
||||
break;
|
||||
|
@ -303,200 +288,131 @@ public class MainActivity extends AppCompatActivity {
|
|||
}
|
||||
|
||||
private void answerSpeech(String input) {
|
||||
Context context = getApplicationContext();
|
||||
Configuration config = context.getResources().getConfiguration();
|
||||
|
||||
Locale locale = new Locale(recogLang);
|
||||
Locale.setDefault(locale);
|
||||
/* Split language string (en-US) */
|
||||
String[] contextLang = recogLang.split("-");
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
config.setLocale(locale);
|
||||
} else {
|
||||
config.locale = locale;
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
||||
context = context.createConfigurationContext(config);
|
||||
} else {
|
||||
context.getResources().updateConfiguration(config, context.getResources().getDisplayMetrics());
|
||||
}
|
||||
/* Switch language within current context for voice recognition */
|
||||
Context context = LangContext.load(getApplicationContext(), contextLang[0]);
|
||||
|
||||
input = input.toLowerCase();
|
||||
Random randomGen = new Random();
|
||||
if (input.contains(context.getString(R.string.christina))) {
|
||||
switch (randomGen.nextInt(4)) {
|
||||
case 0:
|
||||
speak(voiceLines.get(10));
|
||||
break;
|
||||
case 1:
|
||||
speak(voiceLines.get(13));
|
||||
break;
|
||||
case 2:
|
||||
speak(voiceLines.get(14));
|
||||
break;
|
||||
case 3:
|
||||
speak(voiceLines.get(15));
|
||||
break;
|
||||
}
|
||||
VoiceLine[] specificLines = {
|
||||
voiceLines[VoiceLine.Line.CHRISTINA],
|
||||
voiceLines[VoiceLine.Line.WHY_CHRISTINA],
|
||||
voiceLines[VoiceLine.Line.SHOULD_CHRISTINA],
|
||||
voiceLines[VoiceLine.Line.NO_TINA]
|
||||
};
|
||||
speak(specificLines[randomgen.nextInt(specificLines.length)]);
|
||||
} else if (input.contains(context.getString(R.string.nullpo))) {
|
||||
shaman_girls += 1;
|
||||
if (shaman_girls < 5) {
|
||||
switch (randomGen.nextInt(2)) {
|
||||
case 0:
|
||||
speak(voiceLines.get(9));
|
||||
break;
|
||||
case 1:
|
||||
speak(voiceLines.get(43));
|
||||
break;
|
||||
}
|
||||
VoiceLine[] specificLines = {
|
||||
voiceLines[VoiceLine.Line.GAH],
|
||||
voiceLines[VoiceLine.Line.GAH_EXTENDED]
|
||||
};
|
||||
speak(specificLines[randomgen.nextInt(specificLines.length)]);
|
||||
} else {
|
||||
switch (shaman_girls) {
|
||||
case 5:
|
||||
speak(new VoiceLine(R.raw.leskinen_awesome, Mood.WINKING, R.string.line_Leskinen_awesome));
|
||||
speak(new VoiceLine(R.raw.leskinen_awesome, VoiceLine.Mood.WINKING, R.string.line_Leskinen_awesome));
|
||||
break;
|
||||
case 6:
|
||||
speak(new VoiceLine(R.raw.leskinen_nice, Mood.WINKING, R.string.line_Leskinen_nice));
|
||||
speak(new VoiceLine(R.raw.leskinen_nice, VoiceLine.Mood.WINKING, R.string.line_Leskinen_nice));
|
||||
break;
|
||||
case 7:
|
||||
speak(new VoiceLine(R.raw.leskinen_oh_no, Mood.WINKING, R.string.line_Leskinen_oh_no));
|
||||
speak(new VoiceLine(R.raw.leskinen_oh_no, VoiceLine.Mood.WINKING, R.string.line_Leskinen_oh_no));
|
||||
break;
|
||||
case 8:
|
||||
speak(new VoiceLine(R.raw.leskinen_shaman, Mood.WINKING, R.string.line_Leskinen_shaman));
|
||||
speak(new VoiceLine(R.raw.leskinen_shaman, VoiceLine.Mood.WINKING, R.string.line_Leskinen_shaman));
|
||||
break;
|
||||
case 9:
|
||||
speak(new VoiceLine(R.raw.leskinen_holy_cow, Mood.WINKING, R.string.line_Leskinen_holy_cow));
|
||||
speak(new VoiceLine(R.raw.leskinen_holy_cow, VoiceLine.Mood.WINKING, R.string.line_Leskinen_holy_cow));
|
||||
shaman_girls = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (input.contains(context.getString(R.string.the_zombie))
|
||||
|| input.contains(context.getString(R.string.celeb17))) {
|
||||
speak(voiceLines.get(32));
|
||||
speak(voiceLines[VoiceLine.Line.DONT_CALL_ME_LIKE_THAT]);
|
||||
} else if (input.contains(context.getString(R.string.atchannel))
|
||||
|| input.contains(context.getString(R.string.kurigohan))
|
||||
|| input.contains(context.getString(R.string.kamehameha))) {
|
||||
speak(voiceLines.get(30 + randomGen.nextInt(2)));
|
||||
VoiceLine[] specificLines = {
|
||||
voiceLines[VoiceLine.Line.SENPAI_DONT_TELL],
|
||||
voiceLines[VoiceLine.Line.STILL_NOT_HAPPY]
|
||||
};
|
||||
speak(specificLines[randomgen.nextInt(specificLines.length)]);
|
||||
} else if (input.contains(context.getString(R.string.salieri))
|
||||
|| input.contains(context.getString(R.string.maho))
|
||||
|| input.contains(context.getString(R.string.hiyajo))) {
|
||||
speak(voiceLines.get(26 + randomGen.nextInt(4)));
|
||||
VoiceLine[] specificLines = {
|
||||
voiceLines[VoiceLine.Line.SENPAI_QUESTION],
|
||||
voiceLines[VoiceLine.Line.SENPAI_WHAT_WE_TALKING],
|
||||
voiceLines[VoiceLine.Line.SENPAI_QUESTIONMARK],
|
||||
voiceLines[VoiceLine.Line.SENPAI_WHO_IS_THIS]
|
||||
};
|
||||
speak(specificLines[randomgen.nextInt(specificLines.length)]);
|
||||
} else if (input.contains(context.getString(R.string.time_machine))
|
||||
|| input.contains(context.getString(R.string.cern))
|
||||
|| input.contains(context.getString(R.string.time_travel))) {
|
||||
speak(voiceLines.get(33 + randomGen.nextInt(5)));
|
||||
VoiceLine[] specificLines = {
|
||||
voiceLines[VoiceLine.Line.TM_NONCENCE],
|
||||
voiceLines[VoiceLine.Line.TM_YOU_SAID],
|
||||
voiceLines[VoiceLine.Line.TM_NO_EVIDENCE],
|
||||
voiceLines[VoiceLine.Line.TM_DONT_KNOW],
|
||||
voiceLines[VoiceLine.Line.TM_NOT_POSSIBLE]
|
||||
};
|
||||
speak(specificLines[randomgen.nextInt(specificLines.length)]);
|
||||
} else if (input.contains(context.getString(R.string.memory))
|
||||
|| input.contains(context.getString(R.string.amadeus))
|
||||
|| input.contains(context.getString(R.string.science))) {
|
||||
speak(voiceLines.get(38 + randomGen.nextInt(5)));
|
||||
VoiceLine[] specificLines = {
|
||||
voiceLines[VoiceLine.Line.HUMANS_SOFTWARE],
|
||||
voiceLines[VoiceLine.Line.MEMORY_COMPLEXITY],
|
||||
voiceLines[VoiceLine.Line.SECRET_DIARY],
|
||||
voiceLines[VoiceLine.Line.MODIFIYING_MEMORIES],
|
||||
voiceLines[VoiceLine.Line.MEMORIES_CHRISTINA]
|
||||
};
|
||||
speak(specificLines[randomgen.nextInt(specificLines.length)]);
|
||||
} else if (input.contains(context.getString(R.string.hello))
|
||||
|| input.contains(context.getString(R.string.good_morning))
|
||||
|| input.contains(context.getString(R.string.konnichiwa))
|
||||
|| input.contains(context.getString(R.string.good_evening))) {
|
||||
switch (randomGen.nextInt(4)) {
|
||||
case 0:
|
||||
speak(voiceLines.get(12));
|
||||
break;
|
||||
case 1:
|
||||
speak(voiceLines.get(24));
|
||||
break;
|
||||
case 2:
|
||||
speak(voiceLines.get(25));
|
||||
break;
|
||||
case 3:
|
||||
speak(voiceLines.get(0));
|
||||
break;
|
||||
}
|
||||
VoiceLine[] specificLines = {
|
||||
voiceLines[VoiceLine.Line.HELLO],
|
||||
voiceLines[VoiceLine.Line.NICE_TO_MEET_OKABE],
|
||||
voiceLines[VoiceLine.Line.PLEASED_TO_MEET],
|
||||
voiceLines[VoiceLine.Line.LOOKING_FORWARD_TO_WORKING]
|
||||
};
|
||||
speak(specificLines[randomgen.nextInt(specificLines.length)]);
|
||||
} else if (input.contains(context.getString(R.string.nice_body))
|
||||
|| input.contains(context.getString(R.string.hot))
|
||||
|| input.contains(context.getString(R.string.sexy))
|
||||
|| input.contains(context.getString(R.string.boobies))
|
||||
|| input.contains(context.getString(R.string.oppai))) {
|
||||
switch (randomGen.nextInt(3)) {
|
||||
case 0:
|
||||
speak(voiceLines.get(2));
|
||||
break;
|
||||
case 1:
|
||||
speak(voiceLines.get(5));
|
||||
break;
|
||||
case 2:
|
||||
speak(voiceLines.get(11));
|
||||
break;
|
||||
}
|
||||
VoiceLine[] specificLines = {
|
||||
voiceLines[VoiceLine.Line.DEVILISH_PERVERT],
|
||||
voiceLines[VoiceLine.Line.PERVERT_CONFIRMED],
|
||||
voiceLines[VoiceLine.Line.PERVERT_IDIOT]
|
||||
};
|
||||
speak(specificLines[randomgen.nextInt(specificLines.length)]);
|
||||
} else if (input.contains(context.getString(R.string.robotics_notes))
|
||||
|| input.contains(context.getString(R.string.antimatter))) {
|
||||
speak(voiceLines.get(21)); //Hehehe
|
||||
speak(voiceLines[VoiceLine.Line.HEHEHE]);
|
||||
} else {
|
||||
speak(voiceLines.get(16 + randomGen.nextInt(7)));
|
||||
VoiceLine[] specificLines = {
|
||||
voiceLines[VoiceLine.Line.ASK_ME],
|
||||
voiceLines[VoiceLine.Line.WHAT_DO_YOU_WANT],
|
||||
voiceLines[VoiceLine.Line.WHAT_IS_IT],
|
||||
voiceLines[VoiceLine.Line.HEHEHE],
|
||||
voiceLines[VoiceLine.Line.WHY_SAY_THAT],
|
||||
voiceLines[VoiceLine.Line.YOU_SURE]
|
||||
};
|
||||
speak(specificLines[randomgen.nextInt(specificLines.length)]);
|
||||
}
|
||||
}
|
||||
|
||||
private void setupLines() {
|
||||
voiceLines.add(new VoiceLine(R.raw.hello, Mood.HAPPY, R.string.line_hello));
|
||||
voiceLines.add(new VoiceLine(R.raw.daga_kotowaru, Mood.ANNOYED, R.string.line_but_i_refuse));
|
||||
voiceLines.add(new VoiceLine(R.raw.devilish_pervert, Mood.ANGRY, R.string.line_devilish_pervert));
|
||||
voiceLines.add(new VoiceLine(R.raw.i_guess, Mood.INDIFFERENT, R.string.line_i_guess));
|
||||
voiceLines.add(new VoiceLine(R.raw.nice, Mood.WINKING, R.string.line_nice));
|
||||
voiceLines.add(new VoiceLine(R.raw.pervert_confirmed, Mood.PISSED, R.string.line_pervert_confirmed)); //5
|
||||
voiceLines.add(new VoiceLine(R.raw.sorry, Mood.SAD, R.string.line_sorry));
|
||||
voiceLines.add(new VoiceLine(R.raw.sounds_tough, Mood.SIDE, R.string.line_sounds_tough));
|
||||
voiceLines.add(new VoiceLine(R.raw.this_guy_hopeless, Mood.DISAPPOINTED, R.string.line_this_guy_hopeless));
|
||||
voiceLines.add(new VoiceLine(R.raw.gah, Mood.INDIFFERENT, R.string.line_gah));
|
||||
voiceLines.add(new VoiceLine(R.raw.dont_add_tina, Mood.ANGRY, R.string.line_dont_add_tina)); //10
|
||||
voiceLines.add(new VoiceLine(R.raw.pervert_idot_wanttodie, Mood.ANGRY, R.string.line_pervert_idiot_wanttodie));
|
||||
voiceLines.add(new VoiceLine(R.raw.pleased_to_meet_you, Mood.SIDED_PLEASANT, R.string.line_pleased_to_meet_you));
|
||||
voiceLines.add(new VoiceLine(R.raw.who_the_hell_christina, Mood.PISSED, R.string.line_who_the_hell_christina));
|
||||
voiceLines.add(new VoiceLine(R.raw.why_christina, Mood.PISSED, R.string.line_why_christina));
|
||||
voiceLines.add(new VoiceLine(R.raw.christina, Mood.ANNOYED, R.string.line_christina)); //15
|
||||
voiceLines.add(new VoiceLine(R.raw.ask_me_whatever, Mood.HAPPY, R.string.line_ask_me_whatever));
|
||||
voiceLines.add(new VoiceLine(R.raw.could_i_help, Mood.HAPPY, R.string.line_could_i_help));
|
||||
voiceLines.add(new VoiceLine(R.raw.ask_me_whatever, Mood.HAPPY, R.string.line_ask_me_whatever));
|
||||
voiceLines.add(new VoiceLine(R.raw.what_do_you_want, Mood.HAPPY, R.string.line_what_do_you_want));
|
||||
voiceLines.add(new VoiceLine(R.raw.what_is_it, Mood.HAPPY, R.string.line_what_is_it)); //20
|
||||
voiceLines.add(new VoiceLine(R.raw.heheh, Mood.WINKING, R.string.line_heheh));
|
||||
voiceLines.add(new VoiceLine(R.raw.huh_why_say, Mood.SIDED_WORRIED, R.string.line_huh_why_say));
|
||||
voiceLines.add(new VoiceLine(R.raw.you_sure, Mood.SIDED_WORRIED, R.string.line_you_sure));
|
||||
voiceLines.add(new VoiceLine(R.raw.nice_to_meet_okabe, Mood.SIDED_PLEASANT, R.string.line_nice_to_meet_okabe));
|
||||
voiceLines.add(new VoiceLine(R.raw.look_forward_to_working, Mood.HAPPY, R.string.line_look_forward_to_working)); //25
|
||||
voiceLines.add(new VoiceLine(R.raw.senpai_question, Mood.SIDE, R.string.line_senpai_question));
|
||||
voiceLines.add(new VoiceLine(R.raw.senpai_questionmark, Mood.SIDE, R.string.line_senpai_question_mark));
|
||||
voiceLines.add(new VoiceLine(R.raw.senpai_what_we_talkin, Mood.SIDED_WORRIED, R.string.line_senpai_what_we_talkin));
|
||||
voiceLines.add(new VoiceLine(R.raw.senpai_who_is_this, Mood.NORMAL, R.string.line_senpai_who_is_this));
|
||||
voiceLines.add(new VoiceLine(R.raw.senpai_please_dont_tell, Mood.BLUSH, R.string.line_senpai_please_dont_tell)); //30
|
||||
voiceLines.add(new VoiceLine(R.raw.still_not_happy, Mood.BLUSH, R.string.line_still_not_happy));
|
||||
voiceLines.add(new VoiceLine(R.raw.dont_call_me_like_that, Mood.ANGRY, R.string.line_dont_call_me_like_that));
|
||||
voiceLines.add(new VoiceLine(R.raw.tm_nonsense, Mood.DISAPPOINTED, R.string.line_tm_nonsense));
|
||||
voiceLines.add(new VoiceLine(R.raw.tm_not_possible, Mood.DISAPPOINTED, R.string.line_tm_not_possible));
|
||||
voiceLines.add(new VoiceLine(R.raw.tm_scientist_no_evidence, Mood.NORMAL, R.string.line_tm_scientist_no_evidence));
|
||||
voiceLines.add(new VoiceLine(R.raw.tm_we_dont_know, Mood.NORMAL, R.string.line_tm_we_dont_know)); //35
|
||||
voiceLines.add(new VoiceLine(R.raw.tm_you_said, Mood.SIDED_WORRIED, R.string.line_tm_you_said));
|
||||
voiceLines.add(new VoiceLine(R.raw.humans_software, Mood.NORMAL, R.string.line_humans_software));
|
||||
voiceLines.add(new VoiceLine(R.raw.memory_complex, Mood.INDIFFERENT, R.string.line_memory_complex));
|
||||
voiceLines.add(new VoiceLine(R.raw.secret_diary, Mood.INDIFFERENT, R.string.line_secret_diary));
|
||||
voiceLines.add(new VoiceLine(R.raw.modifying_memories_impossible, Mood.INDIFFERENT, R.string.line_modifying_memories_impossible)); //40
|
||||
voiceLines.add(new VoiceLine(R.raw.memories_christina, Mood.WINKING, R.string.line_memories_christina));
|
||||
voiceLines.add(new VoiceLine(R.raw.gah_extended, Mood.BLUSH, R.string.line_gah_extended));
|
||||
voiceLines.add(new VoiceLine(R.raw.should_christina, Mood.PISSED, R.string.line_should_christina));
|
||||
voiceLines.add(new VoiceLine(R.raw.ok, Mood.HAPPY, R.string.line_ok));
|
||||
}
|
||||
|
||||
private class Mood {
|
||||
static final int HAPPY = R.drawable.kurisu_9;
|
||||
static final int PISSED = R.drawable.kurisu_6;
|
||||
static final int ANNOYED = R.drawable.kurisu_7;
|
||||
static final int ANGRY = R.drawable.kurisu_10;
|
||||
static final int BLUSH = R.drawable.kurisu_11;
|
||||
/* TODO: How should we name this mood?.. */
|
||||
static final int SIDE = R.drawable.kurisu_12;
|
||||
static final int SAD = R.drawable.kurisu_3;
|
||||
static final int NORMAL = R.drawable.kurisu_2;
|
||||
static final int SLEEPY = R.drawable.kurisu_1;
|
||||
static final int WINKING = R.drawable.kurisu_5;
|
||||
static final int DISAPPOINTED = R.drawable.kurisu_8;
|
||||
static final int INDIFFERENT = R.drawable.kurisu_4;
|
||||
static final int SIDED_PLEASANT = R.drawable.kurisu_15;
|
||||
static final int SIDED_WORRIED = R.drawable.kurisu_17;
|
||||
}
|
||||
|
||||
private class listener implements RecognitionListener {
|
||||
final String TAG = "Amadeus.listener";
|
||||
|
||||
|
@ -518,7 +434,7 @@ public class MainActivity extends AppCompatActivity {
|
|||
public void onError(int error) {
|
||||
Log.d(TAG, "error " + error);
|
||||
sr.cancel();
|
||||
speak(voiceLines.get(6));
|
||||
speak(voiceLines[VoiceLine.Line.SORRY]);
|
||||
}
|
||||
public void onResults(Bundle results) {
|
||||
String input = "";
|
||||
|
|
|
@ -21,6 +21,6 @@ public class SettingsActivity extends FragmentActivity {
|
|||
|
||||
@Override
|
||||
protected void attachBaseContext(Context newBase) {
|
||||
super.attachBaseContext(LangContextWrapper.wrap(newBase));
|
||||
super.attachBaseContext(LangContext.wrap(newBase));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package com.example.yink.amadeus;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceFragment;
|
||||
|
@ -12,8 +11,6 @@ import android.support.annotation.RequiresApi;
|
|||
|
||||
@RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
|
||||
public class SettingsFragment extends PreferenceFragment {
|
||||
SharedPreferences sharedPreferences;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
|
|
@ -15,7 +15,7 @@ class VoiceLine {
|
|||
this.subtitle = subtitle;
|
||||
}
|
||||
|
||||
int getId(){
|
||||
int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
|
@ -26,4 +26,122 @@ class VoiceLine {
|
|||
int getSubtitle() {
|
||||
return subtitle;
|
||||
}
|
||||
|
||||
static class Mood {
|
||||
static final int HAPPY = R.drawable.kurisu_9;
|
||||
static final int PISSED = R.drawable.kurisu_6;
|
||||
static final int ANNOYED = R.drawable.kurisu_7;
|
||||
static final int ANGRY = R.drawable.kurisu_10;
|
||||
static final int BLUSH = R.drawable.kurisu_11;
|
||||
/* TODO: How should we name this mood?.. */
|
||||
static final int SIDE = R.drawable.kurisu_12;
|
||||
static final int SAD = R.drawable.kurisu_3;
|
||||
static final int NORMAL = R.drawable.kurisu_2;
|
||||
static final int SLEEPY = R.drawable.kurisu_1;
|
||||
static final int WINKING = R.drawable.kurisu_5;
|
||||
static final int DISAPPOINTED = R.drawable.kurisu_8;
|
||||
static final int INDIFFERENT = R.drawable.kurisu_4;
|
||||
static final int SIDED_PLEASANT = R.drawable.kurisu_15;
|
||||
static final int SIDED_WORRIED = R.drawable.kurisu_17;
|
||||
}
|
||||
|
||||
static class Line {
|
||||
static VoiceLine[] voiceLines = new VoiceLine[45];
|
||||
|
||||
static final int HELLO = 0;
|
||||
static final int DAGA_KOTOWARU = 1;
|
||||
static final int DEVILISH_PERVERT = 2;
|
||||
static final int I_GUESS = 3;
|
||||
static final int NICE = 4;
|
||||
static final int PERVERT_CONFIRMED = 5;
|
||||
static final int SORRY = 6;
|
||||
static final int SOUNDS_TOUGH = 7;
|
||||
static final int HOPELESS = 8;
|
||||
static final int CHRISTINA = 9;
|
||||
static final int GAH = 10;
|
||||
static final int NO_TINA = 11;
|
||||
static final int WHY_CHRISTINA = 12;
|
||||
static final int WHO_IS_CHRISTINA = 13;
|
||||
static final int ASK_ME = 14;
|
||||
static final int COULD_I_HELP = 15;
|
||||
static final int WHAT_DO_YOU_WANT = 16;
|
||||
static final int WHAT_IS_IT = 17;
|
||||
static final int HEHEHE = 18;
|
||||
static final int WHY_SAY_THAT = 19;
|
||||
static final int YOU_SURE = 20;
|
||||
static final int NICE_TO_MEET_OKABE = 21;
|
||||
static final int LOOKING_FORWARD_TO_WORKING = 22;
|
||||
static final int SENPAI_QUESTION = 23;
|
||||
static final int SENPAI_QUESTIONMARK = 24;
|
||||
static final int SENPAI_WHAT_WE_TALKING = 25;
|
||||
static final int SENPAI_WHO_IS_THIS = 26;
|
||||
static final int SENPAI_DONT_TELL = 27;
|
||||
static final int STILL_NOT_HAPPY = 28;
|
||||
static final int DONT_CALL_ME_LIKE_THAT = 29;
|
||||
static final int TM_NONCENCE = 30;
|
||||
static final int TM_NO_EVIDENCE = 31;
|
||||
static final int TM_DONT_KNOW = 32;
|
||||
static final int TM_YOU_SAID = 33;
|
||||
static final int HUMANS_SOFTWARE = 34;
|
||||
static final int MEMORY_COMPLEXITY = 35;
|
||||
static final int SECRET_DIARY = 36;
|
||||
static final int MODIFIYING_MEMORIES = 37;
|
||||
static final int MEMORIES_CHRISTINA = 38;
|
||||
static final int GAH_EXTENDED = 39;
|
||||
static final int SHOULD_CHRISTINA = 40;
|
||||
static final int OK = 41;
|
||||
static final int TM_NOT_POSSIBLE = 42;
|
||||
static final int PLEASED_TO_MEET = 43;
|
||||
static final int PERVERT_IDIOT = 44;
|
||||
|
||||
static VoiceLine[] getLines() {
|
||||
voiceLines[HELLO] = new VoiceLine(R.raw.hello, Mood.HAPPY, R.string.line_hello);
|
||||
voiceLines[DAGA_KOTOWARU] = new VoiceLine(R.raw.daga_kotowaru, Mood.ANNOYED, R.string.line_but_i_refuse);
|
||||
voiceLines[DEVILISH_PERVERT] = new VoiceLine(R.raw.devilish_pervert, Mood.ANGRY, R.string.line_devilish_pervert);
|
||||
voiceLines[I_GUESS] = new VoiceLine(R.raw.i_guess, Mood.INDIFFERENT, R.string.line_i_guess);
|
||||
voiceLines[NICE] = new VoiceLine(R.raw.nice, Mood.WINKING, R.string.line_nice);
|
||||
voiceLines[PERVERT_CONFIRMED] = new VoiceLine(R.raw.pervert_confirmed, Mood.PISSED, R.string.line_pervert_confirmed);
|
||||
voiceLines[SORRY] = new VoiceLine(R.raw.sorry, Mood.SAD, R.string.line_sorry);
|
||||
voiceLines[SOUNDS_TOUGH] = new VoiceLine(R.raw.sounds_tough, Mood.SIDE, R.string.line_sounds_tough);
|
||||
voiceLines[HOPELESS] = new VoiceLine(R.raw.this_guy_hopeless, Mood.DISAPPOINTED, R.string.line_this_guy_hopeless);
|
||||
voiceLines[CHRISTINA] = new VoiceLine(R.raw.christina, Mood.ANNOYED, R.string.line_christina);
|
||||
voiceLines[GAH] = new VoiceLine(R.raw.gah, Mood.INDIFFERENT, R.string.line_gah);
|
||||
voiceLines[NO_TINA] = new VoiceLine(R.raw.dont_add_tina, Mood.ANGRY, R.string.line_dont_add_tina);
|
||||
voiceLines[WHY_CHRISTINA] = new VoiceLine(R.raw.why_christina, Mood.PISSED, R.string.line_why_christina);
|
||||
voiceLines[WHO_IS_CHRISTINA] = new VoiceLine(R.raw.who_the_hell_christina, Mood.PISSED, R.string.line_who_the_hell_christina);
|
||||
voiceLines[ASK_ME] = new VoiceLine(R.raw.ask_me_whatever, Mood.HAPPY, R.string.line_ask_me_whatever);
|
||||
voiceLines[COULD_I_HELP] = new VoiceLine(R.raw.could_i_help, Mood.HAPPY, R.string.line_could_i_help);
|
||||
voiceLines[WHAT_DO_YOU_WANT] = new VoiceLine(R.raw.what_do_you_want, Mood.HAPPY, R.string.line_what_do_you_want);
|
||||
voiceLines[WHAT_IS_IT] = new VoiceLine(R.raw.what_is_it, Mood.HAPPY, R.string.line_what_is_it);
|
||||
voiceLines[HEHEHE] = new VoiceLine(R.raw.heheh, Mood.WINKING, R.string.line_heheh);
|
||||
voiceLines[WHY_SAY_THAT] = new VoiceLine(R.raw.huh_why_say, Mood.SIDED_WORRIED, R.string.line_huh_why_say);
|
||||
voiceLines[YOU_SURE] = new VoiceLine(R.raw.you_sure, Mood.SIDED_WORRIED, R.string.line_you_sure);
|
||||
voiceLines[NICE_TO_MEET_OKABE] = new VoiceLine(R.raw.nice_to_meet_okabe, Mood.SIDED_PLEASANT, R.string.line_nice_to_meet_okabe);
|
||||
voiceLines[LOOKING_FORWARD_TO_WORKING] = new VoiceLine(R.raw.look_forward_to_working, Mood.HAPPY, R.string.line_look_forward_to_working);
|
||||
voiceLines[SENPAI_QUESTION] = new VoiceLine(R.raw.senpai_question, Mood.SIDE, R.string.line_senpai_question);
|
||||
voiceLines[SENPAI_QUESTIONMARK] = new VoiceLine(R.raw.senpai_questionmark, Mood.SIDE, R.string.line_senpai_question_mark);
|
||||
voiceLines[SENPAI_WHAT_WE_TALKING] = new VoiceLine(R.raw.senpai_what_we_talkin, Mood.SIDED_WORRIED, R.string.line_senpai_what_we_talkin);
|
||||
voiceLines[SENPAI_WHO_IS_THIS] = new VoiceLine(R.raw.senpai_who_is_this, Mood.NORMAL, R.string.line_senpai_who_is_this);
|
||||
voiceLines[SENPAI_DONT_TELL] = new VoiceLine(R.raw.senpai_please_dont_tell, Mood.BLUSH, R.string.line_senpai_please_dont_tell);
|
||||
voiceLines[STILL_NOT_HAPPY] = new VoiceLine(R.raw.still_not_happy, Mood.BLUSH, R.string.line_still_not_happy);
|
||||
voiceLines[DONT_CALL_ME_LIKE_THAT] = new VoiceLine(R.raw.dont_call_me_like_that, Mood.ANGRY, R.string.line_dont_call_me_like_that);
|
||||
voiceLines[TM_NONCENCE] = new VoiceLine(R.raw.tm_nonsense, Mood.DISAPPOINTED, R.string.line_tm_nonsense);
|
||||
voiceLines[TM_NO_EVIDENCE] = new VoiceLine(R.raw.tm_scientist_no_evidence, Mood.NORMAL, R.string.line_tm_scientist_no_evidence);
|
||||
voiceLines[TM_DONT_KNOW] = new VoiceLine(R.raw.tm_we_dont_know, Mood.NORMAL, R.string.line_tm_we_dont_know);
|
||||
voiceLines[TM_YOU_SAID] = new VoiceLine(R.raw.tm_you_said, Mood.SIDED_WORRIED, R.string.line_tm_you_said);
|
||||
voiceLines[HUMANS_SOFTWARE] = new VoiceLine(R.raw.humans_software, Mood.NORMAL, R.string.line_humans_software);
|
||||
voiceLines[MEMORY_COMPLEXITY] = new VoiceLine(R.raw.memory_complex, Mood.INDIFFERENT, R.string.line_memory_complex);
|
||||
voiceLines[SECRET_DIARY] = new VoiceLine(R.raw.secret_diary, Mood.INDIFFERENT, R.string.line_secret_diary);
|
||||
voiceLines[MODIFIYING_MEMORIES] = new VoiceLine(R.raw.modifying_memories_impossible, Mood.INDIFFERENT, R.string.line_modifying_memories_impossible);
|
||||
voiceLines[MEMORIES_CHRISTINA] = new VoiceLine(R.raw.memories_christina, Mood.WINKING, R.string.line_memories_christina);
|
||||
voiceLines[GAH_EXTENDED] = new VoiceLine(R.raw.gah_extended, Mood.BLUSH, R.string.line_gah_extended);
|
||||
voiceLines[SHOULD_CHRISTINA] = new VoiceLine(R.raw.should_christina, Mood.PISSED, R.string.line_should_christina);
|
||||
voiceLines[OK] = new VoiceLine(R.raw.ok, Mood.HAPPY, R.string.line_ok);
|
||||
voiceLines[TM_NOT_POSSIBLE] = new VoiceLine(R.raw.tm_not_possible, Mood.DISAPPOINTED, R.string.line_tm_not_possible);
|
||||
voiceLines[PLEASED_TO_MEET] = new VoiceLine(R.raw.pleased_to_meet_you, Mood.SIDED_PLEASANT, R.string.line_pleased_to_meet_you);
|
||||
voiceLines[PERVERT_IDIOT] = new VoiceLine(R.raw.pervert_idot_wanttodie, Mood.ANGRY, R.string.line_pervert_idiot_wanttodie);
|
||||
|
||||
return voiceLines;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
android:id="@+id/imageView_kurisu"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:src="@drawable/kurisu9a"
|
||||
android:scaleType="centerCrop" />
|
||||
|
||||
<ImageView
|
||||
|
|
|
@ -3,8 +3,9 @@
|
|||
<string name="call">Conectar a Kurisu?</string>
|
||||
<string name="connecting">Conectando…</string>
|
||||
<string name="disconnected">Desconectado.</string>
|
||||
<string name="default_lang">es</string>
|
||||
<string name="default_recog_lang">ja-JP</string>
|
||||
<string name="google_app_error">Google App wasn\'t detected.</string>
|
||||
<string name="lang_default_value">Pt-Pt</string>
|
||||
|
||||
<string name="line_hello">Hola.</string>
|
||||
<string name="line_dont_call_me_like_that">No me llames así!</string>
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<string name="connecting">Connecting…</string>
|
||||
<string name="disconnected">Disconnected.</string>
|
||||
<string name="default_lang">ja</string>
|
||||
<string name="default_recog_lang">ja</string>
|
||||
<string name="default_recog_lang">ja-JP</string>
|
||||
<string name="google_app_error">Google App wasn\'t detected.</string>
|
||||
|
||||
<string name="line_hello">Hello.</string>
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<string name="connecting">Conectando…</string>
|
||||
<string name="disconnected">Desconectado.</string>
|
||||
<string name="default_lang">pt</string>
|
||||
<string name="default_recog_lang">ja</string>
|
||||
<string name="default_recog_lang">ja-JP</string>
|
||||
<string name="google_app_error">Google App wasn\'t detected.</string>
|
||||
|
||||
<string name="line_hello">Olá.</string>
|
||||
|
|
|
@ -4,10 +4,11 @@
|
|||
<string name="connecting">Подключение…</string>
|
||||
<string name="disconnected">Отключено.</string>
|
||||
<string name="default_lang">ru</string>
|
||||
<string name="default_recog_lang">ja</string>
|
||||
<string name="default_recog_lang">ja-JP</string>
|
||||
<string name="google_app_error">Google App не найден.</string>
|
||||
|
||||
<!-- Настройки -->
|
||||
<string name="pref_app_settings">Настройки приложения</string>
|
||||
<string name="pref_recog_lang">Язык распознавания</string>
|
||||
<string name="pref_recog_lang_desc">Выберите язык распознавания голоса</string>
|
||||
<string name="pref_lang">Язык</string>
|
||||
|
|
|
@ -23,8 +23,8 @@
|
|||
</string-array>
|
||||
|
||||
<string-array name="languagesRecogValues">
|
||||
<item>en</item>
|
||||
<item>ru</item>
|
||||
<item>ja</item>
|
||||
<item>en-US</item>
|
||||
<item>ru-RU</item>
|
||||
<item>ja-JP</item>
|
||||
</string-array>
|
||||
</resources>
|
|
@ -4,10 +4,11 @@
|
|||
<string name="connecting">Connecting…</string>
|
||||
<string name="disconnected">Disconnected.</string>
|
||||
<string name="default_lang">en</string>
|
||||
<string name="default_recog_lang">en</string>
|
||||
<string name="default_recog_lang">en-US</string>
|
||||
<string name="google_app_error">Google App wasn\'t detected.</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="pref_app_settings">Application settings</string>
|
||||
<string name="pref_recog_lang">Recognition language</string>
|
||||
<string name="pref_recog_lang_desc">Select voice recognition language</string>
|
||||
<string name="pref_lang">Language</string>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<PreferenceCategory android:title="Subtitle Settings">
|
||||
<PreferenceCategory android:title="@string/pref_app_settings">
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="show_subtitles"
|
||||
|
|
Loading…
Reference in New Issue