bugfixes and translation
This commit is contained in:
parent
6bbf436f45
commit
edd9c666ac
|
@ -14,6 +14,7 @@ import org.foxarmy.barcodescannerforemployees.dataclasses.Product
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.FileOutputStream
|
import java.io.FileOutputStream
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
|
import java.util.concurrent.TimeUnit
|
||||||
|
|
||||||
class Net {
|
class Net {
|
||||||
var language = "en-US"
|
var language = "en-US"
|
||||||
|
@ -518,7 +519,11 @@ class Net {
|
||||||
|
|
||||||
fun downloadImage(url: String, file: File, callback: () -> Unit) {
|
fun downloadImage(url: String, file: File, callback: () -> Unit) {
|
||||||
CoroutineScope(Dispatchers.IO).launch {
|
CoroutineScope(Dispatchers.IO).launch {
|
||||||
val client = OkHttpClient()
|
val client = OkHttpClient.Builder()
|
||||||
|
.connectTimeout(30, TimeUnit.SECONDS)
|
||||||
|
.readTimeout(10, TimeUnit.MINUTES)
|
||||||
|
.build()
|
||||||
|
|
||||||
val request = Request.Builder()
|
val request = Request.Builder()
|
||||||
.url(url)
|
.url(url)
|
||||||
.addHeader("Authorization", "Bearer $token")
|
.addHeader("Authorization", "Bearer $token")
|
||||||
|
|
|
@ -77,18 +77,20 @@ class WebSocketClient(private val context: Context, private val server: String)
|
||||||
val url = "https://${net.server}/api/abstractproduct/getImage/${currentGroup}/${data["local_id"]}"
|
val url = "https://${net.server}/api/abstractproduct/getImage/${currentGroup}/${data["local_id"]}"
|
||||||
net.downloadImage(url, pictureFile, {
|
net.downloadImage(url, pictureFile, {
|
||||||
abstractProductDAO.addAbstractProduct(newAbstractProduct)
|
abstractProductDAO.addAbstractProduct(newAbstractProduct)
|
||||||
|
(context as MainActivity).updateAll()
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
"product" -> {
|
"product" -> {
|
||||||
val newProduct = Product.createFromJSON(data)
|
val newProduct = Product.createFromJSON(data)
|
||||||
productDAO.insertNewProduct(newProduct)
|
productDAO.insertNewProduct(newProduct)
|
||||||
|
(context as MainActivity).updateAll()
|
||||||
}
|
}
|
||||||
|
|
||||||
"category" -> {
|
"category" -> {
|
||||||
val newCategory = Category.createFromJSON(data)
|
val newCategory = Category.createFromJSON(data)
|
||||||
categoryDAO.addCategory(newCategory)
|
categoryDAO.addCategory(newCategory)
|
||||||
|
(context as MainActivity).updateAll()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -110,16 +112,19 @@ class WebSocketClient(private val context: Context, private val server: String)
|
||||||
val url = "https://${net.server}/api/abstractproduct/getImage/${currentGroup}/${data["local_id"]}"
|
val url = "https://${net.server}/api/abstractproduct/getImage/${currentGroup}/${data["local_id"]}"
|
||||||
net.downloadImage(url, pictureFile, {
|
net.downloadImage(url, pictureFile, {
|
||||||
abstractProductDAO.updateAbstractProduct(updatedAbstractProduct)
|
abstractProductDAO.updateAbstractProduct(updatedAbstractProduct)
|
||||||
|
(context as MainActivity).updateAll()
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
"product" -> {
|
"product" -> {
|
||||||
val updatedProduct = Product.createFromJSON(data)
|
val updatedProduct = Product.createFromJSON(data)
|
||||||
productDAO.updateProduct(updatedProduct)
|
productDAO.updateProduct(updatedProduct)
|
||||||
|
(context as MainActivity).updateAll()
|
||||||
}
|
}
|
||||||
"category" -> {
|
"category" -> {
|
||||||
val updatedCategory = Category.createFromJSON(data)
|
val updatedCategory = Category.createFromJSON(data)
|
||||||
categoryDAO.updateCategory(updatedCategory)
|
categoryDAO.updateCategory(updatedCategory)
|
||||||
|
(context as MainActivity).updateAll()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -130,19 +135,20 @@ class WebSocketClient(private val context: Context, private val server: String)
|
||||||
when(item) {
|
when(item) {
|
||||||
"abstractproduct" -> {
|
"abstractproduct" -> {
|
||||||
abstractProductDAO.eraseAbstractProduct(id.toInt(), context)
|
abstractProductDAO.eraseAbstractProduct(id.toInt(), context)
|
||||||
|
(context as MainActivity).updateAll()
|
||||||
}
|
}
|
||||||
"product" -> {
|
"product" -> {
|
||||||
productDAO.eraseProduct(id.toInt())
|
productDAO.eraseProduct(id.toInt())
|
||||||
|
(context as MainActivity).updateAll()
|
||||||
}
|
}
|
||||||
"category" -> {
|
"category" -> {
|
||||||
categoryDAO.eraseCategory(id.toInt(), context)
|
categoryDAO.eraseCategory(id.toInt(), context)
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
(context as MainActivity).updateAll()
|
(context as MainActivity).updateAll()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun onClosing(webSocket: WebSocket, code: Int, reason: String) {
|
override fun onClosing(webSocket: WebSocket, code: Int, reason: String) {
|
||||||
Log.d("QWERTYUIOP", "Closing ws. Reason: $reason")
|
Log.d("QWERTYUIOP", "Closing ws. Reason: $reason")
|
||||||
|
|
|
@ -69,8 +69,10 @@ class ManageGroupActivity : AppCompatActivity() {
|
||||||
if (response.code == 200) {
|
if (response.code == 200) {
|
||||||
val groups = sharedPreferences.getStringSet("groups", emptySet())!!
|
val groups = sharedPreferences.getStringSet("groups", emptySet())!!
|
||||||
groups.remove(groupId.toString())
|
groups.remove(groupId.toString())
|
||||||
if (groups.isEmpty()) {
|
|
||||||
sharedPreferences.edit().putStringSet("groups", groups).apply()
|
sharedPreferences.edit().putStringSet("groups", groups).apply()
|
||||||
|
sharedPreferences.edit().putString("currentGroup", "").apply()
|
||||||
|
|
||||||
|
if (groups.isEmpty()) {
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
val intent = Intent(this, GroupActivity::class.java)
|
val intent = Intent(this, GroupActivity::class.java)
|
||||||
startActivity(intent)
|
startActivity(intent)
|
||||||
|
@ -96,7 +98,7 @@ class ManageGroupActivity : AppCompatActivity() {
|
||||||
val groupMemberView = GroupMemberView(this, this as Context, response.body!!.string(), user)
|
val groupMemberView = GroupMemberView(this, this as Context, response.body!!.string(), user)
|
||||||
|
|
||||||
groupMemberView.setOnLongClickListener { view ->
|
groupMemberView.setOnLongClickListener { view ->
|
||||||
amIAnAdminIn(groupId, {amIAnAdmin ->
|
amIAnAdminIn(groupId, { amIAnAdmin ->
|
||||||
if (!amIAnAdmin) return@amIAnAdminIn
|
if (!amIAnAdmin) return@amIAnAdminIn
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
val popupMenu = PopupMenu(this, groupMemberView)
|
val popupMenu = PopupMenu(this, groupMemberView)
|
||||||
|
@ -165,10 +167,12 @@ class ManageGroupActivity : AppCompatActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setUpAdminRelatedButtons() {
|
fun setUpAdminRelatedButtons() {
|
||||||
amIAnAdminIn(groupId, {isAdmin ->
|
amIAnAdminIn(groupId, { isAdmin ->
|
||||||
|
runOnUiThread {
|
||||||
if (!isAdmin) {
|
if (!isAdmin) {
|
||||||
binding.renameButton.visibility = View.GONE
|
binding.renameButton.visibility = View.GONE
|
||||||
}
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -7,6 +7,7 @@ import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.*
|
import android.widget.*
|
||||||
|
import androidx.constraintlayout.widget.ConstraintLayout
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.core.view.children
|
import androidx.core.view.children
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
|
@ -17,7 +18,6 @@ import org.foxarmy.barcodescannerforemployees.activities.FindBarcodelessAbstract
|
||||||
import org.foxarmy.barcodescannerforemployees.database.AbstractProductDAO
|
import org.foxarmy.barcodescannerforemployees.database.AbstractProductDAO
|
||||||
import org.foxarmy.barcodescannerforemployees.database.DBStorageController
|
import org.foxarmy.barcodescannerforemployees.database.DBStorageController
|
||||||
import org.foxarmy.barcodescannerforemployees.databinding.FragmentStorageBinding
|
import org.foxarmy.barcodescannerforemployees.databinding.FragmentStorageBinding
|
||||||
import org.foxarmy.barcodescannerforemployees.dataclasses.AbstractProduct
|
|
||||||
import org.foxarmy.barcodescannerforemployees.generateThumbnailForImage
|
import org.foxarmy.barcodescannerforemployees.generateThumbnailForImage
|
||||||
import org.foxarmy.barcodescannerforemployees.getPreferences
|
import org.foxarmy.barcodescannerforemployees.getPreferences
|
||||||
import org.foxarmy.barcodescannerforemployees.views.AbstractProductView
|
import org.foxarmy.barcodescannerforemployees.views.AbstractProductView
|
||||||
|
@ -161,12 +161,26 @@ class StorageFragment : Fragment() {
|
||||||
)
|
)
|
||||||
|
|
||||||
if (filterBy == "barcodeless") {
|
if (filterBy == "barcodeless") {
|
||||||
abstractProductView.setOnClickListener {
|
abstractProductView.also {
|
||||||
|
it.setOnClickListener {
|
||||||
(activity as FindBarcodelessAbstractProduct).selected(abstractProductView.abstractProduct)
|
(activity as FindBarcodelessAbstractProduct).selected(abstractProductView.abstractProduct)
|
||||||
}
|
}
|
||||||
abstractProductView.findViewById<TextView>(R.id.productNameView).setOnClickListener {
|
it.findViewById<TextView>(R.id.productNameView).setOnClickListener {
|
||||||
(activity as FindBarcodelessAbstractProduct).selected(abstractProductView.abstractProduct)
|
(activity as FindBarcodelessAbstractProduct).selected(abstractProductView.abstractProduct)
|
||||||
}
|
}
|
||||||
|
it.findViewById<ConstraintLayout>(R.id.productLayout).setOnClickListener {
|
||||||
|
(activity as FindBarcodelessAbstractProduct).selected(abstractProductView.abstractProduct)
|
||||||
|
}
|
||||||
|
it.findViewById<TextView>(R.id.categoryView).setOnClickListener {
|
||||||
|
(activity as FindBarcodelessAbstractProduct).selected(abstractProductView.abstractProduct)
|
||||||
|
}
|
||||||
|
it.findViewById<TextView>(R.id.unitView).setOnClickListener {
|
||||||
|
(activity as FindBarcodelessAbstractProduct).selected(abstractProductView.abstractProduct)
|
||||||
|
}
|
||||||
|
it.findViewById<TextView>(R.id.productNetWeightView).setOnClickListener {
|
||||||
|
(activity as FindBarcodelessAbstractProduct).selected(abstractProductView.abstractProduct)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
activity!!.runOnUiThread{
|
activity!!.runOnUiThread{
|
||||||
|
|
|
@ -114,11 +114,12 @@ class AbstractProductView : LinearLayout {
|
||||||
} else {
|
} else {
|
||||||
mainActivity.removeSelection()
|
mainActivity.removeSelection()
|
||||||
}
|
}
|
||||||
|
activity.runOnUiThread {
|
||||||
this.background = ContextCompat.getDrawable(
|
this.background = ContextCompat.getDrawable(
|
||||||
context,
|
context,
|
||||||
if (isProductSelected) R.drawable.outline_selected else R.drawable.outline
|
if (isProductSelected) R.drawable.outline_selected else R.drawable.outline
|
||||||
)
|
)
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
} else {
|
} else {
|
||||||
return false
|
return false
|
||||||
|
@ -137,22 +138,24 @@ class AbstractProductView : LinearLayout {
|
||||||
} else {
|
} else {
|
||||||
mainActivity.removeSelection()
|
mainActivity.removeSelection()
|
||||||
}
|
}
|
||||||
|
activity.runOnUiThread {
|
||||||
this.background = ContextCompat.getDrawable(
|
this.background = ContextCompat.getDrawable(
|
||||||
context,
|
context,
|
||||||
if (isProductSelected) R.drawable.outline_selected else R.drawable.outline
|
if (isProductSelected) R.drawable.outline_selected else R.drawable.outline
|
||||||
)
|
)
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
} else {
|
} else {
|
||||||
mainActivity.addSelection()
|
mainActivity.addSelection()
|
||||||
|
|
||||||
isProductSelected = !isProductSelected
|
isProductSelected = !isProductSelected
|
||||||
|
activity.runOnUiThread {
|
||||||
|
|
||||||
this.background = ContextCompat.getDrawable(
|
this.background = ContextCompat.getDrawable(
|
||||||
context,
|
context,
|
||||||
if (isProductSelected) R.drawable.outline_selected else R.drawable.outline
|
if (isProductSelected) R.drawable.outline_selected else R.drawable.outline
|
||||||
)
|
)
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -182,8 +185,9 @@ class AbstractProductView : LinearLayout {
|
||||||
|
|
||||||
private fun onNameLongClick(): Boolean {
|
private fun onNameLongClick(): Boolean {
|
||||||
if (activity !is MainActivity) {
|
if (activity !is MainActivity) {
|
||||||
|
activity.runOnUiThread {
|
||||||
Toast.makeText(activity, productNameField!!.text, Toast.LENGTH_SHORT).show()
|
Toast.makeText(activity, productNameField!!.text, Toast.LENGTH_SHORT).show()
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
val mainActivity = activity as MainActivity
|
val mainActivity = activity as MainActivity
|
||||||
|
@ -191,8 +195,10 @@ class AbstractProductView : LinearLayout {
|
||||||
if (mainActivity.selectionMode) {
|
if (mainActivity.selectionMode) {
|
||||||
return onAnyLongClick()
|
return onAnyLongClick()
|
||||||
} else {
|
} else {
|
||||||
|
activity.runOnUiThread {
|
||||||
Toast.makeText(activity, productNameField!!.text, Toast.LENGTH_SHORT).show()
|
Toast.makeText(activity, productNameField!!.text, Toast.LENGTH_SHORT).show()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -82,6 +82,8 @@ class CategoryView : LinearLayout {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateStroke() {
|
private fun updateStroke() {
|
||||||
|
(context as Activity).runOnUiThread {
|
||||||
this.background = ContextCompat.getDrawable(context, if (isCategorySelected) R.drawable.outline_selected else R.drawable.outline)
|
this.background = ContextCompat.getDrawable(context, if (isCategorySelected) R.drawable.outline_selected else R.drawable.outline)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -228,7 +228,6 @@ class ProductView : LinearLayout {
|
||||||
this.background = ContextCompat.getDrawable(context, R.drawable.outline_selected)
|
this.background = ContextCompat.getDrawable(context, R.drawable.outline_selected)
|
||||||
} else {
|
} else {
|
||||||
if (product.id != 0) {
|
if (product.id != 0) {
|
||||||
thread {
|
|
||||||
this.outline = GradientDrawable()
|
this.outline = GradientDrawable()
|
||||||
backgroundColor = evaluateColor()
|
backgroundColor = evaluateColor()
|
||||||
strokeColor = darkenColor(backgroundColor, 0.25) // (backgroundColor and 0xfefefe ) shr 1
|
strokeColor = darkenColor(backgroundColor, 0.25) // (backgroundColor and 0xfefefe ) shr 1
|
||||||
|
@ -236,7 +235,6 @@ class ProductView : LinearLayout {
|
||||||
this.outline.setStroke(4, strokeColor)
|
this.outline.setStroke(4, strokeColor)
|
||||||
this.outline.alpha = 84
|
this.outline.alpha = 84
|
||||||
this.background = outline
|
this.background = outline
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
this.background = ContextCompat.getDrawable(context, R.drawable.outline)
|
this.background = ContextCompat.getDrawable(context, R.drawable.outline)
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,14 +120,12 @@
|
||||||
<string name="online_only_feature">Эта возможность доступна только с онлайн аккаунтом</string>
|
<string name="online_only_feature">Эта возможность доступна только с онлайн аккаунтом</string>
|
||||||
<string name="username_changed">Имя пользователя изменено. Пожалуйста, перезайдите</string>
|
<string name="username_changed">Имя пользователя изменено. Пожалуйста, перезайдите</string>
|
||||||
<string name="password_changed">Пароль изменён. Пожалуйста, перезайдите</string>
|
<string name="password_changed">Пароль изменён. Пожалуйста, перезайдите</string>
|
||||||
<string name="new_group_name">Enter new group name</string>
|
<string name="new_group_name">Введите новое имя группы</string>
|
||||||
<string name="kick">Kick</string>
|
<string name="kick">Выгнать</string>
|
||||||
<string name="transfer_ownership">Transfer ownership</string>
|
<string name="transfer_ownership">Передать владение группой</string>
|
||||||
<string name="transfer_ownership_confirmation">Are you sure you want to transfer ownership on current group to that
|
<string name="transfer_ownership_confirmation">Вы увереных, что хотите передать владение группой этому пользователю?</string>
|
||||||
user?
|
<string name="loading_please_wait">Загрузка, пожалуйста ждите</string>
|
||||||
</string>
|
<string name="loading">Загрузка</string>
|
||||||
<string name="loading_please_wait">Loading, please wait</string>
|
|
||||||
<string name="loading">Loading</string>
|
|
||||||
<string-array name="languages">
|
<string-array name="languages">
|
||||||
<item>en-US</item>
|
<item>en-US</item>
|
||||||
<item>ru-RU</item>
|
<item>ru-RU</item>
|
||||||
|
|
|
@ -121,9 +121,7 @@
|
||||||
<string name="new_group_name">Enter new group name</string>
|
<string name="new_group_name">Enter new group name</string>
|
||||||
<string name="kick">Kick</string>
|
<string name="kick">Kick</string>
|
||||||
<string name="transfer_ownership">Transfer ownership</string>
|
<string name="transfer_ownership">Transfer ownership</string>
|
||||||
<string name="transfer_ownership_confirmation">Are you sure you want to transfer ownership on current group to that
|
<string name="transfer_ownership_confirmation">Are you sure you want to transfer ownership on current group to that user?</string>
|
||||||
user?
|
|
||||||
</string>
|
|
||||||
<string name="loading_please_wait">Loading, please wait</string>
|
<string name="loading_please_wait">Loading, please wait</string>
|
||||||
<string name="loading">Loading</string>
|
<string name="loading">Loading</string>
|
||||||
<string-array name="languages">
|
<string-array name="languages">
|
||||||
|
|
Loading…
Reference in New Issue