From 13bd451140da1452603b2362e67b10dcd87d5f2d Mon Sep 17 00:00:00 2001 From: Bryn Knatterud Date: Mon, 4 May 2015 11:34:19 -0500 Subject: [PATCH] show verification check details in info icon --- .../CollapsibleVersionAdapter.java | 13 +++++++------ .../java/model/datasource/VersionDataSource.java | 4 ++++ .../model/modelClasses/mainData/VersionModel.java | 5 +++++ .../src/main/res/layout/row_version_selector.xml | 6 ++++-- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/app/app/src/main/java/adapters/selectionAdapters/CollapsibleVersionAdapter.java b/app/app/src/main/java/adapters/selectionAdapters/CollapsibleVersionAdapter.java index 4f0aac5..25da588 100644 --- a/app/app/src/main/java/adapters/selectionAdapters/CollapsibleVersionAdapter.java +++ b/app/app/src/main/java/adapters/selectionAdapters/CollapsibleVersionAdapter.java @@ -218,15 +218,15 @@ private String getVerificationText(VersionModel version){ break; } case 1:{ - text = getContext().getResources().getString(R.string.expired_title_start); + text = getContext().getResources().getString(R.string.expired_title_start) + "\n" + version.verificationText; break; } case 3:{ - text = getContext().getResources().getString(R.string.failed_title_start); + text = getContext().getResources().getString(R.string.failed_title_start) + "\n" + version.verificationText; break; } default:{ - text = getContext().getResources().getString(R.string.error_title_start); + text = getContext().getResources().getString(R.string.error_title_start) + "\n" + version.verificationText; } } @@ -338,6 +338,7 @@ private void downloadRow(final VersionModel version, final ViewHolderForGroup fi Intent downloadIntent = new Intent(getContext(), VersionDownloadService.class); downloadIntent.putExtra(VersionDownloadService.VERSION_ID, Long.toString(version.uid)); getContext().startService(downloadIntent); + reload(); } } @@ -388,9 +389,9 @@ public Dialog onCreateDialog(Bundle savedInstanceState) { .setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { - int state = new VersionDataSource(getContext()).getModel(Long.toString(version.uid)).verificationStatus; - if(state == VersionModel.DOWNLOAD_STATE.DOWNLOAD_STATE_DOWNLOADING.ordinal() || - state == VersionModel.DOWNLOAD_STATE.DOWNLOAD_STATE_ERROR.ordinal()) { + VersionModel.DOWNLOAD_STATE state = new VersionDataSource(getContext()).getModel(Long.toString(version.uid)).downloadState; + if(state == VersionModel.DOWNLOAD_STATE.DOWNLOAD_STATE_DOWNLOADING || + state == VersionModel.DOWNLOAD_STATE.DOWNLOAD_STATE_ERROR) { stopDownloadService(version); new DeleteVersionTask().execute(version); } diff --git a/app/app/src/main/java/model/datasource/VersionDataSource.java b/app/app/src/main/java/model/datasource/VersionDataSource.java index 6e9c8bb..df41090 100644 --- a/app/app/src/main/java/model/datasource/VersionDataSource.java +++ b/app/app/src/main/java/model/datasource/VersionDataSource.java @@ -37,6 +37,7 @@ public class VersionDataSource extends AMDatabaseDataSourceAbstract { static final String TABLE_VERSION_COLUMN_SOURCE_TEXT_VERSION = "_column_source_text_version"; static final String TABLE_VERSION_COLUMN_VERSION = "_column_version"; + static final String TABLE_VERSION_COLUMN_VERIFICATION_TEXT = "_column_verification_text"; static final String TABLE_VERSION_COLUMN_VERIFICATION_STATUS = "_column_verification_status"; public VersionDataSource(Context context) { @@ -157,6 +158,7 @@ public ContentValues getModelAsContentValues(AMDatabaseModelAbstractObject model values.put(TABLE_VERSION_COLUMN_SOURCE_TEXT_VERSION, versionModel.status.sourceTextVersion); values.put(TABLE_VERSION_COLUMN_VERSION, versionModel.status.version); values.put(TABLE_VERSION_COLUMN_VERIFICATION_STATUS, versionModel.verificationStatus); + values.put(TABLE_VERSION_COLUMN_VERIFICATION_TEXT, versionModel.verificationText); return values; } @@ -184,6 +186,7 @@ public AMDatabaseModelAbstractObject getObjectFromCursor(Cursor cursor) { model.status.version = cursor.getString(cursor.getColumnIndex(TABLE_VERSION_COLUMN_VERSION)); model.verificationStatus = cursor.getInt(cursor.getColumnIndex(TABLE_VERSION_COLUMN_VERIFICATION_STATUS)); + model.verificationText = cursor.getString(cursor.getColumnIndex(TABLE_VERSION_COLUMN_VERIFICATION_TEXT)); return model; } @@ -207,6 +210,7 @@ public String getTableCreationString() { VersionDataSource.TABLE_VERSION_COLUMN_PUBLISH_DATE + " VARCHAR," + VersionDataSource.TABLE_VERSION_COLUMN_SOURCE_TEXT + " VARCHAR," + VersionDataSource.TABLE_VERSION_COLUMN_SOURCE_TEXT_VERSION + " VARCHAR," + + VersionDataSource.TABLE_VERSION_COLUMN_VERIFICATION_TEXT + " VARCHAR," + VersionDataSource.TABLE_VERSION_COLUMN_VERSION + " VARCHAR)"; return creationString; diff --git a/app/app/src/main/java/model/modelClasses/mainData/VersionModel.java b/app/app/src/main/java/model/modelClasses/mainData/VersionModel.java index 9e816b9..f21a20c 100644 --- a/app/app/src/main/java/model/modelClasses/mainData/VersionModel.java +++ b/app/app/src/main/java/model/modelClasses/mainData/VersionModel.java @@ -81,6 +81,7 @@ private class StatusJsonModel { public StatusModel status; public DOWNLOAD_STATE downloadState; + public String verificationText; public int verificationStatus; private ArrayList signingOrganizations = null; @@ -200,6 +201,7 @@ public void initModelFromJson(JSONObject json, long parentId, boolean sideLoaded this.parentId = parentId; downloadState = DOWNLOAD_STATE.DOWNLOAD_STATE_NONE; + this.verificationText = ""; } @Override @@ -237,17 +239,20 @@ public int getVerificationStatus(Context context){ case 1:{ if(verifyStatus < 1){ verifyStatus = 1; + this.verificationText += book.getTitle() + " Has Expired \n"; } break; } case 3:{ if(verifyStatus < 3){ verifyStatus = 3; + this.verificationText += book.getTitle() + " Failed \n"; } break; } default:{ verifyStatus = 2; + this.verificationText += book.getTitle() + " Encountered an Error \n"; break; } } diff --git a/app/app/src/main/res/layout/row_version_selector.xml b/app/app/src/main/res/layout/row_version_selector.xml index a438eab..453e3ae 100644 --- a/app/app/src/main/res/layout/row_version_selector.xml +++ b/app/app/src/main/res/layout/row_version_selector.xml @@ -309,13 +309,15 @@