allow users to initiate a purchase flow check
This commit is contained in:
parent
d0a8b3b218
commit
0849ce2b66
4 changed files with 100 additions and 2 deletions
|
@ -225,6 +225,7 @@ import lombok.SneakyThrows;
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
|
|
||||||
import static android.os.Build.VERSION_CODES.M;
|
import static android.os.Build.VERSION_CODES.M;
|
||||||
|
import static android.os.Build.VERSION_CODES.P;
|
||||||
|
|
||||||
public class MainActivity extends AppCompatActivity implements SdkStatusListener,
|
public class MainActivity extends AppCompatActivity implements SdkStatusListener,
|
||||||
SharedPreferences.OnSharedPreferenceChangeListener,
|
SharedPreferences.OnSharedPreferenceChangeListener,
|
||||||
|
@ -1271,7 +1272,7 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
|
||||||
return sp.getBoolean(PREFERENCE_KEY_INTERNAL_FIRST_RUN_COMPLETED, false);
|
return sp.getBoolean(PREFERENCE_KEY_INTERNAL_FIRST_RUN_COMPLETED, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkPurchases() {
|
public void checkPurchases() {
|
||||||
if (billingClient != null) {
|
if (billingClient != null) {
|
||||||
Purchase.PurchasesResult result = billingClient.queryPurchases(BillingClient.SkuType.INAPP);
|
Purchase.PurchasesResult result = billingClient.queryPurchases(BillingClient.SkuType.INAPP);
|
||||||
if (result.getPurchasesList() != null) {
|
if (result.getPurchasesList() != null) {
|
||||||
|
@ -1282,6 +1283,24 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void checkPurchases(GenericTaskHandler handler) {
|
||||||
|
boolean purchaseFound = false;
|
||||||
|
if (billingClient != null) {
|
||||||
|
Purchase.PurchasesResult result = billingClient.queryPurchases(BillingClient.SkuType.INAPP);
|
||||||
|
if (result.getPurchasesList() != null) {
|
||||||
|
for (Purchase purchase : result.getPurchasesList()) {
|
||||||
|
handlePurchase(purchase, handler);
|
||||||
|
purchaseFound = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!purchaseFound) {
|
||||||
|
handler.onError(new Exception(getString(R.string.skip_queue_purchase_not_found)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void handlePurchase(Purchase purchase) {
|
private void handlePurchase(Purchase purchase) {
|
||||||
handleBillingPurchase(purchase, billingClient, MainActivity.this, null, new RewardVerifiedHandler() {
|
handleBillingPurchase(purchase, billingClient, MainActivity.this, null, new RewardVerifiedHandler() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -1298,6 +1317,28 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void handlePurchase(Purchase purchase, GenericTaskHandler handler) {
|
||||||
|
handleBillingPurchase(purchase, billingClient, MainActivity.this, null, new RewardVerifiedHandler() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(RewardVerified rewardVerified) {
|
||||||
|
if (Lbryio.currentUser != null) {
|
||||||
|
Lbryio.currentUser.setRewardApproved(rewardVerified.isRewardApproved());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (handler != null) {
|
||||||
|
handler.onSuccess();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(Exception error) {
|
||||||
|
if (handler != null) {
|
||||||
|
handler.onError(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private void checkPendingOpens() {
|
private void checkPendingOpens() {
|
||||||
if (pendingFollowingReload) {
|
if (pendingFollowingReload) {
|
||||||
loadFollowingContent();
|
loadFollowingContent();
|
||||||
|
|
|
@ -19,10 +19,12 @@ import androidx.fragment.app.Fragment;
|
||||||
import com.google.android.material.button.MaterialButton;
|
import com.google.android.material.button.MaterialButton;
|
||||||
import com.google.android.material.snackbar.Snackbar;
|
import com.google.android.material.snackbar.Snackbar;
|
||||||
|
|
||||||
|
import io.lbry.browser.MainActivity;
|
||||||
import io.lbry.browser.R;
|
import io.lbry.browser.R;
|
||||||
import io.lbry.browser.listener.SignInListener;
|
import io.lbry.browser.listener.SignInListener;
|
||||||
import io.lbry.browser.model.TwitterOauth;
|
import io.lbry.browser.model.TwitterOauth;
|
||||||
import io.lbry.browser.model.lbryinc.RewardVerified;
|
import io.lbry.browser.model.lbryinc.RewardVerified;
|
||||||
|
import io.lbry.browser.tasks.GenericTaskHandler;
|
||||||
import io.lbry.browser.tasks.RewardVerifiedHandler;
|
import io.lbry.browser.tasks.RewardVerifiedHandler;
|
||||||
import io.lbry.browser.tasks.TwitterOauthHandler;
|
import io.lbry.browser.tasks.TwitterOauthHandler;
|
||||||
import io.lbry.browser.tasks.lbryinc.TwitterVerifyTask;
|
import io.lbry.browser.tasks.lbryinc.TwitterVerifyTask;
|
||||||
|
@ -69,6 +71,33 @@ public class ManualVerificationFragment extends Fragment {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
root.findViewById(R.id.verification_manual_skip_queue_verify).setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
showLoading();
|
||||||
|
if (MainActivity.instance != null) {
|
||||||
|
MainActivity.instance.checkPurchases(new GenericTaskHandler() {
|
||||||
|
@Override
|
||||||
|
public void beforeStart() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSuccess() {
|
||||||
|
hideLoading();
|
||||||
|
listener.onManualVerifyContinue();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(Exception error) {
|
||||||
|
hideLoading();
|
||||||
|
showError(error.getMessage());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
root.findViewById(R.id.verification_manual_continue_button).setOnClickListener(new View.OnClickListener() {
|
root.findViewById(R.id.verification_manual_continue_button).setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -267,6 +296,16 @@ public class ManualVerificationFragment extends Fragment {
|
||||||
showFlowError(extra);
|
showFlowError(extra);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void showError(String message) {
|
||||||
|
Context context = getContext();
|
||||||
|
View root = getView();
|
||||||
|
if (context != null && root != null) {
|
||||||
|
Snackbar.make(root, message, Snackbar.LENGTH_LONG).
|
||||||
|
setTextColor(Color.WHITE).
|
||||||
|
setBackgroundTint(Color.RED).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void showFlowError(String extra) {
|
private void showFlowError(String extra) {
|
||||||
Context context = getContext();
|
Context context = getContext();
|
||||||
View root = getView();
|
View root = getView();
|
||||||
|
|
|
@ -93,7 +93,22 @@
|
||||||
android:layout_marginTop="4dp"
|
android:layout_marginTop="4dp"
|
||||||
android:fontFamily="@font/inter"
|
android:fontFamily="@font/inter"
|
||||||
android:text="@string/skip_queue_button_text" />
|
android:text="@string/skip_queue_button_text" />
|
||||||
|
<TextView
|
||||||
|
android:textSize="16sp"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:fontFamily="@font/inter"
|
||||||
|
android:text="@string/skip_queue_manual_check"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
android:textFontWeight="300" />
|
||||||
|
<com.google.android.material.button.MaterialButton
|
||||||
|
android:id="@+id/verification_manual_skip_queue_verify"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="4dp"
|
||||||
|
android:fontFamily="@font/inter"
|
||||||
|
android:text="@string/verify_purchase" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:textSize="20sp"
|
android:textSize="20sp"
|
||||||
|
|
|
@ -454,6 +454,9 @@
|
||||||
<string name="twitter_verify">Verify with Twitter</string>
|
<string name="twitter_verify">Verify with Twitter</string>
|
||||||
<string name="skip_queue_verification">Skip the Queue</string>
|
<string name="skip_queue_verification">Skip the Queue</string>
|
||||||
<string name="skip_queue_verification_desc">Skip the manual verification queue by paying a fee in order to start participating in the rewards program immediately.</string>
|
<string name="skip_queue_verification_desc">Skip the manual verification queue by paying a fee in order to start participating in the rewards program immediately.</string>
|
||||||
|
<string name="skip_queue_manual_check">If you previously completed a purchase successfully and you still see this screen, please tap the verify purchase button below.</string>
|
||||||
|
<string name="skip_queue_purchase_not_found">No purchase was found for this account.</string>
|
||||||
|
<string name="verify_purchase">Verify Purchase</string>
|
||||||
<string name="request_to_be_verified">Please request to be verified on the <a href="https://discordapp.com/invite/Z3bERWA">LBRY Discord server</a>. A manual review can take anywhere from several minutes to several days.</string>
|
<string name="request_to_be_verified">Please request to be verified on the <a href="https://discordapp.com/invite/Z3bERWA">LBRY Discord server</a>. A manual review can take anywhere from several minutes to several days.</string>
|
||||||
<string name="enjoy_free_content">Please enjoy free content in the meantime!</string>
|
<string name="enjoy_free_content">Please enjoy free content in the meantime!</string>
|
||||||
<string name="verify_phone_number">Verify Phone Number</string>
|
<string name="verify_phone_number">Verify Phone Number</string>
|
||||||
|
|
Loading…
Reference in a new issue