aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/ml/docilealligator
diff options
context:
space:
mode:
authorDocile-Alligator <chineseperson5@gmail.com>2022-06-03 05:03:32 +0000
committerDocile-Alligator <chineseperson5@gmail.com>2022-06-03 05:03:32 +0000
commitd88e18208274995dadfaf1a3ca03e77be946fb63 (patch)
tree39e09dd1e90d53383606f20bbb8440772d601abb /app/src/main/java/ml/docilealligator
parent73c662159fd06d99166bc80d7500c8f850d21813 (diff)
downloadinfinity-for-reddit-d88e18208274995dadfaf1a3ca03e77be946fb63.tar
infinity-for-reddit-d88e18208274995dadfaf1a3ca03e77be946fb63.tar.gz
infinity-for-reddit-d88e18208274995dadfaf1a3ca03e77be946fb63.tar.bz2
infinity-for-reddit-d88e18208274995dadfaf1a3ca03e77be946fb63.tar.lz
infinity-for-reddit-d88e18208274995dadfaf1a3ca03e77be946fb63.tar.xz
infinity-for-reddit-d88e18208274995dadfaf1a3ca03e77be946fb63.tar.zst
infinity-for-reddit-d88e18208274995dadfaf1a3ca03e77be946fb63.zip
Add a link handler in SearchActivity.
Diffstat (limited to 'app/src/main/java/ml/docilealligator')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java16
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/apis/RedditAPI.java2
2 files changed, 16 insertions, 2 deletions
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 996b8ef4..ae5d097d 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java
@@ -4,6 +4,7 @@ import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
+import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.text.Editable;
@@ -14,6 +15,7 @@ import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
+import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
@@ -90,6 +92,8 @@ public class SearchActivity extends BaseActivity {
Toolbar toolbar;
@BindView(R.id.search_edit_text_search_activity)
EditText searchEditText;
+ @BindView(R.id.link_handler_image_view_search_activity)
+ ImageView linkHandlerImageView;
@BindView(R.id.subreddit_name_relative_layout_search_activity)
RelativeLayout subredditNameRelativeLayout;
@BindView(R.id.search_in_text_view_search_activity)
@@ -208,7 +212,7 @@ public class SearchActivity extends BaseActivity {
subredditAutocompleteCall = mOauthRetrofit.create(RedditAPI.class).subredditAutocomplete(APIUtils.getOAuthHeader(mAccessToken),
s.toString(), nsfw);
- subredditAutocompleteCall.enqueue(new Callback<String>() {
+ subredditAutocompleteCall.enqueue(new Callback<>() {
@Override
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
if (response.isSuccessful()) {
@@ -246,6 +250,15 @@ public class SearchActivity extends BaseActivity {
return false;
});
+ linkHandlerImageView.setOnClickListener(view -> {
+ if (!searchEditText.getText().toString().equals("")) {
+ Intent intent = new Intent(this, LinkResolverActivity.class);
+ intent.setData(Uri.parse(searchEditText.getText().toString()));
+ startActivity(intent);
+ finish();
+ }
+ });
+
if (savedInstanceState != null) {
subredditName = savedInstanceState.getString(SUBREDDIT_NAME_STATE);
subredditIsUser = savedInstanceState.getBoolean(SUBREDDIT_IS_USER_STATE);
@@ -365,6 +378,7 @@ public class SearchActivity extends BaseActivity {
int toolbarPrimaryTextAndIconColorColor = mCustomThemeWrapper.getToolbarPrimaryTextAndIconColor();
searchEditText.setTextColor(toolbarPrimaryTextAndIconColorColor);
searchEditText.setHintTextColor(mCustomThemeWrapper.getToolbarPrimaryTextAndIconColor());
+ linkHandlerImageView.setColorFilter(mCustomThemeWrapper.getToolbarPrimaryTextAndIconColor(), android.graphics.PorterDuff.Mode.SRC_IN);
int colorAccent = mCustomThemeWrapper.getColorAccent();
searchInTextView.setTextColor(colorAccent);
subredditNameTextView.setTextColor(mCustomThemeWrapper.getPrimaryTextColor());
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/apis/RedditAPI.java b/app/src/main/java/ml/docilealligator/infinityforreddit/apis/RedditAPI.java
index f4120d14..826dc663 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/apis/RedditAPI.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/apis/RedditAPI.java
@@ -288,7 +288,7 @@ public interface RedditAPI {
Call<String> optInQuarantinedSubreddit(@HeaderMap Map<String, String> headers, @FieldMap Map<String, String> params);
@GET("/api/subreddit_autocomplete_v2?typeahead_active=true&include_profiles=false&raw_json=1")
- Call<String> subredditAutocomplete(@HeaderMap Map<String ,String> headers, @Query("query") String query,
+ Call<String> subredditAutocomplete(@HeaderMap Map<String, String> headers, @Query("query") String query,
@Query("include_over_18") boolean nsfw);
@POST("/api/submit_gallery_post.json?resubmit=true&raw_json=1")