diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index befab07..6855ed5 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -36,6 +36,12 @@ + + + + () { + @Override + public void onSuccess(RichConsent response) { + consentDetails = response; + updateUI(); + } + + @Override + public void onFailure(Throwable exception) { + Log.e(TAG, "Error obtaining consent details", exception); + } + }); + } catch (NoSuchAlgorithmException | InvalidKeySpecException e) { + Log.e(TAG, "Error requesting consent details", e); + } + + } + + private void setupUI() { + bindingMessageText = (TextView) findViewById(R.id.bindingMessage); + scopeText = (TextView) findViewById(R.id.scope); + dateText = (TextView) findViewById(R.id.dateText); + + Button rejectButton = (Button) findViewById(R.id.rejectButton); + assert rejectButton != null; + rejectButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + rejectRequested(); + } + }); + + Button allowButton = (Button) findViewById(R.id.allowButton); + assert allowButton != null; + allowButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + allowRequested(); + } + }); + } + + private void updateUI() { + if (consentDetails != null) { + bindingMessageText.setText(consentDetails.requested_details.binding_message); + scopeText.setText(String.join(", ", consentDetails.requested_details.scope)); + } else { + bindingMessageText.setText("N/A"); + scopeText.setText("N/A"); + } + dateText.setText(notification.getDate().toString()); + } + + private void rejectRequested() { + guardian + .reject(notification, enrollment) + .start(new DialogCallback<>(this, + R.string.progress_title_please_wait, + R.string.progress_message_reject, + new Callback() { + @Override + public void onSuccess(Void response) { + finish(); + } + + @Override + public void onFailure(Throwable exception) { + + } + })); + } + + private void allowRequested() { + guardian + .allow(notification, enrollment) + .start(new DialogCallback<>(this, + R.string.progress_title_please_wait, + R.string.progress_message_allow, + new Callback() { + @Override + public void onSuccess(Void response) { + finish(); + } + + @Override + public void onFailure(Throwable exception) { + + } + })); + } +} diff --git a/app/src/main/res/layout/activity_notification_with_consent_details.xml b/app/src/main/res/layout/activity_notification_with_consent_details.xml new file mode 100644 index 0000000..98602db --- /dev/null +++ b/app/src/main/res/layout/activity_notification_with_consent_details.xml @@ -0,0 +1,121 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +