Skip to content

Develop #334

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ If your app

* As of now, It is only available in jCenter(), So just put this in your app dependencies:
```gradle
implementation 'com.droidninja:filepicker:2.2.4'
implementation 'com.droidninja:filepicker:2.2.5'
```
There is a method `getFilePath` in `ContentUriUtils` class through you can get the file path from Uri. e.g.

Expand Down Expand Up @@ -128,8 +128,9 @@ String zipTypes = {"zip","rar"};
addFileSupport("ZIP",zipTypes, R.drawable.ic_zip_icon);
```

#Styling
Just override these styles in your main module to change colors and themes.
# Styling

Just override these styles in your main module to change colors and themes.

- If you have dark theme colors, just use `LibAppTheme.Dark`
- If you have light theme colors, just use `LibAppTheme`
Expand Down Expand Up @@ -163,8 +164,8 @@ Just override these styles in your main module to change colors and themes.
<item name="tabGravity">fill</item>
<item name="tabMaxWidth">0dp</item>
</style>


<style name="ToolbarTheme" parent="Widget.MaterialComponents.Toolbar.Primary">
<item name="materialThemeOverlay">@style/ThemeOverlay.App.Toolbar.Light</item>
<item name="android:theme">@style/ThemeOverlay.App.Toolbar.Light</item>
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/java/vi/filepicker/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,11 @@ public void onPickDoc() {
.setActivityTitle("Please select doc")
.setImageSizeLimit(5) //Provide Size in MB
.setVideoSizeLimit(20)
.addFileSupport("ZIP", zips)
.addFileSupport("AAC", pdfs, R.drawable.pdf_blue)
// .addFileSupport("ZIP", zips)
// .addFileSupport("AAC", pdfs, R.drawable.pdf_blue)
.enableDocSupport(true)
.enableSelectAll(true)
.sortDocumentsBy(SortingTypes.name)
.sortDocumentsBy(SortingTypes.NAME)
.withOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED)
.pickFile(this);
}
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/values-it/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="rationale_doc_picker">L\'app ha bisogno di questo permesso per accedere ai documenti del dispositivo.</string>
<string name="rationale_photo_picker">L\'app ha bisogno di questo permesso per selezionare foto dalla galleria e dalla camera.</string>
</resources>
9 changes: 4 additions & 5 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<resources>
<string name="app_name">Android FilePicker</string>
<string name="app_name" translatable="false">Android FilePicker</string>

<!-- TODO: Remove or change this placeholder text -->
<string name="hello_blank_fragment">Hello blank fragment</string>
<string name="rationale_photo_picker">We require this permission to select photo from gallery and camera.</string>
<string name="rationale_doc_picker">We need this pemission to read documents from device.</string>
<string name="hello_blank_fragment" translatable="false">Hello blank fragment</string>
<string name="rationale_photo_picker">We require this permission to select photo from gallery and camera.</string>
<string name="rationale_doc_picker">We need this permission to read documents from device.</string>
</resources>
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,7 @@ allprojects {
task clean(type: Delete) {
delete rootProject.buildDir
}

subprojects {
tasks.withType(Javadoc).all { enabled = false }
}
4 changes: 3 additions & 1 deletion filepicker/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: "com.jfrog.bintray"

version = "2.2.4"
version = "2.2.5"

android {
compileSdkVersion 30
Expand Down Expand Up @@ -86,6 +86,7 @@ task javadoc(type: Javadoc) {
excludes = ['**/*.kt']
options.addStringOption('Xdoclint:none', '-quiet')
options.addStringOption('encoding', 'UTF-8')
options.addStringOption('charSet', 'UTF-8')
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
}
Expand All @@ -94,6 +95,7 @@ task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}

artifacts {
archives javadocJar
archives sourcesJar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import android.view.Menu
import android.view.MenuItem
import android.view.View
import android.widget.TextView
import androidx.core.widget.ContentLoadingProgressBar
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider
import com.bumptech.glide.Glide
Expand All @@ -27,6 +28,7 @@ import java.util.Comparator
class MediaDetailsActivity : BaseFilePickerActivity(), FileAdapterListener {
private var recyclerView: RecyclerView? = null
private var emptyView: TextView? = null
private lateinit var progressBar: ContentLoadingProgressBar
private lateinit var mGlideRequestManager: RequestManager
private var photoGridAdapter: PhotoGridAdapter? = null
private var fileType: Int = 0
Expand Down Expand Up @@ -74,6 +76,8 @@ class MediaDetailsActivity : BaseFilePickerActivity(), FileAdapterListener {
}

private fun setUpView() {
progressBar = findViewById(R.id.progressbar)
progressBar.visibility = View.VISIBLE
recyclerView = findViewById(R.id.recyclerview)
emptyView = findViewById(R.id.empty_view)

Expand Down Expand Up @@ -108,6 +112,7 @@ class MediaDetailsActivity : BaseFilePickerActivity(), FileAdapterListener {
}

private fun updateList(medias: List<Media>) {
progressBar.visibility = View.GONE
if (medias.isNotEmpty()) {
emptyView?.visibility = View.GONE
recyclerView?.visibility = View.VISIBLE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ object PickerManager {
private var maxCount = FilePickerConst.DEFAULT_MAX_COUNT
private var showImages = true
var cameraDrawable = R.drawable.ic_camera
var sortingType = SortingTypes.none
var sortingType = SortingTypes.NONE

val selectedPhotos: ArrayList<Uri> = ArrayList()
val selectedFiles: ArrayList<Uri> = ArrayList()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import android.os.Bundle
import android.view.*
import android.widget.TextView
import android.widget.Toast
import androidx.core.widget.ContentLoadingProgressBar
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider
import androidx.recyclerview.widget.DefaultItemAnimator
Expand Down Expand Up @@ -35,7 +36,7 @@ class MediaDetailPickerFragment : BaseFragment(), FileAdapterListener {

lateinit var emptyView: TextView
lateinit var viewModel: VMMediaPicker

private lateinit var progressBar: ContentLoadingProgressBar
private var mListener: PhotoPickerFragmentListener? = null
private var photoGridAdapter: PhotoGridAdapter? = null
private var imageCaptureManager: ImageCaptureManager? = null
Expand Down Expand Up @@ -91,6 +92,8 @@ class MediaDetailPickerFragment : BaseFragment(), FileAdapterListener {
}

private fun initView(view: View) {
progressBar = view.findViewById(R.id.progressbar)
progressBar.visibility = View.VISIBLE
recyclerView = view.findViewById(R.id.recyclerview)
emptyView = view.findViewById(R.id.empty_view)
arguments?.let {
Expand Down Expand Up @@ -138,6 +141,7 @@ class MediaDetailPickerFragment : BaseFragment(), FileAdapterListener {

private fun updateList(medias: List<Media>) {
view?.let { _ ->
progressBar.visibility = View.GONE
if (medias.isNotEmpty()) {
emptyView.visibility = View.GONE
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import android.widget.Toast
import androidx.core.widget.ContentLoadingProgressBar
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider
import com.bumptech.glide.Glide
Expand All @@ -36,7 +37,7 @@ class MediaFolderPickerFragment : BaseFragment(), FolderGridAdapter.FolderGridAd

lateinit var emptyView: TextView
lateinit var viewModel: VMMediaPicker

private lateinit var progressBar: ContentLoadingProgressBar
private var mListener: PhotoPickerFragmentListener? = null
private var photoGridAdapter: FolderGridAdapter? = null
private var imageCaptureManager: ImageCaptureManager? = null
Expand Down Expand Up @@ -78,6 +79,8 @@ class MediaFolderPickerFragment : BaseFragment(), FolderGridAdapter.FolderGridAd
}

private fun initView(view: View) {
progressBar = view.findViewById(R.id.progressbar)
progressBar.visibility = View.VISIBLE
recyclerView = view.findViewById(R.id.recyclerview)
emptyView = view.findViewById(R.id.empty_view)
arguments?.let {
Expand Down Expand Up @@ -128,6 +131,7 @@ class MediaFolderPickerFragment : BaseFragment(), FolderGridAdapter.FolderGridAd

private fun updateList(dirs: List<PhotoDirectory>) {
view?.let {
progressBar.visibility = View.GONE
if (dirs.isNotEmpty()) {
emptyView.visibility = View.GONE
recyclerView.visibility = View.VISIBLE
Expand Down Expand Up @@ -166,9 +170,11 @@ class MediaFolderPickerFragment : BaseFragment(), FolderGridAdapter.FolderGridAd

override fun onFolderClicked(photoDirectory: PhotoDirectory) {
val intent = Intent(activity, MediaDetailsActivity::class.java)
intent.putExtra(PhotoDirectory::class.java.simpleName, photoDirectory.apply {
medias.clear()
})
val intentPhotoDir = PhotoDirectory(bucketId = photoDirectory.bucketId,name = photoDirectory.name)
intent.putExtra(PhotoDirectory::class.java.simpleName, intentPhotoDir)
// intent.putExtra(PhotoDirectory::class.java.simpleName, photoDirectory.apply {
// medias.clear()
// })
intent.putExtra(FilePickerConst.EXTRA_FILE_TYPE, fileType)
intent.putExtra(FilePickerConst.EXTRA_IMAGE_FILE_SIZE, imageFileSize)
intent.putExtra(FilePickerConst.EXTRA_VIDEO_FILE_SIZE, videoFileSize)
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package droidninja.filepicker.models.sort

import droidninja.filepicker.models.Document
import java.util.*

/**
* Created by gabriel on 10/2/17.
*/
class NameComparator : Comparator<Document> {
override fun compare(o1: Document, o2: Document): Int {
return o1.name.toLowerCase(Locale.getDefault()).compareTo(o2.name.toLowerCase(Locale.getDefault()))
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package droidninja.filepicker.models.sort

import droidninja.filepicker.models.Document
import java.util.*

/**
* Created by gabriel on 10/2/17.
*/
enum class SortingTypes(val comparator: Comparator<Document>?) {
NAME(NameComparator()), NONE(null);
}
8 changes: 8 additions & 0 deletions filepicker/src/main/res/layout/activity_media_details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@
android:layout_below="@+id/appbar_layout"
android:background="@android:color/white" />

<androidx.core.widget.ContentLoadingProgressBar
style="?android:attr/progressBarStyleLarge"
android:id="@+id/progressbar"
android:layout_centerInParent="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"/>

<TextView
android:id="@+id/empty_view"
android:layout_width="match_parent"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@
android:layout_width="fill_parent"
android:layout_height="fill_parent" />

<androidx.core.widget.ContentLoadingProgressBar
style="?android:attr/progressBarStyleLarge"
android:id="@+id/progressbar"
android:layout_centerInParent="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"/>

<TextView
android:id="@+id/empty_view"
android:layout_width="match_parent"
Expand Down
8 changes: 8 additions & 0 deletions filepicker/src/main/res/layout/fragment_photo_picker.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@
android:layout_height="fill_parent"
/>

<androidx.core.widget.ContentLoadingProgressBar
style="?android:attr/progressBarStyleLarge"
android:id="@+id/progressbar"
android:layout_centerInParent="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"/>

<TextView
android:id="@+id/empty_view"
android:layout_width="match_parent"
Expand Down