├── app
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── drawable
│ │ │ │ ├── thumbnail.png
│ │ │ │ ├── thumbnailvideo.png
│ │ │ │ ├── ic_download.xml
│ │ │ │ ├── ic_repost.xml
│ │ │ │ ├── ic_instagram.xml
│ │ │ │ └── ic_launcher_background.xml
│ │ │ ├── mipmap-hdpi
│ │ │ │ ├── ic_launcher.webp
│ │ │ │ └── ic_launcher_round.webp
│ │ │ ├── mipmap-mdpi
│ │ │ │ ├── ic_launcher.webp
│ │ │ │ └── ic_launcher_round.webp
│ │ │ ├── mipmap-xhdpi
│ │ │ │ ├── ic_launcher.webp
│ │ │ │ └── ic_launcher_round.webp
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ ├── ic_launcher.webp
│ │ │ │ └── ic_launcher_round.webp
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ ├── ic_launcher.webp
│ │ │ │ └── ic_launcher_round.webp
│ │ │ ├── xml
│ │ │ │ ├── filepaths.xml
│ │ │ │ ├── backup_rules.xml
│ │ │ │ └── data_extraction_rules.xml
│ │ │ ├── values
│ │ │ │ ├── attrs.xml
│ │ │ │ ├── dimens.xml
│ │ │ │ ├── strings.xml
│ │ │ │ ├── colors.xml
│ │ │ │ └── styles.xml
│ │ │ ├── mipmap-anydpi-v26
│ │ │ │ ├── ic_launcher.xml
│ │ │ │ └── ic_launcher_round.xml
│ │ │ ├── menu
│ │ │ │ └── menu_main.xml
│ │ │ ├── layout
│ │ │ │ ├── instagram_button.xml
│ │ │ │ ├── instagram_list.xml
│ │ │ │ └── activity_main.xml
│ │ │ └── drawable-v24
│ │ │ │ └── ic_launcher_foreground.xml
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── bachors
│ │ │ │ └── instadownloader
│ │ │ │ ├── util
│ │ │ │ ├── Downloader.kt
│ │ │ │ ├── AndroidDownloader.kt
│ │ │ │ └── DownloadCompletedReceiver.kt
│ │ │ │ ├── net
│ │ │ │ ├── ApiInterface.kt
│ │ │ │ └── ApiIg.kt
│ │ │ │ ├── model
│ │ │ │ ├── Insta.kt
│ │ │ │ └── Data.kt
│ │ │ │ ├── adapter
│ │ │ │ └── InstaAdapter.java
│ │ │ │ └── MainActivity.java
│ │ └── AndroidManifest.xml
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── bachors
│ │ │ └── instadownloader
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── bachors
│ │ └── instadownloader
│ │ └── ExampleInstrumentedTest.java
├── proguard-rules.pro
└── build.gradle.kts
├── .idea
├── .name
├── .gitignore
├── vcs.xml
├── AndroidProjectSystem.xml
├── migrations.xml
├── misc.xml
├── deploymentTargetSelector.xml
├── gradle.xml
├── runConfigurations.xml
└── codeStyles
├── demo.png
├── gradle
├── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
└── libs.versions.toml
├── .gitignore
├── README.md
├── settings.gradle.kts
├── gradle.properties
├── gradlew.bat
└── gradlew
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/.idea/.name:
--------------------------------------------------------------------------------
1 | Insta Downloader
--------------------------------------------------------------------------------
/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 |
--------------------------------------------------------------------------------
/demo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bachors/Insta-Downloader/HEAD/demo.png
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bachors/Insta-Downloader/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/src/main/res/drawable/thumbnail.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bachors/Insta-Downloader/HEAD/app/src/main/res/drawable/thumbnail.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/thumbnailvideo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bachors/Insta-Downloader/HEAD/app/src/main/res/drawable/thumbnailvideo.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bachors/Insta-Downloader/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bachors/Insta-Downloader/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bachors/Insta-Downloader/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bachors/Insta-Downloader/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bachors/Insta-Downloader/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bachors/Insta-Downloader/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bachors/Insta-Downloader/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bachors/Insta-Downloader/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bachors/Insta-Downloader/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bachors/Insta-Downloader/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/java/com/bachors/instadownloader/util/Downloader.kt:
--------------------------------------------------------------------------------
1 | package com.bachors.instadownloader.util
2 |
3 | interface Downloader {
4 | fun downloadFile(url: String, name: String, type: String): Long
5 | }
--------------------------------------------------------------------------------
/app/src/main/res/xml/filepaths.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 | 4dp
3 | 8dp
4 | 10dp
5 | 16dp
6 |
7 |
--------------------------------------------------------------------------------
/.idea/AndroidProjectSystem.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Tue Jun 03 23:51:37 WIB 2025
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
5 | zipStoreBase=GRADLE_USER_HOME
6 | zipStorePath=wrapper/dists
7 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/caches
5 | /.idea/libraries
6 | /.idea/modules.xml
7 | /.idea/workspace.xml
8 | /.idea/navEditor.xml
9 | /.idea/assetWizardSettings.xml
10 | .DS_Store
11 | /build
12 | /captures
13 | .externalNativeBuild
14 | .cxx
15 | local.properties
16 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Insta Downloader
3 | Instagram video URL
4 | https://www.instagram.com/p/xxx/
5 | DOWNLOAD & REPOST
6 |
7 |
--------------------------------------------------------------------------------
/.idea/migrations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_download.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/java/com/bachors/instadownloader/net/ApiInterface.kt:
--------------------------------------------------------------------------------
1 | package com.bachors.instadownloader.net
2 |
3 | import okhttp3.ResponseBody
4 | import retrofit2.Call
5 | import retrofit2.http.GET
6 | import retrofit2.http.Query
7 |
8 | interface ApiInterface {
9 | @GET("exec")
10 | fun getVideo(@Query("u") postUrl: String?): Call?
11 | }
12 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #3F51B5
5 | #FF4081
6 | #FF4081
7 | #f0f1f3
8 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_repost.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Insta-Downloader
2 | Simple Video & Photo Downloader for Instagram Post & Reel. Supports downloading carousel media. .
3 |
4 | Step by step
5 | ------------
6 | - Open the InstaDownloader app
7 | - Open the Instagram app
8 | - Click on the Copy Share URL menu
9 | - Paste URL
10 | - Click the download or repost button
11 |
12 | DEMO
13 | -----
14 |
15 |
--------------------------------------------------------------------------------
/app/src/main/java/com/bachors/instadownloader/model/Insta.kt:
--------------------------------------------------------------------------------
1 | package com.bachors.instadownloader.model
2 |
3 | import com.google.gson.annotations.Expose
4 | import com.google.gson.annotations.SerializedName
5 |
6 | /**
7 | * @author Ican Bachors
8 | * @version 1.1
9 | * Source: https://github.com/bachors/Insta-Downloader
10 | */
11 | class Insta {
12 | @JvmField
13 | @SerializedName("data")
14 | @Expose
15 | val data: MutableList? = null
16 | }
17 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_main.xml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/app/src/test/java/com/bachors/instadownloader/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.bachors.instadownloader;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/app/src/main/res/xml/backup_rules.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/settings.gradle.kts:
--------------------------------------------------------------------------------
1 | pluginManagement {
2 | repositories {
3 | google {
4 | content {
5 | includeGroupByRegex("com\\.android.*")
6 | includeGroupByRegex("com\\.google.*")
7 | includeGroupByRegex("androidx.*")
8 | }
9 | }
10 | mavenCentral()
11 | gradlePluginPortal()
12 | }
13 | }
14 | dependencyResolutionManagement {
15 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
16 | repositories {
17 | google()
18 | mavenCentral()
19 | }
20 | }
21 |
22 | rootProject.name = "Insta Downloader"
23 | include(":app")
24 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/data_extraction_rules.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
12 |
13 |
19 |
--------------------------------------------------------------------------------
/app/src/main/java/com/bachors/instadownloader/model/Data.kt:
--------------------------------------------------------------------------------
1 | package com.bachors.instadownloader.model
2 |
3 | import com.google.gson.annotations.Expose
4 | import com.google.gson.annotations.SerializedName
5 |
6 | /**
7 | * @author Ican Bachors
8 | * @version 1.1
9 | * Source: https://github.com/bachors/Insta-Downloader
10 | */
11 | class Data {
12 | @JvmField
13 | @SerializedName("type")
14 | @Expose
15 | val type: String? = null
16 |
17 | @JvmField
18 | @SerializedName("url")
19 | @Expose
20 | val url: String? = null
21 |
22 | @JvmField
23 | @SerializedName("filename")
24 | @Expose
25 | val filename: String? = null
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/instagram_button.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
16 |
17 |
--------------------------------------------------------------------------------
/.idea/deploymentTargetSelector.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_instagram.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/app/src/main/java/com/bachors/instadownloader/net/ApiIg.kt:
--------------------------------------------------------------------------------
1 | package com.bachors.instadownloader.net
2 |
3 | import retrofit2.Retrofit
4 | import retrofit2.converter.gson.GsonConverterFactory
5 |
6 | object ApiIg {
7 | const val BASE_URL: String =
8 | "https://script.google.com/macros/s/AKfycbyHQ9twIO2CKf4TFsPDHrB2JARDK66yVDlUrmPukDefHnWsAAnRuFjE8DR1R-qU-nC9/"
9 | private var retrofit: Retrofit? = null
10 |
11 | @JvmStatic
12 | val client: Retrofit
13 | get() {
14 | if (retrofit == null) {
15 | retrofit = Retrofit.Builder()
16 | .baseUrl(BASE_URL)
17 | .addConverterFactory(GsonConverterFactory.create())
18 | .build()
19 | }
20 | return retrofit!!
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
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
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/bachors/instadownloader/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.bachors.instadownloader;
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 Testing documentation
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.bachors.instadownloader", appContext.getPackageName());
25 | }
26 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/bachors/instadownloader/util/AndroidDownloader.kt:
--------------------------------------------------------------------------------
1 | package com.bachors.instadownloader.util
2 |
3 | import android.app.DownloadManager
4 | import android.content.Context
5 | import android.os.Environment
6 | import androidx.core.net.toUri
7 |
8 | class AndroidDownloader(
9 | context: Context
10 | ): Downloader {
11 |
12 | private val downloadManager = context.getSystemService(DownloadManager::class.java)
13 |
14 | override fun downloadFile(url: String, name: String, type: String): Long {
15 | val request = DownloadManager.Request(url.toUri())
16 | .setMimeType("""$type/*""")
17 | .setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI or DownloadManager.Request.NETWORK_MOBILE)
18 | .setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED)
19 | .setTitle(name)
20 | .setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, name)
21 | return downloadManager.enqueue(request)
22 | }
23 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/bachors/instadownloader/util/DownloadCompletedReceiver.kt:
--------------------------------------------------------------------------------
1 | package com.bachors.instadownloader.util
2 |
3 | import android.app.DownloadManager
4 | import android.content.BroadcastReceiver
5 | import android.content.Context
6 | import android.content.Intent
7 | import android.widget.Toast
8 | import com.bachors.instadownloader.MainActivity
9 |
10 | class DownloadCompletedReceiver: BroadcastReceiver() {
11 |
12 | override fun onReceive(context: Context?, intent: Intent?) {
13 | if(intent?.action == "android.intent.action.DOWNLOAD_COMPLETE") {
14 | val id = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, -1L)
15 | if(id != -1L) {
16 | println("Download with ID $id finished!")
17 | if (MainActivity.loading.isShowing) {
18 | MainActivity.loading.dismiss()
19 | }
20 | Toast.makeText(context, "Download with ID $id finished!", Toast.LENGTH_LONG).show()
21 | }
22 | }
23 | }
24 | }
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. For more details, visit
12 | # https://developer.android.com/r/tools/gradle-multi-project-decoupled-projects
13 | # org.gradle.parallel=true
14 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app's APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Enables namespacing of each library's R class so that its R class includes only the
19 | # resources declared in the library itself and none from the library's dependencies,
20 | # thereby reducing the size of the R class for that library
21 | android.nonTransitiveRClass=true
--------------------------------------------------------------------------------
/app/src/main/res/layout/instagram_list.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
14 |
20 |
21 |
26 |
27 |
28 |
29 |
39 |
40 |
--------------------------------------------------------------------------------
/app/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | alias(libs.plugins.android.application)
3 | alias(libs.plugins.kotlin.android)
4 | }
5 |
6 | android {
7 | namespace = "com.bachors.instadownloader"
8 | compileSdk = 36
9 |
10 | defaultConfig {
11 | applicationId = "com.bachors.instadownloader"
12 | minSdk = 23
13 | targetSdk = 36
14 | versionCode = 1
15 | versionName = "1.0"
16 |
17 | testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
18 | }
19 |
20 | buildTypes {
21 | release {
22 | isMinifyEnabled = false
23 | proguardFiles(
24 | getDefaultProguardFile("proguard-android-optimize.txt"),
25 | "proguard-rules.pro"
26 | )
27 | }
28 | }
29 | compileOptions {
30 | sourceCompatibility = JavaVersion.VERSION_17
31 | targetCompatibility = JavaVersion.VERSION_17
32 | }
33 | buildFeatures {
34 | viewBinding = true
35 | }
36 | kotlinOptions {
37 | jvmTarget = "17"
38 | }
39 | }
40 |
41 | dependencies {
42 |
43 | implementation(libs.appcompat)
44 | implementation(libs.material)
45 | implementation(libs.constraintlayout)
46 | implementation(libs.retrofit)
47 | implementation(libs.converter.gson)
48 | implementation(libs.logging.interceptor)
49 | implementation(libs.glide)
50 | implementation(libs.core.ktx)
51 | implementation(libs.media3.exoplayer)
52 | implementation(libs.media3.exoplayer.dash)
53 | implementation(libs.media3.ui)
54 | testImplementation(libs.junit)
55 | androidTestImplementation(libs.ext.junit)
56 | androidTestImplementation(libs.espresso.core)
57 | }
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
15 |
18 |
21 |
22 |
23 |
24 |
30 |
--------------------------------------------------------------------------------
/gradle/libs.versions.toml:
--------------------------------------------------------------------------------
1 | [versions]
2 | agp = "8.10.1"
3 | glide = "4.11.0"
4 | junit = "4.13.2"
5 | junitVersion = "1.2.1"
6 | espressoCore = "3.6.1"
7 | appcompat = "1.7.0"
8 | material = "1.12.0"
9 | constraintlayout = "2.2.1"
10 | loggingInterceptor = "3.4.1"
11 | retrofit = "2.0.2"
12 | kotlin = "2.1.21"
13 | coreKtx = "1.16.0"
14 | media3Exoplayer = "1.6.1"
15 |
16 | [libraries]
17 | glide = { module = "com.github.bumptech.glide:glide", version.ref = "glide" }
18 | junit = { group = "junit", name = "junit", version.ref = "junit" }
19 | ext-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" }
20 | espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" }
21 | appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" }
22 | material = { group = "com.google.android.material", name = "material", version.ref = "material" }
23 | constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" }
24 | logging-interceptor = { module = "com.squareup.okhttp3:logging-interceptor", version.ref = "loggingInterceptor" }
25 | retrofit = { module = "com.squareup.retrofit2:retrofit", version.ref = "retrofit" }
26 | converter-gson = { module = "com.squareup.retrofit2:converter-gson", version.ref = "retrofit" }
27 | core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
28 | media3-exoplayer = { module = "androidx.media3:media3-exoplayer", version.ref = "media3Exoplayer" }
29 | media3-exoplayer-dash = { module = "androidx.media3:media3-exoplayer-dash", version.ref = "media3Exoplayer" }
30 | media3-ui = { module = "androidx.media3:media3-ui", version.ref = "media3Exoplayer" }
31 |
32 | [plugins]
33 | android-application = { id = "com.android.application", version.ref = "agp" }
34 | kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
35 |
36 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
15 |
16 |
22 |
23 |
27 |
28 |
40 |
41 |
42 |
43 |
48 |
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
21 |
26 |
29 |
30 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%" == "" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%" == "" set DIRNAME=.
29 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34 |
35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
37 |
38 | @rem Find java.exe
39 | if defined JAVA_HOME goto findJavaFromJavaHome
40 |
41 | set JAVA_EXE=java.exe
42 | %JAVA_EXE% -version >NUL 2>&1
43 | if "%ERRORLEVEL%" == "0" goto execute
44 |
45 | echo.
46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47 | echo.
48 | echo Please set the JAVA_HOME variable in your environment to match the
49 | echo location of your Java installation.
50 |
51 | goto fail
52 |
53 | :findJavaFromJavaHome
54 | set JAVA_HOME=%JAVA_HOME:"=%
55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56 |
57 | if exist "%JAVA_EXE%" goto execute
58 |
59 | echo.
60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61 | echo.
62 | echo Please set the JAVA_HOME variable in your environment to match the
63 | echo location of your Java installation.
64 |
65 | goto fail
66 |
67 | :execute
68 | @rem Setup the command line
69 |
70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
71 |
72 |
73 | @rem Execute Gradle
74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
75 |
76 | :end
77 | @rem End local scope for the variables with windows NT shell
78 | if "%ERRORLEVEL%"=="0" goto mainEnd
79 |
80 | :fail
81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
82 | rem the _cmd.exe /c_ return code!
83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84 | exit /b 1
85 |
86 | :mainEnd
87 | if "%OS%"=="Windows_NT" endlocal
88 |
89 | :omega
90 |
--------------------------------------------------------------------------------
/.idea/codeStyles:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | xmlns:android
16 |
17 | ^$
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 | xmlns:.*
27 |
28 | ^$
29 |
30 |
31 | BY_NAME
32 |
33 |
34 |
35 |
36 |
37 |
38 | .*:id
39 |
40 | http://schemas.android.com/apk/res/android
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 | .*:name
50 |
51 | http://schemas.android.com/apk/res/android
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 | name
61 |
62 | ^$
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 | style
72 |
73 | ^$
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 | .*
83 |
84 | ^$
85 |
86 |
87 | BY_NAME
88 |
89 |
90 |
91 |
92 |
93 |
94 | .*
95 |
96 | http://schemas.android.com/apk/res/android
97 |
98 |
99 | ANDROID_ATTRIBUTE_ORDER
100 |
101 |
102 |
103 |
104 |
105 |
106 | .*
107 |
108 | .*
109 |
110 |
111 | BY_NAME
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
--------------------------------------------------------------------------------
/app/src/main/java/com/bachors/instadownloader/adapter/InstaAdapter.java:
--------------------------------------------------------------------------------
1 | package com.bachors.instadownloader.adapter;
2 |
3 | import static com.bachors.instadownloader.MainActivity.loading;
4 |
5 | import android.content.Context;
6 | import android.content.Intent;
7 | import android.net.Uri;
8 | import android.os.Environment;
9 | import android.view.LayoutInflater;
10 | import android.view.View;
11 | import android.view.ViewGroup;
12 | import android.widget.ImageView;
13 | import android.widget.TextView;
14 |
15 | import androidx.annotation.NonNull;
16 | import androidx.media3.common.MediaItem;
17 | import androidx.media3.common.MediaMetadata;
18 | import androidx.media3.exoplayer.ExoPlayer;
19 | import androidx.media3.ui.PlayerView;
20 | import androidx.recyclerview.widget.RecyclerView;
21 |
22 | import com.bachors.instadownloader.R;
23 | import com.bachors.instadownloader.model.Data;
24 | import com.bachors.instadownloader.util.AndroidDownloader;
25 | import com.bumptech.glide.Glide;
26 |
27 | import java.io.File;
28 | import java.util.ArrayList;
29 | import java.util.List;
30 |
31 | public class InstaAdapter extends RecyclerView.Adapter {
32 |
33 | private List semuaData;
34 | private final Context inContext;
35 | private ExoPlayer player = null;
36 | AndroidDownloader adl;
37 |
38 | public InstaAdapter(Context context) {
39 | this.inContext = context;
40 | semuaData = new ArrayList<>();
41 | }
42 |
43 | public List getData() {
44 | return semuaData;
45 | }
46 |
47 | public void setData(List semuaData) {
48 | this.semuaData = semuaData;
49 | }
50 |
51 | @Override
52 | public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
53 | RecyclerView.ViewHolder viewHolder = null;
54 | LayoutInflater inflater = LayoutInflater.from(parent.getContext());
55 |
56 | viewHolder = getViewHolder(parent, inflater);
57 | return viewHolder;
58 | }
59 |
60 | @NonNull
61 | private RecyclerView.ViewHolder getViewHolder(ViewGroup parent, LayoutInflater inflater) {
62 | RecyclerView.ViewHolder viewHolder;
63 | View v = inflater.inflate(R.layout.instagram_list, parent, false);
64 | viewHolder = new inVH(v);
65 | return viewHolder;
66 | }
67 |
68 | @Override
69 | public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) {
70 |
71 | Data data = semuaData.get(position);
72 |
73 | final inVH inVH = (inVH) holder;
74 |
75 | adl = new AndroidDownloader(inContext);
76 |
77 | if(data.type.equals("Video")){
78 | inVH.image.setVisibility(View.GONE);
79 | inVH.video.setVisibility(View.VISIBLE);
80 |
81 | MediaItem mediaItem = new MediaItem.Builder()
82 | .setUri(Uri.parse(data.url))
83 | .setMediaMetadata(new MediaMetadata.Builder().setTitle(data.filename).build())
84 | .build();
85 |
86 | player = new ExoPlayer.Builder(inContext).build();
87 | inVH.video.setPlayer(player);
88 | player.setMediaItem(mediaItem);
89 | player.prepare();
90 | player.setPlayWhenReady(true);
91 | }else{
92 | inVH.video.setVisibility(View.GONE);
93 | inVH.image.setVisibility(View.VISIBLE);
94 | Glide.with(inContext).load(data.url).into(inVH.image);
95 | }
96 |
97 | inVH.repost.setOnClickListener(view -> {
98 | File filePath = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), data.filename);
99 | if(filePath.exists()){
100 | Intent i = new Intent();
101 | i.setAction(Intent.ACTION_SEND);
102 | i.setType(data.type.toLowerCase() + "/*");
103 | i.putExtra(Intent.EXTRA_STREAM, Uri.parse(filePath.toString()));
104 | i.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
105 | inContext.startActivity(i);
106 | }else {
107 | loading.show();
108 | adl.downloadFile(data.url, data.filename, data.type.toLowerCase());
109 | }
110 | });
111 |
112 | }
113 |
114 | @Override
115 | public int getItemCount() {
116 | return semuaData == null ? 0 : semuaData.size();
117 | }
118 |
119 | public void add(Data r) {
120 | semuaData.add(r);
121 | notifyItemInserted(semuaData.size() - 1);
122 | }
123 |
124 | public void addAll(List semuaData) {
125 | for (Data data : semuaData) {
126 | add(data);
127 | }
128 | }
129 |
130 | public void remove(Data r) {
131 | int position = semuaData.indexOf(r);
132 | if (position > -1) {
133 | semuaData.remove(position);
134 | notifyItemRemoved(position);
135 | }
136 | }
137 |
138 | public void clear() {
139 | while (getItemCount() > 0) {
140 | remove(getItem(0));
141 | }
142 | }
143 |
144 | public boolean isEmpty() {
145 | return getItemCount() == 0;
146 | }
147 |
148 | public Data getItem(int position) {
149 | return semuaData.get(position);
150 | }
151 |
152 | protected class inVH extends RecyclerView.ViewHolder {
153 | private final ImageView image;
154 | private final PlayerView video;
155 | private final TextView repost;
156 |
157 | public inVH(View itemView) {
158 | super(itemView);
159 |
160 | image = itemView.findViewById(R.id.image);
161 | video = itemView.findViewById(R.id.video);
162 | repost = itemView.findViewById(R.id.repost);
163 |
164 | }
165 | }
166 |
167 | }
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | #
4 | # Copyright 2015 the original author or authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # https://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | ##############################################################################
20 | ##
21 | ## Gradle start up script for UN*X
22 | ##
23 | ##############################################################################
24 |
25 | # Attempt to set APP_HOME
26 | # Resolve links: $0 may be a link
27 | PRG="$0"
28 | # Need this for relative symlinks.
29 | while [ -h "$PRG" ] ; do
30 | ls=`ls -ld "$PRG"`
31 | link=`expr "$ls" : '.*-> \(.*\)$'`
32 | if expr "$link" : '/.*' > /dev/null; then
33 | PRG="$link"
34 | else
35 | PRG=`dirname "$PRG"`"/$link"
36 | fi
37 | done
38 | SAVED="`pwd`"
39 | cd "`dirname \"$PRG\"`/" >/dev/null
40 | APP_HOME="`pwd -P`"
41 | cd "$SAVED" >/dev/null
42 |
43 | APP_NAME="Gradle"
44 | APP_BASE_NAME=`basename "$0"`
45 |
46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
48 |
49 | # Use the maximum available, or set MAX_FD != -1 to use that value.
50 | MAX_FD="maximum"
51 |
52 | warn () {
53 | echo "$*"
54 | }
55 |
56 | die () {
57 | echo
58 | echo "$*"
59 | echo
60 | exit 1
61 | }
62 |
63 | # OS specific support (must be 'true' or 'false').
64 | cygwin=false
65 | msys=false
66 | darwin=false
67 | nonstop=false
68 | case "`uname`" in
69 | CYGWIN* )
70 | cygwin=true
71 | ;;
72 | Darwin* )
73 | darwin=true
74 | ;;
75 | MINGW* )
76 | msys=true
77 | ;;
78 | NONSTOP* )
79 | nonstop=true
80 | ;;
81 | esac
82 |
83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
84 |
85 |
86 | # Determine the Java command to use to start the JVM.
87 | if [ -n "$JAVA_HOME" ] ; then
88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
89 | # IBM's JDK on AIX uses strange locations for the executables
90 | JAVACMD="$JAVA_HOME/jre/sh/java"
91 | else
92 | JAVACMD="$JAVA_HOME/bin/java"
93 | fi
94 | if [ ! -x "$JAVACMD" ] ; then
95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
96 |
97 | Please set the JAVA_HOME variable in your environment to match the
98 | location of your Java installation."
99 | fi
100 | else
101 | JAVACMD="java"
102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
103 |
104 | Please set the JAVA_HOME variable in your environment to match the
105 | location of your Java installation."
106 | fi
107 |
108 | # Increase the maximum file descriptors if we can.
109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
110 | MAX_FD_LIMIT=`ulimit -H -n`
111 | if [ $? -eq 0 ] ; then
112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
113 | MAX_FD="$MAX_FD_LIMIT"
114 | fi
115 | ulimit -n $MAX_FD
116 | if [ $? -ne 0 ] ; then
117 | warn "Could not set maximum file descriptor limit: $MAX_FD"
118 | fi
119 | else
120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
121 | fi
122 | fi
123 |
124 | # For Darwin, add options to specify how the application appears in the dock
125 | if $darwin; then
126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
127 | fi
128 |
129 | # For Cygwin or MSYS, switch paths to Windows format before running java
130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
133 |
134 | JAVACMD=`cygpath --unix "$JAVACMD"`
135 |
136 | # We build the pattern for arguments to be converted via cygpath
137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
138 | SEP=""
139 | for dir in $ROOTDIRSRAW ; do
140 | ROOTDIRS="$ROOTDIRS$SEP$dir"
141 | SEP="|"
142 | done
143 | OURCYGPATTERN="(^($ROOTDIRS))"
144 | # Add a user-defined pattern to the cygpath arguments
145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
147 | fi
148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
149 | i=0
150 | for arg in "$@" ; do
151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
153 |
154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
156 | else
157 | eval `echo args$i`="\"$arg\""
158 | fi
159 | i=`expr $i + 1`
160 | done
161 | case $i in
162 | 0) set -- ;;
163 | 1) set -- "$args0" ;;
164 | 2) set -- "$args0" "$args1" ;;
165 | 3) set -- "$args0" "$args1" "$args2" ;;
166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
172 | esac
173 | fi
174 |
175 | # Escape application args
176 | save () {
177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
178 | echo " "
179 | }
180 | APP_ARGS=`save "$@"`
181 |
182 | # Collect all arguments for the java command, following the shell quoting and substitution rules
183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
184 |
185 | exec "$JAVACMD" "$@"
186 |
--------------------------------------------------------------------------------
/app/src/main/java/com/bachors/instadownloader/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.bachors.instadownloader;
2 |
3 | import static android.content.ContentValues.TAG;
4 |
5 | import android.content.ActivityNotFoundException;
6 | import android.content.Context;
7 | import android.content.Intent;
8 | import android.os.Build;
9 | import android.os.Bundle;
10 |
11 | import androidx.activity.EdgeToEdge;
12 | import androidx.activity.result.ActivityResultLauncher;
13 | import androidx.activity.result.contract.ActivityResultContracts;
14 | import androidx.appcompat.app.AlertDialog;
15 | import androidx.appcompat.app.AppCompatActivity;
16 | import androidx.recyclerview.widget.DefaultItemAnimator;
17 | import androidx.recyclerview.widget.LinearLayoutManager;
18 |
19 | import android.util.Log;
20 | import android.view.KeyEvent;
21 | import android.view.View;
22 |
23 | import com.bachors.instadownloader.adapter.InstaAdapter;
24 | import com.bachors.instadownloader.databinding.ActivityMainBinding;
25 | import com.bachors.instadownloader.model.Data;
26 | import com.bachors.instadownloader.model.Insta;
27 | import com.bachors.instadownloader.net.ApiIg;
28 | import com.bachors.instadownloader.net.ApiInterface;
29 | import com.google.gson.Gson;
30 |
31 | import android.view.Menu;
32 | import android.view.MenuItem;
33 | import android.widget.Button;
34 | import android.widget.Toast;
35 |
36 | import org.json.JSONException;
37 | import org.json.JSONObject;
38 |
39 | import java.io.IOException;
40 | import java.util.ArrayList;
41 | import java.util.List;
42 | import java.util.Objects;
43 |
44 | import okhttp3.ResponseBody;
45 | import retrofit2.Call;
46 | import retrofit2.Callback;
47 | import retrofit2.Response;
48 |
49 | /**
50 | * @author Ican Bachors
51 | * @version 2.0
52 | * Source: https://github.com/bachors/Insta-Downloader
53 | */
54 |
55 | public class MainActivity extends AppCompatActivity {
56 |
57 | private ActivityMainBinding binding;
58 | Context con;
59 | private final String postUri = "https://www.instagram.com/p/";
60 | private final String reeltUri = "https://www.instagram.com/reel/";
61 | ApiInterface apiService;
62 | public static AlertDialog loading;
63 | List post = new ArrayList<>();
64 | InstaAdapter instaAdapter;
65 |
66 | @Override
67 | protected void onCreate(Bundle savedInstanceState) {
68 | EdgeToEdge.enable(this);
69 | super.onCreate(savedInstanceState);
70 | getSupportActionBar();
71 | Objects.requireNonNull(getSupportActionBar()).setElevation(0);
72 |
73 | con = this;
74 |
75 | binding = ActivityMainBinding.inflate(getLayoutInflater());
76 | setContentView(binding.getRoot());
77 |
78 | if (Build.VERSION.SDK_INT >= 30) {
79 | String[] permissions = new String[]{
80 | android.Manifest.permission.READ_EXTERNAL_STORAGE
81 | };
82 | permissionLauncherMultiple.launch(permissions);
83 | }else{
84 | String[] permissions = new String[]{
85 | android.Manifest.permission.READ_EXTERNAL_STORAGE,
86 | android.Manifest.permission.WRITE_EXTERNAL_STORAGE
87 | };
88 | permissionLauncherMultiple.launch(permissions);
89 | }
90 |
91 | apiService = ApiIg.getClient().create(ApiInterface.class);
92 |
93 | AlertDialog.Builder builder2 = new AlertDialog.Builder(this);
94 | builder2.setCancelable(false);
95 | builder2.setMessage("Please wait...");
96 | loading = builder2.create();
97 |
98 | instaAdapter = new InstaAdapter(this);
99 | LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
100 | binding.rv.setLayoutManager(linearLayoutManager);
101 | binding.rv.setItemAnimator(new DefaultItemAnimator());
102 | binding.rv.setAdapter(instaAdapter);
103 |
104 | binding.inur.setOnKeyListener((v, keyCode, event) -> {
105 | // If the event is a key-down event on the "enter" button
106 | if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) {
107 | String url = binding.inur.getText().toString().trim();
108 | if(url.matches(postUri + "(.*)") || url.matches(reeltUri + "(.*)")){
109 | loading.show();
110 | getData(url);
111 | }else{
112 | Toast.makeText(getApplicationContext(), "URL not valid.", Toast.LENGTH_SHORT).show();
113 | }
114 | return true;
115 | }
116 | return false;
117 | });
118 |
119 | Intent intent = getIntent();
120 | String action = intent.getAction();
121 | assert action != null;
122 | if (action.equals(Intent.ACTION_SEND)) {
123 | String url = intent.getStringExtra(Intent.EXTRA_TEXT);
124 | if (url != null) {
125 | if(url.matches(postUri + "(.*)") || url.matches(reeltUri + "(.*)")){
126 | loading.show();
127 | getData(url);
128 | }else{
129 | Toast.makeText(getApplicationContext(), "URL not valid.", Toast.LENGTH_SHORT).show();
130 | }
131 | }
132 | }
133 |
134 | }
135 |
136 | private void getData(String url) {
137 | Objects.requireNonNull(apiService.getVideo(url))
138 | .enqueue(new Callback<>() {
139 | @Override
140 | public void onResponse(Call call, Response response) {
141 | if (response.isSuccessful()) {
142 | try {
143 | JSONObject jsonRESULTS = new JSONObject(response.body().string());
144 | if (jsonRESULTS.has("message")) {
145 | if(loading.isShowing()){
146 | loading.dismiss();
147 | }
148 | Toast.makeText(getApplicationContext(), jsonRESULTS.getString("message"), Toast.LENGTH_SHORT).show();
149 | } else {
150 | if (loading.isShowing()) {
151 | loading.dismiss();
152 | }
153 | Gson gson = new Gson();
154 | final Insta insta = gson.fromJson(jsonRESULTS.toString(), Insta.class);
155 | post = insta.data;
156 | instaAdapter.clear();
157 | instaAdapter.addAll(post);
158 | }
159 | } catch (JSONException | IOException e) {
160 | e.printStackTrace();
161 | if(loading.isShowing()){
162 | loading.dismiss();
163 | }
164 | Toast.makeText(getApplicationContext(), "URL not valid.", Toast.LENGTH_SHORT).show();
165 | }
166 | } else {
167 | if(loading.isShowing()){
168 | loading.dismiss();
169 | }
170 | Toast.makeText(getApplicationContext(), "URL not valid.", Toast.LENGTH_SHORT).show();
171 | }
172 | }
173 |
174 | @Override
175 | public void onFailure(Call call, Throwable t) {
176 | Log.e("debug", "onFailure: ERROR > " + t.toString());
177 | if(loading.isShowing()){
178 | loading.dismiss();
179 | }
180 | Toast.makeText(getApplicationContext(), "URL not valid.", Toast.LENGTH_SHORT).show();
181 | }
182 | });
183 | }
184 |
185 | @Override
186 | public boolean onCreateOptionsMenu(Menu menu) {
187 | // Inflate the menu; this adds items to the action bar if it is present.
188 | getMenuInflater().inflate(R.menu.menu_main, menu);
189 | return true;
190 | }
191 |
192 | @Override
193 | public boolean onPrepareOptionsMenu(Menu menu) {
194 | MenuItem actionViewItem = menu.findItem(R.id.instagram);
195 | View v = actionViewItem.getActionView();
196 | Button x = v.findViewById(R.id.btn_instagram);
197 | x.setOnClickListener(v1 -> {
198 | Intent launchIntent = getPackageManager().getLaunchIntentForPackage("com.instagram.android");
199 | if (launchIntent != null)
200 | {
201 | try
202 | {
203 | startActivity(launchIntent);
204 | }
205 | catch (ActivityNotFoundException ex)
206 | {
207 | ex.printStackTrace();
208 | }
209 | }
210 | });
211 | return super.onPrepareOptionsMenu(menu);
212 | }
213 |
214 | @Override
215 | public boolean onOptionsItemSelected(MenuItem item) {
216 |
217 | int id = item.getItemId();
218 |
219 | //noinspection SimplifiableIfStatement
220 | if (id == R.id.instagram) {
221 | Intent launchIntent = getPackageManager().getLaunchIntentForPackage("com.instagram.android");
222 | if (launchIntent != null)
223 | {
224 | try
225 | {
226 | startActivity(launchIntent);
227 | }
228 | catch (ActivityNotFoundException ex)
229 | {
230 | ex.printStackTrace();
231 | }
232 | }
233 | }
234 |
235 | return super.onOptionsItemSelected(item);
236 | }
237 |
238 | private final ActivityResultLauncher permissionLauncherMultiple = registerForActivityResult(
239 | new ActivityResultContracts.RequestMultiplePermissions(),
240 | result -> {
241 | // here we will check if permissions were now (from permission request dialog) or already granted or not
242 |
243 | boolean allAreGranted = true;
244 | for (boolean isGranted : result.values()) {
245 | Log.d(TAG, "onActivityResult: isGranted: " + isGranted);
246 | allAreGranted = allAreGranted && isGranted;
247 | }
248 |
249 | if (!allAreGranted) {
250 | // All or some Permissions were denied so can't do the task that requires that permission
251 | Log.d(TAG, "onActivityResult: All or some permissions denied...");
252 | // Toast.makeText(this, "All or some permissions denied...", Toast.LENGTH_SHORT).show();
253 | }
254 | }
255 | );
256 |
257 | }
--------------------------------------------------------------------------------