Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@

.idea
build
.kotlin
.gradle
local.properties
45 changes: 23 additions & 22 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,44 +1,45 @@
plugins {
id 'com.android.application'
id 'kotlin-android'
id "com.android.application"
}

android {
compileSdk 33
namespace 'com.lazygeniouz.filecompat.example'
compileSdk = 36
namespace = "com.lazygeniouz.filecompat.example"

defaultConfig {
applicationId "com.lazygeniouz.filecompat.example"
minSdk 21
targetSdk 33
versionCode 1
versionName "1.0"
applicationId = "com.lazygeniouz.filecompat.example"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
minSdk = 23
targetSdk = 36
versionCode = 1
versionName = "1.0"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
minifyEnabled = false
proguardFiles getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro"
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
buildFeatures {
buildConfig = true
}

kotlinOptions {
jvmTarget = '1.8'
freeCompilerArgs += "-Xopt-in=kotlin.RequiresOptIn"
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
}

dependencies {
implementation project(':dfc')
implementation project(":dfc")
//implementation "com.lazygeniouz:dfc:1.1"

implementation 'androidx.appcompat:appcompat:1.6.0'
implementation 'androidx.activity:activity-ktx:1.6.1'
implementation 'com.google.android.material:material:1.7.0'
implementation "androidx.appcompat:appcompat:1.7.1"
implementation "androidx.activity:activity-ktx:1.12.3"
implementation "androidx.documentfile:documentfile:1.1.0"
implementation "com.google.android.material:material:1.13.0"
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package com.lazygeniouz.filecompat.example

import android.annotation.SuppressLint
import android.app.Activity
import android.content.Context
import android.content.Intent
import android.os.Build.VERSION.SDK_INT
import android.os.Bundle
import android.os.storage.StorageManager
import android.widget.Button
import android.widget.ProgressBar
import android.widget.TextView
import androidx.activity.addCallback
import androidx.activity.result.contract.ActivityResultContracts
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.isVisible
Expand All @@ -29,7 +28,7 @@ class MainActivity : AppCompatActivity(R.layout.activity_main) {

private val folderResultLauncher =
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
if (result.resultCode == Activity.RESULT_OK) {
if (result.resultCode == RESULT_OK) {
val documentUri = result.data?.data
if (documentUri != null) {
textView.text = ""
Expand All @@ -53,11 +52,10 @@ class MainActivity : AppCompatActivity(R.layout.activity_main) {
}
}


@SuppressLint("SetTextI18n")
private val fileResultLauncher =
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
if (result.resultCode == Activity.RESULT_OK) {
if (result.resultCode == RESULT_OK) {
val documentUri = result.data?.data
if (documentUri != null) {
textView.text = ""
Expand All @@ -83,6 +81,8 @@ class MainActivity : AppCompatActivity(R.layout.activity_main) {
textView = findViewById(R.id.fileNames)
progress = findViewById(R.id.progress)

onBackPressedDispatcher.addCallback(this) { finishAffinity() }

buttonDir.setOnClickListener {
folderResultLauncher.launch(getStorageIntent())
}
Expand All @@ -95,13 +95,9 @@ class MainActivity : AppCompatActivity(R.layout.activity_main) {
private fun getStorageIntent(single: Boolean = false): Intent {
return if (single) Intent(Intent.ACTION_GET_CONTENT).setType("*/*") else {
if (SDK_INT >= 30) {
val storageManager = getSystemService(Context.STORAGE_SERVICE) as StorageManager
val storageManager = getSystemService(STORAGE_SERVICE) as StorageManager
storageManager.primaryStorageVolume.createOpenDocumentTreeIntent()
} else Intent(Intent.ACTION_OPEN_DOCUMENT_TREE)
}
}

@Suppress("override_deprecation")
// this is just a sample app, ignore this.
override fun onBackPressed() = finishAffinity()
}
1 change: 1 addition & 0 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:gravity="center"
android:orientation="vertical">

Expand Down
24 changes: 14 additions & 10 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import com.vanniktech.maven.publish.AndroidSingleVariantLibrary
import com.vanniktech.maven.publish.SonatypeHost
import com.vanniktech.maven.publish.JavadocJar
import com.vanniktech.maven.publish.SourcesJar

buildscript {
repositories {
Expand All @@ -8,11 +9,10 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:8.7.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.23"
classpath "com.android.tools.build:gradle:9.0.0"

classpath 'org.jetbrains.dokka:dokka-gradle-plugin:1.9.20'
classpath 'com.vanniktech:gradle-maven-publish-plugin:0.30.0'
classpath "org.jetbrains.dokka:dokka-gradle-plugin:2.1.0"
classpath "com.vanniktech:gradle-maven-publish-plugin:0.36.0"
}
}

Expand All @@ -23,18 +23,22 @@ allprojects {
}

plugins.withId("com.vanniktech.maven.publish.base") {
version "1.2"
group "com.lazygeniouz"
version = "1.3"
group = "com.lazygeniouz"

mavenPublishing {
signAllPublications()
pomFromGradleProperties()
publishToMavenCentral(SonatypeHost.S01, true)
configure(new AndroidSingleVariantLibrary("release", true, true))
publishToMavenCentral(true)
configure(new AndroidSingleVariantLibrary(
new JavadocJar.Dokka("dokkaHtml"),
new SourcesJar.Sources(),
"release"
))
}
}
}

tasks.register('clean', Delete) {
tasks.register("clean", Delete) {
delete rootProject.layout.buildDirectory
}
19 changes: 7 additions & 12 deletions dfc/build.gradle
Original file line number Diff line number Diff line change
@@ -1,32 +1,27 @@
plugins {
id 'com.android.library'
id 'kotlin-android'
id 'org.jetbrains.dokka'
id 'com.vanniktech.maven.publish.base'
}

android {
compileSdk 35
namespace 'com.lazygeniouz.dfc'
compileSdk = 36
namespace = "com.lazygeniouz.dfc"

defaultConfig {
minSdk 21
targetSdk 35
minSdk = 21
targetSdk = 36
}

buildTypes {
release {
minifyEnabled false
minifyEnabled = false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}

kotlinOptions {
jvmTarget = JavaVersion.VERSION_17.toString()
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
}
4 changes: 0 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
android.useAndroidX=true
kotlin.code.style=official
android.enableJetifier=true
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8

android.nonFinalResIds=false
android.nonTransitiveRClass=false
android.defaults.buildfeatures.buildconfig=true

POM_PACKAGING=aar
POM_NAME=dfc
Expand Down
4 changes: 3 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#Fri Feb 06 19:51:09 IST 2026
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip
distributionSha256Sum=a17ddd85a26b6a7f5ddb71ff8b05fc5104c0202c6e64782429790c933686c806
distributionUrl=https\://services.gradle.org/distributions/gradle-9.1.0-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down