Skip to content

Commit

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

See merge request mobile/android/android!2151
  • Loading branch information
javiergm1983 committed Dec 13, 2021
2 parents 2b93b1c + 2c5dda6 commit 42859a0
Show file tree
Hide file tree
Showing 209 changed files with 5,716 additions and 3,408 deletions.
16 changes: 14 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ android {
resValue ("string", "app_version", "\"${versionName}\"")
resValue ("string", "sdk_version", "\"${getSdkGitHash()}\"")
resValue ("string", "karere_version", "\"${getKarereGitHash()}\"")

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

sourceSets.main {
Expand Down Expand Up @@ -217,6 +219,8 @@ dependencies {

implementation "com.jeremyliao:live-event-bus-x:$liveEventBus"

implementation "androidx.biometric:biometric:$biometricVersion"

//GMS
gmsImplementation 'com.google.firebase:firebase-core:18.0.0'
gmsImplementation 'com.google.firebase:firebase-messaging:21.0.1'
Expand All @@ -228,14 +232,22 @@ dependencies {
gmsImplementation 'com.google.firebase:firebase-crashlytics-ndk'
gmsImplementation 'com.google.firebase:firebase-analytics-ktx'
//HMS
hmsImplementation "com.huawei.agconnect:agconnect-core:$huaweiServicesVersion"
hmsImplementation 'com.huawei.hms:push:4.0.2.300'
hmsImplementation 'com.huawei.hms:location:4.0.2.300'
hmsImplementation 'com.huawei.hms:maps:4.0.1.301'
hmsImplementation 'com.huawei.hms:location:6.2.0.300'
hmsImplementation 'com.huawei.hms:maps:6.0.1.304'
hmsImplementation 'com.huawei.hms:iap:4.0.2.300'
hmsImplementation 'com.huawei.hms:hianalytics:5.2.0.301'
hmsImplementation 'com.huawei.agconnect:agconnect-crash:1.5.1.300'

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

// Testing dependencies
testImplementation "junit:junit:$junitVersion"
testImplementation "com.google.truth:truth:$truthVersion"
androidTestImplementation "androidx.test.ext:junit:$androidxTestExtVersion"
}

def taskRequests = gradle.getStartParameter().getTaskRequests().toString()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package mega.privacy.android.app.service.crashreporter

import com.google.firebase.crashlytics.FirebaseCrashlytics
import mega.privacy.android.app.middlelayer.crashreporter.CrashReporter

class CrashReporterImpl : CrashReporter {

private val crashlytics: FirebaseCrashlytics = FirebaseCrashlytics.getInstance()

override fun report(e: Throwable) {
crashlytics.recordException(e)
crashlytics.sendUnsentReports()
}

override fun setEnabled(enabled: Boolean) {
crashlytics.setCrashlyticsCollectionEnabled(enabled)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.annotation.SuppressLint;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.location.Address;
import android.location.Location;
import android.os.Looper;
Expand Down Expand Up @@ -208,25 +209,23 @@ public void createSnapshot(double latitude, double longitude, int mapWidth) {
LatLngBounds latLngBounds = getLatLngBounds(RADIUS, location);
googleMap.moveCamera(CameraUpdateFactory.newLatLngBounds(latLngBounds, 0));
googleMap.setOnMapLoadedCallback(() -> {
mapView.setDrawingCacheEnabled(true);
mapView.measure(View.MeasureSpec.makeMeasureSpec(mapWidth, View.MeasureSpec.EXACTLY),
View.MeasureSpec.makeMeasureSpec(mapWidth, View.MeasureSpec.EXACTLY));
mapView.layout(0, 0, mapWidth, mapWidth);
mapView.buildDrawingCache(true);
Bitmap bitmap = Bitmap.createScaledBitmap(mapView.getDrawingCache(), SNAPSHOT_SIZE, SNAPSHOT_SIZE, true);
mapView.setDrawingCacheEnabled(false);

Bitmap bitmap = Bitmap.createBitmap(mapView.getWidth(), mapView.getHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
mapView.draw(canvas);
bitmap = Bitmap.createScaledBitmap(bitmap, SNAPSHOT_SIZE, SNAPSHOT_SIZE, true);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
int quality = 100;
bitmap.compress(Bitmap.CompressFormat.JPEG, quality, stream);
byte[] byteArray = stream.toByteArray();
logDebug("The bitmaps has " + byteArray.length + " initial size");

while (byteArray.length > MAX_SIZE) {
stream = new ByteArrayOutputStream();
quality -= 10;
bitmap.compress(Bitmap.CompressFormat.JPEG, quality, stream);
byteArray = stream.toByteArray();
}

logDebug("The bitmaps has " + byteArray.length + " final size with quality: " + quality);
sendSnapshot(byteArray, latitude, longitude);
});
Expand Down
1 change: 1 addition & 0 deletions app/src/hms/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@

</application>
<uses-permission android:name="com.huawei.appmarket.service.commondata.permission.GET_COMMON_DATA" />
<uses-permission android:name="com.huawei.permission.SECURITY_DIAGNOSE" />

</manifest>
68 changes: 65 additions & 3 deletions app/src/hms/agconnect-services.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,74 @@
{
"agcgw":{
"backurl":"connect-dre.hispace.hicloud.com",
"url":"connect-dre.dbankcloud.cn",
"websocketbackurl":"connect-ws-dre.hispace.dbankcloud.com",
"websocketurl":"connect-ws-dre.hispace.dbankcloud.cn"
},
"agcgw_all":{
"CN":"connect-drcn.dbankcloud.cn",
"CN_back":"connect-drcn.hispace.hicloud.com",
"DE":"connect-dre.dbankcloud.cn",
"DE_back":"connect-dre.hispace.hicloud.com",
"RU":"connect-drru.dbankcloud.cn",
"RU_back":"connect-drru.hispace.hicloud.com",
"SG":"connect-dra.dbankcloud.cn",
"SG_back":"connect-dra.hispace.hicloud.com"
},
"client":{
"cp_id":"890064000023000226",
"product_id":"9105385871709201844",
"client_id":"336506096061514880",
"client_secret":"1D8B6BACC69B2CD7D27FB9AE682A5856E8CE0240AB2A1637673E6DBF2192EBF1",
"project_id":"9105385871709201844",
"app_id":"102009895",
"api_key":"CV615BpZFQAtZTZJY66AUU/7YiKDxTGnCsWWc80v9oLtnyzUlXriGzSpWqOK3wRcA0Pj07c3mwpA2peCqCFfZcmjhOtk",
"package_name":"mega.privacy.android.app.huawei"
},
"oauth_client":{
"client_id":"102009895",
"client_type":1
},
"app_info":{
"app_id":"102009895",
"package_name":"mega.privacy.android.app.huawei",
"api_key":"CV615BpZFQAtZTZJY66AUU/7YiKDxTGnCsWWc80v9oLtnyzUlXriGzSpWqOK3wRcA0Pj07c3mwpA2peCqCFfZcmjhOtk"
"package_name":"mega.privacy.android.app.huawei"
},
"service":{
"analytics":{
"collector_url":"datacollector-dre.dt.hicloud.com,datacollector-dre.dt.dbankcloud.cn",
"collector_url_ru":"datacollector-drru.dt.hicloud.com,datacollector-drru.dt.dbankcloud.cn",
"collector_url_sg":"datacollector-dra.dt.hicloud.com,datacollector-dra.dt.dbankcloud.cn",
"collector_url_de":"datacollector-dre.dt.hicloud.com,datacollector-dre.dt.dbankcloud.cn",
"collector_url_cn":"datacollector-drcn.dt.hicloud.com,datacollector-drcn.dt.dbankcloud.cn",
"resource_id":"p1",
"channel_id":""
},
"search":{
"url":"https://search-dre.cloud.huawei.com"
},
"cloudstorage":{
"storage_url":"https://ops-dre.agcstorage.link"
},
"ml":{
"mlservice_url":"ml-api-dre.ai.dbankcloud.com,ml-api-dre.ai.dbankcloud.cn"
}
},
"configuration_version":"1.0"
"region":"DE",
"configuration_version":"3.0",
"appInfos":[
{
"package_name":"mega.privacy.android.app.huawei",
"client":{
"app_id":"102009895"
},
"app_info":{
"package_name":"mega.privacy.android.app.huawei",
"app_id":"102009895"
},
"oauth_client":{
"client_type":1,
"client_id":"102009895"
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package mega.privacy.android.app.service.crashreporter

import com.huawei.agconnect.crash.AGConnectCrash
import mega.privacy.android.app.middlelayer.crashreporter.CrashReporter

class CrashReporterImpl : CrashReporter {

private val agConnectCrash = AGConnectCrash.getInstance()

override fun report(e: Throwable) {
agConnectCrash.recordException(e)
}

override fun setEnabled(enabled: Boolean) {
agConnectCrash.enableCrashCollection(enabled)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,23 @@ public void createSnapshot(double latitude, double longitude, int mapWidth) {
// Don't create MapView for HMS, use the existing HuaweiMap object to create snapshot.
mMap.setOnMapLoadedCallback(() -> mMap.snapshot((snapshot) -> {
if (snapshot == null) return;
// crop the snapshot.
snapshot = Bitmap.createBitmap(snapshot, (snapshot.getWidth() - mapWidth) / 2,
(snapshot.getHeight() - mapWidth) / 2, mapWidth, mapWidth);

// Cut out the middle part of the original snapshot.
int x = 0, y = 0;
int w = snapshot.getWidth();
int h = snapshot.getHeight();

if(w > SNAPSHOT_SIZE) {
x = (w - SNAPSHOT_SIZE) / 2;
w = SNAPSHOT_SIZE;
}

if(h > SNAPSHOT_SIZE) {
y = (h - SNAPSHOT_SIZE) / 2;
h = SNAPSHOT_SIZE;
}

snapshot = Bitmap.createBitmap(snapshot, x, y, w, h);

ByteArrayOutputStream stream = new ByteArrayOutputStream();
int quality = 100;
Expand Down Expand Up @@ -174,7 +188,9 @@ public void setMyLocation(boolean animateCamera) {
@Override
public void removeMarker() {
try {
fullScreenMarker.remove();
if (fullScreenMarker != null) {
fullScreenMarker.remove();
}
} catch (Exception e) {
logError(e.getMessage(), e);
e.printStackTrace();
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT" />
<uses-permission android:name="android.permission.USE_BIOMETRIC" />

<!--<uses-permission android:name="android.permission.READ_CALL_LOG"/>-->
<!--<uses-permission android:name="android.permission.WRITE_CALL_LOG"/>-->
Expand All @@ -66,6 +67,9 @@
android:mimeType="application/*"
android:scheme="https" />
</intent>

<!-- Location opened outside the app -->
<package android:name="com.google.android.apps.maps" />
</queries>

<application
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.github.barteksc.pdfviewer.scroll;

import static mega.privacy.android.app.utils.LogUtil.logDebug;
import static mega.privacy.android.app.utils.Util.dp2px;

import android.annotation.SuppressLint;
import android.content.Context;
import android.os.Handler;
Expand All @@ -8,6 +11,7 @@
import android.widget.RelativeLayout;
import android.widget.TextView;

import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.core.content.ContextCompat;

import com.github.barteksc.pdfviewer.PDFView;
Expand All @@ -16,10 +20,7 @@
import mega.privacy.android.app.R;
import mega.privacy.android.app.lollipop.PdfViewerActivityLollipop;

import static mega.privacy.android.app.utils.LogUtil.logDebug;
import static mega.privacy.android.app.utils.Util.dp2px;

public class DefaultScrollHandle extends RelativeLayout implements ScrollHandle {
public class DefaultScrollHandle extends ConstraintLayout implements ScrollHandle {

float motionYOrigin;

Expand Down Expand Up @@ -53,23 +54,27 @@ public DefaultScrollHandle(Context context) {
public void setupLayout(PDFView pdfView) {
logDebug("setupLayout");

RelativeLayout.LayoutParams tvHlp = new RelativeLayout.LayoutParams(dp2px(50), dp2px(50));
ConstraintLayout.LayoutParams textViewHandleLp = new ConstraintLayout.LayoutParams(dp2px(45), dp2px(45));
textViewHandleLp.endToEnd = LayoutParams.PARENT_ID;
textViewHandleLp.topToTop = LayoutParams.PARENT_ID;
textViewHandleLp.bottomToBottom = LayoutParams.PARENT_ID;
textViewHandleLp.setMargins(dp2px(5), dp2px(5), dp2px(-10), dp2px(5));
textViewHandle.setBackgroundResource(R.drawable.fastscroll_pdf_viewer);
tvHlp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
tvHlp.setMargins(dp2px(5), 0, dp2px(-20), 0);
textViewHandle.setPadding(dp2px(10), dp2px(10), dp2px(10), dp2px(10));
addView(textViewHandle, tvHlp);

RelativeLayout.LayoutParams tvBlp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
textViewBubble.setBackgroundResource(R.drawable.fastscroll__pdf_bubble);
textViewHandle.setElevation(dp2px(4));
addView(textViewHandle, textViewHandleLp);

ConstraintLayout.LayoutParams textViewBubbleLp = new ConstraintLayout.LayoutParams(ConstraintLayout.LayoutParams.WRAP_CONTENT, ConstraintLayout.LayoutParams.WRAP_CONTENT);
textViewBubbleLp.endToEnd = LayoutParams.PARENT_ID;
textViewBubbleLp.topToTop = LayoutParams.PARENT_ID;
textViewBubbleLp.bottomToBottom = LayoutParams.PARENT_ID;
textViewBubbleLp.setMargins(0, 0, dp2px(40), 0);
textViewBubble.setBackgroundResource(R.drawable.fastscroll_pdf_bubble);
textViewBubble.setElevation(dp2px(4));
tvBlp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
tvBlp.addRule(RelativeLayout.CENTER_VERTICAL);
textViewBubble.setTextAlignment(TEXT_ALIGNMENT_CENTER);
textViewBubble.setTextColor(ContextCompat.getColor(context, R.color.scroll_bubble_text_color));
textViewBubble.setPadding(dp2px(10), dp2px(5), dp2px(10), dp2px(5));
tvBlp.setMargins(0, 0, dp2px(35), 0);
addView(textViewBubble, tvBlp);
textViewBubble.setPadding(dp2px(10), dp2px(6), dp2px(10), dp2px(6));
addView(textViewBubble, textViewBubbleLp);

RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/java/mega/privacy/android/app/BaseActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@

import dagger.hilt.android.AndroidEntryPoint;
import kotlin.Pair;
import kotlin.Suppress;
import mega.privacy.android.app.globalmanagement.MyAccountInfo;
import mega.privacy.android.app.interfaces.ActivityLauncher;
import mega.privacy.android.app.interfaces.PermissionRequester;
Expand Down Expand Up @@ -749,6 +750,9 @@ public void showSnackbar (int type, View view, View anchor, String s, long idCha
case SNACKBAR_IMCOMPATIBILITY_TYPE:
snackbar = Snackbar.make(view, !isTextEmpty(s) ? s : getString(R.string.sent_as_message), Snackbar.LENGTH_INDEFINITE);
break;
case DISMISS_ACTION_SNACKBAR:
snackbar = Snackbar.make(view, s, Snackbar.LENGTH_INDEFINITE);
break;
default:
snackbar = Snackbar.make(view, s, Snackbar.LENGTH_LONG);
break;
Expand Down Expand Up @@ -810,6 +814,11 @@ public void showSnackbar (int type, View view, View anchor, String s, long idCha
snackbar.show();
break;
}

case DISMISS_ACTION_SNACKBAR:
snackbar.setAction(R.string.general_ok, new SnackbarNavigateOption(view.getContext(), type));
snackbar.show();
break;
}
}

Expand Down Expand Up @@ -1247,6 +1256,7 @@ public void launchActivity(@NotNull Intent intent) {
}

@Override
@SuppressWarnings("deprecation") // TODO Migrate to registerForActivityResult()
public void launchActivityForResult(@NotNull Intent intent, int requestCode) {
startActivityForResult(intent, requestCode);
}
Expand Down
Loading

0 comments on commit 42859a0

Please sign in to comment.