Skip to content

Commit

Permalink
bug fix, added german translation
Browse files Browse the repository at this point in the history
Signed-off-by: nuclearfog <sufianbekziz@protonmail.com>
  • Loading branch information
nuclearfog committed Jan 14, 2024
1 parent ba4d120 commit 93244b6
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ android {
targetSdkVersion 34
versionCode 3
versionName "2.0"
resConfigs 'en', 'de-rDE'
resConfigs 'en', 'de'
}

buildTypes {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.Toast;

/**
* Main activity of this application, used to show network selector and handle link conversion
Expand Down Expand Up @@ -38,6 +39,7 @@ protected void onCreate(Bundle savedInstanceState) {
selector.setAdapter(adapter);
if (settings.getMode() == AppSettings.MODE_DEFAULT) {
selector.setSelection(NetworkAdapter.INDEX_DEFAULT, false);
urlContainer.setVisibility(View.INVISIBLE);
} else if (settings.getMode() == AppSettings.MODE_CUSTOM) {
selector.setSelection(NetworkAdapter.INDEX_CUSTOM, false);
urlContainer.setVisibility(View.VISIBLE);
Expand All @@ -54,14 +56,19 @@ public void onClick(View v) {
if (v.getId() == R.id.network_confirm) {
String url = urlInput.getText().toString();
if (Patterns.WEB_URL.matcher(url).matches()) {
if (url.endsWith("/"))
url = url.substring(0, url.length() - 1);
// reformat url
if (url.startsWith("http://"))
url = "https://" + url.substring(7);
else if (!url.startsWith("https://"))
url = "https://" + url;
int index = url.indexOf("/", 8);
if (index >= 8)
url = url.substring(0, index);
urlInput.setText(url);
// save url
settings.setDomain(url);
settings.setMode(AppSettings.MODE_CUSTOM);
Toast.makeText(getApplicationContext(), R.string.info_instance_set, Toast.LENGTH_SHORT).show();
} else {
urlInput.setError(getString(R.string.error_wrong_url));
}
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/res/layout/layout_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:visibility="invisible"
android:importantForAutofill="no"
android:inputType="textUri"
android:background="@android:color/transparent"
Expand All @@ -44,7 +43,6 @@
android:id="@+id/network_confirm"
android:layout_width="@dimen/button_size"
android:layout_height="@dimen/button_size"
android:visibility="invisible"
android:src="@android:drawable/ic_menu_save"
android:contentDescription="@string/description_button" />

Expand Down
11 changes: 11 additions & 0 deletions app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Nitterify</string>
<string name="label_network_selector">Nitter-Instanz auswählen</string>
<string name="error_open_link">Link konnte nicht geöffnet werden!</string>
<string name="hint_url">Nitter-URL z.B. https://nitter.net</string>
<string name="error_wrong_url">Falsches URL-Format!</string>
<string name="description_button">Instanz-URL sichern</string>
<string name="info_instance_set">Instanz-URL gesichert</string>
<string name="custom_instance">Benutzerdefinierte Instanz</string>
</resources>
4 changes: 2 additions & 2 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
<string name="error_open_link">could not open link!</string>
<string name="hint_url">Nitter url e.g. https://nitter.net</string>
<string name="error_wrong_url">wrong URL format!</string>
<string name="title_open_with">open with</string>
<string name="description_button">save instance url</string>
<string name="info_instance_set">instance url saved</string>
<!-- instance for nitter.net -->
<string name="select_nitter">Nitter</string>
<string name="select_nitter" translatable="false">Nitter</string>
<!-- instance for nitter.net -->
<string name="custom_instance">custom instance</string>
</resources>

0 comments on commit 93244b6

Please sign in to comment.