Skip to content

Commit 1c8442b

Browse files
committed
Merge branch 'develop' into temp-integration-pt2
2 parents 787f0a2 + fdccc6f commit 1c8442b

File tree

7 files changed

+30
-33
lines changed

7 files changed

+30
-33
lines changed

app/src/main/java/org/oppia/app/player/state/SelectionInteractionView.kt

+5-9
Original file line numberDiff line numberDiff line change
@@ -39,22 +39,18 @@ class SelectionInteractionView @JvmOverloads constructor(
3939
lateinit var entityType: String
4040
private lateinit var explorationId: String
4141

42-
init {
43-
adapter = createAdapter()
44-
}
45-
4642
override fun onAttachedToWindow() {
4743
super.onAttachedToWindow()
4844
FragmentManager.findFragment<InjectableFragment>(this).createViewComponent(this).inject(this)
4945
}
5046

51-
fun setItemInputType(selectionItemInputType: SelectionItemInputType) {
47+
fun setAllOptionsItemInputType(selectionItemInputType: SelectionItemInputType) {
5248
// TODO(#299): Find a cleaner way to initialize the item input type. Using data-binding results in a race condition
5349
// with setting the adapter data, so this needs to be done in an order-agnostic way. There should be a way to do
5450
// this more efficiently and cleanly than always relying on notifying of potential changes in the adapter when the
5551
// type is set (plus the type ought to be permanent).
5652
this.selectionItemInputType = selectionItemInputType
57-
adapter!!.notifyDataSetChanged()
53+
adapter = createAdapter()
5854
}
5955

6056
// TODO(#264): Clean up HTML parser such that it can be handled completely through a binding adapter, allowing
@@ -106,10 +102,10 @@ class SelectionInteractionView @JvmOverloads constructor(
106102
}
107103

108104
/** Sets the [SelectionItemInputType] for a specific [SelectionInteractionView] via data-binding. */
109-
@BindingAdapter("itemInputType")
110-
fun setItemInputType(
105+
@BindingAdapter("allOptionsItemInputType")
106+
fun setAllOptionsItemInputType(
111107
selectionInteractionView: SelectionInteractionView, selectionItemInputType: SelectionItemInputType
112-
) = selectionInteractionView.setItemInputType(selectionItemInputType)
108+
) = selectionInteractionView.setAllOptionsItemInputType(selectionItemInputType)
113109

114110
/** Sets the exploration ID for a specific [SelectionInteractionView] via data-binding. */
115111
@BindingAdapter("explorationId")

app/src/main/java/org/oppia/app/topic/overview/TopicOverviewViewModel.kt

+17-16
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import javax.inject.Inject
1515
class TopicOverviewViewModel @Inject constructor(
1616
private val context: Context
1717
) : ObservableViewModel() {
18-
private val decimalFormat: DecimalFormat = DecimalFormat("#.###")
18+
private val decimalFormat: DecimalFormat = DecimalFormat("##")
1919

2020
val topic = ObservableField<Topic>(Topic.getDefaultInstance())
2121

@@ -25,20 +25,21 @@ class TopicOverviewViewModel @Inject constructor(
2525

2626
/** Returns the space this topic requires on disk, formatted for display. */
2727
fun getTopicSizeWithUnit(): String {
28-
val size: Double = topic.get()?.diskSizeBytes!!.toDouble()
29-
if (size == 0.0) {
30-
return "0 " + context.getString(R.string.size_bytes)
31-
}
32-
val sizeInKB = size / 1024.0
33-
val sizeInMB = size / 1024.0 / 1024.0
34-
val sizeInGB = size / 1024.0 / 1024.0 / 1024.0
35-
val sizeInTB = size / 1024.0 / 1024.0 / 1024.0 / 1024.0
36-
return when {
37-
sizeInTB >= 1 -> decimalFormat.format(sizeInTB) + " " + context.getString(R.string.size_tb)
38-
sizeInGB >= 1 -> decimalFormat.format(sizeInGB) + " " + context.getString(R.string.size_gb)
39-
sizeInMB >= 1 -> decimalFormat.format(sizeInMB) + " " + context.getString(R.string.size_mb)
40-
sizeInKB >= 1 -> decimalFormat.format(sizeInKB) + " " + context.getString(R.string.size_kb)
41-
else -> decimalFormat.format(size) + " " + context.getString(R.string.size_bytes)
42-
}
28+
return topic.get()?.let { topic ->
29+
val sizeInBytes: Int = topic.diskSizeBytes.toInt()
30+
val sizeInKb = sizeInBytes / 1024
31+
val sizeInMb = sizeInKb / 1024
32+
val sizeInGb = sizeInMb / 1024
33+
return@let when {
34+
sizeInGb >= 1 -> context.getString(R.string.size_gb, roundUpToHundreds(sizeInGb))
35+
sizeInMb >= 1 -> context.getString(R.string.size_mb, roundUpToHundreds(sizeInMb))
36+
sizeInKb >= 1 -> context.getString(R.string.size_kb, roundUpToHundreds(sizeInKb))
37+
else -> context.getString(R.string.size_bytes, roundUpToHundreds(sizeInBytes))
38+
}
39+
} ?: context.getString(R.string.unknown_size)
40+
}
41+
42+
private fun roundUpToHundreds(intValue: Int): Int {
43+
return ((intValue + 9) / 10) * 10
4344
}
4445
}
-5.48 KB
Loading

app/src/main/res/layout/selection_interaction_item.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@
3535
android:layout_marginEnd="20dp"
3636
android:layout_marginBottom="@dimen/divider_margin_bottom"
3737
android:divider="@android:color/transparent"
38+
app:allOptionsItemInputType="@{viewModel.getSelectionItemInputType()}"
3839
app:data="@{viewModel.choiceItems}"
3940
app:explorationId="@{viewModel.explorationId}"
40-
app:itemInputType="@{viewModel.getSelectionItemInputType()}"
4141
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
4242
</LinearLayout>
4343
</layout>

app/src/main/res/layout/topic_review_summary_view.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
android:layout_width="0dp"
3030
android:layout_height="104dp"
3131
android:importantForAccessibility="no"
32-
android:scaleType="fitXY"
32+
android:scaleType="centerInside"
3333
android:src="@{skill.skillThumbnail.thumbnailGraphic}"
3434
app:layout_constraintEnd_toEndOf="parent"
3535
app:layout_constraintStart_toStartOf="parent"

app/src/main/res/values/strings.xml

+5-5
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@
6464
<string name="play_pause_audio">Play/Pause Audio</string>
6565
<string name="help">Help</string>
6666
<string name="preferences">Preferences</string>
67-
<string name="size_bytes">Bytes</string>
68-
<string name="size_kb">KB</string>
69-
<string name="size_mb">MB</string>
70-
<string name="size_gb">GB</string>
71-
<string name="size_tb">TB</string>
67+
<string name="unknown_size">Unknown size</string>
68+
<string name="size_bytes">%d Bytes</string>
69+
<string name="size_kb">%d KB</string>
70+
<string name="size_mb">%d MB</string>
71+
<string name="size_gb">%d GB</string>
7272
<plurals name="chapter_count">
7373
<item quantity="one">
7474
1 Chapter

domain/src/main/assets/fractions_exploration1.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2739,7 +2739,7 @@
27392739
"classifier_model_id": null,
27402740
"content": {
27412741
"content_id": "content",
2742-
"html": "<p>“Hi, Mr Crumb,” said Matthew. “I'd like to buy half of that chocolate cake, please.”</p><p>“Yes, fine,” said Crumb. He pulled out a knife and cut off a small corner of the cake for Matthew, like this:</p><oppia-noninteractive-image alt-with-value=\"&amp;quot;Square cake with 2/9ths cut off.&amp;quot;\" caption-with-value=\"&amp;quot;&amp;quot;\" filepath-with-value=\"&amp;quot;img_20180109_231743_oom5t5uurn_height_192_width_192.png&amp;quot;\"></oppia-noninteractive-image><p>Is Crumb giving Matthew the correct amount of cake?<br></p>"
2742+
"html": "<p>Matthew was happy to go back to the bakery, because he wanted to get more cake for his friends. However, when he got there, he met a lazy-looking Assistant Baker behind the counter, named Crumb.</p><p>“Hi, Mr. Crumb,” said Matthew. “I'd like to buy half of that chocolate cake, please.”</p><p>“Yes, fine,” said Crumb. He pulled out a knife and cut off a small corner of the cake for Matthew, like this:</p><oppia-noninteractive-image alt-with-value=\"&amp;quot;Square cake with 2/9ths cut off.&amp;quot;\" caption-with-value=\"&amp;quot;&amp;quot;\" filepath-with-value=\"&amp;quot;img_20180109_231743_oom5t5uurn_height_192_width_192.png&amp;quot;\"></oppia-noninteractive-image><p>Is Crumb giving Matthew the correct amount of cake?<br></p>"
27432743
},
27442744
"written_translations": {
27452745
"translations_mapping": {

0 commit comments

Comments
 (0)