keep F-Droid visible after adding removeable storage mirror
This commit is contained in:
parent
0e5dd45859
commit
69e2ca4283
@ -11,6 +11,7 @@ import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import org.fdroid.fdroid.data.Repo;
|
||||
import org.fdroid.fdroid.data.RepoProvider;
|
||||
import org.fdroid.fdroid.views.ManageReposActivity;
|
||||
import org.fdroid.fdroid.views.main.MainActivity;
|
||||
|
||||
import java.net.URI;
|
||||
@ -88,6 +89,7 @@ public class AddRepoIntentService extends IntentService {
|
||||
}
|
||||
}
|
||||
}
|
||||
intent.putExtra(ManageReposActivity.EXTRA_FINISH_AFTER_ADDING_REPO, false);
|
||||
intent.setComponent(new ComponentName(this, MainActivity.class));
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
startActivity(intent);
|
||||
|
@ -37,6 +37,8 @@ import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.LoaderManager;
|
||||
import android.support.v4.app.NavUtils;
|
||||
import android.support.v4.app.TaskStackBuilder;
|
||||
import android.support.v4.content.CursorLoader;
|
||||
import android.support.v4.content.Loader;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
@ -81,6 +83,8 @@ public class ManageReposActivity extends AppCompatActivity
|
||||
implements LoaderManager.LoaderCallbacks<Cursor>, RepoAdapter.EnabledListener {
|
||||
private static final String TAG = "ManageReposActivity";
|
||||
|
||||
public static final String EXTRA_FINISH_AFTER_ADDING_REPO = "finishAfterAddingRepo";
|
||||
|
||||
private static final String DEFAULT_NEW_REPO_TEXT = "https://";
|
||||
|
||||
private enum AddRepoState {
|
||||
@ -95,7 +99,7 @@ public class ManageReposActivity extends AppCompatActivity
|
||||
* True if activity started with an intent such as from QR code. False if
|
||||
* opened from, e.g. the main menu.
|
||||
*/
|
||||
private boolean isImportingRepo;
|
||||
private boolean finishAfterAddingRepo;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@ -158,6 +162,16 @@ public class ManageReposActivity extends AppCompatActivity
|
||||
case R.id.action_add_repo:
|
||||
showAddRepo();
|
||||
return true;
|
||||
case android.R.id.home:
|
||||
Intent upIntent = NavUtils.getParentActivityIntent(this);
|
||||
if (NavUtils.shouldUpRecreateTask(this, upIntent) || isTaskRoot()) {
|
||||
TaskStackBuilder.create(this)
|
||||
.addNextIntentWithParentStack(upIntent)
|
||||
.startActivities();
|
||||
} else {
|
||||
NavUtils.navigateUpTo(this, upIntent);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
@ -274,7 +288,7 @@ public class ManageReposActivity extends AppCompatActivity
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dialog.dismiss();
|
||||
if (isImportingRepo) {
|
||||
if (finishAfterAddingRepo) {
|
||||
ManageReposActivity.this.finish();
|
||||
}
|
||||
}
|
||||
@ -789,7 +803,7 @@ public class ManageReposActivity extends AppCompatActivity
|
||||
if (addRepoDialog.isShowing()) {
|
||||
addRepoDialog.dismiss();
|
||||
}
|
||||
if (isImportingRepo) {
|
||||
if (finishAfterAddingRepo) {
|
||||
setResult(RESULT_OK);
|
||||
finish();
|
||||
}
|
||||
@ -800,7 +814,7 @@ public class ManageReposActivity extends AppCompatActivity
|
||||
/* an URL from a click, NFC, QRCode scan, etc */
|
||||
NewRepoConfig newRepoConfig = new NewRepoConfig(this, intent);
|
||||
if (newRepoConfig.isValidRepo()) {
|
||||
isImportingRepo = true;
|
||||
finishAfterAddingRepo = intent.getBooleanExtra(EXTRA_FINISH_AFTER_ADDING_REPO, true);
|
||||
showAddRepo(newRepoConfig.getRepoUriString(), newRepoConfig.getFingerprint(),
|
||||
newRepoConfig.getUsername(), newRepoConfig.getPassword());
|
||||
checkIfNewRepoOnSameWifi(newRepoConfig);
|
||||
|
@ -353,7 +353,12 @@ public class MainActivity extends AppCompatActivity implements BottomNavigationB
|
||||
confirmIntent.setData(intent.getData());
|
||||
startActivityForResult(confirmIntent, REQUEST_SWAP);
|
||||
} else {
|
||||
startActivity(new Intent(ACTION_ADD_REPO, intent.getData(), this, ManageReposActivity.class));
|
||||
Intent clean = new Intent(ACTION_ADD_REPO, intent.getData(), this, ManageReposActivity.class);
|
||||
if (intent.hasExtra(ManageReposActivity.EXTRA_FINISH_AFTER_ADDING_REPO)) {
|
||||
clean.putExtra(ManageReposActivity.EXTRA_FINISH_AFTER_ADDING_REPO,
|
||||
intent.getBooleanExtra(ManageReposActivity.EXTRA_FINISH_AFTER_ADDING_REPO, true));
|
||||
}
|
||||
startActivity(clean);
|
||||
}
|
||||
finish();
|
||||
} else if (parser.getErrorMessage() != null) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user