Skip to content

Commit

Permalink
chore: release v1.2.0 (#403)
Browse files Browse the repository at this point in the history
chore: release v1.2.0
  • Loading branch information
iamareebjamal authored Jun 20, 2019
2 parents c438b11 + a093c4e commit 1fc58ef
Show file tree
Hide file tree
Showing 76 changed files with 4,070 additions and 169 deletions.
21 changes: 21 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name-template: Release v$NEXT_MINOR_VERSION 🌈
tag-template: v$NEXT_MINOR_VERSION
categories:
- title: 🚀 Features
label: feature
- title: 🐛 Bug Fixes
label: fix
- title: 🧰 Maintenance
label: chore
- title: Dependencies and Libraries
label: dependencies
change-template: '- $TITLE (#$NUMBER) - @$AUTHOR'
template: |
## Changes
$CHANGES
## Contributors
Thanks a lot to our contributors for making this release possible:
$CONTRIBUTORS
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id "com.diffplug.gradle.spotless" version "3.23.0"
id "com.diffplug.gradle.spotless" version "3.23.1"
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
Expand All @@ -18,8 +18,8 @@ android {
applicationId 'org.fossasia.badgemagic'
minSdkVersion versions.minSdk
targetSdkVersion versions.targetSdk
versionCode 3
versionName '1.1.0'
versionCode 4
versionName '1.2.0'
vectorDrawables.useSupportLibrary = true
}

Expand Down
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,37 @@ import android.view.LayoutInflater
import android.view.ViewGroup
import org.fossasia.badgemagic.R
import org.fossasia.badgemagic.data.DrawableInfo
import org.fossasia.badgemagic.ui.DrawerActivity

class DrawableAdapter : RecyclerView.Adapter<DrawableItemHolder>() {
var onDrawableSelected: OnDrawableSelected? = null
private val drawableList = mutableListOf<DrawableInfo>()

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): DrawableItemHolder {
val v = LayoutInflater.from(parent.context).inflate(R.layout.recycler_item, parent, false)
return DrawableItemHolder(v)
return DrawableItemHolder(
when (viewType) {
R.layout.recycler_item -> LayoutInflater.from(parent.context).inflate(R.layout.recycler_item, parent, false)
else -> LayoutInflater.from(parent.context).inflate(R.layout.recycler_item_add, parent, false)
}
)
}

override fun getItemViewType(position: Int) = position
override fun getItemViewType(position: Int) = if (position == drawableList.size) R.layout.recycler_item_add else R.layout.recycler_item

override fun getItemId(position: Int) = position.toLong()

override fun onBindViewHolder(holder: DrawableItemHolder, position: Int) {
holder.apply {
bind(drawableList[position])
listener = onDrawableSelected
}
if (position != drawableList.size)
holder.apply {
bind(drawableList[position])
listener = onDrawableSelected
}
else
holder.itemView.setOnClickListener {
val contextAct = it.context
if (contextAct is DrawerActivity)
contextAct.switchToDrawLayout()
}
}

fun addAll(newDrawableList: List<DrawableInfo>) {
Expand All @@ -32,7 +44,7 @@ class DrawableAdapter : RecyclerView.Adapter<DrawableItemHolder>() {
notifyDataSetChanged()
}

override fun getItemCount() = drawableList.size
override fun getItemCount() = drawableList.size + 1
}

interface OnDrawableSelected {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
package org.fossasia.badgemagic.adapter

import android.graphics.drawable.BitmapDrawable
import android.graphics.drawable.VectorDrawable
import android.view.View
import android.widget.ImageView
import android.widget.LinearLayout
import androidx.recyclerview.widget.RecyclerView
import org.fossasia.badgemagic.R
import org.fossasia.badgemagic.data.DrawableInfo
import org.fossasia.badgemagic.util.ImageUtils

class DrawableItemHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {

private val card: LinearLayout = itemView.findViewById(R.id.card)
private val image: ImageView = itemView.findViewById(R.id.image)
var listener: OnDrawableSelected? = null

fun bind(drawableInfo: DrawableInfo) {
image.setImageBitmap(ImageUtils.trim((drawableInfo.image as BitmapDrawable).bitmap, 100))

if (drawableInfo.image is VectorDrawable)
image.setImageBitmap(ImageUtils.trim(ImageUtils.vectorToBitmap(drawableInfo.image), 80))
else if (drawableInfo.image is BitmapDrawable)
image.setImageBitmap(ImageUtils.trim(drawableInfo.image.bitmap, 80))

image.setColorFilter(itemView.context.resources.getColor(android.R.color.black))

Expand Down
16 changes: 16 additions & 0 deletions app/src/main/java/org/fossasia/badgemagic/adapter/SaveAdapter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ class SaveAdapter(private val context: Context?, private val list: List<ConfigIn

override fun getItemCount() = list.size

fun resetSelectedItem() {
selectedPosition = -1
notifyDataSetChanged()
}

fun getSelectedItem(): ConfigInfo? {
return if (selectedPosition == -1) null else list[selectedPosition]
}
Expand All @@ -42,6 +47,7 @@ class SaveAdapter(private val context: Context?, private val list: List<ConfigIn
private val text: TextView = itemView.findViewById(R.id.text)
private val options: AppCompatImageView = itemView.findViewById(R.id.options)
private val playPause: AppCompatImageView = itemView.findViewById(R.id.play_pause)
private val editButton: AppCompatImageView = itemView.findViewById(R.id.button_edit)
private val chipFlash: Chip = itemView.findViewById(R.id.chip_flash)
private val chipMarquee: Chip = itemView.findViewById(R.id.chip_marquee)
private val chipInverted: Chip = itemView.findViewById(R.id.chip_inverted)
Expand All @@ -56,6 +62,9 @@ class SaveAdapter(private val context: Context?, private val list: List<ConfigIn
options.setOnClickListener {
listener.onOptionsSelected(list[adapterPosition])
}
editButton.setOnClickListener {
listener.onEdit(list[adapterPosition])
}
}

fun bind(item: ConfigInfo) {
Expand All @@ -77,6 +86,12 @@ class SaveAdapter(private val context: Context?, private val list: List<ConfigIn
else -> context.resources.getColor(android.R.color.black)
}
)
editButton.setColorFilter(
when {
selectedPosition != -1 && selectedPosition == adapterPosition -> context.resources.getColor(android.R.color.white)
else -> context.resources.getColor(android.R.color.black)
}
)
options.setColorFilter(
when {
selectedPosition != -1 && selectedPosition == adapterPosition -> context.resources.getColor(android.R.color.white)
Expand Down Expand Up @@ -110,5 +125,6 @@ class SaveAdapter(private val context: Context?, private val list: List<ConfigIn

interface OnSavedItemSelected {
fun onSelected(item: ConfigInfo?)
fun onEdit(item: ConfigInfo?)
fun onOptionsSelected(item: ConfigInfo)
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@ import androidx.databinding.ObservableField
import org.fossasia.badgemagic.R
import org.fossasia.badgemagic.data.draw_layout.DrawMode
import org.fossasia.badgemagic.ui.custom.DrawBadgeLayout
import org.fossasia.badgemagic.util.SendingUtils

@BindingAdapter("drawState")
fun setBadgeDrawState(badge: DrawBadgeLayout, drawModeState: ObservableField<DrawMode>) {
drawModeState.get()?.let { badge.changeDrawState(it) }
}

@BindingAdapter("resetState")
fun resetDrawBadge(badge: DrawBadgeLayout, isEnabled: ObservableBoolean) {
badge.resetCheckList()
@BindingAdapter("drawingJSON")
fun setBadgeValues(badge: DrawBadgeLayout, drawJSON: ObservableField<String>) {
val badgeConfig = SendingUtils.getBadgeFromJSON(drawJSON.get() ?: "{}")
badgeConfig?.hexStrings?.let { badge.setValue(it) }
}

@BindingAdapter("changeColor")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import org.fossasia.badgemagic.R
import org.fossasia.badgemagic.util.Resource
import org.fossasia.badgemagic.util.StorageUtils
import org.koin.core.KoinComponent
import org.koin.core.inject

Expand All @@ -14,32 +15,47 @@ class ClipArtService : KoinComponent {
private val resourceHelper: Resource by inject()

init {
updateClipArts()
}

private fun getAllClips(): SparseArray<Drawable> {
val tempSparseArray = SparseArray<Drawable>()
val listOfDrawables = listOf(
resourceHelper.getDrawable(R.drawable.apple),
resourceHelper.getDrawable(R.drawable.clock),
resourceHelper.getDrawable(R.drawable.dustbin),
resourceHelper.getDrawable(R.drawable.face),
resourceHelper.getDrawable(R.drawable.heart),
resourceHelper.getDrawable(R.drawable.home),
resourceHelper.getDrawable(R.drawable.invader),
resourceHelper.getDrawable(R.drawable.mail),
resourceHelper.getDrawable(R.drawable.mix1),
resourceHelper.getDrawable(R.drawable.mix2),
resourceHelper.getDrawable(R.drawable.mushroom),
resourceHelper.getDrawable(R.drawable.mustache),
resourceHelper.getDrawable(R.drawable.oneup),
resourceHelper.getDrawable(R.drawable.pause),
resourceHelper.getDrawable(R.drawable.spider),
resourceHelper.getDrawable(R.drawable.sun),
resourceHelper.getDrawable(R.drawable.thumbs_up)
resourceHelper.getDrawable(R.drawable.clip_apple),
resourceHelper.getDrawable(R.drawable.clip_clock),
resourceHelper.getDrawable(R.drawable.clip_dustbin),
resourceHelper.getDrawable(R.drawable.clip_face),
resourceHelper.getDrawable(R.drawable.clip_heart),
resourceHelper.getDrawable(R.drawable.clip_home),
resourceHelper.getDrawable(R.drawable.clip_invader),
resourceHelper.getDrawable(R.drawable.clip_mail),
resourceHelper.getDrawable(R.drawable.clip_mix1),
resourceHelper.getDrawable(R.drawable.clip_mix2),
resourceHelper.getDrawable(R.drawable.clip_mushroom),
resourceHelper.getDrawable(R.drawable.clip_mustache),
resourceHelper.getDrawable(R.drawable.clip_oneup),
resourceHelper.getDrawable(R.drawable.clip_pause),
resourceHelper.getDrawable(R.drawable.clip_spider),
resourceHelper.getDrawable(R.drawable.clip_sun),
resourceHelper.getDrawable(R.drawable.clip_thumbs_up)
)
var lastIndex = 0
listOfDrawables.forEachIndexed { index, drawable ->
drawable?.let {
lastIndex = index
tempSparseArray.append(index, it)
}
}
clipArts.value = tempSparseArray
val drawablesInStorage = StorageUtils.getAllClips()
drawablesInStorage.forEach {
tempSparseArray.append(++lastIndex, it)
}

return tempSparseArray
}

fun updateClipArts() {
clipArts.value = getAllClips()
}

fun getClipArts(): LiveData<SparseArray<Drawable>> = clipArts
Expand Down
6 changes: 5 additions & 1 deletion app/src/main/java/org/fossasia/badgemagic/di/Modules.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ 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.DrawerViewModel
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 +18,9 @@ val viewModelModules = module {
viewModel { TextArtViewModel(get(), get()) }
viewModel { FilesViewModel(get()) }
viewModel { SettingsViewModel(get()) }
viewModel { DrawViewModel() }
viewModel { EditBadgeViewModel(get()) }
viewModel { DrawViewModel(get()) }
viewModel { DrawerViewModel(get()) }
}

val singletonModules = module {
Expand Down
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
}
20 changes: 0 additions & 20 deletions app/src/main/java/org/fossasia/badgemagic/ui/DrawActivity.kt

This file was deleted.

Loading

0 comments on commit 1fc58ef

Please sign in to comment.