breadcrumbs
This commit is contained in:
parent
e3106936b8
commit
9807b835f8
8 changed files with 101 additions and 32 deletions
|
|
@ -155,9 +155,8 @@ public class HomeRecyclerViewAdapter extends RecyclerView.Adapter<HomeRecyclerVi
|
|||
|
||||
public void setVideoList(ArrayList<Video> list, boolean reset){
|
||||
int size = videoList.size();
|
||||
if(reset || size == 0){
|
||||
videoList = new ArrayList<>();
|
||||
}
|
||||
if(reset || size == 0) clear();
|
||||
Log.e("TAG", String.valueOf(videoList.size()));
|
||||
videoList.addAll(list);
|
||||
notifyItemRangeInserted(size, videoList.size());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,11 +33,14 @@ public class YoutubeAPIManager {
|
|||
key = applicationInfo.metaData.getString("ytAPIkey");
|
||||
dbManager = new DBManager(context);
|
||||
|
||||
//get Locale
|
||||
JSONObject country = genericRequest("https://ipwho.is/");
|
||||
try{
|
||||
countryCODE = country.getString("country_code");
|
||||
}catch(Exception ignored){}
|
||||
Thread thread = new Thread(() -> {
|
||||
//get Locale
|
||||
JSONObject country = genericRequest("https://ipwho.is/");
|
||||
try{
|
||||
countryCODE = country.getString("country_code");
|
||||
}catch(Exception ignored){}
|
||||
});
|
||||
thread.start();
|
||||
|
||||
}catch(Exception ignored){
|
||||
Toast.makeText(context, "Couldn't find API Key for the request", Toast.LENGTH_SHORT).show();
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import android.os.Bundle;
|
|||
import android.os.IBinder;
|
||||
import android.text.method.ScrollingMovementMethod;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
|
@ -32,6 +33,7 @@ import com.yausername.youtubedl_android.YoutubeDL;
|
|||
import com.yausername.youtubedl_android.YoutubeDLRequest;
|
||||
import java.io.File;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import io.reactivex.Observable;
|
||||
|
|
@ -50,10 +52,11 @@ public class CustomCommandActivity extends AppCompatActivity {
|
|||
private TextView output;
|
||||
private EditText input;
|
||||
private ExtendedFloatingActionButton fab;
|
||||
private ExtendedFloatingActionButton cancelFab;
|
||||
Context context;
|
||||
|
||||
private final DownloadProgressCallback callback = (progress, etaInSeconds, line) -> CustomCommandActivity.this.runOnUiThread(() -> {
|
||||
output.append(line);
|
||||
output.append("\n"+line);
|
||||
notificationUtil.updateDownloadNotification(NotificationUtil.COMMAND_DOWNLOAD_NOTIFICATION_ID,
|
||||
line, (int) progress, 0, getString(R.string.running_ytdlp_command));
|
||||
});
|
||||
|
|
@ -88,10 +91,29 @@ public class CustomCommandActivity extends AppCompatActivity {
|
|||
|
||||
fab = findViewById(R.id.command_fab);
|
||||
fab.setOnClickListener(view -> {
|
||||
runCommand(input.getText().toString());
|
||||
if (isStoragePermissionGranted()){
|
||||
runCommand(input.getText().toString());
|
||||
}
|
||||
});
|
||||
|
||||
cancelFab = findViewById(R.id.cancel_command_fab);
|
||||
cancelFab.setOnClickListener(view -> {
|
||||
compositeDisposable.clear();
|
||||
stopDownloadService();
|
||||
swapFabs();
|
||||
running = false;
|
||||
input.setEnabled(true);
|
||||
});
|
||||
}
|
||||
|
||||
private void swapFabs(){
|
||||
int cancel = cancelFab.getVisibility();
|
||||
int start = fab.getVisibility();
|
||||
cancelFab.setVisibility(start);
|
||||
fab.setVisibility(cancel);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
super.onBackPressed();
|
||||
|
|
@ -106,10 +128,7 @@ public class CustomCommandActivity extends AppCompatActivity {
|
|||
Toast.makeText(context, "Wrong input! Try Again!", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
|
||||
fab.hide();
|
||||
input.setEnabled(false);
|
||||
|
||||
output.setText("");
|
||||
startDownloadService(getString(R.string.running_ytdlp_command), NotificationUtil.COMMAND_DOWNLOAD_NOTIFICATION_ID);
|
||||
text = text.substring(6).trim();
|
||||
|
|
@ -137,6 +156,7 @@ public class CustomCommandActivity extends AppCompatActivity {
|
|||
request.addOption("-o", youtubeDLDir.getAbsolutePath() + "/%(title)s.%(ext)s");
|
||||
|
||||
running = true;
|
||||
swapFabs();
|
||||
|
||||
Disposable disposable = Observable.fromCallable(() -> YoutubeDL.getInstance().execute(request, callback))
|
||||
.subscribeOn(Schedulers.newThread())
|
||||
|
|
@ -147,14 +167,14 @@ public class CustomCommandActivity extends AppCompatActivity {
|
|||
stopDownloadService();
|
||||
// MEDIA SCAN
|
||||
MediaScannerConnection.scanFile(context, new String[]{"/storage"}, null, null);
|
||||
fab.show();
|
||||
input.setEnabled(true);
|
||||
swapFabs();
|
||||
}, e -> {
|
||||
if (BuildConfig.DEBUG) Log.e(TAG, getString(R.string.failed_download), e);
|
||||
output.append(e.getMessage());
|
||||
running = false;
|
||||
stopDownloadService();
|
||||
fab.show();
|
||||
swapFabs();
|
||||
input.setEnabled(true);
|
||||
});
|
||||
compositeDisposable.add(disposable);
|
||||
|
|
@ -173,4 +193,14 @@ public class CustomCommandActivity extends AppCompatActivity {
|
|||
context.getApplicationContext().unbindService(serviceConnection);
|
||||
isDownloadServiceRunning = false;
|
||||
}
|
||||
|
||||
public boolean isStoragePermissionGranted() {
|
||||
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
||||
== PackageManager.PERMISSION_GRANTED) {
|
||||
return true;
|
||||
}else{
|
||||
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -342,7 +342,6 @@ public class HomeFragment extends Fragment implements HomeRecyclerViewAdapter.On
|
|||
dbManager.addToResults(resultObjects);
|
||||
new Handler(Looper.getMainLooper()).post(() -> {
|
||||
homeRecyclerViewAdapter.setVideoList(resultObjects, true);
|
||||
//addEndofResultsText();
|
||||
shimmerCards.stopShimmer();
|
||||
shimmerCards.setVisibility(View.GONE);
|
||||
});
|
||||
|
|
@ -374,6 +373,7 @@ public class HomeFragment extends Fragment implements HomeRecyclerViewAdapter.On
|
|||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
resultObjects.clear();
|
||||
resultObjects.add(youtubeAPIManager.getVideo(query));
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, e.toString());
|
||||
|
|
@ -484,7 +484,6 @@ public class HomeFragment extends Fragment implements HomeRecyclerViewAdapter.On
|
|||
|
||||
SharedPreferences sharedPreferences = context.getSharedPreferences("root_preferences", Activity.MODE_PRIVATE);
|
||||
|
||||
|
||||
boolean aria2 = sharedPreferences.getBoolean("aria2", false);
|
||||
if(aria2){
|
||||
request.addOption("--downloader", "libaria2c.so");
|
||||
|
|
@ -494,17 +493,13 @@ public class HomeFragment extends Fragment implements HomeRecyclerViewAdapter.On
|
|||
request.addOption("-N", concurrentFragments);
|
||||
}
|
||||
|
||||
|
||||
|
||||
String limitRate = sharedPreferences.getString("limit_rate", "");
|
||||
if(!limitRate.equals("")){
|
||||
request.addOption("-r", limitRate);
|
||||
}
|
||||
if(!limitRate.equals("")) request.addOption("-r", limitRate);
|
||||
|
||||
boolean writeThumbnail = sharedPreferences.getBoolean("write_thumbnail", false);
|
||||
if(writeThumbnail){
|
||||
request.addOption("--write-thumbnail");
|
||||
}
|
||||
if(writeThumbnail) request.addOption("--write-thumbnail");
|
||||
|
||||
request.addOption("--no-mtime");
|
||||
|
||||
if (type.equals("mp3")) {
|
||||
boolean removeNonMusic = sharedPreferences.getBoolean("remove_non_music", false);
|
||||
|
|
@ -513,7 +508,6 @@ public class HomeFragment extends Fragment implements HomeRecyclerViewAdapter.On
|
|||
}
|
||||
request.addOption("--postprocessor-args", "-write_id3v1 1 -id3v2_version 3");
|
||||
request.addOption("--add-metadata");
|
||||
request.addOption("--no-mtime");
|
||||
request.addOption("-x");
|
||||
String format = sharedPreferences.getString("audio_format", "");
|
||||
request.addOption("--audio-format", format);
|
||||
|
|
|
|||
|
|
@ -32,11 +32,20 @@
|
|||
android:gravity="start"
|
||||
android:maxLines="5" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/custom_command_output"
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:gravity="bottom"
|
||||
android:layout_height="wrap_content" />
|
||||
android:layout_height="wrap_content"
|
||||
android:clipToPadding="false"
|
||||
android:paddingBottom="150dp"
|
||||
>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/custom_command_output"
|
||||
android:layout_width="match_parent"
|
||||
android:gravity="bottom"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</ScrollView>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
|
@ -68,8 +77,19 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|end"
|
||||
android:layout_margin="16dp"
|
||||
android:text="Run Command"
|
||||
android:text="@string/run_command"
|
||||
app:icon="@drawable/ic_baseline_keyboard_arrow_right_24"
|
||||
/>
|
||||
|
||||
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
|
||||
android:id="@+id/cancel_command_fab"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|end"
|
||||
android:layout_margin="16dp"
|
||||
android:text="@string/cancel_download"
|
||||
android:visibility="gone"
|
||||
app:icon="@drawable/ic_delete_all"
|
||||
/>
|
||||
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
|
|
@ -64,4 +64,26 @@
|
|||
<string name="choose_range_desc">Cilëso cilën pjesë të listës do të shkarkosh. Lëre siç është që t\'i shkarkosh të gjitha</string>
|
||||
<string name="last_cant_be_smaller_than_first">Indeksi i fundit nuk mund të jetë më i vogël se indeksi i parë</string>
|
||||
<string name="first_cant_be_larger_than_last">Indeksi i parë nuk mund të jetë më i madh se indeksi i fundit</string>
|
||||
<string name="concurrent_fragments_summary">Numri i fragmenteve të një videoje që duhen shkarkuar në të njëjtën kohë</string>
|
||||
<string name="concurrent_fragments">Fragmentet e njëkohëshme</string>
|
||||
<string name="downloading">Shkarkimet</string>
|
||||
<string name="limit_rate">Limito Shpejtësinë</string>
|
||||
<string name="limit_rate_summary">Shpejtësia maksimale e shkarkimit në byte për sekond, p.sh 50K ose 4.2M</string>
|
||||
<string name="aria2_summary">Përdor Aria2c si shkarkues në vend të atij normal</string>
|
||||
<string name="remove_non_music">Hiq pjesët pa muzikë</string>
|
||||
<string name="remove_non_music_summary">Hiq segmentet e SponsorBlock që përmbajnë pjesë pa muzikë në skedarët audio</string>
|
||||
<string name="processing">Proçesimi</string>
|
||||
<string name="embed_subs">Vendos Titrat në Video</string>
|
||||
<string name="embed_subs_summary">Vendos titra brenda videos por vetëm për formatet mp4, webm dhe mkv</string>
|
||||
<string name="embed_thumb">Vendos Thumbnail</string>
|
||||
<string name="embed_thumb_summary">Vendos thumbnail si pamje e pare e videos</string>
|
||||
<string name="add_chapters">Vendos Kapituj në Video</string>
|
||||
<string name="add_chapters_summary">Merr Kapitujt / Segmentet e YouTube ose Sponsorblock dhe vendosi si kapituj për videon</string>
|
||||
<string name="save_thumb">Ruaj Thumbnail</string>
|
||||
<string name="save_thumb_summary">Vendos Thumbnail si skedar tek direktoria ku është shkarkuar sendi</string>
|
||||
<string name="audio_format">Formati i Audios</string>
|
||||
<string name="video_format">Formati i Videos</string>
|
||||
<string name="audio_quality">Kualiteti i Audios</string>
|
||||
<string name="audio_quality_summary">0 (Më i miri) 10 (Më i keqi)</string>
|
||||
<string name="cancel_download">Anulo Shkarkimin</string>
|
||||
</resources>
|
||||
|
|
@ -89,4 +89,5 @@
|
|||
<string name="audio_quality">Audio Quality</string>
|
||||
<string name="audio_quality_summary">0 (Best) 10 (Worst)</string>
|
||||
<string name="cancel_download">Cancel Download</string>
|
||||
<string name="run_command">Run Command</string>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ buildscript {
|
|||
|
||||
def versionMajor = 1
|
||||
def versionMinor = 2
|
||||
def versionPatch = 0
|
||||
def versionPatch = 1
|
||||
def versionBuild = 0 // bump for dogfood builds, public betas, etc.
|
||||
|
||||
ext {
|
||||
|
|
|
|||
Loading…
Reference in a new issue