Skip to content

Commit

Permalink
Merge pull request #20387 from brave/add_custom_filter_button_selecto…
Browse files Browse the repository at this point in the history
…r_android

[Android] add custom filter button selector
  • Loading branch information
tapanmodh authored Oct 11, 2023
2 parents d1267fc + 4853839 commit 42dae6f
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 2 deletions.
2 changes: 2 additions & 0 deletions android/brave_java_resources.gni
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,8 @@ brave_java_resources = [
"java/res/drawable-xxxhdpi/uphold_white.png",
"java/res/drawable-xxxhdpi/yandex.png",
"java/res/drawable/ad_free_card_bg.xml",
"java/res/drawable/add_custom_filter_button_background_disabled.xml",
"java/res/drawable/add_custom_filter_button_background_selector.xml",
"java/res/drawable/add_widget_button.xml",
"java/res/drawable/ads_custom_notification_border.xml",
"java/res/drawable/ads_custom_notification_border_dark.xml",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Patterns;
import android.view.LayoutInflater;
import android.view.Menu;
Expand Down Expand Up @@ -48,10 +50,22 @@ public void onActivityCreated(Bundle savedInstanceState) {

private void setData() {
initFilterListAndroidHandler();
Button addBtn = getView().findViewById(R.id.btn_add);
TextInputEditText urlEditText = getView().findViewById(R.id.enter_url_edittext);
urlEditText.requestFocus();
urlEditText.addTextChangedListener(new TextWatcher() {
@Override
public void afterTextChanged(Editable s) {}

@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}

@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
addBtn.setEnabled(s.toString().trim().length() > 0 ? true : false);
}
});

Button addBtn = getView().findViewById(R.id.btn_add);
addBtn.setOnClickListener(view -> {
if (urlEditText.getText().toString().length() > 0) {
String url = urlEditText.getText().toString().trim();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2023 The Brave Authors. All rights reserved.
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this file,
You can obtain one at https://mozilla.org/MPL/2.0/.
-->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/add_custom_filter_button_disabled_color" />
<corners android:radius="48dp" />
</shape>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2023 The Brave Authors. All rights reserved.
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this file,
You can obtain one at https://mozilla.org/MPL/2.0/.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="true" android:drawable="@drawable/blue_48_rounded_bg"/>
<item android:drawable="@drawable/add_custom_filter_button_background_disabled"/>
</selector>
3 changes: 2 additions & 1 deletion android/java/res/layout/fragment_add_custom_filter_lists.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@
android:layout_marginBottom="16dp"
android:layout_marginHorizontal="16dp"
app:layout_constraintBottom_toBottomOf="parent"
android:background="@drawable/blue_48_rounded_bg"
android:background="@drawable/add_custom_filter_button_background_selector"
app:backgroundTint="@null"
android:enabled="false"
android:text="@string/brave_wallet_add_network_add"
android:textAllCaps="false"
android:textColor="@android:color/white"
Expand Down
1 change: 1 addition & 0 deletions android/java/res/values/brave_colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@
<color name="add_custom_filter_summary_color">#666D89</color>
<color name="add_custom_filter_error_text_color">#FF4B6A</color>
<color name="add_custom_filter_tint_color">#666D89</color>
<color name="add_custom_filter_button_disabled_color">#A8ADBF</color>

<color name="brave_stats_ads_color">#FF7654</color>
<color name="brave_stats_data_saved_color">#737ADE</color>
Expand Down

0 comments on commit 42dae6f

Please sign in to comment.