Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
= authored and = committed Jul 23, 2020
0 parents commit 27331a9
Show file tree
Hide file tree
Showing 48 changed files with 1,574 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
35 changes: 35 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 29

defaultConfig {
applicationId "com.ig.igdownloader"
minSdkVersion 21
targetSdkVersion 29
versionCode 1
versionName "1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.3.0-alpha01'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.android.volley:volley:1.1.0'
implementation 'com.amitshekhar.android:android-networking:1.0.2'
implementation 'com.anggrayudi:android-hidden-api:28.1'
}
21 changes: 21 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Binary file added app/release/IG-Downloader V1.0.apk
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.ig.igdownloader;

import android.content.Context;

import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;

import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.*;

/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("com.ig.igdownloader", appContext.getPackageName());
}
}
28 changes: 28 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ig.igdownloader">

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>

<application
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:allowBackup="false"
android:theme="@style/AppTheme">
<activity android:name=".activities.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

</activity>
<activity android:name=".activities.MainActivity2" />
<activity android:name=".activities.ImageDownloader"/>
</application>

</manifest>
Binary file added app/src/main/ic_launcher-playstore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 44 additions & 0 deletions app/src/main/java/com/ig/igdownloader/ImagePreviewActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.ig.igdownloader;

import android.annotation.SuppressLint;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.AsyncTask;
import android.widget.ImageView;

import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;

@SuppressLint("StaticFieldLeak")
public class ImagePreviewActivity extends AsyncTask<Void, Void, Bitmap> {
final String url;
final ImageView imageView;

public ImagePreviewActivity(String url, ImageView imageView) {
this.url = url;
this.imageView = imageView;
}

@Override
protected Bitmap doInBackground(Void... voids) {
try {
URL urlConnection = new URL(url);
HttpURLConnection urlConnection1 = (HttpURLConnection) urlConnection.openConnection();
urlConnection1.setDoInput(true);
urlConnection1.connect();
InputStream input = urlConnection1.getInputStream();
return BitmapFactory.decodeStream(input);
} catch (IOException e) {
e.printStackTrace();
}
return null;
}

@Override
protected void onPostExecute(Bitmap bitmap) {
super.onPostExecute(bitmap);
imageView.setImageBitmap(bitmap);
}
}
119 changes: 119 additions & 0 deletions app/src/main/java/com/ig/igdownloader/VideoDownloaderActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
package com.ig.igdownloader;

import android.annotation.SuppressLint;
import android.app.ProgressDialog;
import android.content.Context;
import android.os.AsyncTask;
import android.os.Environment;
import android.os.PowerManager;
import android.widget.Toast;

import com.ig.igdownloader.nakul.Utils;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;

@SuppressLint("StaticFieldLeak")
public class VideoDownloaderActivity extends AsyncTask<String, Integer, String> {
ProgressDialog mProgressDialog;
final Context context;
PowerManager.WakeLock mWakeLock;
String fileN = null;

public VideoDownloaderActivity(Context context) {
this.context = context;
}

@Override
protected String doInBackground(String... strings) {
InputStream is = null;
OutputStream os = null;
HttpURLConnection connection = null;
try {
URL url = new URL(strings[0]);
connection = (HttpURLConnection) url.openConnection();
connection.connect();

if (connection.getResponseCode() != HttpURLConnection.HTTP_OK) {
return "Server returned HTTP " + connection.getResponseCode()
+ " " + connection.getResponseMessage();
}
int fileLength = connection.getContentLength();
is = connection.getInputStream();
fileN = Utils.fileName() + ".mp4";
File fileName = new File(Environment.getExternalStorageDirectory() + "/" + "IGDownloader", fileN);
// file = new File(Environment."sample.mp4");
os = new FileOutputStream(fileName);

byte[] data = new byte[4096];
long total = 0;
int count;
while ((count = is.read(data)) != -1) {
if (isCancelled()) {
is.close();
return null;
}
count += total;
if (fileLength > 0) {
publishProgress((int) total * 100 / fileLength);
os.write(data, 0, count);
}
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (is != null) {
is.close();
if (os != null) {
os.close();
}
}
} catch (IOException e) {
e.printStackTrace();
}
if (connection != null) {
connection.disconnect();
}
}
return null;
}

@Override
protected void onPreExecute() {
super.onPreExecute();
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
assert pm != null;
mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, getClass().getName());
mWakeLock.acquire(10 * 60 * 1000L /*10 minutes*/);
mProgressDialog = new ProgressDialog(this.context);
mProgressDialog.show();
}

@Override
protected void onProgressUpdate(Integer... values) {
super.onProgressUpdate(values);

mProgressDialog.setIndeterminate(false);
mProgressDialog.setMax(100);
mProgressDialog.setMessage("Downloading...");
mProgressDialog.setCancelable(false);
mProgressDialog.setProgress(values[0]);
}

@Override
protected void onPostExecute(String s) {
super.onPostExecute(s);
mWakeLock.release();
mProgressDialog.dismiss();
if (s != null)
Toast.makeText(context, "Download error: " + s, Toast.LENGTH_LONG).show();
else
Toast.makeText(context, "File downloaded", Toast.LENGTH_SHORT).show();
}
}
Loading

0 comments on commit 27331a9

Please sign in to comment.