forked from oppia/oppia-android
-
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.
Fix Part of oppia#4938: Introduce Onboarding Audio language screen (o…
…ppia#5386) <!-- READ ME FIRST: Please fill in the explanation section below and check off every point from the Essential Checklist! --> ## Explanation Fix Part of oppia#4938: New screen to allow a user to select an audio language during the onboarding process. This PR only adds the layout and navigation functions without implementing the language selection functionality. ||Portrait|Landscape| |--|--|--| |Mobile|![Screenshot_1719963278](https://github.com/oppia/oppia-android/assets/59600948/8f6e9f7b-0362-4172-9a46-036661b71598)|![Screenshot_1719963292](https://github.com/oppia/oppia-android/assets/59600948/19c1124c-1c63-4b71-b678-597db2f005d8)| ||![Screenshot_1719963273](https://github.com/oppia/oppia-android/assets/59600948/324726d9-8fdb-466d-82d0-71b7ddc3581a)|![Screenshot_1719963301](https://github.com/oppia/oppia-android/assets/59600948/8d3c1b27-217e-4e1d-b633-20368a057569)| |Tablet|![Screenshot_1719963641](https://github.com/oppia/oppia-android/assets/59600948/1b53195b-2c17-4a15-8c95-6090fa77470e)|![Screenshot_1719963651](https://github.com/oppia/oppia-android/assets/59600948/49300ebf-bfae-4a42-922d-64b591bbf138)| ||![Screenshot_1719963670](https://github.com/oppia/oppia-android/assets/59600948/cf4e37d3-56f0-47c4-9f0d-b01d75cceb8d)|![Screenshot_1719963660](https://github.com/oppia/oppia-android/assets/59600948/c4b8f6f7-a41e-44a0-af7f-1c8bfca9fa4f)| ## Essential Checklist <!-- Please tick the relevant boxes by putting an "x" in them. --> - [x] The PR title and explanation each start with "Fix #bugnum: " (If this PR fixes part of an issue, prefix the title with "Fix part of #bugnum: ...".) - [x] Any changes to [scripts/assets](https://github.com/oppia/oppia-android/tree/develop/scripts/assets) files have their rationale included in the PR explanation. - [x] The PR follows the [style guide](https://github.com/oppia/oppia-android/wiki/Coding-style-guide). - [x] The PR does not contain any unnecessary code changes from Android Studio ([reference](https://github.com/oppia/oppia-android/wiki/Guidance-on-submitting-a-PR#undo-unnecessary-changes)). - [x] The PR is made from a branch that's **not** called "develop" and is up-to-date with "develop". - [x] The PR is **assigned** to the appropriate reviewers ([reference](https://github.com/oppia/oppia-android/wiki/Guidance-on-submitting-a-PR#clarification-regarding-assignees-and-reviewers-section)).
- Loading branch information
1 parent
fcd75ef
commit 1c4b17a
Showing
19 changed files
with
813 additions
and
51 deletions.
There are no files selected for viewing
73 changes: 73 additions & 0 deletions
73
app/src/main/java/org/oppia/android/app/onboarding/AudioLanguageFragmentPresenter.kt
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,73 @@ | ||
package org.oppia.android.app.onboarding | ||
|
||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import android.view.inputmethod.EditorInfo | ||
import android.widget.ArrayAdapter | ||
import androidx.appcompat.app.AppCompatActivity | ||
import androidx.fragment.app.Fragment | ||
import com.google.android.material.appbar.AppBarLayout | ||
import org.oppia.android.R | ||
import org.oppia.android.app.options.AudioLanguageSelectionViewModel | ||
import org.oppia.android.app.translation.AppLanguageResourceHandler | ||
import org.oppia.android.databinding.AudioLanguageSelectionFragmentBinding | ||
import javax.inject.Inject | ||
|
||
/** The presenter for [AudioLanguageFragment]. */ | ||
class AudioLanguageFragmentPresenter @Inject constructor( | ||
private val fragment: Fragment, | ||
private val activity: AppCompatActivity, | ||
private val appLanguageResourceHandler: AppLanguageResourceHandler, | ||
private val audioLanguageSelectionViewModel: AudioLanguageSelectionViewModel | ||
) { | ||
private lateinit var binding: AudioLanguageSelectionFragmentBinding | ||
|
||
/** | ||
* Returns a newly inflated view to render the fragment with an evaluated audio language as the | ||
* initial selected language, based on current locale. | ||
*/ | ||
fun handleCreateView( | ||
inflater: LayoutInflater, | ||
container: ViewGroup? | ||
): View { | ||
|
||
// Hide toolbar as it's not needed in this layout. The toolbar is created by a shared activity | ||
// and is required in OptionsFragment. | ||
activity.findViewById<AppBarLayout>(R.id.reading_list_app_bar_layout).visibility = View.GONE | ||
|
||
binding = AudioLanguageSelectionFragmentBinding.inflate( | ||
inflater, | ||
container, | ||
/* attachToRoot= */ false | ||
) | ||
binding.lifecycleOwner = fragment | ||
|
||
binding.audioLanguageText.text = appLanguageResourceHandler.getStringInLocaleWithWrapping( | ||
R.string.audio_language_fragment_text, | ||
appLanguageResourceHandler.getStringInLocale(R.string.app_name) | ||
) | ||
|
||
binding.onboardingNavigationBack.setOnClickListener { | ||
activity.finish() | ||
} | ||
|
||
val adapter = ArrayAdapter( | ||
fragment.requireContext(), | ||
R.layout.onboarding_language_dropdown_item, | ||
R.id.onboarding_language_text_view, | ||
audioLanguageSelectionViewModel.availableAudioLanguages | ||
) | ||
|
||
binding.audioLanguageDropdownList.apply { | ||
setAdapter(adapter) | ||
setText( | ||
audioLanguageSelectionViewModel.defaultLanguageSelection, | ||
false | ||
) | ||
setRawInputType(EditorInfo.TYPE_NULL) | ||
} | ||
|
||
return binding.root | ||
} | ||
} |
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
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
96 changes: 96 additions & 0 deletions
96
app/src/main/res/layout-land/audio_language_selection_fragment.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,96 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<layout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:card_view="http://schemas.android.com/apk/res-auto"> | ||
|
||
<androidx.constraintlayout.widget.ConstraintLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:background="@color/component_color_onboarding_shared_green_color"> | ||
|
||
<androidx.constraintlayout.widget.Guideline | ||
android:id="@+id/audio_language_background_guide" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:orientation="horizontal" | ||
app:layout_constraintGuide_percent="0.55" /> | ||
|
||
<org.oppia.android.app.customview.OppiaCurveBackgroundView | ||
android:layout_width="match_parent" | ||
android:layout_height="0dp" | ||
app:customBackgroundColor="@{@color/component_color_onboarding_shared_white_color}" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintTop_toBottomOf="@id/audio_language_background_guide" /> | ||
|
||
<TextView | ||
android:id="@+id/audio_language_text" | ||
style="@style/AudioLanguageTextStyle" | ||
android:layout_marginTop="@dimen/phone_shared_margin_xl" | ||
android:layout_marginEnd="@dimen/phone_shared_margin_large" | ||
android:text="@string/audio_language_fragment_text" | ||
android:textColor="@color/component_color_onboarding_shared_white_color" | ||
app:layout_constraintBottom_toTopOf="@id/audio_language_subtitle" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" /> | ||
|
||
<TextView | ||
android:id="@+id/audio_language_subtitle" | ||
style="@style/AudioLanguageSubtitleStyle" | ||
android:layout_marginStart="@dimen/phone_shared_margin_xl" | ||
android:layout_marginTop="@dimen/phone_shared_margin_small" | ||
android:layout_marginEnd="@dimen/phone_shared_margin_xl" | ||
android:text="@string/audio_language_fragment_subtitle" | ||
android:textColor="@color/component_color_onboarding_shared_white_color" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@id/audio_language_text" | ||
app:layout_constraintWidth_percent="0.50" /> | ||
|
||
<com.google.android.material.card.MaterialCardView | ||
android:id="@+id/audio_language_dropdown_background" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_marginStart="@dimen/phone_shared_margin_xl" | ||
android:layout_marginTop="@dimen/phone_shared_margin_large" | ||
android:layout_marginEnd="@dimen/phone_shared_margin_xl" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@id/audio_language_subtitle" | ||
app:layout_constraintWidth_percent="0.50" | ||
card_view:cardCornerRadius="@dimen/onboarding_shared_corner_radius" | ||
card_view:cardElevation="@dimen/onboarding_shared_elevation" | ||
card_view:cardUseCompatPadding="false"> | ||
|
||
<com.google.android.material.textfield.TextInputLayout style="@style/LanguageDropdownStyle"> | ||
|
||
<AutoCompleteTextView | ||
android:id="@+id/audio_language_dropdown_list" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:inputType="none" | ||
android:padding="@dimen/onboarding_shared_padding_small" /> | ||
</com.google.android.material.textfield.TextInputLayout> | ||
</com.google.android.material.card.MaterialCardView> | ||
|
||
<Button | ||
android:id="@+id/onboarding_navigation_back" | ||
style="@style/OnboardingNavigationSecondaryButton" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_margin="@dimen/phone_shared_margin_large" | ||
android:text="@string/onboarding_navigation_back" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" /> | ||
|
||
<Button | ||
android:id="@+id/onboarding_navigation_continue" | ||
style="@style/OnboardingNavigationPrimaryButton" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_margin="@dimen/phone_shared_margin_large" | ||
android:text="@string/onboarding_navigation_continue" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent" /> | ||
</androidx.constraintlayout.widget.ConstraintLayout> | ||
</layout> |
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
Oops, something went wrong.