mirror of
				https://github.com/commons-app/apps-android-commons.git
				synced 2025-10-31 14:53:59 +01:00 
			
		
		
		
	
						commit
						15b4831e5d
					
				
					 11 changed files with 81 additions and 35 deletions
				
			
		
							
								
								
									
										7
									
								
								.idea/inspectionProfiles/Project_Default.xml
									
										
									
										generated
									
									
									
								
							
							
						
						
									
										7
									
								
								.idea/inspectionProfiles/Project_Default.xml
									
										
									
										generated
									
									
									
								
							|  | @ -1,16 +1,12 @@ | |||
| <component name="InspectionProjectProfileManager"> | ||||
|   <profile version="1.0"> | ||||
|     <option name="myName" value="Project Default" /> | ||||
|     <inspection_tool class="AndroidLintNewerVersionAvailable" enabled="true" level="WARNING" enabled_by_default="true" /> | ||||
|     <inspection_tool class="AutoCloseableResource" enabled="true" level="WARNING" enabled_by_default="true" /> | ||||
|     <inspection_tool class="ClassWithOnlyPrivateConstructors" enabled="true" level="WARNING" enabled_by_default="true" /> | ||||
|     <inspection_tool class="ConfusingElse" enabled="true" level="WARNING" enabled_by_default="true"> | ||||
|       <option name="reportWhenNoStatementFollow" value="true" /> | ||||
|     </inspection_tool> | ||||
|     <inspection_tool class="ControlFlowStatementWithoutBraces" enabled="true" level="ERROR" enabled_by_default="true" /> | ||||
|     <inspection_tool class="DefaultNotLastCaseInSwitch" enabled="true" level="WARNING" enabled_by_default="true" /> | ||||
|     <inspection_tool class="ExplicitThis" enabled="true" level="WEAK WARNING" enabled_by_default="true" /> | ||||
|     <inspection_tool class="FieldMayBeFinal" enabled="true" level="WARNING" enabled_by_default="true" /> | ||||
|     <inspection_tool class="LocalCanBeFinal" enabled="true" level="WARNING" enabled_by_default="true"> | ||||
|       <option name="REPORT_VARIABLES" value="true" /> | ||||
|       <option name="REPORT_PARAMETERS" value="true" /> | ||||
|  | @ -25,13 +21,11 @@ | |||
|       <option name="ignoreInMatchingInstanceof" value="false" /> | ||||
|     </inspection_tool> | ||||
|     <inspection_tool class="ProblematicWhitespace" enabled="true" level="WARNING" enabled_by_default="true" /> | ||||
|     <inspection_tool class="ProtectedMemberInFinalClass" enabled="true" level="WARNING" enabled_by_default="true" /> | ||||
|     <inspection_tool class="RedundantFieldInitialization" enabled="true" level="WARNING" enabled_by_default="true" /> | ||||
|     <inspection_tool class="RedundantImplements" enabled="true" level="WARNING" enabled_by_default="true"> | ||||
|       <option name="ignoreSerializable" value="false" /> | ||||
|       <option name="ignoreCloneable" value="false" /> | ||||
|     </inspection_tool> | ||||
|     <inspection_tool class="RedundantMethodOverride" enabled="true" level="WARNING" enabled_by_default="true" /> | ||||
|     <inspection_tool class="SimplifiableEqualsExpression" enabled="true" level="WARNING" enabled_by_default="true" /> | ||||
|     <inspection_tool class="TypeParameterExtendsFinalClass" enabled="true" level="WARNING" enabled_by_default="true" /> | ||||
|     <inspection_tool class="UnnecessarilyQualifiedStaticUsage" enabled="true" level="WARNING" enabled_by_default="true"> | ||||
|  | @ -47,6 +41,5 @@ | |||
|     <inspection_tool class="UnnecessaryQualifierForThis" enabled="true" level="WARNING" enabled_by_default="true" /> | ||||
|     <inspection_tool class="UnnecessarySuperConstructor" enabled="true" level="WARNING" enabled_by_default="true" /> | ||||
|     <inspection_tool class="UnnecessaryThis" enabled="true" level="WARNING" enabled_by_default="true" /> | ||||
|     <inspection_tool class="UnnecessaryToStringCall" enabled="true" level="WARNING" enabled_by_default="true" /> | ||||
|   </profile> | ||||
| </component> | ||||
|  | @ -380,7 +380,7 @@ android { | |||
|         compose true | ||||
|     } | ||||
|     composeOptions { | ||||
|         kotlinCompilerExtensionVersion '1.3.2' | ||||
|         kotlinCompilerExtensionVersion '1.5.8' | ||||
|     } | ||||
|     namespace 'fr.free.nrw.commons' | ||||
|     lint { | ||||
|  |  | |||
|  | @ -15,19 +15,19 @@ abstract class NotForUploadStatusDao { | |||
|      * Insert into Not For Upload status. | ||||
|      */ | ||||
|     @Insert(onConflict = OnConflictStrategy.REPLACE) | ||||
|     abstract suspend fun insert(notForUploadStatus: NotForUploadStatus) | ||||
|     abstract fun insert(notForUploadStatus: NotForUploadStatus) | ||||
| 
 | ||||
|     /** | ||||
|      * Delete Not For Upload status entry. | ||||
|      */ | ||||
|     @Delete | ||||
|     abstract suspend fun delete(notForUploadStatus: NotForUploadStatus) | ||||
|     abstract fun delete(notForUploadStatus: NotForUploadStatus) | ||||
| 
 | ||||
|     /** | ||||
|      * Query Not For Upload status with image sha1. | ||||
|      */ | ||||
|     @Query("SELECT * FROM images_not_for_upload_table WHERE imageSHA1 = (:imageSHA1) ") | ||||
|     abstract suspend fun getFromImageSHA1(imageSHA1: String): NotForUploadStatus? | ||||
|     abstract fun getFromImageSHA1(imageSHA1: String): NotForUploadStatus? | ||||
| 
 | ||||
|     /** | ||||
|      * Asynchronous image sha1 query. | ||||
|  | @ -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 suspend fun deleteWithImageSHA1(imageSHA1: String) | ||||
|     abstract fun deleteWithImageSHA1(imageSHA1: String) | ||||
| 
 | ||||
|     /** | ||||
|      * Asynchronous image sha1 deletion. | ||||
|  | @ -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 suspend fun find(imageSHA1: String): Int | ||||
|     abstract fun find(imageSHA1: String): Int | ||||
| } | ||||
|  |  | |||
|  | @ -17,31 +17,31 @@ abstract class UploadedStatusDao { | |||
|      * Insert into uploaded status. | ||||
|      */ | ||||
|     @Insert(onConflict = OnConflictStrategy.REPLACE) | ||||
|     abstract suspend fun insert(uploadedStatus: UploadedStatus) | ||||
|     abstract fun insert(uploadedStatus: UploadedStatus) | ||||
| 
 | ||||
|     /** | ||||
|      * Update uploaded status entry. | ||||
|      */ | ||||
|     @Update | ||||
|     abstract suspend fun update(uploadedStatus: UploadedStatus) | ||||
|     abstract fun update(uploadedStatus: UploadedStatus) | ||||
| 
 | ||||
|     /** | ||||
|      * Delete uploaded status entry. | ||||
|      */ | ||||
|     @Delete | ||||
|     abstract suspend fun delete(uploadedStatus: UploadedStatus) | ||||
|     abstract fun delete(uploadedStatus: UploadedStatus) | ||||
| 
 | ||||
|     /** | ||||
|      * Query uploaded status with image sha1. | ||||
|      */ | ||||
|     @Query("SELECT * FROM uploaded_table WHERE imageSHA1 = (:imageSHA1) ") | ||||
|     abstract suspend fun getFromImageSHA1(imageSHA1: String): UploadedStatus? | ||||
|     abstract fun getFromImageSHA1(imageSHA1: String): UploadedStatus? | ||||
| 
 | ||||
|     /** | ||||
|      * Query uploaded status with modified image sha1. | ||||
|      */ | ||||
|     @Query("SELECT * FROM uploaded_table WHERE modifiedImageSHA1 = (:modifiedImageSHA1) ") | ||||
|     abstract suspend fun getFromModifiedImageSHA1(modifiedImageSHA1: String): UploadedStatus? | ||||
|     abstract fun getFromModifiedImageSHA1(modifiedImageSHA1: String): UploadedStatus? | ||||
| 
 | ||||
|     /** | ||||
|      * Asynchronous insert into uploaded status table. | ||||
|  | @ -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 suspend fun findByImageSHA1( | ||||
|     abstract fun findByImageSHA1( | ||||
|         imageSHA1: String, | ||||
|         imageResult: Boolean, | ||||
|     ): Int | ||||
|  | @ -66,7 +66,7 @@ abstract class UploadedStatusDao { | |||
|     @Query( | ||||
|         "SELECT COUNT() FROM uploaded_table WHERE modifiedImageSHA1 = (:modifiedImageSHA1) AND modifiedImageResult = (:modifiedImageResult) ", | ||||
|     ) | ||||
|     abstract suspend fun findByModifiedImageSHA1( | ||||
|     abstract fun findByModifiedImageSHA1( | ||||
|         modifiedImageSHA1: String, | ||||
|         modifiedImageResult: Boolean, | ||||
|     ): Int | ||||
|  |  | |||
|  | @ -8,6 +8,8 @@ public class Prefs { | |||
|     public static final String UPLOADS_SHOWING = "uploadsshowing"; | ||||
|     public static final String MANAGED_EXIF_TAGS = "managed_exif_tags"; | ||||
|     public static final String DESCRIPTION_LANGUAGE = "languageDescription"; | ||||
|     public static final String SECONDARY_LANGUAGE = "languageSecondary"; | ||||
| 
 | ||||
|     public static final String APP_UI_LANGUAGE = "appUiLanguage"; | ||||
|     public static final String KEY_THEME_VALUE = "appThemePref"; | ||||
| 
 | ||||
|  |  | |||
|  | @ -79,6 +79,7 @@ public class SettingsFragment extends PreferenceFragmentCompat { | |||
| 
 | ||||
|     private ListPreference themeListPreference; | ||||
|     private Preference descriptionLanguageListPreference; | ||||
|     private Preference descriptionSecondaryLanguageListPreference; | ||||
|     private Preference appUiLanguageListPreference; | ||||
|     private String keyLanguageListPreference; | ||||
|     private TextView recentLanguagesTextView; | ||||
|  | @ -152,6 +153,7 @@ public class SettingsFragment extends PreferenceFragmentCompat { | |||
|         appUiLanguageListPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() { | ||||
|             @Override | ||||
|             public boolean onPreferenceClick(Preference preference) { | ||||
|                 System.out.println("Clicked appui"); | ||||
|                 prepareAppLanguages(appUiLanguageListPreference.getKey()); | ||||
|                 return true; | ||||
|             } | ||||
|  | @ -178,6 +180,28 @@ public class SettingsFragment extends PreferenceFragmentCompat { | |||
|             } | ||||
|         }); | ||||
| 
 | ||||
|         descriptionSecondaryLanguageListPreference = findPreference("descriptionSecondaryLanguagePref"); | ||||
|         assert descriptionSecondaryLanguageListPreference != null; | ||||
|         keyLanguageListPreference = descriptionSecondaryLanguageListPreference.getKey(); | ||||
|         languageCode = getCurrentLanguageCode(keyLanguageListPreference); | ||||
|         assert languageCode != null; | ||||
|         if (languageCode.equals("")) { | ||||
|             // If current language code is empty, means none selected by user yet so use phone local | ||||
|             descriptionSecondaryLanguageListPreference.setSummary(Locale.getDefault().getDisplayLanguage()); | ||||
|         } else { | ||||
|             // If any language is selected by user previously, use it | ||||
|             Locale defLocale = createLocale(languageCode); | ||||
|             descriptionSecondaryLanguageListPreference.setSummary(defLocale.getDisplayLanguage(defLocale)); | ||||
|         } | ||||
|         descriptionSecondaryLanguageListPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() { | ||||
|             @Override | ||||
|             public boolean onPreferenceClick(Preference preference) { | ||||
|                 System.out.println("clickedseco"); | ||||
|                 prepareAppLanguages(descriptionSecondaryLanguageListPreference.getKey()); | ||||
|                 return true; | ||||
|             } | ||||
|         }); | ||||
| 
 | ||||
|         Preference betaTesterPreference = findPreference("becomeBetaTester"); | ||||
|         betaTesterPreference.setOnPreferenceClickListener(preference -> { | ||||
|             Utils.handleWebUrl(getActivity(), Uri.parse(getResources().getString(R.string.beta_opt_in_link))); | ||||
|  | @ -205,6 +229,7 @@ public class SettingsFragment extends PreferenceFragmentCompat { | |||
|             findPreference("useAuthorName").setEnabled(false); | ||||
|             findPreference("displayNearbyCardView").setEnabled(false); | ||||
|             findPreference("descriptionDefaultLanguagePref").setEnabled(false); | ||||
|             findPreference("descriptionSecondaryLanguagePref").setEnabled(false); | ||||
|             findPreference("displayLocationPermissionForCardView").setEnabled(false); | ||||
|             findPreference(CampaignView.CAMPAIGNS_DEFAULT_PREFERENCE).setEnabled(false); | ||||
|             findPreference("managed_exif_tags").setEnabled(false); | ||||
|  | @ -278,6 +303,8 @@ public class SettingsFragment extends PreferenceFragmentCompat { | |||
|      */ | ||||
|     private void prepareAppLanguages(final String keyListPreference) { | ||||
| 
 | ||||
|         System.out.println("gets to prepare app languages"); | ||||
| 
 | ||||
|         // Gets current language code from shared preferences | ||||
|         final String languageCode = getCurrentLanguageCode(keyListPreference); | ||||
|         final List<Language> recentLanguages = recentLanguagesDao.getRecentLanguages(); | ||||
|  | @ -293,6 +320,15 @@ public class SettingsFragment extends PreferenceFragmentCompat { | |||
|             } | ||||
|         } else if (keyListPreference.equals("descriptionDefaultLanguagePref")) { | ||||
| 
 | ||||
|             assert languageCode != null; | ||||
|             if (languageCode.equals("")) { | ||||
|                 selectedLanguages.put(0, Locale.getDefault().getLanguage()); | ||||
| 
 | ||||
|             } else { | ||||
|                 selectedLanguages.put(0, languageCode); | ||||
|             } | ||||
|         } else if (keyListPreference.equals("descriptionSecondaryLanguagePref")) { | ||||
| 
 | ||||
|         assert languageCode != null; | ||||
|         if (languageCode.equals("")) { | ||||
|             selectedLanguages.put(0, Locale.getDefault().getLanguage()); | ||||
|  | @ -368,9 +404,12 @@ public class SettingsFragment extends PreferenceFragmentCompat { | |||
|                     getActivity().recreate(); | ||||
|                     final Intent intent = new Intent(getActivity(), MainActivity.class); | ||||
|                     startActivity(intent); | ||||
|                 }else { | ||||
|                 }else if(keyListPreference.equals("descriptionDefaultLanguagePref")){ | ||||
|                     descriptionLanguageListPreference.setSummary(defLocale.getDisplayLanguage(defLocale)); | ||||
|                 } | ||||
|                 else{ | ||||
|                     descriptionSecondaryLanguageListPreference.setSummary(defLocale.getDisplayLanguage(defLocale)); | ||||
|                 } | ||||
|                 dialog.dismiss(); | ||||
|             } | ||||
|         }); | ||||
|  | @ -496,6 +535,8 @@ public class SettingsFragment extends PreferenceFragmentCompat { | |||
|             defaultKvStore.putString(Prefs.APP_UI_LANGUAGE, userSelectedValue); | ||||
|         } else if (preferenceKey.equals("descriptionDefaultLanguagePref")) { | ||||
|             defaultKvStore.putString(Prefs.DESCRIPTION_LANGUAGE, userSelectedValue); | ||||
|         } else if (preferenceKey.equals("descriptionSecondaryLanguagePref")) { | ||||
|             defaultKvStore.putString(Prefs.SECONDARY_LANGUAGE, userSelectedValue); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|  | @ -511,6 +552,9 @@ public class SettingsFragment extends PreferenceFragmentCompat { | |||
|         if (preferenceKey.equals("descriptionDefaultLanguagePref")) { | ||||
|             return defaultKvStore.getString(Prefs.DESCRIPTION_LANGUAGE, ""); | ||||
|         } | ||||
|         if (preferenceKey.equals("descriptionSecondaryLanguagePref")) { | ||||
|             return defaultKvStore.getString(Prefs.SECONDARY_LANGUAGE, ""); | ||||
|         } | ||||
|         return null; | ||||
|     } | ||||
| 
 | ||||
|  |  | |||
|  | @ -10,15 +10,13 @@ abstract class BaseDelegateAdapter<T>( | |||
|     areContentsTheSame: (T, T) -> Boolean = { old, new -> old == new }, | ||||
| ) : AsyncListDifferDelegationAdapter<T>( | ||||
|         object : DiffUtil.ItemCallback<T>() { | ||||
|             override fun areItemsTheSame( | ||||
|                 oldItem: T, | ||||
|                 newItem: T, | ||||
|             ) = areItemsTheSame(oldItem, newItem) | ||||
|             override fun areItemsTheSame(oldItem: T & Any, newItem: T & Any): Boolean { | ||||
|                 return areItemsTheSame(oldItem, newItem) | ||||
|             } | ||||
| 
 | ||||
|             override fun areContentsTheSame( | ||||
|                 oldItem: T, | ||||
|                 newItem: T, | ||||
|             ) = areContentsTheSame(oldItem, newItem) | ||||
|             override fun areContentsTheSame(oldItem: T & Any, newItem: T & Any): Boolean { | ||||
|                 return areContentsTheSame(oldItem, newItem) | ||||
|             } | ||||
|             }, | ||||
|         *delegates, | ||||
|     ) { | ||||
|  |  | |||
|  | @ -22,16 +22,16 @@ abstract class DepictsDao { | |||
|     private val maxItemsAllowed = 10 | ||||
| 
 | ||||
|     @Insert(onConflict = OnConflictStrategy.REPLACE) | ||||
|     abstract suspend fun insert(depictedItem: Depicts) | ||||
|     abstract fun insert(depictedItem: Depicts) | ||||
| 
 | ||||
|     @Query("Select * From depicts_table order by lastUsed DESC") | ||||
|     abstract suspend fun getAllDepicts(): List<Depicts> | ||||
|     abstract fun getAllDepicts(): List<Depicts> | ||||
| 
 | ||||
|     @Query("Select * From depicts_table order by lastUsed DESC LIMIT :n OFFSET 10") | ||||
|     abstract suspend fun getDepictsForDeletion(n: Int): List<Depicts> | ||||
|     abstract fun getDepictsForDeletion(n: Int): List<Depicts> | ||||
| 
 | ||||
|     @Delete | ||||
|     abstract suspend fun delete(depicts: Depicts) | ||||
|     abstract fun delete(depicts: Depicts) | ||||
| 
 | ||||
|     /** | ||||
|      * Gets all Depicts objects from the database, ordered by lastUsed in descending order. | ||||
|  |  | |||
|  | @ -544,6 +544,7 @@ Upload your first media by tapping on the add button.</string> | |||
|   <string name="dialog_box_text_nomination">Why should %1$s be deleted?</string> | ||||
|   <string name="review_is_uploaded_by">%1$s is uploaded by: %2$s</string> | ||||
|   <string name="default_description_language">Default description language</string> | ||||
|   <string name="secondary_description_language">Secondary Description Language</string> | ||||
|   <string name="delete_helper_show_deletion_title">Nominating for deletion</string> | ||||
|   <string name="delete_helper_show_deletion_title_success">Success</string> | ||||
|   <string name="delete_helper_show_deletion_message_if">Nominated %1$s for deletion.</string> | ||||
|  |  | |||
|  | @ -25,12 +25,20 @@ | |||
|           app:singleLineTitle="false" | ||||
|           android:title="@string/app_ui_language" /> | ||||
| 
 | ||||
| 
 | ||||
|         <Preference | ||||
|           android:key="descriptionDefaultLanguagePref" | ||||
|           app:useSimpleSummaryProvider="true" | ||||
|           app:singleLineTitle="false" | ||||
|           android:title="@string/default_description_language" /> | ||||
| 
 | ||||
|         <!-- New Secondary Language Picker --> | ||||
|         <Preference | ||||
|           android:key="descriptionSecondaryLanguagePref" | ||||
|           app:useSimpleSummaryProvider="true" | ||||
|           app:singleLineTitle="false" | ||||
|           android:title="@string/secondary_description_language" /> | ||||
| 
 | ||||
|         <SwitchPreference | ||||
|           android:defaultValue="true" | ||||
|           android:key="displayNearbyCardView" | ||||
|  |  | |||
|  | @ -17,7 +17,7 @@ org.gradle.jvmargs=-Xmx1536M | |||
| org.gradle.caching=true | ||||
| android.enableR8.fullMode=false | ||||
| 
 | ||||
| KOTLIN_VERSION=1.7.20 | ||||
| KOTLIN_VERSION=1.9.22 | ||||
| LEAK_CANARY_VERSION=2.10 | ||||
| DAGGER_VERSION=2.23 | ||||
| ROOM_VERSION=2.5.0 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Adeeth101
						Adeeth101