diff --git a/News-Android-App/build.gradle b/News-Android-App/build.gradle index 810197da..a1b18746 100644 --- a/News-Android-App/build.gradle +++ b/News-Android-App/build.gradle @@ -131,7 +131,7 @@ dependencies { // implementation 'com.google.android.gms:play-services:4.2.42' //implementation project(':Android-SingleSignOn') //implementation project(path: ':MaterialShowcaseView:library', configuration: 'default') - implementation 'com.github.nextcloud:Android-SingleSignOn:0.4.1' + implementation 'com.github.nextcloud:Android-SingleSignOn:0.5.0-rc1' implementation 'com.github.David-Development:MaterialShowcaseView:bf6afa225d' // https://mvnrepository.com/artifact/androidx.legacy/legacy-support-v4 diff --git a/News-Android-App/src/androidTest/java/de/luhmer/owncloudnewsreader/di/TestApiProvider.java b/News-Android-App/src/androidTest/java/de/luhmer/owncloudnewsreader/di/TestApiProvider.java index c8ea3a9f..bb38c380 100644 --- a/News-Android-App/src/androidTest/java/de/luhmer/owncloudnewsreader/di/TestApiProvider.java +++ b/News-Android-App/src/androidTest/java/de/luhmer/owncloudnewsreader/di/TestApiProvider.java @@ -9,6 +9,7 @@ import android.util.Log; import com.nextcloud.android.sso.aidl.NextcloudRequest; import com.nextcloud.android.sso.api.NetworkRequest; import com.nextcloud.android.sso.api.NextcloudAPI; +import com.nextcloud.android.sso.api.Response; import com.nextcloud.android.sso.exceptions.NextcloudHttpRequestFailedException; import org.mockito.Mockito; @@ -16,6 +17,7 @@ import org.mockito.Mockito; import java.io.ByteArrayInputStream; import java.io.InputStream; import java.nio.charset.Charset; +import java.util.ArrayList; import de.luhmer.owncloudnewsreader.helper.GsonConfig; import de.luhmer.owncloudnewsreader.reader.nextcloud.API; @@ -109,6 +111,13 @@ public class TestApiProvider extends ApiProvider { return inputStream; } + @Override + protected Response performNetworkRequestV2(NextcloudRequest request, InputStream requestBodyInputStream) throws Exception { + return new Response( + performNetworkRequest(request, requestBodyInputStream), new ArrayList<>(0) + ); + } + private InputStream handleFolders() { String folders = "{\"folders\":[{\"id\":2,\"name\":\"Comic\"},{\"id\":3,\"name\":\"Android\"}]}"; return stringToInputStream(folders); diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/LoginDialogActivity.java b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/LoginDialogActivity.java index 01263be6..0c932a8c 100644 --- a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/LoginDialogActivity.java +++ b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/LoginDialogActivity.java @@ -46,12 +46,10 @@ import android.widget.ImageView; import android.widget.RelativeLayout; import android.widget.TextView; -import androidx.appcompat.app.AlertDialog; -import androidx.appcompat.app.AppCompatActivity; - import com.google.android.material.textfield.TextInputLayout; import com.nextcloud.android.sso.AccountImporter; import com.nextcloud.android.sso.api.NextcloudAPI; +import com.nextcloud.android.sso.exceptions.AccountImportCancelledException; import com.nextcloud.android.sso.exceptions.AndroidGetAccountsPermissionNotGranted; import com.nextcloud.android.sso.exceptions.NextcloudFilesAppNotInstalledException; import com.nextcloud.android.sso.exceptions.NextcloudHttpRequestFailedException; @@ -65,6 +63,8 @@ import java.net.URL; import javax.inject.Inject; +import androidx.appcompat.app.AlertDialog; +import androidx.appcompat.app.AppCompatActivity; import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick; @@ -458,10 +458,13 @@ public class LoginDialogActivity extends AppCompatActivity { public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); - AccountImporter.onActivityResult(requestCode, resultCode, data, LoginDialogActivity.this, account -> { - LoginDialogActivity.this.importedAccount = account; - loginSingleSignOn(); - }); + try { + AccountImporter.onActivityResult(requestCode, resultCode, data, LoginDialogActivity.this, account -> { + LoginDialogActivity.this.importedAccount = account; + loginSingleSignOn(); + }); + } catch (AccountImportCancelledException ignored) { + } } @Override diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsReaderListActivity.java b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsReaderListActivity.java index 444909d3..844a2e09 100644 --- a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsReaderListActivity.java +++ b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsReaderListActivity.java @@ -42,26 +42,10 @@ import android.view.View; import android.widget.SearchView; import android.widget.Toast; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.annotation.VisibleForTesting; -import androidx.appcompat.app.ActionBarDrawerToggle; -import androidx.appcompat.app.AlertDialog; -import androidx.appcompat.widget.Toolbar; -import androidx.core.app.ActivityCompat; -import androidx.core.view.GravityCompat; -import androidx.customview.widget.ViewDragHelper; -import androidx.drawerlayout.widget.DrawerLayout; -import androidx.fragment.app.DialogFragment; -import androidx.fragment.app.Fragment; -import androidx.fragment.app.FragmentManager; -import androidx.fragment.app.FragmentTransaction; -import androidx.preference.PreferenceManager; -import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; - import com.google.android.material.snackbar.Snackbar; import com.nextcloud.android.sso.AccountImporter; import com.nextcloud.android.sso.api.NextcloudAPI; +import com.nextcloud.android.sso.exceptions.AccountImportCancelledException; import com.nextcloud.android.sso.exceptions.NextcloudFilesAppAccountNotFoundException; import com.nextcloud.android.sso.exceptions.NextcloudFilesAppAccountPermissionNotGrantedException; import com.nextcloud.android.sso.exceptions.NextcloudFilesAppNotSupportedException; @@ -84,6 +68,22 @@ import java.util.concurrent.TimeUnit; import javax.inject.Inject; import javax.inject.Named; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.annotation.VisibleForTesting; +import androidx.appcompat.app.ActionBarDrawerToggle; +import androidx.appcompat.app.AlertDialog; +import androidx.appcompat.widget.Toolbar; +import androidx.core.app.ActivityCompat; +import androidx.core.view.GravityCompat; +import androidx.customview.widget.ViewDragHelper; +import androidx.drawerlayout.widget.DrawerLayout; +import androidx.fragment.app.DialogFragment; +import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentManager; +import androidx.fragment.app.FragmentTransaction; +import androidx.preference.PreferenceManager; +import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; import butterknife.BindView; import butterknife.ButterKnife; import de.luhmer.owncloudnewsreader.ListView.SubscriptionExpandableListAdapter; @@ -970,21 +970,24 @@ public class NewsReaderListActivity extends PodcastFragmentActivity implements } - AccountImporter.onActivityResult(requestCode, resultCode, data, this, account -> { - Log.d(TAG, "accountAccessGranted() called with: account = [" + account + "]"); - mApi.initApi(new NextcloudAPI.ApiConnectedListener() { - @Override - public void onConnected() { - Log.d(TAG, "onConnected() called"); - } + try { + AccountImporter.onActivityResult(requestCode, resultCode, data, this, account -> { + Log.d(TAG, "accountAccessGranted() called with: account = [" + account + "]"); + mApi.initApi(new NextcloudAPI.ApiConnectedListener() { + @Override + public void onConnected() { + Log.d(TAG, "onConnected() called"); + } - @Override - public void onError(Exception ex) { - Log.e(TAG, "onError() called with:", ex); - } - }); + @Override + public void onError(Exception ex) { + Log.e(TAG, "onError() called with:", ex); + } + }); - }); + }); + } catch (AccountImportCancelledException ignored) { + } } @Override