Skip to content

Gradle fixes #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ android {
compose true
}
composeOptions {
kotlinCompilerExtensionVersion '1.3.2'
kotlinCompilerExtensionVersion '1.5.8'
}
namespace 'fr.free.nrw.commons'
lint {
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 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.
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 suspend fun deleteWithImageSHA1(imageSHA1: String)
abstract 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 suspend fun find(imageSHA1: String): Int
abstract 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 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.
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 suspend fun findByImageSHA1(
abstract 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 suspend fun findByModifiedImageSHA1(
abstract fun findByModifiedImageSHA1(
modifiedImageSHA1: String,
modifiedImageResult: Boolean,
): Int
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/fr/free/nrw/commons/settings/Prefs.java
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -152,6 +153,7 @@ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
appUiLanguageListPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
System.out.println("Clicked appui");
prepareAppLanguages(appUiLanguageListPreference.getKey());
return true;
}
Expand All @@ -178,6 +180,28 @@ public boolean onPreferenceClick(Preference preference) {
}
});

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)));
Expand Down Expand Up @@ -205,6 +229,7 @@ public boolean onPreferenceClick(Preference preference) {
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);
Expand Down Expand Up @@ -278,6 +303,8 @@ private void prepareTheme() {
*/
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();
Expand All @@ -300,7 +327,16 @@ private void prepareAppLanguages(final String keyListPreference) {
} else {
selectedLanguages.put(0, languageCode);
}
} else if (keyListPreference.equals("descriptionSecondaryLanguagePref")) {

assert languageCode != null;
if (languageCode.equals("")) {
selectedLanguages.put(0, Locale.getDefault().getLanguage());

} else {
selectedLanguages.put(0, languageCode);
}
}

LanguagesAdapter languagesAdapter = new LanguagesAdapter(
getActivity(),
Expand Down Expand Up @@ -368,9 +404,12 @@ public void onItemClick(AdapterView<?> adapterView, View view, int i,
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();
}
});
Expand Down Expand Up @@ -496,6 +535,8 @@ private void saveLanguageValue(final String userSelectedValue, final String pref
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);
}
}

Expand All @@ -511,6 +552,9 @@ private String getCurrentLanguageCode(final String preferenceKey) {
if (preferenceKey.equals("descriptionDefaultLanguagePref")) {
return defaultKvStore.getString(Prefs.DESCRIPTION_LANGUAGE, "");
}
if (preferenceKey.equals("descriptionSecondaryLanguagePref")) {
return defaultKvStore.getString(Prefs.SECONDARY_LANGUAGE, "");
}
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,14 @@ 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,
) {
fun addAll(newResults: List<T>) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/res/xml/preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down