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.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());
|
||||
|
@ -21,12 +21,17 @@
|
||||
app:popupTheme="@style/AppTheme.PopupOverlay"
|
||||
app:navigationIcon="?attr/homeAsUpIndicator">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="16dp">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/search_edit_text_search_activity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:background="#00000000"
|
||||
android:gravity="top"
|
||||
android:hint="@string/search"
|
||||
android:maxLines="1"
|
||||
android:textSize="?attr/font_20"
|
||||
@ -34,6 +39,18 @@
|
||||
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>
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
Loading…
Reference in New Issue
Block a user