|
|
@ -51,6 +51,7 @@ import android.widget.TextView;
|
|
|
|
import android.widget.Toast;
|
|
|
|
import android.widget.Toast;
|
|
|
|
|
|
|
|
|
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
|
|
|
|
import androidx.annotation.RequiresApi;
|
|
|
|
import androidx.appcompat.app.AlertDialog;
|
|
|
|
import androidx.appcompat.app.AlertDialog;
|
|
|
|
import androidx.appcompat.widget.PopupMenu;
|
|
|
|
import androidx.appcompat.widget.PopupMenu;
|
|
|
|
import androidx.constraintlayout.widget.Group;
|
|
|
|
import androidx.constraintlayout.widget.Group;
|
|
|
@ -385,13 +386,16 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
|
|
|
|
popupMenu.getMenu().add(Menu.NONE, R.string.title_primary, order++, R.string.title_primary)
|
|
|
|
popupMenu.getMenu().add(Menu.NONE, R.string.title_primary, order++, R.string.title_primary)
|
|
|
|
.setCheckable(true).setChecked(account.primary);
|
|
|
|
.setCheckable(true).setChecked(account.primary);
|
|
|
|
|
|
|
|
|
|
|
|
if (account.notify &&
|
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
|
|
Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
|
|
|
|
|
|
String channelId = EntityAccount.getNotificationChannelId(account.id);
|
|
|
|
String channelId = EntityAccount.getNotificationChannelId(account.id);
|
|
|
|
NotificationManager nm = Helper.getSystemService(context, NotificationManager.class);
|
|
|
|
NotificationManager nm = Helper.getSystemService(context, NotificationManager.class);
|
|
|
|
NotificationChannel channel = nm.getNotificationChannel(channelId);
|
|
|
|
NotificationChannel channel = nm.getNotificationChannel(channelId);
|
|
|
|
if (channel != null)
|
|
|
|
if (channel == null)
|
|
|
|
|
|
|
|
popupMenu.getMenu().add(Menu.NONE, R.string.title_create_channel, order++, R.string.title_create_channel);
|
|
|
|
|
|
|
|
else {
|
|
|
|
popupMenu.getMenu().add(Menu.NONE, R.string.title_edit_channel, order++, R.string.title_edit_channel);
|
|
|
|
popupMenu.getMenu().add(Menu.NONE, R.string.title_edit_channel, order++, R.string.title_edit_channel);
|
|
|
|
|
|
|
|
popupMenu.getMenu().add(Menu.NONE, R.string.title_delete_channel, order++, R.string.title_delete_channel);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (settings)
|
|
|
|
if (settings)
|
|
|
@ -418,9 +422,18 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
|
|
|
|
} else if (itemId == R.string.title_primary) {
|
|
|
|
} else if (itemId == R.string.title_primary) {
|
|
|
|
onActionPrimary(!item.isChecked());
|
|
|
|
onActionPrimary(!item.isChecked());
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
|
|
|
|
} else if (itemId == R.string.title_create_channel) {
|
|
|
|
|
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
|
|
|
|
|
|
|
|
onActionCreateChannel();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
} else if (itemId == R.string.title_edit_channel) {
|
|
|
|
} else if (itemId == R.string.title_edit_channel) {
|
|
|
|
|
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
|
|
|
|
onActionEditChannel();
|
|
|
|
onActionEditChannel();
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
|
|
|
|
} else if (itemId == R.string.title_delete_channel) {
|
|
|
|
|
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
|
|
|
|
|
|
|
|
onActionDeleteChannel();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
} else if (itemId == R.string.title_edit_properties) {
|
|
|
|
} else if (itemId == R.string.title_edit_properties) {
|
|
|
|
ViewHolder.this.onClick(view);
|
|
|
|
ViewHolder.this.onClick(view);
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
@ -514,6 +527,41 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
|
|
|
|
}.execute(context, owner, args, "account:primary");
|
|
|
|
}.execute(context, owner, args, "account:primary");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@TargetApi(Build.VERSION_CODES.O)
|
|
|
|
|
|
|
|
private void onActionCreateChannel() {
|
|
|
|
|
|
|
|
if (!ActivityBilling.isPro(context)) {
|
|
|
|
|
|
|
|
context.startActivity(new Intent(context, ActivityBilling.class));
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
account.createNotificationChannel(context);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
|
|
|
|
args.putLong("id", account.id);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
new SimpleTask<Void>() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
protected Void onExecute(Context context, Bundle args) {
|
|
|
|
|
|
|
|
long id = args.getLong("id");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DB db = DB.getInstance(context);
|
|
|
|
|
|
|
|
db.account().setAccountNotify(id, true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
protected void onExecuted(Bundle args, Void data) {
|
|
|
|
|
|
|
|
onActionEditChannel();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
protected void onException(Bundle args, Throwable ex) {
|
|
|
|
|
|
|
|
Log.unexpectedError(parentFragment.getParentFragmentManager(), ex);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}.execute(context, owner, args, "create:channel");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@TargetApi(Build.VERSION_CODES.O)
|
|
|
|
@TargetApi(Build.VERSION_CODES.O)
|
|
|
|
private void onActionEditChannel() {
|
|
|
|
private void onActionEditChannel() {
|
|
|
|
Intent intent = new Intent(Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS)
|
|
|
|
Intent intent = new Intent(Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS)
|
|
|
@ -526,6 +574,34 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RequiresApi(api = Build.VERSION_CODES.O)
|
|
|
|
|
|
|
|
private void onActionDeleteChannel() {
|
|
|
|
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
|
|
|
|
args.putLong("id", account.id);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
new SimpleTask<Void>() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
protected Void onExecute(Context context, Bundle args) {
|
|
|
|
|
|
|
|
long id = args.getLong("id");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DB db = DB.getInstance(context);
|
|
|
|
|
|
|
|
db.account().setAccountNotify(id, false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
protected void onExecuted(Bundle args, Void data) {
|
|
|
|
|
|
|
|
account.deleteNotificationChannel(context);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
protected void onException(Bundle args, Throwable ex) {
|
|
|
|
|
|
|
|
Log.unexpectedError(parentFragment.getParentFragmentManager(), ex);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}.execute(context, owner, args, "create:channel");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void onActionCopy() {
|
|
|
|
private void onActionCopy() {
|
|
|
|
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
|
|
|
|
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
|
|
|
|
lbm.sendBroadcast(
|
|
|
|
lbm.sendBroadcast(
|
|
|
|