Commit 665d4fd4 authored by Stefan Zabka's avatar Stefan Zabka
Browse files

fixing broken stuff from merge

parent f6166847
Pipeline #2724 failed with stage
in 2 minutes and 46 seconds
...@@ -23,20 +23,17 @@ ...@@ -23,20 +23,17 @@
package de.ccc.events.badge.card10.filetransfer package de.ccc.events.badge.card10.filetransfer
import android.bluetooth.BluetoothGatt import android.bluetooth.BluetoothGatt
import android.net.Uri
import android.os.Bundle import android.os.Bundle
import android.util.Log import android.util.Log
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.navigation.fragment.findNavController
import de.ccc.events.badge.card10.R import de.ccc.events.badge.card10.R
import de.ccc.events.badge.card10.common.ConnectionService import de.ccc.events.badge.card10.common.ConnectionService
import de.ccc.events.badge.card10.common.GattListener import de.ccc.events.badge.card10.common.GattListener
import de.ccc.events.badge.card10.main.MainFragment
import kotlinx.android.synthetic.main.batch_transfer_fragment.* import kotlinx.android.synthetic.main.batch_transfer_fragment.*
import java.lang.Exception
import java.lang.IllegalStateException
private const val TAG = "BatchTransferFragment" private const val TAG = "BatchTransferFragment"
...@@ -47,9 +44,7 @@ class BatchTransferFragment : Fragment(), FileTransferListener, GattListener { ...@@ -47,9 +44,7 @@ class BatchTransferFragment : Fragment(), FileTransferListener, GattListener {
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
val jobs = BatchTransferFragmentArgs.fromBundle(requireArguments()).jobs
val args = arguments ?: throw IllegalStateException()
val jobs = args.get("jobs") as? Array<TransferJob> ?: throw IllegalStateException()
queue = TransferQueue(jobs) queue = TransferQueue(jobs)
} }
...@@ -61,16 +56,12 @@ class BatchTransferFragment : Fragment(), FileTransferListener, GattListener { ...@@ -61,16 +56,12 @@ class BatchTransferFragment : Fragment(), FileTransferListener, GattListener {
progress.max = 5 progress.max = 5
button_cancel.setOnClickListener { button_cancel.setOnClickListener {
// isCancelled = true //isCancelled = true
startTransfer() startTransfer()
} }
button_done.setOnClickListener { button_done.setOnClickListener {
val fragment = MainFragment() findNavController().popBackStack()
fragmentManager!!.beginTransaction()
.replace(R.id.fragment_container, fragment)
.addToBackStack(null)
.commit()
} }
initConnection() initConnection()
...@@ -114,7 +105,7 @@ class BatchTransferFragment : Fragment(), FileTransferListener, GattListener { ...@@ -114,7 +105,7 @@ class BatchTransferFragment : Fragment(), FileTransferListener, GattListener {
val ctx = activity ?: throw IllegalStateException() val ctx = activity ?: throw IllegalStateException()
val reader = ChunkedReader(ctx, transferJob.sourceUri, ConnectionService.mtu) val reader = ChunkedReader(ctx, transferJob.sourceUri, ConnectionService.mtu)
val service = ConnectionService.leService ?: throw IllegalStateException() val service = ConnectionService.leService ?: throw IllegalStateException()
transfer = FileTransfer(service, reader,this, transferJob.destPath) transfer = FileTransfer(service, reader, this, transferJob.destPath)
} catch (e: Exception) { } catch (e: Exception) {
Log.e(TAG, "Failed to initialize transfer") Log.e(TAG, "Failed to initialize transfer")
return return
......
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
package de.ccc.events.badge.card10.hatchery package de.ccc.events.badge.card10.hatchery
import android.net.Uri
import android.os.AsyncTask import android.os.AsyncTask
import android.os.Bundle import android.os.Bundle
import android.util.Log import android.util.Log
...@@ -32,10 +31,10 @@ import android.view.ViewGroup ...@@ -32,10 +31,10 @@ import android.view.ViewGroup
import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AlertDialog
import androidx.core.net.toUri import androidx.core.net.toUri
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager import androidx.navigation.NavController
import androidx.navigation.fragment.findNavController
import de.ccc.events.badge.card10.R import de.ccc.events.badge.card10.R
import de.ccc.events.badge.card10.common.LoadingDialog import de.ccc.events.badge.card10.common.LoadingDialog
import de.ccc.events.badge.card10.filetransfer.BatchTransferFragment
import de.ccc.events.badge.card10.filetransfer.TransferJob import de.ccc.events.badge.card10.filetransfer.TransferJob
import kotlinx.android.synthetic.main.app_detail_fragment.* import kotlinx.android.synthetic.main.app_detail_fragment.*
import org.apache.commons.compress.archivers.tar.TarArchiveInputStream import org.apache.commons.compress.archivers.tar.TarArchiveInputStream
...@@ -50,9 +49,8 @@ class AppDetailFragment : Fragment() { ...@@ -50,9 +49,8 @@ class AppDetailFragment : Fragment() {
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
app = AppDetailFragmentArgs.fromBundle(requireArguments()).app
val bundle = arguments ?: throw IllegalStateException()
app = bundle.getParcelable<App>("app") ?: throw IllegalStateException()
} }
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?) = override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?) =
...@@ -78,8 +76,8 @@ class AppDetailFragment : Fragment() { ...@@ -78,8 +76,8 @@ class AppDetailFragment : Fragment() {
) { dialog, _ -> dialog.dismiss() } ) { dialog, _ -> dialog.dismiss() }
.create() .create()
val fm = fragmentManager ?: throw java.lang.IllegalStateException() val nav = findNavController();
ReleaseDownload(app, ctx.cacheDir, loadingDialog, errorDialog, fm).execute() ReleaseDownload(app, ctx.cacheDir, loadingDialog, errorDialog, nav).execute()
} }
} }
...@@ -88,7 +86,7 @@ class AppDetailFragment : Fragment() { ...@@ -88,7 +86,7 @@ class AppDetailFragment : Fragment() {
private val cacheDir: File, private val cacheDir: File,
private val loadingDialog: LoadingDialog, private val loadingDialog: LoadingDialog,
private val errorDialog: AlertDialog, private val errorDialog: AlertDialog,
private val fragmentManager: FragmentManager private val navController: NavController
) : AsyncTask<Void, Void, List<TransferJob>?>() { ) : AsyncTask<Void, Void, List<TransferJob>?>() {
override fun doInBackground(vararg p0: Void?): List<TransferJob>? { override fun doInBackground(vararg p0: Void?): List<TransferJob>? {
...@@ -137,16 +135,9 @@ class AppDetailFragment : Fragment() { ...@@ -137,16 +135,9 @@ class AppDetailFragment : Fragment() {
} }
loadingDialog.dismiss() loadingDialog.dismiss()
val nav = AppDetailFragmentDirections.startBatchTransfer(jobs.toTypedArray())
navController.navigate(nav)
val bundle = Bundle()
bundle.putParcelableArray("jobs", jobs.toTypedArray())
val fragment = BatchTransferFragment()
fragment.arguments = bundle
fragmentManager.beginTransaction()
.replace(R.id.fragment_container, fragment)
.addToBackStack(null)
.commit()
} }
fun createLauncher(slug: String, cacheDir: File): TransferJob { fun createLauncher(slug: String, cacheDir: File): TransferJob {
......
...@@ -62,12 +62,7 @@ class AppListFragment : Fragment() { ...@@ -62,12 +62,7 @@ class AppListFragment : Fragment() {
} }
private fun onAppClicked(app: App) { private fun onAppClicked(app: App) {
val bundle = Bundle() findNavController().navigate(AppListFragmentDirections.actionAppListFragmentToAppDetailFragment(app))
bundle.putParcelable("app", app)
val fragment = AppDetailFragment()
fragment.arguments = bundle
findNavController()
} }
private class DownloadTask( private class DownloadTask(
......
...@@ -27,18 +27,12 @@ import android.os.Bundle ...@@ -27,18 +27,12 @@ import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.navigation.NavDirections
import androidx.navigation.fragment.findNavController import androidx.navigation.fragment.findNavController
import de.ccc.events.badge.card10.CARD10_BLUETOOTH_MAC_PREFIX import de.ccc.events.badge.card10.CARD10_BLUETOOTH_MAC_PREFIX
import de.ccc.events.badge.card10.R import de.ccc.events.badge.card10.R
import de.ccc.events.badge.card10.filetransfer.FileTransferFragment
import de.ccc.events.badge.card10.hatchery.AppListFragment
import de.ccc.events.badge.card10.sparkle.BeautifulFragment
import kotlinx.android.synthetic.main.disconnected_fragment.* import kotlinx.android.synthetic.main.disconnected_fragment.*
import kotlinx.android.synthetic.main.main_fragment.*
import kotlinx.android.synthetic.main.main_fragment.label_status
/** /**
* Here we give the user the option to start his device and connect it * Here we give the user the option to start his device and connect it
...@@ -46,11 +40,11 @@ import kotlinx.android.synthetic.main.main_fragment.label_status ...@@ -46,11 +40,11 @@ import kotlinx.android.synthetic.main.main_fragment.label_status
class DisconnectedFragment : Fragment() { class DisconnectedFragment : Fragment() {
private val bluetoothAdapter = BluetoothAdapter.getDefaultAdapter() private val bluetoothAdapter = BluetoothAdapter.getDefaultAdapter()
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?) = override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?) : View =
inflater.inflate(R.layout.disconnected_fragment, container, false) inflater.inflate(R.layout.disconnected_fragment, container, false)
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
button_pair.setOnClickListener { MainFragmentDirections.Scanner() } button_pair.setOnClickListener { findNavController().navigate(DisconnectedFragmentDirections.Scanner()) }
val bondedCard10s = val bondedCard10s =
bluetoothAdapter.bondedDevices.filter { it.address.startsWith(CARD10_BLUETOOTH_MAC_PREFIX, true) } bluetoothAdapter.bondedDevices.filter { it.address.startsWith(CARD10_BLUETOOTH_MAC_PREFIX, true) }
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:padding="@dimen/activity_padding"> android:padding="@dimen/activity_padding">
...@@ -23,27 +23,13 @@ ...@@ -23,27 +23,13 @@
app:layout_constraintRight_toRightOf="parent" app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/image_logo"/> app:layout_constraintTop_toBottomOf="@+id/image_logo"/>
<Button android:id="@+id/button_pair"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/main_button_pair"
android:layout_marginTop="@dimen/main_label_margin"
style="@style/MainButton"
app:layout_constraintTop_toBottomOf="@id/label_status"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"/>
<androidx.constraintlayout.widget.ConstraintLayout android:layout_width="match_parent" <androidx.constraintlayout.widget.ConstraintLayout android:layout_width="match_parent"
android:layout_height="0dp" android:layout_height="0dp"
app:layout_constraintTop_toBottomOf="@id/button_pair" android:id="@+id/container_connected"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
android:id="@+id/container_disconnected"> app:layout_constraintTop_toBottomOf="@+id/image_logo">
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintTop_toBottomOf="@id/button_pair"
android:id="@+id/container_connected">
<Button android:layout_width="wrap_content" <Button android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="@dimen/main_label_margin" android:layout_marginTop="@dimen/main_label_margin"
......
...@@ -6,9 +6,7 @@ ...@@ -6,9 +6,7 @@
<fragment android:id="@+id/mainFragment" android:name="de.ccc.events.badge.card10.main.MainFragment" <fragment android:id="@+id/mainFragment" android:name="de.ccc.events.badge.card10.main.MainFragment"
android:label="MainFragment" tools:layout="@layout/main_fragment"> android:label="MainFragment" tools:layout="@layout/main_fragment">
<action android:id="@+id/Scanner" app:destination="@id/scannerFragment"
app:enterAnim="@anim/nav_default_enter_anim" app:exitAnim="@anim/nav_default_exit_anim"
app:popEnterAnim="@anim/nav_default_pop_enter_anim" app:popExitAnim="@anim/nav_default_pop_exit_anim"/>
<action android:id="@+id/Mood" app:destination="@id/moodFragment"/> <action android:id="@+id/Mood" app:destination="@id/moodFragment"/>
<action android:id="@+id/Beautiful" app:destination="@id/beautifulFragment"/> <action android:id="@+id/Beautiful" app:destination="@id/beautifulFragment"/>
<action android:id="@+id/AppList" app:destination="@id/appListFragment"/> <action android:id="@+id/AppList" app:destination="@id/appListFragment"/>
...@@ -34,10 +32,22 @@ ...@@ -34,10 +32,22 @@
android:name="de.ccc.events.badge.card10.filetransfer.FileTransferFragment" android:name="de.ccc.events.badge.card10.filetransfer.FileTransferFragment"
android:label="FileTransferFragment" tools:layout="@layout/file_transfer_fragment"/> android:label="FileTransferFragment" tools:layout="@layout/file_transfer_fragment"/>
<fragment android:id="@+id/appDetailFragment" android:name="de.ccc.events.badge.card10.hatchery.AppDetailFragment" <fragment android:id="@+id/appDetailFragment" android:name="de.ccc.events.badge.card10.hatchery.AppDetailFragment"
android:label="AppDetailFragment" tools:layout="@layout/app_detail_fragment"/> android:label="AppDetailFragment" tools:layout="@layout/app_detail_fragment">
<action android:id="@+id/startBatchTransfer"
app:destination="@id/batchTransferFragment"/>
<argument android:name="app" app:argType="de.ccc.events.badge.card10.hatchery.App"/>
</fragment>
<fragment android:id="@+id/disconnectedFragment" android:name="de.ccc.events.badge.card10.main.DisconnectedFragment" <fragment android:id="@+id/disconnectedFragment" android:name="de.ccc.events.badge.card10.main.DisconnectedFragment"
android:label="DisconnectedFragment"> android:label="DisconnectedFragment">
<action android:id="@+id/Connected" app:destination="@id/mainFragment" <action android:id="@+id/Connected" app:destination="@id/mainFragment"
/> />
<action android:id="@+id/Scanner" app:destination="@id/scannerFragment"
app:enterAnim="@anim/nav_default_enter_anim" app:exitAnim="@anim/nav_default_exit_anim"
app:popEnterAnim="@anim/nav_default_pop_enter_anim" app:popExitAnim="@anim/nav_default_pop_exit_anim"/>
</fragment>
<fragment android:id="@+id/batchTransferFragment"
android:name="de.ccc.events.badge.card10.filetransfer.BatchTransferFragment"
android:label="BatchTransferFragment">
<argument android:name="jobs" app:argType="de.ccc.events.badge.card10.filetransfer.TransferJob[]"/>
</fragment> </fragment>
</navigation> </navigation>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment