diff options
| author | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2020-06-17 17:15:28 +0000 |
|---|---|---|
| committer | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2020-07-01 19:53:27 +0000 |
| commit | ef428267cf8dba9dab3d33f00f83053545e8608c (patch) | |
| tree | 102486962efe3221d61e98ab74c6060366c1cbda /android | |
| parent | 9b8368a948dfc9dd460d6e0c3a7f49870eb7e3ee (diff) | |
| download | mullvadvpn-ef428267cf8dba9dab3d33f00f83053545e8608c.tar.xz mullvadvpn-ef428267cf8dba9dab3d33f00f83053545e8608c.zip | |
Add scroll animation for Select Location screen
Diffstat (limited to 'android')
3 files changed, 56 insertions, 23 deletions
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/SelectLocationFragment.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/SelectLocationFragment.kt index db5b1ad769..ca0e007025 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/SelectLocationFragment.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/SelectLocationFragment.kt @@ -22,6 +22,7 @@ import net.mullvad.mullvadvpn.util.AdapterWithHeader class SelectLocationFragment : ServiceDependentFragment(OnNoService.GoToLaunchScreen) { private lateinit var relayListAdapter: RelayListAdapter + private lateinit var titleController: CollapsibleTitleController override fun onAttach(context: Context) { super.onAttach(context) @@ -49,9 +50,16 @@ class SelectLocationFragment : ServiceDependentFragment(OnNoService.GoToLaunchSc view.findViewById<ImageButton>(R.id.close).setOnClickListener { close() } + titleController = CollapsibleTitleController(view, R.id.relay_list) + view.findViewById<RecyclerView>(R.id.relay_list).apply { layoutManager = LinearLayoutManager(parentActivity) - adapter = AdapterWithHeader(relayListAdapter, R.layout.select_location_header) + + adapter = AdapterWithHeader(relayListAdapter, R.layout.select_location_header).apply { + onHeaderAvailable = { headerView -> + titleController.expandedTitleView = headerView.findViewById(R.id.expanded_title) + } + } addItemDecoration(RelayItemDividerDecoration(parentActivity)) } @@ -71,10 +79,13 @@ class SelectLocationFragment : ServiceDependentFragment(OnNoService.GoToLaunchSc relayListListener.onRelayListChange = null } - fun close() { - activity?.onBackPressed() + override fun onDestroyView() { + super.onDestroyView() + titleController.onDestroy() } + fun close() { + activity?.onBackPressed() } private fun updateLocationConstraint(relayItem: RelayItem?) { diff --git a/android/src/main/res/layout/select_location.xml b/android/src/main/res/layout/select_location.xml index c3cad97b72..cf3e905876 100644 --- a/android/src/main/res/layout/select_location.xml +++ b/android/src/main/res/layout/select_location.xml @@ -1,19 +1,40 @@ -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:background="@color/darkBlue" - android:orientation="vertical" - android:gravity="left" - android:elevation="1dp"> - <ImageButton android:id="@+id/close" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_weight="0" - android:padding="12dp" - android:background="?android:attr/selectableItemBackground" - android:src="@drawable/icon_close" /> - <android.support.v7.widget.RecyclerView android:id="@+id/relay_list" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:scrollbars="vertical" /> -</LinearLayout> +<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:background="@color/darkBlue" + android:gravity="left" + android:elevation="1dp"> + <TextView android:id="@+id/title" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:textColor="@color/white" + android:textSize="16sp" + android:textStyle="bold" + android:text="@string/select_location" /> + <LinearLayout android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical"> + <FrameLayout android:layout_width="match_parent" + android:layout_height="wrap_content"> + <ImageButton android:id="@+id/close" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:padding="12dp" + android:background="?android:attr/selectableItemBackground" + android:src="@drawable/icon_close" /> + <TextView android:id="@+id/collapsed_title" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginHorizontal="4dp" + android:layout_gravity="center" + android:textColor="@color/white" + android:textSize="16sp" + android:textStyle="bold" + android:text="@string/select_location" /> + </FrameLayout> + <net.mullvad.mullvadvpn.ui.widget.CustomRecyclerView android:id="@+id/relay_list" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:scrollbars="vertical" /> + </LinearLayout> +</FrameLayout> diff --git a/android/src/main/res/layout/select_location_header.xml b/android/src/main/res/layout/select_location_header.xml index f7bdd1aa2d..8182db4be0 100644 --- a/android/src/main/res/layout/select_location_header.xml +++ b/android/src/main/res/layout/select_location_header.xml @@ -3,7 +3,8 @@ android:layout_height="wrap_content" android:orientation="vertical" android:gravity="left"> - <TextView android:layout_width="wrap_content" + <TextView android:id="@+id/expanded_title" + android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="0" android:layout_marginVertical="4dp" |
