Skip to content

Commit

Permalink
redesign with material design 2
Browse files Browse the repository at this point in the history
  • Loading branch information
tastelessjolt committed Aug 27, 2018
1 parent bf19e69 commit c0f0c40
Show file tree
Hide file tree
Showing 24 changed files with 1,784 additions and 102 deletions.
17 changes: 17 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>youtube-dl-android</name>
<comment>Project youtube-dl-android created by Buildship.</comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
</natures>
</projectDescription>
8 changes: 8 additions & 0 deletions .settings/org.eclipse.buildship.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
auto.sync=false
build.scans.enabled=false
connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)
connection.project.dir=
eclipse.preferences.version=1
gradle.user.home=
offline.mode=false
override.workspace.settings=true
6 changes: 6 additions & 0 deletions app/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/>
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
<classpathentry kind="output" path="bin/default"/>
</classpath>
23 changes: 23 additions & 0 deletions app/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>app</name>
<comment>Project app created by Buildship.</comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
</natures>
</projectDescription>
2 changes: 2 additions & 0 deletions app/.settings/org.eclipse.buildship.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
connection.project.dir=..
eclipse.preferences.version=1
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.MaterialComponents.Light">
android:theme="@style/Theme.MaterialComponents.Light.NoActionBar">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
9 changes: 6 additions & 3 deletions app/src/main/java/me/harshithgoka/youtubedl/Extractor.java
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,10 @@ public String getID (String url) {
return m.group(2);
}

public List<Format> getFormats(String you_url) {
public VideoInfo getFormats(String you_url) {
String response;
String video_id = "";
String thumbnail_url = "";
JSONObject ret = new JSONObject();

try {
Expand Down Expand Up @@ -262,7 +264,7 @@ else if (params.contains("s")) {

for (String param: params) {
if (param.equals("itag")) {
f.itag = Integer.parseInt(query_pairs.get(param));
f.setItag(Integer.parseInt(query_pairs.get(param)));
}

if (param.equals("type")) {
Expand All @@ -277,7 +279,8 @@ else if (params.contains("s")) {
formats.add(f);
}

return formats;
VideoInfo videoInfo = new VideoInfo(video_id, thumbnail_url, formats);
return videoInfo;


} catch (IOException e) {
Expand Down
30 changes: 27 additions & 3 deletions app/src/main/java/me/harshithgoka/youtubedl/Format.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ public class Format implements Parcelable {
public String url;
public String quality;
public String type;

public String extension;
public String description;
public String content;

public boolean audio, video;

public Format (String title) {
this.title = title;
Expand All @@ -38,10 +40,24 @@ protected Format(Parcel in) {
type = in.readString();

extension = Utils.getExtension(this);
title = Utils.getTitle(this);
content = Utils.getTitle(this);
description = Utils.getDescription(this);
}

public void setFormat(Format fmt) {
title = fmt.title;
itag = fmt.itag;
url = fmt.url;
quality = fmt.quality;
type = fmt.type;
extension = fmt.extension;
description = fmt.description;
content = fmt.content;

audio = fmt.audio;
video = fmt.video;
}

public static final Creator<Format> CREATOR = new Creator<Format>() {
@Override
public Format createFromParcel(Parcel in) {
Expand All @@ -54,13 +70,21 @@ public Format[] newArray(int size) {
}
};

public void setItag(int itag) {
this.itag = itag;

extension = Utils.getExtension(this);
content = Utils.getTitle(this);
description = Utils.getDescription(this);
}

@Override
public int describeContents() {
return 0;
}

@Override
public void writeToParcel(Parcel parcel, int i) {
public void writeToParcel(Parcel parcel, int flags) {
parcel.writeInt(itag);
parcel.writeString(url);
parcel.writeString(quality);
Expand Down
37 changes: 18 additions & 19 deletions app/src/main/java/me/harshithgoka/youtubedl/FormatAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@
import android.content.Context;
import android.net.Uri;
import androidx.recyclerview.widget.RecyclerView;
import me.harshithgoka.youtubedl.Utils.Utils;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.Toast;

import java.util.ArrayList;
import java.util.List;
import java.util.Locale;

/**
* Created by harshithgoka on 12/16/2017 AD.
Expand All @@ -24,19 +26,25 @@ public class FormatAdapter extends RecyclerView.Adapter<FormatAdapter.MyViewHold
Context context;

class MyViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
public TextView quality, type, itag, url;
public TextView quality, itag, ext;
public View audio, video;

public MyViewHolder(View itemView) {
super(itemView);
quality = itemView.findViewById(R.id.format_quality);
type = itemView.findViewById(R.id.format_type);
itag = itemView.findViewById(R.id.format_itag);
url = itemView.findViewById(R.id.format_url);
ext = itemView.findViewById(R.id.format_ext);
audio = itemView.findViewById(R.id.audio);
video = itemView.findViewById(R.id.video);

// This is nice!
// https://stackoverflow.com/questions/31627073/why-does-onclicklistener-on-a-viewholder-dont-work
itemView.setOnClickListener(this);
}

@Override
public void onClick(View view) {
String finalurl = ((TextView) view.findViewById(R.id.format_url)).getText().toString();
String finalurl = ((TextView) view.findViewById(R.id.format_ext)).getText().toString();

ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
assert clipboard != null;
Expand Down Expand Up @@ -65,21 +73,12 @@ public FormatAdapter.MyViewHolder onCreateViewHolder(ViewGroup parent, int viewT
@Override
public void onBindViewHolder(final FormatAdapter.MyViewHolder holder, int position) {
Format format = formats.get(position);
if (format.quality != null)
holder.quality.setText(format.quality);
else
holder.quality.setText("Quality not defined");
if (format.type != null)
holder.type.setText(format.title);
else
holder.type.setText("Type not defined");

if (format.url != null)
holder.url.setText(format.description);
else
holder.url.setText("URL not found");
holder.quality.setText(Utils.getTitle(format));
holder.ext.setText(format.extension);
holder.itag.setText(String.format(Locale.UK, "%d", format.itag));

holder.itag.setText(format.itag + "");
holder.audio.setBackgroundResource(format.audio ? R.drawable.ic_volume_up_black_24dp : R.drawable.ic_volume_off_black_24dp);
holder.video.setBackgroundResource(format.video ? R.drawable.ic_videocam_black_24dp: R.drawable.ic_videocam_off_black_24dp);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import android.content.Intent;
import android.os.Bundle;
import android.os.Parcelable;

import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.snackbar.Snackbar;
import androidx.appcompat.app.AppCompatActivity;
Expand Down Expand Up @@ -30,7 +30,7 @@ protected void onCreate(Bundle savedInstanceState) {
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);

FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.paste);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Expand Down
Loading

0 comments on commit c0f0c40

Please sign in to comment.