Skip to content

Commit

Permalink
Merge branch 'main' into rotate_feature
Browse files Browse the repository at this point in the history
  • Loading branch information
shankarpriyank authored Sep 26, 2023
2 parents 6bb3667 + a2ad039 commit 8db0ed2
Show file tree
Hide file tree
Showing 98 changed files with 1,902 additions and 614 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2.4.0
uses: actions/checkout@v3

- name: Set up JDK
uses: actions/setup-java@v2.5.0
uses: actions/setup-java@v3
with:
distribution: "temurin"
java-version: 17

- name: Cache packages
id: cache-packages
uses: actions/cache@v2.1.7
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
Expand All @@ -37,7 +37,7 @@ jobs:
- name: AVD cache
if: github.event_name != 'pull_request'
uses: actions/cache@v2
uses: actions/cache@v3
id: avd-cache
with:
path: |
Expand Down Expand Up @@ -89,7 +89,7 @@ jobs:
run: bash ./gradlew assembleBetaDebug --stacktrace

- name: Upload betaDebug APK
uses: actions/upload-artifact@v2.3.1
uses: actions/upload-artifact@v3
with:
name: betaDebugAPK
path: app/build/outputs/apk/beta/debug/app-*.apk
Expand All @@ -98,7 +98,7 @@ jobs:
run: bash ./gradlew assembleProdDebug --stacktrace

