ImportKeys: Add possibility to go back to single card
This commit is contained in:
@@ -2,6 +2,12 @@ package org.sufficientlysecure.keychain.keyimport.processing;
|
|||||||
|
|
||||||
public interface LoaderState {
|
public interface LoaderState {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Basic mode includes ability to import all keys retrieved from the selected source
|
||||||
|
* This doesn't make sense for all sources (for example keyservers..)
|
||||||
|
*
|
||||||
|
* @return if currently selected source supports basic mode
|
||||||
|
*/
|
||||||
boolean isBasicModeSupported();
|
boolean isBasicModeSupported();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -311,12 +311,21 @@ public class ImportKeysActivity extends BaseActivity implements ImportKeysListen
|
|||||||
super.onActivityResult(requestCode, resultCode, data);
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBackPressed() {
|
||||||
|
FragmentManager fM = getSupportFragmentManager();
|
||||||
|
ImportKeysListFragment listFragment =
|
||||||
|
(ImportKeysListFragment) fM.findFragmentByTag(TAG_FRAG_LIST);
|
||||||
|
|
||||||
|
if ((listFragment == null) || listFragment.onBackPressed()) {
|
||||||
|
super.onBackPressed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadKeys(LoaderState loaderState) {
|
public void loadKeys(LoaderState loaderState) {
|
||||||
FragmentManager fM = getSupportFragmentManager();
|
FragmentManager fM = getSupportFragmentManager();
|
||||||
ImportKeysListFragment listFragment = (ImportKeysListFragment) fM.findFragmentByTag(TAG_FRAG_LIST);
|
((ImportKeysListFragment) fM.findFragmentByTag(TAG_FRAG_LIST)).loadState(loaderState);
|
||||||
|
|
||||||
listFragment.loadState(loaderState);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -210,6 +210,21 @@ public class ImportKeysListFragment extends Fragment implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* User may want to go back to single card view if he's now in full key list
|
||||||
|
* Check if we are in full key list and if this import operation supports basic mode
|
||||||
|
*
|
||||||
|
* @return true if activity's back pressed can be performed
|
||||||
|
*/
|
||||||
|
public boolean onBackPressed() {
|
||||||
|
boolean advanced = mBinding.getAdvanced();
|
||||||
|
if (advanced && mLoaderState.isBasicModeSupported()) {
|
||||||
|
mBinding.setAdvanced(false);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public void loadState(LoaderState loaderState) {
|
public void loadState(LoaderState loaderState) {
|
||||||
mLoaderState = loaderState;
|
mLoaderState = loaderState;
|
||||||
|
|
||||||
@@ -263,8 +278,7 @@ public class ImportKeysListFragment extends Fragment implements
|
|||||||
@Override
|
@Override
|
||||||
public void onLoadFinished(
|
public void onLoadFinished(
|
||||||
Loader<AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>> loader,
|
Loader<AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>> loader,
|
||||||
AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>> data
|
AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>> data) {
|
||||||
) {
|
|
||||||
|
|
||||||
mAdapter.setData(data.getResult());
|
mAdapter.setData(data.getResult());
|
||||||
int size = mAdapter.getItemCount();
|
int size = mAdapter.getItemCount();
|
||||||
@@ -329,8 +343,6 @@ public class ImportKeysListFragment extends Fragment implements
|
|||||||
getKeyResult.createNotify(mActivity).show();
|
getKeyResult.createNotify(mActivity).show();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user