Skip to content

Commit

Permalink
added option to force quit focus mode when smth goes wrong
Browse files Browse the repository at this point in the history
  • Loading branch information
nethical6 committed Aug 25, 2024
1 parent 88ff8bc commit ffcf783
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ public class FocusQuest extends Fragment {

SharedPreferences questInfo;

private TextView mins;
private int minsClickCounter = 0;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// Inflate the layout for this fragment
Expand All @@ -53,6 +56,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
setFTime = view.findViewById(R.id.choose_ftime);
selectTimeLayout = view.findViewById(R.id.focus_set_time_layout);
startFocus = view.findViewById(R.id.btn_start_focus);
mins = view.findViewById(R.id.mins_txt);
return view;
}

Expand Down Expand Up @@ -87,6 +91,21 @@ public void onViewCreated(View view, Bundle savedInstanceState) {
startFocus.setOnClickListener(v -> {
makeQuestWarningDialog().show();
});
mins.setOnClickListener(v -> {
minsClickCounter++;
if(minsClickCounter==6){
Toast.makeText(requireContext(),"Press 4 times more to force exit focus mode", Toast.LENGTH_SHORT).show();;
}
if(minsClickCounter>10){
SurvivalModeManager.disableSurvivalMode(requireContext());
DigiUtils.replaceScreenWithoutAddingToBackStack(getParentFragmentManager(),new HomeFragment());
SharedPreferences questPref = requireContext().getSharedPreferences(
DigiConstants.PREF_QUEST_INFO_FILE, Context.MODE_PRIVATE);

questPref.edit().putString(DigiConstants.PREF_QUEST_ID_KEY,DigiConstants.QUEST_ID_NULL).apply();

}
});

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ public void onDestroy() {
if (countDownTimer != null) {
countDownTimer.cancel();
}
SurvivalModeManager.disableSurvivalMode(getApplicationContext());
SharedPreferences questPref = getSharedPreferences(
DigiConstants.PREF_QUEST_INFO_FILE, Context.MODE_PRIVATE);

questPref.edit().putString(DigiConstants.PREF_QUEST_ID_KEY,DigiConstants.QUEST_ID_NULL).apply();
}

@Nullable
Expand Down
14 changes: 13 additions & 1 deletion app/src/main/res/layout/focus_quest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
android:textColor="#fff"/>

<TextView
android:id="@+id/textView"
android:id="@+id/mins_txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
Expand All @@ -58,4 +58,16 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/focus_set_time_layout" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="8dp"
android:layout_marginTop="16dp"
android:text="@string/enter_safe_mode_title"
android:textAppearance="@style/TextAppearance.Material3.BodySmall"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/btn_start_focus" />

</androidx.constraintlayout.widget.ConstraintLayout>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@
<string name="title">Title</string>
<string name="description">description</string>
<string name="shorts_allow_first_shorts_title">Do not block the first short I open myself (Experimental)</string>
<string name="enter_safe_mode_title">Press "minutes" ten times to force quit focus mode.</string>


</resources>

0 comments on commit ffcf783

Please sign in to comment.