From 0d9d0b8b1ca55670f2f86d584cef39cc74603f05 Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 11 Oct 2016 20:09:31 +0200 Subject: [PATCH] move the library files in a separate folder + misc changes - dont do such commits at home --- .gitignore | 1 + app/build.gradle | 5 ++++- .../simplemobiletools/filemanager/Utils.java | 7 ------- .../filemanager/activities/AboutActivity.java | 6 +++--- .../filemanager/activities/MainActivity.java | 4 ++-- .../filemanager/dialogs/PropertiesDialog.java | 13 ++++++------ .../filemanager/fragments/ItemsFragment.java | 16 +++++++-------- .../filemanager/adapters/ItemsAdapter.kt | 8 ++++---- .../filemanager/dialogs/SelectFolderDialog.kt | 8 ++++---- .../filemanager/extensions/long.kt | 12 +++++++++++ .../filemanager/models/FileDirItem.kt | 19 ------------------ app/src/main/res/layout/activity_main.xml | 2 +- app/src/main/res/layout/copy_item.xml | 2 +- app/src/main/res/layout/directory_picker.xml | 2 +- {simplefilepicker => library}/build.gradle | 10 +++++---- .../proguard-rules.pro | 0 library/src/main/AndroidManifest.xml | 2 ++ .../filepicker}/Breadcrumbs.kt | 14 ++++++------- .../filepicker/adapters/ItemsAdapter.kt | 2 +- .../filepicker/dialogs/SelectFolderDialog.kt | 6 +++--- .../filepicker/extensions/long.kt | 0 .../filepicker/extensions/resources.kt | 2 +- .../filepicker/extensions/string.kt | 0 .../filepicker/models/FileDirItem.kt | 0 .../filepicker/views/Breadcrumbs.kt | 2 +- .../src/main/res/drawable-v21/selector.xml | 0 .../src/main/res/drawable/selector.xml | 0 .../src/main/res/layout/breadcrumb_item.xml | 0 .../src/main/res/layout/directory_picker.xml | 2 +- .../src/main/res/layout/list_item.xml | 0 .../src/main/res/mipmap-hdpi/directory.png | Bin .../src/main/res/mipmap-hdpi/file.png | Bin .../src/main/res/mipmap-mdpi/directory.png | Bin .../src/main/res/mipmap-mdpi/file.png | Bin .../src/main/res/mipmap-xhdpi/directory.png | Bin .../src/main/res/mipmap-xhdpi/file.png | Bin .../src/main/res/mipmap-xxhdpi/directory.png | Bin .../src/main/res/mipmap-xxhdpi/file.png | Bin .../src/main/res/mipmap-xxxhdpi/directory.png | Bin .../src/main/res/mipmap-xxxhdpi/file.png | Bin library/src/main/res/values-de/strings.xml | 12 +++++++++++ library/src/main/res/values-it/strings.xml | 12 +++++++++++ library/src/main/res/values-ja/strings.xml | 12 +++++++++++ .../src/main/res/values-pt-rPT/strings.xml | 12 +++++++++++ library/src/main/res/values-sv/strings.xml | 12 +++++++++++ .../src/main/res/values/colors.xml | 0 .../src/main/res/values/dimens.xml | 0 library/src/main/res/values/strings.xml | 12 +++++++++++ settings.gradle | 2 +- simplefilepicker/.gitignore | 1 - simplefilepicker/src/main/AndroidManifest.xml | 9 --------- .../src/main/res/values-de/strings.xml | 12 ----------- .../src/main/res/values-it/strings.xml | 12 ----------- .../src/main/res/values-ja/strings.xml | 12 ----------- .../src/main/res/values-pt-rPT/strings.xml | 12 ----------- .../src/main/res/values-sv/strings.xml | 12 ----------- .../src/main/res/values/strings.xml | 12 ----------- 57 files changed, 143 insertions(+), 158 deletions(-) create mode 100644 app/src/main/kotlin/com/simplemobiletools/filemanager/extensions/long.kt delete mode 100644 app/src/main/kotlin/com/simplemobiletools/filemanager/models/FileDirItem.kt rename {simplefilepicker => library}/build.gradle (84%) rename {simplefilepicker => library}/proguard-rules.pro (100%) create mode 100644 library/src/main/AndroidManifest.xml rename {app/src/main/kotlin/com/simplemobiletools/filemanager => library/src/main/kotlin/com/simplemobiletools/filepicker}/Breadcrumbs.kt (90%) rename {simplefilepicker => library}/src/main/kotlin/com/simplemobiletools/filepicker/adapters/ItemsAdapter.kt (96%) rename {simplefilepicker => library}/src/main/kotlin/com/simplemobiletools/filepicker/dialogs/SelectFolderDialog.kt (94%) rename {simplefilepicker => library}/src/main/kotlin/com/simplemobiletools/filepicker/extensions/long.kt (100%) rename {simplefilepicker => library}/src/main/kotlin/com/simplemobiletools/filepicker/extensions/resources.kt (84%) rename {simplefilepicker => library}/src/main/kotlin/com/simplemobiletools/filepicker/extensions/string.kt (100%) rename {simplefilepicker => library}/src/main/kotlin/com/simplemobiletools/filepicker/models/FileDirItem.kt (100%) rename {simplefilepicker => library}/src/main/kotlin/com/simplemobiletools/filepicker/views/Breadcrumbs.kt (99%) rename {simplefilepicker => library}/src/main/res/drawable-v21/selector.xml (100%) rename {simplefilepicker => library}/src/main/res/drawable/selector.xml (100%) rename {simplefilepicker => library}/src/main/res/layout/breadcrumb_item.xml (100%) rename {simplefilepicker => library}/src/main/res/layout/directory_picker.xml (93%) rename {simplefilepicker => library}/src/main/res/layout/list_item.xml (100%) rename {simplefilepicker => library}/src/main/res/mipmap-hdpi/directory.png (100%) rename {simplefilepicker => library}/src/main/res/mipmap-hdpi/file.png (100%) rename {simplefilepicker => library}/src/main/res/mipmap-mdpi/directory.png (100%) rename {simplefilepicker => library}/src/main/res/mipmap-mdpi/file.png (100%) rename {simplefilepicker => library}/src/main/res/mipmap-xhdpi/directory.png (100%) rename {simplefilepicker => library}/src/main/res/mipmap-xhdpi/file.png (100%) rename {simplefilepicker => library}/src/main/res/mipmap-xxhdpi/directory.png (100%) rename {simplefilepicker => library}/src/main/res/mipmap-xxhdpi/file.png (100%) rename {simplefilepicker => library}/src/main/res/mipmap-xxxhdpi/directory.png (100%) rename {simplefilepicker => library}/src/main/res/mipmap-xxxhdpi/file.png (100%) create mode 100644 library/src/main/res/values-de/strings.xml create mode 100644 library/src/main/res/values-it/strings.xml create mode 100644 library/src/main/res/values-ja/strings.xml create mode 100644 library/src/main/res/values-pt-rPT/strings.xml create mode 100644 library/src/main/res/values-sv/strings.xml rename {simplefilepicker => library}/src/main/res/values/colors.xml (100%) rename {simplefilepicker => library}/src/main/res/values/dimens.xml (100%) create mode 100644 library/src/main/res/values/strings.xml delete mode 100644 simplefilepicker/.gitignore delete mode 100644 simplefilepicker/src/main/AndroidManifest.xml delete mode 100644 simplefilepicker/src/main/res/values-de/strings.xml delete mode 100644 simplefilepicker/src/main/res/values-it/strings.xml delete mode 100644 simplefilepicker/src/main/res/values-ja/strings.xml delete mode 100644 simplefilepicker/src/main/res/values-pt-rPT/strings.xml delete mode 100644 simplefilepicker/src/main/res/values-sv/strings.xml delete mode 100644 simplefilepicker/src/main/res/values/strings.xml diff --git a/.gitignore b/.gitignore index 7051e766..dcb90474 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ /captures release.keystore signing.properties +/library/build diff --git a/app/build.gradle b/app/build.gradle index 0bc402e2..e8176c25 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -36,11 +36,14 @@ dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.4.0' - compile 'com.jakewharton:butterknife:8.0.1' compile 'com.android.support:design:23.4.0' + compile 'com.jakewharton:butterknife:8.0.1' 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/Utils.java b/app/src/main/java/com/simplemobiletools/filemanager/Utils.java index 72d33f98..37dcb40a 100644 --- a/app/src/main/java/com/simplemobiletools/filemanager/Utils.java +++ b/app/src/main/java/com/simplemobiletools/filemanager/Utils.java @@ -6,8 +6,6 @@ import android.content.pm.PackageManager; import android.support.v4.content.ContextCompat; import android.widget.Toast; -import com.simplemobiletools.filemanager.models.FileDirItem; - import java.text.DecimalFormat; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -35,11 +33,6 @@ public class Utils { return matcher.matches(); } - public static String getFormattedSize(FileDirItem item) { - final long size = item.getSize(); - return formatSize(size); - } - public static String formatSize(long size) { if (size <= 0) return "0 B"; diff --git a/app/src/main/java/com/simplemobiletools/filemanager/activities/AboutActivity.java b/app/src/main/java/com/simplemobiletools/filemanager/activities/AboutActivity.java index d882e12e..58922ad9 100644 --- a/app/src/main/java/com/simplemobiletools/filemanager/activities/AboutActivity.java +++ b/app/src/main/java/com/simplemobiletools/filemanager/activities/AboutActivity.java @@ -41,7 +41,7 @@ public class AboutActivity extends SimpleActivity { private void setupEmail() { final String email = mRes.getString(R.string.email); - final String appName = mRes.getString(R.string.app_name); + final String appName = mRes.getString(R.string.smtfp_app_name); final String href = "" + email + ""; mEmailTV.setText(Html.fromHtml(href)); mEmailTV.setMovementMethod(LinkMovementMethod.getInstance()); @@ -63,9 +63,9 @@ public class AboutActivity extends SimpleActivity { @OnClick(R.id.about_invite) public void inviteFriend() { final Intent intent = new Intent(); - final String text = String.format(getString(R.string.share_text), getString(R.string.app_name), getStoreUrl()); + final String text = String.format(getString(R.string.share_text), getString(R.string.smtfp_app_name), getStoreUrl()); intent.setAction(Intent.ACTION_SEND); - intent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.app_name)); + intent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.smtfp_app_name)); intent.putExtra(Intent.EXTRA_TEXT, text); intent.setType("text/plain"); startActivity(Intent.createChooser(intent, getString(R.string.invite_via))); diff --git a/app/src/main/java/com/simplemobiletools/filemanager/activities/MainActivity.java b/app/src/main/java/com/simplemobiletools/filemanager/activities/MainActivity.java index e5711cb8..3eded05d 100644 --- a/app/src/main/java/com/simplemobiletools/filemanager/activities/MainActivity.java +++ b/app/src/main/java/com/simplemobiletools/filemanager/activities/MainActivity.java @@ -9,13 +9,13 @@ import android.support.v4.app.ActivityCompat; import android.view.Menu; import android.view.MenuItem; -import com.simplemobiletools.filemanager.Breadcrumbs; import com.simplemobiletools.filemanager.Config; import com.simplemobiletools.filemanager.Constants; import com.simplemobiletools.filemanager.R; import com.simplemobiletools.filemanager.Utils; import com.simplemobiletools.filemanager.fragments.ItemsFragment; -import com.simplemobiletools.filemanager.models.FileDirItem; +import com.simplemobiletools.filepicker.models.FileDirItem; +import com.simplemobiletools.filepicker.Breadcrumbs; import butterknife.BindView; import butterknife.ButterKnife; diff --git a/app/src/main/java/com/simplemobiletools/filemanager/dialogs/PropertiesDialog.java b/app/src/main/java/com/simplemobiletools/filemanager/dialogs/PropertiesDialog.java index 87a22551..6093259c 100644 --- a/app/src/main/java/com/simplemobiletools/filemanager/dialogs/PropertiesDialog.java +++ b/app/src/main/java/com/simplemobiletools/filemanager/dialogs/PropertiesDialog.java @@ -11,7 +11,7 @@ import android.widget.TextView; import com.simplemobiletools.filemanager.Config; import com.simplemobiletools.filemanager.R; import com.simplemobiletools.filemanager.Utils; -import com.simplemobiletools.filemanager.models.FileDirItem; +import com.simplemobiletools.filepicker.models.FileDirItem; import java.io.File; import java.util.Calendar; @@ -50,17 +50,18 @@ public class PropertiesDialog extends DialogFragment { final AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); builder.setTitle(getResources().getString(title)); builder.setView(infoView); - builder.setPositiveButton(R.string.ok, null); + builder.setPositiveButton(R.string.smtfp_ok, null); return builder.create(); } private String getItemSize() { if (mItem.isDirectory()) { - return Utils.formatSize(directorySize(new File(mItem.getPath()))); + return Utils.formatSize(getDirectorySize(new File(mItem.getPath()))); } - return Utils.getFormattedSize(mItem); + return ""; + //return Utils.getFormattedSize(mItem); } private String formatLastModified(long ts) { @@ -69,13 +70,13 @@ public class PropertiesDialog extends DialogFragment { return DateFormat.format("dd/MM/yyyy HH:mm", cal).toString(); } - private long directorySize(File dir) { + private long getDirectorySize(File dir) { if (dir.exists()) { long size = 0; File[] files = dir.listFiles(); for (int i = 0; i < files.length; i++) { if (files[i].isDirectory()) { - size += directorySize(files[i]); + size += getDirectorySize(files[i]); } else { size += files[i].length(); if ((!files[i].isHidden() && !dir.isHidden()) || mShowHidden) 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 cdec91f9..af6e0f9a 100644 --- a/app/src/main/java/com/simplemobiletools/filemanager/fragments/ItemsFragment.java +++ b/app/src/main/java/com/simplemobiletools/filemanager/fragments/ItemsFragment.java @@ -39,7 +39,7 @@ import com.simplemobiletools.filemanager.adapters.ItemsAdapter; import com.simplemobiletools.filemanager.asynctasks.CopyTask; import com.simplemobiletools.filemanager.dialogs.PropertiesDialog; import com.simplemobiletools.filemanager.dialogs.SelectFolderDialog; -import com.simplemobiletools.filemanager.models.FileDirItem; +import com.simplemobiletools.filepicker.models.FileDirItem; import java.io.File; import java.io.FileFilter; @@ -215,8 +215,8 @@ public class ItemsFragment extends android.support.v4.app.Fragment final AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); builder.setTitle(getResources().getString(R.string.create_new)); builder.setView(newItemView); - builder.setPositiveButton(R.string.ok, null); - builder.setNegativeButton(R.string.cancel, null); + builder.setPositiveButton(R.string.smtfp_ok, null); + builder.setNegativeButton(R.string.smtfp_cancel, null); final AlertDialog alertDialog = builder.create(); alertDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); @@ -394,8 +394,8 @@ public class ItemsFragment extends android.support.v4.app.Fragment final AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); builder.setTitle(getResources().getString(title)); builder.setView(renameView); - builder.setPositiveButton(R.string.ok, null); - builder.setNegativeButton(R.string.cancel, null); + builder.setPositiveButton(R.string.smtfp_ok, null); + builder.setNegativeButton(R.string.smtfp_cancel, null); final AlertDialog alertDialog = builder.create(); alertDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); @@ -445,8 +445,8 @@ public class ItemsFragment extends android.support.v4.app.Fragment final AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); builder.setTitle(getResources().getString(copyString)); builder.setView(copyView); - builder.setPositiveButton(R.string.ok, null); - builder.setNegativeButton(R.string.cancel, null); + builder.setPositiveButton(R.string.smtfp_ok, null); + builder.setNegativeButton(R.string.smtfp_cancel, null); mCopyDialog = builder.create(); mCopyDialog.show(); @@ -454,7 +454,7 @@ public class ItemsFragment extends android.support.v4.app.Fragment @Override public void onClick(View v) { final String destinationPath = mDestinationView.getText().toString().trim(); - if (destinationPath.equals(getResources().getString(R.string.select_destination))) { + if (destinationPath.equals(getResources().getString(R.string.smtfp_select_destination))) { Utils.showToast(getContext(), R.string.please_select_destination); return; } diff --git a/app/src/main/kotlin/com/simplemobiletools/filemanager/adapters/ItemsAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/filemanager/adapters/ItemsAdapter.kt index 8fc8171e..f753ec03 100644 --- a/app/src/main/kotlin/com/simplemobiletools/filemanager/adapters/ItemsAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/filemanager/adapters/ItemsAdapter.kt @@ -10,9 +10,9 @@ import android.widget.BaseAdapter import android.widget.ImageView import android.widget.TextView import com.simplemobiletools.filemanager.R -import com.simplemobiletools.filemanager.Utils +import com.simplemobiletools.filemanager.extensions.formatSize import com.simplemobiletools.filemanager.extensions.getColoredIcon -import com.simplemobiletools.filemanager.models.FileDirItem +import com.simplemobiletools.filepicker.models.FileDirItem import kotlinx.android.synthetic.main.list_item.view.* class ItemsAdapter(context: Context, private val mItems: List) : BaseAdapter() { @@ -48,7 +48,7 @@ class ItemsAdapter(context: Context, private val mItems: List) : Ba viewHolder.details.text = getChildrenCnt(item) } else { viewHolder.icon.setImageBitmap(mFileBmp) - viewHolder.details.text = Utils.getFormattedSize(item) + viewHolder.details.text = item.size.formatSize() } return view @@ -56,7 +56,7 @@ class ItemsAdapter(context: Context, private val mItems: List) : Ba private fun getChildrenCnt(item: FileDirItem): String { val children = item.children - return mRes.getQuantityString(R.plurals.items, children, children) + return mRes.getQuantityString(R.plurals.smtfp_items, children, children) } override fun getCount(): Int { diff --git a/app/src/main/kotlin/com/simplemobiletools/filemanager/dialogs/SelectFolderDialog.kt b/app/src/main/kotlin/com/simplemobiletools/filemanager/dialogs/SelectFolderDialog.kt index 15303307..56ffe89f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/filemanager/dialogs/SelectFolderDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/filemanager/dialogs/SelectFolderDialog.kt @@ -12,7 +12,7 @@ import com.simplemobiletools.filemanager.R import com.simplemobiletools.filemanager.Utils import com.simplemobiletools.filemanager.adapters.ItemsAdapter import com.simplemobiletools.filemanager.fragments.ItemsFragment -import com.simplemobiletools.filemanager.models.FileDirItem +import com.simplemobiletools.filepicker.models.FileDirItem import kotlinx.android.synthetic.main.directory_picker.view.* import java.io.File import java.util.* @@ -39,10 +39,10 @@ class SelectFolderDialog : DialogFragment() { setupBreadcrumbs() return AlertDialog.Builder(activity) - .setTitle(resources.getString(R.string.select_destination)) + .setTitle(resources.getString(R.string.smtfp_select_destination)) .setView(dialog) - .setPositiveButton(R.string.ok) { dialog, which -> sendResult() } - .setNegativeButton(R.string.cancel, null) + .setPositiveButton(R.string.smtfp_ok) { dialog, which -> sendResult() } + .setNegativeButton(R.string.smtfp_cancel, null) .create() } diff --git a/app/src/main/kotlin/com/simplemobiletools/filemanager/extensions/long.kt b/app/src/main/kotlin/com/simplemobiletools/filemanager/extensions/long.kt new file mode 100644 index 00000000..3fcceb29 --- /dev/null +++ b/app/src/main/kotlin/com/simplemobiletools/filemanager/extensions/long.kt @@ -0,0 +1,12 @@ +package com.simplemobiletools.filemanager.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/app/src/main/kotlin/com/simplemobiletools/filemanager/models/FileDirItem.kt b/app/src/main/kotlin/com/simplemobiletools/filemanager/models/FileDirItem.kt deleted file mode 100644 index b61c4cea..00000000 --- a/app/src/main/kotlin/com/simplemobiletools/filemanager/models/FileDirItem.kt +++ /dev/null @@ -1,19 +0,0 @@ -package com.simplemobiletools.filemanager.models - -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}" - } -} diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 343e16af..276588ed 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -5,7 +5,7 @@ android:layout_width="match_parent" android:layout_height="match_parent"> - + android:text="@string/smtfp_select_destination"/> - + diff --git a/app/src/main/kotlin/com/simplemobiletools/filemanager/Breadcrumbs.kt b/library/src/main/kotlin/com/simplemobiletools/filepicker/Breadcrumbs.kt similarity index 90% rename from app/src/main/kotlin/com/simplemobiletools/filemanager/Breadcrumbs.kt rename to library/src/main/kotlin/com/simplemobiletools/filepicker/Breadcrumbs.kt index 086ed51e..d4d9f7af 100644 --- a/app/src/main/kotlin/com/simplemobiletools/filemanager/Breadcrumbs.kt +++ b/library/src/main/kotlin/com/simplemobiletools/filepicker/Breadcrumbs.kt @@ -1,4 +1,4 @@ -package com.simplemobiletools.filemanager +package com.simplemobiletools.filepicker import android.content.Context import android.graphics.Point @@ -9,7 +9,7 @@ import android.view.View import android.view.WindowManager import android.widget.LinearLayout import android.widget.TextView -import com.simplemobiletools.filemanager.models.FileDirItem +import com.simplemobiletools.filepicker.models.FileDirItem class Breadcrumbs(context: Context, attrs: AttributeSet) : LinearLayout(context, attrs), View.OnClickListener { private var mDeviceWidth: Int = 0 @@ -52,8 +52,8 @@ class Breadcrumbs(context: Context, attrs: AttributeSet) : LinearLayout(context, for (i in 0..cnt - 1) { val child = getChildAt(i) - child.measure(View.MeasureSpec.makeMeasureSpec(usableWidth, View.MeasureSpec.AT_MOST), - View.MeasureSpec.makeMeasureSpec(childHeight, View.MeasureSpec.AT_MOST)) + child.measure(MeasureSpec.makeMeasureSpec(usableWidth, MeasureSpec.AT_MOST), + MeasureSpec.makeMeasureSpec(childHeight, MeasureSpec.AT_MOST)) curWidth = child.measuredWidth curHeight = child.measuredHeight @@ -90,18 +90,18 @@ class Breadcrumbs(context: Context, attrs: AttributeSet) : LinearLayout(context, } } - val parentWidth = View.MeasureSpec.getSize(widthMeasureSpec) + val parentWidth = MeasureSpec.getSize(widthMeasureSpec) val calculatedHeight = paddingTop + paddingBottom + rowHeight * lines setMeasuredDimension(parentWidth, calculatedHeight) } fun setInitialBreadcrumb(fullPath: String) { - val showFullPath = Config.newInstance(context).showFullPath + val showFullPath = false//com.simplemobiletools.filemanager.Config.newInstance(context).showFullPath val basePath = Environment.getExternalStorageDirectory().toString() var tempPath = fullPath var currPath = basePath if (!showFullPath) { - tempPath = fullPath.replace(basePath, context.getString(R.string.initial_breadcrumb) + "/") + tempPath = fullPath.replace(basePath, context.getString(R.string.smtfp_initial_breadcrumb) + "/") } else { currPath = "/" } diff --git a/simplefilepicker/src/main/kotlin/com/simplemobiletools/filepicker/adapters/ItemsAdapter.kt b/library/src/main/kotlin/com/simplemobiletools/filepicker/adapters/ItemsAdapter.kt similarity index 96% rename from simplefilepicker/src/main/kotlin/com/simplemobiletools/filepicker/adapters/ItemsAdapter.kt rename to library/src/main/kotlin/com/simplemobiletools/filepicker/adapters/ItemsAdapter.kt index 5492b2f9..f174702f 100644 --- a/simplefilepicker/src/main/kotlin/com/simplemobiletools/filepicker/adapters/ItemsAdapter.kt +++ b/library/src/main/kotlin/com/simplemobiletools/filepicker/adapters/ItemsAdapter.kt @@ -56,7 +56,7 @@ class ItemsAdapter(context: Context, private val mItems: List) : Ba private fun getChildrenCnt(item: FileDirItem): String { val children = item.children - return mRes.getQuantityString(R.plurals.items, children, children) + return mRes.getQuantityString(R.plurals.smtfp_items, children, children) } override fun getCount(): Int { diff --git a/simplefilepicker/src/main/kotlin/com/simplemobiletools/filepicker/dialogs/SelectFolderDialog.kt b/library/src/main/kotlin/com/simplemobiletools/filepicker/dialogs/SelectFolderDialog.kt similarity index 94% rename from simplefilepicker/src/main/kotlin/com/simplemobiletools/filepicker/dialogs/SelectFolderDialog.kt rename to library/src/main/kotlin/com/simplemobiletools/filepicker/dialogs/SelectFolderDialog.kt index 22286733..ec64dc42 100644 --- a/simplefilepicker/src/main/kotlin/com/simplemobiletools/filepicker/dialogs/SelectFolderDialog.kt +++ b/library/src/main/kotlin/com/simplemobiletools/filepicker/dialogs/SelectFolderDialog.kt @@ -40,10 +40,10 @@ class SelectFolderDialog : DialogFragment() { setupBreadcrumbs() return AlertDialog.Builder(activity) - .setTitle(resources.getString(R.string.select_destination)) + .setTitle(resources.getString(R.string.smtfp_select_destination)) .setView(dialog) - .setPositiveButton(R.string.ok) { dialog, which -> sendResult() } - .setNegativeButton(R.string.cancel, null) + .setPositiveButton(R.string.smtfp_ok) { dialog, which -> sendResult() } + .setNegativeButton(R.string.smtfp_cancel, null) .create() } diff --git a/simplefilepicker/src/main/kotlin/com/simplemobiletools/filepicker/extensions/long.kt b/library/src/main/kotlin/com/simplemobiletools/filepicker/extensions/long.kt similarity index 100% rename from simplefilepicker/src/main/kotlin/com/simplemobiletools/filepicker/extensions/long.kt rename to library/src/main/kotlin/com/simplemobiletools/filepicker/extensions/long.kt diff --git a/simplefilepicker/src/main/kotlin/com/simplemobiletools/filepicker/extensions/resources.kt b/library/src/main/kotlin/com/simplemobiletools/filepicker/extensions/resources.kt similarity index 84% rename from simplefilepicker/src/main/kotlin/com/simplemobiletools/filepicker/extensions/resources.kt rename to library/src/main/kotlin/com/simplemobiletools/filepicker/extensions/resources.kt index bf2949f7..77245de9 100644 --- a/simplefilepicker/src/main/kotlin/com/simplemobiletools/filepicker/extensions/resources.kt +++ b/library/src/main/kotlin/com/simplemobiletools/filepicker/extensions/resources.kt @@ -8,7 +8,7 @@ fun Resources.getColoredIcon(colorId: Int, resId: Int): Bitmap { options.inMutable = true val bitmap = BitmapFactory.decodeResource(this, resId, options) val paint = Paint() - val filter = PorterDuffColorFilter(getColor(colorId), PorterDuff.Mode.SRC_IN) + val filter = PorterDuffColorFilter(this.getColor(colorId), PorterDuff.Mode.SRC_IN) paint.colorFilter = filter val canvas = Canvas(bitmap) canvas.drawBitmap(bitmap, 0f, 0f, paint) diff --git a/simplefilepicker/src/main/kotlin/com/simplemobiletools/filepicker/extensions/string.kt b/library/src/main/kotlin/com/simplemobiletools/filepicker/extensions/string.kt similarity index 100% rename from simplefilepicker/src/main/kotlin/com/simplemobiletools/filepicker/extensions/string.kt rename to library/src/main/kotlin/com/simplemobiletools/filepicker/extensions/string.kt diff --git a/simplefilepicker/src/main/kotlin/com/simplemobiletools/filepicker/models/FileDirItem.kt b/library/src/main/kotlin/com/simplemobiletools/filepicker/models/FileDirItem.kt similarity index 100% rename from simplefilepicker/src/main/kotlin/com/simplemobiletools/filepicker/models/FileDirItem.kt rename to library/src/main/kotlin/com/simplemobiletools/filepicker/models/FileDirItem.kt diff --git a/simplefilepicker/src/main/kotlin/com/simplemobiletools/filepicker/views/Breadcrumbs.kt b/library/src/main/kotlin/com/simplemobiletools/filepicker/views/Breadcrumbs.kt similarity index 99% rename from simplefilepicker/src/main/kotlin/com/simplemobiletools/filepicker/views/Breadcrumbs.kt rename to library/src/main/kotlin/com/simplemobiletools/filepicker/views/Breadcrumbs.kt index 6ebcaf5c..6ca87ba8 100644 --- a/simplefilepicker/src/main/kotlin/com/simplemobiletools/filepicker/views/Breadcrumbs.kt +++ b/library/src/main/kotlin/com/simplemobiletools/filepicker/views/Breadcrumbs.kt @@ -102,7 +102,7 @@ class Breadcrumbs(context: Context, attrs: AttributeSet) : LinearLayout(context, var tempPath = fullPath var currPath = basePath if (!showFullPath) { - tempPath = fullPath.replace(basePath, context.getString(R.string.initial_breadcrumb) + "/") + tempPath = fullPath.replace(basePath, context.getString(R.string.smtfp_initial_breadcrumb) + "/") } else { currPath = "/" } diff --git a/simplefilepicker/src/main/res/drawable-v21/selector.xml b/library/src/main/res/drawable-v21/selector.xml similarity index 100% rename from simplefilepicker/src/main/res/drawable-v21/selector.xml rename to library/src/main/res/drawable-v21/selector.xml diff --git a/simplefilepicker/src/main/res/drawable/selector.xml b/library/src/main/res/drawable/selector.xml similarity index 100% rename from simplefilepicker/src/main/res/drawable/selector.xml rename to library/src/main/res/drawable/selector.xml diff --git a/simplefilepicker/src/main/res/layout/breadcrumb_item.xml b/library/src/main/res/layout/breadcrumb_item.xml similarity index 100% rename from simplefilepicker/src/main/res/layout/breadcrumb_item.xml rename to library/src/main/res/layout/breadcrumb_item.xml diff --git a/simplefilepicker/src/main/res/layout/directory_picker.xml b/library/src/main/res/layout/directory_picker.xml similarity index 93% rename from simplefilepicker/src/main/res/layout/directory_picker.xml rename to library/src/main/res/layout/directory_picker.xml index a66203e6..bf067e1f 100644 --- a/simplefilepicker/src/main/res/layout/directory_picker.xml +++ b/library/src/main/res/layout/directory_picker.xml @@ -6,7 +6,7 @@ android:layout_height="wrap_content" android:orientation="vertical"> - + Simple File Picker + 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 new file mode 100644 index 00000000..2d13ee5f --- /dev/null +++ b/library/src/main/res/values-it/strings.xml @@ -0,0 +1,12 @@ + + Simple File Picker + 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 new file mode 100644 index 00000000..f12835cf --- /dev/null +++ b/library/src/main/res/values-ja/strings.xml @@ -0,0 +1,12 @@ + + Simple File Picker + 宛先を選択 + ホーム + 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 new file mode 100644 index 00000000..3f0a4d32 --- /dev/null +++ b/library/src/main/res/values-pt-rPT/strings.xml @@ -0,0 +1,12 @@ + + Simple File Picker + 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 new file mode 100644 index 00000000..a63f2cb7 --- /dev/null +++ b/library/src/main/res/values-sv/strings.xml @@ -0,0 +1,12 @@ + + Simple File Picker + Välj mål + home + OK + Cancel + + + 1 objekt + %1$d objekt + + diff --git a/simplefilepicker/src/main/res/values/colors.xml b/library/src/main/res/values/colors.xml similarity index 100% rename from simplefilepicker/src/main/res/values/colors.xml rename to library/src/main/res/values/colors.xml diff --git a/simplefilepicker/src/main/res/values/dimens.xml b/library/src/main/res/values/dimens.xml similarity index 100% rename from simplefilepicker/src/main/res/values/dimens.xml rename to library/src/main/res/values/dimens.xml diff --git a/library/src/main/res/values/strings.xml b/library/src/main/res/values/strings.xml new file mode 100644 index 00000000..0534a6bf --- /dev/null +++ b/library/src/main/res/values/strings.xml @@ -0,0 +1,12 @@ + + Simple File Picker + Select destination + home + OK + Cancel + + + 1 item + %1$d items + + diff --git a/settings.gradle b/settings.gradle index ee6da4ef..33069973 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1 +1 @@ -include ':app', ':simplefilepicker' +include ':app', ':library' diff --git a/simplefilepicker/.gitignore b/simplefilepicker/.gitignore deleted file mode 100644 index 796b96d1..00000000 --- a/simplefilepicker/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/build diff --git a/simplefilepicker/src/main/AndroidManifest.xml b/simplefilepicker/src/main/AndroidManifest.xml deleted file mode 100644 index a2c52fe8..00000000 --- a/simplefilepicker/src/main/AndroidManifest.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - diff --git a/simplefilepicker/src/main/res/values-de/strings.xml b/simplefilepicker/src/main/res/values-de/strings.xml deleted file mode 100644 index cac400d1..00000000 --- a/simplefilepicker/src/main/res/values-de/strings.xml +++ /dev/null @@ -1,12 +0,0 @@ - - Simple File Picker - Ziel auswählen - home - OK - Abbrechen - - - 1 Datei/Ordner - %1$d Dateien/Ordner - - diff --git a/simplefilepicker/src/main/res/values-it/strings.xml b/simplefilepicker/src/main/res/values-it/strings.xml deleted file mode 100644 index 4c11a683..00000000 --- a/simplefilepicker/src/main/res/values-it/strings.xml +++ /dev/null @@ -1,12 +0,0 @@ - - Simple File Picker - Seleziona destinazione - home - OK - Annulla - - - 1 elemento - %1$d elementi - - diff --git a/simplefilepicker/src/main/res/values-ja/strings.xml b/simplefilepicker/src/main/res/values-ja/strings.xml deleted file mode 100644 index aa4b4d80..00000000 --- a/simplefilepicker/src/main/res/values-ja/strings.xml +++ /dev/null @@ -1,12 +0,0 @@ - - Simple File Picker - 宛先を選択 - ホーム - OK - Cancel - - - 1 アイテム - %1$d アイテム - - diff --git a/simplefilepicker/src/main/res/values-pt-rPT/strings.xml b/simplefilepicker/src/main/res/values-pt-rPT/strings.xml deleted file mode 100644 index 40c78896..00000000 --- a/simplefilepicker/src/main/res/values-pt-rPT/strings.xml +++ /dev/null @@ -1,12 +0,0 @@ - - Simple File Picker - Selecionar destino - início - OK - Cancelar - - - 1 item - %1$d itens - - diff --git a/simplefilepicker/src/main/res/values-sv/strings.xml b/simplefilepicker/src/main/res/values-sv/strings.xml deleted file mode 100644 index b3d89f2a..00000000 --- a/simplefilepicker/src/main/res/values-sv/strings.xml +++ /dev/null @@ -1,12 +0,0 @@ - - Simple File Picker - Välj mål - home - OK - Cancel - - - 1 objekt - %1$d objekt - - diff --git a/simplefilepicker/src/main/res/values/strings.xml b/simplefilepicker/src/main/res/values/strings.xml deleted file mode 100644 index 2bf173bf..00000000 --- a/simplefilepicker/src/main/res/values/strings.xml +++ /dev/null @@ -1,12 +0,0 @@ - - Simple File Picker - Select destination - home - OK - Cancel - - - 1 item - %1$d items - -