Skip to content

Commit

Permalink
Use SAF to get files.
Browse files Browse the repository at this point in the history
Version Bump
Upgraded to Latest Packages & Gradle
Using Storage Access Framework method to get status files from device for Android 10+
Removed Save & Saved Files Tab for Android 10+

Signed-off-by: GauthamAsir <[email protected]>
  • Loading branch information
GauthamAsir committed Jul 13, 2022
1 parent 42021ef commit 3df4120
Show file tree
Hide file tree
Showing 13 changed files with 460 additions and 344 deletions.
29 changes: 14 additions & 15 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ apply plugin: 'com.android.application'
android {
signingConfigs {
release {
storeFile file('E:\\000Gautham\\Documents\\Documents\\0000TEMP\\mellow_rjsweets.jks')
storePassword 'agav0012'
keyAlias = 'gautham'
keyPassword 'agav0012'
storeFile file('D:\\00000\\stock_wiki_exports\\new_storekey.jks')
storePassword '123456'
keyAlias 'mellow'
keyPassword '123456'
}
}
compileSdkVersion 33
Expand All @@ -16,7 +16,7 @@ android {
minSdkVersion 21
targetSdkVersion 33
versionCode 4
versionName "4.6"
versionName "4.7"
Date date = new Date()
String d = date.format('_ddMMYYYY')
setProperty("archivesBaseName", "WhatsApp_Status_Downloader_v$versionName$d")
Expand All @@ -43,23 +43,22 @@ dependencies {

implementation group: 'commons-io', name: 'commons-io', version: '2.6'

implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.preference:preference:1.1.1'
testImplementation 'junit:junit:4.13.1'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation 'androidx.appcompat:appcompat:1.4.2'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.preference:preference:1.2.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'

implementation 'com.intuit.sdp:sdp-android:1.0.6'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.google.android.material:material:1.2.1'
implementation 'com.google.android.material:material:1.6.1'

implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
implementation 'de.hdodenhof:circleimageview:3.1.0'

implementation 'com.github.GauthamAsir:AppUpdater:1.1'

implementation 'com.github.bumptech.glide:glide:4.11.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
implementation 'com.github.bumptech.glide:glide:4.13.2'
annotationProcessor 'com.github.bumptech.glide:compiler:4.13.2'

}
16 changes: 5 additions & 11 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,9 @@
xmlns:tools="http://schemas.android.com/tools"
package="a.gautham.statusdownloader">

<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
tools:ignore="ScopedStorage" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission
android:name="android.permission.MANAGE_EXTERNAL_STORAGE"
android:minSdkVersion="30"
tools:ignore="ScopedStorage" />
<uses-permission
android:name="android.permission.READ_EXTERNAL_STORAGE"
android:maxSdkVersion="29" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

<application
android:allowBackup="true"
Expand All @@ -25,7 +17,9 @@
android:theme="@style/AppTheme">
<activity android:name=".PrivacyPolicy"></activity>
<activity android:name=".AboutUs" />
<activity android:name=".SplashActivity">
<activity
android:name=".SplashActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import androidx.recyclerview.widget.RecyclerView;

import com.bumptech.glide.Glide;
import com.squareup.picasso.Picasso;

import java.util.List;

Expand Down Expand Up @@ -56,11 +55,22 @@ public void onBindViewHolder(@NonNull final ItemViewHolder holder, int position)

final Status status = imagesList.get(position);

if (status.isVideo())
Glide.with(context).asBitmap().load(status.getFile()).into(holder.imageView);
// holder.imageView.setImageBitmap(status.getThumbnail());
else
Picasso.get().load(status.getFile()).into(holder.imageView);
if (status.isApi30()) {
Glide.with(context).load(status.getDocumentFile().getUri()).into(holder.imageView);
} else {
Glide.with(context).load(status.getFile()).into(holder.imageView);
}

// if (status.isVideo())
// Glide.with(context).asBitmap().load(status.getFile()).into(holder.imageView);
//// holder.imageView.setImageBitmap(status.getThumbnail());
// else {
// if(status.isApi30()) {
// Glide.with(context).load(status.getDocumentFile().getUri()).into(holder.imageView);
// } else {
// Glide.with(context).load(status.getFile()).into(holder.imageView);
// }
// }

holder.save.setOnClickListener(view -> {
if (status.getFile().delete()) {
Expand Down Expand Up @@ -142,7 +152,11 @@ public void onBindViewHolder(@NonNull final ItemViewHolder holder, int position)
alertD.setView(view);

ImageView imageView = view.findViewById(R.id.img);
Picasso.get().load(status.getFile()).into(imageView);
if (status.isApi30()) {
Glide.with(context).load(status.getDocumentFile().getUri()).into(imageView);
} else {
Glide.with(context).load(status.getFile()).into(imageView);
}

AlertDialog alert = alertD.create();
alert.getWindow().getAttributes().windowAnimations = R.style.SlidingDialogAnimation;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.squareup.picasso.Picasso;
import com.bumptech.glide.Glide;

import java.util.List;

Expand Down Expand Up @@ -49,7 +49,13 @@ public ItemViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType
public void onBindViewHolder(@NonNull final ItemViewHolder holder, int position) {

final Status status = imagesList.get(position);
Picasso.get().load(status.getFile()).into(holder.imageView);
if (status.isApi30()) {
holder.save.setVisibility(View.GONE);
Glide.with(context).load(status.getDocumentFile().getUri()).into(holder.imageView);
} else {
holder.save.setVisibility(View.VISIBLE);
Glide.with(context).load(status.getFile()).into(holder.imageView);
}

holder.save.setOnClickListener(v -> Common.copyFile(status, context, container));

Expand All @@ -58,7 +64,13 @@ public void onBindViewHolder(@NonNull final ItemViewHolder holder, int position)
Intent shareIntent = new Intent(Intent.ACTION_SEND);

shareIntent.setType("image/jpg");
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + status.getFile().getAbsolutePath()));

if (status.isApi30()) {
shareIntent.putExtra(Intent.EXTRA_STREAM, status.getDocumentFile().getUri());
} else {
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + status.getFile().getAbsolutePath()));
}

context.startActivity(Intent.createChooser(shareIntent, "Share image"));

});
Expand All @@ -71,7 +83,11 @@ public void onBindViewHolder(@NonNull final ItemViewHolder holder, int position)
alertD.setView(view);

