Skip to content

Commit 74bfdd0

Browse files
Add files via upload
1 parent 7418ec6 commit 74bfdd0

File tree

62 files changed

+2473
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+2473
-0
lines changed

Diff for: app/build.gradle

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
plugins {
2+
id 'com.android.application'
3+
}
4+
5+
android {
6+
compileSdkVersion 31
7+
buildToolsVersion "30.0.3"
8+
9+
defaultConfig {
10+
applicationId "com.android.whatsappsaver"
11+
minSdkVersion 21
12+
targetSdkVersion 31
13+
versionCode 1
14+
versionName "1.0"
15+
16+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
17+
}
18+
19+
buildTypes {
20+
release {
21+
minifyEnabled false
22+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
23+
}
24+
}
25+
compileOptions {
26+
sourceCompatibility JavaVersion.VERSION_1_8
27+
targetCompatibility JavaVersion.VERSION_1_8
28+
}
29+
}
30+
31+
dependencies {
32+
implementation 'androidx.appcompat:appcompat:1.3.1'
33+
implementation 'com.google.android.material:material:1.4.0'
34+
implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
35+
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
36+
testImplementation 'junit:junit:4.+'
37+
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
38+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
39+
implementation 'androidx.cardview:cardview:1.0.0'
40+
implementation 'com.github.bumptech.glide:glide:4.12.0'
41+
implementation 'org.jsoup:jsoup:1.13.1'
42+
implementation 'androidx.drawerlayout:drawerlayout:1.1.1'
43+
implementation 'androidx.viewpager:viewpager:1.0.0'
44+
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
45+
}

Diff for: app/proguard-rules.pro

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.android.whatsappsaver;
2+
3+
import android.content.Context;
4+
5+
import androidx.test.platform.app.InstrumentationRegistry;
6+
import androidx.test.ext.junit.runners.AndroidJUnit4;
7+
8+
import org.junit.Test;
9+
import org.junit.runner.RunWith;
10+
11+
import static org.junit.Assert.*;
12+
13+
/**
14+
* Instrumented test, which will execute on an Android device.
15+
*
16+
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
17+
*/
18+
@RunWith(AndroidJUnit4.class)
19+
public class ExampleInstrumentedTest {
20+
@Test
21+
public void useAppContext() {
22+
// Context of the app under test.
23+
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
24+
assertEquals("com.android.whatsappsaver", appContext.getPackageName());
25+
}
26+
}

