diff --git a/briar-android/artwork/transports_list_scene.xml b/briar-android/artwork/transports_list_scene.xml deleted file mode 100644 index bcb0d82ea..000000000 --- a/briar-android/artwork/transports_list_scene.xml +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/briar-android/src/main/java/org/briarproject/briar/android/navdrawer/NavDrawerActivity.java b/briar-android/src/main/java/org/briarproject/briar/android/navdrawer/NavDrawerActivity.java index 7fa637593..d1a5ea458 100644 --- a/briar-android/src/main/java/org/briarproject/briar/android/navdrawer/NavDrawerActivity.java +++ b/briar-android/src/main/java/org/briarproject/briar/android/navdrawer/NavDrawerActivity.java @@ -7,9 +7,7 @@ import android.os.Bundle; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; -import android.view.ViewTreeObserver.OnGlobalLayoutListener; import android.widget.ImageView; -import android.widget.ScrollView; import android.widget.TextView; import com.google.android.material.navigation.NavigationView; @@ -47,9 +45,7 @@ import androidx.fragment.app.FragmentTransaction; import androidx.lifecycle.ViewModelProvider; import androidx.lifecycle.ViewModelProviders; -import static android.view.View.FOCUS_DOWN; import static android.view.View.GONE; -import static android.view.View.INVISIBLE; import static android.view.View.VISIBLE; import static androidx.core.view.GravityCompat.START; import static androidx.drawerlayout.widget.DrawerLayout.LOCK_MODE_LOCKED_CLOSED; @@ -92,7 +88,6 @@ public class NavDrawerActivity extends BriarActivity implements LifecycleManager lifecycleManager; private DrawerLayout drawerLayout; - private ScrollView drawerScrollView; private NavigationView navigation; @Override @@ -114,26 +109,8 @@ public class NavDrawerActivity extends BriarActivity implements if (ask) showDozeDialog(getString(R.string.setup_doze_intro)); }); - drawerScrollView = findViewById(R.id.drawerScrollView); - View chevronView = drawerScrollView.findViewById(R.id.chevronView); - drawerScrollView.getViewTreeObserver().addOnGlobalLayoutListener( - new OnGlobalLayoutListener() { - @Override - public void onGlobalLayout() { - // hide/show chevron depending on whether we can scroll - if (drawerScrollView.canScrollVertically(1)) { - chevronView.setVisibility(VISIBLE); - } else { - chevronView.setVisibility(INVISIBLE); - } - drawerScrollView.getViewTreeObserver() - .removeOnGlobalLayoutListener(this); - } - }); + View drawerScrollView = findViewById(R.id.drawerScrollView); new PluginViewController(drawerScrollView, this, viewModel); - chevronView.setOnClickListener(v -> - drawerScrollView.fullScroll(FOCUS_DOWN) - ); Toolbar toolbar = findViewById(R.id.toolbar); drawerLayout = findViewById(R.id.drawer_layout); diff --git a/briar-android/src/main/java/org/briarproject/briar/android/navdrawer/PluginViewController.java b/briar-android/src/main/java/org/briarproject/briar/android/navdrawer/PluginViewController.java index 075125959..7206d98e3 100644 --- a/briar-android/src/main/java/org/briarproject/briar/android/navdrawer/PluginViewController.java +++ b/briar-android/src/main/java/org/briarproject/briar/android/navdrawer/PluginViewController.java @@ -2,6 +2,7 @@ package org.briarproject.briar.android.navdrawer; import android.view.View; import android.widget.ImageView; +import android.widget.ScrollView; import org.briarproject.bramble.api.plugin.BluetoothConstants; import org.briarproject.bramble.api.plugin.LanTcpConstants; @@ -13,6 +14,9 @@ import org.briarproject.briar.R; import androidx.appcompat.widget.SwitchCompat; import androidx.lifecycle.LifecycleOwner; +import static android.view.View.FOCUS_DOWN; +import static android.view.View.GONE; +import static android.view.View.VISIBLE; import static androidx.core.content.ContextCompat.getColor; import static org.briarproject.bramble.api.plugin.Plugin.State.ACTIVE; import static org.briarproject.bramble.api.plugin.Plugin.State.DISABLED; @@ -22,15 +26,38 @@ import static org.briarproject.briar.android.navdrawer.NavDrawerViewModel.TRANSP class PluginViewController { - private final ImageView torIcon, wifiIcon, btIcon; + private final ImageView torIconExpanded, torIconCollapsed; + private final ImageView wifiIconExpanded, wifiIconCollapsed; + private final ImageView btIconExpanded, btIconCollapsed; private final SwitchCompat torSwitch, wifiSwitch, btSwitch; PluginViewController(View v, LifecycleOwner owner, NavDrawerViewModel viewModel) { - torIcon = v.findViewById(R.id.torIcon); - wifiIcon = v.findViewById(R.id.wifiIcon); - btIcon = v.findViewById(R.id.btIcon); + ScrollView scrollView = v.findViewById(R.id.drawerScrollView); + View expandedLayout = v.findViewById(R.id.expandedLayout); + View collapsedLayout = v.findViewById(R.id.collapsedLayout); + + expandedLayout.addOnLayoutChangeListener((view, left, top, right, + bottom, oldLeft, oldTop, oldRight, oldBottom) -> + scrollView.fullScroll(FOCUS_DOWN)); + + v.findViewById(R.id.chevronViewCollapsed).setOnClickListener(view -> { + expandedLayout.setVisibility(VISIBLE); + collapsedLayout.setVisibility(GONE); + }); + + v.findViewById(R.id.chevronViewExpanded).setOnClickListener(view -> { + expandedLayout.setVisibility(GONE); + collapsedLayout.setVisibility(VISIBLE); + }); + + torIconExpanded = v.findViewById(R.id.torIconExpanded); + torIconCollapsed = v.findViewById(R.id.torIconCollapsed); + wifiIconExpanded = v.findViewById(R.id.wifiIconExpanded); + wifiIconCollapsed = v.findViewById(R.id.wifiIconCollapsed); + btIconExpanded = v.findViewById(R.id.btIconExpanded); + btIconCollapsed = v.findViewById(R.id.btIconCollapsed); torSwitch = v.findViewById(R.id.torSwitch); wifiSwitch = v.findViewById(R.id.wifiSwitch); @@ -52,7 +79,8 @@ class PluginViewController { } private void stateUpdate(TransportId id, State state) { - updateIcon(getIcon(id), state); + updateIcon(getExpandedIcon(id), state); + updateIcon(getCollapsedIcon(id), state); updateSwitch(getSwitch(id), state); } @@ -69,10 +97,17 @@ class PluginViewController { switchCompat.setEnabled(state != STARTING_STOPPING); } - private ImageView getIcon(TransportId id) { - if (id == TorConstants.ID) return torIcon; - if (id == BluetoothConstants.ID) return btIcon; - if (id == LanTcpConstants.ID) return wifiIcon; + private ImageView getExpandedIcon(TransportId id) { + if (id == TorConstants.ID) return torIconExpanded; + if (id == BluetoothConstants.ID) return btIconExpanded; + if (id == LanTcpConstants.ID) return wifiIconExpanded; + throw new AssertionError(); + } + + private ImageView getCollapsedIcon(TransportId id) { + if (id == TorConstants.ID) return torIconCollapsed; + if (id == BluetoothConstants.ID) return btIconCollapsed; + if (id == LanTcpConstants.ID) return wifiIconCollapsed; throw new AssertionError(); } diff --git a/briar-android/src/main/res/layout/navigation_menu.xml b/briar-android/src/main/res/layout/navigation_menu.xml index 482b362b5..394a3d7f2 100644 --- a/briar-android/src/main/res/layout/navigation_menu.xml +++ b/briar-android/src/main/res/layout/navigation_menu.xml @@ -10,7 +10,9 @@ + android:layout_height="wrap_content" + android:background="@color/window_background" + android:orientation="vertical"> - + diff --git a/briar-android/src/main/res/layout/transports_list.xml b/briar-android/src/main/res/layout/transports_list.xml index e2558853a..019e98615 100644 --- a/briar-android/src/main/res/layout/transports_list.xml +++ b/briar-android/src/main/res/layout/transports_list.xml @@ -2,162 +2,234 @@ - - - - - - - - - - - - - - - - - - - + android:visibility="gone"> - + + + + + + + + + + + + + + + + + + + + + + + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintVertical_bias="1.0"> + + + + + + + + + + + + +