Implement a search panel in ViewPostDetailActivity.

This commit is contained in:
Alex Ning 2021-07-09 08:54:59 +08:00
parent 1352a8268e
commit 5fc3212f98
3 changed files with 94 additions and 1 deletions

View File

@ -11,6 +11,7 @@ import android.view.MenuItem;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.Toast;
import androidx.annotation.NonNull;
@ -27,8 +28,11 @@ import com.evernote.android.state.State;
import com.github.piasy.biv.BigImageViewer;
import com.github.piasy.biv.loader.glide.GlideImageLoader;
import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.card.MaterialCardView;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.snackbar.Snackbar;
import com.google.android.material.textfield.TextInputEditText;
import com.google.android.material.textfield.TextInputLayout;
import com.livefront.bridge.Bridge;
import com.r0adkll.slidr.Slidr;
import com.r0adkll.slidr.model.SlidrInterface;
@ -89,6 +93,18 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
ViewPager2 viewPager2;
@BindView(R.id.fab_view_post_detail_activity)
FloatingActionButton fab;
@BindView(R.id.search_panel_material_card_view_view_post_detail_activity)
MaterialCardView searchPanelMaterialCardView;
@BindView(R.id.search_text_input_layout_view_post_detail_activity)
TextInputLayout searchTextInputLayout;
@BindView(R.id.search_text_input_edit_text_view_post_detail_activity)
TextInputEditText searchTextInputEditText;
@BindView(R.id.previous_result_image_view_view_post_detail_activity)
ImageView previousResultImageView;
@BindView(R.id.next_result_image_view_view_post_detail_activity)
ImageView nextResultImageView;
@BindView(R.id.close_search_panel_image_view_view_post_detail_activity)
ImageView closeSearchPanelImageView;
@Inject
@Named("oauth")
Retrofit mOauthRetrofit;
@ -372,6 +388,14 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
}
}
public void toggleSearchPanelVisibility() {
if (searchPanelMaterialCardView.getVisibility() == View.GONE) {
searchPanelMaterialCardView.setVisibility(View.VISIBLE);
} else {
searchPanelMaterialCardView.setVisibility(View.GONE);
}
}
@Subscribe
public void onAccountSwitchEvent(SwitchAccountEvent event) {
if (!getClass().getName().equals(event.excludeActivityClassName)) {

View File

@ -780,7 +780,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
int itemId = item.getItemId();
if (itemId == R.id.action_search_view_post_detail_fragment) {
activity.toggleSearchPanelVisibility();
} else if (itemId == R.id.action_refresh_view_post_detail_fragment) {
refresh(true, true);
return true;

View File

@ -47,4 +47,73 @@
app:tint="@android:color/white"
app:srcCompat="@drawable/ic_keyboard_arrow_down_24dp" />
<com.google.android.material.card.MaterialCardView
android:id="@+id/search_panel_material_card_view_view_post_detail_activity"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:backgroundTint="#FFFFFF"
android:visibility="gone"
app:cardElevation="16dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/search_text_input_layout_view_post_detail_activity"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:paddingStart="16dp"
android:paddingEnd="16dp"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/search_text_input_edit_text_view_post_detail_activity"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="?attr/font_family"
android:textSize="?attr/font_default"
android:hint="@string/post_filter_name_hint" />
</com.google.android.material.textfield.TextInputLayout>
<ImageView
android:id="@+id/previous_result_image_view_view_post_detail_activity"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="center_vertical"
android:src="@drawable/ic_arrow_upward_black_24dp"
android:background="?actionBarItemBackground"
android:clickable="true"
android:focusable="true" />
<ImageView
android:id="@+id/next_result_image_view_view_post_detail_activity"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="center_vertical"
android:src="@drawable/ic_arrow_downward_black_24dp"
android:background="?actionBarItemBackground"
android:clickable="true"
android:focusable="true" />
<ImageView
android:id="@+id/close_search_panel_image_view_view_post_detail_activity"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="center_vertical"
android:src="@drawable/ic_close_black_24dp"
android:background="?actionBarItemBackground"
android:clickable="true"
android:focusable="true" />
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
</androidx.coordinatorlayout.widget.CoordinatorLayout>