aboutsummaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
authorDocile-Alligator <25734209+Docile-Alligator@users.noreply.github.com>2023-09-18 03:14:31 +0000
committerDocile-Alligator <25734209+Docile-Alligator@users.noreply.github.com>2023-09-18 03:14:31 +0000
commitee4a0167a3b27755527023faba9a9bc00f5b91ee (patch)
treefe4bbd484f933e8036664ec8c3ac16dc21c9061b /app/src/main
parent28400822af6024906fccd8fb9893594d283bee1e (diff)
downloadinfinity-for-reddit-ee4a0167a3b27755527023faba9a9bc00f5b91ee.tar
infinity-for-reddit-ee4a0167a3b27755527023faba9a9bc00f5b91ee.tar.gz
infinity-for-reddit-ee4a0167a3b27755527023faba9a9bc00f5b91ee.tar.bz2
infinity-for-reddit-ee4a0167a3b27755527023faba9a9bc00f5b91ee.tar.lz
infinity-for-reddit-ee4a0167a3b27755527023faba9a9bc00f5b91ee.tar.xz
infinity-for-reddit-ee4a0167a3b27755527023faba9a9bc00f5b91ee.tar.zst
infinity-for-reddit-ee4a0167a3b27755527023faba9a9bc00f5b91ee.zip
Fix https://github.com/Docile-Alligator/Infinity-For-Reddit/issues/1508. Minor UI tweaks in SearchActivity.
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/FetchStreamableVideo.java19
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java15
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/SearchActivityRecyclerViewAdapter.java32
-rw-r--r--app/src/main/res/layout/activity_search.xml25
-rw-r--r--app/src/main/res/layout/item_recent_search_query.xml16
5 files changed, 60 insertions, 47 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/FetchStreamableVideo.java b/app/src/main/java/ml/docilealligator/infinityforreddit/FetchStreamableVideo.java
index ef5629d4..f0b03e1b 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/FetchStreamableVideo.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/FetchStreamableVideo.java
@@ -16,7 +16,6 @@ import ml.docilealligator.infinityforreddit.apis.StreamableAPI;
import ml.docilealligator.infinityforreddit.utils.JSONUtils;
import retrofit2.Call;
import retrofit2.Response;
-import retrofit2.Retrofit;
public class FetchStreamableVideo {
public interface FetchStreamableVideoListener {
@@ -34,7 +33,15 @@ public class FetchStreamableVideo {
String title = jsonObject.getString(JSONUtils.TITLE_KEY);
JSONObject filesObject = jsonObject.getJSONObject(JSONUtils.FILES_KEY);
StreamableVideo.Media mp4 = parseMedia(filesObject.getJSONObject(JSONUtils.MP4_KEY));
- StreamableVideo.Media mp4Mobile = parseMedia(filesObject.getJSONObject(JSONUtils.MP4_MOBILE_KEY));
+ StreamableVideo.Media mp4MobileTemp = null;
+ if (filesObject.has(JSONUtils.MP4_MOBILE_KEY)) {
+ mp4MobileTemp = parseMedia(filesObject.getJSONObject(JSONUtils.MP4_MOBILE_KEY));
+ }
+ if (mp4 == null && mp4MobileTemp == null) {
+ handler.post(fetchStreamableVideoListener::failed);
+ return;
+ }
+ StreamableVideo.Media mp4Mobile = mp4MobileTemp;
handler.post(() -> fetchStreamableVideoListener.success(new StreamableVideo(title, mp4, mp4Mobile)));
} else {
handler.post(fetchStreamableVideoListener::failed);
@@ -56,11 +63,15 @@ public class FetchStreamableVideo {
String title = jsonObject.getString(JSONUtils.TITLE_KEY);
JSONObject filesObject = jsonObject.getJSONObject(JSONUtils.FILES_KEY);
StreamableVideo.Media mp4 = parseMedia(filesObject.getJSONObject(JSONUtils.MP4_KEY));
- StreamableVideo.Media mp4Mobile = parseMedia(filesObject.getJSONObject(JSONUtils.MP4_MOBILE_KEY));
- if (mp4 == null && mp4Mobile == null) {
+ StreamableVideo.Media mp4MobileTemp = null;
+ if (filesObject.has(JSONUtils.MP4_MOBILE_KEY)) {
+ mp4MobileTemp = parseMedia(filesObject.getJSONObject(JSONUtils.MP4_MOBILE_KEY));
+ }
+ if (mp4 == null && mp4MobileTemp == null) {
handler.post(fetchStreamableVideoListener::failed);
return;
}
+ StreamableVideo.Media mp4Mobile = mp4MobileTemp;
handler.post(() -> fetchStreamableVideoListener.success(new StreamableVideo(title, mp4, mp4Mobile)));
} else {
handler.post(fetchStreamableVideoListener::failed);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java
index 8cdb0920..5e3426f8 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java
@@ -3,6 +3,7 @@ package ml.docilealligator.infinityforreddit.activities;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
+import android.content.res.ColorStateList;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
@@ -27,6 +28,7 @@ import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.appbar.AppBarLayout;
+import com.google.android.material.button.MaterialButton;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import org.greenrobot.eventbus.EventBus;
@@ -96,8 +98,8 @@ public class SearchActivity extends BaseActivity {
ImageView clearSearchTextImageView;
@BindView(R.id.link_handler_image_view_search_activity)
ImageView linkHandlerImageView;
- @BindView(R.id.delete_all_recent_searches_image_view_search_activity)
- ImageView deleteAllSearchesImageView;
+ @BindView(R.id.delete_all_recent_searches_button_search_activity)
+ MaterialButton deleteAllSearchesButton;
@BindView(R.id.subreddit_name_relative_layout_search_activity)
RelativeLayout subredditNameRelativeLayout;
@BindView(R.id.search_in_text_view_search_activity)
@@ -161,7 +163,7 @@ public class SearchActivity extends BaseActivity {
setSupportActionBar(toolbar);
clearSearchTextImageView.setVisibility(View.GONE);
- deleteAllSearchesImageView.setVisibility(View.GONE);
+ deleteAllSearchesButton.setVisibility(View.GONE);
searchOnlySubreddits = getIntent().getBooleanExtra(EXTRA_SEARCH_ONLY_SUBREDDITS, false);
searchOnlyUsers = getIntent().getBooleanExtra(EXTRA_SEARCH_ONLY_USERS, false);
@@ -275,7 +277,7 @@ public class SearchActivity extends BaseActivity {
}
});
- deleteAllSearchesImageView.setOnClickListener(view -> {
+ deleteAllSearchesButton.setOnClickListener(view -> {
new MaterialAlertDialogBuilder(this, R.style.MaterialAlertDialogTheme)
.setTitle(R.string.confirm)
.setMessage(R.string.confirm_delete_all_recent_searches)
@@ -343,10 +345,10 @@ public class SearchActivity extends BaseActivity {
mRecentSearchQueryViewModel.getAllRecentSearchQueries().observe(this, recentSearchQueries -> {
if (recentSearchQueries != null && !recentSearchQueries.isEmpty()) {
divider.setVisibility(View.VISIBLE);
- deleteAllSearchesImageView.setVisibility(View.VISIBLE);
+ deleteAllSearchesButton.setVisibility(View.VISIBLE);
} else {
divider.setVisibility(View.GONE);
- deleteAllSearchesImageView.setVisibility(View.GONE);
+ deleteAllSearchesButton.setVisibility(View.GONE);
}
adapter.setRecentSearchQueries(recentSearchQueries);
});
@@ -411,6 +413,7 @@ public class SearchActivity extends BaseActivity {
linkHandlerImageView.setColorFilter(mCustomThemeWrapper.getToolbarPrimaryTextAndIconColor(), android.graphics.PorterDuff.Mode.SRC_IN);
int colorAccent = mCustomThemeWrapper.getColorAccent();
searchInTextView.setTextColor(colorAccent);
+ deleteAllSearchesButton.setIconTint(ColorStateList.valueOf(mCustomThemeWrapper.getPrimaryIconColor()));
subredditNameTextView.setTextColor(mCustomThemeWrapper.getPrimaryTextColor());
divider.setBackgroundColor(mCustomThemeWrapper.getDividerColor());
if (typeface != null) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/SearchActivityRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/SearchActivityRecyclerViewAdapter.java
index 51a8fb63..776c00ef 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/SearchActivityRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/SearchActivityRecyclerViewAdapter.java
@@ -2,21 +2,17 @@ package ml.docilealligator.infinityforreddit.adapters;
import android.graphics.drawable.Drawable;
import android.view.LayoutInflater;
-import android.view.View;
import android.view.ViewGroup;
-import android.widget.ImageView;
-import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import java.util.List;
-import butterknife.BindView;
-import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
+import ml.docilealligator.infinityforreddit.databinding.ItemRecentSearchQueryBinding;
import ml.docilealligator.infinityforreddit.recentsearchquery.RecentSearchQuery;
import ml.docilealligator.infinityforreddit.utils.Utils;
@@ -45,14 +41,14 @@ public class SearchActivityRecyclerViewAdapter extends RecyclerView.Adapter<Recy
@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
- return new RecentSearchQueryViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_recent_search_query, parent, false));
+ return new RecentSearchQueryViewHolder(ItemRecentSearchQueryBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false));
}
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
if (holder instanceof RecentSearchQueryViewHolder) {
if (recentSearchQueries != null && !recentSearchQueries.isEmpty() && position < recentSearchQueries.size()) {
- ((RecentSearchQueryViewHolder) holder).recentSearchQueryTextView.setText(recentSearchQueries.get(position).getSearchQuery());
+ ((RecentSearchQueryViewHolder) holder).binding.recentSearchQueryTextViewItemRecentSearchQuery.setText(recentSearchQueries.get(position).getSearchQuery());
}
}
}
@@ -68,22 +64,18 @@ public class SearchActivityRecyclerViewAdapter extends RecyclerView.Adapter<Recy
}
class RecentSearchQueryViewHolder extends RecyclerView.ViewHolder {
- @BindView(R.id.recent_search_query_text_view_item_recent_search_query)
- TextView recentSearchQueryTextView;
- @BindView(R.id.delete_image_view_item_recent_search_query)
- ImageView deleteImageView;
+ ItemRecentSearchQueryBinding binding;
- public RecentSearchQueryViewHolder(@NonNull View itemView) {
- super(itemView);
+ public RecentSearchQueryViewHolder(@NonNull ItemRecentSearchQueryBinding binding) {
+ super(binding.getRoot());
+ this.binding = binding;
- ButterKnife.bind(this, itemView);
-
- recentSearchQueryTextView.setTextColor(primaryTextColor);
- recentSearchQueryTextView.setCompoundDrawablesWithIntrinsicBounds(historyIcon, null, null, null);
- deleteImageView.setImageDrawable(deleteIcon);
+ binding.recentSearchQueryTextViewItemRecentSearchQuery.setTextColor(primaryTextColor);
+ binding.recentSearchQueryTextViewItemRecentSearchQuery.setCompoundDrawablesWithIntrinsicBounds(historyIcon, null, null, null);
+ binding.deleteButtonItemRecentSearchQuery.setIcon(deleteIcon);
if (activity.typeface != null) {
- recentSearchQueryTextView.setTypeface(activity.typeface);
+ binding.recentSearchQueryTextViewItemRecentSearchQuery.setTypeface(activity.typeface);
}
itemView.setOnClickListener(view -> {
@@ -92,7 +84,7 @@ public class SearchActivityRecyclerViewAdapter extends RecyclerView.Adapter<Recy
}
});
- deleteImageView.setOnClickListener(view -> {
+ binding.deleteButtonItemRecentSearchQuery.setOnClickListener(view -> {
itemOnClickListener.onDelete(recentSearchQueries.get(getBindingAdapterPosition()));
});
}
diff --git a/app/src/main/res/layout/activity_search.xml b/app/src/main/res/layout/activity_search.xml
index 1a4580c6..4589d6ac 100644
--- a/app/src/main/res/layout/activity_search.xml
+++ b/app/src/main/res/layout/activity_search.xml
@@ -87,11 +87,15 @@
android:id="@+id/search_in_text_view_search_activity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_margin="16dp"
+ android:layout_marginStart="16dp"
+ android:layout_marginTop="16dp"
+ android:layout_marginEnd="16dp"
+ android:layout_marginBottom="16dp"
+ android:layout_centerVertical="true"
+ android:fontFamily="?attr/font_family"
android:text="@string/search_in"
android:textColor="?attr/colorAccent"
- android:textSize="?attr/font_default"
- android:fontFamily="?attr/font_family" />
+ android:textSize="?attr/font_default" />
<TextView
android:id="@+id/subreddit_name_text_view_search_activity"
@@ -105,16 +109,17 @@
android:textColor="?attr/primaryTextColor"
android:textSize="?attr/font_default"
android:fontFamily="?attr/font_family" />
- <ImageView
- android:id="@+id/delete_all_recent_searches_image_view_search_activity"
+
+ <com.google.android.material.button.MaterialButton
+ android:id="@+id/delete_all_recent_searches_button_search_activity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
- android:padding="16dp"
- android:clickable="true"
- android:focusable="true"
- android:src="@drawable/ic_delete_all_24"
- app:tint="@color/primaryTextColor" />
+ android:layout_centerVertical="true"
+ app:strokeWidth="0dp"
+ app:icon="@drawable/ic_delete_all_24"
+ app:iconSize="24dp"
+ style="?attr/materialIconButtonOutlinedStyle" />
</RelativeLayout>
diff --git a/app/src/main/res/layout/item_recent_search_query.xml b/app/src/main/res/layout/item_recent_search_query.xml
index 8fdc502c..e23e7378 100644
--- a/app/src/main/res/layout/item_recent_search_query.xml
+++ b/app/src/main/res/layout/item_recent_search_query.xml
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
android:clickable="true"
android:focusable="true"
android:background="?attr/selectableItemBackground">
@@ -13,19 +13,21 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_gravity="center_vertical"
+ android:gravity="center_vertical"
android:fontFamily="?attr/font_family"
android:textSize="?attr/font_default"
android:padding="16dp"
android:drawablePadding="16dp" />
- <ImageView
- android:id="@+id/delete_image_view_item_recent_search_query"
+ <com.google.android.material.button.MaterialButton
+ android:id="@+id/delete_button_item_recent_search_query"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:padding="16dp"
- android:clickable="true"
- android:focusable="true"
- android:background="?attr/selectableItemBackground" />
+ app:strokeWidth="0dp"
+ app:iconSize="24dp"
+ app:iconTint="@null"
+ style="?attr/materialIconButtonOutlinedStyle" />
</LinearLayout> \ No newline at end of file