Skip to content

Commit

Permalink
Merge branch 'release/v4.2.1' into 'master'
Browse files Browse the repository at this point in the history
Release v4.2.1

See merge request mobile/android/android!1895
  • Loading branch information
javiergm1983 committed Jul 22, 2021
2 parents 0c52798 + 4e5302d commit fc1887e
Show file tree
Hide file tree
Showing 57 changed files with 2,150 additions and 2,587 deletions.
4 changes: 4 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,10 @@ dependencies {
hmsImplementation 'com.huawei.hms:location:4.0.2.300'
hmsImplementation 'com.huawei.hms:maps:4.0.1.301'
hmsImplementation 'com.huawei.hms:iap:4.0.2.300'

// Play Core
implementation("com.google.android.play:core:1.10.0")
implementation("com.google.android.play:core-ktx:1.8.1")
}

def taskRequests = gradle.getStartParameter().getTaskRequests().toString()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import java.util.ArrayList;
import java.util.List;

import mega.privacy.android.app.MegaApplication;
import mega.privacy.android.app.R;
import mega.privacy.android.app.middlelayer.iab.BillingManager;
import mega.privacy.android.app.middlelayer.iab.BillingUpdatesListener;
Expand Down Expand Up @@ -155,14 +156,18 @@ public boolean isPurchased(MegaPurchase purchase) {
public void initiatePurchaseFlow(@Nullable String oldSku, @Nullable String purchaseToken, @NonNull MegaSku skuDetails) {
logDebug("oldSku is:" + oldSku + ", new sku is:" + skuDetails);

String obfuscatedAccountId = ((MegaApplication)mActivity.getApplication()).getMyAccountInfo().generateObfuscatedAccountId();
logDebug("Obfuscated account id is:" + obfuscatedAccountId);

//if user is upgrading, it take effect immediately otherwise wait until current plan expired
final int prorationMode = getProductLevel(skuDetails.getSku()) > getProductLevel(oldSku) ? IMMEDIATE_WITH_TIME_PRORATION : DEFERRED;
logDebug("prorationMode is " + prorationMode);
Runnable purchaseFlowRequest = () -> {
BillingFlowParams.Builder builder = BillingFlowParams
.newBuilder()
.setSkuDetails(getSkuDetails(skuDetails))
.setReplaceSkusProrationMode(prorationMode);
.setReplaceSkusProrationMode(prorationMode)
.setObfuscatedAccountId(obfuscatedAccountId);

// setOldSku requires non-null parameters.
if (oldSku != null && purchaseToken != null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package mega.privacy.android.app.service.iar

import android.content.Context
import com.google.android.play.core.review.ReviewInfo
import com.google.android.play.core.review.ReviewManager
import com.google.android.play.core.review.ReviewManagerFactory
import com.google.android.play.core.tasks.Task
import mega.privacy.android.app.MegaApplication
import mega.privacy.android.app.middlelayer.iar.OnCompleteListener
import mega.privacy.android.app.middlelayer.iar.RatingHandler
import mega.privacy.android.app.utils.LogUtil

/**
* Implement rating feature for Google play store using google APIs
*
* @param context Context for getting rating dialog
*/
class RatingHandlerImpl(context: Context) : RatingHandler(context) {

override fun showReviewDialog(context: Context, listener: OnCompleteListener) {
val manager: ReviewManager = ReviewManagerFactory.create(context)
val request: Task<ReviewInfo> = manager.requestReviewFlow()
request.addOnCompleteListener { task ->
if (task.isSuccessful) {
val reviewInfo: ReviewInfo = task.result
MegaApplication.getInstance().currentActivity?.let {
val flow: Task<Void> = manager.launchReviewFlow(it, reviewInfo)
flow.addOnCompleteListener {
LogUtil.logDebug("Rating Task Complete")
listener.onComplete()
}
}
} else {
LogUtil.logError("RatingTask is failed")
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package mega.privacy.android.app.service.iar

import android.content.Context
import mega.privacy.android.app.middlelayer.iar.OnCompleteListener
import mega.privacy.android.app.middlelayer.iar.RatingHandler
import mega.privacy.android.app.utils.LogUtil
/**
* Implement rating feature for HMS by using huawei APIs
*
* @param context Context for getting rating dialog
*/
class RatingHandlerImpl(context: Context) : RatingHandler(context) {

override fun showReviewDialog(context: Context, listener: OnCompleteListener) {
LogUtil.logDebug("showHmsReviewDialog")
}
}
60 changes: 57 additions & 3 deletions app/src/main/java/mega/privacy/android/app/BaseActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
import static mega.privacy.android.app.lollipop.LoginFragmentLollipop.NAME_USER_LOCKED;
import static mega.privacy.android.app.constants.BroadcastConstants.*;
import static mega.privacy.android.app.utils.AlertsAndWarnings.showResumeTransfersWarning;
import static mega.privacy.android.app.utils.Constants.SNACKBAR_IMCOMPATIBILITY_TYPE;
import static mega.privacy.android.app.utils.LogUtil.*;
import static mega.privacy.android.app.utils.PermissionUtils.*;
import static mega.privacy.android.app.utils.TimeUtils.*;
Expand Down Expand Up @@ -100,6 +101,8 @@ public class BaseActivity extends AppCompatActivity implements ActivityLauncher,
private boolean isGeneralTransferOverQuotaWarningShown;
private AlertDialog transferGeneralOverQuotaWarning;

private Snackbar snackbar;

/**
* Load the psa in the web browser fragment if the psa is a web one and this activity
* is on the top of the task stack
Expand Down Expand Up @@ -660,7 +663,26 @@ public void showSnackbar (int type, View view, String s) {
* If the value is -1 (INVALID_HANLDE) the function ends in chats list view.
*/
public void showSnackbar(int type, View view, String s, long idChat) {
showSnackbar(type, view, s, idChat, null);
showSnackbar(type, view, null, s, idChat, null);
}

/**
* Method to display a simple or action Snackbar.
*
* @param type There are three possible values to this param:
* - SNACKBAR_TYPE: creates a simple snackbar
* - MESSAGE_SNACKBAR_TYPE: creates an action snackbar which function is to go to Chat section
* - NOT_SPACE_SNACKBAR_TYPE: creates an action snackbar which function is to go to Storage-Settings section
* - MUTE_NOTIFICATIONS_SNACKBAR_TYPE: creates an action snackbar which function is unmute chats notifications
* - INVITE_CONTACT_TYPE: creates an action snackbar which function is to send a contact invitation
* @param view Layout where the snackbar is going to show.
* @param anchor Sets the view the Snackbar should be anchored above, null as default
* @param s Text to shown in the snackbar
* @param idChat Chat ID. If this param has a valid value the function of MESSAGE_SNACKBAR_TYPE ends in the specified chat.
* If the value is -1 (INVALID_HANLDE) the function ends in chats list view.
*/
public void showSnackbarWithAnchorView(int type, View view, View anchor, String s, long idChat) {
showSnackbar(type, view, anchor, s, idChat, null);
}

/**
Expand All @@ -673,18 +695,18 @@ public void showSnackbar(int type, View view, String s, long idChat) {
* - MUTE_NOTIFICATIONS_SNACKBAR_TYPE: creates an action snackbar which function is unmute chats notifications
* - INVITE_CONTACT_TYPE: creates an action snackbar which function is to send a contact invitation
* @param view Layout where the snackbar is going to show.
* @param anchor Sets the view the Snackbar should be anchored above, null as default
* @param s Text to shown in the snackbar
* @param idChat Chat ID. If this param has a valid value the function of MESSAGE_SNACKBAR_TYPE ends in the specified chat.
* If the value is -1 (INVALID_HANLDE) the function ends in chats list view.
* @param userEmail Email of the user to be invited.
*/
public void showSnackbar (int type, View view, String s, long idChat, String userEmail) {
public void showSnackbar (int type, View view, View anchor, String s, long idChat, String userEmail) {
logDebug("Show snackbar: " + s);
Display display = getWindowManager().getDefaultDisplay();
DisplayMetrics outMetrics = new DisplayMetrics();
display.getMetrics(outMetrics);

Snackbar snackbar;
try {
switch (type) {
case MESSAGE_SNACKBAR_TYPE:
Expand All @@ -696,6 +718,10 @@ public void showSnackbar (int type, View view, String s, long idChat, String use
case MUTE_NOTIFICATIONS_SNACKBAR_TYPE:
snackbar = Snackbar.make(view, R.string.notifications_are_already_muted, Snackbar.LENGTH_LONG);
break;
case SNACKBAR_IMCOMPATIBILITY_TYPE:
case SNACKBAR_IMCOMPATIBILITY_BUTTON_TYPE:
snackbar = Snackbar.make(view, !isTextEmpty(s) ? s : getString(R.string.sent_as_message), Snackbar.LENGTH_INDEFINITE);
break;
default:
snackbar = Snackbar.make(view, s, Snackbar.LENGTH_LONG);
break;
Expand All @@ -708,6 +734,10 @@ public void showSnackbar (int type, View view, String s, long idChat, String use
Snackbar.SnackbarLayout snackbarLayout = (Snackbar.SnackbarLayout) snackbar.getView();
snackbarLayout.setBackgroundResource(R.drawable.background_snackbar);

if (anchor != null) {
snackbar.setAnchorView(anchor);
}

switch (type) {
case SNACKBAR_TYPE: {
TextView snackbarTextView = snackbar.getView().findViewById(com.google.android.material.R.id.snackbar_text);
Expand Down Expand Up @@ -739,9 +769,33 @@ public void showSnackbar (int type, View view, String s, long idChat, String use
snackbar.setAction(R.string.contact_invite, new SnackbarNavigateOption(view.getContext(), type, userEmail));
snackbar.show();
break;
case SNACKBAR_IMCOMPATIBILITY_TYPE: {
snackbarLayout.setBackgroundResource(R.drawable.background_snackbar_incompatibility);
TextView snackbarTextView = snackbar.getView().findViewById(com.google.android.material.R.id.snackbar_text);
snackbarTextView.setMaxLines(3);
snackbar.show();
break;
}
case SNACKBAR_IMCOMPATIBILITY_BUTTON_TYPE: {
snackbar.setAction(R.string.general_ok, v -> {snackbar.dismiss();});
snackbarLayout.setBackgroundResource(R.drawable.background_snackbar_incompatibility);
TextView snackbarTextView = snackbar.getView().findViewById(com.google.android.material.R.id.snackbar_text);
snackbarTextView.setMaxLines(3);
snackbar.show();
break;
}
}
}

/**
* Get snackbar instance
*
* @return snackbar
*/
public Snackbar getSnackbar() {
return snackbar;
}

/**
* Method to display a simple Snackbar.
*
Expand Down
Loading

0 comments on commit fc1887e

Please sign in to comment.