- name: Upload prodDebug APK
uses: actions/upload-artifact@v2.3.1
uses: actions/upload-artifact@v3
with:
name: prodDebugAPK
path: app/build/outputs/apk/prod/debug/app-*.apk
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ dependencies {

implementation "androidx.multidex:multidex:$MULTIDEX_VERSION"

def work_version = "2.8.0"
def work_version = "2.8.1"
// Kotlin + coroutines
implementation "androidx.work:work-runtime-ktx:$work_version"
implementation("androidx.work:work-runtime:$work_version")
Expand Down Expand Up @@ -181,7 +181,7 @@ android {
setProperty("archivesBaseName", "app-commons-v$versionName-" + getBranchName())

minSdkVersion 21
targetSdkVersion 31
targetSdkVersion 33
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
testInstrumentationRunnerArguments clearPackageData: 'true'

Expand Down
2 changes: 2 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
<uses-permission android:name="android.permission.MANAGE_ACCOUNTS" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES"/>
<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" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@
import fr.free.nrw.commons.R;
import fr.free.nrw.commons.Utils;
import fr.free.nrw.commons.kvstore.JsonKvStore;
import fr.free.nrw.commons.location.LocationPermissionsHelper;
import fr.free.nrw.commons.location.LocationPermissionsHelper.Dialog;
import fr.free.nrw.commons.location.LocationPermissionsHelper.LocationPermissionCallback;
import fr.free.nrw.commons.location.LocationServiceManager;
import fr.free.nrw.commons.theme.BaseActivity;
import fr.free.nrw.commons.utils.SystemThemeUtils;
import javax.inject.Inject;
Expand Down Expand Up @@ -148,6 +152,9 @@ public class LocationPickerActivity extends BaseActivity implements OnMapReadyCa
SystemThemeUtils systemThemeUtils;
private boolean isDarkTheme;

@Inject
LocationServiceManager locationManager;

@Override
protected void onCreate(@Nullable final Bundle savedInstanceState) {
getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
Expand Down Expand Up @@ -452,11 +459,43 @@ private void addCenterOnGPSButton(){
fabCenterOnLocation = findViewById(R.id.center_on_gps);
fabCenterOnLocation.setOnClickListener(view -> getCenter());
}

/**
* Animate map to move to desired Latitude and Longitude
* Center the map at user's current location
*/
void getCenter() {
mapboxMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(location.getLatitude(),location.getLongitude()),15.0));
private void getCenter() {
LocationPermissionsHelper.Dialog locationAccessDialog = new Dialog(
R.string.location_permission_title,
R.string.upload_map_location_access
);

LocationPermissionsHelper.Dialog locationOffDialog = new Dialog(
R.string.ask_to_turn_location_on,
R.string.upload_map_location_access
);
LocationPermissionsHelper locationPermissionsHelper = new LocationPermissionsHelper(
this, locationManager, new LocationPermissionCallback() {
@Override
public void onLocationPermissionDenied(String toastMessage) {
// Do nothing
}

@Override
public void onLocationPermissionGranted() {
fr.free.nrw.commons.location.LatLng currLocation = locationManager.getLastLocation();
if (currLocation != null) {
final CameraPosition position;
position = new CameraPosition.Builder()
.target(new com.mapbox.mapboxsdk.geometry.LatLng(currLocation.getLatitude(),
currLocation.getLongitude(), 0)) // Sets the new camera position
.zoom(mapboxMap.getCameraPosition().zoom) // Same zoom level
.build();

mapboxMap.animateCamera(CameraUpdateFactory.newCameraPosition(position), 1000);
}
}
});
locationPermissionsHelper.handleLocationPermissions(locationAccessDialog, locationOffDialog);
}

@Override
Expand Down
18 changes: 18 additions & 0 deletions app/src/main/java/fr/free/nrw/commons/auth/SignupActivity.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package fr.free.nrw.commons.auth;

import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import android.webkit.WebSettings;
import android.webkit.WebView;
Expand Down Expand Up @@ -61,4 +63,20 @@ public void onBackPressed() {
super.onBackPressed();
}
}

/**
* Known bug in androidx.appcompat library version 1.1.0 being tracked here
* https://issuetracker.google.com/issues/141132133
* App tries to put light/dark theme to webview and crashes in the process
* This code tries to prevent applying the theme when sdk is between api 21 to 25
* @param overrideConfiguration
*/
@Override
public void applyOverrideConfiguration(final Configuration overrideConfiguration) {
if (Build.VERSION.SDK_INT <= 25 &&
(getResources().getConfiguration().uiMode == getApplicationContext().getResources().getConfiguration().uiMode)) {
return;
}
super.applyOverrideConfiguration(overrideConfiguration);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public Integer getContributionStateAt(int position) {
public void refreshNominatedMedia(int index) {
if (mediaDetails != null && !listFragment.isVisible()) {
removeFragment(mediaDetails);
mediaDetails = new MediaDetailPagerFragment(false, true);
mediaDetails = MediaDetailPagerFragment.newInstance(false, true);
((BookmarkFragment) getParentFragment()).setScroll(false);
setFragment(mediaDetails, listFragment);
mediaDetails.showImage(index);
Expand Down Expand Up @@ -243,7 +243,7 @@ public void onItemClick(AdapterView<?> parent, View view, int position, long id)
Log.d("deneme8", "on media clicked");
container.setVisibility(View.VISIBLE);
((BookmarkFragment) getParentFragment()).tabLayout.setVisibility(View.GONE);
mediaDetails = new MediaDetailPagerFragment(false, true);
mediaDetails = MediaDetailPagerFragment.newInstance(false, true);
((BookmarkFragment) getParentFragment()).setScroll(false);
setFragment(mediaDetails, listFragment);
mediaDetails.showImage(position);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public void onMediaClicked(int position) {
mediaContainer.setVisibility(View.VISIBLE);
if (mediaDetails == null || !mediaDetails.isVisible()) {
// set isFeaturedImage true for featured images, to include author field on media detail
mediaDetails = new MediaDetailPagerFragment(false, true);
mediaDetails = MediaDetailPagerFragment.newInstance(false, true);
FragmentManager supportFragmentManager = getSupportFragmentManager();
supportFragmentManager
.beginTransaction()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ data class Contribution constructor(
var hasInvalidLocation : Int = 0,
var contentUri: Uri? = null,
var countryCode : String? = null,
var imageSHA1 : String? = null
var imageSHA1 : String? = null,
/**
* Number of times a contribution has been retried after a failure
*/
var retries: Int = 0
) : Parcelable {

fun completeWith(media: Media): Contribution {
Expand Down Expand Up @@ -111,6 +115,6 @@ data class Contribution constructor(
*/
fun formatDescriptions(descriptions: List<UploadMediaDetail>) =
descriptions.filter { it.descriptionText.isNotEmpty() }
.joinToString { "{{${it.languageCode}|1=${it.descriptionText}}}" }
.joinToString(separator = "") { "{{${it.languageCode}|1=${it.descriptionText}}}" }
}
}
Loading

0 comments on commit 8db0ed2

Please sign in to comment.