Skip to content

Commit

Permalink
MIGRATE TO ANDROIDX
Browse files Browse the repository at this point in the history
  • Loading branch information
jeluchu committed Feb 26, 2019
1 parent f12f4c3 commit 410c10a
Show file tree
Hide file tree
Showing 13 changed files with 39 additions and 25 deletions.
Binary file modified .idea/caches/build_file_checksums.ser
Binary file not shown.
Binary file modified .idea/caches/gradle_models.ser
Binary file not shown.
9 changes: 9 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ android {

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'androidx.appcompat:appcompat:1.0.0-beta01'
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v7.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.TimePicker;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import android.content.SharedPreferences;
import android.os.Build;
import android.preference.PreferenceManager;
import android.support.v4.content.WakefulBroadcastReceiver;
import androidx.legacy.content.WakefulBroadcastReceiver;
import android.util.Log;

public class AlarmBootReceiver extends WakefulBroadcastReceiver {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.support.v4.app.NotificationCompat;
import androidx.core.app.NotificationCompat;

public class AlarmService extends IntentService {

Expand Down
27 changes: 15 additions & 12 deletions app/src/main/java/com/example/yink/amadeus/Amadeus.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.example.yink.amadeus;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
Expand All @@ -13,22 +14,22 @@
import android.media.audiofx.Visualizer;
import android.net.Uri;
import android.preference.PreferenceManager;
import android.support.annotation.NonNull;
import androidx.annotation.NonNull;
import android.util.Log;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import java.util.Random;

class Amadeus {

static Boolean isSpeaking = false;
static Boolean isLoop = false;
static MediaPlayer m;
private static String TAG = "Amadeus";
private static int shaman_girls = -1;
private static VoiceLine[] voiceLines = VoiceLine.Line.getLines();
private static HashMap<Bundle<Integer>, Bundle<VoiceLine>> responseInputMap = new HashMap<>();
Expand Down Expand Up @@ -120,8 +121,8 @@ class Amadeus {

static void speak(VoiceLine line, final Activity activity) {
final AnimationDrawable animation;
final TextView subtitles = (TextView) activity.findViewById(R.id.textView_subtitles);
final ImageView kurisu = (ImageView) activity.findViewById(R.id.imageView_kurisu);
final TextView subtitles = activity.findViewById(R.id.textView_subtitles);
final ImageView kurisu = activity.findViewById(R.id.imageView_kurisu);
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(activity);

try {
Expand Down Expand Up @@ -199,6 +200,7 @@ public void onFftDataCapture(Visualizer visualizer, byte[] bytes, int samplingRa
}
}

@SuppressLint("NewApi")
static void responseToInput(String input, Context context, Activity activity) {
VoiceLine[] specificLines = null;
input = input.toLowerCase();
Expand Down Expand Up @@ -237,7 +239,7 @@ static void responseToInput(String input, Context context, Activity activity) {
for (Bundle<Integer> input_bundle : responseInputMap.keySet()) {
for (Integer input_code : input_bundle) {
if (containInput(input, context.getString(input_code))) {
specificLines = responseInputMap.get(input_bundle).toArray();
specificLines = Objects.requireNonNull(responseInputMap.get(input_bundle)).toArray();
break;
}
}
Expand Down Expand Up @@ -272,8 +274,8 @@ static void openApp(String[] input, Activity activity) {

HashMap<String, Integer> dictionary = new HashMap<>();
String corrected;
Boolean found;
/* TODO: Dictionary for other language equivalents. To be reworked. */
boolean found;

dictionary.put("хром", 0);
dictionary.put("календарь", 1);
dictionary.put("часы", 2);
Expand All @@ -285,7 +287,7 @@ static void openApp(String[] input, Activity activity) {
};

for (ApplicationInfo packageInfo : packages) {
/* TODO: Needs to be adjusted probably. */

found = true;
/* Look up words in dictionary and correct the input since we can't open some apps in other langs */
for (String word: input) {
Expand All @@ -301,6 +303,7 @@ static void openApp(String[] input, Activity activity) {
}

if (found) {
String TAG = "Amadeus";
Log.d(TAG, "Found app!");
Intent app;
Amadeus.speak(voiceLines[VoiceLine.Line.OK], activity);
Expand Down Expand Up @@ -338,18 +341,19 @@ private static class Bundle<T> implements Iterable<T> {

private T[] list;

public Bundle(T... list) {
@SafeVarargs
Bundle(T... list) {
this.list = list;
}

public T[] toArray() {
T[] toArray() {
return list;
}

@NonNull
@Override
public Iterator<T> iterator() {
Iterator<T> iterator = new Iterator<T>() {
return new Iterator<T>() {
int index = 0;

@Override
Expand All @@ -362,7 +366,6 @@ public T next() {
return list[index++];
}
};
return iterator;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
import android.os.Bundle;
import android.os.Handler;
import android.preference.PreferenceManager;
import android.support.v4.app.NotificationCompat;
import android.support.v4.app.TaskStackBuilder;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import androidx.core.app.NotificationCompat;
import androidx.core.app.TaskStackBuilder;
import androidx.core.content.ContextCompat;
import androidx.appcompat.app.AppCompatActivity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/java/com/example/yink/amadeus/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
import android.speech.RecognitionListener;
import android.speech.RecognizerIntent;
import android.speech.SpeechRecognizer;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.appcompat.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import android.content.Context;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import androidx.fragment.app.FragmentActivity;

public class SettingsActivity extends FragmentActivity {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceFragment;
import android.support.annotation.RequiresApi;
import androidx.annotation.RequiresApi;

/**
* Created by Yink on 05.03.2017.
Expand Down
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
android.enableJetifier=true
android.useAndroidX=true
org.gradle.jvmargs=-Xmx1536m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
Expand Down

0 comments on commit 410c10a

Please sign in to comment.