Issue#10 Add error message if link cannot be opened

This commit is contained in:
Gergely Hegedus 2022-04-22 00:29:45 +03:00
parent 95a100217c
commit df30bb5bfb
3 changed files with 23 additions and 8 deletions

View file

@ -9,6 +9,8 @@ import android.view.animation.OvershootInterpolator
import androidx.annotation.StringRes import androidx.annotation.StringRes
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.coordinatorlayout.widget.CoordinatorLayout import androidx.coordinatorlayout.widget.CoordinatorLayout
import androidx.core.view.doOnPreDraw
import androidx.core.view.isVisible
import com.google.android.material.bottomnavigation.BottomNavigationView import com.google.android.material.bottomnavigation.BottomNavigationView
import com.google.android.material.floatingactionbutton.FloatingActionButton import com.google.android.material.floatingactionbutton.FloatingActionButton
import com.google.android.material.snackbar.Snackbar import com.google.android.material.snackbar.Snackbar
@ -114,14 +116,18 @@ class MainActivity : AppCompatActivity() {
private fun animateFabVisibility(downloadFab: FloatingActionButton, visible: Boolean) { private fun animateFabVisibility(downloadFab: FloatingActionButton, visible: Boolean) {
val scale = if (visible) 1f else 0f val scale = if (visible) 1f else 0f
val translation = if (visible) 0f else downloadFab.height * 2 / 3f val translation = if (visible) 0f else downloadFab.height * 2 / 3f
downloadFab.isVisible = true
downloadFab.clearAnimation() downloadFab.clearAnimation()
downloadFab.animate() downloadFab.doOnPreDraw {
.scaleX(scale) downloadFab.animate()
.scaleY(scale) .scaleX(scale)
.setDuration(FAB_VISIBILITY_ANIMATION_DURATION) .scaleY(scale)
.setInterpolator(fabVisibilityInterpolator) .setDuration(FAB_VISIBILITY_ANIMATION_DURATION)
.translationY(translation) .setInterpolator(fabVisibilityInterpolator)
.start() .translationY(translation)
.withEndAction { downloadFab.isVisible = visible }
.start()
}
} }
} }
} }

View file

@ -1,16 +1,19 @@
package org.fnives.tiktokdownloader.ui.main.queue package org.fnives.tiktokdownloader.ui.main.queue
import android.content.ActivityNotFoundException
import android.content.Intent import android.content.Intent
import android.net.Uri import android.net.Uri
import android.os.Bundle import android.os.Bundle
import android.view.View import android.view.View
import android.widget.Button import android.widget.Button
import android.widget.EditText import android.widget.EditText
import androidx.coordinatorlayout.widget.CoordinatorLayout
import androidx.core.net.toUri import androidx.core.net.toUri
import androidx.core.widget.doAfterTextChanged import androidx.core.widget.doAfterTextChanged
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.ItemTouchHelper import androidx.recyclerview.widget.ItemTouchHelper
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.google.android.material.snackbar.Snackbar
import org.fnives.tiktokdownloader.R import org.fnives.tiktokdownloader.R
import org.fnives.tiktokdownloader.data.model.VideoState import org.fnives.tiktokdownloader.data.model.VideoState
import org.fnives.tiktokdownloader.di.provideViewModels import org.fnives.tiktokdownloader.di.provideViewModels
@ -46,7 +49,12 @@ class QueueFragment : Fragment(R.layout.fragment_queue) {
createGalleryIntent(data.uri) createGalleryIntent(data.uri)
null -> return@observe null -> return@observe
} }
startActivity(intent) try {
startActivity(intent)
} catch(activityNotFoundException: ActivityNotFoundException) {
val anchor = activity?.findViewById<CoordinatorLayout>(R.id.snack_bar_anchor) ?: return@observe
Snackbar.make(anchor, R.string.could_not_open, Snackbar.LENGTH_SHORT).show()
}
} }
} }

View file

@ -46,4 +46,5 @@
<string name="error_handling">The download may fail for various reasons. In such case on the Queue screen you will see a refresh icon. Pressing that will retry the download.</string> <string name="error_handling">The download may fail for various reasons. In such case on the Queue screen you will see a refresh icon. Pressing that will retry the download.</string>
<string name="captcha_handling">It\'s possible if you try to download too many videos at the same time <b>captcha</b> will be triggered. Since we don\'t want to overload the server, in such case you will need to wait a couple hours to properly retry the download. If that still doesn\'t work you may need to verify a captcha on the same network.</string> <string name="captcha_handling">It\'s possible if you try to download too many videos at the same time <b>captcha</b> will be triggered. Since we don\'t want to overload the server, in such case you will need to wait a couple hours to properly retry the download. If that still doesn\'t work you may need to verify a captcha on the same network.</string>
<string name="link_to_repository">This is an open source project. You can see the repository clicking <u>here.</u></string> <string name="link_to_repository">This is an open source project. You can see the repository clicking <u>here.</u></string>
<string name="could_not_open">Couldn\'t open!</string>
</resources> </resources>