mirror of
https://gitlab.com/oeffi/oeffi.git
synced 2025-07-07 18:38:48 +00:00
DirectionsActivity: Move form out of the away (and return quickly) if query history is scrolled.
This commit is contained in:
parent
f38f7ae931
commit
9ccc4b0ff6
3 changed files with 94 additions and 42 deletions
|
@ -13,6 +13,7 @@ dependencies {
|
|||
compile 'de.schildbach.wallet:integration-android:2.0'
|
||||
compile 'androidx.annotation:annotation:1.0.2'
|
||||
compile 'androidx.recyclerview:recyclerview:1.0.0'
|
||||
compile 'androidx.coordinatorlayout:coordinatorlayout:1.0.0'
|
||||
compile 'androidx.drawerlayout:drawerlayout:1.0.0'
|
||||
compile 'androidx.core:core:1.0.1'
|
||||
compile 'com.squareup.okhttp3:okhttp:3.12.1'
|
||||
|
|
|
@ -32,9 +32,18 @@
|
|||
android:text="@string/directions_connectivity_warning"
|
||||
android:visibility="gone" />
|
||||
|
||||
<ScrollView
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" >
|
||||
android:layout_height="0px"
|
||||
android:layout_weight="1" >
|
||||
|
||||
<ScrollView
|
||||
android:id="@+id/directions_quick_return"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="top"
|
||||
android:background="@android:color/white"
|
||||
android:elevation="3dp" >
|
||||
|
||||
<include layout="@layout/directions_form_include" />
|
||||
</ScrollView>
|
||||
|
@ -42,15 +51,13 @@
|
|||
<FrameLayout
|
||||
android:id="@+id/directions_list_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0px"
|
||||
android:layout_weight="1"
|
||||
android:foreground="@drawable/view_shadow_bottom"
|
||||
android:foregroundGravity="top|fill_horizontal" >
|
||||
android:layout_height="match_parent" >
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@android:id/list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
android:layout_height="match_parent"
|
||||
android:clipToPadding="false" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/directions_query_history_empty"
|
||||
|
@ -83,6 +90,7 @@
|
|||
android:text="@string/stations_list_network_settings" />
|
||||
</LinearLayout>
|
||||
</FrameLayout>
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<include layout="@layout/navigation_drawer" />
|
||||
|
|
|
@ -42,6 +42,7 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.common.primitives.Floats;
|
||||
|
||||
import de.schildbach.oeffi.Constants;
|
||||
import de.schildbach.oeffi.FromViaToAware;
|
||||
|
@ -135,8 +136,10 @@ import android.widget.PopupMenu;
|
|||
import android.widget.TextView;
|
||||
import android.widget.TimePicker;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import okhttp3.HttpUrl;
|
||||
|
@ -146,6 +149,7 @@ public class DirectionsActivity extends OeffiMainActivity implements ActivityCom
|
|||
private ConnectivityManager connectivityManager;
|
||||
private LocationManager locationManager;
|
||||
|
||||
private View quickReturnView;
|
||||
private ToggleImageButton buttonExpand;
|
||||
private LocationView viewFromLocation;
|
||||
private LocationView viewViaLocation;
|
||||
|
@ -159,6 +163,8 @@ public class DirectionsActivity extends OeffiMainActivity implements ActivityCom
|
|||
private Button viewGo;
|
||||
private RecyclerView viewQueryHistoryList;
|
||||
private QueryHistoryAdapter queryHistoryListAdapter;
|
||||
private View viewQueryHistoryEmpty;
|
||||
private View viewQueryMissingCapability;
|
||||
private TextView connectivityWarningView;
|
||||
private OeffiMapView mapView;
|
||||
|
||||
|
@ -437,6 +443,28 @@ public class DirectionsActivity extends OeffiMainActivity implements ActivityCom
|
|||
viewQueryHistoryList.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL_LIST));
|
||||
queryHistoryListAdapter = new QueryHistoryAdapter(this, network, this, this);
|
||||
viewQueryHistoryList.setAdapter(queryHistoryListAdapter);
|
||||
viewQueryHistoryEmpty = findViewById(R.id.directions_query_history_empty);
|
||||
|
||||
viewQueryMissingCapability = findViewById(R.id.directions_network_missing_capability);
|
||||
|
||||
quickReturnView = findViewById(R.id.directions_quick_return);
|
||||
final CoordinatorLayout.LayoutParams layoutParams = new CoordinatorLayout.LayoutParams(
|
||||
quickReturnView.getLayoutParams().width, quickReturnView.getLayoutParams().height);
|
||||
layoutParams.setBehavior(new QuickReturnBehavior());
|
||||
quickReturnView.setLayoutParams(layoutParams);
|
||||
quickReturnView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
|
||||
@Override
|
||||
public void onLayoutChange(final View v, final int left, final int top, final int right, final int bottom,
|
||||
final int oldLeft, final int oldTop, final int oldRight, final int oldBottom) {
|
||||
final int height = bottom - top;
|
||||
viewQueryHistoryList.setPadding(viewQueryHistoryList.getPaddingLeft(), height,
|
||||
viewQueryHistoryList.getPaddingRight(), viewQueryHistoryList.getPaddingBottom());
|
||||
viewQueryHistoryEmpty.setPadding(viewQueryHistoryEmpty.getPaddingLeft(), height,
|
||||
viewQueryHistoryEmpty.getPaddingRight(), viewQueryHistoryEmpty.getPaddingBottom());
|
||||
viewQueryMissingCapability.setPadding(viewQueryMissingCapability.getPaddingLeft(), height,
|
||||
viewQueryMissingCapability.getPaddingRight(), viewQueryMissingCapability.getPaddingBottom());
|
||||
}
|
||||
});
|
||||
|
||||
mapView = (OeffiMapView) findViewById(R.id.directions_map);
|
||||
if (ContextCompat.checkSelfPermission(DirectionsActivity.this,
|
||||
|
@ -573,10 +601,9 @@ public class DirectionsActivity extends OeffiMainActivity implements ActivityCom
|
|||
viewGo.setEnabled(hasDirectionsCap);
|
||||
|
||||
viewQueryHistoryList.setVisibility(hasDirectionsCap ? View.VISIBLE : View.GONE);
|
||||
findViewById(R.id.directions_network_missing_capability)
|
||||
.setVisibility(hasDirectionsCap ? View.GONE : View.VISIBLE);
|
||||
findViewById(R.id.directions_query_history_empty).setVisibility(
|
||||
viewQueryHistoryEmpty.setVisibility(
|
||||
hasDirectionsCap && queryHistoryListAdapter.getItemCount() == 0 ? View.VISIBLE : View.INVISIBLE);
|
||||
viewQueryMissingCapability.setVisibility(hasDirectionsCap ? View.GONE : View.VISIBLE);
|
||||
|
||||
// regular refresh
|
||||
tickReceiver = new BroadcastReceiver() {
|
||||
|
@ -907,6 +934,7 @@ public class DirectionsActivity extends OeffiMainActivity implements ActivityCom
|
|||
private void handleReuseQuery(final Location from, final Location to) {
|
||||
viewFromLocation.setLocation(from);
|
||||
viewToLocation.setLocation(to);
|
||||
quickReturnView.setTranslationY(0); // show
|
||||
}
|
||||
|
||||
private void handleShowSavedTrip(final byte[] serializedTrip) {
|
||||
|
@ -1388,4 +1416,19 @@ public class DirectionsActivity extends OeffiMainActivity implements ActivityCom
|
|||
private Accessibility prefsGetAccessibility() {
|
||||
return Accessibility.valueOf(prefs.getString(Constants.PREFS_KEY_ACCESSIBILITY, Accessibility.NEUTRAL.name()));
|
||||
}
|
||||
|
||||
private static final class QuickReturnBehavior extends CoordinatorLayout.Behavior<View> {
|
||||
@Override
|
||||
public boolean onStartNestedScroll(final CoordinatorLayout coordinatorLayout, final View child,
|
||||
final View directTargetChild, final View target, final int nestedScrollAxes, final int type) {
|
||||
return (nestedScrollAxes & ViewCompat.SCROLL_AXIS_VERTICAL) != 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNestedScroll(final CoordinatorLayout coordinatorLayout, final View child, final View target,
|
||||
final int dxConsumed, final int dyConsumed, final int dxUnconsumed, final int dyUnconsumed,
|
||||
final int type) {
|
||||
child.setTranslationY(Floats.constrainToRange(child.getTranslationY() - dyConsumed, -child.getHeight(), 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue