-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Fetch sound-letter correspondences from Content Provider
close #21
- Loading branch information
Showing
6 changed files
with
119 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
app/src/main/java/ai/elimu/herufi/ui/LetterSoundListActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<LetterSoundGson> 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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<ScrollView | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:background="@drawable/gradient_background"> | ||
|
||
<com.google.android.flexbox.FlexboxLayout | ||
android:id="@+id/letter_sound_list_flexbox_layout" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:paddingStart="@dimen/activity_horizontal_margin" | ||
android:paddingEnd="@dimen/activity_horizontal_margin" | ||
android:paddingTop="@dimen/activity_vertical_margin" | ||
android:paddingBottom="@dimen/activity_vertical_margin" | ||
app:flexWrap="wrap" | ||
app:justifyContent="center"> | ||
|
||
<include layout="@layout/activity_letter_sound_list_letter_view" /> | ||
</com.google.android.flexbox.FlexboxLayout> | ||
</ScrollView> |
19 changes: 19 additions & 0 deletions
19
app/src/main/res/layout/activity_letter_sound_list_letter_view.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<androidx.cardview.widget.CardView | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
android:layout_width="164dp" | ||
android:layout_height="219dp" | ||
android:layout_margin="8dp" | ||
app:cardCornerRadius="16dp" | ||
app:cardBackgroundColor="#F2FFFFFF" | ||
android:foreground="?android:attr/selectableItemBackground"> | ||
|
||
<TextView | ||
android:id="@+id/letter_sound_view_text_view" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="center" | ||
android:textSize="96sp" | ||
android:text="क" /> | ||
</androidx.cardview.widget.CardView> |