forked from fossasia/badgemagic-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: draw clipart option in drawer (fossasia#388)
- Loading branch information
1 parent
b4fe215
commit a8d51fb
Showing
22 changed files
with
472 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
app/src/main/java/org/fossasia/badgemagic/extensions/ActivityExtensions.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package org.fossasia.badgemagic.extensions | ||
|
||
import android.app.Activity | ||
import androidx.annotation.Keep | ||
|
||
@Keep | ||
fun <A : Activity> A.setRotation(rotation: Int) { | ||
this.requestedOrientation = rotation | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
app/src/main/java/org/fossasia/badgemagic/ui/fragments/DrawFragment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package org.fossasia.badgemagic.ui.fragments | ||
|
||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import android.widget.Toast | ||
import androidx.databinding.DataBindingUtil | ||
import androidx.lifecycle.Observer | ||
import kotlinx.android.synthetic.main.fragment_draw.* | ||
import org.fossasia.badgemagic.R | ||
import org.fossasia.badgemagic.databinding.FragmentDrawBinding | ||
import org.fossasia.badgemagic.ui.base.BaseFragment | ||
import org.fossasia.badgemagic.util.Converters | ||
import org.fossasia.badgemagic.util.StorageUtils | ||
import org.fossasia.badgemagic.viewmodels.DrawViewModel | ||
import org.koin.androidx.viewmodel.ext.android.viewModel | ||
|
||
class DrawFragment : BaseFragment() { | ||
|
||
companion object { | ||
@JvmStatic | ||
fun newInstance() = | ||
DrawFragment() | ||
} | ||
|
||
private val drawViewModel by viewModel<DrawViewModel>() | ||
|
||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { | ||
val binding = DataBindingUtil.inflate<FragmentDrawBinding>(inflater, R.layout.fragment_draw, container, false) | ||
binding.viewModel = drawViewModel | ||
return binding.root | ||
} | ||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
|
||
drawViewModel.savedButton.observe(this, Observer { | ||
if (it) { | ||
if (StorageUtils.saveClipArt(Converters.convertStringsToLEDHex(draw_layout.getCheckedList()))) { | ||
Toast.makeText(requireContext(), R.string.clipart_saved_success, Toast.LENGTH_LONG).show() | ||
drawViewModel.updateCliparts() | ||
} else | ||
Toast.makeText(requireContext(), R.string.clipart_saved_error, Toast.LENGTH_LONG).show() | ||
} | ||
}) | ||
|
||
drawViewModel.resetButton.observe(this, Observer { | ||
if (it) { | ||
draw_layout.resetCheckListWithDummyData() | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.