Skip to content

Commit

Permalink
refactor: draw layout changed to edit badge layout (#387)
Browse files Browse the repository at this point in the history
  • Loading branch information
adityastic authored and mariobehling committed Jun 18, 2019
1 parent 4c89e5a commit dd6c926
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".ui.DrawActivity" android:screenOrientation="landscape">
<activity android:name=".ui.EditBadgeActivity" android:screenOrientation="landscape">
</activity>
<activity
android:name=".ui.DrawerActivity"
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/org/fossasia/badgemagic/di/Modules.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import org.fossasia.badgemagic.util.Resource
import org.fossasia.badgemagic.viewmodels.FilesViewModel
import org.fossasia.badgemagic.viewmodels.TextArtViewModel
import org.fossasia.badgemagic.viewmodels.SettingsViewModel
import org.fossasia.badgemagic.viewmodels.DrawViewModel
import org.fossasia.badgemagic.viewmodels.EditBadgeViewModel
import org.koin.android.ext.koin.androidContext
import org.koin.androidx.viewmodel.dsl.viewModel
import org.koin.dsl.module
Expand All @@ -16,7 +16,7 @@ val viewModelModules = module {
viewModel { TextArtViewModel(get(), get()) }
viewModel { FilesViewModel(get()) }
viewModel { SettingsViewModel(get()) }
viewModel { DrawViewModel(get()) }
viewModel { EditBadgeViewModel(get()) }
}

val singletonModules = module {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,24 @@ import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.databinding.DataBindingUtil
import androidx.lifecycle.Observer
import kotlinx.android.synthetic.main.activity_draw.*
import kotlinx.android.synthetic.main.activity_edit_badge.*
import org.fossasia.badgemagic.R
import org.fossasia.badgemagic.data.fragments.BadgeConfig
import org.fossasia.badgemagic.databinding.ActivityDrawBinding
import org.fossasia.badgemagic.databinding.ActivityEditBadgeBinding
import org.fossasia.badgemagic.util.Converters
import org.fossasia.badgemagic.util.SendingUtils
import org.fossasia.badgemagic.util.StorageUtils
import org.fossasia.badgemagic.viewmodels.DrawViewModel
import org.fossasia.badgemagic.viewmodels.EditBadgeViewModel
import org.koin.androidx.viewmodel.ext.android.viewModel

class DrawActivity : AppCompatActivity() {
class EditBadgeActivity : AppCompatActivity() {

private val viewModel by viewModel<DrawViewModel>()
private val viewModel by viewModel<EditBadgeViewModel>()
private lateinit var fileName: String

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val activityDrawBinding = DataBindingUtil.setContentView<ActivityDrawBinding>(this, R.layout.activity_draw)
val activityDrawBinding = DataBindingUtil.setContentView<ActivityEditBadgeBinding>(this, R.layout.activity_edit_badge)
activityDrawBinding.viewModel = viewModel

if (intent.hasExtra("badgeJSON") && intent.hasExtra("fileName")) {
Expand Down Expand Up @@ -53,7 +53,7 @@ class DrawActivity : AppCompatActivity() {

companion object {

class StoreAsync(private val fileName: String, private val badgeConfig: BadgeConfig, private val viewModel: DrawViewModel) : AsyncTask<Void, Void, Void>() {
class StoreAsync(private val fileName: String, private val badgeConfig: BadgeConfig, private val viewModel: EditBadgeViewModel) : AsyncTask<Void, Void, Void>() {
override fun doInBackground(vararg params: Void?): Void? {
StorageUtils.saveEditedBadge(badgeConfig, fileName)
return null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import org.fossasia.badgemagic.util.Converters
import org.fossasia.badgemagic.util.SendingUtils
import org.fossasia.badgemagic.adapter.OnSavedItemSelected
import org.fossasia.badgemagic.adapter.SaveAdapter
import org.fossasia.badgemagic.ui.DrawActivity
import org.fossasia.badgemagic.ui.EditBadgeActivity
import org.koin.androidx.viewmodel.ext.android.sharedViewModel
import java.io.File

Expand Down Expand Up @@ -92,7 +92,7 @@ class SavedBadgesFragment : BaseFragment() {
recyclerAdapter = SaveAdapter(requireContext(), files, object : OnSavedItemSelected {
override fun onEdit(item: ConfigInfo?) {
startActivity(
Intent(requireContext(), DrawActivity::class.java).apply {
Intent(requireContext(), EditBadgeActivity::class.java).apply {
putExtra("badgeJSON", item?.badgeJSON)
putExtra("fileName", item?.fileName)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import androidx.lifecycle.ViewModel
import org.fossasia.badgemagic.data.draw_layout.DrawMode
import org.fossasia.badgemagic.database.StorageFilesService

class DrawViewModel(
class EditBadgeViewModel(
private val storageFilesService: StorageFilesService
) : ViewModel() {
var drawModeState: ObservableField<DrawMode> = ObservableField(DrawMode.NOTHING)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@

<variable
name="viewModel"
type="org.fossasia.badgemagic.viewmodels.DrawViewModel" />
type="org.fossasia.badgemagic.viewmodels.EditBadgeViewModel" />
</data>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
tools:context=".ui.DrawActivity">
tools:context=".ui.EditBadgeActivity">

<org.fossasia.badgemagic.ui.custom.DrawBadgeLayout
android:id="@+id/draw_layout"
Expand Down

0 comments on commit dd6c926

Please sign in to comment.