From 4647d86693065a5a52558cc8f8e340cb48f5353d Mon Sep 17 00:00:00 2001 From: cyberta Date: Fri, 2 Dec 2022 16:02:26 +0100 Subject: add another setText() method in LocationButton that allows to pass a string resource id instead of a string --- .../main/java/se/leap/bitmaskclient/base/fragments/EipFragment.java | 4 ++-- .../main/java/se/leap/bitmaskclient/base/views/LocationButton.java | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/se/leap/bitmaskclient/base/fragments/EipFragment.java b/app/src/main/java/se/leap/bitmaskclient/base/fragments/EipFragment.java index 4df568b9..d63d9c72 100644 --- a/app/src/main/java/se/leap/bitmaskclient/base/fragments/EipFragment.java +++ b/app/src/main/java/se/leap/bitmaskclient/base/fragments/EipFragment.java @@ -542,7 +542,7 @@ public class EipFragment extends Fragment implements Observer { } else if (eipStatus.isBlocking()) { setMainButtonEnabled(true); mainButton.updateState(true, false, true); - locationButton.setText(getString(R.string.no_location)); + locationButton.setText(R.string.no_location); locationButton.setLocationLoad(UNKNOWN); locationButton.showBridgeIndicator(false); locationButton.showRecommendedIndicator(false); @@ -552,7 +552,7 @@ public class EipFragment extends Fragment implements Observer { animateState(R.drawable.state_disconnected); setActivityBarColor(R.color.bg_disconnected_top, R.color.bg_disconnected_top_light_transparent); } else { - locationButton.setText(getContext().getString(R.string.vpn_button_turn_on)); + locationButton.setText(R.string.vpn_button_turn_on); setMainButtonEnabled(true); mainButton.updateState(false, false, false); locationButton.setLocationLoad(UNKNOWN); diff --git a/app/src/main/java/se/leap/bitmaskclient/base/views/LocationButton.java b/app/src/main/java/se/leap/bitmaskclient/base/views/LocationButton.java index 7ad044bd..ae77d60e 100644 --- a/app/src/main/java/se/leap/bitmaskclient/base/views/LocationButton.java +++ b/app/src/main/java/se/leap/bitmaskclient/base/views/LocationButton.java @@ -8,6 +8,7 @@ import android.widget.RelativeLayout; import androidx.annotation.ColorRes; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.annotation.StringRes; import androidx.appcompat.widget.AppCompatImageView; import androidx.appcompat.widget.AppCompatTextView; import androidx.core.content.ContextCompat; @@ -52,6 +53,10 @@ public class LocationButton extends RelativeLayout { textView.setText(text); } + public void setText(@StringRes int resId) { + textView.setText(resId); + } + public void showBridgeIndicator(boolean show) { bridgeView.setVisibility(show ? VISIBLE : GONE); } -- cgit v1.2.3