Skip to content

Commit

Permalink
Customized SearchView theme.
Browse files Browse the repository at this point in the history
  • Loading branch information
surinder-tsys committed Feb 14, 2024
1 parent f59caa7 commit 5734c79
Show file tree
Hide file tree
Showing 15 changed files with 205 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import androidx.lifecycle.ViewModelProvider
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.nextcloud.client.di.ViewModelFactory
import com.nmc.android.utils.SearchViewThemeUtils.themeSearchView
import com.owncloud.android.R
import com.owncloud.android.databinding.LogsActivityBinding
import com.owncloud.android.ui.activity.ToolbarActivity
Expand Down Expand Up @@ -93,7 +94,8 @@ class LogsActivity : ToolbarActivity() {

(menu.findItem(R.id.action_search).actionView as SearchView).apply {
setOnQueryTextListener(searchBoxListener)
viewThemeUtils.androidx.themeToolbarSearchView(this)
//NMC customization
themeSearchView(this@LogsActivity, this)
}
return super.onCreateOptionsMenu(menu)
}
Expand Down
22 changes: 22 additions & 0 deletions app/src/main/java/com/nmc/android/utils/SearchViewThemeUtils.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.nmc.android.utils

import android.content.Context
import android.widget.ImageView
import androidx.appcompat.widget.SearchView
import com.owncloud.android.R

object SearchViewThemeUtils {
fun themeSearchView(context: Context, searchView: SearchView) {
val fontColor = context.resources.getColor(R.color.fontAppbar, null)
val editText: SearchView.SearchAutoComplete = searchView.findViewById(R.id.search_src_text)
editText.textSize = 16F
editText.setTextColor(fontColor)
editText.highlightColor = context.resources.getColor(R.color.et_highlight_color, null)
editText.setHintTextColor(context.resources.getColor(R.color.fontSecondaryAppbar, null))
val closeButton: ImageView = searchView.findViewById(R.id.search_close_btn)
closeButton.setColorFilter(fontColor)
val searchButton: ImageView = searchView.findViewById(R.id.search_button)
searchButton.setImageResource(R.drawable.ic_search)
searchButton.setColorFilter(fontColor)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
import com.nextcloud.utils.extensions.BundleExtensionsKt;
import com.nextcloud.utils.extensions.IntentExtensionsKt;
import com.nextcloud.utils.view.FastScrollUtils;
import com.nmc.android.utils.SearchViewThemeUtils;
import com.owncloud.android.MainApp;
import com.owncloud.android.R;
import com.owncloud.android.databinding.FilesBinding;
Expand Down Expand Up @@ -751,7 +752,8 @@ public boolean onCreateOptionsMenu(Menu menu) {
searchView.setIconified(false);
});

viewThemeUtils.androidx.themeToolbarSearchView(searchView);
//NMC customization
SearchViewThemeUtils.INSTANCE.themeSearchView(this, searchView);

// populate list of menu items to show/hide when drawer is opened/closed
mDrawerMenuItemstoShowHideList = new ArrayList<>(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
import com.nextcloud.client.preferences.AppPreferences;
import com.nextcloud.utils.extensions.BundleExtensionsKt;
import com.nextcloud.utils.extensions.IntentExtensionsKt;
import com.nmc.android.utils.SearchViewThemeUtils;
import com.owncloud.android.MainApp;
import com.owncloud.android.R;
import com.owncloud.android.databinding.ReceiveExternalFilesBinding;
Expand Down Expand Up @@ -1043,7 +1044,8 @@ public boolean onQueryTextChange(String newText) {
}
});

viewThemeUtils.androidx.themeToolbarSearchView(searchView);
//NMC customization
SearchViewThemeUtils.INSTANCE.themeSearchView(this, searchView);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import android.widget.TextView;

