Fixes #4447 1. Updated SDK version to 30 2. Updated WorkManager's version (#4677) (#4692)

This commit is contained in:
Ashish 2021-10-28 11:42:25 +05:30 committed by GitHub
parent ce8d10ea8f
commit b4bfc6c5a3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 30 additions and 4 deletions

View file

@ -139,7 +139,7 @@ dependencies {
implementation "androidx.multidex:multidex:$MULTIDEX_VERSION"
def work_version = "2.4.0"
def work_version = "2.6.0"
// Kotlin + coroutines
implementation "androidx.work:work-runtime-ktx:$work_version"
testImplementation "androidx.work:work-testing:$work_version"
@ -150,7 +150,7 @@ dependencies {
}
android {
compileSdkVersion 29
compileSdkVersion 30
defaultConfig {
//applicationId 'fr.free.nrw.commons'
@ -160,7 +160,7 @@ android {
setProperty("archivesBaseName", "app-commons-v$versionName-" + getBranchName())
minSdkVersion 19
targetSdkVersion 29
targetSdkVersion 30
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
testInstrumentationRunnerArguments clearPackageData: 'true'

View file

@ -17,6 +17,8 @@
<uses-permission android:name="com.google.android.apps.photos.permission.GOOGLE_PHOTOS" />
<uses-permission android:name="android.permission.SET_WALLPAPER"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<!-- Needed only if your app targets Android 5.0 (API level 21) or higher. -->

View file

@ -1,9 +1,13 @@
package fr.free.nrw.commons.contributions;
import android.Manifest.permission;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.os.Build.VERSION;
import android.os.Build.VERSION_CODES;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
@ -42,6 +46,7 @@ import fr.free.nrw.commons.quiz.QuizChecker;
import fr.free.nrw.commons.settings.SettingsFragment;
import fr.free.nrw.commons.theme.BaseActivity;
import fr.free.nrw.commons.upload.worker.UploadWorker;
import fr.free.nrw.commons.utils.PermissionUtils;
import fr.free.nrw.commons.utils.ViewUtilWrapper;
import javax.inject.Inject;
import javax.inject.Named;
@ -138,6 +143,16 @@ public class MainActivity extends BaseActivity
private void setUpPager() {
tabLayout.setOnNavigationItemSelectedListener(item -> {
if (VERSION.SDK_INT >= VERSION_CODES.M) {
if (item.getTitle().equals(getString(R.string.nearby_fragment))
&& checkSelfPermission(permission.READ_PHONE_STATE)
!= PackageManager.PERMISSION_GRANTED) {
requestPhoneStatePermission(() -> {
tabLayout.setSelectedItemId(NavTab.NEARBY.code());
});
return false;
}
}
if (!item.getTitle().equals(getString(R.string.more))) {
// do not change title for more fragment
setTitle(item.getTitle());
@ -147,6 +162,12 @@ public class MainActivity extends BaseActivity
});
}
private void requestPhoneStatePermission(final Runnable runnable) {
PermissionUtils.checkPermissionsAndPerformAction(this,
android.Manifest.permission.READ_PHONE_STATE, (Runnable) runnable::run, (Runnable) () -> {
}, R.string.need_permission, R.string.read_phone_state_permission_message);
}
private void setUpLoggedOutPager() {
loadFragment(ExploreFragment.newInstance(),false);
tabLayout.setOnNavigationItemSelectedListener(item -> {

View file

@ -657,6 +657,9 @@ Upload your first media by tapping on the add button.</string>
<string name="learn_more">LEARN MORE</string>
<string name="wlm_campaign_title">Wiki Loves Monuments</string>
<string name="wlm_campaign_description">Wiki Loves Monuments is an international photo contest for monuments organised by Wikimedia</string>
<string name="need_permission">Need Permission</string>
<string name="read_phone_state_permission_message">Nearby maps need to read PHONE STATE to function properly</string>
<string name="contributions_of_user">Contributions of User: %s</string>
<string name="achievements_of_user">Achievements of User: %s</string>
<string name="menu_view_user_page">View user page</string>