diff --git a/app/build.gradle b/app/build.gradle index 03b342a..03c72e4 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -50,7 +50,7 @@ dependencies { implementation fileTree(dir: "libs", include: ["*.jar"]) implementation 'com.github.elimu-ai:model:model-2.0.66' // See https://jitpack.io/#elimu-ai/model - implementation 'com.github.elimu-ai:content-provider:1.2.25@aar' // See https://jitpack.io/#elimu-ai/content-provider + implementation 'com.github.elimu-ai:content-provider:1.2.26@aar' // See https://jitpack.io/#elimu-ai/content-provider implementation 'com.github.elimu-ai:analytics:3.1.11@aar' // See https://jitpack.io/#elimu-ai/analytics implementation 'androidx.appcompat:appcompat:1.6.1' diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 4dcec49..087a739 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -27,7 +27,7 @@ - + + diff --git a/app/src/main/java/ai/elimu/herufi/MainActivity.java b/app/src/main/java/ai/elimu/herufi/MainActivity.java index 0677a10..682fca9 100644 --- a/app/src/main/java/ai/elimu/herufi/MainActivity.java +++ b/app/src/main/java/ai/elimu/herufi/MainActivity.java @@ -7,6 +7,7 @@ import androidx.appcompat.app.AppCompatActivity; import ai.elimu.herufi.ui.LetterListActivity; +import ai.elimu.herufi.ui.LetterSoundListActivity; public class MainActivity extends AppCompatActivity { @@ -26,7 +27,8 @@ protected void onStart() { Log.i(getClass().getName(), "onStart"); super.onStart(); - Intent intent = new Intent(getApplicationContext(), LetterListActivity.class); +// Intent intent = new Intent(getApplicationContext(), LetterListActivity.class); + Intent intent = new Intent(getApplicationContext(), LetterSoundListActivity.class); startActivity(intent); finish(); } diff --git a/app/src/main/java/ai/elimu/herufi/ui/LetterSoundListActivity.java b/app/src/main/java/ai/elimu/herufi/ui/LetterSoundListActivity.java new file mode 100644 index 0000000..e0197f6 --- /dev/null +++ b/app/src/main/java/ai/elimu/herufi/ui/LetterSoundListActivity.java @@ -0,0 +1,72 @@ +package ai.elimu.herufi.ui; + +import android.os.Bundle; +import android.speech.tts.TextToSpeech; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.TextView; + +import androidx.appcompat.app.AppCompatActivity; + +import com.google.android.flexbox.FlexboxLayout; + +import java.util.List; + +import ai.elimu.content_provider.utils.ContentProviderUtil; +import ai.elimu.herufi.BaseApplication; +import ai.elimu.herufi.BuildConfig; +import ai.elimu.herufi.R; +import ai.elimu.model.v2.gson.content.LetterSoundGson; + +public class LetterSoundListActivity extends AppCompatActivity { + + private FlexboxLayout flexboxLayout; + + @Override + public void onCreate(Bundle savedInstanceState) { + Log.i(getClass().getName(), "onCreate"); + super.onCreate(savedInstanceState); + + setContentView(R.layout.activity_letter_sound_list); + + flexboxLayout = findViewById(R.id.letter_sound_list_flexbox_layout); + } + + @Override + protected void onStart() { + Log.i(getClass().getName(), "onStart"); + super.onStart(); + + List letterSoundGsons = ContentProviderUtil.getAllLetterSoundGsons(getApplicationContext(), BuildConfig.CONTENT_PROVIDER_APPLICATION_ID); + Log.i(getClass().getName(), "letterSoundGsons.size(): " + letterSoundGsons.size()); + + // Create a view for each letter-sound correspondence in the list + flexboxLayout.removeAllViews(); + for (final LetterSoundGson letterSoundGson : letterSoundGsons) { + View letterSoundView = LayoutInflater.from(this).inflate(R.layout.activity_letter_sound_list_letter_view, flexboxLayout, false); + + TextView textView = letterSoundView.findViewById(R.id.letter_sound_view_text_view); + textView.setText("id " + letterSoundGson.getId()); + + // Play sound when pressed + letterSoundView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Log.i(getClass().getName(), "letterView onClick"); + + Log.i(getClass().getName(), "letterSoundGson.getId(): '" + letterSoundGson.getId() + "'"); + + BaseApplication baseApplication = (BaseApplication) getApplication(); + TextToSpeech tts = baseApplication.getTTS(); +// tts.speak(letterSoundGson.getText(), TextToSpeech.QUEUE_FLUSH, null, "letter_sound_" + letterSoundGson.getId()); + + // Report learning event to the Analytics application (https://github.com/elimu-ai/analytics) +// LearningEventUtil.reportLetterSoundLearningEvent(letterSoundGson, LearningEventType.LETTER_SOUND_PRESSED, getApplicationContext(), BuildConfig.ANALYTICS_APPLICATION_ID); + } + }); + + flexboxLayout.addView(letterSoundView); + } + } +} diff --git a/app/src/main/res/layout/activity_letter_sound_list.xml b/app/src/main/res/layout/activity_letter_sound_list.xml new file mode 100644 index 0000000..84cbb9f --- /dev/null +++ b/app/src/main/res/layout/activity_letter_sound_list.xml @@ -0,0 +1,22 @@ + + + + + + + + diff --git a/app/src/main/res/layout/activity_letter_sound_list_letter_view.xml b/app/src/main/res/layout/activity_letter_sound_list_letter_view.xml new file mode 100644 index 0000000..2f62341 --- /dev/null +++ b/app/src/main/res/layout/activity_letter_sound_list_letter_view.xml @@ -0,0 +1,19 @@ + + + + +