Added logo, microphone and improved UI a lot + fixed not starting in background

This commit is contained in:
Mathieu 2021-10-15 23:33:37 +02:00
parent 3caee5d422
commit d1e7eb0cb3
8 changed files with 130 additions and 35 deletions

View File

@ -1,22 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="DesignSurface"> <component name="DesignSurface">
<option name="filePathToZoomLevelMap"> <option name="filePathToZoomLevelMap">
<map> <map>
<entry key="app/src/main/res/drawable-v24/ic_launcher_foreground.xml" value="0.36614583333333334" /> <entry key="../../../../../layout/custom_preview.xml" value="0.5354166666666667" />
<entry key="app/src/main/res/drawable/ic_launcher_background.xml" value="0.36614583333333334" /> <entry key="app/src/main/res/drawable-v24/ic_launcher_foreground.xml"
<entry key="app/src/main/res/drawable/rounded_white_on_top.xml" value="0.36614583333333334" /> value="0.36614583333333334" />
<entry key="app/src/main/res/layout/activity_listening.xml" value="0.264" /> <entry key="app/src/main/res/drawable/circle.xml" value="0.346875" />
<entry key="app/src/main/res/layout/activity_main.xml" value="0.35" /> <entry key="app/src/main/res/drawable/ic_launcher_background.xml"
<entry key="app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml" value="0.36614583333333334" /> value="0.36614583333333334" />
</map> <entry key="app/src/main/res/drawable/mic.xml" value="0.346875" />
</option> <entry key="app/src/main/res/drawable/microphone.xml" value="0.346875" />
</component> <entry key="app/src/main/res/drawable/round_button.xml" value="0.346875" />
<component name="ExternalStorageConfigurationManager" enabled="true" /> <entry key="app/src/main/res/drawable/rounded_white_on_top.xml"
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="Android Studio default JDK" project-jdk-type="JavaSDK"> value="0.36614583333333334" />
<output url="file://$PROJECT_DIR$/build/classes" /> <entry key="app/src/main/res/layout/activity_listening.xml" value="0.536" />
</component> <entry key="app/src/main/res/layout/activity_main.xml" value="0.35" />
<component name="ProjectType"> <entry key="app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml"
<option name="id" value="Android" /> value="0.36614583333333334" />
</component> </map>
</option>
</component>
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="ProjectRootManager" default="true" languageLevel="JDK_11" project-jdk-name="Android Studio default JDK"
project-jdk-type="JavaSDK" version="2">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
<option name="id" value="Android" />
</component>
</project> </project>

View File

@ -31,7 +31,7 @@ dependencies {
implementation 'androidx.appcompat:appcompat:1.3.1' implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0' implementation 'com.google.android.material:material:1.4.0'
testImplementation 'junit:junit:4.+' implementation 'com.agrawalsuneet.androidlibs:dotsloader:1.4'
androidTestImplementation 'androidx.test.ext:junit:1.1.3' androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'

View File

@ -35,4 +35,19 @@ public class ListeningActivity extends AppCompatActivity {
public void quit(View view) { public void quit(View view) {
finish(); finish();
} }
public void startRecording(View view) {
view.setVisibility(View.INVISIBLE);
View dots = findViewById(R.id.dots);
dots.setVisibility(View.VISIBLE);
}
public void stopRecording(View view) {
view.setVisibility(View.INVISIBLE);
View dots = findViewById(R.id.microphone);
dots.setVisibility(View.VISIBLE);
}
} }

View File

@ -36,7 +36,8 @@ public class PorcupineService extends Service {
getApplicationContext(), getApplicationContext(),
(keywordIndex) -> { (keywordIndex) -> {
Intent dialogIntent = new Intent(this, ListeningActivity.class); Intent dialogIntent = new Intent(getApplicationContext(), ListeningActivity.class);
dialogIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
dialogIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); dialogIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(dialogIntent); startActivity(dialogIntent);

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

View File

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M12,14c1.66,0 2.99,-1.34 2.99,-3L15,5c0,-1.66 -1.34,-3 -3,-3S9,3.34 9,5v6c0,1.66 1.34,3 3,3zM17.3,11c0,3 -2.54,5.1 -5.3,5.1S6.7,14 6.7,11L5,11c0,3.41 2.72,6.23 6,6.72L11,21h2v-3.28c3.28,-0.48 6,-3.3 6,-6.72h-1.7z"/>
</vector>

View File

@ -1,10 +1,11 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/RelativeLayout" android:id="@+id/RelativeLayout"
android:layout_width="fill_parent" android:layout_width="match_parent"
android:layout_height="fill_parent" android:layout_height="match_parent"
android:background="#66000000" android:background="#66000000"
tools:context="ch.mathieubroillet.jarvis.android.ListeningActivity"> tools:context="ch.mathieubroillet.jarvis.android.ListeningActivity">
@ -20,8 +21,8 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_marginBottom="300dp" android:layout_marginBottom="300dp"
android:fontFamily="@font/google_bold"
android:alpha="0" android:alpha="0"
android:fontFamily="@font/google_bold"
android:onClick="quit" android:onClick="quit"
android:text="" /> android:text="" />
</LinearLayout> </LinearLayout>
@ -34,24 +35,80 @@
android:background="@drawable/rounded_white_on_top"> android:background="@drawable/rounded_white_on_top">
<ImageView
android:id="@+id/jarvis_logo"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="15dp"
android:contentDescription="logo"
app:srcCompat="@drawable/logo" />
<TextView <TextView
android:id="@+id/textView2" android:id="@+id/imjarvis_text"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentTop="true" android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" android:layout_centerHorizontal="true"
android:layout_marginTop="30dp" android:layout_marginTop="70dp"
android:fontFamily="@font/google_regular" android:fontFamily="@font/google_medium"
android:text="@string/listening" android:text="@string/imjarvis"
android:textSize="30dp" /> android:textSize="25sp" />
<ProgressBar <TextView
android:id="@+id/progressBar" android:id="@+id/howcanihelp_text"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentStart="true" android:layout_alignParentTop="true"
android:layout_alignParentEnd="true" android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true" /> android:layout_marginTop="105dp"
android:fontFamily="@font/google_light"
android:text="@string/howcanihelp"
android:textSize="20sp" />
<TextView
android:id="@+id/listening_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="150dp"
android:fontFamily="@font/google_medium"
android:text="@string/listening"
android:textSize="20sp" />
<com.agrawalsuneet.dotsloader.loaders.LinearDotsLoader
android:id="@+id/dots"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="223dp"
android:onClick="stopRecording"
android:visibility="invisible"
app:loader_animDur="250"
app:loader_circleRadius="10dp"
app:loader_defaultColor="#f5b273"
app:loader_dotsDist="10dp"
app:loader_expandOnSelect="false"
app:loader_isSingleDir="false"
app:loader_noOfDots="4"
app:loader_selectedColor="#6a5767"
app:loader_selectedRadius="10dp"
app:loader_showRunningShadow="true" />
<ImageView
android:id="@+id/microphone"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="205dp"
android:contentDescription="microphone"
android:onClick="startRecording"
app:srcCompat="@drawable/microphone"
tools:ignore="OnClick" />
</RelativeLayout> </RelativeLayout>

View File

@ -1,4 +1,6 @@
<resources> <resources>
<string name="app_name">Jarvis Client Android</string> <string name="app_name">Jarvis Client Android</string>
<string name="listening">Je vous écoute…</string> <string name="listening">J\'écoute…</string>
<string name="imjarvis">Salut, je suis Jarvis.</string>
<string name="howcanihelp">Dis moi comment je peux t\'aider.</string>
</resources> </resources>