Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasKaminsky committed Jun 27, 2024
2 parents c054c25 + f8e49f2 commit 36f1d11
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,15 @@
import android.preference.PreferenceManager;
import android.text.TextUtils;
import android.util.AndroidRuntimeException;
import android.util.DisplayMetrics;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo;
import android.webkit.CookieManager;
import android.webkit.CookieSyncManager;
import android.webkit.WebResourceRequest;
import android.webkit.WebResourceResponse;
import android.webkit.WebView;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.TextView.OnEditorActionListener;
import android.widget.Toast;
Expand Down Expand Up @@ -208,7 +202,6 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity

public static final int NO_ICON = 0;
public static final String EMPTY_STRING = "";

public static final int REQUEST_CODE_FIRST_RUN = 102;

/// parameters from EXTRAs in starter Intent
Expand Down Expand Up @@ -394,36 +387,50 @@ private void deleteCookies() {
* @param url The URL where the login request is to be anonymously posted.
* This URL should handle the login request and return the login URL.
* It's typically the entry point for the login process.
* Example: "https://example.com/index.php/login/v2"
* Example: "<a href="https://example.com/index.php/login/v2">...</a>"
*/
private void anonymouslyPostLoginRequest(String url) {
baseUrl = url;

Thread thread = new Thread(() -> {
PostMethod post = new PostMethod(baseUrl, false, new FormBody.Builder().build());

PlainClient client = clientFactory.createPlainClient();
post.execute(client);
String response = post.getResponseBodyAsString();
JsonObject jsonObject = JsonParser.parseString(response).getAsJsonObject();
String login = jsonObject.get("login").getAsString();
if (login == null) {
login = getResources().getString(R.string.webview_login_url);
}

String loginUrl = login;
runOnUiThread(() -> {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(loginUrl));
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
});
String response = getResponseOfAnonymouslyPostLoginRequest();

token = jsonObject.getAsJsonObject("poll").get("token").getAsString();
try {
JsonObject jsonObject = JsonParser.parseString(response).getAsJsonObject();
String loginUrl = getLoginUrl(jsonObject);
runOnUiThread(() -> launchDefaultWebBrowser(loginUrl));
token = jsonObject.getAsJsonObject("poll").get("token").getAsString();
} catch (Throwable t) {
Log_OC.d(TAG, "Error caught at anonymouslyPostLoginRequest: " + t);
DisplayUtils.showSnackMessage(this, R.string.authenticator_activity_login_error);
}
});

thread.start();
}

private String getResponseOfAnonymouslyPostLoginRequest() {
PostMethod post = new PostMethod(baseUrl, false, new FormBody.Builder().build());
PlainClient client = clientFactory.createPlainClient();
post.execute(client);
return post.getResponseBodyAsString();
}

private String getLoginUrl(JsonObject response) {
String result = response.get("login").getAsString();
if (result == null) {
result = getResources().getString(R.string.webview_login_url);
}

return result;
}

private void launchDefaultWebBrowser(String url) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}

private static String getWebLoginUserAgent() {
return Build.MANUFACTURER.substring(0, 1).toUpperCase(Locale.getDefault()) +
Build.MANUFACTURER.substring(1).toLowerCase(Locale.getDefault()) + " " + Build.MODEL + " (Android)";
Expand Down Expand Up @@ -1585,12 +1592,9 @@ private void doOnResumeAndBound() {
}
}


