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'
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

View file

@ -384,7 +384,6 @@ 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("");
@ -423,13 +422,6 @@ public class MainApp extends MultiDexApplication implements HasAndroidInjector {
preferences.removeKeysMigrationPreference();
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,
powerManagementService);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
ReceiversHelper.registerPowerSaveReceiver(uploadsStorageManager,
accountManager,
connectivityService,
powerManagementService);
}
}
public static void notificationChannels() {
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() {
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,10 +433,8 @@ 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);
}
}
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {

View file

@ -21,7 +21,6 @@
package com.owncloud.android.datastorage;
import android.os.Build;
import android.os.Environment;
import com.owncloud.android.MainApp;
@ -67,7 +66,6 @@ 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();
@ -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
// Add internal storage directory

View file

@ -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();

View file

@ -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();

View file

@ -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

View file

@ -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

View file

@ -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);

View file

@ -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);
}
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));
}
mDefaultToolbar.setVisibility(View.VISIBLE);
mHomeSearchToolbar.setVisibility(View.GONE);
ThemeUtils.colorStatusBar(this);

View file

@ -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";

View file

@ -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";

View file

@ -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()) {

View file

@ -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());
mContainerActivity.getFileOperationsHelper().openFileWithTextEditor(singleFile, getContext());
} else {
mContainerActivity.getFileOperationsHelper().openFileAsRichDocument(singleFile,
getContext());
mContainerActivity.getFileOperationsHelper().openFileAsRichDocument(singleFile, getContext());
}
return true;
} else {
DisplayUtils.showSnackMessage(getView(), "Not supported on older than Android 5");
return false;
}
}
case R.id.action_rename_file: {
RenameFileDialogFragment dialog = RenameFileDialogFragment.newInstance(singleFile);

View file

@ -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");

View file

@ -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;
default:
return super.onOptionsItemSelected(item);

View file

@ -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());
}
return view;
}

View file

@ -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);
}
}
}
@ -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,6 +664,7 @@ public final class ThemeUtils {
/**
* Will change a menu item text tint
*
* @param item the menu item object
* @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;
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
flags = Document.FLAG_SUPPORTS_RENAME | flags;
}
newRow().add(Document.COLUMN_DOCUMENT_ID, document.getDocumentId())
.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) {
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())