Verified Commit aaea63a1 authored by HashikD's avatar HashikD
Browse files

Changed Snowflake Button to Switch

parent c5b31d6c
......@@ -6,7 +6,7 @@ import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.Switch;
import android.widget.TextView;
import androidx.annotation.NonNull;
......@@ -52,15 +52,17 @@ public class MainFragment extends Fragment {
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_main, container, false);
usersServedTV = rootView.findViewById(R.id.users_served);
Button startButton = rootView.findViewById(R.id.start_button);
Switch startButton = rootView.findViewById(R.id.start_button);
startButton.setOnClickListener(v -> {
if (callback.isServiceRunning()) //Toggling the service.
startButton.setOnCheckedChangeListener((buttonView, isChecked) -> {
if (callback.isServiceRunning() && !isChecked) { //Toggling the service.
startButton.setText(getString(R.string.Snowflake_Off));
callback.serviceToggle(ForegroundServiceConstants.ACTION_STOP);
else
} else {
startButton.setText(getString(R.string.Snowflake_On));
callback.serviceToggle(ForegroundServiceConstants.ACTION_START);
}
});
showServed(callback.getServed());
// Inflate the layout for this fragment
......
......@@ -6,13 +6,16 @@
tools:context=".fragments.MainFragment">
<Button
<Switch
android:id="@+id/start_button"
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:foreground="?android:attr/selectableItemBackground"
android:text="Service Toggle" />
android:layout_margin="20dp"
android:text="@string/Snowflake_Off"
android:textAlignment="textStart"
android:textColor="@color/colorText"
android:textSize="20sp" />
<TextView
android:id="@+id/users_served"
......
......@@ -3,4 +3,6 @@
<string name="not_channel_desc">This Channel should not be muted. The Android system will consider Snowflake not import and will kill the service if it\'s muted.</string>
<string name="not_channel_name">Snowflake Service</string>
<string name="users_served_text">Users you have helped circumvent censorship in the past day \n</string>
<string name="Snowflake_Off">Snowflake is Off</string>
<string name="Snowflake_On">Snowflake is On</string>
</resources>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment