mirror of
https://github.com/nextcloud/notes-android.git
synced 2024-11-26 23:27:55 +03:00
Merge branch 'master' into 831-room
This commit is contained in:
commit
753458e3a5
5 changed files with 6 additions and 79 deletions
|
@ -63,7 +63,8 @@ android {
|
||||||
dependencies {
|
dependencies {
|
||||||
// Nextcloud SSO
|
// Nextcloud SSO
|
||||||
implementation "com.github.nextcloud:Android-SingleSignOn:0.5.3"
|
implementation "com.github.nextcloud:Android-SingleSignOn:0.5.3"
|
||||||
implementation 'com.github.stefan-niedermann.nextcloud-commons:sso-glide:0.0.5'
|
implementation 'com.github.stefan-niedermann.nextcloud-commons:sso-glide:0.0.7'
|
||||||
|
implementation 'com.github.stefan-niedermann:android-commons:0.0.4'
|
||||||
|
|
||||||
// Glide
|
// Glide
|
||||||
implementation 'com.github.bumptech.glide:glide:4.11.0'
|
implementation 'com.github.bumptech.glide:glide:4.11.0'
|
||||||
|
@ -89,7 +90,7 @@ dependencies {
|
||||||
implementation 'androidx.multidex:multidex:2.0.1'
|
implementation 'androidx.multidex:multidex:2.0.1'
|
||||||
|
|
||||||
// Testing
|
// Testing
|
||||||
testImplementation 'junit:junit:4.13'
|
testImplementation 'junit:junit:4.13.1'
|
||||||
androidTestImplementation 'com.android.support:support-annotations:28.0.0'
|
androidTestImplementation 'com.android.support:support-annotations:28.0.0'
|
||||||
androidTestImplementation 'com.android.support.test:runner:1.0.2'
|
androidTestImplementation 'com.android.support.test:runner:1.0.2'
|
||||||
androidTestImplementation 'androidx.test:runner:1.3.0'
|
androidTestImplementation 'androidx.test:runner:1.3.0'
|
||||||
|
|
|
@ -13,7 +13,7 @@ import android.widget.EditText;
|
||||||
import it.niedermann.owncloud.notes.R;
|
import it.niedermann.owncloud.notes.R;
|
||||||
import it.niedermann.owncloud.notes.shared.util.MarkDownUtil;
|
import it.niedermann.owncloud.notes.shared.util.MarkDownUtil;
|
||||||
|
|
||||||
import static it.niedermann.owncloud.notes.shared.util.ClipboardUtil.getClipboardURLorNull;
|
import static it.niedermann.android.util.ClipboardUtil.getClipboardURLorNull;
|
||||||
import static it.niedermann.owncloud.notes.shared.util.MarkDownUtil.CHECKBOX_UNCHECKED_MINUS_TRAILING_SPACE;
|
import static it.niedermann.owncloud.notes.shared.util.MarkDownUtil.CHECKBOX_UNCHECKED_MINUS_TRAILING_SPACE;
|
||||||
import static it.niedermann.owncloud.notes.shared.util.MarkDownUtil.getEndOfLine;
|
import static it.niedermann.owncloud.notes.shared.util.MarkDownUtil.getEndOfLine;
|
||||||
import static it.niedermann.owncloud.notes.shared.util.MarkDownUtil.getStartOfLine;
|
import static it.niedermann.owncloud.notes.shared.util.MarkDownUtil.getStartOfLine;
|
||||||
|
|
|
@ -12,7 +12,7 @@ import android.widget.EditText;
|
||||||
|
|
||||||
import it.niedermann.owncloud.notes.R;
|
import it.niedermann.owncloud.notes.R;
|
||||||
|
|
||||||
import static it.niedermann.owncloud.notes.shared.util.ClipboardUtil.getClipboardURLorNull;
|
import static it.niedermann.android.util.ClipboardUtil.getClipboardURLorNull;
|
||||||
|
|
||||||
public class ContextBasedRangeFormattingCallback implements ActionMode.Callback {
|
public class ContextBasedRangeFormattingCallback implements ActionMode.Callback {
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ import it.niedermann.owncloud.notes.R;
|
||||||
import it.niedermann.owncloud.notes.databinding.DialogExceptionBinding;
|
import it.niedermann.owncloud.notes.databinding.DialogExceptionBinding;
|
||||||
import it.niedermann.owncloud.notes.exception.tips.TipsAdapter;
|
import it.niedermann.owncloud.notes.exception.tips.TipsAdapter;
|
||||||
|
|
||||||
import static it.niedermann.owncloud.notes.shared.util.ClipboardUtil.copyToClipboard;
|
import static it.niedermann.android.util.ClipboardUtil.copyToClipboard;
|
||||||
|
|
||||||
public class ExceptionDialogFragment extends AppCompatDialogFragment {
|
public class ExceptionDialogFragment extends AppCompatDialogFragment {
|
||||||
|
|
||||||
|
|
|
@ -1,74 +0,0 @@
|
||||||
package it.niedermann.owncloud.notes.shared.util;
|
|
||||||
|
|
||||||
import android.content.ClipData;
|
|
||||||
import android.content.ClipboardManager;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.text.TextUtils;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
|
|
||||||
import java.net.MalformedURLException;
|
|
||||||
import java.net.URL;
|
|
||||||
|
|
||||||
import it.niedermann.owncloud.notes.R;
|
|
||||||
|
|
||||||
import static android.content.Context.CLIPBOARD_SERVICE;
|
|
||||||
|
|
||||||
public class ClipboardUtil {
|
|
||||||
|
|
||||||
private static final String TAG = ClipboardUtil.class.getSimpleName();
|
|
||||||
|
|
||||||
private ClipboardUtil() {
|
|
||||||
// Util class
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean copyToClipboard(@NonNull Context context, @Nullable String text) {
|
|
||||||
return copyToClipboard(context, text, text);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean copyToClipboard(@NonNull Context context, @Nullable String label, @Nullable String text) {
|
|
||||||
final ClipboardManager clipboardManager = (ClipboardManager) context.getSystemService(CLIPBOARD_SERVICE);
|
|
||||||
if (clipboardManager == null) {
|
|
||||||
Log.e(TAG, "ClipboardManager is null");
|
|
||||||
Toast.makeText(context, R.string.could_not_copy_to_clipboard, Toast.LENGTH_LONG).show();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
final ClipData clipData = ClipData.newPlainText(label, text);
|
|
||||||
clipboardManager.setPrimaryClip(clipData);
|
|
||||||
Log.i(TAG, "Copied to clipboard: [" + label + "] \"" + text + "\"");
|
|
||||||
Toast.makeText(context, R.string.copied_to_clipboard, Toast.LENGTH_SHORT).show();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
public static String getClipboardURLorNull(@NonNull Context context) {
|
|
||||||
final ClipboardManager clipboardManager = (ClipboardManager) context.getSystemService(CLIPBOARD_SERVICE);
|
|
||||||
if (clipboardManager == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
final ClipData clipboardData = clipboardManager.getPrimaryClip();
|
|
||||||
if (clipboardData == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (clipboardData.getItemCount() < 1) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
final ClipData.Item clipItem = clipboardData.getItemAt(0);
|
|
||||||
if (clipItem == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
final CharSequence clipText = clipItem.getText();
|
|
||||||
if (TextUtils.isEmpty(clipText)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
return new URL(clipText.toString()).toString();
|
|
||||||
} catch (MalformedURLException e) {
|
|
||||||
Log.d(TAG, "Clipboard does not contain a valid URL: " + clipText);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in a new issue