Search in sources :

Example 1 with KITKAT

use of android.os.Build.VERSION_CODES.KITKAT in project robolectric by robolectric.

the class ShadowApplicationTest method shouldCorrectlyInstantiatedAccessibilityService.

@Test
@Config(minSdk = KITKAT)
public void shouldCorrectlyInstantiatedAccessibilityService() throws Exception {
    AccessibilityManager accessibilityManager = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE);
    AccessibilityManager.TouchExplorationStateChangeListener listener = enabled -> {
    };
    assertThat(accessibilityManager.addTouchExplorationStateChangeListener(listener)).isTrue();
    assertThat(accessibilityManager.removeTouchExplorationStateChangeListener(listener)).isTrue();
}
Also used : KITKAT(android.os.Build.VERSION_CODES.KITKAT) LinearLayout(android.widget.LinearLayout) PrintManager(android.print.PrintManager) Shadows(org.robolectric.Shadows) TextClassificationManager(android.view.textclassifier.TextClassificationManager) AndroidJUnit4(androidx.test.ext.junit.runners.AndroidJUnit4) IBinder(android.os.IBinder) LOLLIPOP(android.os.Build.VERSION_CODES.LOLLIPOP) ShadowLooper.shadowMainLooper(org.robolectric.shadows.ShadowLooper.shadowMainLooper) AutofillManager(android.view.autofill.AutofillManager) ApplicationProvider(androidx.test.core.app.ApplicationProvider) TestActivity(org.robolectric.shadows.testing.TestActivity) Scheduler(org.robolectric.util.Scheduler) ServiceConnection(android.content.ServiceConnection) Assert.fail(org.junit.Assert.fail) NsdManager(android.net.nsd.NsdManager) M(android.os.Build.VERSION_CODES.M) O(android.os.Build.VERSION_CODES.O) LEGACY(org.robolectric.annotation.LooperMode.Mode.LEGACY) IntentFilter(android.content.IntentFilter) MILLISECONDS(java.util.concurrent.TimeUnit.MILLISECONDS) FingerprintManager(android.hardware.fingerprint.FingerprintManager) RuntimeEnvironment(org.robolectric.RuntimeEnvironment) BroadcastReceiver(android.content.BroadcastReceiver) VERSION_CODES(android.os.Build.VERSION_CODES) CountDownLatch(java.util.concurrent.CountDownLatch) List(java.util.List) JELLY_BEAN_MR1(android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) Application(android.app.Application) Assert.assertFalse(org.junit.Assert.assertFalse) ActivityNotFoundException(android.content.ActivityNotFoundException) MediaSessionManager(android.media.session.MediaSessionManager) Context(android.content.Context) BatteryManager(android.os.BatteryManager) CaptioningManager(android.view.accessibility.CaptioningManager) RunWith(org.junit.runner.RunWith) Config(org.robolectric.annotation.Config) Intent(android.content.Intent) Shadows.shadowOf(org.robolectric.Shadows.shadowOf) Assert.assertSame(org.junit.Assert.assertSame) Binder(android.os.Binder) LOLLIPOP_MR1(android.os.Build.VERSION_CODES.LOLLIPOP_MR1) AccessibilityManager(android.view.accessibility.AccessibilityManager) SubscriptionManager(android.telephony.SubscriptionManager) Before(org.junit.Before) UserManager(android.os.UserManager) Assert.assertNotNull(org.junit.Assert.assertNotNull) ComponentName(android.content.ComponentName) LayoutInflater(android.view.LayoutInflater) Robolectric(org.robolectric.Robolectric) RestrictionsManager(android.content.RestrictionsManager) Assert.assertTrue(org.junit.Assert.assertTrue) PopupWindow(android.widget.PopupWindow) Test(org.junit.Test) LooperMode(org.robolectric.annotation.LooperMode) Truth.assertThat(com.google.common.truth.Truth.assertThat) Gravity(android.view.Gravity) Assert.assertNull(org.junit.Assert.assertNull) SystemSensorManager(android.hardware.SystemSensorManager) Vibrator(android.os.Vibrator) Activity(android.app.Activity) AccessibilityManager(android.view.accessibility.AccessibilityManager) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 2 with KITKAT