ImageView imageView = view.findViewById(R.id.img);
Picasso.get().load(status.getFile()).into(imageView);
if (status.isApi30()) {
Glide.with(context).load(status.getDocumentFile().getUri()).into(imageView);
} else {
Glide.with(context).load(status.getFile()).into(imageView);
}

AlertDialog alert = alertD.create();
alert.getWindow().getAttributes().windowAnimations = R.style.SlidingDialogAnimation;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ public PageAdapter(@NonNull FragmentManager fm, int totalTabs) {
@Override
public Fragment getItem(int position) {

if (position == 1) {
if (position == 0)
return new ImageFragment();

if (position == 1)
return new VideoFragment();
}else if (position == 2)
return new SavedFilesFragment();
return new ImageFragment();

return new SavedFilesFragment();

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,25 @@ public ItemViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType
public void onBindViewHolder(@NonNull final ItemViewHolder holder, int position) {

final Status status = videoList.get(position);
Glide.with(context).asBitmap().load(status.getFile()).into(holder.imageView);

if (status.isApi30()) {
holder.save.setVisibility(View.GONE);
Glide.with(context).load(status.getDocumentFile().getUri()).into(holder.imageView);
} else {
holder.save.setVisibility(View.VISIBLE);
Glide.with(context).load(status.getFile()).into(holder.imageView);
}

holder.share.setOnClickListener(v -> {

Intent shareIntent = new Intent(Intent.ACTION_SEND);

shareIntent.setType("image/mp4");
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + status.getFile().getAbsolutePath()));
if (status.isApi30()) {
shareIntent.putExtra(Intent.EXTRA_STREAM, status.getDocumentFile().getUri());
} else {
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + status.getFile().getAbsolutePath()));
}
context.startActivity(Intent.createChooser(shareIntent, "Share image"));

});
Expand Down Expand Up @@ -91,7 +102,12 @@ public void onBindViewHolder(@NonNull final ItemViewHolder holder, int position)

videoView.setMediaController(mediaController);
mediaController.setMediaPlayer(videoView);
videoView.setVideoURI(Uri.fromFile(status.getFile()));

if (status.isApi30()) {
videoView.setVideoURI(status.getDocumentFile().getUri());
} else {
videoView.setVideoURI(Uri.fromFile(status.getFile()));
}
videoView.requestFocus();

((ViewGroup) mediaController.getParent()).removeView(mediaController);
Expand Down
Loading

0 comments on commit 3df4120

Please sign in to comment.