Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added some features #357

Merged
merged 1 commit into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
Expand Down Expand Up @@ -61,6 +62,16 @@
</intent-filter>
</activity>

<provider
android:name="com.niyaj.poposroom.utils.MyFileProvider"
android:authorities="com.popos.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>

<!-- Trigger Google Play services to install the backported photo picker module. -->
<!--suppress AndroidDomInspection -->
<service
Expand Down
37 changes: 10 additions & 27 deletions app/src/main/java/com/niyaj/poposroom/ui/PoposApp.kt
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
package com.niyaj.poposroom.ui

import android.annotation.SuppressLint
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.WindowInsetsSides
import androidx.compose.foundation.layout.consumeWindowInsets
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.only
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.safeDrawing
import androidx.compose.foundation.layout.windowInsetsPadding
import androidx.compose.material3.Scaffold
import androidx.compose.material3.SnackbarDuration
import androidx.compose.material3.SnackbarHost
Expand Down Expand Up @@ -88,30 +81,20 @@ fun PoposApp(
}

Scaffold(
modifier = Modifier.semantics {
testTagsAsResourceId = true
},
modifier = Modifier
.semantics {
testTagsAsResourceId = true
}
.fillMaxSize(),
contentWindowInsets = WindowInsets(0, 0, 0, 0),
snackbarHost = { SnackbarHost(snackbarHostState) },
containerColor = Color.White,
contentColor = Color.Transparent
) { padding ->
Box(
modifier = Modifier
.fillMaxSize()
.padding(padding)
.consumeWindowInsets(padding)
.windowInsetsPadding(
WindowInsets.safeDrawing.only(
WindowInsetsSides.Horizontal,
),
)
) {
PoposNavHost(
appState = appState,
startRoute = RootNavGraph.startRoute,
)
}
) {
PoposNavHost(
appState = appState,
startRoute = RootNavGraph.startRoute,
)
}
}
}
Expand Down
11 changes: 11 additions & 0 deletions app/src/main/java/com/niyaj/poposroom/utils/MyFileProvider.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.niyaj.poposroom.utils;

import androidx.core.content.FileProvider;

import com.niyaj.poposroom.R;

