randomizer and UI

This commit is contained in:
s434603 2019-01-26 16:47:28 +01:00
parent 2d27dbec4e
commit d4610ace5c
12 changed files with 94 additions and 15 deletions

View File

@ -3,6 +3,9 @@
<component name="GradleSettings"> <component name="GradleSettings">
<option name="linkedExternalProjectsSettings"> <option name="linkedExternalProjectsSettings">
<GradleProjectSettings> <GradleProjectSettings>
<compositeConfiguration>
<compositeBuild compositeDefinitionSource="SCRIPT" />
</compositeConfiguration>
<option name="distributionType" value="DEFAULT_WRAPPED" /> <option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" /> <option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="modules"> <option name="modules">

View File

@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="AndroidDomInspection" enabled="false" level="ERROR" enabled_by_default="false" />
</profile>
</component>

View File

@ -5,7 +5,7 @@
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" /> <option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
<option name="myNullables"> <option name="myNullables">
<value> <value>
<list size="7"> <list size="10">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" /> <item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" /> <item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
<item index="2" class="java.lang.String" itemvalue="javax.annotation.CheckForNull" /> <item index="2" class="java.lang.String" itemvalue="javax.annotation.CheckForNull" />
@ -13,18 +13,24 @@
<item index="4" class="java.lang.String" itemvalue="android.support.annotation.Nullable" /> <item index="4" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
<item index="5" class="java.lang.String" itemvalue="androidx.annotation.Nullable" /> <item index="5" class="java.lang.String" itemvalue="androidx.annotation.Nullable" />
<item index="6" class="java.lang.String" itemvalue="androidx.annotation.RecentlyNullable" /> <item index="6" class="java.lang.String" itemvalue="androidx.annotation.RecentlyNullable" />
<item index="7" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.qual.Nullable" />
<item index="8" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NullableDecl" />
<item index="9" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NullableType" />
</list> </list>
</value> </value>
</option> </option>
<option name="myNotNulls"> <option name="myNotNulls">
<value> <value>
<list size="6"> <list size="9">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" /> <item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" /> <item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" /> <item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" /> <item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
<item index="4" class="java.lang.String" itemvalue="androidx.annotation.NonNull" /> <item index="4" class="java.lang.String" itemvalue="androidx.annotation.NonNull" />
<item index="5" class="java.lang.String" itemvalue="androidx.annotation.RecentlyNonNull" /> <item index="5" class="java.lang.String" itemvalue="androidx.annotation.RecentlyNonNull" />
<item index="6" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.qual.NonNull" />
<item index="7" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NonNullDecl" />
<item index="8" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NonNullType" />
</list> </list>
</value> </value>
</option> </option>

6
.idea/vcs.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

View File

@ -7,8 +7,10 @@ import android.support.v7.app.AppCompatActivity;
import android.os.Bundle; import android.os.Bundle;
import android.view.View; import android.view.View;
import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Random;
public class MainActivity extends AppCompatActivity { public class MainActivity extends AppCompatActivity {
@ -61,15 +63,35 @@ public class MainActivity extends AppCompatActivity {
startActivityForResult(intent, SPEECH_REQUEST_CODE); startActivityForResult(intent, SPEECH_REQUEST_CODE);
} }
// Randomly picks a string from the list and tells the result
private void randomizer(List<String> T) {
// Randomly picks a string
Random rand = new Random();
String answer = T.get(rand.nextInt(T.size()));
/*
if statement with clue about result (vibration?),
depending on whether answer = "It is a cat" or = "It is NOT a cat";
thread must sleep for some time (3000ms-4000ms)
*/
// Says the result
tts.speak(answer, TextToSpeech.QUEUE_FLUSH, null);
}
// Process voice command given by user // Process voice command given by user
private void processVoiceCommand(String spokenText) { private void processVoiceCommand(String spokenText) {
if (spokenText.contains("photo") || spokenText.contains("foto")) { if (spokenText.contains("photo") || spokenText.contains("foto")) {
// sound of taking photo
// ...
// say the result // camera shutter sound (?); indication of app taking a photo
String toSpeak = "Lets do this, motherfucker";
tts.speak(toSpeak, TextToSpeech.QUEUE_FLUSH, null); // Starting question
String question = "Is it a cat or not?";
tts.speak(question, TextToSpeech.QUEUE_FLUSH, null);
// Initiating randomizer method on 'answers'
List<String> answers = Arrays.asList("It is a cat", "It is NOT a cat");
randomizer(answers);
} }
} }
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 176 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

View File

@ -4,14 +4,46 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@color/pink"
tools:context=".MainActivity"> tools:context=".MainActivity">
<Button <ImageView
android:id="@+id/logo"
android:layout_width="390dp"
android:layout_height="100dp"
android:layout_marginStart="20dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="200dp"
android:layout_marginEnd="20dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="77dp"
android:background="@drawable/logo"
android:contentDescription="@strings/logo"
app:layout_constraintBottom_toTopOf="@+id/speechButton"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.444"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.569" />
<ImageButton
android:id="@+id/speechButton" android:id="@+id/speechButton"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="161dp"
android:layout_marginLeft="161dp"
android:layout_marginTop="500dp"
android:layout_marginEnd="160dp"
android:layout_marginRight="160dp"
android:layout_marginBottom="300dp"
android:background="@drawable/mic"
android:contentDescription="@string/speech_button"
android:onClick="handleSpeechButtonClick" android:onClick="handleSpeechButtonClick"
android:text="@string/speech_button" app:layout_constraintBottom_toBottomOf="parent"
tools:layout_editor_absoluteX="147dp" app:layout_constraintEnd_toEndOf="parent"
tools:layout_editor_absoluteY="230dp" /> app:layout_constraintHorizontal_bias="0.506"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.578" />
</android.support.constraint.ConstraintLayout> </android.support.constraint.ConstraintLayout>

View File

@ -1,4 +1,7 @@
<resources> <resources>
<string name="app_name">Cat or Not 2</string> <string name="app_name">Cat or Not</string>
<string name="logo">Application logo</string>
<string name="speech_button">Click me!</string> <string name="speech_button">Click me!</string>
<string name="mic_description">Voice commands</string>
<color name="pink">#FF55AA</color>
</resources> </resources>

View File

@ -1,7 +1,7 @@
<resources> <resources>
<!-- Base application theme. --> <!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. --> <!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item>

View File

@ -7,7 +7,7 @@ buildscript {
jcenter() jcenter()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:3.2.1' classpath 'com.android.tools.build:gradle:3.3.0'
// NOTE: Do not place your application dependencies here; they belong // NOTE: Do not place your application dependencies here; they belong

View File

@ -1,5 +1,6 @@
#Sat Jan 26 00:33:53 CET 2019
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip