diff --git a/app/src/main/java/com/aurora/store/ErrorType.java b/app/src/main/java/com/aurora/store/ErrorType.java index 534d2b53a..ac9c26170 100644 --- a/app/src/main/java/com/aurora/store/ErrorType.java +++ b/app/src/main/java/com/aurora/store/ErrorType.java @@ -24,5 +24,6 @@ public enum ErrorType { NO_NETWORK, NO_APPS, NO_SEARCH, - UNKNOWN + UNKNOWN, + MALFORMED } diff --git a/app/src/main/java/com/aurora/store/adapter/OkHttpClientAdapter.java b/app/src/main/java/com/aurora/store/adapter/OkHttpClientAdapter.java index de6627e21..95de66c20 100644 --- a/app/src/main/java/com/aurora/store/adapter/OkHttpClientAdapter.java +++ b/app/src/main/java/com/aurora/store/adapter/OkHttpClientAdapter.java @@ -22,6 +22,7 @@ package com.aurora.store.adapter; import android.content.Context; +import com.aurora.store.exception.MalformedRequestException; import com.aurora.store.utility.Util; import com.dragons.aurora.playstoreapiv2.AuthException; import com.dragons.aurora.playstoreapiv2.GooglePlayAPI; @@ -134,7 +135,7 @@ public class OkHttpClientAdapter extends HttpClientAdapter { } else if (code >= 500) { throw new GooglePlayException("Server error", code); } else if (code >= 400) { - throw new GooglePlayException("Malformed request", code); + throw new MalformedRequestException("Malformed Request", code); } return content; } diff --git a/app/src/main/java/com/aurora/store/exception/MalformedRequestException.java b/app/src/main/java/com/aurora/store/exception/MalformedRequestException.java new file mode 100644 index 000000000..8d88cf88d --- /dev/null +++ b/app/src/main/java/com/aurora/store/exception/MalformedRequestException.java @@ -0,0 +1,56 @@ +/* + * Aurora Store + * Copyright (C) 2019, Rahul Kumar Patel + * + * Yalp Store + * Copyright (C) 2018 Sergey Yeriomin + * + * Aurora Store is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * Aurora Store is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Aurora Store. If not, see . + * + * + */ + +package com.aurora.store.exception; + +import java.io.IOException; + +public class MalformedRequestException extends IOException { + + protected int code; + + public MalformedRequestException() { + super("MalformedRequestException"); + } + + public MalformedRequestException(String message, int code) { + super(message); + this.code = code; + } + + public MalformedRequestException(String message) { + super(message); + } + + public MalformedRequestException(String message, Throwable cause) { + super(message, cause); + } + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } +} diff --git a/app/src/main/java/com/aurora/store/fragment/DetailsFragment.java b/app/src/main/java/com/aurora/store/fragment/DetailsFragment.java index 10cb5136c..52c8dbb0a 100644 --- a/app/src/main/java/com/aurora/store/fragment/DetailsFragment.java +++ b/app/src/main/java/com/aurora/store/fragment/DetailsFragment.java @@ -36,6 +36,7 @@ import androidx.core.widget.NestedScrollView; import com.aurora.store.ErrorType; import com.aurora.store.R; +import com.aurora.store.exception.MalformedRequestException; import com.aurora.store.fragment.details.ActionButton; import com.aurora.store.fragment.details.BackToPlayStore; import com.aurora.store.fragment.details.Beta; @@ -53,8 +54,6 @@ import com.aurora.store.receiver.DetailsInstallReceiver; import com.aurora.store.task.DetailsApp; import com.aurora.store.utility.Log; import com.aurora.store.view.ErrorView; -import com.dragons.aurora.playstoreapiv2.GooglePlayException; -import com.google.android.material.snackbar.Snackbar; import butterknife.BindView; import butterknife.ButterKnife; @@ -187,11 +186,11 @@ public class DetailsFragment extends BaseFragment implements BaseFragment.EventL @Override public void processException(Throwable e) { mDisposable.clear(); - if (e.getCause() instanceof GooglePlayException && ((GooglePlayException) e).getCode() == 404) { - Snackbar.make(mContainer, "App Not Purchased", Snackbar.LENGTH_LONG).show(); + if (e instanceof MalformedRequestException) { + setErrorView(ErrorType.MALFORMED); + switchViews(true); } else super.processException(e); - } @Override diff --git a/app/src/main/java/com/aurora/store/fragment/details/ActionButton.java b/app/src/main/java/com/aurora/store/fragment/details/ActionButton.java index 53dec18b8..592a0442e 100644 --- a/app/src/main/java/com/aurora/store/fragment/details/ActionButton.java +++ b/app/src/main/java/com/aurora/store/fragment/details/ActionButton.java @@ -214,9 +214,8 @@ public class ActionButton extends AbstractHelper { .subscribe(deliveryData -> { initiateDownload(deliveryData); }, err -> { - Log.e(err.getMessage()); runOnUiThread(() -> { - Toast.makeText(context, "App not available", Toast.LENGTH_LONG).show(); + Toast.makeText(context, "App Not purchased", Toast.LENGTH_LONG).show(); draw(); switchViews(false); }); @@ -284,7 +283,7 @@ public class ActionButton extends AbstractHelper { request = RequestBuilder.buildRequest(context, app, deliveryData.getDownloadUrl()); fetchListener = getFetchListener(); fetch.addListener(fetchListener); - + if (isPaused) fetch.resume(requestId); else diff --git a/app/src/main/java/com/aurora/store/view/ErrorView.java b/app/src/main/java/com/aurora/store/view/ErrorView.java index 66364048f..1563a05ab 100644 --- a/app/src/main/java/com/aurora/store/view/ErrorView.java +++ b/app/src/main/java/com/aurora/store/view/ErrorView.java @@ -76,6 +76,11 @@ public class ErrorView extends RelativeLayout { imgError.setImageDrawable(context.getDrawable(R.drawable.ic_unknown)); txtError.setText(R.string.error_unknown); break; + case MALFORMED: + imgError.setImageDrawable(context.getDrawable(R.drawable.ic_unknown)); + txtError.setText(R.string.error_app_not_found); + btnError.setText(R.string.action_close); + break; } } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 4523b1e04..51f655969 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -50,6 +50,7 @@ Cancel Clear Clear All + Close Convert Local Convert System Link copied to clipboard