public class MyFileProvider extends FileProvider {
public MyFileProvider() {
super(R.xml.file_paths);
}
}
6 changes: 6 additions & 0 deletions app/src/main/res/xml/file_paths.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<cache-path name="shared_images" path="images/"/>
</paths>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ object MarketListTestTags {
const val CREATE_NEW_ITEM = "Create New Item"
const val UPDATE_ITEM = "Update Item"

const val MARKET_LIST_SCREEN_TITLE = "Market Items"
const val MARKET_LIST_SCREEN_TITLE = "Market Lists"

const val ADD_EDIT_MARKET_LIST_BUTTON = "AddEdit Item"

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.niyaj.common.tags

object MeasureUnitTestTags {

const val UNIT_SCREEN_TITLE = "Measure Units"
const val UNIT_SEARCH_PLACEHOLDER = "Search for Items..."
const val UNIT_NOT_AVAILABLE = "Items Not Available"

const val ADD_EDIT_UNIT_BUTTON = "AddEdit Unit"

const val CREATE_NEW_UNIT = "Create New Unit"
const val UPDATE_UNIT = "Update Unit"

const val UNIT_NAME_FIELD = "Unit Name"
const val UNIT_NAME_ERROR_TAG = "Unit Name Error"

const val UNIT_VALUE_FIELD = "Value Increased By"
const val UNIT_VALUE_ERROR_TAG = "Unit Measure Value Error"

const val UNIT_NAME_EMPTY_ERROR = "Unit name must not be empty."
const val UNIT_NAME_DIGIT_ERROR = "Unit name must not contains any digit."
const val UNIT_NAME_LENGTH_ERROR = "Unit name must be at least 2 characters long."
const val UNIT_NAME_ALREADY_EXIST_ERROR = "Unit name already exists."

const val UNIT_VALUE_EMPTY_ERROR = "Unit measure value must not be empty."
const val UNIT_VALUE_INVALID = "Unit value is invalid."
const val UNIT_VALUE_LESS_THAN_FIVE_ERROR = "Unit value must greater than 0."

const val DELETE_ITEM_TITLE = "Delete Unit?"
const val DELETE_ITEM_MESSAGE = "Are you sure to delete these items?"

const val UNIT_LIST_ITEM_TAG = "Unit-"

const val UNIT_SETTINGS_TITLE = "Item Settings"

const val IMPORT_UNIT_TITLE = "Import Item"
const val IMPORT_UNIT_BTN_TEXT = "Import Item"
const val IMPORT_UNIT_OPN_FILE = "Open File"
const val IMPORT_UNIT_NOTE_TEXT = "Make sure to open measure-units.json file."

const val EXPORT_UNIT_TITLE = "Export Item"
const val EXPORT_UNIT_BTN_TEXT = "Export Item"
const val EXPORT_UNIT_BTN = "Export Item"

const val EXPORT_UNIT_FILE_NAME = "measure-units"

}
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ object Constants {
const val SELECTALL_ICON = "SelectAllIcon"
const val PASSWORD_HIDDEN_ICON = "Password Hidden"
const val PASSWORD_SHOWN_ICON = "Password Shown"

}


Expand Down
45 changes: 34 additions & 11 deletions core/common/src/main/java/com/niyaj/common/utils/Extensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,9 @@ val getEndDateLong: Long = endTime().timeInMillis
val Date.toTimeSpan
get() = DateUtils.getRelativeTimeSpanString(this.time).toString()

val Long.toTimeSpan
get() = DateUtils.getRelativeTimeSpanString(this).toString()

fun createDottedString(name: String, limit: Int): String {
if (name.length > limit) {
var wordLength = 0
Expand Down Expand Up @@ -651,14 +654,34 @@ val String.isToday: Boolean

// Create a list of all measure units.
val measureUnitLists = listOf(
"kg", "gm", "li", "ml", "unit", "bottle", "packet",
"tsp", "tbsp", "cup", "pint", "quart", "gallon",
"ounce", "pound", "yard", "foot", "inch", "mile",
"kilometer", "meter", "centimeter", "millimeter",
"acre", "hectare", "square meter", "square foot", "square inch",
"cubic meter", "cubic foot", "cubic inch",
"fluid ounce", "fluid dram", "minim", "drop",
"grain", "scruple", "ounce troy", "pound troy", "carat",
"milligram", "micrograms", "nano gram", "pictogram",
"femto-gram", "atto-gram", "zepto gram", "yocto-gram"
)
"kg", "gm", "li", "bottle", "packet",
"tsp", "tbsp", "cup", "pcs"
)


fun List<Int>.toListString(): String {
val sb = StringBuilder()
for (item in this) {
sb.append(item).append(",")
}
return sb.toString()
}

fun String.toListString(): MutableList<Int> {
if (this.isEmpty()) return mutableListOf()

val items = this.trimEnd().split(",")

return items.map { it.trim() } // Trim to remove leading/trailing whitespace
.filter { it.isNotEmpty() } // Filter out empty strings
.map { it.toInt() }.toMutableList()
}


fun Double.toSafeString(): String {
return when {
this == 0.0 -> "0"
this == this.toInt().toDouble() -> this.toInt().toString()
else -> this.toString()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class HomeRepositoryImpl(
selectedCartOrder: Int? = null,
products: List<Product>,
): List<ProductWithFlowQuantity> {
val data = products.map { product ->
return products.map { product ->
ProductWithFlowQuantity(
categoryId = product.categoryId,
productId = product.productId,
Expand All @@ -87,7 +87,5 @@ class HomeRepositoryImpl(
quantity = getQuantity(selectedCartOrder, product.productId).distinctUntilChanged()
)
}

return data
}
}
Loading