Merge remote-tracking branch 'origin/master' into dev

This commit is contained in:
Tobias Kaminsky 2023-11-22 02:31:04 +01:00
commit bc2ed72ade
13 changed files with 180 additions and 22 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 53 KiB

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View file

@ -7,7 +7,7 @@
*
* Copyright (C) 2018 Andy Scherzinger
* Copyright (C) 2020 Chris Narkiewicz <hello@ezaquarii.com>
* Copyright (C) 2020 TSI-mc
* Copyright (C) 2023 TSI-mc
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
@ -25,11 +25,17 @@
package com.owncloud.android.ui.fragment;
import android.Manifest;
import android.accounts.AccountManager;
import android.app.Activity;
import android.app.SearchManager;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.provider.ContactsContract;
import android.text.InputType;
import android.text.TextUtils;
import android.view.LayoutInflater;
@ -46,6 +52,7 @@ import com.owncloud.android.datamodel.FileDataStorageManager;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.lib.common.OwnCloudAccount;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.lib.resources.shares.OCShare;
import com.owncloud.android.lib.resources.shares.ShareType;
import com.owncloud.android.lib.resources.status.NextcloudVersion;
@ -61,6 +68,7 @@ import com.owncloud.android.ui.fragment.util.FileDetailSharingFragmentHelper;
import com.owncloud.android.ui.helpers.FileOperationsHelper;
import com.owncloud.android.utils.ClipboardUtil;
import com.owncloud.android.utils.DisplayUtils;
import com.owncloud.android.utils.PermissionUtil;
import com.owncloud.android.utils.theme.ViewThemeUtils;
import java.util.ArrayList;
@ -68,6 +76,8 @@ import java.util.List;
import javax.inject.Inject;
import androidx.activity.result.ActivityResultLauncher;
import androidx.activity.result.contract.ActivityResultContracts;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
@ -167,6 +177,8 @@ public class FileDetailSharingFragment extends Fragment implements ShareeListAda
file.isEncrypted()));
binding.sharesList.setLayoutManager(new LinearLayoutManager(getContext()));
binding.pickContactEmailBtn.setOnClickListener(v -> checkContactPermission());
setupView();
return view;
@ -208,6 +220,7 @@ public class FileDetailSharingFragment extends Fragment implements ShareeListAda
} else {
binding.searchView.setQueryHint(getResources().getString(R.string.reshare_not_allowed));
binding.searchView.setInputType(InputType.TYPE_NULL);
binding.pickContactEmailBtn.setVisibility(View.GONE);
disableSearchView(binding.searchView);
}
}
@ -460,6 +473,52 @@ public class FileDetailSharingFragment extends Fragment implements ShareeListAda
adapter.addShares(publicShares);
}
private void checkContactPermission() {
if (PermissionUtil.checkSelfPermission(requireActivity(), Manifest.permission.READ_CONTACTS)) {
pickContactEmail();
} else {
requestContactPermissionLauncher.launch(Manifest.permission.READ_CONTACTS);
}
}
private void pickContactEmail() {
Intent intent = new Intent(Intent.ACTION_PICK);
intent.setDataAndType(ContactsContract.Contacts.CONTENT_URI, ContactsContract.CommonDataKinds.Email.CONTENT_TYPE);
onContactSelectionResultLauncher.launch(intent);
}
private void handleContactResult(@NonNull Uri contactUri) {
// Define the projection to get all email addresses.
String[] projection = {ContactsContract.CommonDataKinds.Email.ADDRESS};
Cursor cursor = fileActivity.getContentResolver().query(contactUri, projection, null, null, null);
if (cursor != null) {
if (cursor.moveToFirst()) {
// The contact has only one email address, use it.
int columnIndex = cursor.getColumnIndex(ContactsContract.CommonDataKinds.Email.ADDRESS);
if (columnIndex != -1) {
// Use the email address as needed.
// email variable contains the selected contact's email address.
String email = cursor.getString(columnIndex);
binding.searchView.post(() -> {
binding.searchView.setQuery(email, false);
binding.searchView.requestFocus();
});
} else {
DisplayUtils.showSnackMessage(binding.getRoot(), R.string.email_pick_failed);
Log_OC.e(FileDetailSharingFragment.class.getSimpleName(), "Failed to pick email address.");
}
} else {
DisplayUtils.showSnackMessage(binding.getRoot(), R.string.email_pick_failed);
Log_OC.e(FileDetailSharingFragment.class.getSimpleName(), "Failed to pick email address as no Email found.");
}
cursor.close();
} else {
DisplayUtils.showSnackMessage(binding.getRoot(), R.string.email_pick_failed);
Log_OC.e(FileDetailSharingFragment.class.getSimpleName(), "Failed to pick email address as Cursor is null.");
}
}
private boolean containsNoNewPublicShare(List<OCShare> shares) {
for (OCShare share : shares) {
@ -546,6 +605,38 @@ public class FileDetailSharingFragment extends Fragment implements ShareeListAda
fileOperationsHelper.setPermissionsToShare(share, permission);
}
//launcher for contact permission
private final ActivityResultLauncher<String> requestContactPermissionLauncher =
registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> {
if (isGranted) {
pickContactEmail();
} else {
DisplayUtils.showSnackMessage(binding.getRoot(), R.string.contact_no_permission);
}
});
//launcher to handle contact selection
private final ActivityResultLauncher<Intent> onContactSelectionResultLauncher =
registerForActivityResult(new ActivityResultContracts.StartActivityForResult(),
result -> {
if (result.getResultCode() == Activity.RESULT_OK) {
Intent intent = result.getData();
if (intent == null) {
DisplayUtils.showSnackMessage(binding.getRoot(), R.string.email_pick_failed);
return;
}
Uri contactUri = intent.getData();
if (contactUri == null) {
DisplayUtils.showSnackMessage(binding.getRoot(), R.string.email_pick_failed);
return;
}
handleContactResult(contactUri);
}
});
public interface OnEditShareListener {
void editExistingShare(OCShare share, int screenTypePermission, boolean isReshareShown,
boolean isExpiryDateShown);

View file

@ -0,0 +1,26 @@
<!--
@author Google LLC
Copyright (C) 2023 Google LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="#666666"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@android:color/white"
android:pathData="M20,0L4,0v2h16L20,0zM4,24h16v-2L4,22v2zM20,4L4,4c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2L22,6c0,-1.1 -0.9,-2 -2,-2zM12,6.75c1.24,0 2.25,1.01 2.25,2.25s-1.01,2.25 -2.25,2.25S9.75,10.24 9.75,9 10.76,6.75 12,6.75zM17,17L7,17v-1.5c0,-1.67 3.33,-2.5 5,-2.5s5,0.83 5,2.5L17,17z" />
</vector>

View file

@ -1,7 +1,10 @@
<?xml version="1.0" encoding="utf-8"?><!--
Nextcloud Android client application
@author TSI-mc
Copyright (C) 2018 Andy Scherzinger
Copyright (C) 2023 TSI-mc
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
@ -29,83 +32,94 @@
android:id="@+id/search_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingStart="@dimen/standard_padding"
android:paddingEnd="@dimen/zero">
<ImageView
android:id="@+id/searchViewIcon"
android:layout_height="@dimen/user_icon_size"
android:layout_width="@dimen/user_icon_size"
android:padding="@dimen/standard_half_padding"
android:contentDescription="@string/avatar"
android:layout_height="@dimen/user_icon_size"
android:layout_gravity="center_vertical"
android:contentDescription="@string/avatar"
android:padding="@dimen/standard_half_padding"
android:src="@drawable/ic_search_grey" />
<androidx.appcompat.widget.SearchView
android:id="@+id/searchView"
style="@style/ownCloud.SearchView"
android:layout_width="match_parent"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/zero"
android:layout_marginEnd="@dimen/standard_quarter_margin"
android:layout_weight="1"
android:hint="@string/share_search"
app:searchIcon="@null" />
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/pick_contact_email_btn"
android:layout_width="@dimen/minimum_size_for_touchable_area"
android:layout_height="@dimen/minimum_size_for_touchable_area"
android:layout_gravity="center_vertical"
android:padding="12dp"
android:layout_marginEnd="@dimen/standard_quarter_margin"
android:src="@drawable/ic_contact_book" />
</LinearLayout>
<LinearLayout
android:id="@+id/shared_with_you_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/standard_half_margin"
android:layout_width="match_parent"
android:orientation="horizontal"
android:paddingLeft="@dimen/standard_padding"
android:paddingRight="@dimen/standard_padding"
android:paddingTop="@dimen/standard_padding">
android:paddingTop="@dimen/standard_padding"
android:paddingRight="@dimen/standard_padding">
<ImageView
android:contentDescription="@string/avatar"
android:id="@+id/shared_with_you_avatar"
android:layout_height="@dimen/user_icon_size"
android:layout_width="@dimen/user_icon_size"
android:layout_height="@dimen/user_icon_size"
android:contentDescription="@string/avatar"
android:src="@drawable/ic_user" />
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="@dimen/standard_padding"
android:paddingRight="@dimen/standard_padding"
android:paddingTop="@dimen/standard_half_padding">
android:paddingTop="@dimen/standard_half_padding"
android:paddingRight="@dimen/standard_padding">
<TextView
android:id="@+id/shared_with_you_username"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/shared_with_you_by"
android:textSize="@dimen/two_line_primary_text_size" />
<LinearLayout
android:id="@+id/shared_with_you_note_container"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:paddingTop="@dimen/standard_half_padding"
tools:ignore="UseCompoundDrawables">
<ImageView
android:contentDescription="@string/note_icon_hint"
android:layout_height="16dp"
android:layout_width="16dp"
android:layout_height="16dp"
android:contentDescription="@string/note_icon_hint"
android:src="@drawable/file_text" />
<TextView
android:id="@+id/shared_with_you_note"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_width="0dp"
android:paddingEnd="@dimen/standard_half_padding"
android:paddingStart="@dimen/standard_half_padding"
android:paddingEnd="@dimen/standard_half_padding"
android:textSize="16sp" />
</LinearLayout>
@ -113,10 +127,11 @@
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/sharesList"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="@drawable/divider"
android:dividerHeight="1dp"
android:id="@+id/sharesList"
android:layout_height="match_parent"
android:layout_width="match_parent" />
tools:listitem="@layout/file_details_share_link_share_item" />
</LinearLayout>

View file

@ -239,6 +239,7 @@
<string name="folder_confirm_create">Crear</string>
<string name="folder_list_empty_headline">No hay carpetas aquí</string>
<string name="folder_picker_choose_button_text">Seleccionar</string>
<string name="folder_picker_move_button_text">Mover</string>
<string name="forbidden_permissions">No se te permite %s</string>
<string name="forbidden_permissions_copy">para copiar este archivo</string>
<string name="forbidden_permissions_create">para crear este archivo</string>

View file

@ -540,6 +540,7 @@
<string name="wait_a_moment">Aguarda un momento…</string>
<string name="wait_checking_credentials">Verificando credenciales almacenadas</string>
<string name="wait_for_tmp_copy_from_private_storage">Copiando el archivo desde almacenamiento privado</string>
<string name="webview_version_check_alert_dialog_positive_button_title">Actualizar</string>
<string name="what_s_new_image">Imagen de qué es nuevo</string>
<string name="whats_new_skip">Omitir</string>
<string name="whats_new_title">Nuevo en %1$s</string>

View file

@ -525,6 +525,7 @@
<string name="version_dev_download">Lae alla</string>
<string name="wait_a_moment">Oota üks hetk…</string>
<string name="wait_for_tmp_copy_from_private_storage">Faili kopeerimine privaatsest salvestusalast</string>
<string name="webview_version_check_alert_dialog_positive_button_title">Uuenda</string>
<string name="whats_new_skip">Jäta vahele</string>
<string name="whats_your_status">Mis on su staatus?</string>
<string name="write_email">Saada kiri</string>

View file

@ -393,6 +393,7 @@
<string name="folder_list_empty_headline">Ez dago karpetarik hemen</string>
<string name="folder_picker_choose_button_text">Aukeratu</string>
<string name="folder_picker_choose_caption_text">Aukeratu helburuko karpeta</string>
<string name="folder_picker_copy_button_text">Kopiatu</string>
<string name="folder_picker_move_button_text">Mugitu</string>
<string name="forbidden_permissions">Ez daukazu baimenik %s</string>
<string name="forbidden_permissions_copy">fitxategi hau kopiatzeko</string>
@ -943,6 +944,7 @@
<string name="wait_a_moment">Itxaron momentu bat…</string>
<string name="wait_checking_credentials">Gordetako nortasun-datuak konprobatzen</string>
<string name="wait_for_tmp_copy_from_private_storage">Fitxategia biltegiratze pribatutik kopiatzen</string>
<string name="webview_version_check_alert_dialog_positive_button_title">Eguneratu</string>
<string name="what_s_new_image">Zer da irudi berria</string>
<string name="whats_new_skip">Salto egin</string>
<string name="whats_new_title">Berria %1$s-n</string>

View file

@ -393,6 +393,7 @@
<string name="folder_list_empty_headline">هیچ پوشه ای اینجا وجود ندارد</string>
<string name="folder_picker_choose_button_text">انتخاب کردن</string>
<string name="folder_picker_choose_caption_text">پوشهٔ هدف را انتخاب کنید</string>
<string name="folder_picker_copy_button_text">رونوشت</string>
<string name="folder_picker_move_button_text">انتقال</string>
<string name="forbidden_permissions">شما مجاز نیستید%s</string>
<string name="forbidden_permissions_copy">کپی این فایل</string>
@ -943,6 +944,7 @@
<string name="wait_a_moment">یک لحظه صبر کنید...</string>
<string name="wait_checking_credentials">بررسی اعتبارنامه‌های ذخیره شده</string>
<string name="wait_for_tmp_copy_from_private_storage">کپی کردن فایل از حافظه خصوصی</string>
<string name="webview_version_check_alert_dialog_positive_button_title">به‌روز رسانی</string>
<string name="what_s_new_image">چه تصویر جدیدی است</string>
<string name="whats_new_skip">رد شدن</string>
<string name="whats_new_title">جدید در %1$s</string>

View file

@ -381,6 +381,7 @@
<string name="folder_list_empty_headline">Ei kansioita täällä</string>
<string name="folder_picker_choose_button_text">Valitse</string>
<string name="folder_picker_choose_caption_text">Valitse kohdekansio</string>
<string name="folder_picker_copy_button_text">Kopioi</string>
<string name="folder_picker_move_button_text">Siirrä</string>
<string name="forbidden_permissions">Sinulla ei ole oikeutta %s</string>
<string name="forbidden_permissions_copy">kopioida tämä tiedosto</string>
@ -906,6 +907,7 @@ GNU yleinen lisenssi, versio 2</string>
<string name="wait_a_moment">Odota hetki…</string>
<string name="wait_checking_credentials">Tarkistetaan tallennettuja tilitietoja</string>
<string name="wait_for_tmp_copy_from_private_storage">Kopioidaan tiedostoa yksityisestä tallennustilasta</string>
<string name="webview_version_check_alert_dialog_positive_button_title">Päivitä</string>
<string name="what_s_new_image">Mitä uutta -kuva</string>
<string name="whats_new_skip">Ohita</string>
<string name="whats_new_title">Uutta versiossa %1$s</string>

View file

@ -18,6 +18,7 @@
<string name="actionbar_copy">Kopier</string>
<string name="actionbar_mkdir">Ny mappe</string>
<string name="actionbar_move">Flytt</string>
<string name="actionbar_move_or_copy">Flytt eller kopier</string>
<string name="actionbar_open_with">Åpne med</string>
<string name="actionbar_search">Søk</string>
<string name="actionbar_see_details">Detaljer</string>
@ -425,6 +426,13 @@
<string name="image_editor_rotate_ccw">Roter mot klokken</string>
<string name="image_editor_rotate_cw">Roter med klokken</string>
<string name="image_editor_unable_to_edit_image">Kan ikke endre bildet.</string>
<string name="image_preview_filedetails">Fildetaljer</string>
<string name="image_preview_image_taking_conditions">Betingelser for å ta bilder</string>
<string name="image_preview_unit_fnumber">ƒ/%s</string>
<string name="image_preview_unit_iso">ISO %s</string>
<string name="image_preview_unit_megapixel">%s MP</string>
<string name="image_preview_unit_millimetres">%s mm</string>
<string name="image_preview_unit_seconds">%s s</string>
<string name="in_folder">i mappen %1$s</string>
<string name="instant_upload_existing">Last også opp eksisterende filer</string>
<string name="instant_upload_on_charging">Bare last opp under lading</string>
@ -505,6 +513,7 @@
<string name="no_calendar_exists">Ingen kalender finnes</string>
<string name="no_email_app_available">Ingen program for å behandle e-post adresse</string>
<string name="no_items">Ingen gjenstander</string>
<string name="no_map_app_availble">Ingen app tilgjengelig for å håndtere kart</string>
<string name="no_mutliple_accounts_allowed">Kun én konto er tillatt</string>
<string name="no_pdf_app_available">Ingen app tilgjengelig for å håndtere PDF</string>
<string name="no_send_app">Ingen program for å sende valgt fil</string>
@ -591,7 +600,9 @@
<string name="prefs_imprint">Avtrykk</string>
<string name="prefs_instant_behaviour_dialogTitle">Opprinnelig fil vil bli…</string>
<string name="prefs_instant_behaviour_title">Opprinnelig fil vil bli…</string>
<string name="prefs_instant_upload_path_use_date_subfolders_summary">Lagre i undermapper basert på dato</string>
<string name="prefs_instant_upload_path_use_subfolders_title">Bruk undermapper</string>
<string name="prefs_instant_upload_subfolder_rule_title">Alternativer for undermappe</string>
<string name="prefs_keys_exist">Legg til ende-til-ende -kryptering på denne klienten</string>
<string name="prefs_license">Lisens</string>
<string name="prefs_lock">Appsikkerhet</string>
@ -781,6 +792,8 @@
<string name="stream_not_possible_headline">Intern strøming ikke mulig</string>
<string name="stream_not_possible_message">Vennligst last ned media i stedet, eller bruk ekstern app.</string>
<string name="strict_mode">Streng modus: ingen HTTP-tilkobling tillatt!</string>
<string name="sub_folder_rule_day">År/Måned/Dag</string>
<string name="sub_folder_rule_month">År/Måned</string>
<string name="sub_folder_rule_year">År</string>
<string name="subject_shared_with_you">\"%1$s\" er blitt delt med deg</string>
<string name="subject_user_shared_with_you">%1$s delte \"%2$s\" med deg</string>
@ -932,7 +945,9 @@
<string name="wait_a_moment">Vent et øyeblikk…</string>
<string name="wait_checking_credentials">Sjekker lagrede påloggingsdetaljer</string>
<string name="wait_for_tmp_copy_from_private_storage">Kopierer fil fra privat lager</string>
<string name="webview_version_check_alert_dialog_message">Vennligst oppdater Android systemets WebView-app for pålogging</string>
<string name="webview_version_check_alert_dialog_positive_button_title">Oppdater</string>
<string name="webview_version_check_alert_dialog_title">Oppdater Android systemets WebView</string>
<string name="what_s_new_image">Hva er nytt-bilde</string>
<string name="whats_new_skip">Hopp over</string>
<string name="whats_new_title">Nytt i %1$s</string>

View file

@ -602,6 +602,7 @@
<string name="actionbar_calendar_contacts_restore">Restore contacts &amp; calendar</string>
<string name="contacts_backup_button">Back up now</string>
<string name="contactlist_no_permission">No permission given, nothing imported.</string>
<string name="contact_no_permission">Contact permission is required.</string>
<string name="restore_backup">Restore backup</string>
<string name="contacts_preferences_no_file_found">No file found</string>
<string name="contacts_preferences_something_strange_happened">Could not find your last backup!</string>
@ -939,6 +940,7 @@
<string name="link_share_file_drop">File drop (upload only)</string>
<string name="could_not_retrieve_shares">Could not retrieve shares</string>
<string name="failed_update_ui">Failed to update UI</string>
<string name="email_pick_failed">Failed to pick email address.</string>
<string name="remote">(remote)</string>
<string name="set_status">Set status</string>
<string name="online_status">Online status</string>