Diff for: app/src/main/AndroidManifest.xml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.android.whatsappsaver">
4+
5+
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
6+
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
7+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
8+
9+
<application
10+
android:allowBackup="true"
11+
android:icon="@mipmap/ic_launcher"
12+
android:label="@string/app_name"
13+
android:requestLegacyExternalStorage="true"
14+
android:roundIcon="@mipmap/ic_launcher_round"
15+
android:supportsRtl="true"
16+
android:theme="@style/Theme.WhatsAppSaver">
17+
<activity android:name=".VideoViewActivity" />
18+
<activity android:name=".ImageViewActivity" />
19+
<activity
20+
android:name=".SplashActivity"
21+
android:exported="true">
22+
<intent-filter>
23+
<action android:name="android.intent.action.MAIN" />
24+
25+
<category android:name="android.intent.category.LAUNCHER" />
26+
</intent-filter>
27+
</activity>
28+
<activity android:name=".MainActivity" />
29+
</application>
30+
31+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
package com.android.whatsappsaver;
2+
3+
import androidx.appcompat.app.AppCompatActivity;
4+
5+
import android.content.Intent;
6+
import android.net.Uri;
7+
import android.os.Bundle;
8+
import android.view.View;
9+
import android.widget.ImageButton;
10+
import android.widget.ImageView;
11+
import android.widget.Toast;
12+
13+
import com.bumptech.glide.Glide;
14+
15+
import java.io.File;
16+
import java.io.FileInputStream;
17+
import java.io.FileOutputStream;
18+
import java.io.IOException;
19+
import java.nio.channels.FileChannel;
20+
21+
public class ImageViewActivity extends AppCompatActivity {
22+
ImageButton share, download, repost;
23+
String imagePath, path, aType, packageName;
24+
String type = "";
25+
ImageView imageView;
26+
@Override
27+
protected void onCreate(Bundle savedInstanceState) {
28+
super.onCreate(savedInstanceState);
29+
setContentView(R.layout.activity_image_view);
30+
31+
imageView = findViewById(R.id.imageViewer);
32+
share = findViewById(R.id.imageViewer_share);
33+
download = findViewById(R.id.imageViewer_save);
34+
repost = findViewById(R.id.imageViewer_repost);
35+
36+
Intent intent = getIntent();
37+
if (intent != null){
38+
imagePath = intent.getStringExtra("image");
39+
type = intent.getStringExtra("type");
40+
aType = intent.getStringExtra("aType");
41+
42+
if (imagePath != null) {
43+
Glide.with(this).load(imagePath).into(imageView);
44+
}
45+
}
46+
47+
path = Utils.statusSaverPath;
48+
packageName = "com.whatsapp";
49+
50+
share.setOnClickListener(new View.OnClickListener() {
51+
@Override
52+
public void onClick(View view) {
53+
share(imagePath);
54+
}
55+
});
56+
57+
download.setOnClickListener(new View.OnClickListener() {
58+
@Override
59+
public void onClick(View view) {
60+
copyFileOrDirectory(imagePath, path);
61+
}
62+
});
63+
64+
repost.setOnClickListener(new View.OnClickListener() {
65+
@Override
66+
public void onClick(View view) {
67+
repost(imagePath, packageName);
68+
}
69+
});
70+
71+
if (aType.equals("0")){
72+
download.setVisibility(View.GONE);
73+
} else {
74+
download.setVisibility(View.VISIBLE);
75+
}
76+
}
77+
78+
private void copyFileOrDirectory(String source, String destination){
79+
try {
80+
File src = new File(source);
81+
File dest = new File(destination);
82+
83+
if (src.isDirectory()) {
84+
String files[] = src.list();
85+
int fileLength = files.length;
86+
for (int i = 0; i < fileLength; i++) {
87+
String src1 = (new File(src, files[i]).getPath());
88+
String dest1 = dest.getPath();
89+
copyFileOrDirectory(src1, dest1);
90+
}
91+
} else {
92+
copyFile(src, dest);
93+
}
94+
} catch (IOException ioException) {
95+
ioException.printStackTrace();
96+
}
97+
}
98+
99+
private void copyFile(File sourceFile, File destFile) throws IOException{
100+
if (!destFile.getParentFile().exists()){
101+
destFile.getParentFile().mkdirs();
102+
}
103+
104+
if (!destFile.exists()){
105+
destFile.createNewFile();
106+
}
107+
108+
FileChannel source = null;
109+
FileChannel destination = null;
110+
111+
try {
112+
source = new FileInputStream(sourceFile).getChannel();
113+
destination = new FileOutputStream(destFile).getChannel();
114+
destination.transferFrom(source, 0, source.size());
115+
Toast.makeText(this, "Picture Saved", Toast.LENGTH_SHORT).show();
116+
} finally {
117+
if (source != null) {
118+
source.close();
119+
}
120+
if (destination != null) {
121+
destination.close();
122+
}
123+
}
124+
}
125+
126+
private void share(String path) {
127+
Intent intent = new Intent(Intent.ACTION_SEND);
128+
intent.setType("image/jpg");
129+
intent.putExtra(Intent.EXTRA_STREAM, Uri.parse(path));
130+
startActivity(Intent.createChooser(intent, "Share Using"));
131+
}
132+
133+
private void repost(String path, String packageName) {
134+
Intent intent = new Intent(Intent.ACTION_SEND);
135+
intent.setType("image/jpg");
136+
intent.putExtra(Intent.EXTRA_STREAM, Uri.parse(path));
137+
intent.setPackage(packageName);
138+
startActivity(Intent.createChooser(intent, "Share to"));
139+
}
140+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
package com.android.whatsappsaver;
2+
3+
import androidx.annotation.NonNull;
4+
import androidx.annotation.Nullable;
5+
import androidx.appcompat.app.ActionBarDrawerToggle;
6+
import androidx.appcompat.app.AppCompatActivity;
7+
import androidx.appcompat.widget.Toolbar;
8+
import androidx.core.view.GravityCompat;
9+
import androidx.drawerlayout.widget.DrawerLayout;
10+
import androidx.fragment.app.Fragment;
11+
import androidx.fragment.app.FragmentManager;
12+
import androidx.fragment.app.FragmentPagerAdapter;
13+
import androidx.viewpager.widget.ViewPager;
14+
15+
import android.content.Context;
16+
import android.os.Bundle;
17+
import android.view.MenuItem;
18+
import android.widget.Toast;
19+
20+
import com.android.whatsappsaver.fragments.WhatsAppImagesFragment;
21+
import com.android.whatsappsaver.fragments.WhatsAppSavedFragment;
22+
import com.android.whatsappsaver.fragments.WhatsAppVideosFragment;
23+
import com.google.android.material.navigation.NavigationView;
24+
import com.google.android.material.tabs.TabLayout;
25+
26+
import java.io.File;
27+
import java.util.ArrayList;
28+
import java.util.List;
29+
30+
public class MainActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener{
31+
NavigationView navigationView;
32+
@Override
33+
protected void onCreate(Bundle savedInstanceState) {
34+
super.onCreate(savedInstanceState);
35+
setContentView(R.layout.activity_main);
36+
37+
Toolbar toolbar = findViewById(R.id.toolbar);
38+
setSupportActionBar(toolbar);
39+
40+
DrawerLayout drawerLayout = findViewById(R.id.drawerLayout);
41+
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
42+
this, drawerLayout, toolbar, R.string.open_nav, R.string.close_nav);
43+
drawerLayout.addDrawerListener(toggle);
44+
toggle.syncState();
45+
46+
navigationView = findViewById(R.id.nav_view);
47+
navigationView.setNavigationItemSelectedListener(this);
48+
49+
ViewPager viewPager = findViewById(R.id.viewPager);
50+
TabLayout tabLayout = findViewById(R.id.tabs);
51+
viewPager.setOffscreenPageLimit(0);
52+
setupViewPager(viewPager);
53+
tabLayout.setupWithViewPager(viewPager);
54+
55+
new File(Utils.statusSaverPath).mkdirs();
56+
}
57+
58+
@Override
59+
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
60+
int id = item.getItemId();
61+
62+
//TODO
63+
64+
if (id == R.id.navRate) {
65+
Toast.makeText(this, "Option Clicked", Toast.LENGTH_SHORT).show();
66+
} else if (id == R.id.navBusinessWhatsApp) {
67+
Toast.makeText(this, "Will be implemented soon", Toast.LENGTH_SHORT).show();
68+
}
69+
70+
DrawerLayout drawerLayout = findViewById(R.id.drawerLayout);
71+
drawerLayout.closeDrawer(GravityCompat.START);
72+
return true;
73+
}
74+
75+
private void setupViewPager(ViewPager viewPager) {
76+
ViewPageAdapter adapter = new ViewPageAdapter(MainActivity.this, getSupportFragmentManager());
77+
adapter.addFragment(new WhatsAppImagesFragment(), "Images");
78+
adapter.addFragment(new WhatsAppVideosFragment(), "Videos");
79+
adapter.addFragment(new WhatsAppSavedFragment(), "Saved");
80+
viewPager.setAdapter(adapter);
81+
viewPager.setCurrentItem(0);
82+
}
83+
84+
class ViewPageAdapter extends FragmentPagerAdapter {
85+
private Context context;
86+
private final List<Fragment> fragmentList = new ArrayList<>();
87+
private final List<String> fragmentTitles = new ArrayList<>();
88+
89+
public ViewPageAdapter(Context context1, FragmentManager fragmentManager){
90+
super(fragmentManager);
91+
context = context1;
92+
}
93+
94+
@NonNull
95+
@Override
96+
public Fragment getItem(int position) {
97+
return fragmentList.get(position);
98+
}
99+
100+
@Override
101+
public int getCount() {
102+
return fragmentList.size();
103+
}
104+
105+
public void addFragment(Fragment fragment, String title) {
106+
fragmentList.add(fragment);
107+
fragmentTitles.add(title);
108+
}
109+
110+
@Nullable
111+
@Override
112+
public CharSequence getPageTitle(int position) {
113+
return fragmentTitles.get(position);
114+
}
115+
}
116+
}

0 commit comments

Comments
 (0)