Skip to content

Commit

Permalink
show verification check details in info icon
Browse files Browse the repository at this point in the history
  • Loading branch information
bknatterud committed May 4, 2015
1 parent 38c0c7a commit 13bd451
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down Expand Up @@ -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();
}
}

Expand Down Expand Up @@ -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);
}
Expand Down
4 changes: 4 additions & 0 deletions app/app/src/main/java/model/datasource/VersionDataSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ private class StatusJsonModel {
public StatusModel status;
public DOWNLOAD_STATE downloadState;

public String verificationText;
public int verificationStatus;

private ArrayList<String> signingOrganizations = null;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
}
Expand Down
6 changes: 4 additions & 2 deletions app/app/src/main/res/layout/row_version_selector.xml
Original file line number Diff line number Diff line change
Expand Up @@ -309,13 +309,15 @@
</LinearLayout>

<Button
android:paddingTop="10dp"
android:layout_marginTop="20dp"
android:layout_marginBottom="5dp"
android:id="@+id/delete_button"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_height="40dp"
android:background="#e11"
android:text="@string/delete_version"
android:gravity="center"
android:layout_gravity="center"
/>
</LinearLayout>
</FrameLayout>
Expand Down

0 comments on commit 13bd451

Please sign in to comment.