Skip to content

Commit

Permalink
add: add file picker module (open system file manager to select file,…
Browse files Browse the repository at this point in the history
… and auto convert Uri to real path)
  • Loading branch information
SunnyQjm committed Feb 14, 2020
1 parent 4216918 commit ce6a56b
Show file tree
Hide file tree
Showing 18 changed files with 615 additions and 145 deletions.
1 change: 1 addition & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,5 @@ dependencies {
implementation project(path: ':quick_android_webview')
implementation project(path: ':quick_android_custom_view')
implementation project(path: ':quick_android_easy_bar')
implementation project(path: ':quick_android_file_picker')
}
30 changes: 28 additions & 2 deletions app/src/main/java/cn/qjm253/quick_android/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import android.os.Bundle
import cn.qjm253.quick_android.custom_view_demo.CustomViewDemoActivity
import cn.qjm253.quick_android.mvp_demo.MVPDemoActivity
import cn.qjm253.quick_android.webview_demo.WebViewDemo
import cn.qjm253.quick_android_base.QuickAndroid
import cn.qjm253.quick_android_base.base.activity.BaseQuickAndroidActivity
import cn.qjm253.quick_android_base.extensions.*
import cn.qjm253.quick_android_base.util.ContentUriUtil
Expand All @@ -14,15 +15,18 @@ import cn.qjm253.quick_android_easy_bar.init
import cn.qjm253.quick_android_image_picker.openWechatStyleGallery
import cn.qjm253.quick_android_image_picker.startClipImage
import cn.qjm253.quick_android_qrcode.QuickAndroidQrCode
import cn.qjm253.quick_android_qrcode.scanCode
import cn.qjm253.quick_android_rx_permission.QuickAndroidRxPermission
import cn.qjm253.quick_android_rx_permission.createRxPermission
import com.example.quick_android_file_picker.QuickAndroidFilePicker
import com.example.quick_android_file_picker.createFilePicker
import com.qingmei2.rximagepicker_extension.MimeType
import com.qingmei2.rximagepicker_extension_wechat.WechatConfigrationBuilder
import kotlinx.android.synthetic.main.activity_main.*

class MainActivity : BaseQuickAndroidActivity() {

val rxPermission = QuickAndroidRxPermission(this)
private val rxPermission = QuickAndroidRxPermission(this)

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
Expand Down Expand Up @@ -101,6 +105,28 @@ class MainActivity : BaseQuickAndroidActivity() {
btnCustomViewDemo.setOnClickListener {
jumpTo(CustomViewDemoActivity::class.java)
}

btnPickerFile.setOnClickListener {
QuickAndroid
.createRxPermission(this)
.request(
arrayOf(
Manifest.permission.READ_EXTERNAL_STORAGE
)
)
.subscribe {
if (it.granted) {
checkMyPermission(Manifest.permission.READ_EXTERNAL_STORAGE, {
QuickAndroid
.createFilePicker(this)
.pickerFile()
.subscribe { fpr ->
toast(fpr.path)
}
})
}
}
}
}

// override fun onPermissionsGranted(requestCode: Int, perms: MutableList<String>) {
Expand Down
12 changes: 12 additions & 0 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,16 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/btnWebviewDemo" />

<Button
android:id="@+id/btnPickerFile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:text="Picker file "
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/btnWebviewDemo" />
</LinearLayout>
Loading

0 comments on commit ce6a56b

Please sign in to comment.