1
0

Wibracje jako podpowiedz i fake odglos aparatu

This commit is contained in:
Maciej 2019-01-27 17:24:19 +01:00
parent 5126db3a6e
commit 04e94226dc
12 changed files with 43 additions and 64 deletions

Binary file not shown.

View File

@ -8,12 +8,6 @@
</compositeConfiguration> </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">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
</set>
</option>
<option name="resolveModulePerSourceSet" value="false" /> <option name="resolveModulePerSourceSet" value="false" />
</GradleProjectSettings> </GradleProjectSettings>
</option> </option>

View File

@ -1,6 +0,0 @@
<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

@ -1,40 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="NullableNotNullManager">
<option name="myDefaultNullable" value="android.support.annotation.Nullable" />
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
<option name="myNullables">
<value>
<list size="10">
<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="2" class="java.lang.String" itemvalue="javax.annotation.CheckForNull" />
<item index="3" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.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="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>
</value>
</option>
<option name="myNotNulls">
<value>
<list size="9">
<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="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="4" class="java.lang.String" itemvalue="androidx.annotation.NonNull" />
<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>
</value>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" /> <output url="file://$PROJECT_DIR$/build/classes" />
</component> </component>

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RenderSettings">
<option name="showDecorations" value="true" />
</component>
</project>

BIN
app/debug/app.aab Normal file

Binary file not shown.

BIN
app/release/app.aab Normal file

Binary file not shown.

View File

@ -7,7 +7,7 @@ import android.support.test.runner.AndroidJUnit4;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import static org.junit.Assert.*; import static org.junit.Assert.assertEquals;
/** /**
* Instrumented test, which will execute on an Android device. * Instrumented test, which will execute on an Android device.

View File

@ -9,6 +9,7 @@
android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission <uses-permission
android:name="android.permission.RECORD_AUDIO" /> android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.VIBRATE"/>
<application <application
android:allowBackup="true" android:allowBackup="true"

View File

@ -1,27 +1,32 @@
package com.example.se.catornot2; package com.example.se.catornot2;
import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.media.MediaPlayer;
import android.os.Build;
import android.os.Bundle;
import android.os.VibrationEffect;
import android.speech.RecognizerIntent; import android.speech.RecognizerIntent;
import android.speech.tts.TextToSpeech; import android.speech.tts.TextToSpeech;
import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View; import android.view.View;
import android.os.Vibrator;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Random; import java.util.Random;
public class MainActivity extends AppCompatActivity { public class MainActivity extends AppCompatActivity {
private static final int SPEECH_REQUEST_CODE = 0; private static final int SPEECH_REQUEST_CODE = 0;
TextToSpeech tts; TextToSpeech tts;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); setContentView(R.layout.activity_main);
initializeTextToSpeech(); initializeTextToSpeech();
} }
// This callback is invoked when the Speech Recognizer returns. // This callback is invoked when the Speech Recognizer returns.
@ -75,20 +80,46 @@ public class MainActivity extends AppCompatActivity {
thread must sleep for some time (3000ms-4000ms) thread must sleep for some time (3000ms-4000ms)
*/ */
// Says the result //vibrate if answer is 'It is a cat'
tts.speak(answer, TextToSpeech.QUEUE_FLUSH, null);
if (answer.equals("It is a cat")){
shakeItBaby();
} }
// Says the result
try {
Thread.sleep(4000);
tts.speak(answer, TextToSpeech.QUEUE_FLUSH, null);
}catch(Exception e) {
}
}
private void shakeItBaby() {
if (Build.VERSION.SDK_INT >= 26) {
((Vibrator) getSystemService(VIBRATOR_SERVICE)).vibrate(VibrationEffect.createOneShot(500, VibrationEffect.DEFAULT_AMPLITUDE));
} else {
((Vibrator) getSystemService(VIBRATOR_SERVICE)).vibrate(500);
}
}
// 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")) {
// camera shutter sound (?); indication of app taking a photo // camera shutter sound (?); indication of app taking a photo
MediaPlayer mySound;
mySound= MediaPlayer.create(MainActivity.this,R.raw.photosound);
mySound.start();
// Starting question // Starting question
try {
Thread.sleep(3000);
String question = "Is it a cat or not?"; String question = "Is it a cat or not?";
tts.speak(question, TextToSpeech.QUEUE_FLUSH, null); tts.speak(question, TextToSpeech.QUEUE_FLUSH, null);
}catch(Exception e) {
}
// Initiating randomizer method on 'answers' // Initiating randomizer method on 'answers'
List<String> answers = Arrays.asList("It is a cat", "It is NOT a cat"); List<String> answers = Arrays.asList("It is a cat", "It is NOT a cat");
randomizer(answers); randomizer(answers);

Binary file not shown.

View File

@ -2,7 +2,7 @@ package com.example.se.catornot2;
import org.junit.Test; import org.junit.Test;
import static org.junit.Assert.*; import static org.junit.Assert.assertEquals;
/** /**
* Example local unit test, which will execute on the development machine (host). * Example local unit test, which will execute on the development machine (host).