|
34 | 34 | import android.util.Log;
|
35 | 35 | import android.widget.Toast;
|
36 | 36 |
|
37 |
| -import androidx.core.app.ActivityCompat; |
38 |
| -import androidx.core.content.ContextCompat; |
39 |
| -import androidx.fragment.app.Fragment; |
40 |
| - |
| 37 | +import com.nextcloud.android.sso.exceptions.AccountImportCancelledException; |
41 | 38 | import com.nextcloud.android.sso.exceptions.AndroidGetAccountsPermissionNotGranted;
|
42 | 39 | import com.nextcloud.android.sso.exceptions.NextcloudFilesAppAccountNotFoundException;
|
43 | 40 | import com.nextcloud.android.sso.exceptions.NextcloudFilesAppAccountPermissionNotGrantedException;
|
|
52 | 49 | import java.util.Arrays;
|
53 | 50 | import java.util.List;
|
54 | 51 |
|
| 52 | +import androidx.core.app.ActivityCompat; |
| 53 | +import androidx.core.content.ContextCompat; |
| 54 | +import androidx.fragment.app.Fragment; |
55 | 55 | import io.reactivex.annotations.NonNull;
|
56 | 56 |
|
57 | 57 | import static android.app.Activity.RESULT_CANCELED;
|
@@ -221,17 +221,18 @@ public interface IAccountAccessGranted {
|
221 | 221 | }
|
222 | 222 |
|
223 | 223 | public static void onActivityResult(int requestCode, int resultCode, Intent data, Activity activity,
|
224 |
| - IAccountAccessGranted callback) { |
| 224 | + IAccountAccessGranted callback) throws AccountImportCancelledException { |
225 | 225 | onActivityResult(requestCode, resultCode, data, activity, null, callback);
|
226 | 226 | }
|
227 | 227 |
|
228 | 228 | public static void onActivityResult(int requestCode, int resultCode, Intent data, Fragment fragment,
|
229 |
| - IAccountAccessGranted callback) { |
| 229 | + IAccountAccessGranted callback) throws AccountImportCancelledException { |
230 | 230 | onActivityResult(requestCode, resultCode, data, null, fragment, callback);
|
231 | 231 | }
|
232 | 232 |
|
233 | 233 | private static void onActivityResult(int requestCode, int resultCode, Intent data, Activity activity,
|
234 |
| - Fragment fragment, IAccountAccessGranted callback) { |
| 234 | + Fragment fragment, IAccountAccessGranted callback) |
| 235 | + throws AccountImportCancelledException { |
235 | 236 | Context context = (activity != null) ? activity : fragment.getContext();
|
236 | 237 |
|
237 | 238 | if (resultCode == RESULT_OK) {
|
@@ -268,8 +269,8 @@ private static void onActivityResult(int requestCode, int resultCode, Intent dat
|
268 | 269 | } else if (resultCode == RESULT_CANCELED) {
|
269 | 270 | switch (requestCode) {
|
270 | 271 | case CHOOSE_ACCOUNT_SSO:
|
271 |
| - Toast.makeText(context, R.string.select_account_unknown_error_toast, Toast.LENGTH_LONG).show(); |
272 |
| - break; |
| 272 | + // nothing to do here |
| 273 | + throw new AccountImportCancelledException(); |
273 | 274 | case REQUEST_AUTH_TOKEN_SSO:
|
274 | 275 | try {
|
275 | 276 | handleFailedAuthRequest(data);
|
|
0 commit comments