mirror of
https://github.com/oxen-io/session-android.git
synced 2025-10-23 17:48:50 +00:00
Show a banner in the event of a service outage.
We will now determine if there has been a service outage and render a banner at the top of the conversation list if we detect that there has been one.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package org.thoughtcrime.securesms.components.reminder;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.view.View.OnClickListener;
|
||||
|
||||
public abstract class Reminder {
|
||||
@@ -10,14 +11,14 @@ public abstract class Reminder {
|
||||
private OnClickListener okListener;
|
||||
private OnClickListener dismissListener;
|
||||
|
||||
public Reminder(@NonNull CharSequence title,
|
||||
@NonNull CharSequence text)
|
||||
public Reminder(@Nullable CharSequence title,
|
||||
@NonNull CharSequence text)
|
||||
{
|
||||
this.title = title;
|
||||
this.text = text;
|
||||
this.title = title;
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public CharSequence getTitle() {
|
||||
public @Nullable CharSequence getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
@@ -44,4 +45,13 @@ public abstract class Reminder {
|
||||
public boolean isDismissable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public @NonNull Importance getImportance() {
|
||||
return Importance.NORMAL;
|
||||
}
|
||||
|
||||
|
||||
public enum Importance {
|
||||
NORMAL, ERROR
|
||||
}
|
||||
}
|
||||
|
@@ -3,6 +3,7 @@ package org.thoughtcrime.securesms.components.reminder;
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.os.Build.VERSION_CODES;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@@ -49,8 +50,16 @@ public class ReminderView extends LinearLayout {
|
||||
}
|
||||
|
||||
public void showReminder(final Reminder reminder) {
|
||||
title.setText(reminder.getTitle());
|
||||
if (!TextUtils.isEmpty(reminder.getTitle())) {
|
||||
title.setText(reminder.getTitle());
|
||||
title.setVisibility(VISIBLE);
|
||||
} else {
|
||||
title.setText("");
|
||||
title.setVisibility(GONE);
|
||||
}
|
||||
text.setText(reminder.getText());
|
||||
container.setBackgroundResource(reminder.getImportance() == Reminder.Importance.ERROR ? R.drawable.reminder_background_error
|
||||
: R.drawable.reminder_background_normal);
|
||||
|
||||
setOnClickListener(reminder.getOkListener());
|
||||
|
||||
|
@@ -0,0 +1,30 @@
|
||||
package org.thoughtcrime.securesms.components.reminder;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
|
||||
public class ServiceOutageReminder extends Reminder {
|
||||
|
||||
public ServiceOutageReminder(@NonNull Context context) {
|
||||
super(null,
|
||||
context.getString(R.string.reminder_header_service_outage_text));
|
||||
}
|
||||
|
||||
public static boolean isEligible(@NonNull Context context) {
|
||||
return TextSecurePreferences.getServiceOutage(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDismissable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Importance getImportance() {
|
||||
return Importance.ERROR;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user