Skip to content

Commit

Permalink
Merge pull request #2200 from marunjar/add_resources
Browse files Browse the repository at this point in the history
add more string resources
  • Loading branch information
marunjar authored Nov 3, 2023
2 parents 964ab98 + a5839af commit bf30f4b
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@
import org.json.JSONException;
import org.json.JSONObject;

import java.util.Collections;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

import fr.neamar.kiss.BuildConfig;
import fr.neamar.kiss.KissApplication;
import fr.neamar.kiss.R;

Expand Down Expand Up @@ -98,10 +96,10 @@ public void onClick() {
ClipboardManager clipboard = (ClipboardManager) getContext().getSystemService(CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText("kiss", out.toString());
clipboard.setPrimaryClip(clip);
Toast.makeText(getContext(), "Settings exported to clipboard", Toast.LENGTH_SHORT).show();
Toast.makeText(getContext(), R.string.export_settings_done, Toast.LENGTH_SHORT).show();
} catch (JSONException e) {
Log.e(TAG, "Unable to export preferences", e);
Toast.makeText(getContext(), "Unable to export preferences", Toast.LENGTH_SHORT).show();
Log.e(TAG, "Unable to export settings", e);
Toast.makeText(getContext(), R.string.export_settings_error, Toast.LENGTH_SHORT).show();
} finally {
defaultValues.edit().clear().apply();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ public void onClick(DialogInterface dialog, int which) {
JSONObject jsonObject = new JSONObject(clipboardText);
int minVersion = jsonObject.optInt("__v", -1);
if (minVersion < 0) {
Toast.makeText(getContext(), "Unable to import preferences, no valid version string detected.", Toast.LENGTH_LONG).show();
Toast.makeText(getContext(), R.string.import_settings_version_missing, Toast.LENGTH_LONG).show();
return;
} else if (minVersion > BuildConfig.VERSION_CODE) {
Toast.makeText(getContext(), "Please upgrade your KISS version before importing those settings.", Toast.LENGTH_LONG).show();
Toast.makeText(getContext(), R.string.import_settings_upgrade_kiss, Toast.LENGTH_LONG).show();
return;
}

Expand Down Expand Up @@ -97,7 +97,7 @@ public void onClick(DialogInterface dialog, int which) {
}
// always commit preferences to ensure that changes are saved synchronously before continuing
if (!editor.commit()) {
Toast.makeText(getContext(), "Unable to save preferences", Toast.LENGTH_SHORT).show();
Toast.makeText(getContext(), R.string.import_settings_save_not_possible, Toast.LENGTH_SHORT).show();
}

DataHandler dataHandler = ((KissApplication) getContext().getApplicationContext()).getDataHandler();
Expand All @@ -119,10 +119,10 @@ public void onClick(DialogInterface dialog, int which) {
dataHandler.reloadSearchProvider();
dataHandler.reloadContactsProvider();

Toast.makeText(getContext(), "Preferences imported!", Toast.LENGTH_SHORT).show();
Toast.makeText(getContext(), R.string.import_settings_done, Toast.LENGTH_SHORT).show();
} catch (JSONException | NullPointerException e) {
Log.e(TAG, "Unable to import preferences", e);
Toast.makeText(getContext(), "Unable to import preferences", Toast.LENGTH_SHORT).show();
Toast.makeText(getContext(), R.string.import_settings_error, Toast.LENGTH_SHORT).show();
}
}

Expand Down
7 changes: 7 additions & 0 deletions app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -321,4 +321,11 @@
<string name="icons_themed_name">Symboldesigns</string>
<string name="icons_themed_summary">Symbole werden mit Systemfarben eingefärbt (beta)</string>
<string name="search_provider_error_uri_cannot_be_handle">Die angegebene URI kann von keiner Anwendung auf Ihrem Gerät verarbeitet werden.</string>
<string name="export_settings_done">Die Einstellungen wurden erfolgreich in die Zwischenablage exportiert.</string>
<string name="export_settings_error">Die Einstellungen können nicht exportiert werden.</string>
<string name="import_settings_version_missing">Einstellungen können nicht importiert werden, da keine gültige Version gefunden wurde.</string>
<string name="import_settings_upgrade_kiss">Bitte aktualisieren Sie Ihre KISS-Version, bevor Sie diese Einstellungen importieren..</string>
<string name="import_settings_save_not_possible">Einstellungen können nicht gespeichert werden.</string>
<string name="import_settings_done">Einstellungen erfolgreich importiert!</string>
<string name="import_settings_error">Die Einstellungen können nicht importiert werden.</string>
</resources>
11 changes: 4 additions & 7 deletions app/src/main/res/values/arrays.xml
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,12 @@
<item>enabled</item>
<item>disabled</item>
</string-array>
<string name="gesture_menu">Display menu</string>
<string name="gesture_hide_keyboard">Hide keyboard</string>
<string name="gesture_quicksettings">Display quick settings</string>

<string-array name="resultsSizeEntries">
<item>Default</item>
<item>Medium</item>
<item>Small</item>
<item>Smallest</item>
<item>@string/results_size_default</item>
<item>@string/results_size_medium</item>
<item>@string/results_size_small</item>
<item>@string/results_size_smallest</item>
</string-array>

<string-array name="resultsSizeValues" translatable="false">
Expand Down
14 changes: 14 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -334,4 +334,18 @@
<string name="always_default_web_search_on_enter">Always trigger default web search provider on enter</string>
<string name="icons_themed_name">Themed icons</string>
<string name="icons_themed_summary">Icons are tinted with system colors (beta)</string>
<string name="export_settings_done">Settings successfully exported to clipboard.</string>
<string name="export_settings_error">Unable to export settings.</string>
<string name="import_settings_version_missing">Unable to import settings, no valid version string detected.</string>
<string name="import_settings_upgrade_kiss">Please upgrade your KISS version before importing those settings.</string>
<string name="import_settings_save_not_possible">Unable to save settings.</string>
<string name="import_settings_done">Settings successfully imported!</string>
<string name="import_settings_error">Unable to import settings.</string>
<string name="results_size_default">Default</string>
<string name="results_size_medium">Medium</string>
<string name="results_size_small">Small</string>
<string name="results_size_smallest">Smallest</string>
<string name="gesture_menu">Display menu</string>
<string name="gesture_hide_keyboard">Hide keyboard</string>
<string name="gesture_quicksettings">Display quick settings</string>
</resources>

0 comments on commit bf30f4b

Please sign in to comment.