Skip to content

Commit

Permalink
Merge pull request #52 from Gkemon/fix-for-android-13
Browse files Browse the repository at this point in the history
#51 -- fix pdf not saving for android 13
  • Loading branch information
Gkemon authored Nov 26, 2022
2 parents d51da3c + 98c3304 commit 185d427
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 15 deletions.
13 changes: 6 additions & 7 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,17 @@ dependencies {
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation project(path: ':xml-to-pdf')
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test:runner:1.4.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation 'com.intuit.ssp:ssp-android:1.0.6'
androidTestImplementation 'androidx.test:runner:1.5.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.0'
implementation 'com.intuit.ssp:ssp-android:1.1.0'
implementation 'com.intuit.sdp:sdp-android:1.1.0'
implementation 'androidx.recyclerview:recyclerview:1.2.1'
implementation 'com.github.bumptech.glide:glide:4.13.2'
annotationProcessor 'com.github.bumptech.glide:compiler:4.13.0'
implementation 'com.github.bumptech.glide:glide:4.14.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.14.1'
/*Comment out the line below if you want to use library locally*/
implementation project(path: ':xml-to-pdf')

/*Comment out the line below if you want to use library from jitpack repo*/
//implementation 'com.github.Gkemon:Android-XML-to-PDF-Generator:2.6.5'
//implementation 'com.github.Gkemon:Android-XML-to-PDF-Generator:2.6.7'
}
8 changes: 4 additions & 4 deletions xml-to-pdf/build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 32
compileSdkVersion 33
defaultConfig {
minSdkVersion 21
targetSdkVersion 32
targetSdkVersion 33

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'consumer-rules.pro'
Expand Down Expand Up @@ -37,8 +37,8 @@ dependencies {
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'com.karumi:dexter:6.2.2'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.4'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.0'
implementation 'io.reactivex.rxjava3:rxandroid:3.0.0'
// Because RxAndroid releases are few and far between, it is recommended you also
// explicitly depend on RxJava's latest version for bug fixes and new features.
Expand Down
14 changes: 10 additions & 4 deletions xml-to-pdf/src/main/java/com/gkemon/XMLtoPDF/PdfGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -536,12 +536,18 @@ private boolean hasAllPermission(Context context) {
@Override
public void build(PdfGeneratorListener pdfGeneratorListener) {
this.pdfGeneratorListener = pdfGeneratorListener;
if (hasAllPermission(context)) {
if (hasAllPermission(context) || (xmlToPDFLifecycleObserver != null && android.os.Build.VERSION.SDK_INT > 32)) {
print();
} else {
postLog("WRITE_EXTERNAL_STORAGE and READ_EXTERNAL_STORAGE Permission is not given." +
" Permission taking popup (using https://github.com/Karumi/Dexter) is going " +
"to be shown");
if(android.os.Build.VERSION.SDK_INT > 32) {
postFailure("Your current sdk is greater then 32, so you need to set ''xmlToPDFLifecycleObserver'' ." +
"To see example please check this code - https://github.com/Gkemon/Android-XML-to-PDF-Generator/blob/master/sample/src/main/java/com/emon/exampleXMLtoPDF/MainActivity.java" +
", line-67.");
}else {
postLog("WRITE_EXTERNAL_STORAGE and READ_EXTERNAL_STORAGE Permission is not given." +
" Permission taking popup (using https://github.com/Karumi/Dexter) is going " +
"to be shown");
}
Dexter.withContext(context)
.withPermissions(Manifest.permission.WRITE_EXTERNAL_STORAGE,
Manifest.permission.READ_EXTERNAL_STORAGE)
Expand Down

0 comments on commit 185d427

Please sign in to comment.