Skip to content

Commit

Permalink
fixed tint
Browse files Browse the repository at this point in the history
  • Loading branch information
LagradOst committed Sep 21, 2022
1 parent 8423aad commit 4e1d6d2
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 14 deletions.
48 changes: 35 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

#### [Work in progress]

Just a simple library to have a download button which works with Fetch. Mostly for personal usage.
https://jitpack.io/#LagradOst/Aria2cButton/

Just a simple library to have a download button which works with Aria2c. Mostly for personal usage.

TODO:
- [ ] Themeable/Attributes
- [x] Themeable/Attributes
- [ ] Testing with recyclerview
- [ ] More default download buttons
- [x] More default download buttons

### Usage:
```xml
Expand All @@ -21,20 +23,40 @@ TODO:
```kotlin
val downloadButton = findViewById<PieFetchButton>(R.id.download_button)

// This is required to run once in the app before any fetch usage.
initFetch(this)
// This is required to run once in the app before any aria2c usage.
thread {
Aria2Starter.start(
this,
Aria2Settings(
UUID.randomUUID().toString(),
4337,
filesDir.path,
"${filesDir.path}/session"
)
)
}

// this is used to store data for resuming next app launch
downloadButton.setPersistentId(pId)

// Arbitrary path
val path = this.filesDir.path + "/FetchButtonTest/test.bin"
val uriReq = newUriRequest(
pId, "https://speed.hetzner.de/100MB.bin", "Hello World",
notificationMetaData = NotificationMetaData(
pId.toInt(),
0xFF0000,
"contentTitle",
"Subtext",
"row2Extra",
"https://www.royalroadcdn.com/public/covers-full/36735-the-perfect-run.jpg",
"SpeedTest",
"secondRow"
)
)

// This is just to play around with the default behavior, use
// downloadButton.pauseDownload() and such to control the download easily
// To subscribe to another download, just use downloadButton.currentRequestId = fetchRequestId
downloadButton.setDefaultClickListener {
com.tonyodev.fetch2.Request(
// Download url
"https://speedtest-co.turnkeyinternet.net/1000mb.bin",
path,
)
downloadButton.setDefaultClickListener {
listOf(uriReq)
}
```
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ class MainActivity : AppCompatActivity() {
)
)

//downloadButton.setDefaultClickListener {
// listOf(uriReq)
//}

downloadButton.setOnClickListener { view ->
if (view !is PieFetchButton) return@setOnClickListener
val id = view.persistentId
Expand Down
2 changes: 1 addition & 1 deletion library/src/main/res/layout/download_button_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:padding="2dp"
app:tint="?attr/aria2c_icon_color"
android:tint="?attr/aria2c_icon_color"
android:src="@drawable/ic_baseline_play_arrow_24"
android:visibility="visible" />
</FrameLayout>

0 comments on commit 4e1d6d2

Please sign in to comment.