2015-06-09 07:37:20 -07:00
|
|
|
package org.thoughtcrime.securesms;
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.DialogInterface;
|
|
|
|
import android.support.annotation.NonNull;
|
2015-05-20 23:36:30 +02:00
|
|
|
import android.support.v7.app.AlertDialog;
|
2015-06-09 07:37:20 -07:00
|
|
|
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
2019-07-24 12:30:23 +10:00
|
|
|
import network.loki.messenger.R;
|
|
|
|
|
2015-05-20 23:36:30 +02:00
|
|
|
public class MuteDialog extends AlertDialog {
|
|
|
|
|
|
|
|
|
|
|
|
protected MuteDialog(Context context) {
|
|
|
|
super(context);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected MuteDialog(Context context, boolean cancelable, OnCancelListener cancelListener) {
|
|
|
|
super(context, cancelable, cancelListener);
|
|
|
|
}
|
2015-06-09 07:37:20 -07:00
|
|
|
|
2015-05-20 23:36:30 +02:00
|
|
|
protected MuteDialog(Context context, int theme) {
|
|
|
|
super(context, theme);
|
|
|
|
}
|
2015-06-09 07:37:20 -07:00
|
|
|
|
|
|
|
public static void show(final Context context, final @NonNull MuteSelectionListener listener) {
|
2015-05-20 23:36:30 +02:00
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
2015-06-09 07:37:20 -07:00
|
|
|
builder.setTitle(R.string.MuteDialog_mute_notifications);
|
|
|
|
builder.setItems(R.array.mute_durations, new DialogInterface.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog, final int which) {
|
|
|
|
final long muteUntil;
|
|
|
|
|
|
|
|
switch (which) {
|
2015-11-08 19:22:23 +01:00
|
|
|
case 0: muteUntil = System.currentTimeMillis() + TimeUnit.HOURS.toMillis(1); break;
|
|
|
|
case 1: muteUntil = System.currentTimeMillis() + TimeUnit.HOURS.toMillis(2); break;
|
|
|
|
case 2: muteUntil = System.currentTimeMillis() + TimeUnit.DAYS.toMillis(1); break;
|
|
|
|
case 3: muteUntil = System.currentTimeMillis() + TimeUnit.DAYS.toMillis(7); break;
|
|
|
|
case 4: muteUntil = System.currentTimeMillis() + TimeUnit.DAYS.toMillis(365); break;
|
|
|
|
default: muteUntil = System.currentTimeMillis() + TimeUnit.HOURS.toMillis(1); break;
|
2015-06-09 07:37:20 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
listener.onMuted(muteUntil);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
builder.show();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public interface MuteSelectionListener {
|
|
|
|
public void onMuted(long until);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|