mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-28 11:58:23 +01:00
Add a link handler in SearchActivity.
This commit is contained in:
parent
73c662159f
commit
d88e182082
@ -4,6 +4,7 @@ import android.app.Activity;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
@ -14,6 +15,7 @@ import android.view.View;
|
|||||||
import android.view.inputmethod.EditorInfo;
|
import android.view.inputmethod.EditorInfo;
|
||||||
import android.view.inputmethod.InputMethodManager;
|
import android.view.inputmethod.InputMethodManager;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
|
import android.widget.ImageView;
|
||||||
import android.widget.RelativeLayout;
|
import android.widget.RelativeLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
@ -90,6 +92,8 @@ public class SearchActivity extends BaseActivity {
|
|||||||
Toolbar toolbar;
|
Toolbar toolbar;
|
||||||
@BindView(R.id.search_edit_text_search_activity)
|
@BindView(R.id.search_edit_text_search_activity)
|
||||||
EditText searchEditText;
|
EditText searchEditText;
|
||||||
|
@BindView(R.id.link_handler_image_view_search_activity)
|
||||||
|
ImageView linkHandlerImageView;
|
||||||
@BindView(R.id.subreddit_name_relative_layout_search_activity)
|
@BindView(R.id.subreddit_name_relative_layout_search_activity)
|
||||||
RelativeLayout subredditNameRelativeLayout;
|
RelativeLayout subredditNameRelativeLayout;
|
||||||
@BindView(R.id.search_in_text_view_search_activity)
|
@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),
|
subredditAutocompleteCall = mOauthRetrofit.create(RedditAPI.class).subredditAutocomplete(APIUtils.getOAuthHeader(mAccessToken),
|
||||||
s.toString(), nsfw);
|
s.toString(), nsfw);
|
||||||
subredditAutocompleteCall.enqueue(new Callback<String>() {
|
subredditAutocompleteCall.enqueue(new Callback<>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||||
if (response.isSuccessful()) {
|
if (response.isSuccessful()) {
|
||||||
@ -246,6 +250,15 @@ public class SearchActivity extends BaseActivity {
|
|||||||
return false;
|
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) {
|
if (savedInstanceState != null) {
|
||||||
subredditName = savedInstanceState.getString(SUBREDDIT_NAME_STATE);
|
subredditName = savedInstanceState.getString(SUBREDDIT_NAME_STATE);
|
||||||
subredditIsUser = savedInstanceState.getBoolean(SUBREDDIT_IS_USER_STATE);
|
subredditIsUser = savedInstanceState.getBoolean(SUBREDDIT_IS_USER_STATE);
|
||||||
@ -365,6 +378,7 @@ public class SearchActivity extends BaseActivity {
|
|||||||
int toolbarPrimaryTextAndIconColorColor = mCustomThemeWrapper.getToolbarPrimaryTextAndIconColor();
|
int toolbarPrimaryTextAndIconColorColor = mCustomThemeWrapper.getToolbarPrimaryTextAndIconColor();
|
||||||
searchEditText.setTextColor(toolbarPrimaryTextAndIconColorColor);
|
searchEditText.setTextColor(toolbarPrimaryTextAndIconColorColor);
|
||||||
searchEditText.setHintTextColor(mCustomThemeWrapper.getToolbarPrimaryTextAndIconColor());
|
searchEditText.setHintTextColor(mCustomThemeWrapper.getToolbarPrimaryTextAndIconColor());
|
||||||
|
linkHandlerImageView.setColorFilter(mCustomThemeWrapper.getToolbarPrimaryTextAndIconColor(), android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
int colorAccent = mCustomThemeWrapper.getColorAccent();
|
int colorAccent = mCustomThemeWrapper.getColorAccent();
|
||||||
searchInTextView.setTextColor(colorAccent);
|
searchInTextView.setTextColor(colorAccent);
|
||||||
subredditNameTextView.setTextColor(mCustomThemeWrapper.getPrimaryTextColor());
|
subredditNameTextView.setTextColor(mCustomThemeWrapper.getPrimaryTextColor());
|
||||||
|
@ -288,7 +288,7 @@ public interface RedditAPI {
|
|||||||
Call<String> optInQuarantinedSubreddit(@HeaderMap Map<String, String> headers, @FieldMap Map<String, String> params);
|
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")
|
@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);
|
@Query("include_over_18") boolean nsfw);
|
||||||
|
|
||||||
@POST("/api/submit_gallery_post.json?resubmit=true&raw_json=1")
|
@POST("/api/submit_gallery_post.json?resubmit=true&raw_json=1")
|
||||||
|
@ -21,18 +21,35 @@
|
|||||||
app:popupTheme="@style/AppTheme.PopupOverlay"
|
app:popupTheme="@style/AppTheme.PopupOverlay"
|
||||||
app:navigationIcon="?attr/homeAsUpIndicator">
|
app:navigationIcon="?attr/homeAsUpIndicator">
|
||||||
|
|
||||||
<EditText
|
<LinearLayout
|
||||||
android:id="@+id/search_edit_text_search_activity"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="wrap_content"
|
||||||
android:background="#00000000"
|
android:layout_marginEnd="16dp">
|
||||||
android:gravity="top"
|
|
||||||
android:hint="@string/search"
|
<EditText
|
||||||
android:maxLines="1"
|
android:id="@+id/search_edit_text_search_activity"
|
||||||
android:textSize="?attr/font_20"
|
android:layout_width="0dp"
|
||||||
android:fontFamily="?attr/font_family"
|
android:layout_height="match_parent"
|
||||||
android:inputType="textNoSuggestions"
|
android:layout_weight="1"
|
||||||
android:imeOptions="actionSearch" />
|
android:background="#00000000"
|
||||||
|
android:hint="@string/search"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:textSize="?attr/font_20"
|
||||||
|
android:fontFamily="?attr/font_family"
|
||||||
|
android:inputType="textNoSuggestions"
|
||||||
|
android:imeOptions="actionSearch" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/link_handler_image_view_search_activity"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:padding="8dp"
|
||||||
|
android:src="@drawable/ic_open_link_24dp"
|
||||||
|
android:clickable="true"
|
||||||
|
android:focusable="true"
|
||||||
|
android:background="?attr/actionBarItemBackground" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
</androidx.appcompat.widget.Toolbar>
|
</androidx.appcompat.widget.Toolbar>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user