Skip to content

Commit

Permalink
Removed explicit download button; remove bottom bar; add new FAB
Browse files Browse the repository at this point in the history
  • Loading branch information
tastelessjolt committed Sep 7, 2018
1 parent 659ba2c commit a3f5b22
Show file tree
Hide file tree
Showing 4 changed files with 130 additions and 54 deletions.
38 changes: 21 additions & 17 deletions app/src/main/java/me/harshithgoka/youtubedl/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,19 @@
import android.text.Html;
import android.text.method.ScrollingMovementMethod;
import android.util.Log;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.widget.EditText;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;

import com.google.android.material.bottomappbar.BottomAppBar;
import com.google.android.material.bottomsheet.BottomSheetBehavior;
import com.google.android.material.button.MaterialButton;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
Expand All @@ -50,8 +53,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe

EditText urlEdit;
TextView log;
FloatingActionButton btnCopy;
FloatingActionButton btnDownload;
MaterialButton btnCopy;

List<Format> formats;

Expand Down Expand Up @@ -120,16 +122,28 @@ protected void onCreate(Bundle savedInstanceState) {
}

this.btnCopy = findViewById(R.id.paste);
this.btnDownload = findViewById(R.id.btnDownload);

this.btnCopy.setOnClickListener(this);
this.btnDownload.setOnClickListener(this);

log = (TextView) findViewById(R.id.textView);
log.setMovementMethod(new ScrollingMovementMethod());

urlEdit = (EditText) findViewById(R.id.url);

urlEdit.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
switch (actionId) {
case EditorInfo.IME_ACTION_GO:
Log.d("URL", v.getText().toString());
startPoint(null);
return true;
default:
return false;
}
}
});

progressBars = new ArrayList<>();
progressBars.add((ProgressBar) findViewById(R.id.progressBar));
progressBars.add((ProgressBar) findViewById(R.id.progressBar2));
Expand Down Expand Up @@ -169,16 +183,6 @@ protected void onCreate(Bundle savedInstanceState) {
viLinearLayoutManager = new LinearLayoutManager(getApplicationContext());
viRecyclerView.setLayoutManager(viLinearLayoutManager);


BottomAppBar bar = (BottomAppBar) findViewById(R.id.bar);
bar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// Handle the navigation click by showing a BottomDrawer etc.
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
}
});

// ATTENTION: This was auto-generated to handle app links.
Intent appLinkIntent = getIntent();
String appLinkAction = appLinkIntent.getAction();
Expand Down Expand Up @@ -321,9 +325,9 @@ public void onClick(View v) {
pasteFromClipboard(v);
break;

case R.id.btnDownload:
startPoint(v);
break;
// case R.id.btnDownload:
// startPoint(v);
// break;
}
}

Expand Down
12 changes: 12 additions & 0 deletions app/src/main/res/drawable/ic_outline_file_copy_24px.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#42a5f5"
android:pathData="M16,1H4C2.9,1 2,1.9 2,3v14h2V3h12V1z"/>
<path
android:fillColor="#4caf50"
android:pathData="M15,5H8C6.9,5 6.01,5.9 6.01,7L6,21c0,1.1 0.89,2 1.99,2H19c1.1,0 2,-0.9 2,-2V11L15,5zM8,21V7h6v5h5v9L8,21z"/>
</vector>
95 changes: 58 additions & 37 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@
</androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.AppBarLayout>
<androidx.core.widget.NestedScrollView
android:id="@+id/mainContent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
Expand Down Expand Up @@ -72,7 +73,8 @@
android:layout_height="match_parent"
android:textSize="20sp"
android:hint="@string/url_hint"
android:inputType="textUri" />
android:inputType="textUri"
android:imeOptions="actionGo"/>
</com.google.android.material.textfield.TextInputLayout>

<ProgressBar
Expand Down Expand Up @@ -103,46 +105,65 @@
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>

<com.google.android.material.bottomappbar.BottomAppBar
android:id="@+id/bar"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_gravity="bottom"
android:elevation="10dp"
android:translationZ="10dp"
app:backgroundTint="@color/colorPrimary"
app:navigationIcon="@drawable/ic_menu_24" />
<!--<com.google.android.material.button.MaterialButton-->
<!--android:id="@+id/btnDownload"-->
<!--android:layout_height="wrap_content"-->
<!--android:layout_width="wrap_content"-->
<!--android:visibility="gone"/>-->

