Skip to content

Commit

Permalink
Fix backstack
Browse files Browse the repository at this point in the history
  • Loading branch information
muzzammilshahid committed May 29, 2024
1 parent 041c6e3 commit f7c298a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,8 @@
import io.xconn.androidexample.R;
import io.xconn.androidexample.util.App;


public class CameraFragment extends Fragment {


private ActivityResultLauncher<String> cameraPermissionLauncher;
private ActivityResultLauncher<Intent> cameraLauncher;
private ActivityResultLauncher<Intent> galleryLauncher;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import android.os.Looper;
import android.text.TextUtils;
import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand All @@ -32,11 +31,11 @@
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import io.xconn.cryptology.SealedBox;
import io.xconn.cryptology.SecretBox;
import io.xconn.androidexample.R;
import io.xconn.androidexample.util.App;
import io.xconn.androidexample.util.Helpers;
import io.xconn.cryptology.SealedBox;
import io.xconn.cryptology.SecretBox;

public class GalleryFragment extends Fragment implements Helpers.PasswordDialogListener {

Expand All @@ -60,18 +59,10 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
super.onViewCreated(view, savedInstanceState);
requireActivity().findViewById(R.id.frameLayout).setFocusableInTouchMode(true);
requireActivity().findViewById(R.id.frameLayout).requestFocus();
requireActivity().findViewById(R.id.frameLayout).setOnKeyListener((v, keyCode, event) -> {
if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP) {
onBackPressed();
return true;
}
return false;
});
Helpers.showPasswordDialog(requireContext(), this,
true);
}


@Override
public boolean onPasswordSubmit(String password) {
boolean isPrivateKeyDecrypted = decryptPrivateKey(password);
Expand Down Expand Up @@ -104,14 +95,6 @@ public void onDismissed(boolean dismissedAfterSubmit) {
}


private void onBackPressed() {
if (isCameraFragmentFocused()) {
focusOnCameraFragment();
}
navigateToCameraFragment();
}


private boolean decryptPrivateKey(String password) {
String encryptedPrivateKeyHex = App.getString(App.PREF_PRIVATE_KEY);
String nonceHex = App.getString(App.PREF_NONCE);
Expand All @@ -136,7 +119,6 @@ private boolean decryptPrivateKey(String password) {
}

private boolean isCameraFragmentFocused() {

if (isAdded()) {
return !requireActivity().findViewById(R.id.menu_camera).isSelected();
}
Expand Down

0 comments on commit f7c298a

Please sign in to comment.