Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
alex1115alex committed Apr 6, 2023
2 parents c7fa6ba + c59d670 commit e2a4415
Show file tree
Hide file tree
Showing 25 changed files with 80 additions and 59 deletions.
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<application
android:allowBackup="true"
android:icon="@drawable/logo_mlkit"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme">

Expand Down
Binary file added app/src/main/ic_launcher-playstore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public void onComplete(@NonNull Task<String> task) {
EventBus.getDefault().post(new TranslateSuccessEvent(task.getResult()));
} else {
translatedText.setValue(new ResultOrError(null, task.getException()));
task.getException().printStackTrace();
// task.getException().printStackTrace();
}
// Update the list of downloaded models as more may have been
// automatically downloaded due to requested translation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.util.Log;

import com.teamopensmartglasses.sgmlib.FocusStates;
import com.teamopensmartglasses.translate.R;
import com.teamopensmartglasses.translate.events.ChangeSourceLanguageEvent;
import com.teamopensmartglasses.translate.events.ChangeTargetLanguageEvent;
Expand All @@ -22,21 +23,22 @@ public class TranslationService extends SmartGlassesAndroidService {

//our instance of the SGM library
public SGMLib sgmLib;
public boolean newScreen = true;
public String previousTranslation = "";
public FocusStates focusState;
TranslationBackend translationBackend;
public TranslationService(){
super(MainActivity.class,
"translation_app",
1001,
"Translation",
"Translation app for smartglasses", R.drawable.common_google_signin_btn_icon_light_normal);
"Translation app for smartglasses", R.drawable.ic_stat_name);
}

@Override
public void onCreate() {
super.onCreate();

focusState = FocusStates.OUT_FOCUS;

//Create SGMLib instance with context: this
sgmLib = new SGMLib(this);

Expand Down Expand Up @@ -69,34 +71,51 @@ public void onDestroy(){

public void processTranscriptionCallback(String transcript, long timestamp, boolean isFinal){
Log.d(TAG, "PROCESS TRANSCRIPTION CALLBACK. IS IT FINAL? " + isFinal + " " + transcript);
if(isFinal) translateText(transcript);

//don't execute if we're not in focus
if (!focusState.equals(FocusStates.IN_FOCUS)){
return;
}

if(isFinal){
translateText(transcript);
}
}

public void translateCommandCallback(String args, long commandTriggeredTime){
Log.d("TAG","Translation callback called");

//StartScrollingText lets us aquire SGM's mode
sgmLib.startScrollingText("Translation: ");
//request to be the in focus app so we can continue to show transcripts
sgmLib.requestFocus(this::focusChangedCallback);

//StartScrollingText to show our translation
// sgmLib.startScrollingText("Translation: ");

//Subscribe to transcription stream
sgmLib.subscribe(DataStreamType.TRANSCRIPTION_ENGLISH_STREAM, this::processTranscriptionCallback);
}

public void focusChangedCallback(FocusStates focusState){
Log.d(TAG, "Focus callback called with state: " + focusState);
this.focusState = focusState;

//StartScrollingText to show our translation
if (focusState.equals(FocusStates.IN_FOCUS)) {
sgmLib.startScrollingText("Translation: ");
}
}

public void translateText(String text){
translationBackend.sourceText.setValue(text);
translationBackend.translate();
}

@Subscribe
public void onTranslateSuccess(TranslateSuccessEvent event){

if(sgmLib == null) return;

if(newScreen) {
newScreen = false;
//String sourceCode = translationBackend.sourceLang.getValue().getCode();
//String targetCode = translationBackend.targetLang.getValue().getCode();
//sgmLib.startScrollingText("Translation: ");
if (sgmLib == null){
return;
}

sgmLib.pushScrollingText(event.message);
}

Expand Down
15 changes: 15 additions & 0 deletions app/src/main/res/drawable-anydpi/ic_stat_name.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="#FFFFFF">
<group android:scaleX="0.92"
android:scaleY="0.92"
android:translateX="0.96"
android:translateY="0.96">
<path
android:fillColor="@android:color/white"
android:pathData="M12.87,15.07l-2.54,-2.51 0.03,-0.03c1.74,-1.94 2.98,-4.17 3.71,-6.53L17,6L17,4h-7L10,2L8,2v2L1,4v1.99h11.17C11.5,7.92 10.44,9.75 9,11.35 8.07,10.32 7.3,9.19 6.69,8h-2c0.73,1.63 1.73,3.17 2.98,4.56l-5.09,5.02L4,19l5,-5 3.11,3.11 0.76,-2.04zM18.5,10h-2L12,22h2l1.12,-3h4.75L21,22h2l-4.5,-12zM15.88,17l1.62,-4.33L19.12,17h-3.24z"/>
</group>
</vector>
Binary file added app/src/main/res/drawable-hdpi/ic_stat_name.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-mdpi/ic_stat_name.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-xhdpi/ic_stat_name.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-xxhdpi/ic_stat_name.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions app/src/main/res/drawable/ic_launcher_foreground.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="#000000">
<group android:scaleX="0.58"
android:scaleY="0.58"
android:translateX="5.04"
android:translateY="5.04">
<path
android:fillColor="@android:color/white"
android:pathData="M12.87,15.07l-2.54,-2.51 0.03,-0.03c1.74,-1.94 2.98,-4.17 3.71,-6.53L17,6L17,4h-7L10,2L8,2v2L1,4v1.99h11.17C11.5,7.92 10.44,9.75 9,11.35 8.07,10.32 7.3,9.19 6.69,8h-2c0.73,1.63 1.73,3.17 2.98,4.56l-5.09,5.02L4,19l5,-5 3.11,3.11 0.76,-2.04zM18.5,10h-2L12,22h2l1.12,-3h4.75L21,22h2l-4.5,-12zM15.88,17l1.62,-4.33L19.12,17h-3.24z"/>
</group>
</vector>
42 changes: 0 additions & 42 deletions app/src/main/res/drawable/logo_mlkit.xml

This file was deleted.

5 changes: 5 additions & 0 deletions app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
</adaptive-icon>
5 changes: 5 additions & 0 deletions app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
</adaptive-icon>
Binary file added app/src/main/res/mipmap-hdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/mipmap-mdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/mipmap-xhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions app/src/main/res/values/ic_launcher_background.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ic_launcher_background">#C9C9C9</color>
</resources>
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">LanguageTranslator</string>
<string name="app_name">SmartGlassesLanguageTranslation</string>
<string name="translated_text_hint">Translated text</string>
<string name="downloaded_models_label">Downloaded models: %1$s</string>
<string name="translate_progress">Translating&#8230;</string>
Expand Down

0 comments on commit e2a4415

Please sign in to comment.