-
Notifications
You must be signed in to change notification settings - Fork 501
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
* -Implemented low-fi UI for "CompletedStoryList" for landscape mode - tablet * -Implemented low-fi UI for "CompletedStoryList" for portrait mode - tablet * -added robolectric tests * -some nit changes Co-authored-by: Ben Henning <henning.benmax@gmail.com>
- Loading branch information
1 parent
a099bfb
commit ce6c082
Showing
13 changed files
with
261 additions
and
8 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
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
94 changes: 94 additions & 0 deletions
94
app/src/main/res/layout-sw600dp-port/completed_story_item.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,94 @@ | ||
<?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"> | ||
|
||
<data> | ||
|
||
<import type="android.view.View" /> | ||
|
||
<variable | ||
name="viewModel" | ||
type="org.oppia.app.completedstorylist.CompletedStoryItemViewModel" /> | ||
</data> | ||
|
||
<com.google.android.material.card.MaterialCardView | ||
android:id="@+id/topic_container" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginStart="8dp" | ||
android:layout_marginTop="12dp" | ||
android:layout_marginEnd="8dp" | ||
android:layout_marginBottom="12dp" | ||
app:cardCornerRadius="4dp"> | ||
|
||
<androidx.constraintlayout.widget.ConstraintLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:clickable="true" | ||
android:focusable="true"> | ||
|
||
<ImageView | ||
android:id="@+id/completed_story_lesson_thumbnail" | ||
android:layout_width="0dp" | ||
android:layout_height="0dp" | ||
android:background="@color/topicThumbnailBackground" | ||
android:importantForAccessibility="no" | ||
android:contentDescription="@{viewModel.completedStory.storyName}" | ||
android:scaleType="centerInside" | ||
android:src="@{viewModel.completedStory.lessonThumbnail.thumbnailGraphic}" | ||
app:layout_constraintDimensionRatio="4:3" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" /> | ||
|
||
<androidx.constraintlayout.widget.ConstraintLayout | ||
android:id="@+id/constraintLayout" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:background="@color/white" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@id/completed_story_lesson_thumbnail"> | ||
|
||
<TextView | ||
android:id="@+id/completed_story_name_text_view" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginStart="8dp" | ||
android:layout_marginTop="8dp" | ||
android:layout_marginEnd="8dp" | ||
android:ellipsize="end" | ||
android:fontFamily="sans-serif" | ||
android:gravity="top" | ||
android:maxLines="2" | ||
android:minLines="2" | ||
android:text="@{viewModel.completedStory.storyName}" | ||
android:textColor="@color/oppiaPrimaryText" | ||
android:textSize="14sp" | ||
android:textStyle="bold" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" /> | ||
|
||
<TextView | ||
android:id="@+id/completed_story_topic_name_text_view" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginStart="8dp" | ||
android:layout_marginTop="4dp" | ||
android:layout_marginEnd="8dp" | ||
android:fontFamily="sans-serif-light" | ||
android:paddingBottom="12dp" | ||
android:textAllCaps="true" | ||
android:ellipsize="end" | ||
android:text="@{viewModel.completedStory.topicName}" | ||
android:textColor="@color/oppiaStrokeBlack" | ||
android:textSize="14sp" | ||
android:maxLines="1" | ||
android:minLines="1" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@+id/completed_story_name_text_view" /> | ||
</androidx.constraintlayout.widget.ConstraintLayout> | ||
</androidx.constraintlayout.widget.ConstraintLayout> | ||
</com.google.android.material.card.MaterialCardView> | ||
</layout> |
69 changes: 69 additions & 0 deletions
69
app/src/main/res/layout-sw600dp-port/completed_story_list_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,69 @@ | ||
<?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"> | ||
|
||
<data> | ||
|
||
<variable | ||
name="viewModel" | ||
type="org.oppia.app.completedstorylist.CompletedStoryListViewModel" /> | ||
</data> | ||
|
||
<androidx.constraintlayout.widget.ConstraintLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:background="@color/white"> | ||
|
||
<com.google.android.material.appbar.AppBarLayout | ||
android:id="@+id/completed_story_list_app_bar_layout" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent"> | ||
|
||
<androidx.appcompat.widget.Toolbar | ||
android:id="@+id/completed_story_list_toolbar" | ||
android:layout_width="match_parent" | ||
android:layout_height="?attr/actionBarSize" | ||
android:background="?attr/colorPrimary" | ||
android:fontFamily="sans-serif" | ||
android:minHeight="?attr/actionBarSize" | ||
android:textSize="20sp" | ||
app:navigationContentDescription="@string/go_to_previous_page" | ||
app:navigationIcon="?attr/homeAsUpIndicator" | ||
app:title="@string/stories_completed" | ||
app:titleTextColor="@color/white" /> | ||
</com.google.android.material.appbar.AppBarLayout> | ||
|
||
<FrameLayout | ||
android:layout_width="0dp" | ||
android:layout_height="0dp" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@id/completed_story_list_app_bar_layout"> | ||
|
||
<androidx.recyclerview.widget.RecyclerView | ||
android:id="@+id/completed_story_list" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:clipToPadding="false" | ||
android:overScrollMode="never" | ||
android:paddingStart="20dp" | ||
android:paddingTop="20dp" | ||
android:paddingEnd="20dp" | ||
android:paddingBottom="144dp" | ||
android:scrollbars="none" | ||
android:tag="@string/completed_story_list_recyclerview_tag" | ||
app:data="@{viewModel.completedStoryListLiveData}" /> | ||
|
||
<View | ||
android:id="@+id/completed_story_list_shadow_view" | ||
android:layout_width="match_parent" | ||
android:layout_height="6dp" | ||
android:background="@drawable/toolbar_drop_shadow" /> | ||
</FrameLayout> | ||
</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
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
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
86 changes: 86 additions & 0 deletions
86
app/src/test/java/org/oppia/app/testing/CompletedStoryListSpanTest.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,86 @@ | ||
package org.oppia.app.testing | ||
|
||
import androidx.recyclerview.widget.GridLayoutManager | ||
import androidx.recyclerview.widget.RecyclerView | ||
import androidx.test.core.app.ActivityScenario.launch | ||
import androidx.test.core.app.ApplicationProvider | ||
import androidx.test.espresso.intent.Intents | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import com.google.common.truth.Truth.assertThat | ||
import com.google.firebase.FirebaseApp | ||
import kotlinx.coroutines.ExperimentalCoroutinesApi | ||
import org.junit.After | ||
import org.junit.Before | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import org.oppia.app.R | ||
import org.oppia.app.completedstorylist.CompletedStoryListActivity | ||
import org.oppia.app.completedstorylist.CompletedStoryListFragment.Companion.COMPLETED_STORY_LIST_FRAGMENT_TAG | ||
import org.robolectric.annotation.Config | ||
|
||
@RunWith(AndroidJUnit4::class) | ||
class CompletedStoryListSpanTest { | ||
|
||
@Before | ||
@ExperimentalCoroutinesApi | ||
fun setUp() { | ||
Intents.init() | ||
FirebaseApp.initializeApp(ApplicationProvider.getApplicationContext()) | ||
} | ||
|
||
@After | ||
fun tearDown() { | ||
Intents.release() | ||
} | ||
|
||
private fun getCompletedStoryListSpanCount(activity: CompletedStoryListActivity): Int { | ||
val completedStoryListFragment = | ||
activity.supportFragmentManager.findFragmentByTag(COMPLETED_STORY_LIST_FRAGMENT_TAG) | ||
val completedStoryListRecyclerVIew = | ||
completedStoryListFragment?.view?.findViewWithTag<RecyclerView>( | ||
activity.resources.getString( | ||
R.string.completed_story_list_recyclerview_tag | ||
) | ||
) | ||
return (completedStoryListRecyclerVIew?.layoutManager as GridLayoutManager).spanCount | ||
} | ||
|
||
@Test | ||
fun testCompletedStoryList_checkRecyclerViewSpanCount_spanIsCorrect() { | ||
launch(CompletedStoryListActivity::class.java).use { | ||
it.onActivity { activity -> | ||
assertThat(getCompletedStoryListSpanCount(activity)).isEqualTo(2) | ||
} | ||
} | ||
} | ||
|
||
@Test | ||
@Config(qualifiers = "land") | ||
fun testCompletedStoryList_checkRecyclerViewSpanCount_land_spanIsCorrect() { | ||
launch(CompletedStoryListActivity::class.java).use { | ||
it.onActivity { activity -> | ||
assertThat(getCompletedStoryListSpanCount(activity)).isEqualTo(3) | ||
} | ||
} | ||
} | ||
|
||
@Test | ||
@Config(qualifiers = "sw600dp-port") | ||
fun testCompletedStoryList_checkRecyclerViewSpanCount_tabletPort_spanIsCorrect() { | ||
launch(CompletedStoryListActivity::class.java).use { | ||
it.onActivity { activity -> | ||
assertThat(getCompletedStoryListSpanCount(activity)).isEqualTo(3) | ||
} | ||
} | ||
} | ||
|
||
@Test | ||
@Config(qualifiers = "sw600dp-land") | ||
fun testCompletedStoryList_checkRecyclerViewSpanCount_tabletLand_spanIsCorrect() { | ||
launch(CompletedStoryListActivity::class.java).use { | ||
it.onActivity { activity -> | ||
assertThat(getCompletedStoryListSpanCount(activity)).isEqualTo(4) | ||
} | ||
} | ||
} | ||
} |