-
-
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.
Browse files
Browse the repository at this point in the history
…-Provider #1 fetch letters from the content provider
- Loading branch information
Showing
27 changed files
with
225 additions
and
279 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package ai.elimu.herufi; | ||
|
||
import android.app.Application; | ||
import android.speech.tts.TextToSpeech; | ||
import android.util.Log; | ||
|
||
public class BaseApplication extends Application { | ||
|
||
private TextToSpeech tts; | ||
|
||
@Override | ||
public void onCreate() { | ||
Log.i(getClass().getName(), "onCreate"); | ||
super.onCreate(); | ||
|
||
// Initialize Text-to-Speech | ||
getTTS(); | ||
} | ||
|
||
public TextToSpeech getTTS() { | ||
if (tts == null) { | ||
tts = new TextToSpeech(getApplicationContext(), new TextToSpeech.OnInitListener() { | ||
@Override | ||
public void onInit(int status) { | ||
Log.i(getClass().getName(), "TextToSpeech onInit"); | ||
} | ||
}); | ||
} | ||
return tts; | ||
} | ||
|
||
@Override | ||
public void onTerminate() { | ||
Log.i(getClass().getName(), "onTerminate"); | ||
super.onTerminate(); | ||
|
||
// Release the resources used by the TextToSpeech engine | ||
if (tts != null) { | ||
tts.shutdown(); | ||
} | ||
} | ||
} |
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
69 changes: 69 additions & 0 deletions
69
app/src/main/java/ai/elimu/herufi/ui/LetterListActivity.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,69 @@ | ||
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.annotation.Nullable; | ||
import androidx.appcompat.app.AppCompatActivity; | ||
|
||
import com.google.android.flexbox.FlexboxLayout; | ||
|
||
import java.util.List; | ||
|
||
import ai.elimu.herufi.BaseApplication; | ||
import ai.elimu.herufi.R; | ||
import ai.elimu.herufi.util.ContentProviderHelper; | ||
import ai.elimu.model.v2.gson.content.LetterGson; | ||
|
||
public class LetterListActivity extends AppCompatActivity { | ||
|
||
private FlexboxLayout flexboxLayout; | ||
|
||
@Override | ||
protected void onCreate(@Nullable Bundle savedInstanceState) { | ||
Log.i(getClass().getName(), "onCreate"); | ||
super.onCreate(savedInstanceState); | ||
|
||
setContentView(R.layout.activity_letter_list); | ||
|
||
flexboxLayout = findViewById(R.id.letter_list_flexbox_layout); | ||
} | ||
|
||
@Override | ||
protected void onStart() { | ||
Log.i(getClass().getName(), "onStart"); | ||
super.onStart(); | ||
|
||
List<LetterGson> letterGsons = ContentProviderHelper.getLetterGsons(getApplicationContext()); | ||
Log.i(getClass().getName(), "letterGsons.size(): " + letterGsons.size()); | ||
|
||
// Create a view for each letter in the list | ||
flexboxLayout.removeAllViews(); | ||
for (final LetterGson letterGson : letterGsons) { | ||
View letterView = LayoutInflater.from(this).inflate(R.layout.activity_letter_list_letter_view, flexboxLayout, false); | ||
|
||
TextView textView = letterView.findViewById(R.id.letter_view_text_view); | ||
textView.setText(letterGson.getText()); | ||
|
||
// Play letter sound when pressed | ||
letterView.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
Log.i(getClass().getName(), "letterView onClick"); | ||
|
||
Log.i(getClass().getName(), "letterGson.getText(): '" + letterGson.getText() + "'"); | ||
|
||
BaseApplication baseApplication = (BaseApplication) getApplication(); | ||
TextToSpeech tts = baseApplication.getTTS(); | ||
tts.speak(letterGson.getText(), TextToSpeech.QUEUE_FLUSH, null, "letter_" + letterGson.getId()); | ||
} | ||
}); | ||
|
||
flexboxLayout.addView(letterView); | ||
} | ||
} | ||
} |
49 changes: 0 additions & 49 deletions
49
app/src/main/java/ai/elimu/herufi/ui/home/HomeFragment.java
This file was deleted.
Oops, something went wrong.
19 changes: 0 additions & 19 deletions
19
app/src/main/java/ai/elimu/herufi/ui/home/HomeViewModel.java
This file was deleted.
Oops, something went wrong.
44 changes: 0 additions & 44 deletions
44
app/src/main/java/ai/elimu/herufi/ui/notifications/NotificationsFragment.java
This file was deleted.
Oops, something went wrong.
19 changes: 0 additions & 19 deletions
19
app/src/main/java/ai/elimu/herufi/ui/notifications/NotificationsViewModel.java
This file was deleted.
Oops, something went wrong.
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,11 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:shape="rectangle"> | ||
|
||
<gradient | ||
android:angle="135" | ||
android:endColor="@color/green_darken_2" | ||
android:centerColor="@color/green" | ||
android:startColor="@color/green_lighten_2" | ||
android:type="linear" /> | ||
</shape> |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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_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_list_letter_view" /> | ||
</com.google.android.flexbox.FlexboxLayout> | ||
</ScrollView> |
Oops, something went wrong.