<com.google.android.material.floatingactionbutton.FloatingActionButton
<com.google.android.material.button.MaterialButton
android:id="@+id/paste"
style="@style/Widget.MaterialComponents.FloatingActionButton"
style="@style/Widget.MaterialComponents.Button.TextButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:backgroundTint="@color/colorAccent"
android:src="@drawable/ic_content_copy_24"
app:layout_anchor="@id/bar">
</com.google.android.material.floatingactionbutton.FloatingActionButton>
android:layout_height="64dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="18dp"
android:layout_marginRight="18dp"
android:paddingStart="20dp"
android:paddingEnd="20dp"
android:textSize="16sp"
android:fontFamily="@font/product_sans"
android:gravity="center"
android:maxLines="1"
android:textStyle="bold"
android:textColor="@color/textColor"
android:textAppearance="@style/TextAppearance.MaterialComponents.Headline6"
android:text="Paste"
android:elevation="6dp"
app:cornerRadius="32dp"
app:iconPadding="12dp"
app:iconSize="24dp"
app:icon="@drawable/ic_outline_file_copy_24px"
app:iconTint="@android:color/white"
app:iconTintMode="multiply"

<View
android:id="@+id/dummy"
android:layout_width="1dp"
android:layout_height="24dp"
app:layout_anchor="@id/paste"
app:layout_anchorGravity="top" />
app:backgroundTint="@color/backgroundColor"
app:layout_anchor="@id/mainContent"
app:layout_anchorGravity="bottom|right">

<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/btnDownload"
style="@style/Widget.MaterialComponents.FloatingActionButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|top"
android:src="@drawable/ic_send_black_24dp"
app:backgroundTint="@color/colorAccent"
app:fabCradleMargin="@dimen/fab_margin"
app:fabCradleVerticalOffset="@dimen/fab_margin"
app:layout_anchor="@id/dummy"
app:layout_anchorGravity="top"
tools:srcCompat="@tools:sample/backgrounds/scenic[2]" />
</com.google.android.material.button.MaterialButton>

<!--<View-->
<!--android:id="@+id/dummy"-->
<!--android:layout_width="1dp"-->
<!--android:layout_height="24dp"-->
<!--app:layout_anchor="@id/paste"-->
<!--app:layout_anchorGravity="top" />-->

<!--<com.google.android.material.floatingactionbutton.FloatingActionButton-->
<!--android:id="@+id/btnDownload"-->
<!--style="@style/Widget.MaterialComponents.FloatingActionButton"-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content"-->
<!--android:layout_gravity="end|top"-->
<!--android:src="@drawable/ic_send_black_24dp"-->
<!--app:backgroundTint="@color/colorAccent"-->
<!--app:fabCradleMargin="@dimen/fab_margin"-->
<!--app:fabCradleVerticalOffset="@dimen/fab_margin"-->
<!--app:layout_anchor="@id/dummy"-->
<!--app:layout_anchorGravity="top"-->
<!--tools:srcCompat="@tools:sample/backgrounds/scenic[2]" />-->


<include layout="@layout/formats_layout"/>
Expand Down
39 changes: 39 additions & 0 deletions app/src/main/res/layout/fab_text.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.card.MaterialCardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
style="@style/Widget.MaterialComponents.CardView"
android:id="@+id/fab_button_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="3dp"
app:cardCornerRadius="24dp">

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="12dp"
android:orientation="horizontal">

<View
android:id="@+id/fab_img"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="center_vertical"
android:background="@drawable/ic_outline_file_copy_24px"/>

<TextView
android:id="@+id/fab_text"
android:layout_width="wrap_content"
android:layout_height="24dp"
android:layout_marginLeft="6dp"
android:layout_marginRight="6dp"
android:fontFamily="@font/product_sans"
android:gravity="center"
android:maxLines="1"
android:textSize="12sp"
android:textStyle="bold"
android:textAppearance="@style/TextAppearance.MaterialComponents.Headline6"
android:text="Paste"/>
</LinearLayout>
</com.google.android.material.card.MaterialCardView>

0 comments on commit a3f5b22

Please sign in to comment.