Skip to content

Commit

Permalink
Merge branch 'main' into hide-voice-input-when-not-available
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-raoul authored Oct 27, 2024
2 parents 22d8f54 + 522f1fe commit 3bf48a8
Show file tree
Hide file tree
Showing 144 changed files with 645 additions and 606 deletions.
3 changes: 1 addition & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@
android:exported="true"
android:hardwareAccelerated="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:windowSoftInputMode="adjustResize">
<intent-filter android:label="@string/intent_share_upload_label">
<action android:name="android.intent.action.SEND" />
Expand All @@ -122,7 +121,7 @@
android:name=".contributions.MainActivity"
android:configChanges="screenSize|keyboard|orientation"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name" />
/>
<activity
android:name=".settings.SettingsActivity"
android:label="@string/title_activity_settings" />
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/fr/free/nrw/commons/BaseMarker.kt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class BaseMarker {
val drawable: Drawable = context.resources.getDrawable(drawableResId)
icon =
if (drawable is BitmapDrawable) {
(drawable as BitmapDrawable).bitmap
drawable.bitmap
} else {
val bitmap =
Bitmap.createBitmap(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
import java.util.List;
import java.util.Locale;
import javax.inject.Inject;
import javax.inject.Named;
import org.osmdroid.tileprovider.tilesource.TileSourceFactory;
Expand Down Expand Up @@ -301,7 +302,8 @@ private void bindViews() {
modifyLocationButton = findViewById(R.id.modify_location);
removeLocationButton = findViewById(R.id.remove_location);
showInMapButton = findViewById(R.id.show_in_map);
showInMapButton.setText(getResources().getString(R.string.show_in_map_app).toUpperCase());
showInMapButton.setText(getResources().getString(R.string.show_in_map_app).toUpperCase(
Locale.ROOT));
shadow = findViewById(R.id.location_picker_image_view_shadow);
}

Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/fr/free/nrw/commons/Media.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package fr.free.nrw.commons
import android.os.Parcelable
import fr.free.nrw.commons.location.LatLng
import fr.free.nrw.commons.wikidata.model.page.PageTitle
import kotlinx.parcelize.IgnoredOnParcel
import kotlinx.parcelize.Parcelize
import java.util.Date
import java.util.Locale
Expand Down Expand Up @@ -124,6 +125,7 @@ class Media constructor(
* Gets the categories the file falls under.
* @return file categories as an ArrayList of Strings
*/
@IgnoredOnParcel
var addedCategories: List<String>? = null
// TODO added categories should be removed. It is added for a short fix. On category update,
// categories should be re-fetched instead
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package fr.free.nrw.commons.bookmarks.items;

import android.annotation.SuppressLint;
import android.content.ContentProviderClient;
import android.content.ContentValues;
import android.database.Cursor;
Expand Down Expand Up @@ -134,6 +135,7 @@ public boolean findBookmarkItem(final String depictedItemID) {
* @param cursor : Object for storing database data
* @return DepictedItem
*/
@SuppressLint("Range")
DepictedItem fromCursor(final Cursor cursor) {
final String fileName = cursor.getString(cursor.getColumnIndex(Table.COLUMN_NAME));
final String description
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package fr.free.nrw.commons.bookmarks.locations;

import android.annotation.SuppressLint;
import android.content.ContentProviderClient;
import android.content.ContentValues;
import android.database.Cursor;
Expand Down Expand Up @@ -146,6 +147,7 @@ public boolean findBookmarkLocation(Place bookmarkLocation) {
return false;
}

@SuppressLint("Range")
@NonNull
Place fromCursor(final Cursor cursor) {
final LatLng location = new LatLng(cursor.getDouble(cursor.getColumnIndex(Table.COLUMN_LAT)),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package fr.free.nrw.commons.bookmarks.pictures;

import android.annotation.SuppressLint;
import android.content.ContentProviderClient;
import android.content.ContentValues;
import android.database.Cursor;
Expand Down Expand Up @@ -150,6 +151,7 @@ public boolean findBookmark(Bookmark bookmark) {
return false;
}

@SuppressLint("Range")
@NonNull
Bookmark fromCursor(Cursor cursor) {
String fileName = cursor.getString(cursor.getColumnIndex(Table.COLUMN_MEDIA_NAME));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class CategoryClient
}.map {
it
.filter { page ->
page.categoryInfo() == null || !page.categoryInfo().isHidden
!page.categoryInfo().isHidden
}.map {
CategoryItem(
it.title().replace(CATEGORY_PREFIX, ""),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package fr.free.nrw.commons.category;

import android.annotation.SuppressLint;
import android.content.ContentProviderClient;
import android.content.ContentValues;
import android.database.Cursor;
Expand Down Expand Up @@ -111,6 +112,7 @@ List<CategoryItem> recentCategories(int limit) {
}

@NonNull
@SuppressLint("Range")
Category fromCursor(Cursor cursor) {
// Hardcoding column positions!
return new Category(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class WikipediaInstructionsDialogFragment : DialogFragment() {
) = DialogAddToWikipediaInstructionsBinding
.inflate(inflater, container, false)
.apply {
val contribution: Contribution? = arguments!!.getParcelable(ARG_CONTRIBUTION)
val contribution: Contribution? = requireArguments().getParcelable(ARG_CONTRIBUTION)
tvWikicode.setText(contribution?.media?.wikiCode)
instructionsCancel.setOnClickListener { dismiss() }
instructionsConfirm.setOnClickListener {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@ abstract class NotForUploadStatusDao {
* Insert into Not For Upload status.
*/
@Insert(onConflict = OnConflictStrategy.REPLACE)
abstract fun insert(notForUploadStatus: NotForUploadStatus)
abstract suspend fun insert(notForUploadStatus: NotForUploadStatus)

/**
* Delete Not For Upload status entry.
*/
@Delete
abstract fun delete(notForUploadStatus: NotForUploadStatus)
abstract suspend fun delete(notForUploadStatus: NotForUploadStatus)

/**
* Query Not For Upload status with image sha1.
*/
@Query("SELECT * FROM images_not_for_upload_table WHERE imageSHA1 = (:imageSHA1) ")
abstract fun getFromImageSHA1(imageSHA1: String): NotForUploadStatus?
abstract suspend fun getFromImageSHA1(imageSHA1: String): NotForUploadStatus?

/**
* Asynchronous image sha1 query.
Expand All @@ -38,7 +38,7 @@ abstract class NotForUploadStatusDao {
* Deletion Not For Upload status with image sha1.
*/
@Query("DELETE FROM images_not_for_upload_table WHERE imageSHA1 = (:imageSHA1) ")
abstract fun deleteWithImageSHA1(imageSHA1: String)
abstract suspend fun deleteWithImageSHA1(imageSHA1: String)

/**
* Asynchronous image sha1 deletion.
Expand All @@ -49,5 +49,5 @@ abstract class NotForUploadStatusDao {
* Check whether the imageSHA1 is present in database
*/
@Query("SELECT COUNT() FROM images_not_for_upload_table WHERE imageSHA1 = (:imageSHA1) ")
abstract fun find(imageSHA1: String): Int
abstract suspend fun find(imageSHA1: String): Int
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,31 @@ abstract class UploadedStatusDao {
* Insert into uploaded status.
*/
@Insert(onConflict = OnConflictStrategy.REPLACE)
abstract fun insert(uploadedStatus: UploadedStatus)
abstract suspend fun insert(uploadedStatus: UploadedStatus)

/**
* Update uploaded status entry.
*/
@Update
abstract fun update(uploadedStatus: UploadedStatus)
abstract suspend fun update(uploadedStatus: UploadedStatus)

/**
* Delete uploaded status entry.
*/
@Delete
abstract fun delete(uploadedStatus: UploadedStatus)
abstract suspend fun delete(uploadedStatus: UploadedStatus)

/**
* Query uploaded status with image sha1.
*/
@Query("SELECT * FROM uploaded_table WHERE imageSHA1 = (:imageSHA1) ")
abstract fun getFromImageSHA1(imageSHA1: String): UploadedStatus?
abstract suspend fun getFromImageSHA1(imageSHA1: String): UploadedStatus?

/**
* Query uploaded status with modified image sha1.
*/
@Query("SELECT * FROM uploaded_table WHERE modifiedImageSHA1 = (:modifiedImageSHA1) ")
abstract fun getFromModifiedImageSHA1(modifiedImageSHA1: String): UploadedStatus?
abstract suspend fun getFromModifiedImageSHA1(modifiedImageSHA1: String): UploadedStatus?

/**
* Asynchronous insert into uploaded status table.
Expand All @@ -55,7 +55,7 @@ abstract class UploadedStatusDao {
* Check whether the imageSHA1 is present in database
*/
@Query("SELECT COUNT() FROM uploaded_table WHERE imageSHA1 = (:imageSHA1) AND imageResult = (:imageResult) ")
abstract fun findByImageSHA1(
abstract suspend fun findByImageSHA1(
imageSHA1: String,
imageResult: Boolean,
): Int
Expand All @@ -66,7 +66,7 @@ abstract class UploadedStatusDao {
@Query(
"SELECT COUNT() FROM uploaded_table WHERE modifiedImageSHA1 = (:modifiedImageSHA1) AND modifiedImageResult = (:modifiedImageResult) ",
)
abstract fun findByModifiedImageSHA1(
abstract suspend fun findByModifiedImageSHA1(
modifiedImageSHA1: String,
modifiedImageResult: Boolean,
): Int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import fr.free.nrw.commons.utils.CustomSelectorUtils
import fr.free.nrw.commons.utils.CustomSelectorUtils.Companion.checkWhetherFileExistsOnCommonsUsingSHA1
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.MainScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import java.util.Calendar
import java.util.concurrent.TimeUnit
Expand Down Expand Up @@ -65,7 +65,7 @@ class ImageLoader
/**
* Coroutine Scope.
*/
private val scope: CoroutineScope = MainScope()
private val scope: CoroutineScope = CoroutineScope(Dispatchers.IO)

/**
* Query image and setUp the view.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ class DescriptionEditActivity :
) {
try {
descriptionEditHelper
?.addDescription(
.addDescription(
applicationContext,
media,
updatedWikiText,
Expand All @@ -251,7 +251,7 @@ class DescriptionEditActivity :
)
}
} catch (e: InvalidLoginTokenException) {
val username: String? = sessionManager?.userName
val username: String? = sessionManager.userName
val logoutListener =
CommonsApplication.BaseLogoutListener(
this,
Expand All @@ -269,7 +269,7 @@ class DescriptionEditActivity :
for (mediaDetail in uploadMediaDetails) {
try {
compositeDisposable.add(
descriptionEditHelper!!
descriptionEditHelper
.addCaption(
applicationContext,
media,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ class TransformImageImpl : TransformImage {
} catch (e: LLJTranException) {
Timber.tag("Error").d(e)
return null
false
}

if (rotated) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import fr.free.nrw.commons.utils.ActivityUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import javax.inject.Inject;
import javax.inject.Named;

Expand Down Expand Up @@ -112,13 +113,13 @@ public void setTabs() {
mobileRootFragment = new ExploreListRootFragment(mobileArguments);
mapRootFragment = new ExploreMapRootFragment(mapArguments);
fragmentList.add(featuredRootFragment);
titleList.add(getString(R.string.explore_tab_title_featured).toUpperCase());
titleList.add(getString(R.string.explore_tab_title_featured).toUpperCase(Locale.ROOT));

fragmentList.add(mobileRootFragment);
titleList.add(getString(R.string.explore_tab_title_mobile).toUpperCase());
titleList.add(getString(R.string.explore_tab_title_mobile).toUpperCase(Locale.ROOT));

fragmentList.add(mapRootFragment);
titleList.add(getString(R.string.explore_tab_title_map).toUpperCase());
titleList.add(getString(R.string.explore_tab_title_map).toUpperCase(Locale.ROOT));

((MainActivity)getActivity()).showTabs();
((BaseActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.concurrent.TimeUnit;
import javax.inject.Inject;
import timber.log.Timber;
Expand Down Expand Up @@ -95,11 +96,11 @@ public void setTabs() {
searchDepictionsFragment = new SearchDepictionsFragment();
searchCategoryFragment= new SearchCategoryFragment();
fragmentList.add(searchMediaFragment);
titleList.add(getResources().getString(R.string.search_tab_title_media).toUpperCase());
titleList.add(getResources().getString(R.string.search_tab_title_media).toUpperCase(Locale.ROOT));
fragmentList.add(searchCategoryFragment);
titleList.add(getResources().getString(R.string.search_tab_title_categories).toUpperCase());
titleList.add(getResources().getString(R.string.search_tab_title_categories).toUpperCase(Locale.ROOT));
fragmentList.add(searchDepictionsFragment);
titleList.add(getResources().getString(R.string.search_tab_title_depictions).toUpperCase());
titleList.add(getResources().getString(R.string.search_tab_title_depictions).toUpperCase(Locale.ROOT));

viewPagerAdapter.setTabData(fragmentList, titleList);
viewPagerAdapter.notifyDataSetChanged();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ class CategoriesMediaFragment : PageableMediaFragment() {
savedInstanceState: Bundle?,
) {
super.onViewCreated(view, savedInstanceState)
onQueryUpdated("$CATEGORY_PREFIX${arguments!!.getString("categoryName")!!}")
onQueryUpdated("$CATEGORY_PREFIX${requireArguments().getString("categoryName")!!}")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ class ParentCategoriesFragment : PageableCategoryFragment() {
savedInstanceState: Bundle?,
) {
super.onViewCreated(view, savedInstanceState)
onQueryUpdated("$CATEGORY_PREFIX${arguments!!.getString("categoryName")!!}")
onQueryUpdated("$CATEGORY_PREFIX${requireArguments().getString("categoryName")!!}")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ class SubCategoriesFragment : PageableCategoryFragment() {
savedInstanceState: Bundle?,
) {
super.onViewCreated(view, savedInstanceState)
onQueryUpdated("$CATEGORY_PREFIX${arguments!!.getString("categoryName")!!}")
onQueryUpdated("$CATEGORY_PREFIX${requireArguments().getString("categoryName")!!}")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ class ChildDepictionsFragment : PageableDepictionsFragment() {
override val injectedPresenter
get() = presenter

override fun getEmptyText(query: String) = getString(R.string.no_child_classes, arguments!!.getString("wikidataItemName")!!)
override fun getEmptyText(query: String) = getString(R.string.no_child_classes, requireArguments().getString("wikidataItemName")!!)

override fun onViewCreated(
view: View,
savedInstanceState: Bundle?,
) {
super.onViewCreated(view, savedInstanceState)
onQueryUpdated(arguments!!.getString("entityId")!!)
onQueryUpdated(requireArguments().getString("entityId")!!)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ class DepictedImagesFragment : PageableMediaFragment() {
savedInstanceState: Bundle?,
) {
super.onViewCreated(view, savedInstanceState)
onQueryUpdated(arguments!!.getString("entityId")!!)
onQueryUpdated(requireArguments().getString("entityId")!!)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ class ParentDepictionsFragment : PageableDepictionsFragment() {
override val injectedPresenter
get() = presenter

override fun getEmptyText(query: String) = getString(R.string.no_parent_classes, arguments!!.getString("wikidataItemName")!!)
override fun getEmptyText(query: String) = getString(R.string.no_parent_classes, requireArguments().getString("wikidataItemName")!!)

override fun onViewCreated(
view: View,
savedInstanceState: Bundle?,
) {
super.onViewCreated(view, savedInstanceState)
onQueryUpdated(arguments!!.getString("entityId")!!)
onQueryUpdated(requireArguments().getString("entityId")!!)
}
}
Loading

0 comments on commit 3bf48a8

Please sign in to comment.