mirror of
https://github.com/nextcloud/android.git
synced 2024-11-26 07:05:49 +03:00
Drop Android 4.4 Support
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
parent
a9906aa1d7
commit
cf2a35f64d
20 changed files with 80 additions and 177 deletions
|
@ -98,9 +98,6 @@ for (TaskExecutionRequest tr : getGradle().getStartParameter().getTaskRequests()
|
|||
apply from: 'gplay.gradle'
|
||||
System.console().println("Applying gplay.gradle")
|
||||
}
|
||||
if (arg.contains("lint")) {
|
||||
testMinSdk = 19
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -129,7 +126,7 @@ android {
|
|||
compileSdkVersion 29
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion 19
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 29
|
||||
|
||||
// arguments to be passed to functional tests
|
||||
|
|
|
@ -384,21 +384,30 @@ public class MainApp extends MultiDexApplication implements HasAndroidInjector {
|
|||
@SuppressLint("ApplySharedPref") // commit is done on purpose to write immediately
|
||||
private void fixStoragePath() {
|
||||
if (!preferences.isStoragePathFixEnabled()) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
StoragePoint[] storagePoints = DataStorageProvider.getInstance().getAvailableStoragePoints();
|
||||
String storagePath = preferences.getStoragePath("");
|
||||
StoragePoint[] storagePoints = DataStorageProvider.getInstance().getAvailableStoragePoints();
|
||||
String storagePath = preferences.getStoragePath("");
|
||||
|
||||
if (TextUtils.isEmpty(storagePath)) {
|
||||
if (preferences.getLastSeenVersionCode() != 0) {
|
||||
// We already used the app, but no storage is set - fix that!
|
||||
preferences.setStoragePath(Environment.getExternalStorageDirectory().getAbsolutePath());
|
||||
preferences.removeKeysMigrationPreference();
|
||||
} else {
|
||||
// find internal storage path that's indexable
|
||||
boolean set = false;
|
||||
if (TextUtils.isEmpty(storagePath)) {
|
||||
if (preferences.getLastSeenVersionCode() != 0) {
|
||||
// We already used the app, but no storage is set - fix that!
|
||||
preferences.setStoragePath(Environment.getExternalStorageDirectory().getAbsolutePath());
|
||||
preferences.removeKeysMigrationPreference();
|
||||
} else {
|
||||
// find internal storage path that's indexable
|
||||
boolean set = false;
|
||||
for (StoragePoint storagePoint : storagePoints) {
|
||||
if (storagePoint.getStorageType() == StoragePoint.StorageType.INTERNAL &&
|
||||
storagePoint.getPrivacyType() == StoragePoint.PrivacyType.PUBLIC) {
|
||||
preferences.setStoragePath(storagePoint.getPath());
|
||||
preferences.removeKeysMigrationPreference();
|
||||
set = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!set) {
|
||||
for (StoragePoint storagePoint : storagePoints) {
|
||||
if (storagePoint.getStorageType() == StoragePoint.StorageType.INTERNAL &&
|
||||
storagePoint.getPrivacyType() == StoragePoint.PrivacyType.PUBLIC) {
|
||||
if (storagePoint.getPrivacyType() == StoragePoint.PrivacyType.PUBLIC) {
|
||||
preferences.setStoragePath(storagePoint.getPath());
|
||||
preferences.removeKeysMigrationPreference();
|
||||
set = true;
|
||||
|
@ -406,27 +415,10 @@ public class MainApp extends MultiDexApplication implements HasAndroidInjector {
|
|||
}
|
||||
}
|
||||
|
||||
if (!set) {
|
||||
for (StoragePoint storagePoint : storagePoints) {
|
||||
if (storagePoint.getPrivacyType() == StoragePoint.PrivacyType.PUBLIC) {
|
||||
preferences.setStoragePath(storagePoint.getPath());
|
||||
preferences.removeKeysMigrationPreference();
|
||||
set = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
preferences.setStoragePathFixEnabled(true);
|
||||
} else {
|
||||
preferences.removeKeysMigrationPreference();
|
||||
preferences.setStoragePathFixEnabled(true);
|
||||
}
|
||||
preferences.setStoragePathFixEnabled(true);
|
||||
} else {
|
||||
if (TextUtils.isEmpty(storagePath)) {
|
||||
preferences.setStoragePath(Environment.getExternalStorageDirectory().getAbsolutePath());
|
||||
}
|
||||
preferences.removeKeysMigrationPreference();
|
||||
preferences.setStoragePathFixEnabled(true);
|
||||
}
|
||||
|
@ -479,12 +471,10 @@ public class MainApp extends MultiDexApplication implements HasAndroidInjector {
|
|||
connectivityService,
|
||||
powerManagementService);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
ReceiversHelper.registerPowerSaveReceiver(uploadsStorageManager,
|
||||
accountManager,
|
||||
connectivityService,
|
||||
powerManagementService);
|
||||
}
|
||||
ReceiversHelper.registerPowerSaveReceiver(uploadsStorageManager,
|
||||
accountManager,
|
||||
connectivityService,
|
||||
powerManagementService);
|
||||
}
|
||||
|
||||
public static void notificationChannels() {
|
||||
|
|
|
@ -330,13 +330,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
|||
private void deleteCookies() {
|
||||
try {
|
||||
CookieSyncManager.createInstance(this);
|
||||
CookieManager cookieManager = CookieManager.getInstance();
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
cookieManager.removeAllCookies(null);
|
||||
} else {
|
||||
cookieManager.removeAllCookie();
|
||||
}
|
||||
CookieManager.getInstance().removeAllCookies(null);
|
||||
} catch (AndroidRuntimeException e) {
|
||||
Log_OC.e(TAG, e.getMessage());
|
||||
}
|
||||
|
@ -439,9 +433,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
|||
mLoginWebView.setVisibility(View.VISIBLE);
|
||||
|
||||
ThemeUtils.colorStatusBar(AuthenticatorActivity.this, primaryColor);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
getWindow().setNavigationBarColor(primaryColor);
|
||||
}
|
||||
getWindow().setNavigationBarColor(primaryColor);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
|
||||
package com.owncloud.android.datastorage;
|
||||
|
||||
import android.os.Build;
|
||||
import android.os.Environment;
|
||||
|
||||
import com.owncloud.android.MainApp;
|
||||
|
@ -67,34 +66,22 @@ public class DataStorageProvider {
|
|||
|
||||
List<String> paths = new ArrayList<>();
|
||||
StoragePoint storagePoint;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
for (File f : MainApp.getAppContext().getExternalMediaDirs()) {
|
||||
if (f != null && !paths.contains(f.getAbsolutePath())) {
|
||||
storagePoint = new StoragePoint();
|
||||
storagePoint.setPath(f.getAbsolutePath());
|
||||
storagePoint.setDescription(f.getAbsolutePath());
|
||||
storagePoint.setPrivacyType(StoragePoint.PrivacyType.PUBLIC);
|
||||
if (f.getAbsolutePath().startsWith("/storage/emulated/0")) {
|
||||
storagePoint.setStorageType(StoragePoint.StorageType.INTERNAL);
|
||||
for (File f : MainApp.getAppContext().getExternalMediaDirs()) {
|
||||
if (f != null && !paths.contains(f.getAbsolutePath())) {
|
||||
storagePoint = new StoragePoint();
|
||||
storagePoint.setPath(f.getAbsolutePath());
|
||||
storagePoint.setDescription(f.getAbsolutePath());
|
||||
storagePoint.setPrivacyType(StoragePoint.PrivacyType.PUBLIC);
|
||||
if (f.getAbsolutePath().startsWith("/storage/emulated/0")) {
|
||||
storagePoint.setStorageType(StoragePoint.StorageType.INTERNAL);
|
||||
mCachedStoragePoints.add(storagePoint);
|
||||
} else {
|
||||
storagePoint.setStorageType(StoragePoint.StorageType.EXTERNAL);
|
||||
if (isExternalStorageWritable()) {
|
||||
mCachedStoragePoints.add(storagePoint);
|
||||
} else {
|
||||
storagePoint.setStorageType(StoragePoint.StorageType.EXTERNAL);
|
||||
if (isExternalStorageWritable()) {
|
||||
mCachedStoragePoints.add(storagePoint);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (IStoragePointProvider p : mStorageProviders) {
|
||||
if (p.canProvideStoragePoints()) {
|
||||
mCachedStoragePoints.addAll(p.getAvailableStoragePoint());
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < mCachedStoragePoints.size(); i++) {
|
||||
paths.add(mCachedStoragePoints.get(i).getPath());
|
||||
}
|
||||
}
|
||||
|
||||
// Now we go add private ones
|
||||
|
|
|
@ -23,7 +23,6 @@ package com.owncloud.android.files;
|
|||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
|
||||
|
@ -333,7 +332,7 @@ public class FileMenuFilter {
|
|||
*/
|
||||
@NextcloudServer(max = 18)
|
||||
private boolean isRichDocumentEditingSupported(OCCapability capability, String mimeType) {
|
||||
return isSingleFile() && android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP &&
|
||||
return isSingleFile() &&
|
||||
(capability.getRichDocumentsMimeTypeList().contains(mimeType) ||
|
||||
capability.getRichDocumentsOptionalMimeTypeList().contains(mimeType)) &&
|
||||
capability.getRichDocumentsDirectEditing().isTrue();
|
||||
|
|
|
@ -26,7 +26,6 @@ import android.accounts.Account;
|
|||
import android.accounts.AuthenticatorException;
|
||||
import android.accounts.OperationCanceledException;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.res.AssetFileDescriptor;
|
||||
|
@ -34,7 +33,6 @@ import android.database.Cursor;
|
|||
import android.graphics.Point;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.CancellationSignal;
|
||||
import android.os.Handler;
|
||||
|
@ -574,7 +572,6 @@ public class DocumentsStorageProvider extends DocumentsProvider {
|
|||
context.getContentResolver().notifyChange(toNotifyUri(parentFolder), null, false);
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
private void recursiveRevokePermission(Document document) {
|
||||
FileDataStorageManager storageManager = document.getStorageManager();
|
||||
OCFile file = document.getFile();
|
||||
|
|
|
@ -112,7 +112,6 @@ public abstract class EditorWebView extends ExternalSiteWebView {
|
|||
finish();
|
||||
}
|
||||
|
||||
@SuppressLint("AddJavascriptInterface") // suppress warning as webview is only used >= Lollipop
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
webViewLayout = R.layout.richdocuments_webview; // TODO rename
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
package com.owncloud.android.ui.activity;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.SystemClock;
|
||||
import android.text.Editable;
|
||||
|
@ -364,12 +363,12 @@ public class PassCodeActivity extends AppCompatActivity implements Injectable {
|
|||
* @return 'True' when the key event was processed by this method.
|
||||
*/
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event){
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount()== 0){
|
||||
if(ACTION_CHECK.equals(getIntent().getAction()) && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
|
||||
if (ACTION_CHECK.equals(getIntent().getAction())) {
|
||||
moveTaskToBack(true);
|
||||
finishAndRemoveTask();
|
||||
}else if (ACTION_REQUEST_WITH_RESULT.equals(getIntent().getAction()) ||
|
||||
} else if (ACTION_REQUEST_WITH_RESULT.equals(getIntent().getAction()) ||
|
||||
ACTION_CHECK_WITH_RESULT.equals(getIntent().getAction())) {
|
||||
finish();
|
||||
}// else, do nothing, but report that the key was consumed to stay alive
|
||||
|
|
|
@ -62,7 +62,6 @@ import java.lang.ref.WeakReference;
|
|||
import javax.inject.Inject;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.Unbinder;
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
|
@ -70,7 +69,6 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
|||
/**
|
||||
* Opens document for editing via Richdocuments app in a web view
|
||||
*/
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
public class RichDocumentsEditorWebView extends EditorWebView {
|
||||
public static final int REQUEST_LOCAL_FILE = 101;
|
||||
private static final int REQUEST_REMOTE_FILE = 100;
|
||||
|
@ -92,7 +90,6 @@ public class RichDocumentsEditorWebView extends EditorWebView {
|
|||
protected ClientFactory clientFactory;
|
||||
|
||||
@SuppressFBWarnings("ANDROID_WEB_VIEW_JAVASCRIPT_INTERFACE")
|
||||
@SuppressLint("AddJavascriptInterface") // suppress warning as webview is only used >= Lollipop
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
|
|
@ -27,7 +27,6 @@ import android.annotation.SuppressLint;
|
|||
import android.graphics.Bitmap;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
|
@ -50,7 +49,6 @@ import androidx.appcompat.app.ActionBar;
|
|||
import androidx.appcompat.widget.AppCompatSpinner;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.core.view.ViewCompat;
|
||||
|
||||
/**
|
||||
* Base class providing toolbar registration functionality, see {@link #setupToolbar(boolean, boolean)}.
|
||||
|
@ -161,22 +159,14 @@ public abstract class ToolbarActivity extends BaseActivity {
|
|||
@SuppressLint("PrivateResource")
|
||||
private void showHomeSearchToolbar(boolean isShow) {
|
||||
if (isShow) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
mAppBar.setStateListAnimator(AnimatorInflater.loadStateListAnimator(mAppBar.getContext(),
|
||||
R.animator.appbar_elevation_off));
|
||||
} else {
|
||||
ViewCompat.setElevation(mAppBar, 0);
|
||||
}
|
||||
mAppBar.setStateListAnimator(AnimatorInflater.loadStateListAnimator(mAppBar.getContext(),
|
||||
R.animator.appbar_elevation_off));
|
||||
mDefaultToolbar.setVisibility(View.GONE);
|
||||
mHomeSearchToolbar.setVisibility(View.VISIBLE);
|
||||
ThemeUtils.colorStatusBar(this, ContextCompat.getColor(this, R.color.bg_default));
|
||||
} else {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
mAppBar.setStateListAnimator(AnimatorInflater.loadStateListAnimator(mAppBar.getContext(),
|
||||
R.animator.appbar_elevation_on));
|
||||
} else {
|
||||
ViewCompat.setElevation(mAppBar, getResources().getDimension(R.dimen.design_appbar_elevation));
|
||||
}
|
||||
mAppBar.setStateListAnimator(AnimatorInflater.loadStateListAnimator(mAppBar.getContext(),
|
||||
R.animator.appbar_elevation_on));
|
||||
mDefaultToolbar.setVisibility(View.VISIBLE);
|
||||
mHomeSearchToolbar.setVisibility(View.GONE);
|
||||
ThemeUtils.colorStatusBar(this);
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
|
||||
package com.owncloud.android.ui.adapter;
|
||||
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.CancellationSignal;
|
||||
import android.os.ParcelFileDescriptor;
|
||||
|
@ -40,9 +39,6 @@ import java.io.InputStream;
|
|||
import java.io.OutputStream;
|
||||
import java.util.Objects;
|
||||
|
||||
import androidx.annotation.RequiresApi;
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
public class PrintAdapter extends PrintDocumentAdapter {
|
||||
private static final String TAG = PrintAdapter.class.getSimpleName();
|
||||
private static final String PDF_NAME = "finalPrint.pdf";
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
package com.owncloud.android.ui.asynctasks;
|
||||
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Build;
|
||||
import android.print.PrintAttributes;
|
||||
import android.print.PrintDocumentAdapter;
|
||||
import android.print.PrintManager;
|
||||
|
@ -44,11 +43,8 @@ import java.io.FileOutputStream;
|
|||
import java.io.IOException;
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import androidx.annotation.RequiresApi;
|
||||
|
||||
import static android.content.Context.PRINT_SERVICE;
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
public class PrintAsyncTask extends AsyncTask<Void, Void, Boolean> {
|
||||
private static final String TAG = PrintAsyncTask.class.getSimpleName();
|
||||
private static final String JOB_NAME = "Document";
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
package com.owncloud.android.ui.fragment;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
@ -127,7 +126,6 @@ public class OCFileListBottomSheetDialog extends BottomSheetDialog {
|
|||
OCCapability capability = fileActivity.getCapabilities();
|
||||
if (capability.getRichDocuments().isTrue() &&
|
||||
capability.getRichDocumentsDirectEditing().isTrue() &&
|
||||
android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP &&
|
||||
capability.getRichDocumentsTemplatesAvailable().isTrue() &&
|
||||
!file.isEncrypted()) {
|
||||
templates.setVisibility(View.VISIBLE);
|
||||
|
@ -137,7 +135,6 @@ public class OCFileListBottomSheetDialog extends BottomSheetDialog {
|
|||
.getValue(user, ArbitraryDataProvider.DIRECT_EDITING);
|
||||
|
||||
if (!json.isEmpty() &&
|
||||
android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP &&
|
||||
!file.isEncrypted()) {
|
||||
DirectEditing directEditing = new Gson().fromJson(json, DirectEditing.class);
|
||||
|
||||
|
@ -174,8 +171,7 @@ public class OCFileListBottomSheetDialog extends BottomSheetDialog {
|
|||
}
|
||||
|
||||
// create rich workspace
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP &&
|
||||
FileMenuFilter.isEditorAvailable(getContext().getContentResolver(),
|
||||
if (FileMenuFilter.isEditorAvailable(getContext().getContentResolver(),
|
||||
user,
|
||||
MimeTypeUtil.MIMETYPE_TEXT_MARKDOWN) &&
|
||||
file != null && !file.isEncrypted()) {
|
||||
|
|
|
@ -29,7 +29,6 @@ import android.content.Context;
|
|||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
|
@ -1021,11 +1020,9 @@ public class OCFileListFragment extends ExtendedListFragment implements
|
|||
} else if (FileMenuFilter.isEditorAvailable(requireContext().getContentResolver(),
|
||||
accountManager.getUser(),
|
||||
file.getMimeType()) &&
|
||||
!file.isEncrypted() &&
|
||||
android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
!file.isEncrypted()) {
|
||||
mContainerActivity.getFileOperationsHelper().openFileWithTextEditor(file, getContext());
|
||||
} else if (capability.getRichDocumentsMimeTypeList().contains(file.getMimeType()) &&
|
||||
android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP &&
|
||||
capability.getRichDocumentsDirectEditing().isTrue() && !file.isEncrypted()) {
|
||||
mContainerActivity.getFileOperationsHelper().openFileAsRichDocument(file, getContext());
|
||||
} else {
|
||||
|
@ -1091,22 +1088,15 @@ public class OCFileListFragment extends ExtendedListFragment implements
|
|||
}
|
||||
case R.id.action_edit: {
|
||||
// should not be necessary, as menu item is filtered, but better play safe
|
||||
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
if (FileMenuFilter.isEditorAvailable(requireContext().getContentResolver(),
|
||||
accountManager.getUser(),
|
||||
singleFile.getMimeType())) {
|
||||
mContainerActivity.getFileOperationsHelper().openFileWithTextEditor(singleFile,
|
||||
getContext());
|
||||
} else {
|
||||
mContainerActivity.getFileOperationsHelper().openFileAsRichDocument(singleFile,
|
||||
getContext());
|
||||
}
|
||||
|
||||
return true;
|
||||
if (FileMenuFilter.isEditorAvailable(requireContext().getContentResolver(),
|
||||
accountManager.getUser(),
|
||||
singleFile.getMimeType())) {
|
||||
mContainerActivity.getFileOperationsHelper().openFileWithTextEditor(singleFile, getContext());
|
||||
} else {
|
||||
DisplayUtils.showSnackMessage(getView(), "Not supported on older than Android 5");
|
||||
return false;
|
||||
mContainerActivity.getFileOperationsHelper().openFileAsRichDocument(singleFile, getContext());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
case R.id.action_rename_file: {
|
||||
RenameFileDialogFragment dialog = RenameFileDialogFragment.newInstance(singleFile);
|
||||
|
|
|
@ -104,7 +104,6 @@ import java.util.regex.Pattern;
|
|||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.core.content.FileProvider;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
|
@ -288,14 +287,12 @@ public class FileOperationsHelper {
|
|||
|
||||
if (optionalUser.isPresent() && FileMenuFilter.isEditorAvailable(fileActivity.getContentResolver(),
|
||||
optionalUser.get(),
|
||||
file.getMimeType()) &&
|
||||
android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
file.getMimeType())) {
|
||||
openFileWithTextEditor(file, fileActivity);
|
||||
} else {
|
||||
Account account = fileActivity.getAccount();
|
||||
OCCapability capability = fileActivity.getStorageManager().getCapability(account.name);
|
||||
if (capability.getRichDocumentsMimeTypeList().contains(file.getMimeType()) &&
|
||||
android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP &&
|
||||
capability.getRichDocumentsDirectEditing().isTrue()) {
|
||||
openFileAsRichDocument(file, fileActivity);
|
||||
return;
|
||||
|
@ -360,7 +357,6 @@ public class FileOperationsHelper {
|
|||
}
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
public void openFileAsRichDocument(OCFile file, Context context) {
|
||||
Intent collaboraWebViewIntent = new Intent(context, RichDocumentsEditorWebView.class);
|
||||
collaboraWebViewIntent.putExtra(ExternalSiteWebView.EXTRA_TITLE, "Collabora");
|
||||
|
@ -369,7 +365,6 @@ public class FileOperationsHelper {
|
|||
context.startActivity(collaboraWebViewIntent);
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
public void openFileWithTextEditor(OCFile file, Context context) {
|
||||
Intent textEditorIntent = new Intent(context, TextEditorWebView.class);
|
||||
textEditorIntent.putExtra(ExternalSiteWebView.EXTRA_TITLE, "Text");
|
||||
|
|
|
@ -24,7 +24,6 @@ package com.owncloud.android.ui.preview;
|
|||
|
||||
import android.accounts.Account;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.view.Menu;
|
||||
|
@ -289,10 +288,6 @@ public class PreviewTextFileFragment extends PreviewTextFragment {
|
|||
menu.findItem(R.id.action_unset_favorite)
|
||||
);
|
||||
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
|
||||
FileMenuFilter.hideMenuItem(menu.findItem(R.id.action_edit));
|
||||
}
|
||||
|
||||
if (getFile().isSharedWithMe() && !getFile().canReshare()) {
|
||||
FileMenuFilter.hideMenuItem(menu.findItem(R.id.action_send_share_file));
|
||||
}
|
||||
|
@ -331,11 +326,8 @@ public class PreviewTextFileFragment extends PreviewTextFragment {
|
|||
}
|
||||
|
||||
case R.id.action_edit:
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
containerActivity.getFileOperationsHelper().openFileWithTextEditor(getFile(), getContext());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
containerActivity.getFileOperationsHelper().openFileWithTextEditor(getFile(), getContext());
|
||||
return true;
|
||||
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
|
|
|
@ -104,15 +104,10 @@ public class PreviewTextStringFragment extends PreviewTextFragment {
|
|||
}
|
||||
|
||||
FloatingActionButton fabMain = requireActivity().findViewById(R.id.fab_main);
|
||||
|
||||
if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
|
||||
fabMain.setVisibility(View.GONE);
|
||||
} else {
|
||||
fabMain.setVisibility(View.VISIBLE);
|
||||
fabMain.setEnabled(true);
|
||||
fabMain.setOnClickListener(v -> edit());
|
||||
ThemeUtils.colorFloatingActionButton(fabMain, R.drawable.ic_edit, requireContext());
|
||||
}
|
||||
fabMain.setVisibility(View.VISIBLE);
|
||||
fabMain.setEnabled(true);
|
||||
fabMain.setOnClickListener(v -> edit());
|
||||
ThemeUtils.colorFloatingActionButton(fabMain, R.drawable.ic_edit, requireContext());
|
||||
|
||||
return view;
|
||||
}
|
||||
|
|
|
@ -122,7 +122,7 @@ public final class ThemeUtils {
|
|||
}
|
||||
}
|
||||
|
||||
public static int calculateDarkColor(int color, Context context){
|
||||
public static int calculateDarkColor(int color, Context context) {
|
||||
try {
|
||||
return adjustLightness(-0.2f, color, -1f);
|
||||
} catch (Exception e) {
|
||||
|
@ -364,7 +364,7 @@ public final class ThemeUtils {
|
|||
}
|
||||
|
||||
public static void setStatusBarColor(Activity activity, @ColorInt int color) {
|
||||
if (activity != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
if (activity != null) {
|
||||
activity.getWindow().setStatusBarColor(color);
|
||||
}
|
||||
}
|
||||
|
@ -450,11 +450,7 @@ public final class ThemeUtils {
|
|||
*/
|
||||
public static void colorProgressBar(ProgressBar progressBar, @ColorInt int color) {
|
||||
if (progressBar != null) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
progressBar.setProgressTintList(ColorStateList.valueOf(color));
|
||||
} else {
|
||||
ThemeUtils.colorHorizontalProgressBar(progressBar, color);
|
||||
}
|
||||
progressBar.setProgressTintList(ColorStateList.valueOf(color));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -491,7 +487,7 @@ public final class ThemeUtils {
|
|||
}
|
||||
|
||||
/**
|
||||
* Sets the color of the status bar to {@code color} on devices with OS version lollipop or higher.
|
||||
* Sets the color of the status bar to {@code color}.
|
||||
*
|
||||
* @param fragmentActivity fragment activity
|
||||
* @param color the color
|
||||
|
@ -499,7 +495,7 @@ public final class ThemeUtils {
|
|||
public static void colorStatusBar(Activity fragmentActivity, @ColorInt int color) {
|
||||
Window window = fragmentActivity.getWindow();
|
||||
boolean isLightTheme = lightTheme(color);
|
||||
if (window != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
if (window != null) {
|
||||
window.setStatusBarColor(color);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
View decor = window.getDecorView();
|
||||
|
@ -668,7 +664,8 @@ public final class ThemeUtils {
|
|||
|
||||
/**
|
||||
* Will change a menu item text tint
|
||||
* @param item the menu item object
|
||||
*
|
||||
* @param item the menu item object
|
||||
* @param color the wanted color (as resource or color)
|
||||
*/
|
||||
public static void tintMenuItemText(MenuItem item, int color) {
|
||||
|
|
|
@ -88,9 +88,7 @@ public class FileCursor extends MatrixCursor {
|
|||
flags = flags | Document.FLAG_DIR_SUPPORTS_CREATE;
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
flags = Document.FLAG_SUPPORTS_RENAME | flags;
|
||||
}
|
||||
flags = Document.FLAG_SUPPORTS_RENAME | flags;
|
||||
|
||||
newRow().add(Document.COLUMN_DOCUMENT_ID, document.getDocumentId())
|
||||
.add(Document.COLUMN_DISPLAY_NAME, file.getFileName())
|
||||
|
|
|
@ -43,10 +43,11 @@ public class RootCursor extends MatrixCursor {
|
|||
public void addRoot(DocumentsStorageProvider.Document document, Context context) {
|
||||
Account account = document.getAccount();
|
||||
|
||||
int rootFlags = Root.FLAG_SUPPORTS_CREATE | Root.FLAG_SUPPORTS_RECENTS | Root.FLAG_SUPPORTS_SEARCH;
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
|
||||
rootFlags = rootFlags | Root.FLAG_SUPPORTS_IS_CHILD;
|
||||
}
|
||||
int rootFlags =
|
||||
Root.FLAG_SUPPORTS_CREATE |
|
||||
Root.FLAG_SUPPORTS_RECENTS |
|
||||
Root.FLAG_SUPPORTS_SEARCH |
|
||||
Root.FLAG_SUPPORTS_IS_CHILD;
|
||||
|
||||
newRow().add(Root.COLUMN_ROOT_ID, account.name)
|
||||
.add(Root.COLUMN_DOCUMENT_ID, document.getDocumentId())
|
||||
|
|
Loading…
Reference in a new issue