use of android.os.Build.VERSION_CODES.KITKAT in project AmazeFileManager by TeamAmaze.

the class MainActivity method onActivityResult.

protected void onActivityResult(int requestCode, int responseCode, Intent intent) {
    super.onActivityResult(requestCode, responseCode, intent);
    if (requestCode == Drawer.image_selector_request_code) {
        drawer.onActivityResult(requestCode, responseCode, intent);
    } else if (requestCode == 3) {
        Uri treeUri;
        if (responseCode == Activity.RESULT_OK) {
            // Get Uri from Storage Access Framework.
            treeUri = intent.getData();
            // Persist URI - this is required for verification of writability.
            if (treeUri != null)
                getPrefs().edit().putString(PreferencesConstants.PREFERENCE_URI, treeUri.toString()).apply();
        } else {
            /* DialogUtil.displayError(getActivity(), R.string.message_dialog_cannot_write_to_folder_saf, false, currentFolder);
        ||!FileUtil.isWritableNormalOrSaf(currentFolder)*/
            return;
        }
        if (SDK_INT >= KITKAT) {
            getContentResolver().takePersistableUriPermission(treeUri, Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
        }
        executeWithMainFragment(mainFragment -> {
            switch(operation) {
                case // deletion
                DELETE:
                    new DeleteTask(mainActivity).execute((oparrayList));
                    break;
                case // copying
                COPY:
                    // legacy compatibility
                    if (oparrayList != null && oparrayList.size() != 0) {
                        oparrayListList = new ArrayList<>();
                        oparrayListList.add(oparrayList);
                        oparrayList = null;
                        oppatheList = new ArrayList<>();
                        oppatheList.add(oppathe);
                        oppathe = "";
                    }
                    for (int i = 0; i < oparrayListList.size(); i++) {
                        ArrayList<HybridFileParcelable> sourceList = oparrayListList.get(i);
                        Intent intent1 = new Intent(this, CopyService.class);
                        intent1.putExtra(CopyService.TAG_COPY_SOURCES, sourceList);
                        intent1.putExtra(CopyService.TAG_COPY_TARGET, oppatheList.get(i));
                        ServiceWatcherUtil.runService(this, intent1);
                    }
                    break;
                case // moving
                MOVE:
                    // legacy compatibility
                    if (oparrayList != null && oparrayList.size() != 0) {
                        oparrayListList = new ArrayList<>();
                        oparrayListList.add(oparrayList);
                        oparrayList = null;
                        oppatheList = new ArrayList<>();
                        oppatheList.add(oppathe);
                        oppathe = "";
                    }
                    new MoveFiles(oparrayListList, isRootExplorer(), mainFragment.getCurrentPath(), mainFragment.getActivity(), OpenMode.FILE).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, oppatheList);
                    break;
                case // mkdir
                NEW_FOLDER:
                    mainActivityHelper.mkDir(new HybridFile(OpenMode.FILE, oppathe), RootHelper.generateBaseFile(new File(oppathe), true), mainFragment);
                    break;
                case RENAME:
                    mainActivityHelper.rename(mainFragment.getMainFragmentViewModel().getOpenMode(), (oppathe), (oppathe1), null, false, mainActivity, isRootExplorer());
                    mainFragment.updateList();
                    break;
                case NEW_FILE:
                    mainActivityHelper.mkFile(new HybridFile(OpenMode.FILE, oppathe), new HybridFile(OpenMode.FILE, oppathe), mainFragment);
                    break;
                case EXTRACT:
                    mainActivityHelper.extractFile(new File(oppathe));
                    break;
                case COMPRESS:
                    mainActivityHelper.compressFiles(new File(oppathe), oparrayList);
                    break;
                case SAVE_FILE:
                    FileUtil.writeUriToStorage(this, urisToBeSaved, getContentResolver(), mainFragment.getCurrentPath());
                    urisToBeSaved = null;
                    finish();
                    break;
                default:
                    LogHelper.logOnProductionOrCrash(TAG, "Incorrect value for switch");
            }
            return null;
        }, true);
        operation = UNDEFINED;
    } else if (requestCode == REQUEST_CODE_SAF) {
        executeWithMainFragment(mainFragment -> {
            if (responseCode == Activity.RESULT_OK && intent.getData() != null) {
                // otg access
                Uri usbOtgRoot = intent.getData();
                SingletonUsbOtg.getInstance().setUsbOtgRoot(usbOtgRoot);
                mainFragment.loadlist(OTGUtil.PREFIX_OTG, false, OpenMode.OTG);
                drawer.closeIfNotLocked();
                if (drawer.isLocked())
                    drawer.onDrawerClosed();
            } else if (requestCode == REQUEST_CODE_SAF_FTP) {
                FtpServerFragment ftpServerFragment = (FtpServerFragment) getFragmentAtFrame();
                ftpServerFragment.changeFTPServerPath(intent.getData().toString());
                Toast.makeText(this, R.string.ftp_path_change_success, Toast.LENGTH_SHORT).show();
            } else {
                Toast.makeText(this, R.string.error, Toast.LENGTH_SHORT).show();
                // otg access not provided
                drawer.resetPendingPath();
            }
            return null;
        }, true);
    }
}
Also used : CursorLoader(androidx.loader.content.CursorLoader) AppBar(com.amaze.filemanager.ui.views.appbar.AppBar) MOVE(com.amaze.filemanager.file_operations.filesystem.OperationTypeKt.MOVE) Bundle(android.os.Bundle) SingletonUsbOtg(com.amaze.filemanager.file_operations.filesystem.usb.SingletonUsbOtg) NonNull(androidx.annotation.NonNull) ARG_ADDRESS(com.amaze.filemanager.ui.dialogs.SftpConnectDialog.ARG_ADDRESS) Completable(io.reactivex.Completable) Uri(android.net.Uri) ColorDrawable(android.graphics.drawable.ColorDrawable) CloudEntry(com.amaze.filemanager.database.models.explorer.CloudEntry) SDK_INT(android.os.Build.VERSION.SDK_INT) ARG_KEYPAIR_NAME(com.amaze.filemanager.ui.dialogs.SftpConnectDialog.ARG_KEYPAIR_NAME) StorageDirectoryParcelable(com.amaze.filemanager.adapters.data.StorageDirectoryParcelable) UNDEFINED(com.amaze.filemanager.file_operations.filesystem.OperationTypeKt.UNDEFINED) PREFERENCE_NEED_TO_SET_HOME(com.amaze.filemanager.ui.fragments.preference_fragments.PreferencesConstants.PREFERENCE_NEED_TO_SET_HOME) Handler(android.os.Handler) Shell(eu.chainfire.libsuperuser.Shell) Fragment(androidx.fragment.app.Fragment) Function(androidx.arch.core.util.Function) TargetApi(android.annotation.TargetApi) Log(android.util.Log) M(android.os.Build.VERSION_CODES.M) SAVE_FILE(com.amaze.filemanager.file_operations.filesystem.OperationTypeKt.SAVE_FILE) SshConnectionPool(com.amaze.filemanager.filesystem.ssh.SshConnectionPool) CoordinatorLayout(androidx.coordinatorlayout.widget.CoordinatorLayout) GeneralDialogCreation(com.amaze.filemanager.ui.dialogs.GeneralDialogCreation) N(android.os.Build.VERSION_CODES.N) RENAME(com.amaze.filemanager.file_operations.filesystem.OperationTypeKt.RENAME) CompletableObserver(io.reactivex.CompletableObserver) IntentFilter(android.content.IntentFilter) LogHelper(com.amaze.filemanager.LogHelper) StorageNamingHelper(com.amaze.filemanager.ui.strings.StorageNamingHelper) ARG_USERNAME(com.amaze.filemanager.ui.dialogs.SftpConnectDialog.ARG_USERNAME) FileUtils(com.amaze.filemanager.filesystem.files.FileUtils) NEW_FILE(com.amaze.filemanager.file_operations.filesystem.OperationTypeKt.NEW_FILE) JELLY_BEAN_MR2(android.os.Build.VERSION_CODES.JELLY_BEAN_MR2) IdRes(androidx.annotation.IdRes) StringRes(androidx.annotation.StringRes) JELLY_BEAN_MR1(android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) Nullable(androidx.annotation.Nullable) StorageNaming(com.amaze.filemanager.file_operations.filesystem.StorageNaming) SmbConnectionListener(com.amaze.filemanager.ui.dialogs.SmbConnectDialog.SmbConnectionListener) DELETE(com.amaze.filemanager.file_operations.filesystem.OperationTypeKt.DELETE) R(com.amaze.filemanager.R) AppConfig(com.amaze.filemanager.application.AppConfig) PermissionsActivity(com.amaze.filemanager.ui.activities.superclasses.PermissionsActivity) SftpConnectDialog(com.amaze.filemanager.ui.dialogs.SftpConnectDialog) Environment(android.os.Environment) CompressedExplorerFragment(com.amaze.filemanager.ui.fragments.CompressedExplorerFragment) BaseTransientBottomBar(com.google.android.material.snackbar.BaseTransientBottomBar) CloudLoaderAsyncTask(com.amaze.filemanager.asynchronous.asynctasks.CloudLoaderAsyncTask) CloudSheetFragment(com.amaze.filemanager.ui.fragments.CloudSheetFragment) ArrayList(java.util.ArrayList) TagsHelper(com.amaze.filemanager.TagsHelper) TileService(android.service.quicksettings.TileService) RenameBookmark(com.amaze.filemanager.ui.dialogs.RenameBookmark) StorageVolume(android.os.storage.StorageVolume) MainActivityHelper(com.amaze.filemanager.utils.MainActivityHelper) ARG_PORT(com.amaze.filemanager.ui.dialogs.SftpConnectDialog.ARG_PORT) PreferencesConstants(com.amaze.filemanager.ui.fragments.preference_fragments.PreferencesConstants) MenuInflater(android.view.MenuInflater) SearchWorkerFragment(com.amaze.filemanager.ui.fragments.SearchWorkerFragment) DataUtils(com.amaze.filemanager.utils.DataUtils) PreferenceUtils(com.amaze.filemanager.utils.PreferenceUtils) Toast(android.widget.Toast) Menu(android.view.Menu) TabFragment(com.amaze.filemanager.ui.fragments.TabFragment) Loader(androidx.loader.content.Loader) DeleteTask(com.amaze.filemanager.asynchronous.asynctasks.DeleteTask) StorageManager(android.os.storage.StorageManager) PREFERENCE_COLORED_NAVIGATION(com.amaze.filemanager.ui.fragments.preference_fragments.PreferencesConstants.PREFERENCE_COLORED_NAVIGATION) ARG_NAME(com.amaze.filemanager.ui.dialogs.SftpConnectDialog.ARG_NAME) TextUtils(android.text.TextUtils) File(java.io.File) EXTRACT(com.amaze.filemanager.file_operations.filesystem.OperationTypeKt.EXTRACT) MainActivityActionMode(com.amaze.filemanager.utils.MainActivityActionMode) Utils(com.amaze.filemanager.utils.Utils) FtpServerFragment(com.amaze.filemanager.ui.fragments.FtpServerFragment) ARG_DEFAULT_PATH(com.amaze.filemanager.ui.dialogs.SftpConnectDialog.ARG_DEFAULT_PATH) RingtoneManager(android.media.RingtoneManager) Configuration(android.content.res.Configuration) CloudConnectionCallbacks(com.amaze.filemanager.ui.fragments.CloudSheetFragment.CloudConnectionCallbacks) SaveOnDataUtilsChange(com.amaze.filemanager.asynchronous.SaveOnDataUtilsChange) TabFragmentBottomDragListener(com.amaze.filemanager.ui.drag.TabFragmentBottomDragListener) RequiresApi(androidx.annotation.RequiresApi) KITKAT(android.os.Build.VERSION_CODES.KITKAT) BookSorter(com.amaze.filemanager.utils.BookSorter) SpeedDialView(com.leinardi.android.speeddial.SpeedDialView) DrawableRes(androidx.annotation.DrawableRes) MainFragment(com.amaze.filemanager.ui.fragments.MainFragment) AndroidSchedulers(io.reactivex.android.schedulers.AndroidSchedulers) AppBarLayout(com.google.android.material.appbar.AppBarLayout) LOLLIPOP(android.os.Build.VERSION_CODES.LOLLIPOP) SortHandler(com.amaze.filemanager.database.SortHandler) RootHelper(com.amaze.filemanager.filesystem.RootHelper) Drawer(com.amaze.filemanager.ui.views.drawer.Drawer) CopyService(com.amaze.filemanager.asynchronous.services.CopyService) SpeedDialOverlayLayout(com.leinardi.android.speeddial.SpeedDialOverlayLayout) ContentResolver(android.content.ContentResolver) CloudContract(com.amaze.filemanager.database.CloudContract) ARG_PASSWORD(com.amaze.filemanager.ui.dialogs.SftpConnectDialog.ARG_PASSWORD) PasteHelper(com.amaze.filemanager.filesystem.PasteHelper) View(android.view.View) Schedulers(io.reactivex.schedulers.Schedulers) CustomZoomFocusChange(com.amaze.filemanager.ui.views.CustomZoomFocusChange) UsbManager(android.hardware.usb.UsbManager) SmbConnectDialog(com.amaze.filemanager.ui.dialogs.SmbConnectDialog) OTGUtil(com.amaze.filemanager.utils.OTGUtil) AsyncTask(android.os.AsyncTask) ProcessViewerFragment(com.amaze.filemanager.ui.fragments.ProcessViewerFragment) MakeFileOperation(com.amaze.filemanager.filesystem.MakeFileOperation) FragmentTransaction(androidx.fragment.app.FragmentTransaction) BroadcastReceiver(android.content.BroadcastReceiver) List(java.util.List) CloudRail(com.cloudrail.si.CloudRail) Disposable(io.reactivex.disposables.Disposable) FabWithLabelView(com.leinardi.android.speeddial.FabWithLabelView) CloudHandler(com.amaze.filemanager.database.CloudHandler) Pattern(java.util.regex.Pattern) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) Snackbar(com.google.android.material.snackbar.Snackbar) KITKAT_WATCH(android.os.Build.VERSION_CODES.KITKAT_WATCH) DecelerateInterpolator(android.view.animation.DecelerateInterpolator) ServiceWatcherUtil(com.amaze.filemanager.asynchronous.management.ServiceWatcherUtil) Context(android.content.Context) KeyEvent(android.view.KeyEvent) HybridFile(com.amaze.filemanager.filesystem.HybridFile) UtilsHandler(com.amaze.filemanager.database.UtilsHandler) COMPRESS(com.amaze.filemanager.file_operations.filesystem.OperationTypeKt.COMPRESS) Intent(android.content.Intent) FolderChooserDialog(com.afollestad.materialdialogs.folderselector.FolderChooserDialog) TabHandler(com.amaze.filemanager.database.TabHandler) LoaderManager(androidx.loader.app.LoaderManager) OpenMode(com.amaze.filemanager.file_operations.filesystem.OpenMode) AppConstants(com.amaze.filemanager.utils.AppConstants) MenuItem(android.view.MenuItem) HybridFileParcelable(com.amaze.filemanager.filesystem.HybridFileParcelable) OperationData(com.amaze.filemanager.database.models.OperationData) UsbOtgRepresentation(com.amaze.filemanager.file_operations.filesystem.usb.UsbOtgRepresentation) COPY(com.amaze.filemanager.file_operations.filesystem.OperationTypeKt.COPY) SystemBarTintManager(com.readystatesoftware.systembartint.SystemBarTintManager) WeakReference(java.lang.ref.WeakReference) Build(android.os.Build) AppsListFragment(com.amaze.filemanager.ui.fragments.AppsListFragment) Cursor(android.database.Cursor) WRITABLE_OR_ON_SDCARD(com.amaze.filemanager.file_operations.filesystem.FolderStateKt.WRITABLE_OR_ON_SDCARD) ExternalSdCardOperation(com.amaze.filemanager.filesystem.ExternalSdCardOperation) PREFERENCE_VIEW(com.amaze.filemanager.ui.fragments.preference_fragments.PreferencesConstants.PREFERENCE_VIEW) ARG_EDIT(com.amaze.filemanager.ui.dialogs.SftpConnectDialog.ARG_EDIT) NEW_FOLDER(com.amaze.filemanager.file_operations.filesystem.OperationTypeKt.NEW_FOLDER) DialogAction(com.afollestad.materialdialogs.DialogAction) REQUEST_CODE_SAF_FTP(com.amaze.filemanager.ui.fragments.FtpServerFragment.REQUEST_CODE_SAF_FTP) BookmarkCallback(com.amaze.filemanager.ui.dialogs.RenameBookmark.BookmarkCallback) ARG_HAS_PASSWORD(com.amaze.filemanager.ui.dialogs.SftpConnectDialog.ARG_HAS_PASSWORD) Color(android.graphics.Color) MoveFiles(com.amaze.filemanager.asynchronous.asynctasks.MoveFiles) SpeedDialActionItem(com.leinardi.android.speeddial.SpeedDialActionItem) BottomSheetDialogFragment(com.google.android.material.bottomsheet.BottomSheetDialogFragment) HandlerThread(android.os.HandlerThread) CloudPluginException(com.amaze.filemanager.file_operations.exceptions.CloudPluginException) Collections(java.util.Collections) Activity(android.app.Activity) PREFERENCE_BOOKMARKS_ADDED(com.amaze.filemanager.ui.fragments.preference_fragments.PreferencesConstants.PREFERENCE_BOOKMARKS_ADDED) FileUtil(com.amaze.filemanager.filesystem.FileUtil) ContentUris(android.content.ContentUris) HybridFile(com.amaze.filemanager.filesystem.HybridFile) ArrayList(java.util.ArrayList) Intent(android.content.Intent) MoveFiles(com.amaze.filemanager.asynchronous.asynctasks.MoveFiles) Uri(android.net.Uri) CopyService(com.amaze.filemanager.asynchronous.services.CopyService) File(java.io.File) HybridFile(com.amaze.filemanager.filesystem.HybridFile) DeleteTask(com.amaze.filemanager.asynchronous.asynctasks.DeleteTask) FtpServerFragment(com.amaze.filemanager.ui.fragments.FtpServerFragment)

Aggregations

Activity (android.app.Activity)2 BroadcastReceiver (android.content.BroadcastReceiver)2 Context (android.content.Context)2 Intent (android.content.Intent)2 IntentFilter (android.content.IntentFilter)2 JELLY_BEAN_MR1 (android.os.Build.VERSION_CODES.JELLY_BEAN_MR1)2 KITKAT (android.os.Build.VERSION_CODES.KITKAT)2 LOLLIPOP (android.os.Build.VERSION_CODES.LOLLIPOP)2 M (android.os.Build.VERSION_CODES.M)2 TargetApi (android.annotation.TargetApi)1 Application (android.app.Application)1 ActivityNotFoundException (android.content.ActivityNotFoundException)1 ComponentName (android.content.ComponentName)1 ContentResolver (android.content.ContentResolver)1 ContentUris (android.content.ContentUris)1 RestrictionsManager (android.content.RestrictionsManager)1 ServiceConnection (android.content.ServiceConnection)1 Configuration (android.content.res.Configuration)1 Cursor (android.database.Cursor)1 Color (android.graphics.Color)1