From 4559437a706d3838cb0c40f227b03780f9cb982b Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 9 Jul 2019 03:02:45 +0530 Subject: [PATCH 01/10] chore(deps): bump kluent from 1.51 to 1.52 (#438) Bumps kluent from 1.51 to 1.52. Signed-off-by: dependabot-preview[bot] --- app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index 9f4f3ab1d..5e63ae145 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -103,7 +103,7 @@ dependencies { implementation 'androidx.legacy:legacy-support-v4:1.0.0' testImplementation 'junit:junit:4.12' testImplementation 'com.nhaarman:mockito-kotlin-kt1.1:1.5.0' - testImplementation 'org.amshove.kluent:kluent:1.51' + testImplementation 'org.amshove.kluent:kluent:1.52' // Leak Canary debugImplementation "com.squareup.leakcanary:leakcanary-android:${versions.leak_canary}" From 24d0871d354e4b627e6af831d4bf4306c4505f10 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 10 Jul 2019 15:24:44 +0530 Subject: [PATCH 02/10] chore(deps): bump gradle from 3.4.1 to 3.4.2 (#439) Bumps gradle from 3.4.1 to 3.4.2. Signed-off-by: dependabot-preview[bot] --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 153825640..87fef7fb5 100644 --- a/build.gradle +++ b/build.gradle @@ -10,7 +10,7 @@ buildscript { } dependencies { - classpath "com.android.tools.build:gradle:3.4.1" + classpath "com.android.tools.build:gradle:3.4.2" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$versions.kotlin_version" classpath "gradle.plugin.com.github.b3er.local.properties:local-properties-plugin:1.1" } From a97fe716ca52b3165a4d7ced73c4ae69e91ae7a6 Mon Sep 17 00:00:00 2001 From: Aditya Gupta Date: Wed, 10 Jul 2019 19:12:53 +0530 Subject: [PATCH 03/10] fix: retain fragment info when orientation changed (#440) --- .../org/fossasia/badgemagic/ui/fragments/TextArtFragment.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/org/fossasia/badgemagic/ui/fragments/TextArtFragment.kt b/app/src/main/java/org/fossasia/badgemagic/ui/fragments/TextArtFragment.kt index 0b68a25b8..b427dd6b2 100644 --- a/app/src/main/java/org/fossasia/badgemagic/ui/fragments/TextArtFragment.kt +++ b/app/src/main/java/org/fossasia/badgemagic/ui/fragments/TextArtFragment.kt @@ -54,7 +54,7 @@ import org.fossasia.badgemagic.util.ImageUtils import org.fossasia.badgemagic.util.DRAWABLE_END import org.fossasia.badgemagic.util.DRAWABLE_START import org.fossasia.badgemagic.viewmodels.TextArtViewModel -import org.koin.androidx.viewmodel.ext.android.viewModel +import org.koin.androidx.viewmodel.ext.android.sharedViewModel import pl.droidsonroids.gif.GifImageView import java.text.SimpleDateFormat import java.util.Timer @@ -74,7 +74,7 @@ class TextArtFragment : BaseFragment() { private val drawableRecyclerAdapter = DrawableAdapter() private val modeAdapter = ModeAdapter() - private val viewModel by viewModel() + private val viewModel by sharedViewModel() override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) @@ -143,7 +143,7 @@ class TextArtFragment : BaseFragment() { } } - fun startSaveFile() { + private fun startSaveFile() { textViewMainText.hideKeyboard() showSaveFileDialog() } From 80fc9452d3a5ebff9c5187a58620c01fa937a543 Mon Sep 17 00:00:00 2001 From: Aditya Gupta Date: Wed, 10 Jul 2019 19:14:35 +0530 Subject: [PATCH 04/10] feat: ability to edit badges (#429) --- app/src/main/AndroidManifest.xml | 4 +- .../adapter/SavedClipartsAdapter.kt | 19 ++- .../adapter/SavedClipartsViewHolder.kt | 4 + .../bindings/EditBadgeViewBindings.kt | 9 +- .../badgemagic/database/ClipArtService.kt | 13 +- .../org/fossasia/badgemagic/di/Modules.kt | 2 + .../badgemagic/ui/EditClipartActivity.kt | 48 +++++++ .../ui/fragments/SavedClipartFragment.kt | 13 ++ .../fossasia/badgemagic/util/Converters.kt | 2 +- .../fossasia/badgemagic/util/StorageUtils.kt | 18 +++ .../viewmodels/EditClipartViewModel.kt | 48 +++++++ .../viewmodels/SavedClipartViewModel.kt | 18 +-- .../main/res/layout/activity_edit_badge.xml | 32 ++--- .../main/res/layout/activity_edit_clipart.xml | 117 ++++++++++++++++++ .../layout/recycler_item_saved_clipart.xml | 2 +- 15 files changed, 304 insertions(+), 45 deletions(-) create mode 100644 app/src/main/java/org/fossasia/badgemagic/ui/EditClipartActivity.kt create mode 100644 app/src/main/java/org/fossasia/badgemagic/viewmodels/EditClipartViewModel.kt create mode 100644 app/src/main/res/layout/activity_edit_clipart.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index c12752166..2812dcfac 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -23,8 +23,6 @@ android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme"> - - + + , + private var clipartList: List, private val viewModel: SavedClipartViewModel ) : RecyclerView.Adapter() { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): SavedClipartsViewHolder { @@ -22,14 +24,21 @@ class SavedClipartsAdapter( override fun getItemCount(): Int = clipartList.size override fun onBindViewHolder(holder: SavedClipartsViewHolder, position: Int) { - holder.bind(clipartList[position]) - holder.getBindingView().setOnClickListener { + holder.bind(clipartList[position].bitmap) + holder.getDeleteButton().setOnClickListener { viewModel.deleteClipart(position) Toast.makeText(it.context, "Delete Clipart Successfully", Toast.LENGTH_LONG).show() } + holder.getEditButton().setOnClickListener { + it.context.startActivity( + Intent(it.context, EditClipartActivity::class.java).apply { + putExtra("fileName", clipartList[position].fileName) + } + ) + } } - fun setList(list: List) { + fun setList(list: List) { clipartList = list notifyDataSetChanged() } diff --git a/app/src/main/java/org/fossasia/badgemagic/adapter/SavedClipartsViewHolder.kt b/app/src/main/java/org/fossasia/badgemagic/adapter/SavedClipartsViewHolder.kt index c34dd5ac5..987248a5d 100644 --- a/app/src/main/java/org/fossasia/badgemagic/adapter/SavedClipartsViewHolder.kt +++ b/app/src/main/java/org/fossasia/badgemagic/adapter/SavedClipartsViewHolder.kt @@ -1,7 +1,9 @@ package org.fossasia.badgemagic.adapter import android.graphics.Bitmap +import androidx.appcompat.widget.AppCompatImageView import androidx.recyclerview.widget.RecyclerView +import org.fossasia.badgemagic.R import org.fossasia.badgemagic.databinding.RecyclerItemSavedClipartBinding class SavedClipartsViewHolder(private val binding: RecyclerItemSavedClipartBinding) : RecyclerView.ViewHolder(binding.root) { @@ -10,4 +12,6 @@ class SavedClipartsViewHolder(private val binding: RecyclerItemSavedClipartBindi } fun getBindingView() = binding.root + fun getDeleteButton(): AppCompatImageView = getBindingView().findViewById(R.id.button_delete) + fun getEditButton(): AppCompatImageView = getBindingView().findViewById(R.id.button_edit) } diff --git a/app/src/main/java/org/fossasia/badgemagic/bindings/EditBadgeViewBindings.kt b/app/src/main/java/org/fossasia/badgemagic/bindings/EditBadgeViewBindings.kt index e56754e51..cd2f74ce9 100644 --- a/app/src/main/java/org/fossasia/badgemagic/bindings/EditBadgeViewBindings.kt +++ b/app/src/main/java/org/fossasia/badgemagic/bindings/EditBadgeViewBindings.kt @@ -14,12 +14,17 @@ fun setBadgeDrawState(badge: DrawBadgeLayout, drawModeState: ObservableField) { +@BindingAdapter("drawingBadgeJSON") +fun setEditBadgeValues(badge: DrawBadgeLayout, drawJSON: ObservableField) { val badgeConfig = SendingUtils.getBadgeFromJSON(drawJSON.get() ?: "{}") badgeConfig?.hexStrings?.let { badge.setValue(it) } } +@BindingAdapter("drawingClipartJSON") +fun setEditClipartValues(badge: DrawBadgeLayout, drawJSON: ObservableField>) { + drawJSON.get()?.let { badge.setValue(it) } +} + @BindingAdapter("changeColor") fun changeColorState(imageView: ImageView, isEnabled: ObservableBoolean) { imageView.setColorFilter( diff --git a/app/src/main/java/org/fossasia/badgemagic/database/ClipArtService.kt b/app/src/main/java/org/fossasia/badgemagic/database/ClipArtService.kt index ae9bf5be9..f7cc7dded 100644 --- a/app/src/main/java/org/fossasia/badgemagic/database/ClipArtService.kt +++ b/app/src/main/java/org/fossasia/badgemagic/database/ClipArtService.kt @@ -12,6 +12,7 @@ import org.koin.core.inject class ClipArtService : KoinComponent { private val clipArts = MutableLiveData>() + private val storageClipArts = MutableLiveData>() private val resourceHelper: Resource by inject() init { @@ -46,8 +47,8 @@ class ClipArtService : KoinComponent { tempSparseArray.append(index, it) } } - val drawablesInStorage = getClipsFromStorage() - drawablesInStorage.forEach { + val drawablesInStorage = getClipsFromStorage().value + drawablesInStorage?.forEach { tempSparseArray.append(++lastIndex, it.value) } @@ -55,10 +56,16 @@ class ClipArtService : KoinComponent { } fun updateClipArts() { + storageClipArts.value = StorageUtils.getAllClips() clipArts.value = getAllClips() } fun getClipArts(): LiveData> = clipArts - fun getClipsFromStorage() = StorageUtils.getAllClips() + fun getClipsFromStorage(): LiveData> = storageClipArts + + fun deleteClipart(fileName: String) { + StorageUtils.deleteClipart(fileName) + updateClipArts() + } } \ No newline at end of file diff --git a/app/src/main/java/org/fossasia/badgemagic/di/Modules.kt b/app/src/main/java/org/fossasia/badgemagic/di/Modules.kt index eb919a9e6..05008813b 100644 --- a/app/src/main/java/org/fossasia/badgemagic/di/Modules.kt +++ b/app/src/main/java/org/fossasia/badgemagic/di/Modules.kt @@ -10,6 +10,7 @@ import org.fossasia.badgemagic.viewmodels.SettingsViewModel import org.fossasia.badgemagic.viewmodels.DrawViewModel import org.fossasia.badgemagic.viewmodels.DrawerViewModel import org.fossasia.badgemagic.viewmodels.EditBadgeViewModel +import org.fossasia.badgemagic.viewmodels.EditClipartViewModel import org.fossasia.badgemagic.viewmodels.SavedClipartViewModel import org.koin.android.ext.koin.androidContext import org.koin.androidx.viewmodel.dsl.viewModel @@ -20,6 +21,7 @@ val viewModelModules = module { viewModel { FilesViewModel(get()) } viewModel { SettingsViewModel(get()) } viewModel { EditBadgeViewModel(get()) } + viewModel { EditClipartViewModel(get()) } viewModel { DrawViewModel(get()) } viewModel { DrawerViewModel(get()) } viewModel { SavedClipartViewModel(get()) } diff --git a/app/src/main/java/org/fossasia/badgemagic/ui/EditClipartActivity.kt b/app/src/main/java/org/fossasia/badgemagic/ui/EditClipartActivity.kt new file mode 100644 index 000000000..d1b8f2df1 --- /dev/null +++ b/app/src/main/java/org/fossasia/badgemagic/ui/EditClipartActivity.kt @@ -0,0 +1,48 @@ +package org.fossasia.badgemagic.ui + +import android.os.Bundle +import android.widget.Toast +import androidx.appcompat.app.AppCompatActivity +import androidx.databinding.DataBindingUtil +import androidx.lifecycle.Observer +import kotlinx.android.synthetic.main.activity_edit_clipart.* +import org.fossasia.badgemagic.R +import org.fossasia.badgemagic.databinding.ActivityEditClipartBinding +import org.fossasia.badgemagic.util.Converters +import org.fossasia.badgemagic.util.StorageUtils +import org.fossasia.badgemagic.viewmodels.EditClipartViewModel +import org.koin.androidx.viewmodel.ext.android.viewModel + +class EditClipartActivity : AppCompatActivity() { + + private val editClipartViewModel by viewModel() + private lateinit var fileName: String + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + val activityDrawBinding = DataBindingUtil.setContentView(this, R.layout.activity_edit_clipart) + activityDrawBinding.viewModel = editClipartViewModel + + if (intent.hasExtra("fileName")) { + fileName = intent?.extras?.getString("fileName") ?: "" + editClipartViewModel.drawingJSON.set(Converters.convertDrawableToLEDHex(StorageUtils.getClipartFromPath(fileName), false)) + } + + editClipartViewModel.savedButton.observe(this, Observer { + if (it) { + if (StorageUtils.saveEditedClipart(Converters.convertStringsToLEDHex(draw_layout.getCheckedList()), fileName)) { + Toast.makeText(this, R.string.clipart_saved_success, Toast.LENGTH_LONG).show() + editClipartViewModel.updateClipArts() + } else + Toast.makeText(this, R.string.clipart_saved_error, Toast.LENGTH_LONG).show() + finish() + } + }) + + editClipartViewModel.resetButton.observe(this, Observer { + if (it) { + draw_layout.resetCheckListWithDummyData() + } + }) + } +} diff --git a/app/src/main/java/org/fossasia/badgemagic/ui/fragments/SavedClipartFragment.kt b/app/src/main/java/org/fossasia/badgemagic/ui/fragments/SavedClipartFragment.kt index d3ccca1b2..f281caff3 100644 --- a/app/src/main/java/org/fossasia/badgemagic/ui/fragments/SavedClipartFragment.kt +++ b/app/src/main/java/org/fossasia/badgemagic/ui/fragments/SavedClipartFragment.kt @@ -5,9 +5,12 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.databinding.DataBindingUtil +import androidx.lifecycle.Observer import org.fossasia.badgemagic.R +import org.fossasia.badgemagic.data.SavedClipart import org.fossasia.badgemagic.databinding.FragmentSavedClipartsBinding import org.fossasia.badgemagic.ui.base.BaseFragment +import org.fossasia.badgemagic.util.ImageUtils import org.fossasia.badgemagic.viewmodels.SavedClipartViewModel import org.koin.androidx.viewmodel.ext.android.viewModel @@ -26,4 +29,14 @@ class SavedClipartFragment : BaseFragment() { binding.viewModel = viewModel return binding.root } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + + viewModel.getStorageClipartLiveData().observe(viewLifecycleOwner, Observer { list -> + viewModel.adapter.setList( + list.map { SavedClipart(it.key, ImageUtils.convertToBitmap(it.value)) } + ) + }) + } } \ No newline at end of file diff --git a/app/src/main/java/org/fossasia/badgemagic/util/Converters.kt b/app/src/main/java/org/fossasia/badgemagic/util/Converters.kt index 1fbbee9dc..f5c59eb29 100644 --- a/app/src/main/java/org/fossasia/badgemagic/util/Converters.kt +++ b/app/src/main/java/org/fossasia/badgemagic/util/Converters.kt @@ -14,7 +14,7 @@ const val DRAWABLE_START = '«' const val DRAWABLE_END = '»' object Converters { - private fun convertDrawableToLEDHex(drawableIcon: Drawable?, invertLED: Boolean): List { + fun convertDrawableToLEDHex(drawableIcon: Drawable?, invertLED: Boolean): List { var bm = Bitmap.createBitmap(10, 10, Bitmap.Config.ARGB_8888) if (drawableIcon is VectorDrawable) bm = ImageUtils.scaleBitmap(ImageUtils.vectorToBitmap(drawableIcon), 40) diff --git a/app/src/main/java/org/fossasia/badgemagic/util/StorageUtils.kt b/app/src/main/java/org/fossasia/badgemagic/util/StorageUtils.kt index 0565c7c20..0006817a6 100644 --- a/app/src/main/java/org/fossasia/badgemagic/util/StorageUtils.kt +++ b/app/src/main/java/org/fossasia/badgemagic/util/StorageUtils.kt @@ -160,6 +160,20 @@ object StorageUtils { return true } + fun saveEditedClipart(bitmap: Bitmap, fileName: String): Boolean { + checkDirectory() + val file = File(EXTERNAL_CLIPART_DIRECTORY, fileName) + try { + val out = FileOutputStream(file) + bitmap.compress(Bitmap.CompressFormat.PNG, 100, out) + out.flush() + out.close() + } catch (e: Exception) { + return false + } + return true + } + fun getAllClips(): HashMap { checkDirectory() val list = HashMap() @@ -173,6 +187,10 @@ object StorageUtils { return list } + fun getClipartFromPath(filename: String): Drawable? { + return Drawable.createFromPath(File(EXTERNAL_CLIPART_DIRECTORY, filename).absolutePath) + } + fun deleteClipart(fileName: String) { checkDirectory() val deleteFile = File(EXTERNAL_CLIPART_DIRECTORY, fileName) diff --git a/app/src/main/java/org/fossasia/badgemagic/viewmodels/EditClipartViewModel.kt b/app/src/main/java/org/fossasia/badgemagic/viewmodels/EditClipartViewModel.kt new file mode 100644 index 000000000..b5716a7cc --- /dev/null +++ b/app/src/main/java/org/fossasia/badgemagic/viewmodels/EditClipartViewModel.kt @@ -0,0 +1,48 @@ +package org.fossasia.badgemagic.viewmodels + +import androidx.databinding.ObservableBoolean +import androidx.databinding.ObservableField +import androidx.lifecycle.MutableLiveData +import androidx.lifecycle.ViewModel +import org.fossasia.badgemagic.data.draw_layout.DrawMode +import org.fossasia.badgemagic.database.ClipArtService + +class EditClipartViewModel( + private val clipArtService: ClipArtService +) : ViewModel() { + var drawModeState: ObservableField = ObservableField(DrawMode.NOTHING) + var drawingJSON: ObservableField> = ObservableField(listOf()) + + var drawState: ObservableBoolean = ObservableBoolean(false) + var eraseState: ObservableBoolean = ObservableBoolean(false) + + var savedButton: MutableLiveData = MutableLiveData() + var resetButton: MutableLiveData = MutableLiveData() + + init { + savedButton.value = false + resetButton.value = false + } + + fun changeDrawState() { + drawState.set(!drawState.get()) + eraseState.set(false) + drawModeState.set(if (drawState.get()) DrawMode.DRAW else DrawMode.NOTHING) + } + + fun changeEraseState() { + eraseState.set(!eraseState.get()) + drawState.set(false) + drawModeState.set(if (eraseState.get()) DrawMode.ERASE else DrawMode.NOTHING) + } + + fun saveBadge() { + savedButton.value = true + } + + fun changeResetState() { + resetButton.value = true + } + + fun updateClipArts() = clipArtService.updateClipArts() +} \ No newline at end of file diff --git a/app/src/main/java/org/fossasia/badgemagic/viewmodels/SavedClipartViewModel.kt b/app/src/main/java/org/fossasia/badgemagic/viewmodels/SavedClipartViewModel.kt index 9d8600d77..705108fe7 100644 --- a/app/src/main/java/org/fossasia/badgemagic/viewmodels/SavedClipartViewModel.kt +++ b/app/src/main/java/org/fossasia/badgemagic/viewmodels/SavedClipartViewModel.kt @@ -4,29 +4,17 @@ import androidx.lifecycle.ViewModel import org.fossasia.badgemagic.adapter.SavedClipartsAdapter import org.fossasia.badgemagic.data.SavedClipart import org.fossasia.badgemagic.database.ClipArtService -import org.fossasia.badgemagic.util.ImageUtils -import org.fossasia.badgemagic.util.StorageUtils class SavedClipartViewModel( private val clipArtService: ClipArtService ) : ViewModel() { var cliparts = listOf() - var adapter = SavedClipartsAdapter(cliparts.map { it.bitmap }, this) + var adapter = SavedClipartsAdapter(cliparts, this) - init { - cliparts = clipArtService.getClipsFromStorage().map { SavedClipart(it.key, ImageUtils.convertToBitmap(it.value)) } - adapter = SavedClipartsAdapter(cliparts.map { it.bitmap }, this) - } - - private fun update() { - clipArtService.updateClipArts() - cliparts = clipArtService.getClipsFromStorage().map { SavedClipart(it.key, ImageUtils.convertToBitmap(it.value)) } - adapter.setList(cliparts.map { it.bitmap }) - } + fun getStorageClipartLiveData() = clipArtService.getClipsFromStorage() fun deleteClipart(position: Int) { - StorageUtils.deleteClipart(cliparts[position].fileName) - update() + clipArtService.deleteClipart(cliparts[position].fileName) } } diff --git a/app/src/main/res/layout/activity_edit_badge.xml b/app/src/main/res/layout/activity_edit_badge.xml index 7531adfd2..efe471b80 100644 --- a/app/src/main/res/layout/activity_edit_badge.xml +++ b/app/src/main/res/layout/activity_edit_badge.xml @@ -22,10 +22,10 @@ android:layout_above="@id/tools_bar" android:layout_alignParentTop="true" android:layout_centerInParent="true" - android:layout_marginStart="50dp" - android:layout_marginEnd="50dp" + android:layout_marginStart="@dimen/draw_layout_margin" + android:layout_marginEnd="@dimen/draw_layout_margin" app:drawState="@{viewModel.drawModeState}" - app:drawingJSON="@{viewModel.drawingJSON}" /> + app:drawingBadgeJSON="@{viewModel.drawingJSON}" /> + android:padding="@dimen/draw_layout_button_padding"> @@ -58,14 +58,14 @@ @@ -78,14 +78,14 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/recycler_item_saved_clipart.xml b/app/src/main/res/layout/recycler_item_saved_clipart.xml index debef1f86..c3cd61c82 100644 --- a/app/src/main/res/layout/recycler_item_saved_clipart.xml +++ b/app/src/main/res/layout/recycler_item_saved_clipart.xml @@ -60,7 +60,7 @@ app:srcCompat="@drawable/ic_draw_pencil" /> Date: Thu, 11 Jul 2019 13:01:48 +0530 Subject: [PATCH 05/10] chore(deps): bump material from 1.1.0-alpha07 to 1.1.0-alpha08 (#441) Bumps [material](https://github.com/material-components/material-components-android) from 1.1.0-alpha07 to 1.1.0-alpha08. - [Release notes](https://github.com/material-components/material-components-android/releases) - [Commits](https://github.com/material-components/material-components-android/compare/1.1.0-alpha07...1.1.0-alpha08) Signed-off-by: dependabot-preview[bot] --- app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index 5e63ae145..83e40e667 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -93,7 +93,7 @@ dependencies { implementation "org.koin:koin-androidx-viewmodel:${versions.koin_version}" //Material Design - implementation 'com.google.android.material:material:1.1.0-alpha07' + implementation 'com.google.android.material:material:1.1.0-alpha08' //Timber implementation 'com.jakewharton.timber:timber:4.7.1' From 775a80b2f1368c3a142314c756563452ae57a005 Mon Sep 17 00:00:00 2001 From: Aditya Gupta Date: Thu, 18 Jul 2019 12:50:56 +0530 Subject: [PATCH 06/10] fix: travis build (#448) --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 97a6e1ee7..288afb4eb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,8 +16,6 @@ cache: - "${TRAVIS_BUILD_DIR}/gradle/wrapper/dists/" - "$HOME/.gradle/caches/" - "$HOME/.gradle/wrapper/" -install: - - echo yes | sdkmanager "platforms;android-28" before_script: - bash scripts/prep-key.sh script: From 35d16f0cde5385197a0d4afcb6a725074a93aadc Mon Sep 17 00:00:00 2001 From: Aditya Gupta Date: Thu, 18 Jul 2019 13:17:14 +0530 Subject: [PATCH 07/10] build(deps): updated kotlin version (#447) --- versions.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/versions.gradle b/versions.gradle index c09ae3da8..c8670c652 100644 --- a/versions.gradle +++ b/versions.gradle @@ -5,7 +5,7 @@ versions.buildTools = '28.0.3' versions.minSdk = 21 versions.targetSdk = 28 -versions.kotlin_version = '1.3.31' +versions.kotlin_version = '1.3.41' versions.koin_version = '2.0.1' versions.moshi_version = '1.8.0' From 46e6394a62318d599320ea58d6465f81401acfeb Mon Sep 17 00:00:00 2001 From: Aditya Gupta Date: Thu, 18 Jul 2019 14:16:19 +0530 Subject: [PATCH 08/10] fix: Invert LED bug (#444) --- .../fossasia/badgemagic/util/Converters.kt | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/fossasia/badgemagic/util/Converters.kt b/app/src/main/java/org/fossasia/badgemagic/util/Converters.kt index f5c59eb29..fb71182fb 100644 --- a/app/src/main/java/org/fossasia/badgemagic/util/Converters.kt +++ b/app/src/main/java/org/fossasia/badgemagic/util/Converters.kt @@ -185,7 +185,7 @@ object Converters { val foundIndex = editable.indexOf(DRAWABLE_END, i) i = if (foundIndex > 0) { listOfArt.addAll( - convertDrawableToLEDHex(drawableSparse.get(editable.substring(i + 1, foundIndex).toInt()), invertLED) + handleInvertLED(convertDrawableToLEDHex(drawableSparse.get(editable.substring(i + 1, foundIndex).toInt()), invertLED), i == 0 && invertLED) ) foundIndex + 1 } else { @@ -193,7 +193,7 @@ object Converters { } } else { listOfArt.addAll( - convertTextToLEDHex(ch.toString(), invertLED).second + handleInvertLED(convertTextToLEDHex(ch.toString(), invertLED).second, i == 0 && invertLED) ) i++ } @@ -201,6 +201,25 @@ object Converters { return listOfArt } + private fun handleInvertLED(hexStrings: List, addPrefix: Boolean): List { + if (!addPrefix) + return hexStrings + + val listNew = mutableListOf() + if (checkValueInFirstColumn(hexStrings)) + listNew.add("0101010101010101010101") + listNew.addAll(hexStrings) + return listNew + } + + private fun checkValueInFirstColumn(hexStrings: List): Boolean { + for (i in 0 until hexStrings[0].length step 2) { + if (BigInteger(hexStrings[0][i].toString(), 16).toString(10).toInt() < 8) + return true + } + return false + } + fun convertStringsToLEDHex(list: ArrayList): Bitmap { val newBitmap = Bitmap.createBitmap(list[0].list.size, list.size, Bitmap.Config.ARGB_8888) for (i in 0 until list.size) { From ea25302fe58336ba9ac1e1e2bde8c09bd83587a1 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Thu, 18 Jul 2019 14:41:45 +0530 Subject: [PATCH 09/10] chore(deps): bump kluent from 1.52 to 1.53 (#443) Bumps kluent from 1.52 to 1.53. Signed-off-by: dependabot-preview[bot] --- app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index 83e40e667..b1a7d7c73 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -103,7 +103,7 @@ dependencies { implementation 'androidx.legacy:legacy-support-v4:1.0.0' testImplementation 'junit:junit:4.12' testImplementation 'com.nhaarman:mockito-kotlin-kt1.1:1.5.0' - testImplementation 'org.amshove.kluent:kluent:1.52' + testImplementation 'org.amshove.kluent:kluent:1.53' // Leak Canary debugImplementation "com.squareup.leakcanary:leakcanary-android:${versions.leak_canary}" From 2622a20e8064a801c16c9f210d2ef4887798967a Mon Sep 17 00:00:00 2001 From: Aditya Gupta Date: Wed, 24 Jul 2019 00:22:24 +0530 Subject: [PATCH 10/10] chore: updated build version to 1.4.0 (#452) --- app/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index b1a7d7c73..57f773ac6 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -23,8 +23,8 @@ android { applicationId 'org.fossasia.badgemagic' minSdkVersion versions.minSdk targetSdkVersion versions.targetSdk - versionCode 5 - versionName '1.3.0' + versionCode 6 + versionName '1.4.0' vectorDrawables.useSupportLibrary = true }