Skip to content

Commit

Permalink
Add Delete option for saved files & bug fixes.
Browse files Browse the repository at this point in the history
Signed-off-by: GauthamAsir <[email protected]>
  • Loading branch information
GauthamAsir committed Dec 23, 2020
1 parent dd1ba48 commit dd25caa
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 26 deletions.
6 changes: 6 additions & 0 deletions .idea/compiler.xml

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

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.

2 changes: 1 addition & 1 deletion .idea/misc.xml

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

4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ android {
applicationId "a.gautham.statusdownloader"
minSdkVersion 21
targetSdkVersion 29
versionCode 3
versionName "3.0"
versionCode 4
versionName "4.0"
Date date = new Date()
String d = date.format('_ddMMYYYY')
setProperty("archivesBaseName", "WhatsApp_Status_Downloader_v$versionName$d")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.MediaController;
import android.widget.Toast;
import android.widget.VideoView;

import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.RecyclerView;

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

holder.save.setVisibility(View.GONE);
holder.save.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.ic_baseline_delete_24));
holder.share.setVisibility(View.VISIBLE);
holder.save.setVisibility(View.VISIBLE);

final Status status = imagesList.get(position);

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

holder.save.setOnClickListener(view -> {
if (status.getFile().delete()) {
imagesList.remove(position);
notifyDataSetChanged();
Toast.makeText(context, "File Deleted", Toast.LENGTH_SHORT).show();
} else
Toast.makeText(context, "Unable to Delete File", Toast.LENGTH_SHORT).show();
});

holder.share.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import android.view.ViewGroup;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
Expand Down Expand Up @@ -121,7 +120,8 @@ public void run() {
@Override
public void run() {
progressBar.setVisibility(View.GONE);
Toast.makeText(getActivity(), "Dir doest not exists", Toast.LENGTH_SHORT).show();
no_files_found.setVisibility(View.VISIBLE);
// Toast.makeText(getActivity(), "Dir doest not exists", Toast.LENGTH_SHORT).show();
}
});

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

}else {
no_files_found.setVisibility(View.VISIBLE);
progressBar.setVisibility(View.GONE);
}

}
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/ic_baseline_delete_24.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="?android:textColorPrimary"
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" />
</vector>
42 changes: 22 additions & 20 deletions app/src/main/res/layout/item_saved_files.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,42 +9,44 @@
app:cardUseCompatPadding="true">

<RelativeLayout
android:id="@+id/rl1"
android:layout_width="match_parent"
android:layout_height="match_parent">

<RelativeLayout
<ImageView
android:id="@+id/ivThumbnail"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/rl1">
android:layout_height="@dimen/_90sdp"
android:contentDescription="@null"
android:scaleType="centerCrop" />

<ImageView
android:id="@+id/ivThumbnail"
android:layout_width="match_parent"
android:layout_height="@dimen/_90sdp"
android:scaleType="centerCrop"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/ivThumbnail"
android:orientation="horizontal">

<ImageButton
android:id="@+id/save"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/ivThumbnail"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="@drawable/ic_file_download_black"
android:tint="@color/white"
android:gravity="center"
android:backgroundTint="@android:color/transparent"/>
android:backgroundTint="@android:color/transparent"
android:contentDescription="@null" />

<ImageButton
android:id="@+id/share"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/ivThumbnail"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="@drawable/ic_share"
android:tint="@color/white"
android:gravity="center"
android:visibility="gone"
android:backgroundTint="@android:color/transparent"/>
android:backgroundTint="@android:color/transparent"
android:contentDescription="@null" />

</RelativeLayout>
</LinearLayout>

</RelativeLayout>

Expand Down

0 comments on commit dd25caa

Please sign in to comment.