ImportKeys: Use single card for importing all keys
This commit is contained in:
@@ -21,7 +21,6 @@ package org.sufficientlysecure.keychain.keyimport.processing;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.v4.content.AsyncTaskLoader;
|
import android.support.v4.content.AsyncTaskLoader;
|
||||||
import android.support.v4.util.LongSparseArray;
|
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
import org.sufficientlysecure.keychain.keyimport.ImportKeysListEntry;
|
import org.sufficientlysecure.keychain.keyimport.ImportKeysListEntry;
|
||||||
@@ -43,16 +42,17 @@ import java.io.FileNotFoundException;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class ImportKeysListLoader
|
public class ImportKeysListLoader
|
||||||
extends AsyncTaskLoader<AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>> {
|
extends AsyncTaskLoader<AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>> {
|
||||||
|
|
||||||
final Context mContext;
|
private final Context mContext;
|
||||||
final BytesLoaderState mLoaderState;
|
private final BytesLoaderState mLoaderState;
|
||||||
|
|
||||||
ArrayList<ImportKeysListEntry> mData = new ArrayList<>();
|
private ArrayList<ImportKeysListEntry> mData = new ArrayList<>();
|
||||||
LongSparseArray<ParcelableKeyRing> mParcelableRings = new LongSparseArray<>();
|
private ArrayList<ParcelableKeyRing> mParcelableRings = new ArrayList<>();
|
||||||
AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>> mEntryListWrapper;
|
private AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>> mEntryListWrapper;
|
||||||
|
|
||||||
public ImportKeysListLoader(Context context, BytesLoaderState inputData) {
|
public ImportKeysListLoader(Context context, BytesLoaderState inputData) {
|
||||||
super(context);
|
super(context);
|
||||||
@@ -113,7 +113,7 @@ public class ImportKeysListLoader
|
|||||||
super.deliverResult(data);
|
super.deliverResult(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public LongSparseArray<ParcelableKeyRing> getParcelableRings() {
|
public List<ParcelableKeyRing> getParcelableRings() {
|
||||||
return mParcelableRings;
|
return mParcelableRings;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,11 +133,9 @@ public class ImportKeysListLoader
|
|||||||
IteratorWithIOThrow<UncachedKeyRing> it = UncachedKeyRing.fromStream(bufferedInput);
|
IteratorWithIOThrow<UncachedKeyRing> it = UncachedKeyRing.fromStream(bufferedInput);
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
UncachedKeyRing ring = it.next();
|
UncachedKeyRing ring = it.next();
|
||||||
|
|
||||||
ImportKeysListEntry item = new ImportKeysListEntry(mContext, ring);
|
ImportKeysListEntry item = new ImportKeysListEntry(mContext, ring);
|
||||||
mData.add(item);
|
mData.add(item);
|
||||||
|
mParcelableRings.add(item.getParcelableKeyRing());
|
||||||
mParcelableRings.put(item.hashCode(), new ParcelableKeyRing(ring.getEncoded()));
|
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.e(Constants.TAG, "IOException on parsing key file! Return NoValidKeysException!", e);
|
Log.e(Constants.TAG, "IOException on parsing key file! Return NoValidKeysException!", e);
|
||||||
|
|||||||
@@ -28,20 +28,14 @@ import android.support.v4.app.Fragment;
|
|||||||
import android.support.v4.app.FragmentActivity;
|
import android.support.v4.app.FragmentActivity;
|
||||||
import android.support.v4.app.LoaderManager;
|
import android.support.v4.app.LoaderManager;
|
||||||
import android.support.v4.content.Loader;
|
import android.support.v4.content.Loader;
|
||||||
import android.support.v4.util.LongSparseArray;
|
|
||||||
import android.support.v7.widget.LinearLayoutManager;
|
import android.support.v7.widget.LinearLayoutManager;
|
||||||
import android.support.v7.widget.RecyclerView;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.Menu;
|
|
||||||
import android.view.MenuInflater;
|
|
||||||
import android.view.MenuItem;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
import org.sufficientlysecure.keychain.databinding.ImportKeysListFragmentBinding;
|
import org.sufficientlysecure.keychain.databinding.ImportKeysListFragmentBinding;
|
||||||
|
import org.sufficientlysecure.keychain.databinding.ImportKeysListItemBasicBinding;
|
||||||
import org.sufficientlysecure.keychain.keyimport.ImportKeysListEntry;
|
import org.sufficientlysecure.keychain.keyimport.ImportKeysListEntry;
|
||||||
import org.sufficientlysecure.keychain.keyimport.ParcelableKeyRing;
|
import org.sufficientlysecure.keychain.keyimport.ParcelableKeyRing;
|
||||||
import org.sufficientlysecure.keychain.keyimport.processing.AsyncTaskResultWrapper;
|
import org.sufficientlysecure.keychain.keyimport.processing.AsyncTaskResultWrapper;
|
||||||
@@ -56,7 +50,6 @@ import org.sufficientlysecure.keychain.service.input.RequiredInputParcel;
|
|||||||
import org.sufficientlysecure.keychain.ui.adapter.ImportKeysAdapter;
|
import org.sufficientlysecure.keychain.ui.adapter.ImportKeysAdapter;
|
||||||
import org.sufficientlysecure.keychain.ui.util.PermissionsUtil;
|
import org.sufficientlysecure.keychain.ui.util.PermissionsUtil;
|
||||||
import org.sufficientlysecure.keychain.util.IteratorWithSize;
|
import org.sufficientlysecure.keychain.util.IteratorWithSize;
|
||||||
import org.sufficientlysecure.keychain.util.Log;
|
|
||||||
import org.sufficientlysecure.keychain.util.ParcelableProxy;
|
import org.sufficientlysecure.keychain.util.ParcelableProxy;
|
||||||
import org.sufficientlysecure.keychain.util.Preferences;
|
import org.sufficientlysecure.keychain.util.Preferences;
|
||||||
import org.sufficientlysecure.keychain.util.Preferences.CloudSearchPrefs;
|
import org.sufficientlysecure.keychain.util.Preferences.CloudSearchPrefs;
|
||||||
@@ -78,13 +71,12 @@ public class ImportKeysListFragment extends Fragment implements
|
|||||||
private FragmentActivity mActivity;
|
private FragmentActivity mActivity;
|
||||||
private ImportKeysListener mCallback;
|
private ImportKeysListener mCallback;
|
||||||
|
|
||||||
private ImportKeysListFragmentBinding binding;
|
private ImportKeysListFragmentBinding mBinding;
|
||||||
|
private ImportKeysListItemBasicBinding mBindingBasic;
|
||||||
private ParcelableProxy mParcelableProxy;
|
private ParcelableProxy mParcelableProxy;
|
||||||
|
|
||||||
private RecyclerView mRecyclerView;
|
private List<ParcelableKeyRing> mKeyData;
|
||||||
private ImportKeysAdapter mAdapter;
|
private ImportKeysAdapter mAdapter;
|
||||||
private boolean mAdvanced;
|
|
||||||
|
|
||||||
private LoaderState mLoaderState;
|
private LoaderState mLoaderState;
|
||||||
|
|
||||||
public static final int STATUS_FIRST = 0;
|
public static final int STATUS_FIRST = 0;
|
||||||
@@ -94,53 +86,9 @@ public class ImportKeysListFragment extends Fragment implements
|
|||||||
|
|
||||||
private static final int LOADER_ID_BYTES = 0;
|
private static final int LOADER_ID_BYTES = 0;
|
||||||
private static final int LOADER_ID_CLOUD = 1;
|
private static final int LOADER_ID_CLOUD = 1;
|
||||||
private LongSparseArray<ParcelableKeyRing> mCachedKeyData;
|
|
||||||
|
|
||||||
private boolean mShowingOrbotDialog;
|
private boolean mShowingOrbotDialog;
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns an Iterator (with size) of the selected data items.
|
|
||||||
* This iterator is sort of a tradeoff, it's slightly more complex than an
|
|
||||||
* ArrayList would have been, but we save some memory by just returning
|
|
||||||
* relevant elements on demand.
|
|
||||||
*/
|
|
||||||
public IteratorWithSize<ParcelableKeyRing> getData() {
|
|
||||||
final List<ImportKeysListEntry> entries = getEntries();
|
|
||||||
final Iterator<ImportKeysListEntry> it = entries.iterator();
|
|
||||||
return new IteratorWithSize<ParcelableKeyRing>() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getSize() {
|
|
||||||
return entries.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasNext() {
|
|
||||||
return it.hasNext();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ParcelableKeyRing next() {
|
|
||||||
// throws NoSuchElementException if it doesn't exist, but that's not our problem
|
|
||||||
return mCachedKeyData.get(it.next().hashCode());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void remove() {
|
|
||||||
it.remove();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<ImportKeysListEntry> getEntries() {
|
|
||||||
if (mAdapter != null) {
|
|
||||||
return mAdapter.getEntries();
|
|
||||||
} else {
|
|
||||||
Log.e(Constants.TAG, "Adapter not initialized, returning empty list");
|
|
||||||
return new ArrayList<>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an interactive ImportKeyListFragment which reads keyrings from bytes, or file specified
|
* Creates an interactive ImportKeyListFragment which reads keyrings from bytes, or file specified
|
||||||
* by dataUri, or searches a keyserver for serverQuery, if parameter is not null, in that order
|
* by dataUri, or searches a keyserver for serverQuery, if parameter is not null, in that order
|
||||||
@@ -191,23 +139,24 @@ public class ImportKeysListFragment extends Fragment implements
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
|
||||||
binding = DataBindingUtil.inflate(inflater, R.layout.import_keys_list_fragment, container, false);
|
mBinding = DataBindingUtil.inflate(inflater, R.layout.import_keys_list_fragment, container, false);
|
||||||
binding.setStatus(STATUS_FIRST);
|
mBinding.setStatus(STATUS_FIRST);
|
||||||
View view = binding.getRoot();
|
mBindingBasic = mBinding.basic;
|
||||||
|
View view = mBinding.getRoot();
|
||||||
|
|
||||||
mActivity = getActivity();
|
mActivity = getActivity();
|
||||||
setHasOptionsMenu(true);
|
|
||||||
|
|
||||||
Bundle args = getArguments();
|
Bundle args = getArguments();
|
||||||
Uri dataUri = args.getParcelable(ARG_DATA_URI);
|
Uri dataUri = args.getParcelable(ARG_DATA_URI);
|
||||||
byte[] bytes = args.getByteArray(ARG_BYTES);
|
byte[] bytes = args.getByteArray(ARG_BYTES);
|
||||||
String query = args.getString(ARG_SERVER_QUERY);
|
String query = args.getString(ARG_SERVER_QUERY);
|
||||||
boolean nonInteractive = args.getBoolean(ARG_NON_INTERACTIVE, false);
|
boolean nonInteractive = args.getBoolean(ARG_NON_INTERACTIVE, false);
|
||||||
|
mBindingBasic.setNonInteractive(nonInteractive);
|
||||||
|
|
||||||
// Create an empty adapter we will use to display the loaded data.
|
// Create an empty adapter we will use to display the loaded data.
|
||||||
mAdapter = new ImportKeysAdapter(mActivity, mCallback, nonInteractive);
|
mAdapter = new ImportKeysAdapter(mActivity, mCallback, nonInteractive);
|
||||||
binding.recyclerView.setAdapter(mAdapter);
|
mBinding.recyclerView.setAdapter(mAdapter);
|
||||||
binding.recyclerView.setLayoutManager(new LinearLayoutManager(mActivity));
|
mBinding.recyclerView.setLayoutManager(new LinearLayoutManager(mActivity));
|
||||||
|
|
||||||
if (dataUri != null || bytes != null) {
|
if (dataUri != null || bytes != null) {
|
||||||
loadState(new BytesLoaderState(bytes, dataUri));
|
loadState(new BytesLoaderState(bytes, dataUri));
|
||||||
@@ -224,12 +173,18 @@ public class ImportKeysListFragment extends Fragment implements
|
|||||||
restartLoaders();
|
restartLoaders();
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.importKeys.setOnClickListener(new OnClickListener() {
|
mBinding.basic.importKeys.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
mCallback.importKeys();
|
mCallback.importKeys();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
mBinding.basic.listKeys.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
mBinding.setAdvanced(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
@@ -246,42 +201,6 @@ public class ImportKeysListFragment extends Fragment implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
|
||||||
if (mLoaderState != null) {
|
|
||||||
inflater.inflate(R.menu.import_keys_list_fragment, menu);
|
|
||||||
|
|
||||||
MenuItem basicMenuItem = menu.findItem(R.id.basic);
|
|
||||||
basicMenuItem.setVisible(mAdvanced && mLoaderState.isBasicModeSupported());
|
|
||||||
MenuItem advancedMenuItem = menu.findItem(R.id.advanced);
|
|
||||||
advancedMenuItem.setVisible(!mAdvanced);
|
|
||||||
}
|
|
||||||
|
|
||||||
super.onCreateOptionsMenu(menu, inflater);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
|
||||||
int itemId = item.getItemId();
|
|
||||||
switch (itemId) {
|
|
||||||
case R.id.basic:
|
|
||||||
setAdvanced(false);
|
|
||||||
return true;
|
|
||||||
case R.id.advanced:
|
|
||||||
setAdvanced(true);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAdvanced(boolean advanced) {
|
|
||||||
this.mAdvanced = advanced;
|
|
||||||
|
|
||||||
mAdapter.setAdvanced(advanced);
|
|
||||||
mActivity.invalidateOptionsMenu();
|
|
||||||
binding.setAdvanced(advanced);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRequestPermissionsResult(int requestCode,
|
public void onRequestPermissionsResult(int requestCode,
|
||||||
@NonNull String[] permissions,
|
@NonNull String[] permissions,
|
||||||
@@ -310,11 +229,7 @@ public class ImportKeysListFragment extends Fragment implements
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
mBinding.setAdvanced(!mLoaderState.isBasicModeSupported());
|
||||||
if (!mLoaderState.isBasicModeSupported()) {
|
|
||||||
mAdvanced = true;
|
|
||||||
}
|
|
||||||
setAdvanced(mAdvanced);
|
|
||||||
|
|
||||||
restartLoaders();
|
restartLoaders();
|
||||||
}
|
}
|
||||||
@@ -348,7 +263,7 @@ public class ImportKeysListFragment extends Fragment implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (loader != null) {
|
if (loader != null) {
|
||||||
binding.setStatus(STATUS_LOADING);
|
mBinding.setStatus(STATUS_LOADING);
|
||||||
}
|
}
|
||||||
|
|
||||||
return loader;
|
return loader;
|
||||||
@@ -360,19 +275,20 @@ public class ImportKeysListFragment extends Fragment implements
|
|||||||
AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>> data
|
AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>> data
|
||||||
) {
|
) {
|
||||||
ArrayList<ImportKeysListEntry> result = data.getResult();
|
ArrayList<ImportKeysListEntry> result = data.getResult();
|
||||||
binding.setStatus(result.size() > 0 ? STATUS_LOADED : STATUS_EMPTY);
|
|
||||||
|
|
||||||
// free old cached key data
|
|
||||||
mCachedKeyData = null;
|
|
||||||
|
|
||||||
|
mKeyData = null;
|
||||||
mAdapter.setData(result);
|
mAdapter.setData(result);
|
||||||
|
|
||||||
|
int size = result.size();
|
||||||
|
mBindingBasic.setNumber(size);
|
||||||
|
mBinding.setStatus(size > 0 ? STATUS_LOADED : STATUS_EMPTY);
|
||||||
|
|
||||||
GetKeyResult getKeyResult = (GetKeyResult) data.getOperationResult();
|
GetKeyResult getKeyResult = (GetKeyResult) data.getOperationResult();
|
||||||
switch (loader.getId()) {
|
switch (loader.getId()) {
|
||||||
case LOADER_ID_BYTES:
|
case LOADER_ID_BYTES:
|
||||||
if (getKeyResult.success()) {
|
if (getKeyResult.success()) {
|
||||||
// No error
|
// No error
|
||||||
mCachedKeyData = ((ImportKeysListLoader) loader).getParcelableRings();
|
mKeyData = ((ImportKeysListLoader) loader).getParcelableRings();
|
||||||
} else {
|
} else {
|
||||||
getKeyResult.createNotify(mActivity).show();
|
getKeyResult.createNotify(mActivity).show();
|
||||||
}
|
}
|
||||||
@@ -443,4 +359,36 @@ public class ImportKeysListFragment extends Fragment implements
|
|||||||
mAdapter.clearData();
|
mAdapter.clearData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an Iterator (with size) of the selected data items.
|
||||||
|
* This iterator is sort of a tradeoff, it's slightly more complex than an
|
||||||
|
* ArrayList would have been, but we save some memory by just returning
|
||||||
|
* relevant elements on demand.
|
||||||
|
*/
|
||||||
|
public IteratorWithSize<ParcelableKeyRing> getData() {
|
||||||
|
final Iterator<ParcelableKeyRing> it = mKeyData.iterator();
|
||||||
|
return new IteratorWithSize<ParcelableKeyRing>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getSize() {
|
||||||
|
return mKeyData.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasNext() {
|
||||||
|
return it.hasNext();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ParcelableKeyRing next() {
|
||||||
|
return it.next();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void remove() {
|
||||||
|
it.remove();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ public class ImportKeysAdapter extends RecyclerView.Adapter<ImportKeysAdapter.Vi
|
|||||||
|
|
||||||
private FragmentActivity mActivity;
|
private FragmentActivity mActivity;
|
||||||
private ImportKeysResultListener mListener;
|
private ImportKeysResultListener mListener;
|
||||||
private boolean mAdvanced, mNonInteractive;
|
private boolean mNonInteractive;
|
||||||
|
|
||||||
private List<ImportKeysListEntry> mData;
|
private List<ImportKeysListEntry> mData;
|
||||||
|
|
||||||
@@ -64,11 +64,6 @@ public class ImportKeysAdapter extends RecyclerView.Adapter<ImportKeysAdapter.Vi
|
|||||||
this.mNonInteractive = nonInteractive;
|
this.mNonInteractive = nonInteractive;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAdvanced(boolean advanced) {
|
|
||||||
this.mAdvanced = advanced;
|
|
||||||
notifyDataSetChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setData(List<ImportKeysListEntry> data) {
|
public void setData(List<ImportKeysListEntry> data) {
|
||||||
this.mData = data;
|
this.mData = data;
|
||||||
this.mKeyStates = new KeyState[data.size()];
|
this.mKeyStates = new KeyState[data.size()];
|
||||||
@@ -127,8 +122,6 @@ public class ImportKeysAdapter extends RecyclerView.Adapter<ImportKeysAdapter.Vi
|
|||||||
final ImportKeysListEntry entry = mData.get(position);
|
final ImportKeysListEntry entry = mData.get(position);
|
||||||
b.setEntry(entry);
|
b.setEntry(entry);
|
||||||
|
|
||||||
b.setAdvanced(mAdvanced);
|
|
||||||
|
|
||||||
final KeyState keyState = mKeyStates[position];
|
final KeyState keyState = mKeyStates[position];
|
||||||
final boolean downloaded = keyState.mDownloaded;
|
final boolean downloaded = keyState.mDownloaded;
|
||||||
final boolean showed = keyState.mShowed;
|
final boolean showed = keyState.mShowed;
|
||||||
|
|||||||
@@ -1,15 +1,10 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
xmlns:tools="http://schemas.android.com/tools">
|
|
||||||
|
|
||||||
<data>
|
<data>
|
||||||
|
<import type="android.view.View" alias="V" />
|
||||||
<import type="android.view.View" />
|
<import type="org.sufficientlysecure.keychain.ui.ImportKeysListFragment" alias="i" />
|
||||||
|
|
||||||
<import
|
|
||||||
alias="i"
|
|
||||||
type="org.sufficientlysecure.keychain.ui.ImportKeysListFragment" />
|
|
||||||
|
|
||||||
<variable name="status" type="int" />
|
<variable name="status" type="int" />
|
||||||
<variable name="advanced" type="boolean" />
|
<variable name="advanced" type="boolean" />
|
||||||
@@ -24,59 +19,42 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_centerInParent="true"
|
android:layout_centerInParent="true"
|
||||||
android:visibility="@{status == i.STATUS_LOADING ? View.VISIBLE : View.GONE}" />
|
android:visibility="@{status == i.STATUS_LOADING ? V.VISIBLE : V.GONE}" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_centerInParent="true"
|
android:layout_centerInParent="true"
|
||||||
android:text="@string/error_nothing_import"
|
android:text="@string/error_nothing_import"
|
||||||
android:visibility="@{status == i.STATUS_EMPTY ? View.VISIBLE : View.GONE}" />
|
android:visibility="@{status == i.STATUS_EMPTY ? V.VISIBLE : V.GONE}" />
|
||||||
|
|
||||||
<android.support.v7.widget.RecyclerView
|
<LinearLayout
|
||||||
android:id="@+id/recycler_view"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_above="@+id/toolbar_bottom"
|
android:orientation="vertical"
|
||||||
android:paddingLeft="8dp"
|
android:paddingLeft="8dp"
|
||||||
android:paddingRight="8dp"
|
android:paddingRight="8dp"
|
||||||
android:scrollbars="vertical"
|
android:visibility="@{status == i.STATUS_LOADED ? V.VISIBLE : V.GONE}">
|
||||||
android:visibility="@{status == i.STATUS_LOADED ? View.VISIBLE : View.GONE}" />
|
|
||||||
|
|
||||||
<android.support.v7.widget.Toolbar
|
<LinearLayout
|
||||||
android:id="@+id/toolbar_bottom"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_alignParentBottom="true"
|
|
||||||
android:background="?attr/colorPrimary"
|
|
||||||
android:elevation="4dp"
|
|
||||||
android:minHeight="?attr/actionBarSize"
|
|
||||||
android:paddingLeft="8dp"
|
|
||||||
android:paddingRight="8dp"
|
|
||||||
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
|
|
||||||
android:visibility="@{!advanced && (status == i.STATUS_LOADED) ? View.VISIBLE : View.GONE}"
|
|
||||||
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
|
|
||||||
tools:ignore="UnusedAttribute">
|
|
||||||
|
|
||||||
<RelativeLayout
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="match_parent"
|
||||||
|
android:visibility="@{advanced ? V.GONE : V.VISIBLE}">
|
||||||
|
|
||||||
<TextView
|
<include
|
||||||
android:id="@+id/import_keys"
|
android:id="@+id/basic"
|
||||||
style="@style/TextAppearance.Widget.AppCompat.Toolbar.Subtitle"
|
layout="@layout/import_keys_list_item_basic" />
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:drawablePadding="8dp"
|
|
||||||
android:drawableRight="@drawable/ic_file_download_white_24dp"
|
|
||||||
android:gravity="center_vertical"
|
|
||||||
android:text="@string/btn_import_all"
|
|
||||||
android:textAllCaps="true"
|
|
||||||
android:textColor="?android:attr/textColorPrimary" />
|
|
||||||
|
|
||||||
</RelativeLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</android.support.v7.widget.Toolbar>
|
<android.support.v7.widget.RecyclerView
|
||||||
|
android:id="@+id/recycler_view"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:scrollbars="vertical"
|
||||||
|
android:visibility="@{advanced ? V.VISIBLE : V.GONE}" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
<import type="android.view.View" alias="V" />
|
<import type="android.view.View" alias="V" />
|
||||||
<import type="org.sufficientlysecure.keychain.keyimport.ImportKeysListEntry" />
|
<import type="org.sufficientlysecure.keychain.keyimport.ImportKeysListEntry" />
|
||||||
|
|
||||||
<variable name="advanced" type="boolean" />
|
|
||||||
<variable name="nonInteractive" type="boolean" />
|
<variable name="nonInteractive" type="boolean" />
|
||||||
<variable name="entry" type="ImportKeysListEntry" />
|
<variable name="entry" type="ImportKeysListEntry" />
|
||||||
</data>
|
</data>
|
||||||
@@ -77,18 +76,11 @@
|
|||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<!-- This empty layout is needed to get correct bottom padding in basic mode -->
|
|
||||||
<FrameLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:paddingBottom="8dp"
|
|
||||||
android:visibility="@{(!advanced || nonInteractive) ? V.VISIBLE : V.GONE}" />
|
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:padding="8dp"
|
android:padding="8dp"
|
||||||
android:visibility="@{(!advanced || nonInteractive) ? V.GONE : V.VISIBLE}">
|
android:visibility="@{nonInteractive ? V.GONE : V.VISIBLE}">
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/import_key"
|
android:id="@+id/import_key"
|
||||||
@@ -105,8 +97,7 @@
|
|||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content">
|
||||||
android:visibility="@{advanced ? V.VISIBLE : V.GONE}">
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/extra_container"
|
android:id="@+id/extra_container"
|
||||||
|
|||||||
@@ -0,0 +1,62 @@
|
|||||||
|
<layout xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<data>
|
||||||
|
<import type="android.view.View" alias="V" />
|
||||||
|
|
||||||
|
<variable name="nonInteractive" type="boolean" />
|
||||||
|
<variable name="number" type="int" />
|
||||||
|
</data>
|
||||||
|
|
||||||
|
<android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="4dp"
|
||||||
|
android:layout_marginTop="4dp"
|
||||||
|
card_view:cardCornerRadius="2dp">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:paddingTop="24dp">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:paddingBottom="16dp"
|
||||||
|
android:paddingLeft="16dp"
|
||||||
|
android:paddingRight="16dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@{@string/import_found_keys(number)}"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:padding="8dp"
|
||||||
|
android:visibility="@{nonInteractive ? V.GONE : V.VISIBLE}">
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/import_keys"
|
||||||
|
style="@style/CardViewActionButton"
|
||||||
|
android:text="@string/btn_import_keys" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/list_keys"
|
||||||
|
style="@style/CardViewActionButton"
|
||||||
|
android:text="@string/btn_list_keys" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</android.support.v7.widget.CardView>
|
||||||
|
|
||||||
|
</layout>
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
|
||||||
|
|
||||||
<item
|
|
||||||
android:id="@+id/basic"
|
|
||||||
android:title="@string/menu_basic" />
|
|
||||||
|
|
||||||
<item
|
|
||||||
android:id="@+id/advanced"
|
|
||||||
android:title="@string/menu_advanced" />
|
|
||||||
|
|
||||||
</menu>
|
|
||||||
@@ -128,8 +128,6 @@
|
|||||||
<string name="menu_select_all">"Select all"</string>
|
<string name="menu_select_all">"Select all"</string>
|
||||||
<string name="menu_export_all_keys">"Export all keys"</string>
|
<string name="menu_export_all_keys">"Export all keys"</string>
|
||||||
<string name="menu_update_all_keys">"Update all keys"</string>
|
<string name="menu_update_all_keys">"Update all keys"</string>
|
||||||
<string name="menu_basic">"Basic"</string>
|
|
||||||
<string name="menu_advanced">"Advanced"</string>
|
|
||||||
<string name="menu_certify_fingerprint">"Confirm with fingerprint"</string>
|
<string name="menu_certify_fingerprint">"Confirm with fingerprint"</string>
|
||||||
<string name="menu_certify_fingerprint_phrases">"Confirm with phrases"</string>
|
<string name="menu_certify_fingerprint_phrases">"Confirm with phrases"</string>
|
||||||
<string name="menu_share_log">"Share log"</string>
|
<string name="menu_share_log">"Share log"</string>
|
||||||
@@ -526,7 +524,7 @@
|
|||||||
<string name="import_tab_cloud">"Key Search"</string>
|
<string name="import_tab_cloud">"Key Search"</string>
|
||||||
<string name="import_tab_direct">"File/Clipboard"</string>
|
<string name="import_tab_direct">"File/Clipboard"</string>
|
||||||
<string name="import_tab_qr_code">"QR Code/NFC"</string>
|
<string name="import_tab_qr_code">"QR Code/NFC"</string>
|
||||||
<string name="import_import">"Import selected keys"</string>
|
<string name="import_found_keys">"Found %1$d keys"</string>
|
||||||
<string name="import_qr_code_wrong">"QR Code malformed! Please try again!"</string>
|
<string name="import_qr_code_wrong">"QR Code malformed! Please try again!"</string>
|
||||||
<string name="import_qr_code_fp">"Fingerprint is malformed or too short!"</string>
|
<string name="import_qr_code_fp">"Fingerprint is malformed or too short!"</string>
|
||||||
<string name="import_qr_code_too_short_fingerprint">"Fingerprint is too short!"</string>
|
<string name="import_qr_code_too_short_fingerprint">"Fingerprint is too short!"</string>
|
||||||
@@ -1574,7 +1572,8 @@
|
|||||||
<string name="security_token_create">"Hold Security Token against the back of your device."</string>
|
<string name="security_token_create">"Hold Security Token against the back of your device."</string>
|
||||||
<string name="security_token_reset_or_import">"This Security Token already contains a key. You can import the key using the cloud or reset the Security Token."</string>
|
<string name="security_token_reset_or_import">"This Security Token already contains a key. You can import the key using the cloud or reset the Security Token."</string>
|
||||||
<string name="btn_import">"Import"</string>
|
<string name="btn_import">"Import"</string>
|
||||||
<string name="btn_import_all">"Import all"</string>
|
<string name="btn_import_keys">"Import keys"</string>
|
||||||
|
<string name="btn_list_keys">"List keys"</string>
|
||||||
<string name="btn_reset">"Reset"</string>
|
<string name="btn_reset">"Reset"</string>
|
||||||
<string name="security_token_import_radio">"Import key"</string>
|
<string name="security_token_import_radio">"Import key"</string>
|
||||||
<string name="security_token_reset_radio">"Reset Security Token"</string>
|
<string name="security_token_reset_radio">"Reset Security Token"</string>
|
||||||
|
|||||||
Reference in New Issue
Block a user