[tor-commits] [snowflake-mobile/master] Fixed switch state bug
cohosh at torproject.org
cohosh at torproject.org
Mon Aug 10 16:49:27 UTC 2020
commit 86a0425786f2fb512a1776eac5111f8b2dc63235
Author: Hashik Donthineni <HashikDonthineni at gmail.com>
Date: Thu Aug 6 20:30:36 2020 +0530
Fixed switch state bug
---
.../java/org/torproject/snowflake/fragments/MainFragment.java | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/app/src/main/java/org/torproject/snowflake/fragments/MainFragment.java b/app/src/main/java/org/torproject/snowflake/fragments/MainFragment.java
index cc041db..e2d7505 100644
--- a/app/src/main/java/org/torproject/snowflake/fragments/MainFragment.java
+++ b/app/src/main/java/org/torproject/snowflake/fragments/MainFragment.java
@@ -14,7 +14,6 @@ import android.widget.Switch;
import android.widget.TextView;
import androidx.annotation.NonNull;
-import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;
import org.torproject.snowflake.R;
@@ -56,11 +55,19 @@ public class MainFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
+ Log.d(TAG, "onCreateView: ");
View rootView = inflater.inflate(R.layout.fragment_main, container, false);
usersServedTV = rootView.findViewById(R.id.users_served);
Switch startButton = rootView.findViewById(R.id.snowflake_switch);
snowflakeLogo = rootView.findViewById(R.id.snowflake_logo);
+ //If the service is running, set the button to on
+ if (callback.isServiceRunning()) {
+ changeLogoColorStatus(true);
+ startButton.setChecked(true);
+ startButton.setText(getString(R.string.Snowflake_On));
+ }
+
startButton.setOnCheckedChangeListener((buttonView, isChecked) -> {
if (callback.isServiceRunning() && !isChecked) { //Toggling the service.
changeLogoColorStatus(false);
@@ -106,7 +113,7 @@ public class MainFragment extends Fragment {
ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), from, to);
colorAnimation.setDuration(300); // milliseconds
- colorAnimation.addUpdateListener(animator -> snowflakeLogo.setColorFilter((int) animator.getAnimatedValue(), PorterDuff.Mode.SRC_IN));
+ colorAnimation.addUpdateListener(animator -> snowflakeLogo.setColorFilter((int) animator.getAnimatedValue(), PorterDuff.Mode.SRC_ATOP));
colorAnimation.start();
}
}
\ No newline at end of file
More information about the tor-commits
mailing list