private void dismissWaitingDialog() {
Fragment frag = getSupportFragmentManager().findFragmentByTag(WAIT_DIALOG_TAG);
if (frag instanceof DialogFragment) {
DialogFragment dialog = (DialogFragment) frag;

if (frag instanceof DialogFragment dialog) {
try {
dialog.dismiss();
} catch (IllegalStateException e) {
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-ca/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -797,6 +797,7 @@
<string name="upload_cannot_create_file">No s\'ha pogut crear el fitxer local</string>
<string name="upload_chooser_title">Pujada des de…</string>
<string name="upload_content_from_other_apps">Pujada de contingut des d\'altres aplicacions</string>
<string name="upload_direct_camera_photo">Fotografia</string>
<string name="upload_direct_camera_upload">Pujada des de la càmera</string>
<string name="upload_file_dialog_filename">Nom de fitxer</string>
<string name="upload_file_dialog_filetype">Tipus de fitxer</string>
Expand All @@ -813,6 +814,7 @@
<string name="upload_local_storage_full">L\'emmagatzematge local és ple</string>
<string name="upload_local_storage_not_copied">El fitxer no es pot copiar a l\'emmagatzematge local</string>
<string name="upload_lock_failed">Ha fallat el blocatge de la carpeta</string>
<string name="upload_manually_cancelled">L\'usuari ha cancel·lat la pujada</string>
<string name="upload_old_android">El xifratge només és possible amb &gt;= Android 5.0</string>
<string name="upload_query_move_foreign_files">L\'espai insuficient evita la còpia dels fitxers seleccionats a la carpeta %1$s. Els hi voleu moure?</string>
<string name="upload_scan_doc_upload">Escaneja el document des de la càmera</string>
Expand Down
16 changes: 16 additions & 0 deletions app/src/main/res/values-nb-rNO/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
<string name="add_to_cloud">Legg til %1$s</string>
<string name="advanced_settings">Avanserte innstillinger</string>
<string name="allow_resharing">TIllat videre deling</string>
<string name="app_config_base_url_title">Grunnleggende URL-adresse</string>
<string name="app_config_proxy_host_title">Proxy-vertsnavn</string>
<string name="app_config_proxy_port_title">Proxy-port</string>
<string name="app_widget_description">Viser en widget fra dashbordet</string>
<string name="appbar_search_in">Søk i %s</string>
Expand Down Expand Up @@ -89,6 +91,8 @@
<string name="auth_unknown_host_title">Fant ikke vert</string>
<string name="auth_unsupported_multiaccount">%1$s støtter ikke flere kontoer</string>
<string name="auth_wrong_connection_title">Klarte ikke å opprette tilkobling</string>
<string name="authenticator_activity_cancel_login">Avbryt pålogging</string>
<string name="authenticator_activity_please_complete_login_process">Fullfør påloggingsprosessen i nettleseren din</string>
<string name="auto_upload_file_behaviour_kept_in_folder">beholdt i opprinnelig mappe da den kun har leserettigheter</string>
<string name="auto_upload_on_wifi">Kun last opp på ubegrenset Wi-Fi</string>
<string name="auto_upload_path">/Auto-opplasting</string>
Expand Down Expand Up @@ -173,6 +177,7 @@
<string name="confirmation_remove_folder_alert">Ønsker du virkelig å slette %1$s og dets innhold?</string>
<string name="confirmation_remove_folders_alert">Vil du virkelig fjerne de valgte elementene og dets innhold?</string>
<string name="confirmation_remove_local">Kun lokalt</string>
<string name="conflict_dialog_error">Dialogboksen Konfliktløser kan ikke opprettes</string>
<string name="conflict_file_headline">Konflikt med%1$s</string>
<string name="conflict_local_file">Lokal fil</string>
<string name="conflict_message_description">Hvis du velger begge versjonene vil den lokale filen få et tall lagt til på slutten av navnet.</string>
Expand Down Expand Up @@ -205,6 +210,7 @@
<string name="create_new_presentation">Ny presentasjon</string>
<string name="create_new_spreadsheet">Nytt regneark</string>
<string name="create_rich_workspace">Legg til mappebeskrivelse</string>
<string name="creates_rich_workspace">Legger til mappebeskrivelse</string>
<string name="credentials_disabled">Legitimasjon deaktivert</string>
<string name="daily_backup">Daglig sikkerhetskopi</string>
<string name="data_to_back_up">Data å sikkerhetskopiere</string>
Expand Down Expand Up @@ -315,6 +321,7 @@
<string name="error_showing_encryption_dialog">Feil ved visning av krypteringsoppsett</string>
<string name="error_starting_direct_camera_upload">Klarte ikke å starte opp kamera</string>
<string name="error_starting_doc_scan">Feil ved start av dokumentskanning</string>
<string name="error_uploading_direct_camera_upload">Kunne ikke laste opp medier som er tatt</string>
<string name="etm_accounts">Kontoer</string>
<string name="etm_background_execution_count">Tidene går på 48 timer</string>
<string name="etm_background_job_created">Opprettet</string>
Expand Down Expand Up @@ -399,6 +406,7 @@
<string name="file_not_found">Finner ikke filen</string>
<string name="file_not_synced">Kunne ikke synkronisere fil. Viser sist tilgjengelige versjon.</string>
<string name="file_rename">Gi nytt navn</string>
<string name="file_upload_worker_same_file_already_exists">Samme fil eksisterer allerede, ingen konflikt oppdaget</string>
<string name="file_version_restored_error">Feil ved gjennoppretting av fil versjon!</string>
<string name="file_version_restored_successfully">Vellykket gjenoppretting av fil versjon.</string>
<string name="filedetails_details">Detaljer</string>
Expand Down Expand Up @@ -657,13 +665,15 @@
<string name="preview_image_description">Bildeforhåndsvisning</string>
<string name="preview_image_error_no_local_file">Ingen lokal fil å forhåndsvise</string>
<string name="preview_image_error_unknown_format">Kunne ikke vise bilde</string>
<string name="preview_media_unhandled_http_code_message">Filen er for øyeblikket låst av en annen bruker eller prosess og kan derfor ikke slettes. Prøv igjen senere.</string>
<string name="preview_sorry">Beklager</string>
<string name="privacy">Personvern</string>
<string name="public_share_name">Nytt navn</string>
<string name="push_notifications_not_implemented">Push-merknader er avskrudd på grunn av avhengigheter til proprietære Google Play-tjenester.</string>
<string name="push_notifications_old_login">Ingen push-varsler på grunn av utdatert innloggingsøkt. Du bør vurdere å legge til kontoen på nytt.</string>
<string name="push_notifications_temp_error">Push-merknader er for tiden ikke tilgjengelige.</string>
<string name="qr_could_not_be_read">QR-koden kunne ikke leses!</string>
<string name="receive_external_files_activity_start_sync_folder_is_not_exists_message">Finner ikke mappen, synkroniseringsoperasjonen avbrytes</string>
<string name="recommend_subject">Prøv %1$s på denne enheten.</string>
<string name="recommend_text">Jeg inviterer deg til å bruke %1$s på enheten din.\nLast ned her: %2$s</string>
<string name="recommend_urls">%1$s eller %2$s</string>
Expand Down Expand Up @@ -888,12 +898,16 @@
<string name="upload_action_cancelled_resume">Gjenoppta avbrutte opplastinger</string>
<string name="upload_action_failed_clear">Fjern feilede opplastinger</string>
<string name="upload_action_failed_retry">Prøv å laste opp igjen.</string>
<string name="upload_action_file_not_exist_message">Noen filer finnes ikke lenger. Disse opplastingene kan ikke gjenopptas.</string>
<string name="upload_action_global_upload_pause">Sett alle opplastinger på pause</string>
<string name="upload_action_global_upload_resume">Gjenoppta alle opplastinger</string>
<string name="upload_cannot_create_file">Kan ikke opprette lokal fil</string>
<string name="upload_chooser_title">Last opp fra…</string>
<string name="upload_content_from_other_apps">Last opp innhold fra andre apper</string>
<string name="upload_direct_camera_photo">Bilde</string>
<string name="upload_direct_camera_promt">Vil du ta et bilde eller en video?</string>
<string name="upload_direct_camera_upload">Last opp fra kamera</string>
<string name="upload_direct_camera_video">Video</string>
<string name="upload_file_dialog_filename">Filnavn</string>
<string name="upload_file_dialog_filetype">Filtype</string>
<string name="upload_file_dialog_filetype_googlemap_shortcut">Google Maps snarveisfil (%s)</string>
Expand All @@ -906,11 +920,13 @@
<string name="upload_list_delete">Slett</string>
<string name="upload_list_empty_headline">Ingen opplastinger tilgjengelig</string>
<string name="upload_list_empty_text_auto_upload">Last opp noe innhold eller aktiver automatisk opplasting!</string>
<string name="upload_list_expand_header">Vis/skjul utvidelse av topptekst</string>
<string name="upload_list_resolve_conflict">Løs konflikt</string>
<string name="upload_local_storage_full">Lokal lagring full</string>
<string name="upload_local_storage_not_copied">Filen kunne ikke kopieres til lokal lagring</string>
<string name="upload_lock_failed">Låsing av mappe feilet</string>
<string name="upload_manually_cancelled">Opplasting ble avbrutt av bruker</string>
<string name="upload_notification_manager_start_text">%1$d / %2$d - %3$s</string>
<string name="upload_old_android">Kryptering er bare mulig med &gt;= Android 5.0</string>
<string name="upload_query_move_foreign_files">Det er ikke nok plass til å kopiere de valgte filene inn i mappen %1$s. Vil du flytte dem i stedet? </string>
<string name="upload_quota_exceeded">Overskredet lagringskvote</string>
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 @@ -349,6 +349,7 @@

<string name="authenticator_activity_cancel_login">Cancel Login</string>
<string name="authenticator_activity_please_complete_login_process">Please complete login process in your browser</string>
<string name="authenticator_activity_login_error">There was an issue processing your login request. Please try again later.</string>

<string name="favorite">Add to favorites</string>
<string name="unset_favorite">Remove from favorites</string>
Expand Down

0 comments on commit 36f1d11

Please sign in to comment.