mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-21 04:29:45 +01:00
Pop a dialog to log in again or delete the account
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
3f5c03f1ef
commit
cb11c36400
@ -87,6 +87,7 @@ import com.nextcloud.talk.events.BottomSheetLockEvent;
|
||||
import com.nextcloud.talk.events.EventStatus;
|
||||
import com.nextcloud.talk.events.MoreMenuClickEvent;
|
||||
import com.nextcloud.talk.interfaces.ConversationMenuInterface;
|
||||
import com.nextcloud.talk.jobs.AccountRemovalWorker;
|
||||
import com.nextcloud.talk.jobs.ContactAddressBookWorker;
|
||||
import com.nextcloud.talk.jobs.DeleteConversationWorker;
|
||||
import com.nextcloud.talk.models.database.UserEntity;
|
||||
@ -489,10 +490,7 @@ public class ConversationsListController extends BaseController implements Searc
|
||||
.popChangeHandler(new VerticalChangeHandler())));
|
||||
} else {
|
||||
Log.d(TAG, "Starting reauth webview via ConversationsListController");
|
||||
getRouter().pushController(RouterTransaction.with(
|
||||
new WebViewLoginController(currentUser.getBaseUrl(), true))
|
||||
.pushChangeHandler(new VerticalChangeHandler())
|
||||
.popChangeHandler(new VerticalChangeHandler()));
|
||||
showUnauthorizedDialog();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@ -821,6 +819,49 @@ public class ConversationsListController extends BaseController implements Searc
|
||||
}
|
||||
}
|
||||
|
||||
private void showUnauthorizedDialog() {
|
||||
if (getActivity() != null) {
|
||||
|
||||
new LovelyStandardDialog(getActivity(), LovelyStandardDialog.ButtonLayout.HORIZONTAL)
|
||||
.setTopColorRes(R.color.nc_darkRed)
|
||||
.setIcon(DisplayUtils.getTintedDrawable(context.getResources(),
|
||||
R.drawable.ic_delete_black_24dp, R.color.bg_default))
|
||||
.setPositiveButtonColor(context.getResources().getColor(R.color.nc_darkRed))
|
||||
.setTitle(R.string.nc_dialog_invalid_password)
|
||||
.setMessage(R.string.nc_dialog_reauth_or_delete)
|
||||
.setPositiveButton(R.string.nc_delete, 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_settings_reauthorize, new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
getRouter().pushController(RouterTransaction.with(
|
||||
new WebViewLoginController(currentUser.getBaseUrl(), true))
|
||||
.pushChangeHandler(new VerticalChangeHandler())
|
||||
.popChangeHandler(new VerticalChangeHandler()));
|
||||
}
|
||||
})
|
||||
.setInstanceStateHandler(ID_DELETE_CONVERSATION_DIALOG, saveStateHandler)
|
||||
.show();
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteConversation(Data data) {
|
||||
OneTimeWorkRequest deleteConversationWorker =
|
||||
new OneTimeWorkRequest.Builder(DeleteConversationWorker.class).setInputData(data).build();
|
||||
|
@ -35,6 +35,7 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.webkit.*;
|
||||
import android.widget.ProgressBar;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.content.res.ResourcesCompat;
|
||||
@ -42,6 +43,7 @@ import androidx.work.OneTimeWorkRequest;
|
||||
import androidx.work.WorkManager;
|
||||
import autodagger.AutoInjector;
|
||||
import butterknife.BindView;
|
||||
|
||||
import com.bluelinelabs.conductor.RouterTransaction;
|
||||
import com.bluelinelabs.conductor.changehandler.HorizontalChangeHandler;
|
||||
import com.nextcloud.talk.R;
|
||||
@ -64,9 +66,11 @@ import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import io.requery.Persistable;
|
||||
import io.requery.reactivex.ReactiveEntityStore;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.net.CookieManager;
|
||||
import java.net.URLDecoder;
|
||||
@ -406,6 +410,9 @@ public class WebViewLoginController extends BaseController {
|
||||
}
|
||||
} else {
|
||||
if (finalMessageType != null) {
|
||||
// FIXME when the user registers a new account that was setup before (aka
|
||||
// ApplicationWideMessageHolder.MessageType.ACCOUNT_UPDATED_NOT_ADDED)
|
||||
// The token is not updated in the database and therefor the account not visible/usable
|
||||
ApplicationWideMessageHolder.getInstance().setMessageType(finalMessageType);
|
||||
}
|
||||
getRouter().popToRoot();
|
||||
|
@ -409,4 +409,6 @@
|
||||
<string name="failed_to_save">Failed to save %1$s</string>
|
||||
<string name="selected_list_item">selected</string>
|
||||
<string name="filename_progress">%1$s (%2$d)</string>
|
||||
<string name="nc_dialog_invalid_password">Invalid password</string>
|
||||
<string name="nc_dialog_reauth_or_delete">Do you want to reauthorize or delete this account?</string>
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user