package eu.depau.ddroid.fragments import android.Manifest import android.app.Activity import android.content.Intent import android.content.pm.PackageManager import android.net.Uri import android.os.Bundle import android.provider.OpenableColumns import android.support.design.widget.Snackbar import android.support.v4.app.ActivityCompat import android.support.v4.content.ContextCompat import android.util.Log import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.Button import android.widget.CheckBox import android.widget.EditText import eu.depau.ddroid.* import eu.depau.ddroid.abc.WizardActivity import eu.depau.ddroid.abc.WizardFragment import eu.depau.ddroid.values.FlashMethod import eu.depau.ddroid.values.ImageLocation import eu.depau.ddroid.values.WizardStep /** * A placeholder fragment containing a simple view. */ class ImageLocationFragment : WizardFragment() { val READ_REQUEST_CODE = 42 val MY_PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE = 29 val TAG = "ImageLocationFragment" fun isStreamingAvailable(): Boolean { if (StateKeeper.imageLocation != ImageLocation.REMOTE) return false if (StateKeeper.flashMethod != FlashMethod.FLASH_DD && StateKeeper.flashMethod != FlashMethod.FLASH_API) return false return true } fun setStreamingCheckBoxAvailability(context: WizardActivity) { val checkBox = context.findViewById(R.id.streaming_write_checkbox) if (checkBox == null) return val curEnabled = checkBox.isEnabled var enabled = isStreamingAvailable() if (curEnabled != enabled) { checkBox.isEnabled = enabled onCheckBoxClicked(checkBox) } } override fun onCheckBoxClicked(view: View) { super.onCheckBoxClicked(view) if (view.id == R.id.streaming_write_checkbox) StateKeeper.streamingWrite = view.isActivated && view.isEnabled } override fun onRadioButtonClicked(view: View) { StateKeeper.imageLocation = when (view.id) { R.id.download_img_radio -> ImageLocation.REMOTE R.id.use_local_img_radio -> ImageLocation.LOCAL else -> null } activity?.findViewById