Skip to content

Commit

Permalink
Merge branch 'kavyanshkhandelwal/oppia#5273/fix-unused-attribute-warn…
Browse files Browse the repository at this point in the history
…ing' of https://github.com/kavyanshkhandelwal/oppia-android-forked into kavyanshkhandelwal/oppia#5273/fix-unused-attribute-warning
  • Loading branch information
kavyanshkhandelwal committed Jan 22, 2025
2 parents 88f764f + 42210e8 commit 1a1527f
Show file tree
Hide file tree
Showing 41 changed files with 186 additions and 91 deletions.
2 changes: 1 addition & 1 deletion .github/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# [Oppia Android](https://www.oppia.org)

[![Mailing List](https://img.shields.io/badge/Mailing%20List-Oppia%20Android-dev.svg)](mailto:[email protected]) [![Twitter Follow](https://img.shields.io/twitter/follow/oppiaorg.svg?style=social&label=Follow&maxAge=2592000?style=flat-square)](https://twitter.com/oppiaorg) [![GitHub issues by-label](https://img.shields.io/github/issues-search/oppia/oppia-android?label=Available%20starter%20issues&query=is%3Aopen%20is%3Aissue%20label%3A%22good%20first%20issue%22%20no%3Aassignee)](https://github.com/oppia/oppia-android/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22+no%3Aassignee)
[![Twitter Follow](https://img.shields.io/twitter/follow/oppiaorg.svg?style=social&label=Follow&maxAge=2592000?style=flat-square)](https://twitter.com/oppiaorg) [![GitHub issues by-label](https://img.shields.io/github/issues-search/oppia/oppia-android?label=Available%20starter%20issues&query=is%3Aopen%20is%3Aissue%20label%3A%22good%20first%20issue%22%20no%3Aassignee)](https://github.com/oppia/oppia-android/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22+no%3Aassignee)

[![Unit Tests (Robolectric -- Gradle)](https://github.com/oppia/oppia-android/actions/workflows/main.yml/badge.svg)](https://github.com/oppia/oppia-android/actions/workflows/main.yml) [![Unit Tests (Robolectric - Bazel)](https://github.com/oppia/oppia-android/actions/workflows/unit_tests.yml/badge.svg)](https://github.com/oppia/oppia-android/actions/workflows/unit_tests.yml) [![Build Tests](https://github.com/oppia/oppia-android/actions/workflows/build_tests.yml/badge.svg)](https://github.com/oppia/oppia-android/actions/workflows/build_tests.yml) [![Static Checks](https://github.com/oppia/oppia-android/actions/workflows/static_checks.yml/badge.svg)](https://github.com/oppia/oppia-android/actions/workflows/static_checks.yml)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ runs:
$ANDROID_HOME/cmdline-tools/tools/bin/sdkmanager --install "platform-tools"
shell: bash

- name: Install SDK 33
- name: Install SDK 34
run: |
$ANDROID_HOME/cmdline-tools/tools/bin/sdkmanager --install "platforms;android-33"
$ANDROID_HOME/cmdline-tools/tools/bin/sdkmanager --install "platforms;android-34"
shell: bash

- name: Install build tools 32.0.0
Expand Down
5 changes: 0 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ name: Unit Tests (Robolectric -- Gradle)
# events or push events in the develop branch.
on:
workflow_dispatch:
pull_request:
push:
branches:
# Push events on develop branch
- develop

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}
Expand Down
4 changes: 2 additions & 2 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,14 @@ package_group(
"flavor": "oppia",
"min_sdk_version": 21,
"multidex": "native",
"target_sdk_version": 33,
"target_sdk_version": 34,
},
{
"flavor": "oppia_kitkat",
"main_dex_list": "//:config/kitkat_main_dex_class_list.txt",
"min_sdk_version": 21,
"multidex": "manual_main_dex",
"target_sdk_version": 33,
"target_sdk_version": 34,
},
]
]
Expand Down
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'

android {
compileSdkVersion 33
buildToolsVersion "30.0.2"
compileSdkVersion 34
buildToolsVersion "30.0.0"
defaultConfig {
applicationId "org.oppia.android"
minSdkVersion 21
targetSdkVersion 33
targetSdkVersion 34
versionCode 1
versionName "1.0"
multiDexEnabled true
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/AppAndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.oppia.android.app.ui">
<uses-sdk android:minSdkVersion="19"
android:targetSdkVersion="33" />
android:targetSdkVersion="34" />
</manifest>
2 changes: 1 addition & 1 deletion app/src/main/DatabindingAdaptersManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.oppia.android.databinding.adapters">
<uses-sdk android:minSdkVersion="19"
android:targetSdkVersion="33" />
android:targetSdkVersion="34" />
</manifest>
2 changes: 1 addition & 1 deletion app/src/main/DatabindingResourcesManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.oppia.android.app.databinding">
<uses-sdk android:minSdkVersion="19"
android:targetSdkVersion="33" />
android:targetSdkVersion="34" />
</manifest>
2 changes: 1 addition & 1 deletion app/src/main/RecyclerviewAdaptersManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.oppia.android.app.recyclerview.adapters">
<uses-sdk android:minSdkVersion="19"
android:targetSdkVersion="33" />
android:targetSdkVersion="34" />
</manifest>
2 changes: 1 addition & 1 deletion app/src/main/ViewModelManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.oppia.android.app.vm">
<uses-sdk android:minSdkVersion="19"
android:targetSdkVersion="33" />
android:targetSdkVersion="34" />
</manifest>
2 changes: 1 addition & 1 deletion app/src/main/ViewModelsManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.oppia.android.app.view.models">
<uses-sdk android:minSdkVersion="19"
android:targetSdkVersion="33" />
android:targetSdkVersion="34" />
</manifest>
2 changes: 1 addition & 1 deletion app/src/main/ViewsManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.oppia.android.app.views">
<uses-sdk android:minSdkVersion="19"
android:targetSdkVersion="33" />
android:targetSdkVersion="34" />
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import org.oppia.android.domain.translation.TranslationController
/** Completed story view model for the recycler view in [CompletedStoryListFragment]. */
class CompletedStoryItemViewModel(
private val activity: AppCompatActivity,
private val internalProfileId: Int,
private val profileId: ProfileId,
val completedStory: CompletedStory,
val entityType: String,
private val intentFactoryShim: IntentFactoryShim,
Expand All @@ -37,7 +37,7 @@ class CompletedStoryItemViewModel(
/** Called when user clicks on CompletedStoryItem. */
fun onCompletedStoryItemClicked() {
routeToTopicPlayStory(
ProfileId.newBuilder().setInternalId(internalProfileId).build(),
profileId,
completedStory.classroomId,
completedStory.topicId,
completedStory.storyId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ class CompletedStoryListActivity : InjectableAutoLocalizedAppCompatActivity() {
super.onCreate(savedInstanceState)
(activityComponent as ActivityComponentImpl).inject(this)

val internalProfileId: Int = intent?.extractCurrentUserProfileId()?.internalId ?: -1
completedStoryListActivityPresenter.handleOnCreate(internalProfileId)
val profileId = intent?.extractCurrentUserProfileId() ?: ProfileId.getDefaultInstance()
completedStoryListActivityPresenter.handleOnCreate(profileId)
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package org.oppia.android.app.completedstorylist
import androidx.appcompat.app.AppCompatActivity
import org.oppia.android.R
import org.oppia.android.app.activity.ActivityScope
import org.oppia.android.app.model.ProfileId
import javax.inject.Inject

/** The presenter for [CompletedStoryListActivity]. */
Expand All @@ -27,10 +28,24 @@ class CompletedStoryListActivityPresenter
}
}

<<<<<<< HEAD
private fun getCompletedStoryListFragment(): CompletedStoryListFragment? =
=======
/** Initializes views for [CompletedStoryListActivity] and binds [CompletedStoryListFragment]. */
fun handleOnCreate(profileId: ProfileId) {
activity.setContentView(R.layout.completed_story_list_activity)
if (getCompletedStoryListFragment() == null) {
>>>>>>> 42210e8069394528330be84c5f4893bb2dafc2bf
activity
.supportFragmentManager
.findFragmentById(
R.id.completed_story_list_fragment_placeholder,
<<<<<<< HEAD
) as CompletedStoryListFragment?
=======
CompletedStoryListFragment.newInstance(profileId),
CompletedStoryListFragment.COMPLETED_STORY_LIST_FRAGMENT_TAG
).commitNow()
}
>>>>>>> 42210e8069394528330be84c5f4893bb2dafc2bf
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ class CompletedStoryListFragment : InjectableFragment() {
const val COMPLETED_STORY_LIST_FRAGMENT_TAG = "COMPLETED_STORY_LIST_FRAGMENT_TAG"

/** Returns a new [CompletedStoryListFragment] to display corresponding to the specified profile ID. */
fun newInstance(internalProfileId: Int): CompletedStoryListFragment {
val profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build()
fun newInstance(profileId: ProfileId): CompletedStoryListFragment {
return CompletedStoryListFragment().apply {
arguments =
Bundle().apply {
Expand Down Expand Up @@ -49,11 +48,14 @@ class CompletedStoryListFragment : InjectableFragment() {
"Expected arguments to be passed to CompletedStoryListFragment"
}
val profileId = arguments.extractCurrentUserProfileId()
val internalProfileId = profileId.internalId
return completedStoryListFragmentPresenter.handleCreateView(
inflater,
container,
<<<<<<< HEAD
internalProfileId,
=======
profileId
>>>>>>> 42210e8069394528330be84c5f4893bb2dafc2bf
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.GridLayoutManager
import org.oppia.android.R
import org.oppia.android.app.model.ProfileId
import org.oppia.android.app.recyclerview.BindableAdapter
import org.oppia.android.databinding.CompletedStoryItemBinding
import org.oppia.android.databinding.CompletedStoryListFragmentBinding
Expand All @@ -31,6 +32,7 @@ class CompletedStoryListFragmentPresenter
): View? {
viewModel.setProfileId(internalProfileId)

<<<<<<< HEAD
binding =
CompletedStoryListFragmentBinding
.inflate(
Expand All @@ -53,6 +55,15 @@ class CompletedStoryListFragmentPresenter
}
return binding.root
}
=======
/** Initializes and creates the views for [CompletedStoryListFragment]. */
fun handleCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
profileId: ProfileId
): View? {
viewModel.setProfileId(profileId)
>>>>>>> 42210e8069394528330be84c5f4893bb2dafc2bf

private fun createRecyclerViewAdapter(): BindableAdapter<CompletedStoryItemViewModel> =
singleTypeBuilderFactory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import javax.inject.Inject

/** The ObservableViewModel for [CompletedStoryListFragment]. */
@FragmentScope
<<<<<<< HEAD
class CompletedStoryListViewModel
@Inject
constructor(
Expand All @@ -37,6 +38,22 @@ class CompletedStoryListViewModel
ProfileId.newBuilder().setInternalId(internalProfileId).build(),
).toLiveData()
}
=======
class CompletedStoryListViewModel @Inject constructor(
private val activity: AppCompatActivity,
private val intentFactoryShim: IntentFactoryShim,
private val topicController: TopicController,
private val oppiaLogger: OppiaLogger,
private val translationController: TranslationController,
@StoryHtmlParserEntityType private val entityType: String
) : ObservableViewModel() {
/** [profileId] needs to be set before any of the live data members can be accessed. */
private var profileId: ProfileId = ProfileId.getDefaultInstance()

private val completedStoryListResultLiveData: LiveData<AsyncResult<CompletedStoryList>> by lazy {
topicController.getCompletedStoryList(profileId).toLiveData()
}
>>>>>>> 42210e8069394528330be84c5f4893bb2dafc2bf

private val completedStoryLiveData: LiveData<CompletedStoryList> by lazy {
Transformations.map(completedStoryListResultLiveData, ::processCompletedStoryListResult)
Expand All @@ -47,10 +64,17 @@ class CompletedStoryListViewModel
Transformations.map(completedStoryLiveData, ::processCompletedStoryList)
}

<<<<<<< HEAD
/** Sets internalProfileId to this ViewModel. */
fun setProfileId(internalProfileId: Int) {
this.internalProfileId = internalProfileId
}
=======
/** Sets internalProfileId to this ViewModel. */
fun setProfileId(profileId: ProfileId) {
this.profileId = profileId
}
>>>>>>> 42210e8069394528330be84c5f4893bb2dafc2bf

private fun processCompletedStoryListResult(completedStoryListResult: AsyncResult<CompletedStoryList>): CompletedStoryList =
when (completedStoryListResult) {
Expand Down Expand Up @@ -83,3 +107,26 @@ class CompletedStoryListViewModel
return itemViewModelList
}
}
<<<<<<< HEAD
=======

private fun processCompletedStoryList(
completedStoryList: CompletedStoryList
): List<CompletedStoryItemViewModel> {
val itemViewModelList: MutableList<CompletedStoryItemViewModel> = mutableListOf()
itemViewModelList.addAll(
completedStoryList.completedStoryList.map { completedStory ->
CompletedStoryItemViewModel(
activity,
profileId,
completedStory,
entityType,
intentFactoryShim,
translationController
)
}
)
return itemViewModelList
}
}
>>>>>>> 42210e8069394528330be84c5f4893bb2dafc2bf
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import org.oppia.android.app.model.ReadingTextSize
import javax.inject.Inject

/** Utility to change the scale of font for the entire app. */
<<<<<<< HEAD
class FontScaleConfigurationUtil
@Inject
constructor() {
Expand All @@ -29,6 +30,35 @@ class FontScaleConfigurationUtil
metrics.scaledDensity = configuration.fontScale * metrics.density
context.createConfigurationContext(configuration)
context.resources.displayMetrics.setTo(metrics)
=======
class FontScaleConfigurationUtil @Inject constructor() {
/**
* Updates the specified [context]'s current configuration to scale text size according to the
* provided [readingTextSize].
*/
fun adjustFontScale(context: Context, readingTextSize: ReadingTextSize) {
val configuration = context.resources.configuration
configuration.fontScale = getReadingTextSizeConfigurationUtil(readingTextSize)
val metrics: DisplayMetrics = context.resources.displayMetrics
val windowManager = context.getSystemService(WINDOW_SERVICE) as? WindowManager
// TODO(#3616): Migrate to the proper SDK 30+ APIs.
@Suppress("DEPRECATION") // The code is correct for targeted versions of Android.
windowManager!!.defaultDisplay.getMetrics(metrics)
// TODO(#5625): Migrate away from scaledDensity.
@Suppress("DEPRECATION")
metrics.scaledDensity = configuration.fontScale * metrics.density
context.createConfigurationContext(configuration)
context.resources.displayMetrics.setTo(metrics)
}

private fun getReadingTextSizeConfigurationUtil(readingTextSize: ReadingTextSize): Float {
return when (readingTextSize) {
ReadingTextSize.SMALL_TEXT_SIZE -> .8f
ReadingTextSize.MEDIUM_TEXT_SIZE -> 1.0f
ReadingTextSize.LARGE_TEXT_SIZE -> 1.2f
ReadingTextSize.EXTRA_LARGE_TEXT_SIZE -> 1.4f
else -> 1.0f
>>>>>>> 42210e8069394528330be84c5f4893bb2dafc2bf
}

private fun getReadingTextSizeConfigurationUtil(readingTextSize: ReadingTextSize): Float =
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/res/values-ar/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
<string name="topic_revision_tab_spotlight_hint">راجع المفاهيم المكتسبة من الدروس المكتملة هنا.</string>
<string name="first_chapter_spotlight_hint">انقر هنا لبدء تشغيل درس.</string>
<string name="state_continue_button">استمرار</string>
<string name="state_continue_submit">تقديم</string>
<string name="state_continue_submit">إرسال</string>
<string name="previous_state_description">التوجه إلى البطاقة السابقة</string>
<string name="next_state_description">التوجه إلى البطاقة القادمة</string>
<string name="state_submit_button">تقديم</string>
Expand Down Expand Up @@ -261,7 +261,7 @@
<string name="admin_auth_pin">رقم التعريف الشخصي الخاص بالمشرف</string>
<string name="admin_auth_incorrect">رقم التعريف الشخصي الخاص بالمشرف غير صحيح. من فضلك حاول مجددًا.</string>
<string name="admin_auth_null">من فضلك أدخل رقم التعريف الشخصي الخاص بالمشرف.</string>
<string name="admin_auth_submit">تقديم</string>
<string name="admin_auth_submit">إرسال</string>
<string name="admin_auth_close">إغلاق</string>
<string name="admin_pin_requirement_description">قبل أن نضيف ملفات شخصية، نريد أن نحمي حسابك الشخصي عن طريق إنشاء رقم تعريف شخصي. هذا يمكنك من السماح بالتنزيلات وإدارة الملفات الشخصية على الجهاز.</string>
<string name="admin_pin_pin_description">لا تستخدم رقم تعريف شخصي استخدمته من قبل لحسابات الشخصية مثل حساب البنك أو حساب الضمان الإجتماعي.</string>
Expand Down Expand Up @@ -331,7 +331,7 @@
<string name="admin_settings_heading">الوصول إلى إعدادات المشرف</string>
<string name="admin_settings_sub">رقم التعريف الشخصي الخاص بالمشرف مطلوب لتغيير رقم التعريف الشخصي الخاص بالمستخدم</string>
<string name="admin_settings_cancel">إلغاء</string>
<string name="admin_settings_submit">تقديم</string>
<string name="admin_settings_submit">إرسال</string>
<string name="admin_settings_incorrect">رقم التعريف الشخصي الخاص بالمشرف غير صحيح. من فضلك حاول مجددًا.</string>
<string name="admin_settings_enter_user_new_pin">رقم التعريف الشخصي الجديد الخاص ب%1$s.</string>
<string name="reset_pin_enter">أدخل رقم تعريف شخصي جديد</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/test/resources/robolectric.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# app/src/test/resources/robolectric.properties
# TODO(#4748): Remove the need for this file after upgrading Robolectric tests to API 33
# TODO(#4748): Remove the need for this file after upgrading Robolectric tests to API 34
sdk=30
Loading

0 comments on commit 1a1527f

Please sign in to comment.