db-overhaul: fix loading indicators in KeyListActivity and ViewKeyActivity

This commit is contained in:
Vincent Breitmoser 2014-04-04 05:01:35 +02:00
parent d921cca913
commit 2227705d65
7 changed files with 25 additions and 10 deletions

View File

@ -260,7 +260,6 @@ public class PgpImportExport {
}
if (save) {
ProviderHelper.saveKeyRing(mContext, secretKeyRing);
// TODO: preserve certifications
// (http://osdir.com/ml/encryption.bouncy-castle.devel/2007-01/msg00054.html ?)
PGPPublicKeyRing newPubRing = null;
@ -275,6 +274,7 @@ public class PgpImportExport {
if (newPubRing != null) {
ProviderHelper.saveKeyRing(mContext, newPubRing);
}
ProviderHelper.saveKeyRing(mContext, secretKeyRing);
// TODO: remove status returns, use exceptions!
status = Id.return_value.ok;
}

View File

@ -124,7 +124,6 @@ public class KeychainDatabase extends SQLiteOpenHelper {
KeychainDatabase(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
// make sure this is only done once, on the first instance!
boolean iAmIt = false;
synchronized(apg_hack) {

View File

@ -168,10 +168,15 @@ public class KeychainProvider extends ContentProvider {
@Override
public boolean onCreate() {
mUriMatcher = buildUriMatcher();
mKeychainDatabase = new KeychainDatabase(getContext());
return true;
}
public KeychainDatabase getDb() {
if(mKeychainDatabase == null)
mKeychainDatabase = new KeychainDatabase(getContext());
return mKeychainDatabase;
}
/**
* {@inheritDoc}
*/
@ -441,7 +446,7 @@ public class KeychainProvider extends ContentProvider {
orderBy = sortOrder;
}
SQLiteDatabase db = mKeychainDatabase.getReadableDatabase();
SQLiteDatabase db = getDb().getReadableDatabase();
Cursor c = qb.query(db, projection, selection, selectionArgs, groupBy, having, orderBy);
// Tell the cursor what uri to watch, so it knows when its source data changes
@ -465,7 +470,7 @@ public class KeychainProvider extends ContentProvider {
public Uri insert(Uri uri, ContentValues values) {
Log.d(Constants.TAG, "insert(uri=" + uri + ", values=" + values.toString() + ")");
final SQLiteDatabase db = mKeychainDatabase.getWritableDatabase();
final SQLiteDatabase db = getDb().getWritableDatabase();
Uri rowUri = null;
Long keyId = null;
@ -538,7 +543,7 @@ public class KeychainProvider extends ContentProvider {
public int delete(Uri uri, String additionalSelection, String[] selectionArgs) {
Log.v(Constants.TAG, "delete(uri=" + uri + ")");
final SQLiteDatabase db = mKeychainDatabase.getWritableDatabase();
final SQLiteDatabase db = getDb().getWritableDatabase();
int count;
final int match = mUriMatcher.match(uri);

View File

@ -154,9 +154,6 @@ public class KeyListFragment extends Fragment
} catch (ApiLevelTooLowException e) {
}
// this view is made visible if no data is available
mStickyList.setEmptyView(getActivity().findViewById(R.id.key_list_empty));
/*
* ActionBarSherlock does not support MultiChoiceModeListener. Thus multi-selection is only
* available for Android >= 3.0
@ -291,6 +288,9 @@ public class KeyListFragment extends Fragment
mStickyList.setAdapter(mAdapter);
// this view is made visible if no data is available
mStickyList.setEmptyView(getActivity().findViewById(R.id.key_list_empty));
// NOTE: Not supported by StickyListHeader, but reimplemented here
// The list should now be shown.
if (isResumed()) {

View File

@ -28,6 +28,7 @@ import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.Window;
import android.widget.Toast;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.Id;
@ -59,6 +60,7 @@ public class ViewKeyActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
super.onCreate(savedInstanceState);
mExportHelper = new ExportHelper(this);

View File

@ -30,6 +30,7 @@ import android.text.format.DateFormat;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;
@ -55,6 +56,7 @@ public class ViewKeyMainFragment extends Fragment implements
public static final String ARG_DATA_URI = "uri";
private LinearLayout mContainer;
private TextView mName;
private TextView mEmail;
private TextView mComment;
@ -83,6 +85,7 @@ public class ViewKeyMainFragment extends Fragment implements
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.view_key_main_fragment, container, false);
mContainer = (LinearLayout) view.findViewById(R.id.container);
mName = (TextView) view.findViewById(R.id.name);
mEmail = (TextView) view.findViewById(R.id.email);
mComment = (TextView) view.findViewById(R.id.comment);
@ -121,6 +124,9 @@ public class ViewKeyMainFragment extends Fragment implements
return;
}
getActivity().setProgressBarIndeterminateVisibility(Boolean.TRUE);
mContainer.setVisibility(View.GONE);
mDataUri = dataUri;
Log.i(Constants.TAG, "mDataUri: " + mDataUri.toString());
@ -319,6 +325,8 @@ public class ViewKeyMainFragment extends Fragment implements
default:
break;
}
getActivity().setProgressBarIndeterminateVisibility(Boolean.FALSE);
mContainer.setVisibility(View.VISIBLE);
}
/**

View File

@ -12,7 +12,8 @@
android:descendantFocusability="beforeDescendants"
android:orientation="vertical"
android:paddingLeft="16dp"
android:paddingRight="16dp">
android:paddingRight="16dp"
android:id="@+id/container">
<TextView
style="@style/SectionHeader"