Skip to content

Commit f9a8d03

Browse files
authored
Apply the new design for Two-page (#14)
* Add new page fragments * Add fragments for layout * Clean up fragments * Update the text format * Rename image asset * Fix code style * Clean up the string * Clean up the fragments * Update the page pattern * Update the string * Update the test case * Update the import to satisfy the pipepline
1 parent 5def64c commit f9a8d03

File tree

16 files changed

+432
-96
lines changed

16 files changed

+432
-96
lines changed

ExtendCanvas/src/main/java/com/microsoft/device/display/samples/extendcanvas/MainActivity.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
package com.microsoft.device.display.samples.extendcanvas
77

88
import android.os.Bundle
9-
import android.view.View
109
import android.webkit.WebView
1110
import androidx.appcompat.app.AppCompatActivity
1211
import com.microsoft.device.display.samples.extend.R

TwoPage/src/androidTest/java/com/microsoft/device/display/samples/twopage/TwoPageModeOrientationTest.kt

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ class TwoPageModeOrientationTest {
3939
@Test
4040
fun displayLayouts_whenInSingleScreenPortrait() {
4141
onView(withId(R.id.single_pager_container)).check(matches(isDisplayed()))
42-
onView(allOf(withId(R.id.text_view), withText("Page 1")))
42+
onView(allOf(withId(R.id.app_name_text), withText("Two Page")))
4343
.check(matches(isDisplayed()))
4444

4545
changePagePortrait()
4646

47-
onView(allOf(withId(R.id.text_view), withText("Page 2")))
47+
onView(allOf(withId(R.id.page2_page_number), withText("PAGE 2 of 4")))
4848
.check(matches(isDisplayed()))
4949
}
5050

@@ -53,23 +53,23 @@ class TwoPageModeOrientationTest {
5353
spanApplication()
5454

5555
onView(withId(R.id.single_pager_container)).check(matches(isDisplayed()))
56-
onView(allOf(withId(R.id.text_view), withText("Page 1")))
56+
onView(allOf(withId(R.id.app_name_text), withText("Two Page")))
5757
.check(matches(isDisplayed()))
58-
onView(allOf(withId(R.id.text_view), withText("Page 2")))
58+
onView(allOf(withId(R.id.page2_page_number), withText("PAGE 2 of 4")))
5959
.check(matches(isDisplayed()))
6060

6161
changePagePortrait()
6262

63-
onView(allOf(withId(R.id.text_view), withText("Page 2")))
63+
onView(allOf(withId(R.id.page2_page_number), withText("PAGE 2 of 4")))
6464
.check(matches(isDisplayed()))
65-
onView(allOf(withId(R.id.text_view), withText("Page 3")))
65+
onView(allOf(withId(R.id.page3_page_number), withText("PAGE 3 of 4")))
6666
.check(matches(isDisplayed()))
6767

6868
changeTwoPagesPortrait()
6969

70-
onView(allOf(withId(R.id.text_view), withText("Page 4")))
70+
onView(allOf(withId(R.id.page3_page_number), withText("PAGE 3 of 4")))
7171
.check(matches(isDisplayed()))
72-
onView(allOf(withId(R.id.text_view), withText("Page 5")))
72+
onView(allOf(withId(R.id.page4_page_number), withText("PAGE 4 of 4")))
7373
.check(matches(isDisplayed()))
7474
}
7575

@@ -78,12 +78,12 @@ class TwoPageModeOrientationTest {
7878
rotateDevice()
7979

8080
onView(withId(R.id.single_pager_container)).check(matches(isDisplayed()))
81-
onView(allOf(withId(R.id.text_view), withText("Page 1")))
81+
onView(allOf(withId(R.id.app_name_text), withText("Two Page")))
8282
.check(matches(isDisplayed()))
8383

8484
changePageLandscape()
8585

86-
onView(allOf(withId(R.id.text_view), withText("Page 2")))
86+
onView(allOf(withId(R.id.page2_page_number), withText("PAGE 2 of 4")))
8787
.check(matches(isDisplayed()))
8888
}
8989

@@ -93,12 +93,12 @@ class TwoPageModeOrientationTest {
9393
spanLandscapeApplication()
9494

9595
onView(withId(R.id.dual_pager_container)).check(matches(isDisplayed()))
96-
onView(allOf(withId(R.id.text_view), withText("Page 1")))
96+
onView(allOf(withId(R.id.app_name_text), withText("Two Page")))
9797
.check(matches(isDisplayed()))
9898

9999
changePageVertical()
100100

101-
onView(allOf(withId(R.id.text_view), withText("Page 2")))
101+
onView(allOf(withId(R.id.page2_page_number), withText("PAGE 2 of 4")))
102102
.check(matches(isDisplayed()))
103103
}
104104

TwoPage/src/main/java/com/microsoft/device/display/samples/twopage/MainActivity.kt

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,17 @@ package com.microsoft.device.display.samples.twopage
88
import android.annotation.SuppressLint
99
import android.content.res.Configuration
1010
import android.os.Bundle
11+
import android.util.SparseArray
1112
import android.view.Surface
1213
import android.view.View
1314
import androidx.appcompat.app.AppCompatActivity
15+
import androidx.fragment.app.Fragment
1416
import androidx.viewpager.widget.ViewPager
1517
import androidx.viewpager.widget.ViewPager.OnPageChangeListener
18+
import com.microsoft.device.display.samples.twopage.fragments.FirstPageFragment
19+
import com.microsoft.device.display.samples.twopage.fragments.FourthPageFragment
20+
import com.microsoft.device.display.samples.twopage.fragments.SecondPageFragment
21+
import com.microsoft.device.display.samples.twopage.fragments.ThirdPageFragment
1622
import com.microsoft.device.dualscreen.layout.ScreenHelper
1723

1824
class MainActivity : AppCompatActivity(), OnPageChangeListener {
@@ -25,12 +31,24 @@ class MainActivity : AppCompatActivity(), OnPageChangeListener {
2531
@SuppressLint("InflateParams")
2632
override fun onCreate(savedInstanceState: Bundle?) {
2733
super.onCreate(savedInstanceState)
28-
pagerAdapter = PagerAdapter(supportFragmentManager, TestFragment.fragments)
34+
35+
supportActionBar?.hide()
36+
37+
setupPager()
2938
single = layoutInflater.inflate(R.layout.activity_main, null)
3039
dual = layoutInflater.inflate(R.layout.double_landscape_layout, null)
3140
setupLayout()
3241
}
3342

43+
private fun setupPager() {
44+
val fragments = SparseArray<Fragment>()
45+
fragments.put(0, FirstPageFragment())
46+
fragments.put(1, SecondPageFragment())
47+
fragments.put(2, ThirdPageFragment())
48+
fragments.put(3, FourthPageFragment())
49+
pagerAdapter = PagerAdapter(supportFragmentManager, fragments)
50+
}
51+
3452
private fun setupLayout() {
3553
if (ScreenHelper.isDualMode(this)) {
3654
useDualMode()

TwoPage/src/main/java/com/microsoft/device/display/samples/twopage/PagerAdapter.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import androidx.fragment.app.FragmentPagerAdapter
1212

1313
internal class PagerAdapter(
1414
fm: FragmentManager?,
15-
private val fragments: SparseArray<TestFragment>
15+
private val fragments: SparseArray<Fragment>
1616
) : FragmentPagerAdapter(fm!!, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) {
1717
private var showTwoPages = false
1818
override fun getItem(position: Int): Fragment {

TwoPage/src/main/java/com/microsoft/device/display/samples/twopage/TestFragment.kt

Lines changed: 0 additions & 49 deletions
This file was deleted.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.microsoft.device.display.samples.twopage.fragments
2+
3+
import android.os.Bundle
4+
import android.view.LayoutInflater
5+
import android.view.View
6+
import android.view.ViewGroup
7+
import androidx.fragment.app.Fragment
8+
import com.microsoft.device.display.samples.twopage.R
9+
10+
class FirstPageFragment : Fragment() {
11+
override fun onCreateView(
12+
inflater: LayoutInflater,
13+
container: ViewGroup?,
14+
savedInstanceState: Bundle?
15+
): View? {
16+
// Inflate the layout for this fragment
17+
return inflater.inflate(R.layout.fragment_first_page, container, false)
18+
}
19+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.microsoft.device.display.samples.twopage.fragments
2+
3+
import android.os.Bundle
4+
import android.view.LayoutInflater
5+
import android.view.View
6+
import android.view.ViewGroup
7+
import androidx.fragment.app.Fragment
8+
import com.microsoft.device.display.samples.twopage.R
9+
10+
class FourthPageFragment : Fragment() {
11+
override fun onCreateView(
12+
inflater: LayoutInflater,
13+
container: ViewGroup?,
14+
savedInstanceState: Bundle?
15+
): View? {
16+
// Inflate the layout for this fragment
17+
return inflater.inflate(R.layout.fragment_fourth_page, container, false)
18+
}
19+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.microsoft.device.display.samples.twopage.fragments
2+
3+
import android.os.Bundle
4+
import android.view.LayoutInflater
5+
import android.view.View
6+
import android.view.ViewGroup
7+
import androidx.fragment.app.Fragment
8+
import com.microsoft.device.display.samples.twopage.R
9+
10+
class SecondPageFragment : Fragment() {
11+
12+
override fun onCreateView(
13+
inflater: LayoutInflater,
14+
container: ViewGroup?,
15+
savedInstanceState: Bundle?
16+
): View? {
17+
// Inflate the layout for this fragment
18+
return inflater.inflate(R.layout.fragment_second_page, container, false)
19+
}
20+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.microsoft.device.display.samples.twopage.fragments
2+
3+
import android.os.Bundle
4+
import android.view.LayoutInflater
5+
import android.view.View
6+
import android.view.ViewGroup
7+
import androidx.fragment.app.Fragment
8+
import com.microsoft.device.display.samples.twopage.R
9+
10+
class ThirdPageFragment : Fragment() {
11+
override fun onCreateView(
12+
inflater: LayoutInflater,
13+
container: ViewGroup?,
14+
savedInstanceState: Bundle?
15+
): View? {
16+
// Inflate the layout for this fragment
17+
return inflater.inflate(R.layout.fragment_third_page, container, false)
18+
}
19+
}
352 KB
Loading

0 commit comments

Comments
 (0)