mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-27 17:08:34 +03:00
material 3 theming for search bar, toolbar and fab
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
parent
0f997b433d
commit
a6ba545aef
3 changed files with 17 additions and 27 deletions
|
@ -359,7 +359,7 @@ public class ConversationsListController extends BaseController implements Flexi
|
|||
SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE);
|
||||
if (searchItem != null) {
|
||||
searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
|
||||
DisplayUtils.themeSearchView(searchView, context);
|
||||
viewThemeUtils.themeSearchView(searchView);
|
||||
searchView.setMaxWidth(Integer.MAX_VALUE);
|
||||
searchView.setInputType(InputType.TYPE_TEXT_VARIATION_FILTER);
|
||||
int imeOptions = EditorInfo.IME_ACTION_DONE | EditorInfo.IME_FLAG_NO_FULLSCREEN;
|
||||
|
@ -421,23 +421,15 @@ public class ConversationsListController extends BaseController implements Flexi
|
|||
|
||||
activity.binding.searchText.setOnClickListener(v -> {
|
||||
showSearchView(activity, searchView, searchItem);
|
||||
if (getResources() != null) {
|
||||
DisplayUtils.applyColorToStatusBar(
|
||||
activity,
|
||||
ResourcesCompat.getColor(getResources(), R.color.appbar, null)
|
||||
);
|
||||
}
|
||||
viewThemeUtils.themeStatusBar(activity, searchView);
|
||||
});
|
||||
}
|
||||
|
||||
searchView.setOnCloseListener(() -> {
|
||||
if (TextUtils.isEmpty(searchView.getQuery().toString())) {
|
||||
searchView.onActionViewCollapsed();
|
||||
if (activity != null && getResources() != null) {
|
||||
DisplayUtils.applyColorToStatusBar(
|
||||
activity,
|
||||
ResourcesCompat.getColor(getResources(), R.color.bg_default, null)
|
||||
);
|
||||
if (activity != null) {
|
||||
viewThemeUtils.resetStatusBar(activity, searchView);
|
||||
}
|
||||
} else {
|
||||
searchView.post(() -> searchView.setQuery(TAG, true));
|
||||
|
|
|
@ -49,6 +49,7 @@ import com.nextcloud.talk.controllers.ServerSelectionController;
|
|||
import com.nextcloud.talk.controllers.SwitchAccountController;
|
||||
import com.nextcloud.talk.controllers.WebViewLoginController;
|
||||
import com.nextcloud.talk.controllers.base.providers.ActionBarProvider;
|
||||
import com.nextcloud.talk.ui.theme.ViewThemeUtils;
|
||||
import com.nextcloud.talk.utils.DisplayUtils;
|
||||
import com.nextcloud.talk.utils.preferences.AppPreferences;
|
||||
|
||||
|
@ -70,9 +71,13 @@ public abstract class BaseController extends ButterKnifeController {
|
|||
private static final String TAG = "BaseController";
|
||||
@Inject
|
||||
AppPreferences appPreferences;
|
||||
|
||||
@Inject
|
||||
Context context;
|
||||
|
||||
@Inject
|
||||
ViewThemeUtils viewThemeUtils;
|
||||
|
||||
protected BaseController() {
|
||||
cleanTempCertPreference();
|
||||
}
|
||||
|
@ -109,12 +114,18 @@ public abstract class BaseController extends ButterKnifeController {
|
|||
@Override
|
||||
protected void onViewBound(@NonNull View view) {
|
||||
super.onViewBound(view);
|
||||
MainActivity activity = null;
|
||||
|
||||
if (getActivity() != null && getActivity() instanceof MainActivity) {
|
||||
activity = (MainActivity) getActivity();
|
||||
viewThemeUtils.themeCardView(activity.binding.searchToolbar);
|
||||
viewThemeUtils.themeToolbar(activity.binding.toolbar);
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && appPreferences.getIsKeyboardIncognito()) {
|
||||
disableKeyboardPersonalisedLearning((ViewGroup) view);
|
||||
|
||||
if (getActivity() != null && getActivity() instanceof MainActivity) {
|
||||
MainActivity activity = (MainActivity) getActivity();
|
||||
if (activity != null) {
|
||||
disableKeyboardPersonalisedLearning(activity.binding.appBar);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -517,19 +517,6 @@ public class DisplayUtils {
|
|||
window.setNavigationBarColor(color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Theme search view
|
||||
*
|
||||
* @param searchView searchView to be changed
|
||||
* @param context the app's context
|
||||
*/
|
||||
public static void themeSearchView(SearchView searchView, Context context) {
|
||||
// hacky as no default way is provided
|
||||
SearchView.SearchAutoComplete editText = searchView.findViewById(R.id.search_src_text);
|
||||
editText.setTextSize(16);
|
||||
editText.setHintTextColor(context.getResources().getColor(R.color.fontSecondaryAppbar));
|
||||
}
|
||||
|
||||
/**
|
||||
* beautifies a given URL by removing any http/https protocol prefix.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue