add german error translation
This commit is contained in:
parent
81fd1f3ebb
commit
ba2ec36666
|
@ -27,7 +27,7 @@ import java.util.regex.Pattern;
|
|||
*/
|
||||
public class FbScraper extends AsyncTask<Void, Void, Void> {
|
||||
|
||||
private String error;
|
||||
private int error;
|
||||
private String input_url;
|
||||
private WeakReference<MainActivity> main; // no context leak with WeakReference
|
||||
private FbEvent event;
|
||||
|
@ -224,16 +224,16 @@ public class FbScraper extends AsyncTask<Void, Void, Void> {
|
|||
|
||||
} catch (URISyntaxException | MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
this.error = "Error: URL invalid.";
|
||||
this.error = R.string.error_url;
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
this.error = "Error: Scraping event data failed";
|
||||
this.error = R.string.error_scraping;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
this.error = "Error: Unable to connect.";
|
||||
this.error = R.string.error_connection;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
this.error = "Error: Unknown Error.";
|
||||
this.error = R.string.error_unknown;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.akdev.nofbeventscraper;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
@ -109,16 +110,12 @@ public class MainActivity extends AppCompatActivity {
|
|||
@Override
|
||||
public void onClick(View view) {
|
||||
|
||||
try {
|
||||
ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
String str = clipboard.getPrimaryClip().getItemAt(0).getText().toString();
|
||||
String str = Objects.requireNonNull(clipboard.getPrimaryClip()).getItemAt(0).getText().toString();
|
||||
|
||||
clear(true);
|
||||
edit_text_uri_input.setText(str);
|
||||
} catch (NullPointerException e) {
|
||||
e.printStackTrace();
|
||||
error("Error: Clipboard empty");
|
||||
}
|
||||
|
||||
startScraping();
|
||||
}
|
||||
});
|
||||
|
@ -222,8 +219,13 @@ public class MainActivity extends AppCompatActivity {
|
|||
scraper.execute();
|
||||
}
|
||||
|
||||
public void error(String str) {
|
||||
layout_uri_input.setError(str);
|
||||
public void error(Integer resId) {
|
||||
if (resId != null) {
|
||||
layout_uri_input.setError(getString(resId));
|
||||
} else {
|
||||
layout_uri_input.setError(null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -276,34 +278,34 @@ public class MainActivity extends AppCompatActivity {
|
|||
edit_text_uri_input.setText(event.url);
|
||||
|
||||
if (event.name.equals("")) {
|
||||
edit_text_event_name.setError("no event name detected");
|
||||
edit_text_event_name.setError(getString(R.string.error_no_name));
|
||||
} else {
|
||||
edit_text_event_name.setText(event.name);
|
||||
}
|
||||
|
||||
if (event.start_date == null) {
|
||||
edit_text_event_start.setError("no event start date detected");
|
||||
edit_text_event_start.setError(getString(R.string.error_no_start_date));
|
||||
} else {
|
||||
String str = FbEvent.dateTimeToString(event.start_date);
|
||||
edit_text_event_start.setText(str);
|
||||
}
|
||||
|
||||
if (event.end_date == null) {
|
||||
edit_text_event_end.setError("no event end date detected");
|
||||
edit_text_event_end.setError(getString(R.string.error_no_end_date));
|
||||
} else {
|
||||
String str = FbEvent.dateTimeToString(event.end_date);
|
||||
edit_text_event_end.setText(str);
|
||||
}
|
||||
|
||||
if (event.location.equals("")) {
|
||||
edit_text_event_location.setError("no event location detected");
|
||||
edit_text_event_location.setError(getString(R.string.error_no_location));
|
||||
} else {
|
||||
edit_text_event_location.setText(event.location);
|
||||
layout_event_location.setEndIconVisible(true);
|
||||
}
|
||||
|
||||
if (event.description.equals("")) {
|
||||
edit_text_event_description.setError("no event description detected");
|
||||
edit_text_event_description.setError(getString(R.string.error_no_description));
|
||||
} else {
|
||||
edit_text_event_description.setText(event.description);
|
||||
}
|
||||
|
@ -317,6 +319,7 @@ public class MainActivity extends AppCompatActivity {
|
|||
}
|
||||
|
||||
|
||||
@SuppressLint("RestrictedApi")
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
// Inflate the menu; this adds items to the action bar if it is present.
|
||||
|
|
|
@ -114,7 +114,6 @@
|
|||
android:id="@+id/edit_text_event_location"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:autoLink="map"
|
||||
android:focusable="false"
|
||||
android:cursorVisible="false"
|
||||
android:hint="@string/hint_event_location"
|
||||
|
|
|
@ -15,4 +15,14 @@
|
|||
<string name="tooltip_paste">Einfügen von Inhalten aus der Zwischenablage in das URL-Eingabefeld</string>
|
||||
<string name="preferences_url_setting">Welcher URL-Präfix ist zu verwenden?</string>
|
||||
<string name="preferences_url_setting_summary">Die Nutzung von m.facebook.com ist stabiler und schneller. Die Verwendung von www.facebook.com funktioniert besser bei Ereignissen mit mehreren Instanzen und zeigt eine hochauflösende Vorschau an, geht aber irgendwann kaputt, wenn Facebook das klassische Design deaktiviert.</string>
|
||||
<string name="error_clipboard_empty">Fehler: Zwischenablage leer</string>
|
||||
<string name="error_no_name">Fehler: Veranstaltungsname nicht verfügbar</string>
|
||||
<string name="error_no_start_date">Fehler: Veranstaltungsbeginn nicht verfügbar</string>
|
||||
<string name="error_no_end_date">Fehler: Veranstaltungsende nicht verfügbar</string>
|
||||
<string name="error_no_location">Fehler: Veranstaltungsort nicht verfügbar</string>
|
||||
<string name="error_no_description">Fehler: Veranstaltungsbeschreibung nicht verfügbar</string>
|
||||
<string name="error_scraping">Fehler: Veranstaltungsdaten nicht gefunden</string>
|
||||
<string name="error_url">Fehler: URL ungültig</string>
|
||||
<string name="error_connection">Fehler: Keine Verbindung möglich</string>
|
||||
<string name="error_unknown">Fehler: Unbekannter Fehler</string>
|
||||
</resources>
|
|
@ -19,10 +19,24 @@
|
|||
<string name="button_add">Add to calendar</string>
|
||||
<string name="tooltip_paste">Paste content from clipboard into the URL input box</string>
|
||||
|
||||
<!-- Errors -->
|
||||
<string name="error_clipboard_empty">Error: clipboard empty</string>
|
||||
<string name="error_no_name">Error: Event name unavailable</string>
|
||||
<string name="error_no_start_date">Error: Event start date unavailable</string>
|
||||
<string name="error_no_end_date">Error: Event end date unavailable</string>
|
||||
<string name="error_no_location">Error: Event location unavailable</string>
|
||||
<string name="error_no_description">Error: Event description unavailable</string>
|
||||
<string name="error_scraping">Error: Scraping event data failed</string>
|
||||
<string name="error_url">Error: URL invalid</string>
|
||||
<string name="error_connection">Error: Unable to connect</string>
|
||||
<string name="error_unknown">Error: Unknown Error</string>
|
||||
|
||||
<!-- Preferences -->
|
||||
<string name="preferences_scraper_header" translatable="false">Scraper</string>
|
||||
|
||||
<string name="preferences_url_setting">Which URL prefix to use</string>
|
||||
<string name="preferences_url_setting_summary">"Using m.facebook.com is more stable and faster. Using www.facebook.com works better with multiple instance events and will display a high resolution preview but will eventually break when Facebook disables the classic design. "</string>
|
||||
|
||||
|
||||
|
||||
</resources>
|
||||
|
|
Loading…
Reference in New Issue