-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
=
authored and
=
committed
Jul 23, 2020
0 parents
commit 27331a9
Showing
48 changed files
with
1,574 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 not shown.
26 changes: 26 additions & 0 deletions
26
app/src/androidTest/java/com/ig/igdownloader/ExampleInstrumentedTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
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
44
app/src/main/java/com/ig/igdownloader/ImagePreviewActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
119
app/src/main/java/com/ig/igdownloader/VideoDownloaderActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
Oops, something went wrong.