diff --git a/FileManager/AndroidManifest.xml b/FileManager/AndroidManifest.xml index 7882107d..4441d743 100644 --- a/FileManager/AndroidManifest.xml +++ b/FileManager/AndroidManifest.xml @@ -18,9 +18,7 @@ + android:installLocation="auto"> - - diff --git a/FileManager/build.gradle b/FileManager/build.gradle index d81ac7f7..7b21fb24 100644 --- a/FileManager/build.gradle +++ b/FileManager/build.gradle @@ -1,28 +1,28 @@ apply plugin: 'com.android.application' dependencies { - compile 'com.github.openintents:distribution:1.1.3' - compile 'com.android.support:appcompat-v7:25.3.1' + implementation 'com.github.openintents:distribution:1.1.3' + implementation 'com.android.support:appcompat-v7:28.0.0' - androidTestCompile 'com.android.support.test:runner:0.5' - androidTestCompile 'com.android.support.test:rules:0.5' - androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2' - androidTestCompile 'com.android.support.test.espresso:espresso-intents:2.2.2' - androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.2' - androidTestCompile 'com.android.support:support-annotations:25.3.1' - compile 'com.android.support.test.espresso:espresso-idling-resource:2.2.2' + androidTestImplementation 'com.android.support.test:runner:1.0.2' + androidTestImplementation 'com.android.support.test:rules:1.0.2' + androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' + androidTestImplementation 'com.android.support.test.espresso:espresso-intents:3.0.2' + androidTestImplementation 'com.android.support.test.uiautomator:uiautomator-v18:2.1.3' + androidTestImplementation 'com.android.support:support-annotations:28.0.0' + implementation 'com.android.support.test.espresso:espresso-idling-resource:3.0.2' } android { - compileSdkVersion 25 - buildToolsVersion '26.0.2' + compileSdkVersion 28 + buildToolsVersion '28.0.3' defaultConfig { applicationId "org.openintents.filemanager" versionCode 40 versionName "2.2.3" - minSdkVersion 9 - targetSdkVersion 25 + minSdkVersion 14 + targetSdkVersion 28 testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } @@ -66,7 +66,7 @@ android { def outputFile = output.outputFile if (outputFile != null && outputFile.name.endsWith('.apk')) { def fileName = outputFile.name.replace('.apk', "-${versionName}.apk") - output.outputFileName = new File(outputFile.parent, fileName) + output.outputFileName = new File(output.outputFile.parent, fileName).getName() } } } diff --git a/FileManager/res/menu-v11/context.xml b/FileManager/res/menu-v11/context.xml deleted file mode 100644 index c66d2e5d..00000000 --- a/FileManager/res/menu-v11/context.xml +++ /dev/null @@ -1,62 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/FileManager/res/menu-v11/simple_file_list.xml b/FileManager/res/menu-v11/simple_file_list.xml deleted file mode 100644 index 4e0a6cfb..00000000 --- a/FileManager/res/menu-v11/simple_file_list.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/FileManager/res/menu/context.xml b/FileManager/res/menu/context.xml index a2d01582..c66d2e5d 100644 --- a/FileManager/res/menu/context.xml +++ b/FileManager/res/menu/context.xml @@ -1,8 +1,4 @@ - - + + xmlns:app="http://schemas.android.com/apk/res-auto"> - diff --git a/FileManagerDemo/build.gradle b/FileManagerDemo/build.gradle new file mode 100644 index 00000000..b90a9077 --- /dev/null +++ b/FileManagerDemo/build.gradle @@ -0,0 +1,84 @@ +apply plugin: 'com.android.application' + +dependencies { + implementation 'com.github.openintents:distribution:1.1.3' +} + +android { + compileSdkVersion 28 + buildToolsVersion '28.0.3' + + defaultConfig { + applicationId "org.openintents.filemanager.demo" + versionCode 40 + versionName "2.2.3" + minSdkVersion 14 + targetSdkVersion 28 + + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + } + + sourceSets { + main { + manifest.srcFile 'AndroidManifest.xml' + java.srcDirs = ['src'] + resources.srcDirs = ['src'] + aidl.srcDirs = ['src'] + renderscript.srcDirs = ['src'] + res.srcDirs = ['res'] + assets.srcDirs = ['assets'] + jni.srcDirs = ['jni'] + } + + + // Move the build types to build-types/ + // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ... + // This moves them out of them default location under src//... which would + // conflict with src/ being used by the main source set. + // Adding new build types or product flavors should be accompanied + // by a similar customization. + debug.setRoot('build-types/debug') + release.setRoot('build-types/release') + } + + lintOptions { + abortOnError false + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' + + applicationVariants.all { variant -> + variant.outputs.each { output -> + def outputFile = output.outputFile + if (outputFile != null && outputFile.name.endsWith('.apk')) { + def fileName = outputFile.name.replace('.apk', "-${versionName}.apk") + output.outputFileName = new File(output.outputFile.parent, fileName).getName() + } + } + } + } + } + + def propertyFile = new File(projectDir, "build-private.properties") + if (propertyFile && propertyFile.exists()) { + signingConfigs { + release { + Properties props = new Properties() + props.load(new FileInputStream(propertyFile)) + + storeFile file(props.getProperty("key.store")) + storePassword props.getProperty("key.store.password") + keyAlias props.getProperty("key.alias") + keyPassword props.getProperty("key.alias.password") + } + } + buildTypes.release.signingConfig signingConfigs.release + println "Release apks will be signed!" + } else { + println "For signed release apks you need to create a build-private.properties file" + } + +} diff --git a/FileManagerDemo/build.properties b/FileManagerDemo/build.properties deleted file mode 100644 index 00fe51ab..00000000 --- a/FileManagerDemo/build.properties +++ /dev/null @@ -1,42 +0,0 @@ -##### Notice: -# -# Ant properties are immutable: -# whoever sets a property first freezes -# it for the rest of the build. -# -# You can therefore override the following properties -# either through the command line or within Eclipse: -# -# -------------- -# In Eclipse: -# * Open "Window" / "Preferences..." -# * Select "Ant" / "Runtime" -# * Choose tab "Properties" -# * Click "Add Property..." for the following: -# -# * - Name: "android.sdk" -# - value: [path to sdk, e.g. C:\android-sdk_m5-rc15_windows] -# -------------< -# Alternatively, you can provide the property through the -# command line: -# * ant -Dandroid.sdk=C:\android-sdk_m5-rc15_windows -#################################### -# Global properties -# -#################################### -# OS specific properties -# -# android.sdk : path to Android SDK -### Windows -android.sdk=C:\\Program Files\\android\\android-sdk-windows-1.0_r1 -#android.sdk=C:\\android-sdk-windows-1.0_r1 -android.aapt=aapt.exe -android.aidl=aidl.exe -android.dx=dx.bat -android.jar=android.jar -### Linux -# android.sdk=/opt/tools/javame/android-sdk_m5-rc15_linux-x86 -# android.aapt=aapt -# android.aidl=aidl -# android.dx=dx -# android.jar=android.jar diff --git a/FileManagerDemo/build.xml b/FileManagerDemo/build.xml deleted file mode 100644 index e84d0748..00000000 --- a/FileManagerDemo/build.xml +++ /dev/null @@ -1,358 +0,0 @@ - - - - - - - - - - - - - Using Android SDK directory ${sdk-folder} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - purging .bak files - - - - - - - - Generating R.java / Manifest.java from the resources... - - - - - - - - - - - - - - - - - Compiling aidl files into Java classes... - - - - - - - - - - - - - - - - - - - - - Converting compiled files and external libraries into ${outdir}/${dex-file}... - - - - - - - - - - - Packaging resources and assets... - - - - - - - - - - - - - - - - - - - Packaging resources... - - - - - - - - - - - - - - - - - - - - - - - - - - Packaging ${out-debug-package}, and signing it with a debug key... - - - - - - - - - - - - - - - - Packaging ${out-unsigned-package} for release... - - - - - - - - - - - - - - - - - - Installing ${out-debug-package} onto default emulator... - - - - - - - - Installing ${out-debug-package} onto default emulator... - - - - - - - - - - - Installing ${out-signed-package} onto default emulator... - - - - - - - - Reinstalling ${out-signed-package} onto default emulator... - - - - - - - - - - Uninstalling ${application-package} from the default emulator... - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/FileManagerDemo/default.properties b/FileManagerDemo/default.properties deleted file mode 100644 index cd119dea..00000000 --- a/FileManagerDemo/default.properties +++ /dev/null @@ -1,2 +0,0 @@ -# Project target. -target=android-15 diff --git a/FileManagerDemo/src/org/openintents/filemanager/demo/Demo.java b/FileManagerDemo/src/org/openintents/filemanager/demo/Demo.java index 5132b4cd..b8461c6e 100644 --- a/FileManagerDemo/src/org/openintents/filemanager/demo/Demo.java +++ b/FileManagerDemo/src/org/openintents/filemanager/demo/Demo.java @@ -1,4 +1,4 @@ -/* +/* * Copyright (C) 2008 OpenIntents.org * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -50,8 +50,8 @@ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); - mEditText = (EditText) findViewById(R.id.file_path); - mTextView = (TextView) findViewById(R.id.info); + mEditText = findViewById(R.id.file_path); + mTextView = findViewById(R.id.info); } public void onClickOpenFile(View view) { @@ -78,14 +78,8 @@ public void onClickOpenUri(View view) { * Opens the file manager to select a file to open. */ public void openFile() { - String fileName = mEditText.getText().toString(); - Intent intent = new Intent(FileManagerIntents.ACTION_PICK_FILE); - // Construct URI from file name. - File file = new File(fileName); - intent.setData(Uri.fromFile(file)); - // Set fancy title and button (optional) intent.putExtra(FileManagerIntents.EXTRA_TITLE, getString(R.string.open_title)); intent.putExtra(FileManagerIntents.EXTRA_BUTTON_TEXT, getString(R.string.open_button)); @@ -130,15 +124,9 @@ private void saveFile() { * Opens the file manager to pick a directory. */ private void pickDirectory() { - String fileName = mEditText.getText().toString(); - // Note the different intent: PICK_DIRECTORY Intent intent = new Intent(FileManagerIntents.ACTION_PICK_DIRECTORY); - // Construct URI from file name. - File file = new File(fileName); - intent.setData(Uri.fromFile(file)); - // Set fancy title and button (optional) intent.putExtra(FileManagerIntents.EXTRA_TITLE, getString(R.string.pick_directory_title)); intent.putExtra(FileManagerIntents.EXTRA_BUTTON_TEXT, getString(R.string.pick_directory_button)); @@ -174,14 +162,11 @@ public void getContent() { * Use URI to get a file */ public void openFileUri() { - String filePath = mEditText.getText().toString(); - Uri uri = Uri.parse("file://" + filePath); Intent intent = new Intent(Intent.ACTION_VIEW); - intent.setData(uri); // optionally: - //intent.setPackage("org.openintents.filemanager"); + intent.setPackage("org.openintents.filemanager"); try { startActivity(intent); diff --git a/FileManagerTest/.classpath b/FileManagerTest/.classpath deleted file mode 100644 index c9e49941..00000000 --- a/FileManagerTest/.classpath +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/FileManagerTest/.project b/FileManagerTest/.project deleted file mode 100644 index 150d98c0..00000000 --- a/FileManagerTest/.project +++ /dev/null @@ -1,34 +0,0 @@ - - - OI File Manager Test - - - OI File Manager - - - - com.android.ide.eclipse.adt.ResourceManagerBuilder - - - - - com.android.ide.eclipse.adt.PreCompilerBuilder - - - - - org.eclipse.jdt.core.javabuilder - - - - - com.android.ide.eclipse.adt.ApkBuilder - - - - - - com.android.ide.eclipse.adt.AndroidNature - org.eclipse.jdt.core.javanature - - diff --git a/FileManagerTest/AndroidManifest.xml b/FileManagerTest/AndroidManifest.xml deleted file mode 100644 index d6d499c0..00000000 --- a/FileManagerTest/AndroidManifest.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/FileManagerTest/ant.properties b/FileManagerTest/ant.properties deleted file mode 100644 index 77fdbfab..00000000 --- a/FileManagerTest/ant.properties +++ /dev/null @@ -1,14 +0,0 @@ -# This file is used to override default values used by the Ant build system. -# -# This file must be checked in Version Control Systems, as it is -# integral to the build system of your project. -# This file is only used by the Ant script. -# You can use this to override default values such as -# 'source.dir' for the location of your java source folder and -# 'out.dir' for the location of your output folder. -# You can also use it define how the release builds are signed by declaring -# the following properties: -# 'key.store' for the location of your keystore and -# 'key.alias' for the name of the key to use. -# The password will be asked during the build when you use the 'release' target. -tested.project.dir=../FileManager diff --git a/FileManagerTest/build.xml b/FileManagerTest/build.xml deleted file mode 100644 index 75e7c9a2..00000000 --- a/FileManagerTest/build.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/FileManagerTest/libs/polidea_test_runner_1.2.jar b/FileManagerTest/libs/polidea_test_runner_1.2.jar deleted file mode 100644 index 69da44aa..00000000 Binary files a/FileManagerTest/libs/polidea_test_runner_1.2.jar and /dev/null differ diff --git a/FileManagerTest/libs/robotium-solo-3.4.1-javadoc.jar b/FileManagerTest/libs/robotium-solo-3.4.1-javadoc.jar deleted file mode 100644 index 9a79d8c8..00000000 Binary files a/FileManagerTest/libs/robotium-solo-3.4.1-javadoc.jar and /dev/null differ diff --git a/FileManagerTest/libs/robotium-solo-3.4.1.jar b/FileManagerTest/libs/robotium-solo-3.4.1.jar deleted file mode 100644 index 88906845..00000000 Binary files a/FileManagerTest/libs/robotium-solo-3.4.1.jar and /dev/null differ diff --git a/FileManagerTest/lint.xml b/FileManagerTest/lint.xml deleted file mode 100644 index 1f88ec8a..00000000 --- a/FileManagerTest/lint.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/FileManagerTest/project.properties b/FileManagerTest/project.properties deleted file mode 100644 index c291a152..00000000 --- a/FileManagerTest/project.properties +++ /dev/null @@ -1,12 +0,0 @@ -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must be checked in Version Control Systems. -# -# To customize properties used by the Ant build system use, -# "ant.properties", and override values to adapt the script to your -# project structure. -# Indicates whether an apk should be generated for each density. -split.density=false -# Project target. -target=android-16 diff --git a/FileManagerTest/readme.txt b/FileManagerTest/readme.txt deleted file mode 100644 index 8578ea62..00000000 --- a/FileManagerTest/readme.txt +++ /dev/null @@ -1,28 +0,0 @@ - **************************************************************************** - * Copyright (C) 2008-2011 OpenIntents.org * - * * - * Licensed under the Apache License, Version 2.0 (the "License"); * - * you may not use this file except in compliance with the License. * - * You may obtain a copy of the License at * - * * - * http://www.apache.org/licenses/LICENSE-2.0 * - * * - * Unless required by applicable law or agreed to in writing, software * - * distributed under the License is distributed on an "AS IS" BASIS, * - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * - * See the License for the specific language governing permissions and * - * limitations under the License. * - **************************************************************************** - - -OI File Manager Test. - -To obtain the current release, visit - http://www.openintents.org - - ---------------------------------------------------------- -release: 1.0 -date: ? -- First version: GCI task by Michał Zieliński. -- Fix tests that fail on Android 4.0.3: patch by George Venios. diff --git a/FileManagerTest/res/drawable-hdpi/icon.png b/FileManagerTest/res/drawable-hdpi/icon.png deleted file mode 100644 index 8074c4c5..00000000 Binary files a/FileManagerTest/res/drawable-hdpi/icon.png and /dev/null differ diff --git a/FileManagerTest/res/drawable-ldpi/icon.png b/FileManagerTest/res/drawable-ldpi/icon.png deleted file mode 100644 index 1095584e..00000000 Binary files a/FileManagerTest/res/drawable-ldpi/icon.png and /dev/null differ diff --git a/FileManagerTest/res/drawable-mdpi/icon.png b/FileManagerTest/res/drawable-mdpi/icon.png deleted file mode 100644 index a07c69fa..00000000 Binary files a/FileManagerTest/res/drawable-mdpi/icon.png and /dev/null differ diff --git a/FileManagerTest/res/layout/main.xml b/FileManagerTest/res/layout/main.xml deleted file mode 100644 index f3cf75da..00000000 --- a/FileManagerTest/res/layout/main.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - diff --git a/FileManagerTest/res/values/strings.xml b/FileManagerTest/res/values/strings.xml deleted file mode 100644 index fdea3061..00000000 --- a/FileManagerTest/res/values/strings.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - Hello World! - TestNoteList - diff --git a/FileManagerTest/src/org/openintents/filemanager/test/TestFileManagerActivity.java b/FileManagerTest/src/org/openintents/filemanager/test/TestFileManagerActivity.java deleted file mode 100644 index 2136ec12..00000000 --- a/FileManagerTest/src/org/openintents/filemanager/test/TestFileManagerActivity.java +++ /dev/null @@ -1,564 +0,0 @@ -/* - * This is an example test project created in Eclipse to test NotePad which is a sample - * project located in AndroidSDK/samples/android-11/NotePad - * Just click on File --> New --> Project --> Android Project --> Create Project from existing source and - * select NotePad. - * - * Then you can run these test cases either on the emulator or on device. You right click - * the test project and select Run As --> Run As Android JUnit Test - * - * @author Renas Reda, renas.reda@jayway.com - * - */ - -package org.openintents.filemanager.test; - -import android.app.Activity; -import android.content.Intent; -import android.content.SharedPreferences; -import android.net.Uri; -import android.os.Environment; -import android.preference.PreferenceManager; -import android.test.InstrumentationTestCase; - -import com.jayway.android.robotium.solo.Solo; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStreamWriter; -import java.util.Random; - -public class TestFileManagerActivity extends InstrumentationTestCase { - - private static final String TAG = "TestFileManagerActivity"; - - private Solo solo; - private Activity activity; - private Random random = new Random(); - private Intent intent; - private String sdcardPath; - - public TestFileManagerActivity() { - super(); - } - - protected void setUp() throws Exception { - super.setUp(); - - sdcardPath = Environment.getExternalStorageDirectory().getAbsolutePath() + '/'; - - // need to do this before creating activity - cleanDirectory(new File(sdcardPath + "oi-filemanager-tests")); - createDirectory(sdcardPath + "oi-filemanager-tests"); - - intent = new Intent(); - intent.setAction("android.intent.action.MAIN"); - intent.setClassName("org.openintents.filemanager", - "org.openintents.filemanager.FileManagerActivity"); - intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - - activity = getInstrumentation().startActivitySync(intent); - - this.solo = new Solo(getInstrumentation(), activity); - } - - protected void tearDown() throws Exception { - try { - this.solo.finishOpenedActivities(); - } catch (Throwable e) { - e.printStackTrace(); - } - super.tearDown(); - cleanDirectory(new File(sdcardPath + "oi-filemanager-tests")); - } - - private String getAppString(int resId) { - return activity.getString(resId); - } -// -// @Smoke -// public void test000Eula() { -// String accept = getAppString(org.openintents.distribution.R.string.oi_distribution_eula_accept); -// String cancel = getAppString(org.openintents.distribution.R.string.oi_distribution_eula_refuse); -// boolean existsAccept = solo.searchButton(accept); -// boolean existsCancel = solo.searchButton(cancel); -// -// if (existsAccept && existsCancel) { -// solo.clickOnButton(accept); -// } -// } -// -// @Smoke -// public void test001RecentChanges() { -// String recentChanges = getAppString(org.openintents.distribution.R.string.oi_distribution_newversion_recent_changes); -// String cont = getAppString(org.openintents.distribution.R.string.oi_distribution_newversion_continue); -// while(solo.scrollUp()); -// boolean existsRecentChanges = solo.searchText(recentChanges); -// boolean existsCont = solo.searchButton(cont); -// -// if (existsRecentChanges && existsCont) { -// solo.clickOnButton(cont); -// } -// } - - private void cleanDirectory(File file) { - if (!file.exists()) return; - for (String name : file.list()) { - if (!name.startsWith("oi-") && !name.startsWith(".oi-")) { - throw new RuntimeException(file + " contains unexpected file"); - } - File child = new File(file, name); - if (child.isDirectory()) - cleanDirectory(child); - else - child.delete(); - } - file.delete(); - if (file.exists()) { - throw new RuntimeException("Deletion of " + file + " failed"); - } - } - - private void createFile(String path, String content) throws IOException { - File file = new File(path); - OutputStreamWriter wr = new OutputStreamWriter(new FileOutputStream(file), "UTF-8"); - wr.write(content); - wr.close(); - } - - private void createDirectory(String path) throws IOException { - File file = new File(path); - file.mkdir(); - if (!file.exists()) - throw new IOException("Creation of " + path + " failed"); - } - - private void deleteDirectory(String path) { - File file = new File(path); - if (file.exists()) - if (file.isDirectory()) - cleanDirectory(file); - file.delete(); - } - - public void testNavigation() throws IOException { -// if(solo.searchText("Accept")) { -// solo.clickOnButton("Accept"); -// if(solo.searchButton("Continue")) -// solo.clickOnButton("Continue"); -// } - createDirectory(sdcardPath + "oi-filemanager-tests"); - createFile(sdcardPath + "oi-filemanager-tests/oi-test.txt", ""); - createDirectory(sdcardPath + "oi-filemanager-tests/oi-test-dir"); - createFile(sdcardPath + "oi-filemanager-tests/oi-test-dir/oi-fff.txt", ""); - - solo.clickOnText("oi-filemanager-tests"); - assertTrue(solo.searchText("oi-test.txt")); - solo.clickOnText("oi-test-dir"); - assertTrue(solo.searchText("oi-fff.txt")); - - solo.goBack(); - solo.goBack(); - solo.clickOnText("oi-filemanager-tests"); - assertTrue(solo.searchText("oi-test.txt")); - - solo.clickOnText("oi-test-dir"); - solo.goBack(); - assertTrue(solo.searchText("oi-test.txt")); - - solo.goBack(); - } - - public void testModification() throws IOException { - createDirectory(sdcardPath + "oi-filemanager-tests"); - createFile(sdcardPath + "oi-filemanager-tests/oi-rem-test.txt", ""); - solo.clickOnText("oi-filemanager-tests"); - solo.clickLongOnText("oi-rem-test.txt"); - - if (android.os.Build.VERSION.SDK_INT < 11) - solo.clickOnText(getAppString(org.openintents.filemanager.R.string.menu_delete)); // Delete - else - solo.clickOnActionBarItem(org.openintents.filemanager.R.id.menu_delete); - solo.clickOnText(getAppString(android.R.string.ok)); - - if (android.os.Build.VERSION.SDK_INT < 11) - solo.clickOnMenuItem(getAppString(org.openintents.filemanager.R.string.menu_create_folder), true); // New Folder - else - solo.clickOnActionBarItem(org.openintents.filemanager.R.id.menu_create_folder); - solo.enterText(0, "oi-created-folder"); - solo.clickOnText(getAppString(android.R.string.ok)); - - solo.goBack(); - assertTrue(solo.searchText("oi-created-folder")); - solo.goBack(); - - File createdFolder = new File(sdcardPath + "oi-filemanager-tests/oi-created-folder"); - assertTrue(createdFolder.exists()); - assertTrue(createdFolder.isDirectory()); - assertFalse(new File(sdcardPath + "oi-filemanager-tests/oi-rem-test.txt").exists()); - } - - public void testBookmarks() throws IOException { - String fn = "oi-bookmark-" + random.nextInt(1000); - createDirectory(sdcardPath + "oi-filemanager-tests"); - createDirectory(sdcardPath + "oi-filemanager-tests/" + fn); - createFile(sdcardPath + "oi-filemanager-tests/" + fn + "/oi-inside-book.txt", ""); - - // create bookmark - solo.clickOnText("oi-filemanager-tests"); - solo.clickLongOnText(fn); - solo.clickOnText(getAppString(org.openintents.filemanager.R.string.menu_bookmark)); // Add to bookmarks - - // navigate to it - if (android.os.Build.VERSION.SDK_INT < 11) - solo.clickOnMenuItem(getAppString(org.openintents.filemanager.R.string.bookmarks)); // Bookmarks - else - solo.clickOnActionBarItem(org.openintents.filemanager.R.id.menu_bookmarks); - solo.clickOnText(fn); - assertTrue(solo.searchText("oi-inside-book.txt")); - - // remove it - if (android.os.Build.VERSION.SDK_INT < 11) - solo.clickOnMenuItem(getAppString(org.openintents.filemanager.R.string.bookmarks)); // Bookmarks - else - solo.clickOnActionBarItem(org.openintents.filemanager.R.id.menu_bookmarks); - solo.clickLongOnText(fn); - if (android.os.Build.VERSION.SDK_INT < 11) - solo.clickOnText(getAppString(org.openintents.filemanager.R.string.menu_delete)); - else - solo.clickOnActionBarItem(org.openintents.filemanager.R.id.menu_delete); - solo.goBack(); - - // make sure that it is deleted - solo.clickOnMenuItem(getAppString(org.openintents.filemanager.R.string.bookmarks)); - assertFalse(solo.searchText(fn)); - solo.goBack(); - solo.goBack(); - } - - public void testActions() throws IOException { - createDirectory(sdcardPath + "oi-filemanager-tests"); - createDirectory(sdcardPath + "oi-filemanager-tests/oi-move-target"); - createFile(sdcardPath + "oi-filemanager-tests/oi-file-1.txt", ""); - createFile(sdcardPath + "oi-filemanager-tests/oi-file-2.txt", ""); - createFile(sdcardPath + "oi-filemanager-tests/oi-file-3.txt", ""); - createFile(sdcardPath + "oi-filemanager-tests/oi-file-4.txt", ""); - createFile(sdcardPath + "oi-filemanager-tests/oi-file-5.txt", ""); - solo.clickOnText("oi-filemanager-tests"); - - // copy - solo.clickLongOnText("oi-file-1.txt"); - solo.clickOnText(getAppString(org.openintents.filemanager.R.string.menu_copy)); - navigateToTargetAndPasteAndCheck("oi-move-target", "oi-file-1.txt", null); - assertTrue(solo.searchText("oi-file-1.txt")); - - // move - solo.clickLongOnText("oi-file-2.txt"); - solo.clickOnText(getAppString(org.openintents.filemanager.R.string.menu_move)); - navigateToTargetAndPasteAndCheck("oi-move-target", "oi-file-2.txt", null); - assertFalse(solo.searchText("oi-file-2.txt")); - - // multi select - if (android.os.Build.VERSION.SDK_INT < 11) { - solo.clickOnMenuItem(getAppString(org.openintents.filemanager.R.string.menu_multiselect)); - solo.clickOnText("oi-file-3.txt"); - solo.clickOnText("oi-file-4.txt"); - solo.clickOnImageButton(1); - solo.goBack(); - - navigateToTargetAndPasteAndCheck("oi-move-target", "oi-file-3.txt", "oi-file-4.txt"); - } - - // rename - solo.clickLongOnText("oi-file-5.txt"); - solo.clickOnText(getAppString(org.openintents.filemanager.R.string.menu_rename)); - solo.enterText(0, "oi-renamed-file.txt"); - solo.clickOnText(getAppString(android.R.string.ok)); // not sure what to do - assertTrue(solo.searchText("oi-renamed-file.txt")); - - solo.goBack(); - solo.goBack(); - } - - private void navigateToTargetAndPasteAndCheck(String dirname, String name1, String name2) throws IOException { - createDirectory(sdcardPath + "oi-filemanager-tests/"); - solo.clickOnText(dirname); - - if (android.os.Build.VERSION.SDK_INT < 11) - solo.clickOnMenuItem(getAppString(org.openintents.filemanager.R.string.menu_paste), true); - else - solo.clickOnActionBarItem(org.openintents.filemanager.R.id.menu_paste); - - assertTrue(solo.searchText(name1)); - if (name2 != null) - assertTrue(solo.searchText(name2)); - solo.goBack(); - } - - public void testDetails() throws IOException { - createDirectory(sdcardPath + "oi-filemanager-tests"); - createFile(sdcardPath + "oi-filemanager-tests/oi-detail.txt", "abcdefg"); - - solo.clickOnText("oi-filemanager-tests"); - - solo.clickLongOnText("oi-detail.txt"); - solo.clickOnText(getAppString(org.openintents.filemanager.R.string.menu_details)); - assertTrue(solo.searchText(getAppString(org.openintents.filemanager.R.string.details_type_file))); - // depending on locale: - assertTrue(solo.searchText("7.00B") || solo.searchText("7.00 B") || solo.searchText("7,00B") || solo.searchText("7,00 B")); - - // not sure: - //Calendar today = new GregorianCalendar(); - //String todayString = today.get(Calendar.DAY_OF_MONTH) + "/" + today.get(Calendar.MONTH) + "/" + today.get(Calendar.YEAR); - //assertTrue(solo.searchText(todayString)); - - solo.goBack(); - solo.goBack(); - solo.goBack(); - } - - public void testHiddenFiles() throws IOException { - createDirectory(sdcardPath + "oi-filemanager-tests"); - createFile(sdcardPath + "oi-filemanager-tests/.oi-hidden.txt", ""); - solo.clickOnText("oi-filemanager-tests"); - - boolean origState = solo.searchText(".oi-hidden.txt"); - - solo.clickOnMenuItem(getAppString(org.openintents.filemanager.R.string.settings)); - - solo.clickOnText(getAppString(org.openintents.filemanager.R.string.preference_displayhiddenfiles_title)); - solo.goBack(); - assertTrue(origState != solo.searchText(".oi-hidden.txt")); - - solo.goBack(); - solo.goBack(); - } - - public void testOrder() throws IOException, InterruptedException { - createDirectory(sdcardPath + "oi-filemanager-tests"); - createFile(sdcardPath + "oi-filemanager-tests/oi-b.txt", "bbb"); - Thread.sleep(10); // make sure that next file is younger - createFile(sdcardPath + "oi-filemanager-tests/oi-a.txt", "aaaaaa"); - Thread.sleep(10); - createFile(sdcardPath + "oi-filemanager-tests/oi-c.txt", ""); - solo.clickOnText("oi-filemanager-tests"); - - String[] sortOrders = activity.getResources().getStringArray(org.openintents.filemanager.R.array.preference_sortby_names); - - setAscending(true); - setSortOrder(sortOrders[0]); - assertItemsInOrder("oi-a.txt", "oi-b.txt", "oi-c.txt"); - - setSortOrder(sortOrders[1]); - assertItemsInOrder("oi-c.txt", "oi-b.txt", "oi-a.txt"); - - setSortOrder(sortOrders[2]); - assertItemsInOrder("oi-b.txt", "oi-a.txt", "oi-c.txt"); - - setAscending(false); - setSortOrder(sortOrders[0]); - assertItemsInOrder("oi-c.txt", "oi-b.txt", "oi-a.txt"); - } - - private void setSortOrder(String name) { - solo.clickOnMenuItem(getAppString(org.openintents.filemanager.R.string.settings)); - solo.clickOnText(getAppString(org.openintents.filemanager.R.string.preference_sortby)); - solo.clickOnText(name); - solo.goBack(); - } - - private void setAscending(boolean enabled) { - SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(activity); - SharedPreferences.Editor editor = settings.edit(); - editor.putBoolean("ascending", enabled); - editor.commit(); - } - - private void assertItemsInOrder(String a, String b, String c) { - int aPos = solo.getText(a).getTop(); - int bPos = solo.getText(b).getTop(); - int cPos = solo.getText(c).getTop(); - if (aPos > bPos) - fail("aPos > bPos"); - if (bPos > cPos) - fail("bpos > cPos"); - } - - public void testIntentSaveAs() throws IOException { - createDirectory(sdcardPath + "oi-filemanager-tests"); - createFile(sdcardPath + "oi-filemanager-tests/oi-to-open.txt", "bbb"); - - Uri uri = Uri.parse("file://" + sdcardPath + "oi-filemanager-tests/oi-to-open.txt"); - intent = new Intent("android.intent.action.VIEW", uri); - intent.setClassName("org.openintents.filemanager", - "org.openintents.filemanager.SaveAsActivity"); - intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - - activity = getInstrumentation().startActivitySync(intent); - - solo.clickLongOnText(Environment.getExternalStorageDirectory().getParentFile().getName()); - solo.enterText(0, "oi-target.txt"); - solo.sendKey(Solo.ENTER); - assertTrue(new File(sdcardPath + "oi-filemanager-tests/oi-to-open.txtoi-target.txt").exists()); - solo.goBack(); - solo.goBack(); - } - - public void testIntentUrl() throws IOException { - createDirectory(sdcardPath + "oi-filemanager-tests"); - createDirectory(sdcardPath + "oi-filemanager-tests/oi-dir-to-open"); - createDirectory(sdcardPath + "oi-filemanager-tests/oi-dir-to-open/oi-intent"); - - Uri uri = Uri.parse("file://" + sdcardPath + "oi-filemanager-tests/oi-dir-to-open"); - intent = new Intent("android.intent.action.VIEW", uri); - intent.setClassName("org.openintents.filemanager", - "org.openintents.filemanager.FileManagerActivity"); - intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - - activity = getInstrumentation().startActivitySync(intent); - - assertTrue(solo.searchText("oi-intent")); - solo.goBack(); - solo.goBack(); - } - - public void testIntentPickFile() throws IOException { - // startActivityForResult is, I think, impossible to test on Robotinium - createDirectory(sdcardPath + "oi-filemanager-tests"); - createFile(sdcardPath + "oi-filemanager-tests/oi-pick-file", ""); - - Uri uri = Uri.parse("file://" + sdcardPath + "oi-filemanager-tests"); - intent = new Intent("org.openintents.action.PICK_FILE", uri); - intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - - activity = getInstrumentation().startActivitySync(intent); - - solo.clickOnText("oi-pick-file"); - - solo.goBack(); - } - - public void testIntentRememberPickFilePath() throws IOException { - String[] actions = new String[]{ - org.openintents.intents.FileManagerIntents.ACTION_PICK_FILE, - org.openintents.intents.FileManagerIntents.ACTION_PICK_DIRECTORY, - Intent.ACTION_GET_CONTENT - }; - - for (int i = 0; i < 3; i++) { - createDirectory(sdcardPath + "oi-filemanager-tests"); - if (i == 1) { //Pick directory - createDirectory(sdcardPath + "oi-filemanager-tests/oi-dir-to-pick"); - } else { - createFile(sdcardPath + "oi-filemanager-tests/oi-file-to-pick.txt", "bbb"); - } - //Directory because PICK_DIRECTORY doesn't show files - createDirectory(sdcardPath + "oi-to-pick-test-folder-deleted"); - - - // Pick a file first - Uri uri = Uri.parse("file://" + sdcardPath); //If there was already a remembered pick file path - intent = new Intent(actions[i], uri); - intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - - activity = getInstrumentation().startActivitySync(intent); - - solo.clickOnText("oi-filemanager-tests"); - if (i == 1) //Pick directory - solo.clickOnText("oi-dir-to-pick"); - else - solo.clickOnText("oi-file-to-pick.txt"); - - if (i == 2) // When ACTION_GET_CONTENT, the file is picked automatically, when clicked - solo.clickOnButton(getAppString(org.openintents.filemanager.R.string.directory_pick)); - - // Check, if we are in the oi-filemanager-tests directory - intent = new Intent(actions[i]); - intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - activity = getInstrumentation().startActivitySync(intent); - - solo.goBack(); - - - //Delete the oi-filemanager-tests directory - deleteDirectory(sdcardPath + "oi-filemanager-tests"); - - //Check, if the current directory is the default (sdcardPath) - intent = new Intent(actions[i]); - intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - activity = getInstrumentation().startActivitySync(intent); - - assertTrue(solo.searchText("oi-to-pick-test-folder-deleted")); - - //Clean up - (new File(sdcardPath + "oi-to-pick-test-folder-deleted")).delete(); - - solo.goBack(); - solo.goBack(); - } - } - - public void testBrowseToOnPressEnter() throws IOException { - String dirPath = "oi-filemanager-tests"; - String filename = "oi-test-is-in-right-directory"; - createDirectory(sdcardPath + dirPath); - createFile(sdcardPath + dirPath + "/" + filename, ""); - - /* - * We start at the SD card. - */ - solo.clickLongOnText(Environment.getExternalStorageDirectory().getParentFile().getName()); - - solo.clickOnEditText(0); // Let the editText have focus to be able to send the enter key. - solo.enterText(0, "/" + dirPath); - solo.sendKey(Solo.ENTER); - - assertTrue(solo.searchText(filename)); - - solo.goBack(); - solo.goBack(); - } - -// Current implementation directly opens the file and therefore can't be tested. -// public void testIntentUri() throws IOException { -// createDirectory(sdcardPath + "oi-filemanager-tests"); -// createFile(sdcardPath + "oi-filemanager-tests/oi-to-open.txt", "bbb"); -// -// Intent intent = new Intent(Intent.ACTION_VIEW); -// intent.setData(Uri.parse("file://" + sdcardPath + "oi-filemanager-tests/oi-to-open.txt")); -// intent.setClass(activity, org.openintents.filemanager.FileManagerActivity.class); -// intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); -// -// activity = getInstrumentation().startActivitySync(intent); -// -// assertTrue(solo.searchText("oi-to-open.txt")); -// solo.goBack(); -// solo.goBack(); -// } - -// Removed as Filter action is obsolete and removed. -// public void testFilters() throws IOException { -// createDirectory(sdcardPath + "oi-filemanager-tests"); -// createFile(sdcardPath + "oi-filemanager-tests/oi-not-filter.txt", ""); -// createFile(sdcardPath + "oi-filemanager-tests/oi-filtered.py", ""); -// createDirectory(sdcardPath + "oi-filemanager-tests/oi-f-dir"); -// solo.clickOnText("oi-filemanager-tests"); -// -// solo.clickOnMenuItem(getAppString(org.openintents.filemanager.R.string.menu_filter)); -// solo.enterText(0, ".py"); -// solo.clickOnButton(getAppString(android.R.string.ok)); -// -// assertTrue(solo.searchText("oi-filtered.py")); -// assertTrue(solo.searchText("oi-f-dir")); -// assertFalse(solo.searchText("oi-not-filter.txt")); -// -// solo.goBack(); -// solo.goBack(); -// } - - // Other possible tests: - // testSend - // testMore - // testKeyboardFilter -} \ No newline at end of file diff --git a/build.gradle b/build.gradle index e7b3262b..3528e99e 100644 --- a/build.gradle +++ b/build.gradle @@ -5,19 +5,17 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:3.0.0' + classpath 'com.android.tools.build:gradle:3.3.1' } } allprojects { repositories { + google() jcenter() maven { url 'https://jitpack.io' } - maven { - url "https://maven.google.com" - } } apply plugin: 'findbugs' diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 3cf9c1af..0ba46975 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Wed Mar 29 20:52:18 CEST 2017 +#Wed Feb 13 09:23:13 CET 2019 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip diff --git a/settings.gradle b/settings.gradle index 32a2e9a1..768e0e2c 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1 +1 @@ -include 'FileManager' \ No newline at end of file +include 'FileManager', 'FileManagerDemo' \ No newline at end of file