From 5fc3212f98a8ca8652fc7d370946d10b477a251c Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Fri, 9 Jul 2021 08:54:59 +0800 Subject: Implement a search panel in ViewPostDetailActivity. --- .../activities/ViewPostDetailActivity.java | 24 ++++++++ .../fragments/ViewPostDetailFragment.java | 2 +- .../main/res/layout/activity_view_post_detail.xml | 69 ++++++++++++++++++++++ 3 files changed, 94 insertions(+), 1 deletion(-) (limited to 'app') diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPostDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPostDetailActivity.java index 34fbc55a..f093c1f6 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPostDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPostDetailActivity.java @@ -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)) { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java index 589326ee..509ce597 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java @@ -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; diff --git a/app/src/main/res/layout/activity_view_post_detail.xml b/app/src/main/res/layout/activity_view_post_detail.xml index d16899f3..f44fd823 100644 --- a/app/src/main/res/layout/activity_view_post_detail.xml +++ b/app/src/main/res/layout/activity_view_post_detail.xml @@ -47,4 +47,73 @@ app:tint="@android:color/white" app:srcCompat="@drawable/ic_keyboard_arrow_down_24dp" /> + + + + + + + + + + + + + + + + + + + + \ No newline at end of file -- cgit v1.2.3