Skip to content

Commit

Permalink
Fix #4735 Text unit is set in dp instead of sp (#5134)
Browse files Browse the repository at this point in the history
## Explanation
Fix #4735 , Added toolbar in admin_pin_activity xml file inorder to
control the title size using sp.

<!--
- Explain what your PR does. If this PR fixes an existing bug, please
include
- "Fixes #bugnum:" in the explanation so that GitHub can auto-close the
issue
  - when this PR is merged.
  -->

## 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)).

## For UI-specific PRs only

Before fix
Admin pin activity
| Light mode| 
|--------|
|![before
light](https://github.com/oppia/oppia-android/assets/76042077/e80cd747-b04c-43c5-96b9-848dc5db3400)
|

After fix
|Light mode| Dark mode|
|-----------|--------------|
|
![afterlightmode](https://github.com/oppia/oppia-android/assets/76042077/4445ebd1-3fde-40f4-a4cb-cb3716aad43e)
|
![afterdarkmode](https://github.com/oppia/oppia-android/assets/76042077/98bd0994-5f4d-464f-b170-d21e167a9eaa)
|

Co-authored-by: Adhiambo Peres <[email protected]>
  • Loading branch information
Vishwajith-Shettigar and adhiamboperes authored Sep 5, 2023
1 parent c5b11fe commit 7668bf0
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 7 deletions.
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@
<activity
android:name=".app.profile.AdminPinActivity"
android:label="@string/admin_pin_activity_title"
android:theme="@style/OppiaThemeWithoutActionBar"
android:windowSoftInputMode="adjustResize" />
<activity
android:name=".app.profile.PinPasswordActivity"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package org.oppia.android.app.profile
import android.content.Context
import android.content.Intent
import android.os.Bundle
import androidx.appcompat.widget.Toolbar
import org.oppia.android.R
import org.oppia.android.app.activity.ActivityComponentImpl
import org.oppia.android.app.activity.InjectableAutoLocalizedAppCompatActivity
import org.oppia.android.app.model.ScreenName.ADMIN_PIN_ACTIVITY
Expand Down Expand Up @@ -38,6 +40,9 @@ class AdminPinActivity : InjectableAutoLocalizedAppCompatActivity() {
super.onCreate(savedInstanceState)
(activityComponent as ActivityComponentImpl).inject(this)
adminPinActivityPresenter.handleOnCreate()

val toolbar: Toolbar = findViewById(R.id.admin_pin_toolbar)
setSupportActionBar(toolbar)
}

override fun onSupportNavigateUp(): Boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,22 @@ class AdminPinActivityPresenter @Inject constructor(

/** Binds ViewModel and sets up text and button listeners. */
fun handleOnCreate() {
activity.supportActionBar?.setDisplayHomeAsUpEnabled(true)
activity.supportActionBar?.setHomeAsUpIndicator(R.drawable.ic_close_white_24dp)
activity.supportActionBar?.setHomeActionContentDescription(R.string.admin_auth_close)

val binding =
DataBindingUtil.setContentView<AdminPinActivityBinding>(activity, R.layout.admin_pin_activity)

activity.setSupportActionBar(binding.adminPinToolbar)
activity.supportActionBar?.setDisplayHomeAsUpEnabled(true)
activity.supportActionBar?.setHomeAsUpIndicator(R.drawable.ic_close_white_24dp)
activity.supportActionBar?.setHomeActionContentDescription(R.string.admin_auth_close)

binding.apply {
lifecycleOwner = activity
viewModel = adminViewModel
}

binding.adminPinToolbar.title = resourceHandler
.getStringInLocale(R.string.admin_auth_activity_add_profiles_title)
// [onTextChanged] is a extension function defined at [TextInputEditTextHelper]
binding.adminPinInputPinEditText.onTextChanged { pin ->
pin?.let {
Expand Down
26 changes: 22 additions & 4 deletions app/src/main/res/layout/admin_pin_activity.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,32 @@
android:layout_width="match_parent"
android:layout_height="match_parent">


<androidx.appcompat.widget.Toolbar
android:id="@+id/admin_pin_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
android:elevation="4dp"
android:theme="@style/OppiaActionBarTheme"
style="@style/AdminPinToolbarTextAppearance"
app:titleTextAppearance="@style/AdminPinToolbarTextAppearance"
app:titleTextColor="@color/component_color_shared_activity_toolbar_text_color"
app:layout_constraintTop_toTopOf="parent" />

<androidx.core.widget.NestedScrollView
android:id="@+id/scrollViewAdminPin"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/component_color_shared_screen_secondary_background_color"
android:layout_width="@dimen/admin_auth_activity_layout_width"
android:layout_height="0dp"
android:fillViewport="true"
android:overScrollMode="never"
android:scrollbars="none">
android:scrollbars="none"
android:background="@color/component_color_shared_screen_secondary_background_color"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/admin_pin_toolbar"
>

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/admin_auth_container"
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -632,4 +632,8 @@
<item name="android:windowEnterAnimation">@anim/slide_up</item>
<item name="android:windowExitAnimation">@anim/slide_down</item>
</style>

<style name="AdminPinToolbarTextAppearance" parent="TextAppearance.Widget.AppCompat.Toolbar.Title">
<item name="android:textSize">20sp</item>
</style>
</resources>

0 comments on commit 7668bf0

Please sign in to comment.