refactor - bulk edit UI - make fab clickable on Pre-Lollipop devices without custom codes.

This commit is contained in:
orionlee 2019-04-04 15:30:00 -07:00
parent b3fbf0b4aa
commit 46f7805a96
2 changed files with 13 additions and 25 deletions

View File

@ -3,7 +3,6 @@ package de.danoeh.antennapod.dialog;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.res.TypedArray; import android.content.res.TypedArray;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.IdRes; import android.support.annotation.IdRes;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
@ -220,29 +219,12 @@ public class EpisodesApplyActionFragment extends Fragment {
return view; return view;
} }
@Override
public void onStart() {
super.onStart();
compatEnsureSpeedDialClickable();
}
@Override @Override
public void onStop() { public void onStop() {
restoreActionBarTitle(); // it might have been changed to "N selected". Restore original. restoreActionBarTitle(); // it might have been changed to "N selected". Restore original.
super.onStop(); super.onStop();
} }
private void compatEnsureSpeedDialClickable() {
// On pre-Lollipop devices (that does not support elevation),
// need to explicitly bring the fab to the front, otherwise it won't be clickable.
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
ViewGroup root = (ViewGroup)getView();
root.bringChildToFront(root.findViewById(R.id.fabSDScrollCtr));
root.requestLayout();
root.invalidate();
}
}
private void showSpeedDialIfAnyChecked() { private void showSpeedDialIfAnyChecked() {
mSpeedDialView.setVisibility(checkedIds.size() > 0 ? View.VISIBLE : View.GONE); mSpeedDialView.setVisibility(checkedIds.size() > 0 ? View.VISIBLE : View.GONE);
} }

View File

@ -4,11 +4,24 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginTop="0dp" />
<com.leinardi.android.speeddial.SpeedDialOverlayLayout <com.leinardi.android.speeddial.SpeedDialOverlayLayout
android:id="@+id/fabSDOverlay" android:id="@+id/fabSDOverlay"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" /> android:layout_height="match_parent" />
<!-- The FAB SpeedDial
1. MUST be placed at the bottom of the layout xml to ensure it is at the front,
clickable on Pre-Lollipop devices (that do not support elevation).
See: https://stackoverflow.com/a/2614402
2. ScrollView is needed to ensure the vertical list of speed dials are
accessible when screen height is small, eg., landscape mode on most phones.
-->
<ScrollView <ScrollView
android:id="@+id/fabSDScrollCtr" android:id="@+id/fabSDScrollCtr"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -37,11 +50,4 @@
/> />
</ScrollView> </ScrollView>
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginTop="0dp" />
</RelativeLayout> </RelativeLayout>