diff --git a/app/src/main/java/fr/free/nrw/commons/bookmarks/items/BookmarkItemsDao.kt b/app/src/main/java/fr/free/nrw/commons/bookmarks/items/BookmarkItemsDao.kt index bfb3ec764..e21e1ac8f 100644 --- a/app/src/main/java/fr/free/nrw/commons/bookmarks/items/BookmarkItemsDao.kt +++ b/app/src/main/java/fr/free/nrw/commons/bookmarks/items/BookmarkItemsDao.kt @@ -173,19 +173,13 @@ class BookmarkItemsDao @Inject constructor( categoryNameList: List, categoryDescriptionList: List, categoryThumbnailList: List - ): List { - return buildList { - for (i in categoryNameList.indices) { - add( - CategoryItem( - categoryNameList[i], - categoryDescriptionList[i], - categoryThumbnailList[i], - false - ) - ) - } - } + ): List = categoryNameList.mapIndexed { index, name -> + CategoryItem( + name = name, + description = categoryDescriptionList.getOrNull(index), + thumbnail = categoryThumbnailList.getOrNull(index), + isSelected = false + ) } /** diff --git a/app/src/main/java/fr/free/nrw/commons/nearby/NearbyFilterSearchRecyclerViewAdapter.java b/app/src/main/java/fr/free/nrw/commons/nearby/NearbyFilterSearchRecyclerViewAdapter.java index b5f760c9f..53e9970a6 100644 --- a/app/src/main/java/fr/free/nrw/commons/nearby/NearbyFilterSearchRecyclerViewAdapter.java +++ b/app/src/main/java/fr/free/nrw/commons/nearby/NearbyFilterSearchRecyclerViewAdapter.java @@ -91,6 +91,7 @@ public class NearbyFilterSearchRecyclerViewAdapter label.setSelected(!label.isSelected()); holder.placeTypeLayout.setSelected(label.isSelected()); + NearbyFilterState.setSelectedLabels(new ArrayList<>(selectedLabels)); callback.filterByMarkerType(selectedLabels, 0, false, false); }); } @@ -152,6 +153,7 @@ public class NearbyFilterSearchRecyclerViewAdapter label.setSelected(false); selectedLabels.remove(label); } + NearbyFilterState.setSelectedLabels(new ArrayList<>(selectedLabels)); notifyDataSetChanged(); } @@ -163,6 +165,7 @@ public class NearbyFilterSearchRecyclerViewAdapter selectedLabels.add(label); } } + NearbyFilterState.setSelectedLabels(new ArrayList<>(selectedLabels)); notifyDataSetChanged(); } diff --git a/app/src/main/java/fr/free/nrw/commons/nearby/fragments/NearbyParentFragment.kt b/app/src/main/java/fr/free/nrw/commons/nearby/fragments/NearbyParentFragment.kt index 5c991f465..3e6e71511 100644 --- a/app/src/main/java/fr/free/nrw/commons/nearby/fragments/NearbyParentFragment.kt +++ b/app/src/main/java/fr/free/nrw/commons/nearby/fragments/NearbyParentFragment.kt @@ -881,6 +881,12 @@ class NearbyParentFragment : CommonsDaggerSupportFragment(), fun initNearbyFilter() { binding!!.nearbyFilterList.root.visibility = View.GONE hideBottomSheet() + binding!!.nearbyFilter.searchViewLayout.searchView.apply { + setIconifiedByDefault(false) + isIconified = false + setQuery("", false) + clearFocus() + } binding!!.nearbyFilter.searchViewLayout.searchView.setOnQueryTextFocusChangeListener { v, hasFocus -> setLayoutHeightAlignedToWidth( 1.25, @@ -924,6 +930,7 @@ class NearbyParentFragment : CommonsDaggerSupportFragment(), return _isDarkTheme } }) + restoreStoredFilterSelection() binding!!.nearbyFilterList.root .layoutParams.width = getScreenWidth( requireActivity(), @@ -942,6 +949,22 @@ class NearbyParentFragment : CommonsDaggerSupportFragment(), }) } + private fun restoreStoredFilterSelection() { + val adapter = nearbyFilterSearchRecyclerViewAdapter ?: return + val savedLabels = ArrayList(NearbyFilterState.getInstance().selectedLabels) + adapter.selectedLabels.clear() + val savedSet = savedLabels.toSet() + Label.valuesAsList().forEach { label -> + val isSelected = savedSet.contains(label) + label.setSelected(isSelected) + if (isSelected) { + adapter.selectedLabels.add(label) + } + } + NearbyFilterState.setSelectedLabels(ArrayList(adapter.selectedLabels)) + adapter.notifyDataSetChanged() + } + override fun setCheckBoxAction() { binding!!.nearbyFilterList.checkboxTriStates.addAction() binding!!.nearbyFilterList.checkboxTriStates.state = CheckBoxTriStates.UNKNOWN @@ -2987,4 +3010,4 @@ class NearbyParentFragment : CommonsDaggerSupportFragment(), return input.contains("(") || input.contains(")") } } -} \ No newline at end of file +} diff --git a/app/src/main/res/layout/pic_of_day_app_widget.xml b/app/src/main/res/layout/pic_of_day_app_widget.xml index beb3e20d4..53e54a7cf 100644 --- a/app/src/main/res/layout/pic_of_day_app_widget.xml +++ b/app/src/main/res/layout/pic_of_day_app_widget.xml @@ -46,6 +46,6 @@ android:id="@+id/appwidget_image" android:layout_width="match_parent" android:layout_height="wrap_content" - android:contentDescription="@string/appwidget_img" /> + android:contentDescription="@string/appwidget_img" /> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 064b197e4..996d0edba 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -34,12 +34,12 @@ Starting Uploads - Processing %d upload - Processing %d uploads + Processing %1$d upload + Processing %1$d uploads - %d upload - %d uploads + %1$d upload + %1$d uploads This image will be licensed under %1$s @@ -83,7 +83,7 @@ Upload queued (limited connection mode enabled) %1$s uploaded! Tap to view your upload - Uploading file: %s + Uploading file: %1$s %1$s uploading Finishing uploading %1$s Failed to upload %1$s @@ -233,8 +233,8 @@ Llamas Rainbow Bridge Tulip - Welcome Wikipedia - Welcome Copyright + A schematic image of a generic Wikipedia article. + A drawing of a stack of papers with the copyright symbol crossed out. Sydney Opera House Cancel Open @@ -388,9 +388,9 @@ Thanks Received Featured Images Images via \"Nearby Places\" - Level %d - %s (Level %s) - %s (%s) + Level %1$d + %1$s (Level %2$s) + %1$s (%2$s) Images Uploaded Images Not Reverted Images Used @@ -610,7 +610,7 @@ Upload your first media by tapping on the add button. Share image via You haven\'t made any contributions yet - %s has not made any contributions yet + %1$s has not made any contributions yet Account created! Text copied to clipboard Notification marked as read @@ -757,8 +757,8 @@ Upload your first media by tapping on the add button. Please turn on location services to view nearby places. Location access is needed to show nearby places on the map. - Contributions of User: %s - Achievements of User: %s + Contributions of User: %1$s + Achievements of User: %1$s View user profile Edit depictions Edit categories @@ -834,8 +834,8 @@ Upload your first media by tapping on the add button. Saving as a KML file... Saving as a GPX file... - %d image selected - %d images selected + %1$d image selected + %1$d images selected Please remember that all images in a multi-upload get the same categories and depictions. If the images do not share depictions and categories, please perform several separate uploads. Note about multi-uploads diff --git a/app/src/main/res/xml/wikimedia_licenses.xml b/app/src/main/res/xml/wikimedia_licenses.xml deleted file mode 100644 index b9ac19124..000000000 --- a/app/src/main/res/xml/wikimedia_licenses.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/update-license-info/Makefile b/update-license-info/Makefile deleted file mode 100644 index a6c96ee2a..000000000 --- a/update-license-info/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -.FAKE : build update clean install - -build : ../app/src/main/res/xml/wikimedia_licenses.xml - -../app/src/main/res/xml/wikimedia_licenses.xml : licenses.php mediawiki-extensions-UploadWizard - php licenses.php > ../app/src/main/res/xml/wikimedia_licenses.xml - -mediawiki-extensions-UploadWizard : update - -update : - if [ -d mediawiki-extensions-UploadWizard ]; then (cd mediawiki-extensions-UploadWizard && git pull origin master); else git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/UploadWizard mediawiki-extensions-UploadWizard; fi - -clean : - rm -rf mediawiki-extensions-UploadWizard diff --git a/update-license-info/include-stubs.php b/update-license-info/include-stubs.php deleted file mode 100644 index c0a01a0d6..000000000 --- a/update-license-info/include-stubs.php +++ /dev/null @@ -1,68 +0,0 @@ - 'English' ); - } -} -$wgMemc = new FakeMemc(); - -class FakeMessage { - function plain() { - return 'stub-message-plain'; - } - function parse() { - return 'stub-message-parsed'; - } -} - -function wfMessage() { - return new FakeMessage(); -} - -/** - * Converts shorthand byte notation to integer form - * - * @param $string String - * @return Integer - */ -function wfShorthandToInteger( $string = '' ) { - $string = trim( $string ); - if ( $string === '' ) { - return -1; - } - $last = $string[strlen( $string ) - 1]; - $val = intval( $string ); - switch ( $last ) { - case 'g': - case 'G': - $val *= 1024; - // break intentionally missing - case 'm': - case 'M': - $val *= 1024; - // break intentionally missing - case 'k': - case 'K': - $val *= 1024; - } - - return $val; -} - -$wgAPIModules = array(); diff --git a/update-license-info/licenses.php b/update-license-info/licenses.php deleted file mode 100644 index badda1a08..000000000 --- a/update-license-info/licenses.php +++ /dev/null @@ -1,71 +0,0 @@ - -// 2013-09-30 - -require 'include-stubs.php'; -$config = require "mediawiki-extensions-UploadWizard/UploadWizard.config.php"; -require "mediawiki-extensions-UploadWizard/UploadWizard.i18n.php"; -$licenseList = array(); - -foreach ( $config['licenses'] as $key => $license ) { - // Determine template -> license mappings - if ( isset( $license['templates'] ) ) { - $templates = $license['templates']; - } else { - $templates = array( $key ); - } - - if ( count( $templates ) < 1 ) { - throw new Exception("No templates for $key, this is wrong."); - } - if ( count( $templates ) > 1 ) { - //echo "Skipping multi-template license: $key\n"; - continue; - } - $template = $templates[0]; - if ( preg_match( '/^subst:/i', $template ) ) { - //echo "Skipping subst license: $key\n"; - continue; - } - - $msg = $messages['en'][$license['msg']]; - - $licenseInfo = array( - 'desc' => $msg, - 'template' => $template - ); - if ( isset( $license['url'] ) ) { - $url = $license['url']; - if ( substr( $url, 0, 2 ) == '//' ) { - $url = 'https:' . $url; - } - if ( isset( $license['languageCodePrefix'] ) ) { - $url .= $license['languageCodePrefix'] . '$lang'; - } - $licenseInfo['url'] = $url; - } - $licenseList[$key] = $licenseInfo; -} - -//var_dump( $licenseList ); - -echo "\n"; -echo "\n"; -foreach( $licenseList as $key => $licenseInfo ) { - $encId = htmlspecialchars( $key ); - echo " \n"; - -} -echo "\n"; - \ No newline at end of file