diff --git a/app/src/main/java/org/openobservatory/ooniprobe/fragment/onboarding/Onboarding1Fragment.java b/app/src/main/java/org/openobservatory/ooniprobe/fragment/onboarding/Onboarding1Fragment.java index ddc203fbb..54382527a 100644 --- a/app/src/main/java/org/openobservatory/ooniprobe/fragment/onboarding/Onboarding1Fragment.java +++ b/app/src/main/java/org/openobservatory/ooniprobe/fragment/onboarding/Onboarding1Fragment.java @@ -4,24 +4,21 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; - import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; - -import org.openobservatory.ooniprobe.R; - -import butterknife.ButterKnife; -import butterknife.OnClick; +import org.openobservatory.ooniprobe.databinding.FragmentOnboarding1Binding; public class Onboarding1Fragment extends Fragment { - @Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { - View v = inflater.inflate(R.layout.fragment_onboarding_1, container, false); - ButterKnife.bind(this, v); - return v; + @Nullable + @Override + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { + FragmentOnboarding1Binding binding = FragmentOnboarding1Binding.inflate(inflater, container, false); + binding.master.setOnClickListener(v -> masterClick()); + return binding.getRoot(); } - @OnClick(R.id.master) void masterClick() { + void masterClick() { getParentFragmentManager().beginTransaction().replace(android.R.id.content, new Onboarding2Fragment()).commit(); } } diff --git a/app/src/main/java/org/openobservatory/ooniprobe/fragment/onboarding/Onboarding2Fragment.java b/app/src/main/java/org/openobservatory/ooniprobe/fragment/onboarding/Onboarding2Fragment.java index 663da5a4c..fddbc294b 100644 --- a/app/src/main/java/org/openobservatory/ooniprobe/fragment/onboarding/Onboarding2Fragment.java +++ b/app/src/main/java/org/openobservatory/ooniprobe/fragment/onboarding/Onboarding2Fragment.java @@ -6,41 +6,36 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.TextView; - import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; - import org.openobservatory.ooniprobe.R; - -import butterknife.BindView; -import butterknife.ButterKnife; -import butterknife.OnClick; +import org.openobservatory.ooniprobe.databinding.FragmentOnboarding2Binding; public class Onboarding2Fragment extends Fragment implements OnboardingDialogPopquizFragment.OnboardingPopquizInterface, OnboardingDialogWarningFragment.OnboardingWarningInterface { - @BindView(R.id.bullet1) TextView bullet1; - @BindView(R.id.bullet2) TextView bullet2; - @BindView(R.id.bullet3) TextView bullet3; - @Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { - View v = inflater.inflate(R.layout.fragment_onboarding_2, container, false); - ButterKnife.bind(this, v); - bullet1.setText(getString(R.string.bullet, getString(R.string.Onboarding_ThingsToKnow_Bullet_1))); - bullet2.setText(getString(R.string.bullet, getString(R.string.Onboarding_ThingsToKnow_Bullet_2))); - bullet3.setText(getString(R.string.bullet, getString(R.string.Onboarding_ThingsToKnow_Bullet_3))); - return v; + @Nullable + @Override + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { + FragmentOnboarding2Binding binding = FragmentOnboarding2Binding.inflate(inflater, container, false); + binding.bullet1.setText(getString(R.string.bullet, getString(R.string.Onboarding_ThingsToKnow_Bullet_1))); + binding.bullet2.setText(getString(R.string.bullet, getString(R.string.Onboarding_ThingsToKnow_Bullet_2))); + binding.bullet3.setText(getString(R.string.bullet, getString(R.string.Onboarding_ThingsToKnow_Bullet_3))); + binding.master.setOnClickListener(v -> masterClick()); + binding.slave.setOnClickListener(v -> slaveClick()); + return binding.getRoot(); } - @OnClick(R.id.master) void masterClick() { + void masterClick() { OnboardingDialogPopquizFragment.newInstance(R.string.Onboarding_PopQuiz_1_Title, R.string.Onboarding_PopQuiz_1_Question).show(getChildFragmentManager(), null); } - @OnClick(R.id.slave) void slaveClick() { + void slaveClick() { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://ooni.io/about/risks/"))); } - @Override public void onPopquizResult(int questionResId, boolean positive) { + @Override + public void onPopquizResult(int questionResId, boolean positive) { if (questionResId == R.string.Onboarding_PopQuiz_1_Question) { if (positive) OnboardingDialogPopquizFragment.newInstance(R.string.Onboarding_PopQuiz_2_Title, R.string.Onboarding_PopQuiz_2_Question).show(getChildFragmentManager(), null); @@ -54,7 +49,8 @@ public class Onboarding2Fragment extends Fragment implements OnboardingDialogPop } } - @Override public void onWarningResult(int questionResId) { + @Override + public void onWarningResult(int questionResId) { if (questionResId == R.string.Onboarding_PopQuiz_1_Wrong_Paragraph) OnboardingDialogPopquizFragment.newInstance(R.string.Onboarding_PopQuiz_2_Title, R.string.Onboarding_PopQuiz_2_Question).show(getChildFragmentManager(), null); else if (questionResId == R.string.Onboarding_PopQuiz_2_Wrong_Paragraph) diff --git a/app/src/main/java/org/openobservatory/ooniprobe/fragment/onboarding/Onboarding3Fragment.java b/app/src/main/java/org/openobservatory/ooniprobe/fragment/onboarding/Onboarding3Fragment.java index cc649e834..005204e37 100644 --- a/app/src/main/java/org/openobservatory/ooniprobe/fragment/onboarding/Onboarding3Fragment.java +++ b/app/src/main/java/org/openobservatory/ooniprobe/fragment/onboarding/Onboarding3Fragment.java @@ -4,48 +4,42 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.TextView; - import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; - import org.openobservatory.ooniprobe.R; import org.openobservatory.ooniprobe.activity.MainActivity; import org.openobservatory.ooniprobe.common.Application; import org.openobservatory.ooniprobe.common.PreferenceManager; import org.openobservatory.ooniprobe.common.ThirdPartyServices; import org.openobservatory.ooniprobe.common.service.ServiceUtil; +import org.openobservatory.ooniprobe.databinding.FragmentOnboarding3Binding; +import ru.noties.markwon.Markwon; import javax.inject.Inject; -import butterknife.BindView; -import butterknife.ButterKnife; -import butterknife.OnClick; -import ru.noties.markwon.Markwon; - public class Onboarding3Fragment extends Fragment { @Inject PreferenceManager preferenceManager; - @BindView(R.id.bullet1) TextView bullet1; - @BindView(R.id.bullet2) TextView bullet2; - @BindView(R.id.bullet3) TextView bullet3; - @BindView(R.id.paragraph) TextView paragraph; - - @Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { + @Nullable + @Override + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { ((Application) getActivity().getApplication()).getFragmentComponent().inject(this); - View v = inflater.inflate(R.layout.fragment_onboarding_3, container, false); - ButterKnife.bind(this, v); - bullet1.setText(getString(R.string.bullet, getString(R.string.Onboarding_DefaultSettings_Bullet_1))); - bullet2.setText(getString(R.string.bullet, getString(R.string.Onboarding_DefaultSettings_Bullet_2))); - bullet3.setText(getString(R.string.bullet, getString(R.string.Onboarding_DefaultSettings_Bullet_3))); - Markwon.setMarkdown(paragraph, getString(R.string.Onboarding_DefaultSettings_Paragraph)); - return v; + FragmentOnboarding3Binding binding = FragmentOnboarding3Binding.inflate(inflater, container, false); + binding.bullet1.setText(getString(R.string.bullet, getString(R.string.Onboarding_DefaultSettings_Bullet_1))); + binding.bullet2.setText(getString(R.string.bullet, getString(R.string.Onboarding_DefaultSettings_Bullet_2))); + binding.bullet3.setText(getString(R.string.bullet, getString(R.string.Onboarding_DefaultSettings_Bullet_3))); + Markwon.setMarkdown(binding.paragraph, getString(R.string.Onboarding_DefaultSettings_Paragraph)); + + binding.master.setOnClickListener(v -> masterClick()); + binding.slave.setOnClickListener(v -> slaveClick()); + + return binding.getRoot(); } - @OnClick(R.id.master) void masterClick() { + void masterClick() { preferenceManager.setShowOnboarding(false); ThirdPartyServices.reloadConsents((Application) getActivity().getApplication()); startAutoTestIfNeeded(); @@ -53,7 +47,7 @@ public class Onboarding3Fragment extends Fragment { getActivity().finish(); } - @OnClick(R.id.slave) void slaveClick() { + void slaveClick() { preferenceManager.setShowOnboarding(false); startAutoTestIfNeeded(); startActivity(MainActivity.newIntent(getActivity(), R.id.settings)); diff --git a/app/src/main/java/org/openobservatory/ooniprobe/fragment/onboarding/OnboardingAutoTestFragment.java b/app/src/main/java/org/openobservatory/ooniprobe/fragment/onboarding/OnboardingAutoTestFragment.java index 38f520820..01ebce218 100644 --- a/app/src/main/java/org/openobservatory/ooniprobe/fragment/onboarding/OnboardingAutoTestFragment.java +++ b/app/src/main/java/org/openobservatory/ooniprobe/fragment/onboarding/OnboardingAutoTestFragment.java @@ -10,42 +10,39 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; - import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; - +import localhost.toolkit.app.fragment.ConfirmDialogFragment; import org.openobservatory.ooniprobe.R; import org.openobservatory.ooniprobe.common.Application; import org.openobservatory.ooniprobe.common.PreferenceManager; import org.openobservatory.ooniprobe.common.ThirdPartyServices; - -import java.io.Serializable; +import org.openobservatory.ooniprobe.databinding.FragmentOnboardingAutotestBinding; import javax.inject.Inject; - -import butterknife.ButterKnife; -import butterknife.OnClick; -import localhost.toolkit.app.fragment.ConfirmDialogFragment; +import java.io.Serializable; public class OnboardingAutoTestFragment extends Fragment implements ConfirmDialogFragment.OnConfirmedListener { @Inject PreferenceManager preferenceManager; public static final String BATTERY_DIALOG = "battery_optimization"; @Nullable - @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { + @Override + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { ((Application) getActivity().getApplication()).getFragmentComponent().inject(this); - View v = inflater.inflate(R.layout.fragment_onboarding_autotest, container, false); - ButterKnife.bind(this, v); - return v; + FragmentOnboardingAutotestBinding binding = FragmentOnboardingAutotestBinding.inflate(inflater, container, false); + binding.master.setOnClickListener(v -> masterClick()); + binding.slave.setOnClickListener(v -> slaveClick()); + return binding.getRoot(); } - @OnClick(R.id.master) void masterClick() { + void masterClick() { enableAutoTest(); } - @OnClick(R.id.slave) void slaveClick() { + void slaveClick() { next(); } diff --git a/app/src/main/java/org/openobservatory/ooniprobe/fragment/onboarding/OnboardingCrashFragment.java b/app/src/main/java/org/openobservatory/ooniprobe/fragment/onboarding/OnboardingCrashFragment.java index d3ece3295..1c4c97b94 100644 --- a/app/src/main/java/org/openobservatory/ooniprobe/fragment/onboarding/OnboardingCrashFragment.java +++ b/app/src/main/java/org/openobservatory/ooniprobe/fragment/onboarding/OnboardingCrashFragment.java @@ -4,32 +4,29 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; - import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; - -import org.openobservatory.ooniprobe.R; import org.openobservatory.ooniprobe.common.Application; import org.openobservatory.ooniprobe.common.ThirdPartyServices; - -import butterknife.ButterKnife; -import butterknife.OnClick; +import org.openobservatory.ooniprobe.databinding.FragmentOnboardingCrashBinding; public class OnboardingCrashFragment extends Fragment { @Nullable - @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { - View v = inflater.inflate(R.layout.fragment_onboarding_crash, container, false); - ButterKnife.bind(this, v); - return v; + @Override + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { + FragmentOnboardingCrashBinding binding = FragmentOnboardingCrashBinding.inflate(inflater, container, false); + binding.master.setOnClickListener(v -> masterClick()); + binding.slave.setOnClickListener(v -> slaveClick()); + return binding.getRoot(); } - @OnClick(R.id.master) void masterClick() { + void masterClick() { ThirdPartyServices.acceptCrash((Application) getActivity().getApplication()); getParentFragmentManager().beginTransaction().replace(android.R.id.content, new Onboarding3Fragment()).commit(); } - @OnClick(R.id.slave) void slaveClick() { + void slaveClick() { getParentFragmentManager().beginTransaction().replace(android.R.id.content, new Onboarding3Fragment()).commit(); } diff --git a/app/src/main/java/org/openobservatory/ooniprobe/fragment/onboarding/OnboardingDialogPopquizFragment.java b/app/src/main/java/org/openobservatory/ooniprobe/fragment/onboarding/OnboardingDialogPopquizFragment.java index d1f93267a..8321f0f89 100644 --- a/app/src/main/java/org/openobservatory/ooniprobe/fragment/onboarding/OnboardingDialogPopquizFragment.java +++ b/app/src/main/java/org/openobservatory/ooniprobe/fragment/onboarding/OnboardingDialogPopquizFragment.java @@ -9,28 +9,16 @@ import android.view.View; import android.view.ViewGroup; import android.view.WindowManager; -import android.widget.LinearLayout; -import android.widget.TextView; - import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.fragment.app.DialogFragment; - -import com.airbnb.lottie.LottieAnimationView; - import org.openobservatory.ooniprobe.R; - -import butterknife.BindView; -import butterknife.ButterKnife; -import butterknife.OnClick; +import org.openobservatory.ooniprobe.databinding.FragmentOnboardingDialogPopquizBinding; public class OnboardingDialogPopquizFragment extends DialogFragment { private static final String TITLE_RES_ID = "titleResId"; private static final String QUESTION_RES_ID = "questionResId"; - @BindView(R.id.title) @Nullable TextView title; - @BindView(R.id.question) TextView question; - @BindView(R.id.dialog) LinearLayout dialog; - @BindView(R.id.animation) LottieAnimationView animation; + private FragmentOnboardingDialogPopquizBinding binding; public static OnboardingDialogPopquizFragment newInstance(int titleResId, int questionResId) { Bundle args = new Bundle(); @@ -53,42 +41,45 @@ public void onStart() { @Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { assert getArguments() != null; - View v = inflater.inflate(R.layout.fragment_onboarding_dialog_popquiz, container, false); - ButterKnife.bind(this, v); - if (title != null) - title.setText(getArguments().getInt(TITLE_RES_ID)); - question.setText(getArguments().getInt(QUESTION_RES_ID)); - return v; + binding = FragmentOnboardingDialogPopquizBinding.inflate(inflater, container, false); + if (binding.title != null) + binding.title.setText(getArguments().getInt(TITLE_RES_ID)); + binding.question.setText(getArguments().getInt(QUESTION_RES_ID)); + + binding.positive.setOnClickListener(v -> positiveClick()); + binding.negative.setOnClickListener(v -> negativeClick()); + + return binding.getRoot(); } - @OnClick(R.id.positive) void positiveClick() { - animation.setBackgroundResource(R.drawable.dialog_green); - animation.setAnimation("anim/checkMark.json"); - animation.setVisibility(View.VISIBLE); - dialog.setVisibility(View.INVISIBLE); - animation.addAnimatorListener(new AnimatorListenerAdapter() { + void positiveClick() { + binding.animation.setBackgroundResource(R.drawable.dialog_green); + binding.animation.setAnimation("anim/checkMark.json"); + binding.animation.setVisibility(View.VISIBLE); + binding.dialog.setVisibility(View.INVISIBLE); + binding.animation.addAnimatorListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { dismiss(); ((OnboardingPopquizInterface) getParentFragment()).onPopquizResult(getArguments().getInt(QUESTION_RES_ID), true); } }); - animation.playAnimation(); + binding.animation.playAnimation(); } - @OnClick(R.id.negative) void negativeClick() { - animation.setBackgroundResource(R.drawable.dialog_red); - animation.setAnimation("anim/crossMark.json"); - animation.setVisibility(View.VISIBLE); - dialog.setVisibility(View.INVISIBLE); - animation.addAnimatorListener(new AnimatorListenerAdapter() { + void negativeClick() { + binding.animation.setBackgroundResource(R.drawable.dialog_red); + binding.animation.setAnimation("anim/crossMark.json"); + binding.animation.setVisibility(View.VISIBLE); + binding.dialog.setVisibility(View.INVISIBLE); + binding.animation.addAnimatorListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { dismiss(); ((OnboardingPopquizInterface) getParentFragment()).onPopquizResult(getArguments().getInt(QUESTION_RES_ID), false); } }); - animation.playAnimation(); + binding.animation.playAnimation(); } public interface OnboardingPopquizInterface { diff --git a/app/src/main/java/org/openobservatory/ooniprobe/fragment/onboarding/OnboardingDialogWarningFragment.java b/app/src/main/java/org/openobservatory/ooniprobe/fragment/onboarding/OnboardingDialogWarningFragment.java index 5cc405474..f8e6102eb 100644 --- a/app/src/main/java/org/openobservatory/ooniprobe/fragment/onboarding/OnboardingDialogWarningFragment.java +++ b/app/src/main/java/org/openobservatory/ooniprobe/fragment/onboarding/OnboardingDialogWarningFragment.java @@ -7,24 +7,13 @@ import android.view.View; import android.view.ViewGroup; import android.view.WindowManager; -import android.widget.LinearLayout; -import android.widget.TextView; - import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.fragment.app.DialogFragment; - -import org.openobservatory.ooniprobe.R; - -import butterknife.BindView; -import butterknife.ButterKnife; -import butterknife.OnClick; +import org.openobservatory.ooniprobe.databinding.FragmentOnboardingDialogWarningBinding; public class OnboardingDialogWarningFragment extends DialogFragment { private static final String QUESTION_RES_ID = "questionResId"; - @BindView(R.id.title) @Nullable TextView title; - @BindView(R.id.question) TextView question; - @BindView(R.id.dialog) LinearLayout dialog; public static OnboardingDialogWarningFragment newInstance(int questionResId) { Bundle args = new Bundle(); @@ -46,17 +35,20 @@ public void onStart() { @Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { assert getArguments() != null; - View v = inflater.inflate(R.layout.fragment_onboarding_dialog_warning, container, false); - ButterKnife.bind(this, v); - question.setText(getArguments().getInt(QUESTION_RES_ID)); - return v; + FragmentOnboardingDialogWarningBinding binding = FragmentOnboardingDialogWarningBinding.inflate(inflater, container, false); + binding.question.setText(getArguments().getInt(QUESTION_RES_ID)); + + binding.positive.setOnClickListener(v -> positiveClick()); + binding.negative.setOnClickListener(v -> negativeClick()); + + return binding.getRoot(); } - @OnClick(R.id.positive) void positiveClick() { + void positiveClick() { dismiss(); } - @OnClick(R.id.negative) void negativeClick() { + void negativeClick() { dismiss(); ((OnboardingWarningInterface) getParentFragment()).onWarningResult(getArguments().getInt(QUESTION_RES_ID)); }