From 7eeda1a2af7a7efa43b373585503a7923de0ed86 Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 25 Oct 2016 19:07:02 +0200 Subject: [PATCH] include the filepicker project via gradle --- app/build.gradle | 4 +- .../filemanager/fragments/ItemsFragment.java | 6 +- app/src/main/res/drawable-v21/selector.xml | 4 +- app/src/main/res/drawable/selector.xml | 4 +- app/src/main/res/layout/activity_about.xml | 26 +-- app/src/main/res/layout/activity_license.xml | 4 +- app/src/main/res/layout/activity_main.xml | 2 +- app/src/main/res/layout/activity_settings.xml | 6 +- app/src/main/res/layout/copy_item.xml | 30 ++-- app/src/main/res/layout/create_new.xml | 10 +- app/src/main/res/layout/directory_picker.xml | 5 +- app/src/main/res/layout/item_properties.xml | 6 +- app/src/main/res/layout/items_fragment.xml | 4 +- app/src/main/res/layout/list_item.xml | 20 +-- app/src/main/res/layout/property_item.xml | 8 +- app/src/main/res/layout/rename_item.xml | 4 +- app/src/main/res/values/styles.xml | 4 +- library/build.gradle | 49 ------ library/proguard-rules.pro | 17 -- library/src/main/AndroidManifest.xml | 2 - .../filepicker/adapters/ItemsAdapter.kt | 79 --------- .../filepicker/dialogs/PickFolderDialog.kt | 133 -------------- .../filepicker/extensions/long.kt | 12 -- .../filepicker/extensions/resources.kt | 16 -- .../filepicker/extensions/string.kt | 5 - .../filepicker/models/FileDirItem.kt | 43 ----- .../filepicker/views/Breadcrumbs.kt | 162 ------------------ .../main/res/drawable-v21/smtfp_selector.xml | 17 -- .../src/main/res/drawable/smtfp_selector.xml | 5 - .../main/res/layout/smtfp_breadcrumb_item.xml | 6 - .../res/layout/smtfp_directory_picker.xml | 20 --- .../src/main/res/layout/smtfp_list_item.xml | 45 ----- .../main/res/mipmap-hdpi/smtfp_directory.png | Bin 135 -> 0 bytes .../src/main/res/mipmap-hdpi/smtfp_file.png | Bin 153 -> 0 bytes .../main/res/mipmap-mdpi/smtfp_directory.png | Bin 122 -> 0 bytes .../src/main/res/mipmap-mdpi/smtfp_file.png | Bin 133 -> 0 bytes .../main/res/mipmap-xhdpi/smtfp_directory.png | Bin 181 -> 0 bytes .../src/main/res/mipmap-xhdpi/smtfp_file.png | Bin 206 -> 0 bytes .../res/mipmap-xxhdpi/smtfp_directory.png | Bin 245 -> 0 bytes .../src/main/res/mipmap-xxhdpi/smtfp_file.png | Bin 283 -> 0 bytes .../res/mipmap-xxxhdpi/smtfp_directory.png | Bin 325 -> 0 bytes .../main/res/mipmap-xxxhdpi/smtfp_file.png | Bin 372 -> 0 bytes library/src/main/res/values-de/strings.xml | 11 -- library/src/main/res/values-it/strings.xml | 11 -- library/src/main/res/values-ja/strings.xml | 11 -- .../src/main/res/values-pt-rPT/strings.xml | 11 -- library/src/main/res/values-sv/strings.xml | 11 -- library/src/main/res/values/colors.xml | 6 - library/src/main/res/values/dimens.xml | 9 - library/src/main/res/values/strings.xml | 11 -- settings.gradle | 2 +- 51 files changed, 71 insertions(+), 770 deletions(-) delete mode 100644 library/build.gradle delete mode 100644 library/proguard-rules.pro delete mode 100644 library/src/main/AndroidManifest.xml delete mode 100644 library/src/main/kotlin/com/simplemobiletools/filepicker/adapters/ItemsAdapter.kt delete mode 100644 library/src/main/kotlin/com/simplemobiletools/filepicker/dialogs/PickFolderDialog.kt delete mode 100644 library/src/main/kotlin/com/simplemobiletools/filepicker/extensions/long.kt delete mode 100644 library/src/main/kotlin/com/simplemobiletools/filepicker/extensions/resources.kt delete mode 100644 library/src/main/kotlin/com/simplemobiletools/filepicker/extensions/string.kt delete mode 100644 library/src/main/kotlin/com/simplemobiletools/filepicker/models/FileDirItem.kt delete mode 100644 library/src/main/kotlin/com/simplemobiletools/filepicker/views/Breadcrumbs.kt delete mode 100644 library/src/main/res/drawable-v21/smtfp_selector.xml delete mode 100644 library/src/main/res/drawable/smtfp_selector.xml delete mode 100644 library/src/main/res/layout/smtfp_breadcrumb_item.xml delete mode 100644 library/src/main/res/layout/smtfp_directory_picker.xml delete mode 100644 library/src/main/res/layout/smtfp_list_item.xml delete mode 100644 library/src/main/res/mipmap-hdpi/smtfp_directory.png delete mode 100644 library/src/main/res/mipmap-hdpi/smtfp_file.png delete mode 100644 library/src/main/res/mipmap-mdpi/smtfp_directory.png delete mode 100644 library/src/main/res/mipmap-mdpi/smtfp_file.png delete mode 100644 library/src/main/res/mipmap-xhdpi/smtfp_directory.png delete mode 100644 library/src/main/res/mipmap-xhdpi/smtfp_file.png delete mode 100644 library/src/main/res/mipmap-xxhdpi/smtfp_directory.png delete mode 100644 library/src/main/res/mipmap-xxhdpi/smtfp_file.png delete mode 100644 library/src/main/res/mipmap-xxxhdpi/smtfp_directory.png delete mode 100644 library/src/main/res/mipmap-xxxhdpi/smtfp_file.png delete mode 100644 library/src/main/res/values-de/strings.xml delete mode 100644 library/src/main/res/values-it/strings.xml delete mode 100644 library/src/main/res/values-ja/strings.xml delete mode 100644 library/src/main/res/values-pt-rPT/strings.xml delete mode 100644 library/src/main/res/values-sv/strings.xml delete mode 100644 library/src/main/res/values/colors.xml delete mode 100644 library/src/main/res/values/dimens.xml delete mode 100644 library/src/main/res/values/strings.xml diff --git a/app/build.gradle b/app/build.gradle index 3a501fca..64da606b 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -39,12 +39,10 @@ dependencies { compile 'com.android.support:design:23.4.0' compile 'com.jakewharton:butterknife:8.0.1' compile 'com.github.bumptech.glide:glide:3.7.0' + compile 'com.simplemobiletools:filepicker:1.0.0' compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" apt 'com.jakewharton:butterknife-compiler:8.0.1' - - debugCompile project(path: ':library', configuration: 'debug') - releaseCompile project(path: ':library', configuration: 'release') } repositories { diff --git a/app/src/main/java/com/simplemobiletools/filemanager/fragments/ItemsFragment.java b/app/src/main/java/com/simplemobiletools/filemanager/fragments/ItemsFragment.java index 96b99efc..dc1dfa1e 100644 --- a/app/src/main/java/com/simplemobiletools/filemanager/fragments/ItemsFragment.java +++ b/app/src/main/java/com/simplemobiletools/filemanager/fragments/ItemsFragment.java @@ -39,8 +39,6 @@ import com.simplemobiletools.filemanager.Utils; import com.simplemobiletools.filemanager.adapters.ItemsAdapter; import com.simplemobiletools.filemanager.asynctasks.CopyTask; import com.simplemobiletools.filemanager.dialogs.PropertiesDialog; -import com.simplemobiletools.filepicker.dialogs.PickFolderDialog; -import com.simplemobiletools.filepicker.models.FileDirItem; import java.io.File; import java.io.FileFilter; @@ -581,9 +579,9 @@ public class ItemsFragment extends android.support.v4.app.Fragment public void onClick(final View view) { final boolean showHiddenItems = mConfig.getShowHidden(); final boolean showFullPath = mConfig.getShowFullPath(); - PickFolderDialog dialog = PickFolderDialog.Companion.newInstance(mCopyDestinationPath, showHiddenItems, showFullPath); + /*PickFolderDialog dialog = PickFolderDialog.Companion.newInstance(mCopyDestinationPath, showHiddenItems, showFullPath); dialog.setTargetFragment(ItemsFragment.this, SELECT_FOLDER_REQUEST); - dialog.show(getFragmentManager(), "selectFolder"); + dialog.show(getFragmentManager(), "selectFolder");*/ } }; diff --git a/app/src/main/res/drawable-v21/selector.xml b/app/src/main/res/drawable-v21/selector.xml index a454cfaf..4d61c7b4 100644 --- a/app/src/main/res/drawable-v21/selector.xml +++ b/app/src/main/res/drawable-v21/selector.xml @@ -3,12 +3,12 @@ - + diff --git a/app/src/main/res/drawable/selector.xml b/app/src/main/res/drawable/selector.xml index 24f9c0ac..1277703b 100644 --- a/app/src/main/res/drawable/selector.xml +++ b/app/src/main/res/drawable/selector.xml @@ -1,5 +1,5 @@ - - + + diff --git a/app/src/main/res/layout/activity_about.xml b/app/src/main/res/layout/activity_about.xml index 4c0f6851..f43c95dd 100644 --- a/app/src/main/res/layout/activity_about.xml +++ b/app/src/main/res/layout/activity_about.xml @@ -10,9 +10,9 @@ android:id="@+id/about_holder" android:layout_width="match_parent" android:layout_height="wrap_content" - android:paddingBottom="@dimen/smtfp_activity_margin" - android:paddingLeft="@dimen/smtfp_activity_margin" - android:paddingTop="@dimen/smtfp_activity_margin"> + android:paddingBottom="@dimen/activity_margin" + android:paddingLeft="@dimen/activity_margin" + android:paddingTop="@dimen/activity_margin"> @@ -52,8 +52,8 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@+id/about_invite" - android:paddingBottom="@dimen/smtfp_activity_margin" - android:paddingTop="@dimen/smtfp_activity_margin" + android:paddingBottom="@dimen/activity_margin" + android:paddingTop="@dimen/activity_margin" android:text="@string/rate_us_underlined" android:textColor="@color/colorPrimary"/> @@ -62,8 +62,8 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@+id/about_rate_us" - android:paddingBottom="@dimen/smtfp_activity_margin" - android:paddingTop="@dimen/smtfp_activity_margin" + android:paddingBottom="@dimen/activity_margin" + android:paddingTop="@dimen/activity_margin" android:text="@string/third_party_licences_underlined" android:textColor="@color/colorPrimary"/> @@ -73,7 +73,7 @@ android:layout_height="wrap_content" android:layout_below="@+id/about_license" android:paddingBottom="@dimen/social_padding" - android:paddingTop="@dimen/smtfp_activity_margin" + android:paddingTop="@dimen/activity_margin" android:text="@string/follow_us"/> diff --git a/app/src/main/res/layout/activity_license.xml b/app/src/main/res/layout/activity_license.xml index b7355142..3dfaabdb 100644 --- a/app/src/main/res/layout/activity_license.xml +++ b/app/src/main/res/layout/activity_license.xml @@ -10,7 +10,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" - android:padding="@dimen/smtfp_activity_margin"> + android:padding="@dimen/activity_margin"> diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index cfa54ad1..94cee8dc 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -9,7 +9,7 @@ android:id="@+id/breadcrumbs" android:layout_width="match_parent" android:layout_height="wrap_content" - android:padding="@dimen/smtfp_activity_margin"/> + android:padding="@dimen/activity_margin"/> + android:padding="@dimen/activity_margin"> + android:padding="@dimen/activity_margin"> + android:padding="@dimen/activity_margin"> + android:paddingLeft="@dimen/activity_margin" + android:paddingRight="@dimen/activity_margin" + android:paddingTop="@dimen/activity_margin"> + android:textSize="@dimen/details_text_size"/> + android:textSize="@dimen/details_text_size"/> + android:paddingLeft="@dimen/activity_margin" + android:paddingRight="@dimen/activity_margin" + android:paddingTop="@dimen/activity_margin"> @@ -27,7 +27,7 @@ android:id="@+id/dialog_radio_directory" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginBottom="@dimen/smtfp_medium_margin" + android:layout_marginBottom="@dimen/medium_margin" android:text="@string/directory"/> @@ -10,11 +10,10 @@ android:id="@+id/directory_picker_breadcrumbs" android:layout_width="match_parent" android:layout_height="wrap_content" - android:padding="@dimen/smtfp_activity_margin"/> + android:padding="@dimen/activity_margin"/> diff --git a/app/src/main/res/layout/item_properties.xml b/app/src/main/res/layout/item_properties.xml index d9997ece..5b0ec6c4 100644 --- a/app/src/main/res/layout/item_properties.xml +++ b/app/src/main/res/layout/item_properties.xml @@ -5,7 +5,5 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" - android:paddingLeft="@dimen/smtfp_activity_margin" - android:paddingRight="@dimen/smtfp_activity_margin"> - - + android:paddingLeft="@dimen/activity_margin" + android:paddingRight="@dimen/activity_margin"/> diff --git a/app/src/main/res/layout/items_fragment.xml b/app/src/main/res/layout/items_fragment.xml index ea504d2b..dce29add 100644 --- a/app/src/main/res/layout/items_fragment.xml +++ b/app/src/main/res/layout/items_fragment.xml @@ -16,7 +16,7 @@ android:layout_height="wrap_content" android:choiceMode="multipleChoiceModal" android:clipToPadding="false" - android:paddingLeft="@dimen/smtfp_activity_margin"/> + android:paddingLeft="@dimen/activity_margin"/> @@ -25,7 +25,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="bottom|end" - android:layout_margin="@dimen/smtfp_activity_margin" + android:layout_margin="@dimen/activity_margin" android:src="@mipmap/plus"/> diff --git a/app/src/main/res/layout/list_item.xml b/app/src/main/res/layout/list_item.xml index 14d3d464..b668a57a 100644 --- a/app/src/main/res/layout/list_item.xml +++ b/app/src/main/res/layout/list_item.xml @@ -3,21 +3,21 @@ xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" - android:foreground="@drawable/smtfp_selector"> + android:foreground="@drawable/selector"> + android:paddingRight="@dimen/activity_margin"> + android:paddingBottom="@dimen/medium_margin" + android:paddingTop="@dimen/medium_margin" + android:src="@mipmap/directory"/> + android:textSize="@dimen/details_text_size"/> diff --git a/app/src/main/res/layout/property_item.xml b/app/src/main/res/layout/property_item.xml index 12a60ed2..f2e22014 100644 --- a/app/src/main/res/layout/property_item.xml +++ b/app/src/main/res/layout/property_item.xml @@ -9,14 +9,14 @@ android:id="@+id/property_label" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginTop="@dimen/smtfp_activity_margin" - android:textSize="@dimen/smtfp_details_text_size"/> + android:layout_marginTop="@dimen/activity_margin" + android:textSize="@dimen/details_text_size"/> + android:paddingLeft="@dimen/small_margin" + android:paddingRight="@dimen/small_margin"/> diff --git a/app/src/main/res/layout/rename_item.xml b/app/src/main/res/layout/rename_item.xml index 05eb387b..cdd4bdd6 100644 --- a/app/src/main/res/layout/rename_item.xml +++ b/app/src/main/res/layout/rename_item.xml @@ -5,13 +5,13 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" - android:padding="@dimen/smtfp_activity_margin"> + android:padding="@dimen/activity_margin"> diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 4e747d99..682ebbb8 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -5,7 +5,7 @@ @color/colorPrimaryDark @color/colorAccent @style/AppTheme.ActionBarStyle - @dimen/smtfp_normal_text_size + @dimen/normal_text_size diff --git a/library/build.gradle b/library/build.gradle deleted file mode 100644 index b345d276..00000000 --- a/library/build.gradle +++ /dev/null @@ -1,49 +0,0 @@ -apply plugin: 'com.android.library' -apply plugin: 'kotlin-android' -apply plugin: 'kotlin-android-extensions' - -android { - compileSdkVersion 23 - buildToolsVersion "23.0.3" - - defaultConfig { - minSdkVersion 16 - targetSdkVersion 23 - versionCode 1 - versionName "1.0" - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - - sourceSets { - main.java.srcDirs += 'src/main/kotlin' - } - - publishNonDefault true -} - -dependencies { - compile 'com.android.support:appcompat-v7:23.4.0' - compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" -} - -repositories { - mavenCentral() -} - -buildscript { - ext.kotlin_version = '1.0.3' - repositories { - mavenCentral() - } - - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version" - } -} diff --git a/library/proguard-rules.pro b/library/proguard-rules.pro deleted file mode 100644 index 25ea3346..00000000 --- a/library/proguard-rules.pro +++ /dev/null @@ -1,17 +0,0 @@ -# Add project specific ProGuard rules here. -# By default, the flags in this file are appended to flags specified -# in $ANDROID_HOME/tools/proguard/proguard-android.txt -# You can edit the include path and order by changing the proguardFiles -# directive in build.gradle. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# Add any project specific keep options here: - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} diff --git a/library/src/main/AndroidManifest.xml b/library/src/main/AndroidManifest.xml deleted file mode 100644 index c4731658..00000000 --- a/library/src/main/AndroidManifest.xml +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/library/src/main/kotlin/com/simplemobiletools/filepicker/adapters/ItemsAdapter.kt b/library/src/main/kotlin/com/simplemobiletools/filepicker/adapters/ItemsAdapter.kt deleted file mode 100644 index 301076fc..00000000 --- a/library/src/main/kotlin/com/simplemobiletools/filepicker/adapters/ItemsAdapter.kt +++ /dev/null @@ -1,79 +0,0 @@ -package com.simplemobiletools.filepicker.adapters - -import android.content.Context -import android.content.res.Resources -import android.graphics.Bitmap -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup -import android.widget.BaseAdapter -import android.widget.ImageView -import android.widget.TextView -import com.simplemobiletools.filepicker.R -import com.simplemobiletools.filepicker.extensions.formatSize -import com.simplemobiletools.filepicker.extensions.getColoredIcon -import com.simplemobiletools.filepicker.models.FileDirItem -import kotlinx.android.synthetic.main.smtfp_list_item.view.* - -class ItemsAdapter(context: Context, private val mItems: List) : BaseAdapter() { - private val mInflater: LayoutInflater - private val mFileBmp: Bitmap - private val mDirectoryBmp: Bitmap - private val mRes: Resources - - init { - mInflater = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater - - mRes = context.resources - mDirectoryBmp = mRes.getColoredIcon(R.color.smtfp_thumbnail_grey, R.mipmap.smtfp_directory) - mFileBmp = mRes.getColoredIcon(R.color.smtfp_thumbnail_grey, R.mipmap.smtfp_file) - } - - override fun getView(position: Int, convertView: View?, parent: ViewGroup): View { - var view = convertView - val viewHolder: ViewHolder - if (view == null) { - view = mInflater.inflate(R.layout.smtfp_list_item, parent, false) - viewHolder = ViewHolder(view) - view!!.tag = viewHolder - } else { - viewHolder = view.tag as ViewHolder - } - - val item = mItems[position] - viewHolder.name.text = item.name - - if (item.isDirectory) { - viewHolder.icon.setImageBitmap(mDirectoryBmp) - viewHolder.details.text = getChildrenCnt(item) - } else { - viewHolder.icon.setImageBitmap(mFileBmp) - viewHolder.details.text = item.size.formatSize() - } - - return view - } - - private fun getChildrenCnt(item: FileDirItem): String { - val children = item.children - return mRes.getQuantityString(R.plurals.smtfp_items, children, children) - } - - override fun getCount(): Int { - return mItems.size - } - - override fun getItem(position: Int): Any { - return mItems[position] - } - - override fun getItemId(position: Int): Long { - return 0 - } - - internal class ViewHolder(view: View) { - val name: TextView = view.item_name - val icon: ImageView = view.item_icon - val details: TextView = view.item_details - } -} diff --git a/library/src/main/kotlin/com/simplemobiletools/filepicker/dialogs/PickFolderDialog.kt b/library/src/main/kotlin/com/simplemobiletools/filepicker/dialogs/PickFolderDialog.kt deleted file mode 100644 index c0ecda72..00000000 --- a/library/src/main/kotlin/com/simplemobiletools/filepicker/dialogs/PickFolderDialog.kt +++ /dev/null @@ -1,133 +0,0 @@ -package com.simplemobiletools.filepicker.dialogs - -import android.app.Activity -import android.app.Dialog -import android.content.Intent -import android.net.Uri -import android.os.Bundle -import android.support.v4.app.DialogFragment -import android.support.v7.app.AlertDialog -import android.view.View -import com.simplemobiletools.filepicker.R -import com.simplemobiletools.filepicker.adapters.ItemsAdapter -import com.simplemobiletools.filepicker.extensions.getFilenameFromPath -import com.simplemobiletools.filepicker.models.FileDirItem -import com.simplemobiletools.filepicker.views.Breadcrumbs -import kotlinx.android.synthetic.main.smtfp_directory_picker.view.* -import java.io.File -import java.util.* -import kotlin.comparisons.compareBy - -class PickFolderDialog : DialogFragment(), Breadcrumbs.BreadcrumbsListener { - - companion object { - lateinit var mPath: String - var mFirstUpdate: Boolean = true - var mShowHidden: Boolean = false - var mShowFullPath: Boolean = false - - fun newInstance(path: String, showHidden: Boolean, showFullPath: Boolean): PickFolderDialog { - mPath = path - mFirstUpdate = true - mShowHidden = showHidden - mShowFullPath = showFullPath - return PickFolderDialog() - } - } - - lateinit var dialog: View - var requestCode = 0 - - override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { - dialog = activity.layoutInflater.inflate(R.layout.smtfp_directory_picker, null) - requestCode = targetRequestCode - - updateItems() - setupBreadcrumbs() - - return AlertDialog.Builder(activity) - .setTitle(resources.getString(R.string.smtfp_select_destination)) - .setView(dialog) - .setPositiveButton(R.string.smtfp_ok) { dialog, which -> sendResult() } - .setNegativeButton(R.string.smtfp_cancel, null) - .create() - } - - private fun updateItems() { - var items = getItems(mPath) - if (!containsDirectory(items) && !mFirstUpdate) { - sendResult() - return - } - - items = items.sortedWith(compareBy({ !it.isDirectory }, { it.name.toLowerCase() })) - - val adapter = ItemsAdapter(context, items) - dialog.directory_picker_list.adapter = adapter - dialog.directory_picker_breadcrumbs.setBreadcrumb(mPath, mShowFullPath) - dialog.directory_picker_list.setOnItemClickListener { adapterView, view, position, id -> - val item = items[position] - if (item.isDirectory) { - mPath = item.path - updateItems() - } - } - - mFirstUpdate = false - } - - private fun sendResult() { - val intent = Intent() - intent.data = Uri.parse(mPath) - targetFragment.onActivityResult(requestCode, Activity.RESULT_OK, intent) - dismiss() - } - - private fun setupBreadcrumbs() { - dialog.directory_picker_breadcrumbs.setListener(this) - } - - private fun getItems(path: String): List { - val items = ArrayList() - val base = File(path) - val files = base.listFiles() - if (files != null) { - for (file in files) { - if (!file.isDirectory) - continue - - if (!mShowHidden && file.isHidden) - continue - - val curPath = file.absolutePath - val curName = curPath.getFilenameFromPath() - val size = file.length() - - items.add(FileDirItem(curPath, curName, file.isDirectory, getChildren(file), size)) - } - } - return items - } - - private fun getChildren(file: File): Int { - if (file.listFiles() == null || !file.isDirectory) - return 0 - - return file.listFiles().size - } - - private fun containsDirectory(items: List): Boolean { - for (item in items) { - if (item.isDirectory) { - return true - } - } - return false - } - - override fun breadcrumbClicked(id: Int) { - val item = dialog.directory_picker_breadcrumbs.getChildAt(id).tag as FileDirItem - mPath = item.path - updateItems() - } -} diff --git a/library/src/main/kotlin/com/simplemobiletools/filepicker/extensions/long.kt b/library/src/main/kotlin/com/simplemobiletools/filepicker/extensions/long.kt deleted file mode 100644 index 1d80ff51..00000000 --- a/library/src/main/kotlin/com/simplemobiletools/filepicker/extensions/long.kt +++ /dev/null @@ -1,12 +0,0 @@ -package com.simplemobiletools.filepicker.extensions - -import java.text.DecimalFormat - -fun Long.formatSize(): String { - if (this <= 0) - return "0 B" - - val units = arrayOf("B", "kB", "MB", "GB", "TB") - val digitGroups = (Math.log10(toDouble()) / Math.log10(1024.0)).toInt() - return DecimalFormat("#,##0.#").format(this / Math.pow(1024.0, digitGroups.toDouble())) + " " + units[digitGroups] -} diff --git a/library/src/main/kotlin/com/simplemobiletools/filepicker/extensions/resources.kt b/library/src/main/kotlin/com/simplemobiletools/filepicker/extensions/resources.kt deleted file mode 100644 index 77245de9..00000000 --- a/library/src/main/kotlin/com/simplemobiletools/filepicker/extensions/resources.kt +++ /dev/null @@ -1,16 +0,0 @@ -package com.simplemobiletools.filepicker.extensions - -import android.content.res.Resources -import android.graphics.* - -fun Resources.getColoredIcon(colorId: Int, resId: Int): Bitmap { - val options = BitmapFactory.Options() - options.inMutable = true - val bitmap = BitmapFactory.decodeResource(this, resId, options) - val paint = Paint() - val filter = PorterDuffColorFilter(this.getColor(colorId), PorterDuff.Mode.SRC_IN) - paint.colorFilter = filter - val canvas = Canvas(bitmap) - canvas.drawBitmap(bitmap, 0f, 0f, paint) - return bitmap -} diff --git a/library/src/main/kotlin/com/simplemobiletools/filepicker/extensions/string.kt b/library/src/main/kotlin/com/simplemobiletools/filepicker/extensions/string.kt deleted file mode 100644 index bc2b004f..00000000 --- a/library/src/main/kotlin/com/simplemobiletools/filepicker/extensions/string.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.simplemobiletools.filepicker.extensions - -fun String.getFilenameFromPath(): String { - return substring(lastIndexOf("/") + 1) -} diff --git a/library/src/main/kotlin/com/simplemobiletools/filepicker/models/FileDirItem.kt b/library/src/main/kotlin/com/simplemobiletools/filepicker/models/FileDirItem.kt deleted file mode 100644 index 5d495c18..00000000 --- a/library/src/main/kotlin/com/simplemobiletools/filepicker/models/FileDirItem.kt +++ /dev/null @@ -1,43 +0,0 @@ -package com.simplemobiletools.filepicker.models - -import android.graphics.BitmapFactory -import android.media.MediaMetadataRetriever - -class FileDirItem(val path: String, val name: String, val isDirectory: Boolean, val children: Int, val size: Long) : - Comparable { - - override fun compareTo(other: FileDirItem): Int { - if (isDirectory && !other.isDirectory) { - return -1 - } else if (!isDirectory && other.isDirectory) { - return 1 - } - - return name.toLowerCase().compareTo(other.name.toLowerCase()) - } - - override fun toString(): String { - return "FileDirItem{name=$name, isDirectory=$isDirectory, path=$path, children=$children, size=$size}" - } - - fun isGif() = name.toLowerCase().endsWith(".gif") - fun isVideo() = getMimeType().startsWith("video") - - fun isImage(): Boolean { - val options = BitmapFactory.Options() - options.inJustDecodeBounds = true - BitmapFactory.decodeFile(path, options) - return options.outWidth != -1 && options.outHeight != -1 - } - - fun getMimeType(): String { - try { - val retriever = MediaMetadataRetriever() - retriever.setDataSource(path) - return retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_MIMETYPE) - } catch (ignored: Exception) { - - } - return "" - } -} diff --git a/library/src/main/kotlin/com/simplemobiletools/filepicker/views/Breadcrumbs.kt b/library/src/main/kotlin/com/simplemobiletools/filepicker/views/Breadcrumbs.kt deleted file mode 100644 index e4db01e1..00000000 --- a/library/src/main/kotlin/com/simplemobiletools/filepicker/views/Breadcrumbs.kt +++ /dev/null @@ -1,162 +0,0 @@ -package com.simplemobiletools.filepicker.views - -import android.content.Context -import android.graphics.Point -import android.os.Environment -import android.util.AttributeSet -import android.view.LayoutInflater -import android.view.View -import android.view.WindowManager -import android.widget.LinearLayout -import com.simplemobiletools.filepicker.R -import com.simplemobiletools.filepicker.models.FileDirItem -import kotlinx.android.synthetic.main.smtfp_breadcrumb_item.view.* - -class Breadcrumbs(context: Context, attrs: AttributeSet) : LinearLayout(context, attrs), View.OnClickListener { - private var mDeviceWidth: Int = 0 - - private var mInflater: LayoutInflater? = null - private var mListener: BreadcrumbsListener? = null - - init { - init(context) - } - - private fun init(context: Context) { - mInflater = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater - val display = (context.getSystemService(Context.WINDOW_SERVICE) as WindowManager).defaultDisplay - val deviceDisplay = Point() - display.getSize(deviceDisplay) - mDeviceWidth = deviceDisplay.x - } - - fun setListener(listener: BreadcrumbsListener) { - mListener = listener - } - - override fun onLayout(changed: Boolean, l: Int, t: Int, r: Int, b: Int) { - val childRight = measuredWidth - paddingRight - val childBottom = measuredHeight - paddingBottom - val childHeight = childBottom - paddingTop - - val usableWidth = mDeviceWidth - paddingLeft - paddingRight - var maxHeight = 0 - var curWidth: Int - var curHeight: Int - var curLeft = paddingLeft - var curTop = paddingTop - - val cnt = childCount - for (i in 0..cnt - 1) { - val child = getChildAt(i) - - child.measure(MeasureSpec.makeMeasureSpec(usableWidth, MeasureSpec.AT_MOST), - MeasureSpec.makeMeasureSpec(childHeight, MeasureSpec.AT_MOST)) - curWidth = child.measuredWidth - curHeight = child.measuredHeight - - if (curLeft + curWidth >= childRight) { - curLeft = paddingLeft - curTop += maxHeight - maxHeight = 0 - } - - child.layout(curLeft, curTop, curLeft + curWidth, curTop + curHeight) - if (maxHeight < curHeight) - maxHeight = curHeight - - curLeft += curWidth - } - } - - override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) { - val usableWidth = mDeviceWidth - paddingLeft - paddingRight - var width = 0 - var rowHeight = 0 - var lines = 1 - - val cnt = childCount - for (i in 0..cnt - 1) { - val child = getChildAt(i) - measureChild(child, widthMeasureSpec, heightMeasureSpec) - width += child.measuredWidth - rowHeight = child.measuredHeight - - if (width / usableWidth > 0) { - lines++ - width = child.measuredWidth - } - } - - val parentWidth = MeasureSpec.getSize(widthMeasureSpec) - val calculatedHeight = paddingTop + paddingBottom + rowHeight * lines - setMeasuredDimension(parentWidth, calculatedHeight) - } - - fun setBreadcrumb(fullPath: String, showFullPath: Boolean) { - val basePath = Environment.getExternalStorageDirectory().toString() - var tempPath = fullPath - var currPath = basePath - if (!showFullPath) { - tempPath = fullPath.replace(basePath, context.getString(R.string.smtfp_initial_breadcrumb) + "/") - } else { - currPath = "/" - } - - removeAllViewsInLayout() - val dirs = tempPath.split("/".toRegex()).dropLastWhile(String::isEmpty).toTypedArray() - for (i in dirs.indices) { - val dir = dirs[i] - if (i > 0) { - currPath += dir + "/" - } else if (showFullPath) { - addRootFolder() - } - - if (dir.isEmpty()) - continue - - val item = FileDirItem(currPath, dir, true, 0, 0) - addBreadcrumb(item, i > 0 || showFullPath) - } - - if (dirs.size == 0 && showFullPath) { - addRootFolder() - } - } - - private fun addBreadcrumb(item: FileDirItem, addPrefix: Boolean) { - val view = mInflater!!.inflate(R.layout.smtfp_breadcrumb_item, null, false) - var textToAdd = item.name - if (addPrefix) - textToAdd = " -> " + textToAdd - - view.breadcrumb_text.text = textToAdd - addView(view) - view.setOnClickListener(this) - - view.tag = item - } - - fun removeBreadcrumb() { - removeView(getChildAt(childCount - 1)) - } - - private fun addRootFolder() { - val item = FileDirItem("/", " / ", true, 0, 0) - addBreadcrumb(item, false) - } - - override fun onClick(v: View) { - val cnt = childCount - for (i in 0..cnt - 1) { - if (getChildAt(i) != null && getChildAt(i) == v) { - mListener?.breadcrumbClicked(i) - } - } - } - - interface BreadcrumbsListener { - fun breadcrumbClicked(id: Int) - } -} diff --git a/library/src/main/res/drawable-v21/smtfp_selector.xml b/library/src/main/res/drawable-v21/smtfp_selector.xml deleted file mode 100644 index a454cfaf..00000000 --- a/library/src/main/res/drawable-v21/smtfp_selector.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/library/src/main/res/drawable/smtfp_selector.xml b/library/src/main/res/drawable/smtfp_selector.xml deleted file mode 100644 index 24f9c0ac..00000000 --- a/library/src/main/res/drawable/smtfp_selector.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/library/src/main/res/layout/smtfp_breadcrumb_item.xml b/library/src/main/res/layout/smtfp_breadcrumb_item.xml deleted file mode 100644 index 4f89712f..00000000 --- a/library/src/main/res/layout/smtfp_breadcrumb_item.xml +++ /dev/null @@ -1,6 +0,0 @@ - - diff --git a/library/src/main/res/layout/smtfp_directory_picker.xml b/library/src/main/res/layout/smtfp_directory_picker.xml deleted file mode 100644 index ebe2ca5a..00000000 --- a/library/src/main/res/layout/smtfp_directory_picker.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - diff --git a/library/src/main/res/layout/smtfp_list_item.xml b/library/src/main/res/layout/smtfp_list_item.xml deleted file mode 100644 index d4f5b8b2..00000000 --- a/library/src/main/res/layout/smtfp_list_item.xml +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - - - - - - - diff --git a/library/src/main/res/mipmap-hdpi/smtfp_directory.png b/library/src/main/res/mipmap-hdpi/smtfp_directory.png deleted file mode 100644 index 02ea533a8d662e512843bf218e372653e95d843b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 135 zcmeAS@N?(olHy`uVBq!ia0vp^Dj>|k0wldT1B8K;pQnpsh{y4_S5I>?DDbdcG|@|k0wldT1B8K8f~SjPh{y4_XAbf<81OJ3(CJ7} zndX``b76v-N7DYNg?AXzx0$@j_%O$-MDb9#M4)m=#h>FoD;{~Q*wnG^Q^%Sa9jkV9 zthk}E_JdQ<#r;ZwuA-qP*1MK2|9P?TocWEMO!)@USli?GV)cP`F?hQAxvXL2`{{(qt) zvm)<`Q=Hj9{dp?B-k)#6`~UxbmC(cg19_d}4r?#Evfm-&!|_RRhEx83m({x|$*?rj VKUyK^_-~+L44$rjF6*2Ung9auEG+;4 diff --git a/library/src/main/res/mipmap-mdpi/smtfp_file.png b/library/src/main/res/mipmap-mdpi/smtfp_file.png deleted file mode 100644 index b51ce3ed95a437af48d672cb4b8494807587c080..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 133 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM0wlfaz7_*1A5Ry@5R21q&u~5;q+UmdnXs1e(j>>FVdQ&MBb@07N}3VE_OC diff --git a/library/src/main/res/mipmap-xhdpi/smtfp_directory.png b/library/src/main/res/mipmap-xhdpi/smtfp_directory.png deleted file mode 100644 index 71a5a137c463dfd97dfad592c86b7eac773664c5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 181 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA0wn)(8}b0D8c!F;kch)?uX*!1I0(1~u3k7j z(@|)CtD?lCSzab=p|%h2vhJCDWr_9aDM8CMGG^>pz2)3<9-DOK6&2^5E;t7@iOv_Z za^ku1A-hLl9mAHDjh3bd#2aH97>pYj7@1i1Fnhmp-(Sr7N?SnU?z8GoH}30QFuL9E fEIT*+)p6OLF7v?Cmm9c&?qKkA^>bP0l+XkK)+RzI diff --git a/library/src/main/res/mipmap-xhdpi/smtfp_file.png b/library/src/main/res/mipmap-xhdpi/smtfp_file.png deleted file mode 100644 index 798ebd4e25f68b658c82e773eea97bd2ad412f17..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 206 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA0wn)(8}b0Dsh%#5ArXh)UUTGX4&Z5dST1#X z_fmE(jjwTCSC_smS-D$9cp}$l`2@QYT1!{h^YDMEIJ_$LxwOxRqkmdKI;Vst E0NwCNssI20 diff --git a/library/src/main/res/mipmap-xxhdpi/smtfp_directory.png b/library/src/main/res/mipmap-xxhdpi/smtfp_directory.png deleted file mode 100644 index b93d5a1e4a48fb9cddfa530aacfc84e5ea4ad9c9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 245 zcmeAS@N?(olHy`uVBq!ia0vp^9w5xY0wn)GsXhaw_ISEDhGg7(d&7~dDL|z4q4_1- z7ebF0dKZ*BYIUwt;W*;>)jV%O+J|}OmjAiz^vX--1bb;NmdKI;Vst0GcUV@&Et; diff --git a/library/src/main/res/mipmap-xxhdpi/smtfp_file.png b/library/src/main/res/mipmap-xxhdpi/smtfp_file.png deleted file mode 100644 index f3e153b45eb7886c314afd8642bc9018c1f2b5bd..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 283 zcmeAS@N?(olHy`uVBq!ia0vp^9w5xY0wn)GsXhaw9(lSrhGg7(d+8wOAqSC`hqkR( z1O(pr7kRR-^fM4B-pJrB!18rLU;5WcwbqN9K8JrW^zk~kQ@@Q%*UUm`d)(nn1I4KI z5$WBNZm6sYkec37%CT|!!~%}SX+}cp1pU2?gz^k0^oX!`dZ;RJuH;csnA-GWNs++J zBMgC_G6EBiFkSSp5$HU^66g_g!CF(k6j7})P zi3R_eVwcPdw#%5()K(Lq&bsyI0x4_Bbf>AG4m-Kby09c-#l^%UGs{zXGMryqJkPLY Y&+P+xzK0zI93I~B z(C26sy3FL&q}$ba<$&VE(+|=Gi?KQ4VXb{{b%I@HcvNQkRwH8&_$~OogvaO4 zw%oRd*KGoKY|H)oF+L(JmZ@K7yH~M)rTJtXSd}W-{epFln3^$y#Qw2YO4`4lFD^P$~Ceo|M5hK8FSd#^MHkMkW@H6#Nv%Xop z`uOoFkL`+MxXFXli2*NgVS zce*$hNuLo@ada)wwkl-hV=5FsC)E4*jDt)D|B?8wr!IWgTTscqYIn4V0dUAW1Y}9z7KOhqi^sPPIw7!dLw*NrLf;=eP`^JY9k?(#X=nCd zcgzlKvHty0=g_lyrE}%$KcD@NJa^2A$V!HX=v7zCg9d&s2ko((e7)78&qol`;+ E02^zJCIA2c diff --git a/library/src/main/res/values-de/strings.xml b/library/src/main/res/values-de/strings.xml deleted file mode 100644 index dfe6198c..00000000 --- a/library/src/main/res/values-de/strings.xml +++ /dev/null @@ -1,11 +0,0 @@ - - Ziel auswählen - home - OK - Abbrechen - - - 1 Datei/Ordner - %1$d Dateien/Ordner - - diff --git a/library/src/main/res/values-it/strings.xml b/library/src/main/res/values-it/strings.xml deleted file mode 100644 index c41e3bbd..00000000 --- a/library/src/main/res/values-it/strings.xml +++ /dev/null @@ -1,11 +0,0 @@ - - Seleziona destinazione - home - OK - Annulla - - - 1 elemento - %1$d elementi - - diff --git a/library/src/main/res/values-ja/strings.xml b/library/src/main/res/values-ja/strings.xml deleted file mode 100644 index 17258e48..00000000 --- a/library/src/main/res/values-ja/strings.xml +++ /dev/null @@ -1,11 +0,0 @@ - - 宛先を選択 - ホーム - OK - Cancel - - - 1 アイテム - %1$d アイテム - - diff --git a/library/src/main/res/values-pt-rPT/strings.xml b/library/src/main/res/values-pt-rPT/strings.xml deleted file mode 100644 index 68ad0e49..00000000 --- a/library/src/main/res/values-pt-rPT/strings.xml +++ /dev/null @@ -1,11 +0,0 @@ - - Selecionar destino - início - OK - Cancelar - - - 1 item - %1$d itens - - diff --git a/library/src/main/res/values-sv/strings.xml b/library/src/main/res/values-sv/strings.xml deleted file mode 100644 index 566a2267..00000000 --- a/library/src/main/res/values-sv/strings.xml +++ /dev/null @@ -1,11 +0,0 @@ - - Välj mål - home - OK - Cancel - - - 1 objekt - %1$d objekt - - diff --git a/library/src/main/res/values/colors.xml b/library/src/main/res/values/colors.xml deleted file mode 100644 index b2c92efe..00000000 --- a/library/src/main/res/values/colors.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - #33000000 - #08000000 - #44888888 - diff --git a/library/src/main/res/values/dimens.xml b/library/src/main/res/values/dimens.xml deleted file mode 100644 index 4e300dcd..00000000 --- a/library/src/main/res/values/dimens.xml +++ /dev/null @@ -1,9 +0,0 @@ - - 16dp - 6dp - 10dp - 48dp - - 12sp - 14sp - diff --git a/library/src/main/res/values/strings.xml b/library/src/main/res/values/strings.xml deleted file mode 100644 index 21d7a3b4..00000000 --- a/library/src/main/res/values/strings.xml +++ /dev/null @@ -1,11 +0,0 @@ - - Select destination - home - OK - Cancel - - - 1 item - %1$d items - - diff --git a/settings.gradle b/settings.gradle index 33069973..e7b4def4 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1 +1 @@ -include ':app', ':library' +include ':app'