Skip to content

Commit

Permalink
Update to version 3.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Udhayarajan committed Mar 1, 2022
1 parent ee9e777 commit 9b44ce5
Show file tree
Hide file tree
Showing 30 changed files with 2,430 additions and 1,151 deletions.
11 changes: 6 additions & 5 deletions .idea/deploymentTargetDropDown.xml

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

32 changes: 18 additions & 14 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ android {
applicationId "com.mugames.vidsnap"
minSdkVersion 21
targetSdkVersion 31
versionCode 8
versionName "3.1.2(beta)"
versionCode 9
versionName "3.2.0"
multiDexEnabled true


Expand Down Expand Up @@ -62,21 +62,21 @@ dependencies {
implementation 'com.google.firebase:firebase-crashlytics'
implementation 'com.google.firebase:firebase-analytics'

implementation 'androidx.appcompat:appcompat:1.3.1'
implementation "androidx.activity:activity:1.3.1"
implementation "androidx.fragment:fragment:1.3.6"
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.3.1'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1'
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation "androidx.activity:activity:1.4.0"
implementation "androidx.fragment:fragment:1.4.1"
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.4.0'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.2.1'

implementation files('libs/java-json.jar')

implementation 'androidx.preference:preference:1.1.1'
implementation 'androidx.preference:preference:1.2.0'
implementation 'com.google.firebase:firebase-config:21.0.1'
implementation 'com.google.firebase:firebase-database:20.0.2'
implementation 'com.google.firebase:firebase-database:20.0.3'

//Fetch
implementation "androidx.tonyodev.fetch2okhttp:xfetch2okhttp:3.1.6"
Expand All @@ -88,21 +88,21 @@ dependencies {

//Glide
implementation 'com.github.bumptech.glide:glide:4.12.0'
implementation 'androidx.browser:browser:1.3.0'
implementation 'androidx.browser:browser:1.4.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'


testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'

implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'androidx.appcompat:appcompat:1.4.1'




//Room
def room_version = "2.3.0"
def room_version = "2.4.1"
implementation "androidx.room:room-runtime:$room_version"
annotationProcessor "androidx.room:room-compiler:$room_version"
// optional - RxJava2 support for Room
Expand All @@ -114,4 +114,8 @@ dependencies {
// optional - Test helpers
testImplementation "androidx.room:room-testing:$room_version"

//LeakCanary
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.8.1'


}
49 changes: 29 additions & 20 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,55 +12,64 @@

<application
android:name=".VidSnapApp"
android:allowBackup="true"
android:extractNativeLibs="true"
android:largeHeap="true"
android:preserveLegacyExternalStorage="true"
android:requestLegacyExternalStorage="true"
android:hardwareAccelerated="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:largeHeap="true"
android:preserveLegacyExternalStorage="true"
android:requestLegacyExternalStorage="true"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.YouTubeDownloader"
android:allowBackup="true"
tools:targetApi="R">
<activity android:name=".ui.activities.ContactActivity"
android:theme="@style/Theme.YouTubeDownloader.NoActionBar"
android:screenOrientation="portrait"/>
<activity android:name=".ui.activities.ReportActivity"
android:theme="@style/Theme.YouTubeDownloader.NoActionBar"
android:screenOrientation="portrait"/>
<activity android:name=".ui.activities.CheckUpdateActivity"
android:theme="@style/Theme.YouTubeDownloader.NoActionBar"
android:screenOrientation="portrait"/>
<receiver
android:name=".utility.VideoSharedBroadcast"
android:enabled="true"
android:exported="false"></receiver>

<activity android:name=".ui.activities.ShareActivity"
<activity
android:name=".ui.activities.ContactActivity"
android:screenOrientation="portrait"
android:exported="true">
android:theme="@style/Theme.YouTubeDownloader.NoActionBar" />
<activity
android:name=".ui.activities.ReportActivity"
android:screenOrientation="portrait"
android:theme="@style/Theme.YouTubeDownloader.NoActionBar" />
<activity
android:name=".ui.activities.CheckUpdateActivity"
android:screenOrientation="portrait"
android:theme="@style/Theme.YouTubeDownloader.NoActionBar" />
<activity
android:name=".ui.activities.ShareActivity"
android:exported="true"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.SEND" />

<category android:name="android.intent.category.DEFAULT" />

<data android:mimeType="text/plain" />
</intent-filter>
</activity>

<activity
android:name=".ui.activities.MainActivity"
android:exported="true"
android:label="@string/app_name"
android:launchMode="singleTop"
android:screenOrientation="portrait"
android:theme="@style/Theme.YouTubeDownloader.NoActionBar"
android:exported="true">
android:theme="@style/Theme.YouTubeDownloader.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

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

<service android:name=".network.Downloader"/>
<service android:name=".network.Downloader" />

<receiver android:name=".utility.CancelDownloadReceiver"/>
<receiver android:name=".utility.CancelDownloadReceiver" />

<provider
android:name="androidx.core.content.FileProvider"
Expand Down
72 changes: 43 additions & 29 deletions app/src/main/java/com/mugames/vidsnap/extractor/Extractor.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import com.mugames.vidsnap.R;
import com.mugames.vidsnap.network.MiniExecute;
import com.mugames.vidsnap.ui.activities.MainActivity;
import com.mugames.vidsnap.utility.UtilityClass;
import com.mugames.vidsnap.utility.bundles.Formats;
import com.mugames.vidsnap.utility.Statics;
import com.mugames.vidsnap.utility.UtilityInterface;
Expand All @@ -76,9 +77,9 @@ public abstract class Extractor extends Thread {

public Formats formats;

boolean isVideoSizeReady;
boolean isAudioSizeReady;
boolean isManifestReady;
volatile boolean isVideoSizeReady;
volatile boolean isAudioSizeReady;
volatile boolean isManifestReady;
String url;


Expand Down Expand Up @@ -127,14 +128,14 @@ public void run() {
}

private void safeAnalyze() {
if(isNetworkAvailable()){
try{
if (isNetworkAvailable()) {
try {
analyze(url);
}catch (Exception e){
getDialogueInterface().error("Internal error occurred try with different link",e);
} catch (Exception e) {
getDialogueInterface().error("Internal error occurred try with different link", e);
}
}else {
getDialogueInterface().error("No network available :)",null);
} else {
getDialogueInterface().error("No network available :)", null);
}
}

Expand Down Expand Up @@ -231,7 +232,7 @@ private void getSizeForVideos() {
formats.videoSizes.set(index, size);
DecimalFormat decimalFormat = new DecimalFormat("#.##");
formats.videoSizeInString.set(index, decimalFormat.format(size / Math.pow(10, 6)));
formats.mainFileURLs.set(index,filterURLs(formats.mainFileURLs.get(index)));
formats.mainFileURLs.set(index, filterURLs(formats.mainFileURLs.get(index)));
}
isVideoSizeReady = true;
checkForCompletion();
Expand All @@ -249,7 +250,7 @@ private void getSizeForAudio() {
ArrayList<MiniExecute> miniExecutes = new ArrayList<>();

for (int i = 0; i < formats.audioURLs.size(); i++) {
if(formats.audioURLs.get(i)==null) {
if (formats.audioURLs.get(i) == null) {
formats.audioSizes.add(0L);
countDownLatch.countDown();
continue;
Expand All @@ -270,7 +271,7 @@ private void getSizeForAudio() {
int index = miniExecute.getBundle().getInt(EXTRA_INDEX);
long size = miniExecute.getSize();
formats.audioSizes.set(index, size);
formats.audioURLs.set(index,filterURLs(formats.audioURLs.get(index)));
formats.audioURLs.set(index, filterURLs(formats.audioURLs.get(index)));
}
isAudioSizeReady = true;
checkForCompletion();
Expand All @@ -294,10 +295,15 @@ public int getCookiesKey() {
return -1;
}

public void trySignIn(String notificationTxt, String url, String[] validDoneURLS, UtilityInterface.LoginIdentifier loginIdentifier) {
public void trySignIn(String notificationTxt, String url, String[] validDoneURLS,
UtilityInterface.LoginIdentifier loginIdentifier) {
String cookies = loginHelper.getCookies(getCookiesKey());
if (cookies == null)
loginHelper.signInNeeded(notificationTxt, url, validDoneURLS, getCookiesKey(), loginIdentifier);
loginHelper.signInNeeded(
new UtilityClass.LoginDetailsProvider(
notificationTxt, url, validDoneURLS, getCookiesKey(), loginIdentifier
)
);
else loginIdentifier.loggedIn(cookies);
}

Expand All @@ -307,7 +313,7 @@ private void checkForManifestCompletion() {
if (isManifestReady) completed();
}

private void checkForCompletion() {
private synchronized void checkForCompletion() {
if (isAudioSizeReady && isVideoSizeReady)
completed();
}
Expand Down Expand Up @@ -335,56 +341,64 @@ public void whatsAppStatusAnalyzed() {
@Override
public void onAnalyzeCompleted(Formats formats) {
wrappedDialogueInterface.dismiss();
new Handler(applicationContext.getMainLooper()).post(()-> analyzeCallback.onAnalyzeCompleted(formats));
new Handler(applicationContext.getMainLooper()).post(() -> analyzeCallback.onAnalyzeCompleted(formats));
}
};

DialogueInterface wrappedDialogueInterface = new DialogueInterface() {
@Override
public void show(String text) {
new Handler(applicationContext.getMainLooper()).post(()-> dialogueInterface.show(text));
new Handler(applicationContext.getMainLooper()).post(() -> {
if (dialogueInterface != null)
dialogueInterface.show(text);
});
}

@Override
public void error(String message, Exception e) {
new Handler(applicationContext.getMainLooper()).post(()-> dialogueInterface.error(message,e));
new Handler(applicationContext.getMainLooper()).post(() -> {
if (dialogueInterface != null)
dialogueInterface.error(message, e);
});
}

@Override
public void dismiss() {
new Handler(applicationContext.getMainLooper()).post(()-> dialogueInterface.dismiss());
new Handler(applicationContext.getMainLooper()).post(() -> dialogueInterface.dismiss());
}
};

public void setLink(String url) {
this.url = url;
}

boolean isNetworkAvailable(){
boolean isNetworkAvailable() {
ConnectivityManager connectivityManager = (ConnectivityManager) getContext().getSystemService(Context.CONNECTIVITY_SERVICE);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
Network network = connectivityManager.getActiveNetwork();
if(network==null) return false;
Network network = connectivityManager.getActiveNetwork();
if (network == null) return false;
NetworkCapabilities networkCapabilities = connectivityManager.getNetworkCapabilities(network);
if(networkCapabilities==null) return false;
if(networkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI)) return true;
if(networkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR)) return true;
if (networkCapabilities == null) return false;
if (networkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI)) return true;
if (networkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR))
return true;
return networkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_ETHERNET);
}else {
} else {
NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();
int type = networkInfo.getType();
switch (type){
switch (type) {
case TYPE_WIFI:
case TYPE_ETHERNET:
case TYPE_MOBILE:
return true;
default: return false;
default:
return false;
}
}

}

String filterURLs(String url){
String filterURLs(String url) {
return url.replaceAll("\\\\", "");
}
}
Loading

0 comments on commit 9b44ce5

Please sign in to comment.