Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
The Tor Project
Anti-censorship
Pluggable Transports
Snowflake Mobile
Commits
86a04257
Verified
Commit
86a04257
authored
Aug 06, 2020
by
HashikD
Browse files
Fixed switch state bug
parent
73bf1dfb
Changes
1
Hide whitespace changes
Inline
Side-by-side
app/src/main/java/org/torproject/snowflake/fragments/MainFragment.java
View file @
86a04257
...
...
@@ -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
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment