ImportKeys: Add empty list message
This commit is contained in:
@@ -287,6 +287,10 @@ android {
|
|||||||
exclude 'META-INF/NOTICE'
|
exclude 'META-INF/NOTICE'
|
||||||
exclude '.readme'
|
exclude '.readme'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dataBinding {
|
||||||
|
enabled = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
task jacocoTestReport(type:JacocoReport, dependsOn: "testFdroidDebugWithTestCoverageUnitTest") {
|
task jacocoTestReport(type:JacocoReport, dependsOn: "testFdroidDebugWithTestCoverageUnitTest") {
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import android.Manifest;
|
|||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
|
import android.databinding.DataBindingUtil;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@@ -38,11 +39,11 @@ import android.support.v7.widget.RecyclerView;
|
|||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ProgressBar;
|
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
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.keyimport.ImportKeysListEntry;
|
import org.sufficientlysecure.keychain.keyimport.ImportKeysListEntry;
|
||||||
import org.sufficientlysecure.keychain.keyimport.ParcelableKeyRing;
|
import org.sufficientlysecure.keychain.keyimport.ParcelableKeyRing;
|
||||||
import org.sufficientlysecure.keychain.operations.results.GetKeyResult;
|
import org.sufficientlysecure.keychain.operations.results.GetKeyResult;
|
||||||
@@ -73,14 +74,19 @@ public class ImportKeysListFragment extends Fragment implements
|
|||||||
private static final int REQUEST_PERMISSION_READ_EXTERNAL_STORAGE = 12;
|
private static final int REQUEST_PERMISSION_READ_EXTERNAL_STORAGE = 12;
|
||||||
|
|
||||||
private FragmentActivity mActivity;
|
private FragmentActivity mActivity;
|
||||||
|
private ImportKeysListFragmentBinding binding;
|
||||||
private ParcelableProxy mParcelableProxy;
|
private ParcelableProxy mParcelableProxy;
|
||||||
|
|
||||||
private ProgressBar mProgressBar;
|
|
||||||
private RecyclerView mRecyclerView;
|
private RecyclerView mRecyclerView;
|
||||||
private ImportKeysAdapter mAdapter;
|
private ImportKeysAdapter mAdapter;
|
||||||
|
|
||||||
private LoaderState mLoaderState;
|
private LoaderState mLoaderState;
|
||||||
|
|
||||||
|
public static final int STATUS_FIRST = 0;
|
||||||
|
public static final int STATUS_LOADING = 1;
|
||||||
|
public static final int STATUS_LOADED = 2;
|
||||||
|
public static final int STATUS_EMPTY = 3;
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
@@ -88,6 +94,7 @@ public class ImportKeysListFragment extends Fragment implements
|
|||||||
|
|
||||||
private boolean mShowingOrbotDialog;
|
private boolean mShowingOrbotDialog;
|
||||||
|
|
||||||
|
|
||||||
public LoaderState getLoaderState() {
|
public LoaderState getLoaderState() {
|
||||||
return mLoaderState;
|
return mLoaderState;
|
||||||
}
|
}
|
||||||
@@ -137,7 +144,6 @@ public class ImportKeysListFragment extends Fragment implements
|
|||||||
Log.e(Constants.TAG, "Adapter not initialized, returning empty list");
|
Log.e(Constants.TAG, "Adapter not initialized, returning empty list");
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -209,11 +215,14 @@ public class ImportKeysListFragment extends Fragment implements
|
|||||||
mServerQuery = serverQuery;
|
mServerQuery = serverQuery;
|
||||||
mCloudPrefs = cloudPrefs;
|
mCloudPrefs = cloudPrefs;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.import_keys_list_fragment, container, false);
|
binding = DataBindingUtil.inflate(inflater, R.layout.import_keys_list_fragment, container, false);
|
||||||
|
binding.setStatus(STATUS_FIRST);
|
||||||
|
View view = binding.getRoot();
|
||||||
|
|
||||||
mActivity = getActivity();
|
mActivity = getActivity();
|
||||||
|
|
||||||
@@ -223,7 +232,6 @@ public class ImportKeysListFragment extends Fragment implements
|
|||||||
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);
|
||||||
|
|
||||||
mProgressBar = (ProgressBar) view.findViewById(R.id.progress_view);
|
|
||||||
mRecyclerView = (RecyclerView) view.findViewById(R.id.recycler_view);
|
mRecyclerView = (RecyclerView) view.findViewById(R.id.recycler_view);
|
||||||
RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(mActivity);
|
RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(mActivity);
|
||||||
mRecyclerView.setLayoutManager(layoutManager);
|
mRecyclerView.setLayoutManager(layoutManager);
|
||||||
@@ -339,11 +347,6 @@ public class ImportKeysListFragment extends Fragment implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setLoadingStatus(boolean ready) {
|
|
||||||
mRecyclerView.setVisibility(ready ? View.VISIBLE : View.GONE);
|
|
||||||
mProgressBar.setVisibility(ready ? View.GONE : View.VISIBLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Loader<AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>> onCreateLoader(
|
public Loader<AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>> onCreateLoader(
|
||||||
int id,
|
int id,
|
||||||
@@ -364,7 +367,7 @@ public class ImportKeysListFragment extends Fragment implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (loader != null) {
|
if (loader != null) {
|
||||||
setLoadingStatus(false);
|
binding.setStatus(STATUS_LOADING);
|
||||||
}
|
}
|
||||||
|
|
||||||
return loader;
|
return loader;
|
||||||
@@ -375,9 +378,9 @@ public class ImportKeysListFragment extends Fragment implements
|
|||||||
Loader<AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>> loader,
|
Loader<AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>> loader,
|
||||||
AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>> data
|
AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>> data
|
||||||
) {
|
) {
|
||||||
setLoadingStatus(true);
|
ArrayList<ImportKeysListEntry> result = data.getResult();
|
||||||
|
binding.setStatus(result.size() > 0 ? STATUS_LOADED : STATUS_EMPTY);
|
||||||
mAdapter.setData(data.getResult());
|
mAdapter.setData(result);
|
||||||
|
|
||||||
// free old cached key data
|
// free old cached key data
|
||||||
mCachedKeyData = null;
|
mCachedKeyData = null;
|
||||||
|
|||||||
@@ -65,6 +65,7 @@
|
|||||||
android:drawablePadding="8dp"
|
android:drawablePadding="8dp"
|
||||||
android:drawableRight="@drawable/ic_file_download_white_24dp"
|
android:drawableRight="@drawable/ic_file_download_white_24dp"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
|
android:maxLines="1"
|
||||||
android:text="@string/import_import"
|
android:text="@string/import_import"
|
||||||
android:textColor="#ffffffff" />
|
android:textColor="#ffffffff" />
|
||||||
|
|
||||||
|
|||||||
@@ -1,22 +1,44 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<layout xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:background="@color/md_grey_100">
|
|
||||||
|
|
||||||
<ProgressBar
|
<data>
|
||||||
android:id="@+id/progress_view"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:visibility="gone" />
|
|
||||||
|
|
||||||
<android.support.v7.widget.RecyclerView
|
<import type="android.view.View" />
|
||||||
android:id="@+id/recycler_view"
|
|
||||||
|
<import
|
||||||
|
alias="i"
|
||||||
|
type="org.sufficientlysecure.keychain.ui.ImportKeysListFragment" />
|
||||||
|
|
||||||
|
<variable
|
||||||
|
name="status"
|
||||||
|
type="int" />
|
||||||
|
</data>
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:paddingLeft="8dp"
|
android:background="@color/md_grey_100">
|
||||||
android:paddingRight="8dp"
|
|
||||||
android:scrollbars="vertical"
|
<ProgressBar
|
||||||
android:visibility="gone" />
|
android:layout_width="wrap_content"
|
||||||
</FrameLayout>
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:visibility="@{status == i.STATUS_LOADING ? View.VISIBLE : View.GONE}" />
|
||||||
|
|
||||||
|
<android.support.v7.widget.RecyclerView
|
||||||
|
android:id="@+id/recycler_view"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:paddingLeft="8dp"
|
||||||
|
android:paddingRight="8dp"
|
||||||
|
android:scrollbars="vertical"
|
||||||
|
android:visibility="@{status == i.STATUS_LOADED ? View.VISIBLE : View.GONE}" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:text="@string/error_nothing_import"
|
||||||
|
android:visibility="@{status == i.STATUS_EMPTY ? View.VISIBLE : View.GONE}" />
|
||||||
|
</FrameLayout>
|
||||||
|
</layout>
|
||||||
|
|||||||
Reference in New Issue
Block a user