Browse Source

Add a warning on the conversations list as well

Signed-off-by: Joas Schilling <coding@schilljs.com>
Joas Schilling 4 năm trước cách đây
mục cha
commit
37dc7d1df0

+ 39 - 0
app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.java

@@ -270,6 +270,45 @@ public class ConversationsListController extends BaseController implements Searc
         currentUser = userUtils.getCurrentUser();
 
         if (currentUser != null) {
+            if (!currentUser.hasSpreedFeatureCapability("no-ping")) {
+                // Talk 4+
+                new LovelyStandardDialog(getActivity(), LovelyStandardDialog.ButtonLayout.HORIZONTAL)
+                        .setTopColorRes(R.color.nc_darkRed)
+                        .setIcon(DisplayUtils.getTintedDrawable(context.getResources(),
+                                                                R.drawable.ic_timer_black_24dp, R.color.bg_default))
+                        .setPositiveButtonColor(context.getResources().getColor(R.color.nc_darkRed))
+                        .setCancelable(false)
+                        .setTitle(R.string.nc_settings_server_eol_title)
+                        .setMessage(R.string.nc_settings_server_eol)
+                        .setPositiveButton(R.string.nc_settings_remove_account, new View.OnClickListener() {
+                            @Override
+                            public void onClick(View v) {
+                                boolean otherUserExists = userUtils.scheduleUserForDeletionWithId(currentUser.getId());
+
+                                OneTimeWorkRequest accountRemovalWork = new OneTimeWorkRequest.Builder(AccountRemovalWorker.class).build();
+                                WorkManager.getInstance().enqueue(accountRemovalWork);
+
+                                if (otherUserExists && getView() != null) {
+                                    onViewBound(getView());
+                                    onAttach(getView());
+                                } else if (!otherUserExists) {
+                                    getRouter().setRoot(RouterTransaction.with(
+                                            new ServerSelectionController())
+                                                                .pushChangeHandler(new VerticalChangeHandler())
+                                                                .popChangeHandler(new VerticalChangeHandler()));
+                                }
+                            }
+                        })
+                        .setNegativeButton(R.string.nc_cancel, new View.OnClickListener() {
+                            @Override
+                            public void onClick(View v) {
+                                getRouter().pushController(RouterTransaction.with(new SwitchAccountController()));
+                            }
+                        })
+                        .setInstanceStateHandler(ID_DELETE_CONVERSATION_DIALOG, saveStateHandler)
+                        .show();
+            }
+
             credentials = ApiUtils.getCredentials(currentUser.getUsername(), currentUser.getToken());
             shouldUseLastMessageLayout = currentUser.hasSpreedFeatureCapability("last-room-activity");
             if (getActivity() != null && getActivity() instanceof MainActivity) {

+ 1 - 0
app/src/main/res/values/strings.xml

@@ -85,6 +85,7 @@
     <string name="nc_settings_remove_confirmation">Please confirm your intent to remove the current account.</string>
     <string name="nc_settings_remove_account">Remove account</string>
     <string name="nc_settings_add_account">Add a new account</string>
+    <string name="nc_settings_server_eol_title">Unsupported server</string>
     <string name="nc_settings_server_eol">The server version is too old and not supported by this version of the
         Android app</string>
     <string name="nc_settings_server_almost_eol">The server version is very old and will not be supported in the next