Skip to content

Commit dd25caa

Browse files
author
GauthamAsir
committed
Add Delete option for saved files & bug fixes.
Signed-off-by: GauthamAsir <gauthamasir@gmail.com>
1 parent dd1ba48 commit dd25caa

File tree

8 files changed

+57
-26
lines changed

8 files changed

+57
-26
lines changed

.idea/compiler.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/gradle.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ android {
1616
applicationId "a.gautham.statusdownloader"
1717
minSdkVersion 21
1818
targetSdkVersion 29
19-
versionCode 3
20-
versionName "3.0"
19+
versionCode 4
20+
versionName "4.0"
2121
Date date = new Date()
2222
String d = date.format('_ddMMYYYY')
2323
setProperty("archivesBaseName", "WhatsApp_Status_Downloader_v$versionName$d")

app/src/main/java/a/gautham/statusdownloader/Adapter/FilesAdapter.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@
1414
import android.widget.FrameLayout;
1515
import android.widget.ImageView;
1616
import android.widget.MediaController;
17+
import android.widget.Toast;
1718
import android.widget.VideoView;
1819

1920
import androidx.annotation.NonNull;
21+
import androidx.core.content.ContextCompat;
2022
import androidx.recyclerview.widget.RecyclerView;
2123

2224
import com.squareup.picasso.Picasso;
@@ -48,8 +50,9 @@ public ItemViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType
4850
@Override
4951
public void onBindViewHolder(@NonNull final ItemViewHolder holder, int position) {
5052

51-
holder.save.setVisibility(View.GONE);
53+
holder.save.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.ic_baseline_delete_24));
5254
holder.share.setVisibility(View.VISIBLE);
55+
holder.save.setVisibility(View.VISIBLE);
5356

5457
final Status status = imagesList.get(position);
5558

@@ -58,6 +61,15 @@ public void onBindViewHolder(@NonNull final ItemViewHolder holder, int position)
5861
else
5962
Picasso.get().load(status.getFile()).into(holder.imageView);
6063

64+
holder.save.setOnClickListener(view -> {
65+
if (status.getFile().delete()) {
66+
imagesList.remove(position);
67+
notifyDataSetChanged();
68+
Toast.makeText(context, "File Deleted", Toast.LENGTH_SHORT).show();
69+
} else
70+
Toast.makeText(context, "Unable to Delete File", Toast.LENGTH_SHORT).show();
71+
});
72+
6173
holder.share.setOnClickListener(new View.OnClickListener() {
6274
@Override
6375
public void onClick(View v) {

app/src/main/java/a/gautham/statusdownloader/Fragments/SavedFilesFragment.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import android.view.ViewGroup;
1010
import android.widget.ProgressBar;
1111
import android.widget.TextView;
12-
import android.widget.Toast;
1312

1413
import androidx.annotation.NonNull;
1514
import androidx.annotation.Nullable;
@@ -121,7 +120,8 @@ public void run() {
121120
@Override
122121
public void run() {
123122
progressBar.setVisibility(View.GONE);
124-
Toast.makeText(getActivity(), "Dir doest not exists", Toast.LENGTH_SHORT).show();
123+
no_files_found.setVisibility(View.VISIBLE);
124+
// Toast.makeText(getActivity(), "Dir doest not exists", Toast.LENGTH_SHORT).show();
125125
}
126126
});
127127

@@ -132,6 +132,7 @@ public void run() {
132132

133133
}else {
134134
no_files_found.setVisibility(View.VISIBLE);
135+
progressBar.setVisibility(View.GONE);
135136
}
136137

137138
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="24dp"
3+
android:height="24dp"
4+
android:viewportWidth="24"
5+
android:viewportHeight="24">
6+
<path
7+
android:fillColor="?android:textColorPrimary"
8+
android:pathData="M6,19c0,1.1 0.9,2 2,2h8c1.1,0 2,-0.9 2,-2V7H6v12zM19,4h-3.5l-1,-1h-5l-1,1H5v2h14V4z" />
9+
</vector>

app/src/main/res/layout/item_saved_files.xml

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,42 +9,44 @@
99
app:cardUseCompatPadding="true">
1010

1111
<RelativeLayout
12+
android:id="@+id/rl1"
1213
android:layout_width="match_parent"
1314
android:layout_height="match_parent">
1415

15-
<RelativeLayout
16+
<ImageView
17+
android:id="@+id/ivThumbnail"
1618
android:layout_width="match_parent"
17-
android:layout_height="match_parent"
18-
android:id="@+id/rl1">
19+
android:layout_height="@dimen/_90sdp"
20+
android:contentDescription="@null"
21+
android:scaleType="centerCrop" />
1922

20-
<ImageView
21-
android:id="@+id/ivThumbnail"
22-
android:layout_width="match_parent"
23-
android:layout_height="@dimen/_90sdp"
24-
android:scaleType="centerCrop"/>
23+
<LinearLayout
24+
android:layout_width="match_parent"
25+
android:layout_height="wrap_content"
26+
android:layout_below="@+id/ivThumbnail"
27+
android:orientation="horizontal">
2528

2629
<ImageButton
2730
android:id="@+id/save"
28-
android:layout_width="match_parent"
29-
android:layout_height="match_parent"
30-
android:layout_below="@+id/ivThumbnail"
31+
android:layout_width="0dp"
32+
android:layout_height="wrap_content"
33+
android:layout_weight="1"
3134
android:src="@drawable/ic_file_download_black"
3235
android:tint="@color/white"
33-
android:gravity="center"
34-
android:backgroundTint="@android:color/transparent"/>
36+
android:backgroundTint="@android:color/transparent"
37+
android:contentDescription="@null" />
3538

3639
<ImageButton
3740
android:id="@+id/share"
38-
android:layout_width="match_parent"
39-
android:layout_height="match_parent"
40-
android:layout_below="@+id/ivThumbnail"
41+
android:layout_width="0dp"
42+
android:layout_height="wrap_content"
43+
android:layout_weight="1"
4144
android:src="@drawable/ic_share"
4245
android:tint="@color/white"
43-
android:gravity="center"
44-
android:visibility="gone"
45-
android:backgroundTint="@android:color/transparent"/>
46+
android:backgroundTint="@android:color/transparent"
47+
android:contentDescription="@null" />
4648

47-
</RelativeLayout>
49+
</LinearLayout>
4850

4951
</RelativeLayout>
5052

0 commit comments

Comments
 (0)