Merge pull request #35 from RIP95/master

Changes to commands. Bug fix. Switch to gradient background
This commit is contained in:
Nille 2017-03-11 13:57:52 +01:00 committed by GitHub
commit 006343819c
7 changed files with 57 additions and 16 deletions

View File

@ -20,7 +20,7 @@ import android.widget.TextView;
public class LaunchActivity extends AppCompatActivity {
ImageView connect, cancel, imageViewLogo;
TextView status;
AnimationDrawable logo;
//AnimationDrawable logo;
Boolean isPressed = false;
SharedPreferences sharedPreferences;
MediaPlayer m;

View File

@ -32,6 +32,7 @@ import android.widget.ImageView;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Random;
@ -147,10 +148,6 @@ public class MainActivity extends AppCompatActivity {
@Override
protected void onPause() {
isLoop = false;
if (animation != null && animation.isRunning())
animation.stop();
kurisu.setImageResource(R.drawable.kurisu2a);
animation = null;
super.onPause();
}
@ -276,11 +273,37 @@ public class MainActivity extends AppCompatActivity {
List<ApplicationInfo> packages = pm.getInstalledApplications(PackageManager.GET_META_DATA);
Context ctx = getApplicationContext();
HashMap<String, Integer> dictionary = new HashMap<>();
String corrected;
Boolean found;
dictionary.put("хром", 0);
dictionary.put("календарь", 1);
dictionary.put("часы", 2);
dictionary.put("будильник", 2);
dictionary.put("камеру", 3);
String[] words = {
"chrome", "calendar", "clock", "camera"
};
for (ApplicationInfo packageInfo : packages) {
/*
* TODO: Needs to be adjusted probably.
*/
if (packageInfo.packageName.contains(input[0].toLowerCase())) {
found = true;
for (String word: input) {
if (dictionary.get(word) != null) {
corrected = words[dictionary.get(word)].toLowerCase();
} else {
corrected = word.toLowerCase();
}
Log.d(TAG, corrected);
if (!packageInfo.packageName.contains(corrected)) {
found = false;
break;
}
}
if (found) {
Intent app = ctx.getPackageManager().getLaunchIntentForPackage(packageInfo.packageName);
if (app != null) {
speak(voiceLines[VoiceLine.Line.OK]);
@ -449,24 +472,27 @@ public class MainActivity extends AppCompatActivity {
input += data.get(0);
/* TODO: Japanese doesn't split the words. Sigh. */
String[] splitInput = input.split(" ");
/* Really, google? */
if (splitInput[0].equalsIgnoreCase("Асистент")) {
String temp = "";
String[] replace;
temp += data.get(1);
replace = temp.split(" ");
splitInput[0] = replace[0];
}
/* Switch language within current context for voice recognition */
Context context = LangContext.load(getApplicationContext(), contextLang[0]);
if (splitInput.length > 2 && splitInput[0].equalsIgnoreCase(context.getString(R.string.christina))) {
if (splitInput.length > 2 && splitInput[0].equalsIgnoreCase(context.getString(R.string.assistant))) {
String cmd = splitInput[1].toLowerCase();
String[] args = new String[splitInput.length - 2];
System.arraycopy(splitInput, 2, args, 0, splitInput.length - 2);
/* TODO: Must be reimplemented for multilanguage support */
switch (cmd) {
case "open":
openApp(args);
break;
case "открой":
openApp(args);
break;
if (cmd.contains(context.getString(R.string.open))) {
openApp(args);
}
} else {
answerSpeech(input, context);
}

View File

@ -0,0 +1,10 @@
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:angle="135"
android:startColor="#11110c"
android:centerColor="#050600"
android:endColor="#231e00"
android:type="linear" />
</shape>

View File

@ -3,7 +3,7 @@
android:id="@+id/activity_launch"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/launch_bg"
android:background="@drawable/gradient_background"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"

View File

@ -85,4 +85,5 @@
<string name="oppai">おっぱい</string>
<string name="robotics_notes">ロボティクスノーツ</string>
<string name="antimatter">アンティメタ</string>
<string name="assistant">助手</string>
</resources>

View File

@ -86,6 +86,8 @@
<string name="good_morning">доброе утро</string>
<string name="konnichiwa">добрый день</string>
<string name="good_evening">добрый вечер</string>
<string name="assistant">ассистент</string>
<string name="open">открой</string>
<!-- Контекст! -->
<string name="nice_body">симпатичная фигура</string>
<string name="hot">горячая</string>

View File

@ -98,4 +98,6 @@
<string name="oppai">oppai</string>
<string name="robotics_notes">Robotics Notes</string>
<string name="antimatter">antimatter</string>
<string name="assistant">assistant</string>
<string name="open">open</string>
</resources>