mirror of
https://github.com/android-password-store/Android-Password-Store
synced 2025-08-30 13:57:47 +00:00
avoid adding anything when getting back from an activity
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
package com.zeapo.pwdstore;
|
package com.zeapo.pwdstore;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.Fragment;
|
|
||||||
import android.app.FragmentManager;
|
import android.app.FragmentManager;
|
||||||
import android.app.FragmentTransaction;
|
import android.app.FragmentTransaction;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@@ -16,19 +15,16 @@ import com.zeapo.pwdstore.utils.PasswordItem;
|
|||||||
import com.zeapo.pwdstore.utils.PasswordRepository;
|
import com.zeapo.pwdstore.utils.PasswordRepository;
|
||||||
|
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.commons.io.filefilter.FileFilterUtils;
|
|
||||||
import org.eclipse.jgit.lib.Repository;
|
|
||||||
import org.eclipse.jgit.transport.CredentialItem;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileFilter;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Stack;
|
import java.util.Stack;
|
||||||
|
|
||||||
|
|
||||||
public class PasswordStore extends Activity implements ToCloneOrNot.OnFragmentInteractionListener, PasswordFragment.OnFragmentInteractionListener {
|
public class PasswordStore extends Activity implements ToCloneOrNot.OnFragmentInteractionListener, PasswordFragment.OnFragmentInteractionListener {
|
||||||
private int listState = 0;
|
|
||||||
private Stack<Integer> scrollPositions;
|
private Stack<Integer> scrollPositions;
|
||||||
|
/** if we leave the activity to do something, do not add any other fragment */
|
||||||
|
private boolean leftActivity = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@@ -48,6 +44,12 @@ public class PasswordStore extends Activity implements ToCloneOrNot.OnFragmentI
|
|||||||
checkLocalRepository();
|
checkLocalRepository();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPause() {
|
||||||
|
super.onPause();
|
||||||
|
this.leftActivity = true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
// Inflate the menu; this adds items to the action bar if it is present.
|
// Inflate the menu; this adds items to the action bar if it is present.
|
||||||
@@ -98,7 +100,10 @@ public class PasswordStore extends Activity implements ToCloneOrNot.OnFragmentI
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void checkLocalRepository() {
|
private void checkLocalRepository() {
|
||||||
// final File localDir = new File(getFilesDir() + "/store/.git");
|
// if we are coming back from gpg do not anything
|
||||||
|
if (this.leftActivity)
|
||||||
|
return;
|
||||||
|
|
||||||
checkLocalRepository(PasswordRepository.getWorkTree());
|
checkLocalRepository(PasswordRepository.getWorkTree());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -141,6 +146,8 @@ public class PasswordStore extends Activity implements ToCloneOrNot.OnFragmentI
|
|||||||
fragmentTransaction.replace(R.id.main_layout, passFrag, "PasswordsList");
|
fragmentTransaction.replace(R.id.main_layout, passFrag, "PasswordsList");
|
||||||
fragmentTransaction.commit();
|
fragmentTransaction.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.leftActivity = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Stack the positions the different fragments were at */
|
/** Stack the positions the different fragments were at */
|
||||||
@@ -157,6 +164,8 @@ public class PasswordStore extends Activity implements ToCloneOrNot.OnFragmentI
|
|||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
try {
|
try {
|
||||||
|
this.leftActivity = true;
|
||||||
|
|
||||||
Intent intent = new Intent(this, PgpHandler.class);
|
Intent intent = new Intent(this, PgpHandler.class);
|
||||||
intent.putExtra("PGP-ID", FileUtils.readFileToString(PasswordRepository.getFile("/.gpg-id")));
|
intent.putExtra("PGP-ID", FileUtils.readFileToString(PasswordRepository.getFile("/.gpg-id")));
|
||||||
intent.putExtra("NAME", item.getName());
|
intent.putExtra("NAME", item.getName());
|
||||||
|
Reference in New Issue
Block a user