import com.nextcloud.client.account.User;
import com.nmc.android.utils.SearchViewThemeUtils;
import com.nextcloud.client.di.Injectable;
import com.nextcloud.client.jobs.upload.FileUploadWorker;
import com.nextcloud.client.preferences.AppPreferences;
Expand Down Expand Up @@ -293,8 +294,10 @@ public boolean onCreateOptionsMenu(Menu menu) {

final MenuItem item = menu.findItem(R.id.action_search);
mSearchView = (SearchView) MenuItemCompat.getActionView(item);
viewThemeUtils.androidx.themeToolbarSearchView(mSearchView);
viewThemeUtils.platform.tintTextDrawable(this, menu.findItem(R.id.action_choose_storage_path).getIcon());
//NMC customization
SearchViewThemeUtils.INSTANCE.themeSearchView(this, mSearchView);
viewThemeUtils.platform.colorDrawable(menu.findItem(R.id.action_choose_storage_path).getIcon(),
getResources().getColor(R.color.fontAppbar, null));

mSearchView.setOnSearchClickListener(v -> mToolbarSpinner.setVisibility(View.GONE));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,5 @@ class UnifiedSearchHeaderViewHolder(

fun bind(section: UnifiedSearchSection) {
binding.title.text = section.name
viewThemeUtils.platform.colorPrimaryTextViewElement(binding.title)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ class UnifiedSearchItemViewHolder(
MimeTypeUtil.getFileTypeIcon(mimetype, entry.title, context, viewThemeUtils)
}
}
return viewThemeUtils.platform.tintPrimaryDrawable(context, drawable)!!
//NMC Customization
return drawable!!
}

private inner class RoundIfNeededListener(private val entry: SearchResultEntry) :
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import com.google.android.material.button.MaterialButton;
import com.nextcloud.client.account.UserAccountManager;
import com.nextcloud.client.di.Injectable;
import com.nmc.android.utils.SearchViewThemeUtils;
import com.nextcloud.client.preferences.AppPreferences;
import com.nextcloud.client.preferences.AppPreferencesImpl;
import com.owncloud.android.MainApp;
Expand Down Expand Up @@ -178,7 +179,8 @@ public boolean isGridEnabled() {
public void onCreateOptionsMenu(Menu menu, @NonNull MenuInflater inflater) {
final MenuItem item = menu.findItem(R.id.action_search);
searchView = (SearchView) MenuItemCompat.getActionView(item);
viewThemeUtils.androidx.themeToolbarSearchView(searchView);
//NMC customization
SearchViewThemeUtils.INSTANCE.themeSearchView(requireActivity(), searchView);
closeButton = searchView.findViewById(androidx.appcompat.R.id.search_close_btn);
searchView.setOnQueryTextListener(this);
searchView.setOnCloseListener(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import com.nextcloud.client.core.AsyncRunner
import com.nextcloud.client.di.Injectable
import com.nextcloud.client.di.ViewModelFactory
import com.nextcloud.client.network.ClientFactory
import com.nmc.android.utils.SearchViewThemeUtils.themeSearchView
import com.owncloud.android.R
import com.owncloud.android.databinding.ListFragmentBinding
import com.owncloud.android.datamodel.FileDataStorageManager
Expand Down Expand Up @@ -158,7 +159,8 @@ class UnifiedSearchFragment :
// Required to align with TextView width.
// Because this fragment is opened with TextView onClick on the previous screen
maxWidth = Integer.MAX_VALUE
viewThemeUtils.androidx.themeToolbarSearchView(this)
// NMC Customization
themeSearchView(requireActivity(), this)
setQuery(vm.query.value, false)
setOnQueryTextListener(this@UnifiedSearchFragment)
isIconified = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import com.nextcloud.client.account.UserAccountManager;
import com.nextcloud.ui.fileactions.FileActionsBottomSheet;
import com.nextcloud.utils.extensions.BundleExtensionsKt;
import com.nmc.android.utils.SearchViewThemeUtils;
import com.owncloud.android.R;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.lib.common.utils.Log_OC;
Expand Down Expand Up @@ -268,7 +269,8 @@ public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflat
menuItem.setVisible(true);
searchView = (SearchView) MenuItemCompat.getActionView(menuItem);
searchView.setMaxWidth(Integer.MAX_VALUE);
viewThemeUtils.androidx.themeToolbarSearchView(searchView);
//NMC customization
SearchViewThemeUtils.INSTANCE.themeSearchView(requireActivity(), searchView);

if (searchOpen) {
searchView.setIconified(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import android.view.ViewGroup;

import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.nmc.android.utils.SearchViewThemeUtils;
import com.nextcloud.android.lib.richWorkspace.RichWorkspaceDirectEditingRemoteOperation;
import com.nextcloud.client.account.UserAccountManager;
import com.owncloud.android.R;
Expand Down Expand Up @@ -119,7 +120,8 @@ public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflat
searchView = (SearchView) MenuItemCompat.getActionView(menuItem);
searchView.setOnQueryTextListener(this);
searchView.setMaxWidth(Integer.MAX_VALUE);
viewThemeUtils.androidx.themeToolbarSearchView(searchView);
//NMC customization
SearchViewThemeUtils.INSTANCE.themeSearchView(requireActivity(), searchView);

if (searchOpen) {
searchView.setIconified(false);
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/unified_search_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
android:visibility="gone"
android:background="@color/transparent"
app:srcCompat="@drawable/ic_dots_vertical"
app:tint="@color/standard_grey"
app:tint="@color/list_icon_color"
android:layout_gravity="center"
android:layout_width="50dp"
android:layout_height="50dp"
Expand Down
64 changes: 64 additions & 0 deletions app/src/main/res/values-night/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,68 @@
<!-- App bar -->
<color name="appbar">#1E1E1E</color>
<color name="fontAppbar">@android:color/white</color>

<!-- NMC Colors -->
<color name="icon_color">#FFFFFF</color>
<color name="sort_text_color">@color/grey_30</color>
<color name="list_icon_color">@color/grey_30</color>
<color name="warning_icon_color">#CCCCCC</color>
<color name="divider_color">@color/grey_70</color>
<color name="spinner_bg_color">@color/grey_80</color>
<color name="refresh_layout_bg_color">#2D2D2D</color>
<color name="primary_button_disabled_color">@color/grey_70</color>
<color name="toolbar_divider_color">@color/grey_70</color>

<!-- Snackbar Colors -->
<color name="snackbar_bg_color">@color/grey_80</color>
<color name="snackbar_txt_color">@color/grey_0</color>

<!-- Alert Dialog Colors -->
<color name="alert_bg_color">@color/grey_80</color>
<color name="alert_txt_color">@color/grey_0</color>

<!-- NavigationView colors -->
<color name="nav_selected_bg_color">@color/grey_60</color>
<color name="nav_txt_unselected_color">@color/grey_0</color>
<color name="nav_txt_selected_color">@color/grey_0</color>
<color name="nav_icon_unselected_color">@color/grey_30</color>
<color name="nav_icon_selected_color">#FFFFFF</color>
<color name="nav_divider_color">@color/grey_30</color>
<color name="nav_bg_color">@color/grey_80</color>
<color name="drawer_quota_txt_color">#FFFFFF</color>

<!-- Bottom Sheet Colors -->
<color name="bottom_sheet_bg_color">@color/grey_80</color>
<color name="bottom_sheet_icon_color">@color/grey_30</color>
<color name="bottom_sheet_txt_color">@color/grey_0</color>

<!-- Popup Menu Colors -->
<color name="popup_menu_bg">@color/grey_80</color>
<color name="popup_menu_txt_color">@color/grey_0</color>
<color name="overflow_bg_color">@color/grey_80</color>

<!-- Switch Compat Colors -->
<color name="switch_thumb_disabled">@color/grey_70</color>
<color name="switch_track_disabled">@color/grey_60</color>

<!-- Checkbox Colors -->
<color name="checkbox_checked_disabled">@color/grey_70</color>
<color name="checkbox_unchecked_disabled">@color/grey_70</color>

<!-- Share Colors -->
<color name="share_title_txt_color">#FFFFFF</color>
<color name="share_subtitle_txt_color">@color/grey_30</color>
<color name="share_info_txt_color">@color/grey_0</color>
<color name="share_search_border_color">@color/grey_0</color>
<color name="share_btn_txt_color">@color/grey_0</color>
<color name="share_list_item_txt_color">@color/grey_0</color>
<color name="share_disabled_txt_color">@color/grey_60</color>
<color name="share_txt_color">@color/grey_0</color>
<color name="share_et_divider">#FFFFFF</color>

<!-- Scan Colors -->
<color name="scan_doc_bg_color">#121212</color>
<color name="scan_text_color">@color/grey_0</color>
<color name="scan_edit_bottom_color">@color/grey_80</color>
<color name="scan_count_bg_color">@color/grey_80</color>
</resources>
89 changes: 89 additions & 0 deletions app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,93 @@
<color name="appbar">@android:color/white</color>
<color name="fontAppbar">#666666</color>
<color name="fontSecondaryAppbar">#A5A5A5</color>

<!-- NMC Colors -->
<color name="icon_color">#191919</color>
<color name="sort_text_color">@color/primary</color>
<color name="list_icon_color">#191919</color>
<color name="warning_icon_color">#191919</color>
<color name="divider_color">@color/grey_30</color>
<color name="spinner_bg_color">@android:color/white</color>
<color name="refresh_layout_bg_color">#FFFFFF</color>
<color name="primary_button_disabled_color">@color/grey_0</color>
<color name="toolbar_divider_color">#CCCCCC</color>
<color name="et_highlight_color">#77c4ff</color>
<color name="white_trans_70">#B3FFFFFF</color>
<color name="progress_bar_background">@color/grey_10</color>

<!-- Grey Colors -->
<color name="dark_grey">#101010</color>
<color name="grey_0">#F2F2F2</color>
<color name="grey_10">#E5E5E5</color>
<color name="grey_30">#B2B2B2</color>
<color name="grey_60">#666666</color>
<color name="grey_70">#4C4C4C</color>
<color name="grey_80">#333333</color>

<!-- Snackbar Colors -->
<color name="snackbar_bg_color">@color/design_snackbar_background_color</color>
<color name="snackbar_txt_color">@color/white</color>

<!-- Alert Dialog Colors -->
<color name="alert_bg_color">#FFFFFF</color>
<color name="alert_txt_color">#191919</color>

<!-- NavigationView colors -->
<color name="nav_selected_bg_color">@color/grey_0</color>
<color name="nav_txt_unselected_color">#191919</color>
<color name="nav_txt_selected_color">@color/primary</color>
<color name="nav_icon_unselected_color">#191919</color>
<color name="nav_icon_selected_color">@color/primary</color>
<color name="nav_divider_color">@color/grey_30</color>
<color name="nav_bg_color">@color/white</color>
<color name="drawer_quota_txt_color">#191919</color>

<!-- Bottom Sheet Colors -->
<color name="bottom_sheet_bg_color">#FFFFFF</color>
<color name="bottom_sheet_icon_color">#191919</color>
<color name="bottom_sheet_txt_color">#191919</color>

<!-- Popup Menu Colors -->
<color name="popup_menu_bg">#FFFFFF</color>
<color name="popup_menu_txt_color">#191919</color>
<color name="overflow_bg_color">#FFFFFF</color>

<!-- Switch Compat Colors -->
<color name="switch_thumb_checked_enabled">@color/primary</color>
<color name="switch_track_checked_enabled">#F399C7</color>
<color name="switch_thumb_unchecked_enabled">#FFFFFF</color>
<color name="switch_track_unchecked_enabled">@color/grey_30</color>
<color name="switch_thumb_disabled">@color/grey_10</color>
<color name="switch_track_disabled">@color/grey_0</color>

<!-- Checkbox Colors -->
<color name="checkbox_checked_enabled">@color/primary</color>
<color name="checkbox_unchecked_enabled">@color/grey_30</color>
<color name="checkbox_checked_disabled">@color/grey_30</color>
<color name="checkbox_unchecked_disabled">#CCCCCC</color>

<!-- Share Colors -->
<color name="share_title_txt_color">#191919</color>
<color name="share_subtitle_txt_color">@color/grey_30</color>
<color name="share_info_txt_color">#191919</color>
<color name="share_search_border_color">#191919</color>
<color name="share_btn_txt_color">#191919</color>
<color name="share_list_item_txt_color">#191919</color>
<color name="share_disabled_txt_color">@color/grey_30</color>
<color name="share_txt_color">#191919</color>
<color name="share_et_divider">#000000</color>
<color name="share_warning_txt_color">#191919</color>
<color name="sharing_warning_bg_color">#F6E5EB</color>
<color name="sharing_warning_border_color">#C16F81</color>
<color name="share_color">#0D39DF</color>
<color name="shared_with_me_color">#0099ff</color>

<!-- Scan Colors -->
<color name="scan_doc_bg_color">@color/grey_0</color>
<color name="scan_text_color">#191919</color>
<color name="scan_edit_bottom_color">@color/grey_0</color>
<color name="scan_count_bg_color">@color/grey_30</color>
<color name="neptune">#77b6bb</color>
<color name="neptune_50">#5077b6bb</color>
</resources>
2 changes: 1 addition & 1 deletion app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@
<!-- Close button icon -->
<item name="closeIcon">@drawable/ic_close</item>
<!-- Search button icon -->
<item name="searchIcon">@drawable/ic_search_grey</item>
<item name="searchIcon">@drawable/ic_search</item>
<!-- Layout for query suggestion rows // unused for now, staying with the standard layout -->
<!--<item name="suggestionRowLayout">...</item>-->
</style>
Expand Down

0 comments on commit 5734c79

Please sign in to comment.