Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/stefan-niedermann/nextcloud-deck.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Niedermann <info@niedermann.it>2020-04-13 15:47:13 +0300
committerStefan Niedermann <info@niedermann.it>2020-04-13 15:47:13 +0300
commit60a45d6e3e65e63a7dd58dd118b15bfac5fa5d40 (patch)
treeae74783068e3b5fa2f60de22da1d037977eb20da /app/src/main/java/it/niedermann/nextcloud/deck/ui/PushNotificationActivity.java
parent6f9dd4408e45a1dffdcdadf287bc216b1406586d (diff)
#208 Handle push notifications
Display incoming push notifications Signed-off-by: Stefan Niedermann <info@niedermann.it>
Diffstat (limited to 'app/src/main/java/it/niedermann/nextcloud/deck/ui/PushNotificationActivity.java')
-rw-r--r--app/src/main/java/it/niedermann/nextcloud/deck/ui/PushNotificationActivity.java51
1 files changed, 27 insertions, 24 deletions
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/PushNotificationActivity.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/PushNotificationActivity.java
index 6b6b20c8a..62674076d 100644
--- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/PushNotificationActivity.java
+++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/PushNotificationActivity.java
@@ -7,13 +7,15 @@ import android.view.View;
import androidx.appcompat.app.AppCompatActivity;
-import it.niedermann.nextcloud.deck.DeckLog;
import it.niedermann.nextcloud.deck.databinding.ActivityPushNotificationBinding;
import it.niedermann.nextcloud.deck.ui.exception.ExceptionHandler;
public class PushNotificationActivity extends AppCompatActivity {
- private ActivityPushNotificationBinding binding;
+ // Provided by Files app NotificationJob
+ private static final String KEY_SUBJECT = "subject";
+ private static final String KEY_MESSAGE = "message";
+ private static final String KEY_LINK = "link";
@Override
protected void onResume() {
@@ -21,31 +23,32 @@ public class PushNotificationActivity extends AppCompatActivity {
super.onResume();
Thread.currentThread().setUncaughtExceptionHandler(new ExceptionHandler(this));
- binding = ActivityPushNotificationBinding.inflate(getLayoutInflater());
+ if (getIntent() == null) {
+ throw new IllegalArgumentException("Could not retrieve intent");
+ }
+
+ final ActivityPushNotificationBinding binding = ActivityPushNotificationBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
- if (getIntent() != null) {
- binding.subject.setText(getIntent().getStringExtra("subject"));
-
- final String message = getIntent().getStringExtra("message");
- if (!TextUtils.isEmpty(message)) {
- binding.message.setText(message);
- binding.message.setVisibility(View.VISIBLE);
- }
- final String link = getIntent().getStringExtra("link");
- DeckLog.info("push: " + link);
-
- if (link != null) {
- binding.submit.setOnClickListener((v) -> {
- Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(link));
- startActivity(browserIntent);
- });
- } else {
- binding.submit.setEnabled(false);
- }
- binding.cancel.setOnClickListener((v) -> finish());
+
+ binding.subject.setText(getIntent().getStringExtra(KEY_SUBJECT));
+
+ final String message = getIntent().getStringExtra(KEY_MESSAGE);
+ if (!TextUtils.isEmpty(message)) {
+ binding.message.setText(message);
+ binding.message.setVisibility(View.VISIBLE);
+ }
+
+ final String link = getIntent().getStringExtra(KEY_LINK);
+ if (link != null) {
+ binding.submit.setOnClickListener((v) -> {
+ Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(link));
+ startActivity(browserIntent);
+ });
+ } else {
+ binding.submit.setEnabled(false);
}
- // TODO simply open the given URL until proper handling has been implemented
+ binding.cancel.setOnClickListener((v) -> finish());
}
}