summaryrefslogtreecommitdiff
path: root/app/src/main/java/se/leap/bitmaskclient/providersetup/fragments/CircumventionSetupFragment.java
blob: 2709fd0b15ac17c2928babaf4a18359245851113 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package se.leap.bitmaskclient.providersetup.fragments;

import android.graphics.Typeface;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import se.leap.bitmaskclient.base.utils.PreferenceHelper;
import se.leap.bitmaskclient.databinding.FCircumventionSetupBinding;

public class CircumventionSetupFragment extends BaseSetupFragment {

    private CircumventionSetupFragment(int position) {
        super(position);
    }

    public static CircumventionSetupFragment newInstance(int position) {
        return new CircumventionSetupFragment(position);
    }

    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
                             @Nullable Bundle savedInstanceState) {
        FCircumventionSetupBinding binding = FCircumventionSetupBinding.inflate(inflater, container, false);

        binding.circumventionRadioGroup.setOnCheckedChangeListener((group, checkedId) -> {
            if (binding.rbCircumvention.getId() == checkedId) {
                PreferenceHelper.useBridges(true);
                PreferenceHelper.useSnowflake(true);
                binding.tvCircumventionDetailDescription.setVisibility(View.VISIBLE);
                binding.rbCircumvention.setTypeface(Typeface.DEFAULT, Typeface.BOLD);
                binding.rbPlainVpn.setTypeface(Typeface.DEFAULT, Typeface.NORMAL);
                return;
            }

            PreferenceHelper.useBridges(false);
            PreferenceHelper.useSnowflake(false);
            binding.tvCircumventionDetailDescription.setVisibility(View.GONE);
            binding.rbPlainVpn.setTypeface(Typeface.DEFAULT, Typeface.BOLD);
            binding.rbCircumvention.setTypeface(Typeface.DEFAULT, Typeface.NORMAL);
        });
        binding.circumventionRadioGroup.check(binding.rbPlainVpn.getId());
        return binding.getRoot();
    }

    @Override
    public void onFragmentSelected() {
        super.onFragmentSelected();
        setupActivityCallback.setCancelButtonHidden(false);
        setupActivityCallback.setNavigationButtonHidden(false);
    }
}