Drop Android 4.4 Support

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
Andy Scherzinger 2020-11-26 18:45:26 +01:00
parent a9906aa1d7
commit cf2a35f64d
No known key found for this signature in database
GPG key ID: 6CADC7E3523C308B
20 changed files with 80 additions and 177 deletions

View file

@ -98,9 +98,6 @@ for (TaskExecutionRequest tr : getGradle().getStartParameter().getTaskRequests()
apply from: 'gplay.gradle' apply from: 'gplay.gradle'
System.console().println("Applying gplay.gradle") System.console().println("Applying gplay.gradle")
} }
if (arg.contains("lint")) {
testMinSdk = 19
}
} }
} }
@ -129,7 +126,7 @@ android {
compileSdkVersion 29 compileSdkVersion 29
defaultConfig { defaultConfig {
minSdkVersion 19 minSdkVersion 21
targetSdkVersion 29 targetSdkVersion 29
// arguments to be passed to functional tests // arguments to be passed to functional tests

View file

@ -384,7 +384,6 @@ public class MainApp extends MultiDexApplication implements HasAndroidInjector {
@SuppressLint("ApplySharedPref") // commit is done on purpose to write immediately @SuppressLint("ApplySharedPref") // commit is done on purpose to write immediately
private void fixStoragePath() { private void fixStoragePath() {
if (!preferences.isStoragePathFixEnabled()) { if (!preferences.isStoragePathFixEnabled()) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
StoragePoint[] storagePoints = DataStorageProvider.getInstance().getAvailableStoragePoints(); StoragePoint[] storagePoints = DataStorageProvider.getInstance().getAvailableStoragePoints();
String storagePath = preferences.getStoragePath(""); String storagePath = preferences.getStoragePath("");
@ -423,13 +422,6 @@ public class MainApp extends MultiDexApplication implements HasAndroidInjector {
preferences.removeKeysMigrationPreference(); preferences.removeKeysMigrationPreference();
preferences.setStoragePathFixEnabled(true); preferences.setStoragePathFixEnabled(true);
} }
} else {
if (TextUtils.isEmpty(storagePath)) {
preferences.setStoragePath(Environment.getExternalStorageDirectory().getAbsolutePath());
}
preferences.removeKeysMigrationPreference();
preferences.setStoragePathFixEnabled(true);
}
} }
} }
@ -479,13 +471,11 @@ public class MainApp extends MultiDexApplication implements HasAndroidInjector {
connectivityService, connectivityService,
powerManagementService); powerManagementService);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
ReceiversHelper.registerPowerSaveReceiver(uploadsStorageManager, ReceiversHelper.registerPowerSaveReceiver(uploadsStorageManager,
accountManager, accountManager,
connectivityService, connectivityService,
powerManagementService); powerManagementService);
} }
}
public static void notificationChannels() { public static void notificationChannels() {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O && getAppContext() != null) { if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O && getAppContext() != null) {

View file

@ -330,13 +330,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
private void deleteCookies() { private void deleteCookies() {
try { try {
CookieSyncManager.createInstance(this); CookieSyncManager.createInstance(this);
CookieManager cookieManager = CookieManager.getInstance(); CookieManager.getInstance().removeAllCookies(null);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
cookieManager.removeAllCookies(null);
} else {
cookieManager.removeAllCookie();
}
} catch (AndroidRuntimeException e) { } catch (AndroidRuntimeException e) {
Log_OC.e(TAG, e.getMessage()); Log_OC.e(TAG, e.getMessage());
} }
@ -439,10 +433,8 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
mLoginWebView.setVisibility(View.VISIBLE); mLoginWebView.setVisibility(View.VISIBLE);
ThemeUtils.colorStatusBar(AuthenticatorActivity.this, primaryColor); ThemeUtils.colorStatusBar(AuthenticatorActivity.this, primaryColor);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindow().setNavigationBarColor(primaryColor); getWindow().setNavigationBarColor(primaryColor);
} }
}
@Override @Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) { public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {

View file

@ -21,7 +21,6 @@
package com.owncloud.android.datastorage; package com.owncloud.android.datastorage;
import android.os.Build;
import android.os.Environment; import android.os.Environment;
import com.owncloud.android.MainApp; import com.owncloud.android.MainApp;
@ -67,7 +66,6 @@ public class DataStorageProvider {
List<String> paths = new ArrayList<>(); List<String> paths = new ArrayList<>();
StoragePoint storagePoint; StoragePoint storagePoint;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
for (File f : MainApp.getAppContext().getExternalMediaDirs()) { for (File f : MainApp.getAppContext().getExternalMediaDirs()) {
if (f != null && !paths.contains(f.getAbsolutePath())) { if (f != null && !paths.contains(f.getAbsolutePath())) {
storagePoint = new StoragePoint(); storagePoint = new StoragePoint();
@ -85,17 +83,6 @@ public class DataStorageProvider {
} }
} }
} }
} 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 // Now we go add private ones
// Add internal storage directory // Add internal storage directory

View file

@ -23,7 +23,6 @@ package com.owncloud.android.files;
import android.content.ContentResolver; import android.content.ContentResolver;
import android.content.Context; import android.content.Context;
import android.os.Build;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
@ -333,7 +332,7 @@ public class FileMenuFilter {
*/ */
@NextcloudServer(max = 18) @NextcloudServer(max = 18)
private boolean isRichDocumentEditingSupported(OCCapability capability, String mimeType) { 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.getRichDocumentsMimeTypeList().contains(mimeType) ||
capability.getRichDocumentsOptionalMimeTypeList().contains(mimeType)) && capability.getRichDocumentsOptionalMimeTypeList().contains(mimeType)) &&
capability.getRichDocumentsDirectEditing().isTrue(); capability.getRichDocumentsDirectEditing().isTrue();

View file

@ -26,7 +26,6 @@ import android.accounts.Account;
import android.accounts.AuthenticatorException; import android.accounts.AuthenticatorException;
import android.accounts.OperationCanceledException; import android.accounts.OperationCanceledException;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.content.ContentResolver; import android.content.ContentResolver;
import android.content.Context; import android.content.Context;
import android.content.res.AssetFileDescriptor; import android.content.res.AssetFileDescriptor;
@ -34,7 +33,6 @@ import android.database.Cursor;
import android.graphics.Point; import android.graphics.Point;
import android.net.Uri; import android.net.Uri;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.CancellationSignal; import android.os.CancellationSignal;
import android.os.Handler; import android.os.Handler;
@ -574,7 +572,6 @@ public class DocumentsStorageProvider extends DocumentsProvider {
context.getContentResolver().notifyChange(toNotifyUri(parentFolder), null, false); context.getContentResolver().notifyChange(toNotifyUri(parentFolder), null, false);
} }
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void recursiveRevokePermission(Document document) { private void recursiveRevokePermission(Document document) {
FileDataStorageManager storageManager = document.getStorageManager(); FileDataStorageManager storageManager = document.getStorageManager();
OCFile file = document.getFile(); OCFile file = document.getFile();

View file

@ -112,7 +112,6 @@ public abstract class EditorWebView extends ExternalSiteWebView {
finish(); finish();
} }
@SuppressLint("AddJavascriptInterface") // suppress warning as webview is only used >= Lollipop
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
webViewLayout = R.layout.richdocuments_webview; // TODO rename webViewLayout = R.layout.richdocuments_webview; // TODO rename

View file

@ -23,7 +23,6 @@
package com.owncloud.android.ui.activity; package com.owncloud.android.ui.activity;
import android.content.Intent; import android.content.Intent;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.SystemClock; import android.os.SystemClock;
import android.text.Editable; import android.text.Editable;
@ -366,7 +365,7 @@ public class PassCodeActivity extends AppCompatActivity implements Injectable {
@Override @Override
public boolean onKeyDown(int keyCode, KeyEvent event) { public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) { if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
if(ACTION_CHECK.equals(getIntent().getAction()) && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){ if (ACTION_CHECK.equals(getIntent().getAction())) {
moveTaskToBack(true); moveTaskToBack(true);
finishAndRemoveTask(); finishAndRemoveTask();
} else if (ACTION_REQUEST_WITH_RESULT.equals(getIntent().getAction()) || } else if (ACTION_REQUEST_WITH_RESULT.equals(getIntent().getAction()) ||

View file

@ -62,7 +62,6 @@ import java.lang.ref.WeakReference;
import javax.inject.Inject; import javax.inject.Inject;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import butterknife.Unbinder; import butterknife.Unbinder;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; 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 * Opens document for editing via Richdocuments app in a web view
*/ */
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public class RichDocumentsEditorWebView extends EditorWebView { public class RichDocumentsEditorWebView extends EditorWebView {
public static final int REQUEST_LOCAL_FILE = 101; public static final int REQUEST_LOCAL_FILE = 101;
private static final int REQUEST_REMOTE_FILE = 100; private static final int REQUEST_REMOTE_FILE = 100;
@ -92,7 +90,6 @@ public class RichDocumentsEditorWebView extends EditorWebView {
protected ClientFactory clientFactory; protected ClientFactory clientFactory;
@SuppressFBWarnings("ANDROID_WEB_VIEW_JAVASCRIPT_INTERFACE") @SuppressFBWarnings("ANDROID_WEB_VIEW_JAVASCRIPT_INTERFACE")
@SuppressLint("AddJavascriptInterface") // suppress warning as webview is only used >= Lollipop
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);

View file

@ -27,7 +27,6 @@ import android.annotation.SuppressLint;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.view.View; import android.view.View;
import android.widget.FrameLayout; import android.widget.FrameLayout;
@ -50,7 +49,6 @@ import androidx.appcompat.app.ActionBar;
import androidx.appcompat.widget.AppCompatSpinner; import androidx.appcompat.widget.AppCompatSpinner;
import androidx.appcompat.widget.Toolbar; import androidx.appcompat.widget.Toolbar;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
import androidx.core.view.ViewCompat;
/** /**
* Base class providing toolbar registration functionality, see {@link #setupToolbar(boolean, boolean)}. * Base class providing toolbar registration functionality, see {@link #setupToolbar(boolean, boolean)}.
@ -161,22 +159,14 @@ public abstract class ToolbarActivity extends BaseActivity {
@SuppressLint("PrivateResource") @SuppressLint("PrivateResource")
private void showHomeSearchToolbar(boolean isShow) { private void showHomeSearchToolbar(boolean isShow) {
if (isShow) { if (isShow) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
mAppBar.setStateListAnimator(AnimatorInflater.loadStateListAnimator(mAppBar.getContext(), mAppBar.setStateListAnimator(AnimatorInflater.loadStateListAnimator(mAppBar.getContext(),
R.animator.appbar_elevation_off)); R.animator.appbar_elevation_off));
} else {
ViewCompat.setElevation(mAppBar, 0);
}
mDefaultToolbar.setVisibility(View.GONE); mDefaultToolbar.setVisibility(View.GONE);
mHomeSearchToolbar.setVisibility(View.VISIBLE); mHomeSearchToolbar.setVisibility(View.VISIBLE);
ThemeUtils.colorStatusBar(this, ContextCompat.getColor(this, R.color.bg_default)); ThemeUtils.colorStatusBar(this, ContextCompat.getColor(this, R.color.bg_default));
} else { } else {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
mAppBar.setStateListAnimator(AnimatorInflater.loadStateListAnimator(mAppBar.getContext(), mAppBar.setStateListAnimator(AnimatorInflater.loadStateListAnimator(mAppBar.getContext(),
R.animator.appbar_elevation_on)); R.animator.appbar_elevation_on));
} else {
ViewCompat.setElevation(mAppBar, getResources().getDimension(R.dimen.design_appbar_elevation));
}
mDefaultToolbar.setVisibility(View.VISIBLE); mDefaultToolbar.setVisibility(View.VISIBLE);
mHomeSearchToolbar.setVisibility(View.GONE); mHomeSearchToolbar.setVisibility(View.GONE);
ThemeUtils.colorStatusBar(this); ThemeUtils.colorStatusBar(this);

View file

@ -21,7 +21,6 @@
package com.owncloud.android.ui.adapter; package com.owncloud.android.ui.adapter;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.CancellationSignal; import android.os.CancellationSignal;
import android.os.ParcelFileDescriptor; import android.os.ParcelFileDescriptor;
@ -40,9 +39,6 @@ import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.Objects; import java.util.Objects;
import androidx.annotation.RequiresApi;
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public class PrintAdapter extends PrintDocumentAdapter { public class PrintAdapter extends PrintDocumentAdapter {
private static final String TAG = PrintAdapter.class.getSimpleName(); private static final String TAG = PrintAdapter.class.getSimpleName();
private static final String PDF_NAME = "finalPrint.pdf"; private static final String PDF_NAME = "finalPrint.pdf";

View file

@ -22,7 +22,6 @@
package com.owncloud.android.ui.asynctasks; package com.owncloud.android.ui.asynctasks;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Build;
import android.print.PrintAttributes; import android.print.PrintAttributes;
import android.print.PrintDocumentAdapter; import android.print.PrintDocumentAdapter;
import android.print.PrintManager; import android.print.PrintManager;
@ -44,11 +43,8 @@ import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import androidx.annotation.RequiresApi;
import static android.content.Context.PRINT_SERVICE; import static android.content.Context.PRINT_SERVICE;
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public class PrintAsyncTask extends AsyncTask<Void, Void, Boolean> { public class PrintAsyncTask extends AsyncTask<Void, Void, Boolean> {
private static final String TAG = PrintAsyncTask.class.getSimpleName(); private static final String TAG = PrintAsyncTask.class.getSimpleName();
private static final String JOB_NAME = "Document"; private static final String JOB_NAME = "Document";

View file

@ -21,7 +21,6 @@
package com.owncloud.android.ui.fragment; package com.owncloud.android.ui.fragment;
import android.content.Context; import android.content.Context;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
@ -127,7 +126,6 @@ public class OCFileListBottomSheetDialog extends BottomSheetDialog {
OCCapability capability = fileActivity.getCapabilities(); OCCapability capability = fileActivity.getCapabilities();
if (capability.getRichDocuments().isTrue() && if (capability.getRichDocuments().isTrue() &&
capability.getRichDocumentsDirectEditing().isTrue() && capability.getRichDocumentsDirectEditing().isTrue() &&
android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP &&
capability.getRichDocumentsTemplatesAvailable().isTrue() && capability.getRichDocumentsTemplatesAvailable().isTrue() &&
!file.isEncrypted()) { !file.isEncrypted()) {
templates.setVisibility(View.VISIBLE); templates.setVisibility(View.VISIBLE);
@ -137,7 +135,6 @@ public class OCFileListBottomSheetDialog extends BottomSheetDialog {
.getValue(user, ArbitraryDataProvider.DIRECT_EDITING); .getValue(user, ArbitraryDataProvider.DIRECT_EDITING);
if (!json.isEmpty() && if (!json.isEmpty() &&
android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP &&
!file.isEncrypted()) { !file.isEncrypted()) {
DirectEditing directEditing = new Gson().fromJson(json, DirectEditing.class); DirectEditing directEditing = new Gson().fromJson(json, DirectEditing.class);
@ -174,8 +171,7 @@ public class OCFileListBottomSheetDialog extends BottomSheetDialog {
} }
// create rich workspace // create rich workspace
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && if (FileMenuFilter.isEditorAvailable(getContext().getContentResolver(),
FileMenuFilter.isEditorAvailable(getContext().getContentResolver(),
user, user,
MimeTypeUtil.MIMETYPE_TEXT_MARKDOWN) && MimeTypeUtil.MIMETYPE_TEXT_MARKDOWN) &&
file != null && !file.isEncrypted()) { file != null && !file.isEncrypted()) {

View file

@ -29,7 +29,6 @@ import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.graphics.Color; import android.graphics.Color;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.os.Looper; import android.os.Looper;
@ -1021,11 +1020,9 @@ public class OCFileListFragment extends ExtendedListFragment implements
} else if (FileMenuFilter.isEditorAvailable(requireContext().getContentResolver(), } else if (FileMenuFilter.isEditorAvailable(requireContext().getContentResolver(),
accountManager.getUser(), accountManager.getUser(),
file.getMimeType()) && file.getMimeType()) &&
!file.isEncrypted() && !file.isEncrypted()) {
android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
mContainerActivity.getFileOperationsHelper().openFileWithTextEditor(file, getContext()); mContainerActivity.getFileOperationsHelper().openFileWithTextEditor(file, getContext());
} else if (capability.getRichDocumentsMimeTypeList().contains(file.getMimeType()) && } else if (capability.getRichDocumentsMimeTypeList().contains(file.getMimeType()) &&
android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP &&
capability.getRichDocumentsDirectEditing().isTrue() && !file.isEncrypted()) { capability.getRichDocumentsDirectEditing().isTrue() && !file.isEncrypted()) {
mContainerActivity.getFileOperationsHelper().openFileAsRichDocument(file, getContext()); mContainerActivity.getFileOperationsHelper().openFileAsRichDocument(file, getContext());
} else { } else {
@ -1091,22 +1088,15 @@ public class OCFileListFragment extends ExtendedListFragment implements
} }
case R.id.action_edit: { case R.id.action_edit: {
// should not be necessary, as menu item is filtered, but better play safe // 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(), if (FileMenuFilter.isEditorAvailable(requireContext().getContentResolver(),
accountManager.getUser(), accountManager.getUser(),
singleFile.getMimeType())) { singleFile.getMimeType())) {
mContainerActivity.getFileOperationsHelper().openFileWithTextEditor(singleFile, mContainerActivity.getFileOperationsHelper().openFileWithTextEditor(singleFile, getContext());
getContext());
} else { } else {
mContainerActivity.getFileOperationsHelper().openFileAsRichDocument(singleFile, mContainerActivity.getFileOperationsHelper().openFileAsRichDocument(singleFile, getContext());
getContext());
} }
return true; return true;
} else {
DisplayUtils.showSnackMessage(getView(), "Not supported on older than Android 5");
return false;
}
} }
case R.id.action_rename_file: { case R.id.action_rename_file: {
RenameFileDialogFragment dialog = RenameFileDialogFragment.newInstance(singleFile); RenameFileDialogFragment dialog = RenameFileDialogFragment.newInstance(singleFile);

View file

@ -104,7 +104,6 @@ import java.util.regex.Pattern;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.core.content.FileProvider; import androidx.core.content.FileProvider;
import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction; import androidx.fragment.app.FragmentTransaction;
@ -288,14 +287,12 @@ public class FileOperationsHelper {
if (optionalUser.isPresent() && FileMenuFilter.isEditorAvailable(fileActivity.getContentResolver(), if (optionalUser.isPresent() && FileMenuFilter.isEditorAvailable(fileActivity.getContentResolver(),
optionalUser.get(), optionalUser.get(),
file.getMimeType()) && file.getMimeType())) {
android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
openFileWithTextEditor(file, fileActivity); openFileWithTextEditor(file, fileActivity);
} else { } else {
Account account = fileActivity.getAccount(); Account account = fileActivity.getAccount();
OCCapability capability = fileActivity.getStorageManager().getCapability(account.name); OCCapability capability = fileActivity.getStorageManager().getCapability(account.name);
if (capability.getRichDocumentsMimeTypeList().contains(file.getMimeType()) && if (capability.getRichDocumentsMimeTypeList().contains(file.getMimeType()) &&
android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP &&
capability.getRichDocumentsDirectEditing().isTrue()) { capability.getRichDocumentsDirectEditing().isTrue()) {
openFileAsRichDocument(file, fileActivity); openFileAsRichDocument(file, fileActivity);
return; return;
@ -360,7 +357,6 @@ public class FileOperationsHelper {
} }
} }
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public void openFileAsRichDocument(OCFile file, Context context) { public void openFileAsRichDocument(OCFile file, Context context) {
Intent collaboraWebViewIntent = new Intent(context, RichDocumentsEditorWebView.class); Intent collaboraWebViewIntent = new Intent(context, RichDocumentsEditorWebView.class);
collaboraWebViewIntent.putExtra(ExternalSiteWebView.EXTRA_TITLE, "Collabora"); collaboraWebViewIntent.putExtra(ExternalSiteWebView.EXTRA_TITLE, "Collabora");
@ -369,7 +365,6 @@ public class FileOperationsHelper {
context.startActivity(collaboraWebViewIntent); context.startActivity(collaboraWebViewIntent);
} }
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public void openFileWithTextEditor(OCFile file, Context context) { public void openFileWithTextEditor(OCFile file, Context context) {
Intent textEditorIntent = new Intent(context, TextEditorWebView.class); Intent textEditorIntent = new Intent(context, TextEditorWebView.class);
textEditorIntent.putExtra(ExternalSiteWebView.EXTRA_TITLE, "Text"); textEditorIntent.putExtra(ExternalSiteWebView.EXTRA_TITLE, "Text");

View file

@ -24,7 +24,6 @@ package com.owncloud.android.ui.preview;
import android.accounts.Account; import android.accounts.Account;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.view.Menu; import android.view.Menu;
@ -289,10 +288,6 @@ public class PreviewTextFileFragment extends PreviewTextFragment {
menu.findItem(R.id.action_unset_favorite) 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()) { if (getFile().isSharedWithMe() && !getFile().canReshare()) {
FileMenuFilter.hideMenuItem(menu.findItem(R.id.action_send_share_file)); FileMenuFilter.hideMenuItem(menu.findItem(R.id.action_send_share_file));
} }
@ -331,11 +326,8 @@ public class PreviewTextFileFragment extends PreviewTextFragment {
} }
case R.id.action_edit: case R.id.action_edit:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
containerActivity.getFileOperationsHelper().openFileWithTextEditor(getFile(), getContext()); containerActivity.getFileOperationsHelper().openFileWithTextEditor(getFile(), getContext());
return true; return true;
}
return false;
default: default:
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);

View file

@ -104,15 +104,10 @@ public class PreviewTextStringFragment extends PreviewTextFragment {
} }
FloatingActionButton fabMain = requireActivity().findViewById(R.id.fab_main); 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.setVisibility(View.VISIBLE);
fabMain.setEnabled(true); fabMain.setEnabled(true);
fabMain.setOnClickListener(v -> edit()); fabMain.setOnClickListener(v -> edit());
ThemeUtils.colorFloatingActionButton(fabMain, R.drawable.ic_edit, requireContext()); ThemeUtils.colorFloatingActionButton(fabMain, R.drawable.ic_edit, requireContext());
}
return view; return view;
} }

View file

@ -364,7 +364,7 @@ public final class ThemeUtils {
} }
public static void setStatusBarColor(Activity activity, @ColorInt int color) { 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); activity.getWindow().setStatusBarColor(color);
} }
} }
@ -450,11 +450,7 @@ public final class ThemeUtils {
*/ */
public static void colorProgressBar(ProgressBar progressBar, @ColorInt int color) { public static void colorProgressBar(ProgressBar progressBar, @ColorInt int color) {
if (progressBar != null) { if (progressBar != null) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
progressBar.setProgressTintList(ColorStateList.valueOf(color)); progressBar.setProgressTintList(ColorStateList.valueOf(color));
} else {
ThemeUtils.colorHorizontalProgressBar(progressBar, 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 fragmentActivity fragment activity
* @param color the color * @param color the color
@ -499,7 +495,7 @@ public final class ThemeUtils {
public static void colorStatusBar(Activity fragmentActivity, @ColorInt int color) { public static void colorStatusBar(Activity fragmentActivity, @ColorInt int color) {
Window window = fragmentActivity.getWindow(); Window window = fragmentActivity.getWindow();
boolean isLightTheme = lightTheme(color); boolean isLightTheme = lightTheme(color);
if (window != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (window != null) {
window.setStatusBarColor(color); window.setStatusBarColor(color);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
View decor = window.getDecorView(); View decor = window.getDecorView();
@ -668,6 +664,7 @@ public final class ThemeUtils {
/** /**
* Will change a menu item text tint * 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) * @param color the wanted color (as resource or color)
*/ */

View file

@ -88,9 +88,7 @@ public class FileCursor extends MatrixCursor {
flags = flags | Document.FLAG_DIR_SUPPORTS_CREATE; 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()) newRow().add(Document.COLUMN_DOCUMENT_ID, document.getDocumentId())
.add(Document.COLUMN_DISPLAY_NAME, file.getFileName()) .add(Document.COLUMN_DISPLAY_NAME, file.getFileName())

View file

@ -43,10 +43,11 @@ public class RootCursor extends MatrixCursor {
public void addRoot(DocumentsStorageProvider.Document document, Context context) { public void addRoot(DocumentsStorageProvider.Document document, Context context) {
Account account = document.getAccount(); Account account = document.getAccount();
int rootFlags = Root.FLAG_SUPPORTS_CREATE | Root.FLAG_SUPPORTS_RECENTS | Root.FLAG_SUPPORTS_SEARCH; int rootFlags =
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) { Root.FLAG_SUPPORTS_CREATE |
rootFlags = rootFlags | Root.FLAG_SUPPORTS_IS_CHILD; Root.FLAG_SUPPORTS_RECENTS |
} Root.FLAG_SUPPORTS_SEARCH |
Root.FLAG_SUPPORTS_IS_CHILD;
newRow().add(Root.COLUMN_ROOT_ID, account.name) newRow().add(Root.COLUMN_ROOT_ID, account.name)
.add(Root.COLUMN_DOCUMENT_ID, document.getDocumentId()) .add(Root.COLUMN_DOCUMENT_ID, document.getDocumentId())