mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-30 22:34:02 +01:00
Merge remote-tracking branch 'origin/UI-Fix' into issue-1-launguage-order-backend-queries
# Conflicts: # app/src/main/resources/queries/query_for_item.rq
This commit is contained in:
commit
8fe958e3c6
9 changed files with 420 additions and 27 deletions
|
|
@ -707,7 +707,8 @@ public class MediaDetailFragment extends CommonsDaggerSupportFragment implements
|
|||
*/
|
||||
private void buildDepictionList(List<IdAndCaptions> idAndCaptions) {
|
||||
binding.mediaDetailDepictionContainer.removeAllViews();
|
||||
String locale = Locale.getDefault().getLanguage();
|
||||
String fullCode = Locale.getDefault().getLanguage();
|
||||
String locale = fullCode.contains(",") ? fullCode.substring(0, fullCode.indexOf(',')).trim() : fullCode;
|
||||
for (IdAndCaptions idAndCaption : idAndCaptions) {
|
||||
binding.mediaDetailDepictionContainer.addView(buildDepictLabel(
|
||||
getDepictionCaption(idAndCaption, locale),
|
||||
|
|
|
|||
|
|
@ -409,15 +409,55 @@ public class OkHttpJsonApiClient {
|
|||
*/
|
||||
@Nullable
|
||||
public List<Place> getPlaces(
|
||||
final List<Place> placeList, final String language) throws IOException {
|
||||
final List<Place> placeList, final String language, final String secondaryLanguages) throws IOException {
|
||||
final String wikidataQuery = FileUtils.readFromResource("/queries/query_for_item.rq");
|
||||
final String[] secondaryLanguageArray = secondaryLanguages.split(",\\s*"); // could be used to generate backup SparQL Queries
|
||||
|
||||
String qids = "";
|
||||
for (final Place place : placeList) {
|
||||
qids += "\n" + ("wd:" + place.getWikiDataEntityId());
|
||||
}
|
||||
|
||||
StringBuilder fallBackDescription = new StringBuilder();
|
||||
for (int i = 0; i < secondaryLanguageArray.length; i++) {
|
||||
fallBackDescription.append("OPTIONAL {?item schema:description ?itemDescriptionPreferredLanguage_")
|
||||
.append(i + 1)
|
||||
.append(". FILTER (lang(?itemDescriptionPreferredLanguage_")
|
||||
.append(i + 1)
|
||||
.append(") = \"")
|
||||
.append(secondaryLanguageArray[i])
|
||||
.append("\")}\n");
|
||||
}
|
||||
|
||||
StringBuilder fallbackLabel = new StringBuilder();
|
||||
for (int i = 0; i < secondaryLanguageArray.length; i++) {
|
||||
fallbackLabel.append("OPTIONAL {?item rdfs:label ?itemLabelPreferredLanguage_")
|
||||
.append(i + 1)
|
||||
.append(". FILTER (lang(?itemLabelPreferredLanguage_")
|
||||
.append(i + 1)
|
||||
.append(") = \"")
|
||||
.append(secondaryLanguageArray[i])
|
||||
.append("\")}\n");
|
||||
}
|
||||
|
||||
StringBuilder fallbackClassLabel = new StringBuilder();
|
||||
for (int i = 0; i < secondaryLanguageArray.length; i++) {
|
||||
fallbackClassLabel.append("OPTIONAL {?class rdfs:label ?classLabelPreferredLanguage_")
|
||||
.append(i + 1)
|
||||
.append(". FILTER (lang(?classLabelPreferredLanguage_")
|
||||
.append(i + 1)
|
||||
.append(") = \"")
|
||||
.append(secondaryLanguageArray[i])
|
||||
.append("\")}\n");
|
||||
}
|
||||
|
||||
final String query = wikidataQuery
|
||||
.replace("${ENTITY}", qids)
|
||||
.replace("${LANG}", language);
|
||||
.replace("${LANG}", language)
|
||||
.replace("${SECONDARYDESCRIPTION}", fallBackDescription.toString())
|
||||
.replace("${SECONDARYLABEL}", fallbackLabel.toString())
|
||||
.replace("${SECONDARYCLASSLABEL}", fallbackClassLabel.toString());
|
||||
|
||||
final HttpUrl.Builder urlBuilder = HttpUrl
|
||||
.parse(sparqlQueryUrl)
|
||||
.newBuilder()
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ import androidx.annotation.Nullable;
|
|||
import fr.free.nrw.commons.BaseMarker;
|
||||
import fr.free.nrw.commons.MapController;
|
||||
import fr.free.nrw.commons.location.LatLng;
|
||||
import fr.free.nrw.commons.kvstore.JsonKvStore;
|
||||
import fr.free.nrw.commons.settings.Prefs;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
|
|
@ -16,6 +18,7 @@ import java.util.ListIterator;
|
|||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import timber.log.Timber;
|
||||
|
||||
public class NearbyController extends MapController {
|
||||
|
|
@ -34,6 +37,9 @@ public class NearbyController extends MapController {
|
|||
this.nearbyPlaces = nearbyPlaces;
|
||||
}
|
||||
|
||||
@Inject
|
||||
@Named("default_preferences")
|
||||
JsonKvStore defaultKvStore;
|
||||
|
||||
/**
|
||||
* Prepares Place list to make their distance information update later.
|
||||
|
|
@ -56,6 +62,7 @@ public class NearbyController extends MapController {
|
|||
Timber.d("Loading attractions nearby, but currentLatLng is null");
|
||||
return null;
|
||||
}
|
||||
|
||||
List<Place> places = nearbyPlaces
|
||||
.radiusExpander(searchLatLng, Locale.getDefault().getLanguage(), returnClosestResult,
|
||||
customQuery);
|
||||
|
|
@ -139,7 +146,10 @@ public class NearbyController extends MapController {
|
|||
* @throws Exception If an error occurs during the retrieval process.
|
||||
*/
|
||||
public List<Place> getPlaces(List<Place> placeList) throws Exception {
|
||||
return nearbyPlaces.getPlaces(placeList, Locale.getDefault().getLanguage());
|
||||
|
||||
String secondaryLanguages = defaultKvStore.getString(Prefs.SECONDARY_LANGUAGE, "");
|
||||
|
||||
return nearbyPlaces.getPlaces(placeList, Locale.getDefault().getLanguage(), secondaryLanguages);
|
||||
}
|
||||
|
||||
public static LatLng calculateNorthEast(double latitude, double longitude, double distance) {
|
||||
|
|
|
|||
|
|
@ -131,9 +131,9 @@ public class NearbyPlaces {
|
|||
* @throws Exception If an error occurs during the retrieval process.
|
||||
*/
|
||||
public List<Place> getPlaces(final List<Place> placeList,
|
||||
final String lang) throws Exception {
|
||||
final String lang, final String lang2) throws Exception {
|
||||
return okHttpJsonApiClient
|
||||
.getPlaces(placeList, lang);
|
||||
.getPlaces(placeList, lang, lang2);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -0,0 +1,77 @@
|
|||
package fr.free.nrw.commons.recentlanguages
|
||||
|
||||
import android.content.Context
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ArrayAdapter
|
||||
import fr.free.nrw.commons.R
|
||||
import fr.free.nrw.commons.databinding.RowItemLanguagesSpinnerBinding
|
||||
import fr.free.nrw.commons.utils.LangCodeUtils
|
||||
import org.apache.commons.lang3.StringUtils
|
||||
import java.util.HashMap
|
||||
|
||||
/**
|
||||
* Array adapter for saved languages
|
||||
*/
|
||||
class SavedLanguagesAdapter constructor(
|
||||
context: Context,
|
||||
var savedLanguages: List<Language>, // List of saved languages
|
||||
private val selectedLanguages: HashMap<*, String>, // Selected languages map
|
||||
) : ArrayAdapter<String?>(context, R.layout.row_item_languages_spinner) {
|
||||
/**
|
||||
* Selected language code in SavedLanguagesAdapter
|
||||
* Used for marking selected ones
|
||||
*/
|
||||
var selectedLangCode = ""
|
||||
|
||||
override fun isEnabled(position: Int) =
|
||||
savedLanguages[position].languageCode.let {
|
||||
it.isNotEmpty() && !selectedLanguages.containsValue(it) && it != selectedLangCode
|
||||
}
|
||||
|
||||
override fun getCount() = savedLanguages.size
|
||||
|
||||
override fun getView(
|
||||
position: Int,
|
||||
convertView: View?,
|
||||
parent: ViewGroup,
|
||||
): View {
|
||||
val binding: RowItemLanguagesSpinnerBinding
|
||||
var rowView = convertView
|
||||
|
||||
if (rowView == null) {
|
||||
val layoutInflater =
|
||||
context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
|
||||
binding = RowItemLanguagesSpinnerBinding.inflate(layoutInflater, parent, false)
|
||||
rowView = binding.root
|
||||
} else {
|
||||
binding = RowItemLanguagesSpinnerBinding.bind(rowView)
|
||||
}
|
||||
|
||||
val languageCode = savedLanguages[position].languageCode
|
||||
val languageName = savedLanguages[position].languageName
|
||||
binding.tvLanguage.let {
|
||||
it.isEnabled = isEnabled(position)
|
||||
if (languageCode.isEmpty()) {
|
||||
it.text = StringUtils.capitalize(languageName)
|
||||
it.textAlignment = View.TEXT_ALIGNMENT_CENTER
|
||||
} else {
|
||||
it.text =
|
||||
"${StringUtils.capitalize(languageName)}" +
|
||||
" [${LangCodeUtils.fixLanguageCode(languageCode)}]"
|
||||
}
|
||||
}
|
||||
return rowView
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides code of a language from saved languages for a specific position
|
||||
*/
|
||||
fun getLanguageCode(position: Int): String = savedLanguages[position].languageCode
|
||||
|
||||
/**
|
||||
* Provides name of a language from saved languages for a specific position
|
||||
*/
|
||||
fun getLanguageName(position: Int): String = savedLanguages[position].languageName
|
||||
}
|
||||
|
|
@ -18,6 +18,8 @@ import android.widget.AdapterView.OnItemClickListener;
|
|||
import android.widget.EditText;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import android.widget.ArrayAdapter;
|
||||
import androidx.activity.result.ActivityResultCallback;
|
||||
import androidx.activity.result.ActivityResultLauncher;
|
||||
import androidx.activity.result.contract.ActivityResultContracts;
|
||||
|
|
@ -47,10 +49,13 @@ import fr.free.nrw.commons.logging.CommonsLogSender;
|
|||
import fr.free.nrw.commons.recentlanguages.Language;
|
||||
import fr.free.nrw.commons.recentlanguages.RecentLanguagesAdapter;
|
||||
import fr.free.nrw.commons.recentlanguages.RecentLanguagesDao;
|
||||
import fr.free.nrw.commons.recentlanguages.SavedLanguagesAdapter;
|
||||
import fr.free.nrw.commons.upload.LanguagesAdapter;
|
||||
import fr.free.nrw.commons.utils.DialogUtil;
|
||||
import fr.free.nrw.commons.utils.PermissionUtils;
|
||||
import fr.free.nrw.commons.utils.ViewUtil;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
|
@ -153,7 +158,6 @@ 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;
|
||||
}
|
||||
|
|
@ -180,24 +184,18 @@ 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.setSummary("List additional languages.");
|
||||
|
||||
descriptionSecondaryLanguageListPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
System.out.println("clickedseco");
|
||||
prepareAppLanguages(descriptionSecondaryLanguageListPreference.getKey());
|
||||
prepareSecondaryLanguageDialog();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
|
@ -292,6 +290,157 @@ public class SettingsFragment extends PreferenceFragmentCompat {
|
|||
});
|
||||
}
|
||||
|
||||
private void updateSavedLanguages(ListView savedLanguageListView, List<Language> savedLanguages, HashMap<Integer, String> selectedLanguages) {
|
||||
// Use SavedLanguagesAdapter to display saved languages
|
||||
SavedLanguagesAdapter savedLanguagesAdapter = new SavedLanguagesAdapter(
|
||||
getActivity(),
|
||||
savedLanguages, // List of saved Language objects
|
||||
selectedLanguages // Pass the map of selected languages
|
||||
);
|
||||
|
||||
// Set the adapter to the ListView to display the saved languages
|
||||
savedLanguageListView.setAdapter(savedLanguagesAdapter);
|
||||
}
|
||||
|
||||
private ArrayList<String> deSerialise(String languageCodes) {
|
||||
// Check if the stored string is empty or null
|
||||
if (languageCodes == null || languageCodes.isEmpty()) {
|
||||
return new ArrayList<>(); // Return an empty list if there's no data
|
||||
}
|
||||
|
||||
// Split the string by commas and store it in a list
|
||||
String[] languageArray = languageCodes.split(",\\s*"); // Split by comma and optional space
|
||||
return new ArrayList<>(Arrays.asList(languageArray)); // Convert array to ArrayList and return
|
||||
}
|
||||
|
||||
|
||||
private void prepareSecondaryLanguageDialog() {
|
||||
final String languageCode = getCurrentLanguageCode("descriptionSecondaryLanguagePref");
|
||||
HashMap<Integer, String> selectedLanguages = new HashMap<>();
|
||||
assert languageCode != null;
|
||||
selectedLanguages.put(0, Locale.getDefault().getLanguage());
|
||||
System.out.println(Locale.getDefault().getLanguage());
|
||||
System.out.println(languageCode);
|
||||
|
||||
// Deserializing saved language codes to Language objects
|
||||
ArrayList<Language> savedLanguages = new ArrayList<>();
|
||||
for (String code : deSerialise(languageCode)) {
|
||||
System.out.println(code);
|
||||
if(code.equals(Locale.getDefault().getLanguage())){
|
||||
System.out.println("match");
|
||||
continue;
|
||||
}
|
||||
Locale locale = new Locale(code);
|
||||
savedLanguages.add(new Language(locale.getDisplayLanguage(locale), code));
|
||||
}
|
||||
|
||||
// Create the new dialog for secondary language
|
||||
Dialog dialog = new Dialog(getActivity());
|
||||
dialog.setContentView(R.layout.dialog_select_secondary_language);
|
||||
dialog.setCanceledOnTouchOutside(true);
|
||||
dialog.getWindow().setLayout(
|
||||
(int) (getActivity().getResources().getDisplayMetrics().widthPixels * 0.90),
|
||||
(int) (getActivity().getResources().getDisplayMetrics().heightPixels * 0.90)
|
||||
);
|
||||
dialog.show();
|
||||
|
||||
// Bind UI elements
|
||||
EditText editText = dialog.findViewById(R.id.search_language);
|
||||
ListView listView = dialog.findViewById(R.id.language_list);
|
||||
ListView savedLanguageListView = dialog.findViewById(R.id.language_history_list);
|
||||
View separator = dialog.findViewById(R.id.separator);
|
||||
|
||||
// Setup saved languages with the new SavedLanguagesAdapter
|
||||
updateSavedLanguages(savedLanguageListView, savedLanguages, selectedLanguages);
|
||||
|
||||
// Set an onItemClickListener to remove a language when clicked
|
||||
savedLanguageListView.setOnItemClickListener((adapterView, view, position, id) -> {
|
||||
// Remove the clicked language from Saved_Languages
|
||||
savedLanguages.remove(position);
|
||||
|
||||
// Update the saved language list view after removing the language
|
||||
updateSavedLanguages(savedLanguageListView, savedLanguages, selectedLanguages);
|
||||
|
||||
// Update the shared preferences to reflect the removal
|
||||
String updatedLanguageCodes = "";
|
||||
for (Language language : savedLanguages) {
|
||||
updatedLanguageCodes += language.getLanguageCode() + ", ";
|
||||
}
|
||||
// Remove the trailing comma and space if present
|
||||
if (!updatedLanguageCodes.isEmpty()) {
|
||||
updatedLanguageCodes = updatedLanguageCodes.substring(0, updatedLanguageCodes.length() - 2);
|
||||
}
|
||||
saveLanguageValue(updatedLanguageCodes, "descriptionSecondaryLanguagePref");
|
||||
// descriptionSecondaryLanguageListPreference.setSummary(getCurrentLanguageCode("descriptionSecondaryLanguagePref"));
|
||||
});
|
||||
|
||||
// Set up the adapter for new languages using the selectedLanguages map
|
||||
LanguagesAdapter languagesAdapter = new LanguagesAdapter(getActivity(), selectedLanguages);
|
||||
listView.setAdapter(languagesAdapter);
|
||||
|
||||
// Add search functionality
|
||||
editText.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
||||
hideRecentLanguagesSection();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
||||
languagesAdapter.getFilter().filter(charSequence);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable editable) {
|
||||
}
|
||||
});
|
||||
|
||||
// Handle item click for language selection in the main list
|
||||
listView.setOnItemClickListener((adapterView, view, i, l) -> {
|
||||
String selectedLanguageCode = languagesAdapter.getLanguageCode(i);
|
||||
String selectedLanguageName = languagesAdapter.getLanguageName(i);
|
||||
|
||||
if (deSerialise(getCurrentLanguageCode("descriptionSecondaryLanguagePref")).contains(selectedLanguageCode)) {
|
||||
Toast.makeText(getActivity(), "Language already selected", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
|
||||
savedLanguages.add(new Language(selectedLanguageName, selectedLanguageCode));
|
||||
updateSavedLanguages(savedLanguageListView, savedLanguages, selectedLanguages);
|
||||
|
||||
// Update the shared preferences to reflect the addition
|
||||
String updatedLanguageCodes = "";
|
||||
for (Language language : savedLanguages) {
|
||||
updatedLanguageCodes += language.getLanguageCode() + ", ";
|
||||
}
|
||||
// Remove the trailing comma and space if present
|
||||
if (!updatedLanguageCodes.isEmpty()) {
|
||||
updatedLanguageCodes = updatedLanguageCodes.substring(0, updatedLanguageCodes.length() - 2);
|
||||
}
|
||||
|
||||
saveLanguageValue(updatedLanguageCodes, "descriptionSecondaryLanguagePref");
|
||||
|
||||
// descriptionSecondaryLanguageListPreference.setSummary(getCurrentLanguageCode("descriptionSecondaryLanguagePref"));
|
||||
});
|
||||
|
||||
dialog.setOnDismissListener(dialogInterface -> {
|
||||
// Update the shared preferences to reflect changes
|
||||
String updatedLanguageCodes = "";
|
||||
for (Language language : savedLanguages) {
|
||||
updatedLanguageCodes += language.getLanguageCode() + ", ";
|
||||
}
|
||||
// Remove the trailing comma and space if present
|
||||
if (!updatedLanguageCodes.isEmpty()) {
|
||||
updatedLanguageCodes = updatedLanguageCodes.substring(0, updatedLanguageCodes.length() - 2);
|
||||
}
|
||||
saveLanguageValue(updatedLanguageCodes, "descriptionSecondaryLanguagePref");
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Prepare and Show language selection dialog box
|
||||
* Uses previously saved language if there is any, if not uses phone locale as initial language.
|
||||
|
|
@ -303,7 +452,6 @@ 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);
|
||||
|
|
@ -345,6 +493,7 @@ public class SettingsFragment extends PreferenceFragmentCompat {
|
|||
|
||||
Dialog dialog = new Dialog(getActivity());
|
||||
dialog.setContentView(R.layout.dialog_select_language);
|
||||
|
||||
dialog.setCanceledOnTouchOutside(true);
|
||||
dialog.getWindow().setLayout((int)(getActivity().getResources().getDisplayMetrics().widthPixels*0.90),
|
||||
(int)(getActivity().getResources().getDisplayMetrics().heightPixels*0.90));
|
||||
|
|
@ -407,9 +556,6 @@ public class SettingsFragment extends PreferenceFragmentCompat {
|
|||
}else if(keyListPreference.equals("descriptionDefaultLanguagePref")){
|
||||
descriptionLanguageListPreference.setSummary(defLocale.getDisplayLanguage(defLocale));
|
||||
}
|
||||
else{
|
||||
descriptionSecondaryLanguageListPreference.setSummary(defLocale.getDisplayLanguage(defLocale));
|
||||
}
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
|
|
@ -487,13 +633,43 @@ public class SettingsFragment extends PreferenceFragmentCompat {
|
|||
separator.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
private String reSerialise(ArrayList<String> languageCodes) {
|
||||
// Join the elements of the list into a single string, separated by a comma and a space
|
||||
return String.join(", ", languageCodes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Changing the default app language with selected one and save it to SharedPreferences
|
||||
*/
|
||||
public void setLocale(final Activity activity, String userSelectedValue) {
|
||||
if (userSelectedValue.equals("")) {
|
||||
userSelectedValue = Locale.getDefault().getLanguage();
|
||||
}
|
||||
// if (userSelectedValue.equals("")) {
|
||||
// userSelectedValue = Locale.getDefault().getLanguage();
|
||||
// }
|
||||
//
|
||||
// String current = Locale.getDefault().getLanguage();
|
||||
// ArrayList<String> languageCodes = deSerialise(current);
|
||||
// if(appUI) {
|
||||
// languageCodes.set(0, userSelectedValue);
|
||||
// userSelectedValue = reSerialise(languageCodes);
|
||||
// }
|
||||
// else{
|
||||
// ArrayList<String> newLanguageCodes = new ArrayList<>();
|
||||
// ArrayList<String> userSelctedCode = deSerialise(userSelectedValue);
|
||||
//
|
||||
// newLanguageCodes.add(languageCodes.get(0));
|
||||
// for(String code : userSelctedCode){
|
||||
// newLanguageCodes.add(code);
|
||||
// }
|
||||
// userSelectedValue = reSerialise(newLanguageCodes);
|
||||
// }
|
||||
//
|
||||
// System.out.println("Final locale");
|
||||
// System.out.println(userSelectedValue);
|
||||
//
|
||||
// System.out.println("vs");
|
||||
// System.out.println(getCurrentLanguageCode("appUiDefaultLanguagePref"));
|
||||
// System.out.println(getCurrentLanguageCode("descriptionSecondaryLanguagePref"));
|
||||
|
||||
final Locale locale = createLocale(userSelectedValue);
|
||||
Locale.setDefault(locale);
|
||||
final Configuration configuration = new Configuration();
|
||||
|
|
|
|||
76
app/src/main/res/layout/dialog_select_secondary_language.xml
Normal file
76
app/src/main/res/layout/dialog_select_secondary_language.xml
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/search_language"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:hint="Type Language Name"
|
||||
android:padding="12dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/language_order_preference"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:text="Language order preference"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/search_language" />
|
||||
|
||||
<ListView
|
||||
android:id="@+id/language_history_list"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="8dp"
|
||||
app:layout_constraintBottom_toTopOf="@id/separator"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/language_order_preference" />
|
||||
|
||||
<View
|
||||
android:id="@+id/separator"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="@color/black"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/language_history_list" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/all_languages"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="All Languages"
|
||||
app:layout_constraintTop_toBottomOf="@id/separator"
|
||||
app:layout_constraintEnd_toEndOf="@+id/language_history_list"
|
||||
android:layout_margin="8dp"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
<ListView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:id="@+id/language_list"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/all_languages" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
|
||||
|
|
@ -25,6 +25,17 @@
|
|||
<item>@string/exif_tag_name_serialNumbers</item>
|
||||
<item>@string/exif_tag_name_software</item>
|
||||
</array>
|
||||
|
||||
<array name="default_languages">
|
||||
<item>@string/exif_tag_name_author</item>
|
||||
<item>@string/exif_tag_name_copyright</item>
|
||||
<item>@string/exif_tag_name_location</item>
|
||||
<item>@string/exif_tag_name_cameraModel</item>
|
||||
<item>@string/exif_tag_name_lensModel</item>
|
||||
<item>@string/exif_tag_name_serialNumbers</item>
|
||||
<item>@string/exif_tag_name_software</item>
|
||||
</array>
|
||||
|
||||
<array name="pref_exifTag_values">
|
||||
<item>@string/exif_tag_author</item>
|
||||
<item>@string/exif_tag_copyright</item>
|
||||
|
|
|
|||
|
|
@ -18,13 +18,14 @@ WHERE {
|
|||
}
|
||||
|
||||
# Get the label in the preferred language of the user, or any other language if no label is available in that language.
|
||||
OPTIONAL {?item rdfs:label ?itemLabelPreferredLanguage. FILTER (lang(?itemLabelPreferredLanguage) = "en")}
|
||||
OPTIONAL {?item rdfs:label ?itemLabelPreferredLanguage. FILTER (lang(?itemLabelPreferredLanguage) = "${LANG}")}
|
||||
${SECONDARYLABEL}
|
||||
OPTIONAL {?item rdfs:label ?itemLabelAnyLanguage}
|
||||
BIND(COALESCE(?itemLabelPreferredLanguage, ?itemLabelAnyLanguage, "?") as ?label)
|
||||
|
||||
# Get the description in the preferred language of the user, or any other language if no description is available in that language.
|
||||
# This ensures that the query first tries to fetch the label in the user's preferred language, and if it's unavailable, it falls back to English
|
||||
OPTIONAL {?item schema:description ?itemDescriptionPreferredLanguage. FILTER (LANG(?itemDescriptionPreferredLanguage) = "${LANG}" || LANG(?itemDescriptionPreferredLanguage) = "en")}
|
||||
OPTIONAL {?item schema:description ?itemDescriptionPreferredLanguage. FILTER (lang(?itemDescriptionPreferredLanguage) = "${LANG}")}
|
||||
${SECONDARYDESCRIPTION}
|
||||
OPTIONAL {?item schema:description ?itemDescriptionAnyLanguage}
|
||||
BIND(COALESCE(?itemDescriptionPreferredLanguage, ?itemDescriptionAnyLanguage, "?") as ?description)
|
||||
|
||||
|
|
@ -32,6 +33,7 @@ WHERE {
|
|||
OPTIONAL {
|
||||
?item p:P31/ps:P31 ?class.
|
||||
OPTIONAL {?class rdfs:label ?classLabelPreferredLanguage. FILTER (lang(?classLabelPreferredLanguage) = "${LANG}")}
|
||||
${SECONDARYCLASSLABEL}
|
||||
OPTIONAL {?class rdfs:label ?classLabelAnyLanguage}
|
||||
BIND(COALESCE(?classLabelPreferredLanguage, ?classLabelAnyLanguage, "?") as ?classLabel)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue