path
stringlengths 4
297
| contentHash
stringlengths 1
10
| content
stringlengths 0
13M
|
---|---|---|
MoviesBillboard/app/src/main/java/cnovaez/dev/moviesbillboard/domain/database/dao/GenresDao.kt | 99354448 | package cnovaez.dev.moviesbillboard.domain.database.dao
import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import cnovaez.dev.moviesbillboard.domain.database.entities.GenreEntity
/**
** Created by Carlos A. Novaez Guerrero on 15/12/2023 18:48
** [email protected]
**/
@Dao
interface GenresDao {
@Insert(onConflict = OnConflictStrategy.REPLACE)
suspend fun insertGenre(genre: GenreEntity)
@Query("SELECT * FROM genres WHERE key = :genreKey")
suspend fun getGenre(genreKey: String): GenreEntity
} |
MoviesBillboard/app/src/main/java/cnovaez/dev/moviesbillboard/domain/database/dao/DirectorsDao.kt | 752508164 | package cnovaez.dev.moviesbillboard.domain.database.dao
import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import cnovaez.dev.moviesbillboard.domain.database.entities.DirectorEntity
/**
** Created by Carlos A. Novaez Guerrero on 15/12/2023 18:49
** [email protected]
**/
@Dao
interface DirectorsDao {
@Insert(onConflict = OnConflictStrategy.REPLACE)
suspend fun insertDirector(director: DirectorEntity)
@Query("SELECT * FROM directors WHERE id = :directorId")
suspend fun getDirector(directorId: String): DirectorEntity
} |
MoviesBillboard/app/src/main/java/cnovaez/dev/moviesbillboard/domain/database/dao/StarsDao.kt | 2275567793 | package cnovaez.dev.moviesbillboard.domain.database.dao
import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import cnovaez.dev.moviesbillboard.domain.database.entities.StarEntity
/**
** Created by Carlos A. Novaez Guerrero on 15/12/2023 18:50
** [email protected]
**/
@Dao
interface StarsDao {
@Insert(onConflict = OnConflictStrategy.REPLACE)
suspend fun insertStar(star: StarEntity)
@Query("SELECT * FROM stars WHERE id = :starId")
suspend fun getStar(starId: String): StarEntity?
} |
MoviesBillboard/app/src/main/java/cnovaez/dev/moviesbillboard/domain/database/dao/MovieGenreCrossRefDao.kt | 3491751636 | package cnovaez.dev.moviesbillboard.domain.database.dao
import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import cnovaez.dev.moviesbillboard.domain.database.entities.GenreEntity
import cnovaez.dev.moviesbillboard.domain.database.entities.MovieGenreCrossRefEntity
/**
** Created by Carlos A. Novaez Guerrero on 15/12/2023 19:31
** [email protected]
**/
@Dao
interface MovieGenreCrossRefDao {
@Insert(onConflict = OnConflictStrategy.REPLACE)
suspend fun insert(movieGenreCrossRef: MovieGenreCrossRefEntity)
// @Query("SELECT * FROM movie_genres WHERE movieId = :movieId")
// suspend fun getGenresForMovie(movieId: String): List<GenreEntity>
} |
MoviesBillboard/app/src/main/java/cnovaez/dev/moviesbillboard/domain/database/dao/MoviesDao.kt | 106348576 | package cnovaez.dev.moviesbillboard.domain.database.dao
import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import androidx.room.Transaction
import cnovaez.dev.moviesbillboard.domain.database.entities.MovieEntity
import cnovaez.dev.moviesbillboard.domain.database.entities.MovieWithDetails
/**
** Created by Carlos A. Novaez Guerrero on 15/12/2023 18:47
** [email protected]
**/
@Dao
interface MoviesDao {
@Insert(onConflict = OnConflictStrategy.REPLACE)
suspend fun insertMovie(movie: MovieEntity)
@Transaction
@Query("SELECT * FROM movies WHERE id = :movieId")
suspend fun getMovie(movieId: String): MovieWithDetails
@Transaction
@Query("SELECT * FROM movies")
suspend fun getMovies(): List<MovieWithDetails>
@Transaction
@Query("SELECT * FROM movies where id = :movieId")
suspend fun getMovieById(movieId: String): MovieWithDetails?
@Transaction
@Query("SELECT * FROM movies where title LIKE '%' || :filter || '%' OR releaseState LIKE '%' || :filter || '%' OR imDbRating LIKE '%' || :filter || '%'")
suspend fun getMovieByFilter(filter: String): List<MovieWithDetails>
} |
MoviesBillboard/app/src/main/java/cnovaez/dev/moviesbillboard/domain/database/dao/MovieDirectorCrossRefDao.kt | 3627193538 | package cnovaez.dev.moviesbillboard.domain.database.dao
import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import cnovaez.dev.moviesbillboard.domain.database.entities.MovieDirectorCrossRefEntity
/**
** Created by Carlos A. Novaez Guerrero on 15/12/2023 19:34
** [email protected]
**/
@Dao
interface MovieDirectorCrossRefDao {
@Insert(onConflict = OnConflictStrategy.REPLACE)
suspend fun insert(movieDirectorCrossRef: MovieDirectorCrossRefEntity)
} |
MoviesBillboard/app/src/main/java/cnovaez/dev/moviesbillboard/domain/database/dao/MovieStarCrossRefDao.kt | 1332491894 | package cnovaez.dev.moviesbillboard.domain.database.dao
import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import cnovaez.dev.moviesbillboard.domain.database.entities.MovieStarCrossRefEntity
/**
** Created by Carlos A. Novaez Guerrero on 15/12/2023 19:33
** [email protected]
**/
@Dao
interface MovieStarCrossRefDao {
@Insert(onConflict = OnConflictStrategy.REPLACE)
suspend fun insert(movieStarCrossRef: MovieStarCrossRefEntity)
} |
MoviesBillboard/app/src/main/java/cnovaez/dev/moviesbillboard/domain/database/MoviesDatabase.kt | 1626629507 | package cnovaez.dev.moviesbillboard.domain.database
import androidx.room.Database
import androidx.room.RoomDatabase
import cnovaez.dev.moviesbillboard.domain.database.dao.DirectorsDao
import cnovaez.dev.moviesbillboard.domain.database.dao.GenresDao
import cnovaez.dev.moviesbillboard.domain.database.dao.MovieDirectorCrossRefDao
import cnovaez.dev.moviesbillboard.domain.database.dao.MovieGenreCrossRefDao
import cnovaez.dev.moviesbillboard.domain.database.dao.MovieStarCrossRefDao
import cnovaez.dev.moviesbillboard.domain.database.dao.MoviesDao
import cnovaez.dev.moviesbillboard.domain.database.dao.StarsDao
import cnovaez.dev.moviesbillboard.domain.database.entities.DirectorEntity
import cnovaez.dev.moviesbillboard.domain.database.entities.GenreEntity
import cnovaez.dev.moviesbillboard.domain.database.entities.MovieDirectorCrossRefEntity
import cnovaez.dev.moviesbillboard.domain.database.entities.MovieEntity
import cnovaez.dev.moviesbillboard.domain.database.entities.MovieGenreCrossRefEntity
import cnovaez.dev.moviesbillboard.domain.database.entities.MovieStarCrossRefEntity
import cnovaez.dev.moviesbillboard.domain.database.entities.StarEntity
/**
** Created by Carlos A. Novaez Guerrero on 15/12/2023 18:08
** [email protected]
**/
@Database(
entities = [MovieEntity::class, GenreEntity::class, DirectorEntity::class, StarEntity::class, MovieGenreCrossRefEntity::class, MovieDirectorCrossRefEntity::class, MovieStarCrossRefEntity::class],
version = 1,
exportSchema = false
)
abstract class MoviesDatabase : RoomDatabase() {
abstract fun movieDao(): MoviesDao
abstract fun genreDao(): GenresDao
abstract fun directorDao(): DirectorsDao
abstract fun starDao(): StarsDao
abstract fun movieGenreCrossRefDao(): MovieGenreCrossRefDao
abstract fun movieDirectorCrossRefDao(): MovieDirectorCrossRefDao
abstract fun movieStarCrossRefDao(): MovieStarCrossRefDao
} |
MoviesBillboard/app/src/main/java/cnovaez/dev/moviesbillboard/domain/database/entities/MovieDirectorCrossRefEntity.kt | 810366765 | package cnovaez.dev.moviesbillboard.domain.database.entities
import androidx.room.Entity
import androidx.room.ForeignKey
/**
** Created by Carlos A. Novaez Guerrero on 15/12/2023 18:44
** [email protected]
**/
@Entity(
tableName = "movie_directors",
primaryKeys = ["movieId", "directorId"],
foreignKeys = [
ForeignKey(
entity = MovieEntity::class,
parentColumns = ["id"],
childColumns = ["movieId"],
onDelete = ForeignKey.CASCADE
),
ForeignKey(
entity = DirectorEntity::class,
parentColumns = ["id"],
childColumns = ["directorId"],
onDelete = ForeignKey.CASCADE
)
]
)
data class MovieDirectorCrossRefEntity(
val movieId: String,
val directorId: String
)
|
MoviesBillboard/app/src/main/java/cnovaez/dev/moviesbillboard/domain/database/entities/StarEntity.kt | 2791178113 | package cnovaez.dev.moviesbillboard.domain.database.entities
import androidx.room.Entity
import androidx.room.PrimaryKey
/**
** Created by Carlos A. Novaez Guerrero on 15/12/2023 18:41
** [email protected]
**/
@Entity(tableName = "stars")
data class StarEntity(
@PrimaryKey
val id: String,
val name: String
) |
MoviesBillboard/app/src/main/java/cnovaez/dev/moviesbillboard/domain/database/entities/MovieWithDetails.kt | 47659034 | package cnovaez.dev.moviesbillboard.domain.database.entities
import androidx.room.Embedded
import androidx.room.Junction
import androidx.room.Relation
/**
** Created by Carlos A. Novaez Guerrero on 15/12/2023 19:24
** [email protected]
**/
data class MovieWithDetails(
@Embedded val movie: MovieEntity,
@Relation(
parentColumn = "id",
entityColumn = "key",
associateBy = Junction(MovieGenreCrossRefEntity::class, parentColumn = "movieId", entityColumn = "genreKey")
)
val genres: List<GenreEntity>,
@Relation(
parentColumn = "id",
entityColumn = "id",
associateBy = Junction(MovieDirectorCrossRefEntity::class, parentColumn = "movieId", entityColumn = "directorId")
)
val directors: List<DirectorEntity>,
@Relation(
parentColumn = "id",
entityColumn = "id",
associateBy = Junction(MovieStarCrossRefEntity::class, parentColumn = "movieId", entityColumn = "starId")
)
val stars: List<StarEntity>
)
|
MoviesBillboard/app/src/main/java/cnovaez/dev/moviesbillboard/domain/database/entities/MovieGenreCrossRefEntity.kt | 3833039478 | package cnovaez.dev.moviesbillboard.domain.database.entities
import androidx.room.Entity
import androidx.room.ForeignKey
/**
** Created by Carlos A. Novaez Guerrero on 15/12/2023 18:42
** [email protected]
**/
@Entity(
tableName = "movie_genres",
primaryKeys = ["movieId", "genreKey"],
foreignKeys = [
ForeignKey(
entity = MovieEntity::class,
parentColumns = ["id"],
childColumns = ["movieId"],
onDelete = ForeignKey.CASCADE
),
ForeignKey(
entity = GenreEntity::class,
parentColumns = ["key"],
childColumns = ["genreKey"],
onDelete = ForeignKey.CASCADE
)
]
)
data class MovieGenreCrossRefEntity(
val movieId: String,
val genreKey: String
)
|
MoviesBillboard/app/src/main/java/cnovaez/dev/moviesbillboard/domain/database/entities/MovieEntity.kt | 3310555856 | package cnovaez.dev.moviesbillboard.domain.database.entities
import androidx.room.Entity
import androidx.room.PrimaryKey
/**
** Created by Carlos A. Novaez Guerrero on 15/12/2023 18:37
** [email protected]
**/
@Entity(tableName = "movies", primaryKeys = ["id"])
data class MovieEntity(
val id: String,
val title: String,
val fullTitle: String,
val year: String,
val releaseState: String,
val image: String,
val runtimeMins: String,
val runtimeStr: String,
val plot: String,
val contentRating: String,
val imDbRating: String,
val imDbRatingCount: String,
val metacriticRating: String,
) |
MoviesBillboard/app/src/main/java/cnovaez/dev/moviesbillboard/domain/database/entities/MovieStarCrossRefEntity.kt | 3726010658 | package cnovaez.dev.moviesbillboard.domain.database.entities
import androidx.room.Entity
import androidx.room.ForeignKey
/**
** Created by Carlos A. Novaez Guerrero on 15/12/2023 18:45
** [email protected]
**/
@Entity(
tableName = "movie_stars",
primaryKeys = ["movieId", "starId"],
foreignKeys = [
ForeignKey(
entity = MovieEntity::class,
parentColumns = ["id"],
childColumns = ["movieId"],
onDelete = ForeignKey.CASCADE
),
ForeignKey(
entity = StarEntity::class,
parentColumns = ["id"],
childColumns = ["starId"],
onDelete = ForeignKey.CASCADE
)
]
)
data class MovieStarCrossRefEntity(
val movieId: String,
val starId: String
) |
MoviesBillboard/app/src/main/java/cnovaez/dev/moviesbillboard/domain/database/entities/GenreEntity.kt | 1218165266 | package cnovaez.dev.moviesbillboard.domain.database.entities
import androidx.room.Entity
/**
** Created by Carlos A. Novaez Guerrero on 15/12/2023 18:38
** [email protected]
**/
@Entity(tableName = "genres", primaryKeys = ["key"])
data class GenreEntity(
val key: String,
val value: String
) |
MoviesBillboard/app/src/main/java/cnovaez/dev/moviesbillboard/domain/database/entities/DirectorEntity.kt | 3207573480 | package cnovaez.dev.moviesbillboard.domain.database.entities
import androidx.room.Entity
import androidx.room.PrimaryKey
/**
** Created by Carlos A. Novaez Guerrero on 15/12/2023 18:41
** [email protected]
**/
@Entity(tableName = "directors")
data class DirectorEntity(
@PrimaryKey
val id: String,
val name: String
) |
MoviesBillboard/app/src/main/java/cnovaez/dev/moviesbillboard/domain/network_response/MoviesResponse.kt | 2641235202 | package cnovaez.dev.moviesbillboard.domain.network_response
import cnovaez.dev.moviesbillboard.domain.models.Movie
/**
** Created by Carlos A. Novaez Guerrero on 15/12/2023 19:08
** [email protected]
**/
data class MoviesResponse(
val items: List<Movie>,
var errorMessage: String
)
|
MoviesBillboard/app/src/main/java/cnovaez/dev/moviesbillboard/domain/models/Movie.kt | 1869258056 | package cnovaez.dev.moviesbillboard.domain.models
import cnovaez.dev.moviesbillboard.domain.database.entities.MovieEntity
import cnovaez.dev.moviesbillboard.domain.database.entities.MovieWithDetails
/**
** Created by Carlos A. Novaez Guerrero on 15/12/2023 18:37
** [email protected]
**/
data class Movie(
val id: String,
val title: String,
val fullTitle: String,
val year: String,
val releaseState: String,
val image: String,
val runtimeMins: String,
val runtimeStr: String,
val plot: String,
val contentRating: String,
val imDbRating: String,
val imDbRatingCount: String,
val metacriticRating: String,
val genres: String,
val genreList: List<Genre>,
val directors: String,
val directorList: List<GenericIdName>,
val stars: String,
val starList: List<GenericIdName>
) {
fun toEntity() = MovieEntity(
id,
title,
fullTitle,
year,
releaseState,
image,
runtimeMins,
runtimeStr,
plot,
contentRating,
imDbRating,
imDbRatingCount,
metacriticRating,
)
fun toMovieWithDetails() = MovieWithDetails(
MovieEntity(
id,
title,
fullTitle,
year,
releaseState,
image,
runtimeMins,
runtimeStr,
plot,
contentRating,
imDbRating,
imDbRatingCount,
metacriticRating,
),
genreList.map { it.toEntity() },
directorList.map { it.toDirectorEntity() },
starList.map { it.toStarEntity() }
)
} |
MoviesBillboard/app/src/main/java/cnovaez/dev/moviesbillboard/domain/models/Genre.kt | 1627773860 | package cnovaez.dev.moviesbillboard.domain.models
import androidx.room.Entity
import androidx.room.PrimaryKey
import cnovaez.dev.moviesbillboard.domain.database.entities.GenreEntity
/**
** Created by Carlos A. Novaez Guerrero on 15/12/2023 18:38
** [email protected]
**/
data class Genre(
val key: String,
val value: String
) {
fun toEntity() = GenreEntity(key, value)
} |
MoviesBillboard/app/src/main/java/cnovaez/dev/moviesbillboard/domain/models/GenericIdName.kt | 1824844576 | package cnovaez.dev.moviesbillboard.domain.models
import cnovaez.dev.moviesbillboard.domain.database.entities.DirectorEntity
import cnovaez.dev.moviesbillboard.domain.database.entities.StarEntity
/**
** Created by Carlos A. Novaez Guerrero on 15/12/2023 18:41
** [email protected]
**/
data class GenericIdName(
val id: String,
val name: String
) {
fun toStarEntity() = StarEntity(id, name)
fun toDirectorEntity() = DirectorEntity( id, name)
} |
MoviesBillboard/app/src/main/java/cnovaez/dev/moviesbillboard/domain/models/MovieDataResponse.kt | 2321522453 | package cnovaez.dev.moviesbillboard.domain.models
import cnovaez.dev.moviesbillboard.domain.database.entities.MovieWithDetails
/**
** Created by Carlos A. Novaez Guerrero on 17/12/2023 16:43
** [email protected]
**/
data class MovieDataResponse (
val movies: List<MovieWithDetails>,
var errorMessage: String = ""
) |
MoviesBillboard/app/src/main/java/cnovaez/dev/moviesbillboard/domain/models/Routes.kt | 2168495129 | package cnovaez.dev.moviesbillboard.domain.models
/**
** Created by Carlos A. Novaez Guerrero on 17/12/2023 19:22
** [email protected]
**/
sealed class Routes(val route: String) {
object MoviesList : Routes("movie_list")
object MovieFullDetails : Routes("movie_full_details/{movieId}") {
fun createRoute(movieId: String) = "movie_full_details/$movieId"
}
} |
MoreEndpoints/src/main/kotlin/rocks/rdil/moreendpoints/nest/NestFrameworkHandler.kt | 3319875775 | package rocks.rdil.moreendpoints.nest
import com.intellij.lang.ASTNode
import com.intellij.lang.javascript.JSElementTypes
import com.intellij.lang.javascript.JSTokenTypes
import com.intellij.lang.javascript.index.FrameworkIndexingHandler
import com.intellij.lang.javascript.psi.JSLiteralExpression
import com.intellij.lang.javascript.psi.impl.JSReferenceExpressionImpl
import com.intellij.psi.PsiElement
class NestFrameworkHandler : FrameworkIndexingHandler() {
override fun shouldCreateStubForLiteral(node: ASTNode): Boolean {
return this.hasSignificantValue(node)
}
override fun hasSignificantValue(expression: JSLiteralExpression): Boolean {
val decorator = expression.node?.treeParent?.treeParent?.treeParent ?: return false
return this.hasSignificantValue(decorator)
}
// this function will capture routes like @Get("id")
private fun hasSignificantValue(maybeDecorator: ASTNode?): Boolean {
if (maybeDecorator == null) {
return false
}
if (maybeDecorator.firstChildNode?.elementType != JSTokenTypes.AT || maybeDecorator.elementType !== JSElementTypes.ES6_DECORATOR) {
return false
}
val qualifierElement = JSReferenceExpressionImpl.getQualifierNode(maybeDecorator) ?: return false
val refText = qualifierElement.firstChildNode?.text
return NestModel.VERBS.contains(refText)
}
override fun getMarkers(elementToIndex: PsiElement): MutableList<String> {
val significant = this.hasSignificantValue(elementToIndex.node)
return if (significant) {
mutableListOf(KEY)
} else mutableListOf()
}
companion object {
const val KEY: String = "NestJS"
}
}
|
MoreEndpoints/src/main/kotlin/rocks/rdil/moreendpoints/nest/NestUrlResolverFactory.kt | 388579458 | package rocks.rdil.moreendpoints.nest
import com.intellij.microservices.url.*
import com.intellij.openapi.project.Project
class NestUrlResolverFactory : UrlResolverFactory {
override fun forProject(project: Project): UrlResolver? {
if (!NestModel.hasNestJs(project)) {
return null
}
return NestUrlResolver(project)
}
internal class NestUrlResolver(private val project: Project) : HttpUrlResolver() {
override fun getVariants(): Iterable<UrlTargetInfo> {
val endpoints = NestModel.getEndpoints(this.project)
return endpoints.mapNotNull {
this.toUrlTargetInfo(it)
}
}
private fun toUrlTargetInfo(it: NestMapping): NestUrlTargetInfo? {
val element = it.pointer.element
return if (element !== null) {
NestUrlTargetInfo(
this.supportedSchemes,
this.getAuthorityHints(null),
UrlPath.fromExactString(it.path),
setOf(it.method),
element
)
} else null
}
override fun resolve(request: UrlResolveRequest): Iterable<UrlTargetInfo> = emptyList()
}
}
|
MoreEndpoints/src/main/kotlin/rocks/rdil/moreendpoints/nest/NestModel.kt | 224170763 | package rocks.rdil.moreendpoints.nest
import com.intellij.javascript.nodejs.PackageJsonData
import com.intellij.javascript.nodejs.packageJson.PackageJsonFileManager
import com.intellij.lang.javascript.*
import com.intellij.lang.javascript.psi.JSLiteralExpression
import com.intellij.lang.javascript.psi.ecma6.TypeScriptClass
import com.intellij.lang.javascript.psi.ecma6.impl.TypeScriptFunctionImpl
import com.intellij.lang.javascript.psi.impl.JSReferenceExpressionImpl
import com.intellij.lang.javascript.psi.stubs.JSFrameworkMarkersIndex.Companion.getElements
import com.intellij.lang.typescript.psi.impl.ES6DecoratorImpl
import com.intellij.openapi.diagnostic.Logger
import com.intellij.openapi.fileTypes.FileType
import com.intellij.openapi.project.DumbService.Companion.isDumb
import com.intellij.openapi.project.Project
import com.intellij.psi.PsiFile
import com.intellij.psi.PsiManager
import com.intellij.psi.SmartPointerManager
import com.intellij.psi.search.GlobalSearchScope
import com.intellij.psi.util.CachedValueProvider
import com.intellij.psi.util.CachedValuesManager
import com.intellij.psi.util.PsiTreeUtil
import java.lang.IllegalStateException
import java.util.*
private fun removeStringWrapping(text: String): String {
return text
.removeSurrounding("'")
.removeSurrounding("\"")
.removeSurrounding("`")
}
internal object NestModel {
@JvmStatic
var VERBS = arrayOf("All", "Get", "Post", "Put", "Delete", "Patch", "Options", "Head")
@JvmStatic
val LOGGER = Logger.getInstance(NestModel::class.java)
fun getEndpointGroups(project: Project, scope: GlobalSearchScope): Collection<PsiFile> {
if (!hasNestJs(project)) {
return Collections.emptyList()
}
val destination = ArrayList<PsiFile>()
getEndpointsCached(project).forEach { endpoint ->
var containingFile = endpoint.pointer.containingFile
containingFile = if (containingFile?.let { scope.contains(it.virtualFile) } == true) {
containingFile
} else null
if (containingFile != null) {
destination.add(containingFile)
}
}
return destination.distinct()
}
fun hasNestJs(project: Project): Boolean {
val packageJsons = PackageJsonFileManager.getInstance(project).validPackageJsonFiles
if (packageJsons.isEmpty()) {
return false
}
for (packageJson in packageJsons) {
val packageJsonData = PackageJsonData.getOrCreate(packageJson)
val dependencies = arrayOf("@nestjs/core")
if (packageJsonData.containsOneOfDependencyOfAnyType(*dependencies)) {
return true
}
}
return false
}
/*
TS:
@Post()
test() {}
PSI structure (with depths):
// TypeScriptFunction:test FUNCTION 1
// JSAttributeList DECORATORS 2
// ES6Decorator DECORATOR 3
// PsiElement(JS:AT) @ 4
// JSCallExpression 4
// JSReferenceExpression Post 5
// PsiElement(JS:IDENTIFIER) Post 6
// JSArgumentList () 5
// PsiElement(JS:LPAR) ( 7
// PsiElement(JS:RPAR) ) 7
*/
private fun tryCreateMappingFor(expr: ES6DecoratorImpl): NestMapping? {
val qualifierElement = JSReferenceExpressionImpl.getQualifierNode(expr.node)
val verbText = qualifierElement?.firstChildNode?.text ?: return null
val callExpr = expr.node.findChildByType(JSElementTypes.CALL_EXPRESSION)
val params = callExpr?.findChildByType(JSElementTypes.ARGUMENT_LIST)
var pathName: String? = null
var pathPsi: JSLiteralExpression? = null
params?.findChildByType(JSElementTypes.LITERAL_EXPRESSION)?.let {
pathName = removeStringWrapping(it.text)
try {
pathPsi = it.psi as JSLiteralExpression?
} catch (e: Exception) {
// oh no! anyway
}
}
// fall back to the method name if the path is not specified
pathName = pathName ?: PsiTreeUtil.getParentOfType(expr, TypeScriptFunctionImpl::class.java)?.name
if (pathName == null) {
throw IllegalStateException("Path name is null - this should not happen")
}
// get containing controller
var controller: NestController? = null
val parent = PsiTreeUtil.getParentOfType(expr, TypeScriptClass::class.java)
if (parent !== null) {
val parentAttributes = parent.attributeList
val controllerAnnotation = parentAttributes?.decorators?.find {
it.decoratorName == "Controller"
}
val string = PsiTreeUtil.findChildOfType(controllerAnnotation, JSLiteralExpression::class.java)
string?.text?.let {
controller = NestController(removeStringWrapping(it), null)
}
}
return NestMapping(
SmartPointerManager.createPointer(expr),
if (pathPsi !== null) SmartPointerManager.createPointer(pathPsi!!) else null,
controller,
verbText,
pathName!!
)
}
private fun getJsSearchScope(project: Project): GlobalSearchScope {
val types = arrayOf<FileType>(JavaScriptFileType.INSTANCE, TypeScriptFileType.INSTANCE)
return GlobalSearchScope.getScopeRestrictedByFileTypes(GlobalSearchScope.allScope(project), *types)
}
private fun getLiterals(project: Project): Collection<ES6DecoratorImpl> {
return if (isDumb(project)) {
emptySet()
} else {
getElements(NestFrameworkHandler.KEY, ES6DecoratorImpl::class.java, project, getJsSearchScope(project))
}
}
private fun getMappings(project: Project): Collection<NestMapping> {
val destination = ArrayList<NestMapping>()
val literals = getLiterals(project)
literals.forEach {
val mapping = tryCreateMappingFor(it)
if (mapping != null) {
destination.add(mapping)
} else {
LOGGER.warn("Failed to create mapping for $it")
}
}
return destination
}
fun getEndpoints(project: Project, file: PsiFile): Collection<NestMapping> {
val forProject = getEndpointsCached(project)
return forProject.filter { it.pointer.containingFile == file }
}
fun getEndpoints(project: Project): Collection<NestMapping> {
return getEndpointsCached(project)
}
private fun getEndpointsCached(project: Project): Collection<NestMapping> {
return CachedValuesManager.getManager(project).getCachedValue(project) {
CachedValueProvider.Result.create(
getMappings(project),
PsiManager.getInstance(project).modificationTracker.forLanguage(JavascriptLanguage.INSTANCE)
)
}
}
}
|
MoreEndpoints/src/main/kotlin/rocks/rdil/moreendpoints/nest/NestEndpointsProvider.kt | 2491309082 | package rocks.rdil.moreendpoints.nest
import com.intellij.lang.javascript.JavascriptLanguage
import com.intellij.microservices.endpoints.*
import com.intellij.microservices.endpoints.presentation.HttpMethodPresentation
import com.intellij.microservices.url.UrlPath
import com.intellij.microservices.url.UrlTargetInfo
import com.intellij.navigation.ItemPresentation
import com.intellij.openapi.project.Project
import com.intellij.openapi.util.ModificationTracker
import com.intellij.psi.PsiFile
import com.intellij.psi.PsiManager
import icons.JavaScriptLanguageIcons.Nodejs
import com.intellij.microservices.url.Authority
class NestEndpointsProvider : EndpointsUrlTargetProvider<PsiFile, NestMapping> {
override val endpointType: EndpointType = HTTP_SERVER_TYPE
override val presentation: FrameworkPresentation = FrameworkPresentation("NestJS", "NestJS", Nodejs.Nodejs)
override fun getEndpointGroups(project: Project, filter: EndpointsFilter): Iterable<PsiFile> {
if (!NestModel.hasNestJs(project)) {
return emptyList()
}
if (filter !is SearchScopeEndpointsFilter) {
return emptyList()
}
return NestModel.getEndpointGroups(project, filter.transitiveSearchScope)
}
override fun getModificationTracker(project: Project): ModificationTracker {
return PsiManager.getInstance(project).modificationTracker.forLanguage(JavascriptLanguage.INSTANCE)
}
override fun getStatus(project: Project): EndpointsProvider.Status {
return when {
!NestModel.hasNestJs(project) -> EndpointsProvider.Status.UNAVAILABLE
else -> EndpointsProvider.Status.HAS_ENDPOINTS
}
}
override fun getUrlTargetInfo(group: PsiFile, endpoint: NestMapping): Iterable<UrlTargetInfo> {
return listOf(
NestUrlTargetInfo(
// TODO: nest supports others!
listOf("http", "https"),
listOf(Authority.Placeholder()),
UrlPath.fromExactString(endpoint.getFullPath()),
setOf(endpoint.method),
endpoint.pathPointer?.element ?: endpoint.pointer.element!!
)
)
}
override fun isValidEndpoint(group: PsiFile, endpoint: NestMapping): Boolean {
return endpoint.pointer.element?.isValid ?: false
}
override fun getEndpoints(group: PsiFile): Iterable<NestMapping> {
return NestModel.getEndpoints(group.project, group)
}
override fun getEndpointPresentation(group: PsiFile, endpoint: NestMapping): ItemPresentation {
return HttpMethodPresentation(endpoint.getFullPath(), listOf(endpoint.method), endpoint.source, Nodejs.Nodejs, null)
}
}
|
MoreEndpoints/src/main/kotlin/rocks/rdil/moreendpoints/nest/NestController.kt | 3665025628 | package rocks.rdil.moreendpoints.nest
fun ensureLeadAndTrailingSlash(route: String): String {
return if (route.startsWith("/")) {
if (route.endsWith("/")) {
route
} else {
"$route/"
}
} else {
if (route.endsWith("/")) {
"/$route"
} else {
"/$route/"
}
}
}
data class NestController(val routeBase: String?, val parent: NestController?) {
fun getBaseUrl(): String {
return ensureLeadAndTrailingSlash(
if (routeBase != null) {
if (parent != null) {
parent.getBaseUrl() + routeBase
} else {
routeBase
}
} else {
parent?.getBaseUrl() ?: "/"
}
)
}
}
|
MoreEndpoints/src/main/kotlin/rocks/rdil/moreendpoints/nest/NestUrlTargetInfo.kt | 2308937226 | package rocks.rdil.moreendpoints.nest
import com.intellij.microservices.url.Authority
import com.intellij.microservices.url.UrlPath
import com.intellij.microservices.url.UrlTargetInfo
import com.intellij.psi.PsiElement
import icons.JavaScriptLanguageIcons.Nodejs
import javax.swing.Icon
class NestUrlTargetInfo(
override var schemes: List<String>,
override var authorities: List<Authority>,
override var path: UrlPath,
override var methods: Set<String>,
private var psiElement: PsiElement
) : UrlTargetInfo {
override var source: String
override val icon: Icon = Nodejs.Nodejs
init {
source = ""
val resolved = this.resolveToPsiElement()
val cf = resolved?.containingFile
if (cf != null) {
source = cf.name
}
}
override fun resolveToPsiElement(): PsiElement? {
return if (psiElement.isValid) this.psiElement else null
}
}
|
MoreEndpoints/src/main/kotlin/rocks/rdil/moreendpoints/nest/NestMapping.kt | 1028961233 | package rocks.rdil.moreendpoints.nest
import com.intellij.lang.javascript.psi.JSLiteralExpression
import com.intellij.lang.typescript.psi.impl.ES6DecoratorImpl
import com.intellij.psi.SmartPsiElementPointer
/**
* A mapping of a NestJS endpoint to its URL.
*
* @property pointer A pointer to the decorator that defines the endpoint.
* @property parent The parent mapping, if any.
* @property method The HTTP verb used by the endpoint.
* @property path The path of the endpoint.
*/
class NestMapping(
val pointer: SmartPsiElementPointer<ES6DecoratorImpl>,
val pathPointer: SmartPsiElementPointer<JSLiteralExpression>?,
private val parent: NestController?,
val method: String,
val path: String
) {
/**
* The name of the source file of the endpoint.
*/
val source: String
override fun toString(): String {
return "NestMapping(pointer=${pointer}, parent=${parent}, method=${method}, path=${path}, source=${source})"
}
init {
val f = pointer.containingFile
this.source = f?.name ?: ""
}
fun getFullPath(): String {
val base = parent?.getBaseUrl() ?: "/"
return (base + path).replace("//", "/")
}
}
|
Idont/app/src/androidTest/java/com/example/idont/ExampleInstrumentedTest.kt | 3637137499 | package com.example.idont
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.Assert.*
/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("com.example.idont", appContext.packageName)
}
} |
Idont/app/src/test/java/com/example/idont/ExampleUnitTest.kt | 3717616088 | package com.example.idont
import org.junit.Test
import org.junit.Assert.*
/**
* Example local unit test, which will execute on the development machine (host).
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
class ExampleUnitTest {
@Test
fun addition_isCorrect() {
assertEquals(4, 2 + 2)
}
} |
Idont/app/src/main/java/com/example/idont/MainActivity.kt | 3716289860 | package com.example.idont
import android.graphics.drawable.BitmapDrawable
import android.graphics.drawable.GradientDrawable
import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.recyclerview.widget.LinearLayoutManager
import com.example.idont.User.User
import com.example.idont.adapter.UserAdapter
import com.example.idont.databinding.ActivityMainBinding
import com.google.firebase.auth.FirebaseAuth
import com.google.firebase.auth.ktx.auth
import com.google.firebase.database.DataSnapshot
import com.google.firebase.database.DatabaseError
import com.google.firebase.database.DatabaseReference
import com.google.firebase.database.ValueEventListener
import com.google.firebase.database.getValue
import com.google.firebase.database.ktx.database
import com.google.firebase.ktx.Firebase
import com.squareup.picasso.Picasso
class MainActivity : AppCompatActivity() {
lateinit var binding: ActivityMainBinding
lateinit var auth: FirebaseAuth
lateinit var adapter: UserAdapter
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)
auth = Firebase.auth
setUpActionBar()
val database = Firebase.database
val myRef = database.getReference("message")
binding.bSend.setOnClickListener {
myRef.child(myRef.push().key?:"error").setValue(User(auth.currentUser?.displayName,binding.editSend.text.toString()))
}
onChangeListener(myRef)
initRcView()
}
private fun initRcView() = with(binding){
adapter = UserAdapter()
rcView.layoutManager=LinearLayoutManager(this@MainActivity)
rcView.adapter=adapter
}
private fun onChangeListener(dRef: DatabaseReference) {
dRef.addValueEventListener(object : ValueEventListener {
override fun onDataChange(snapshot: DataSnapshot) {
val list = ArrayList<User>()
for(s in snapshot.children){
val user = s.getValue(User::class.java)
if(user !=null )list.add(user)
}
adapter.submitList(list)
}
override fun onCancelled(error: DatabaseError) {
}
})
}
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
menuInflater.inflate(R.menu.main_menu, menu)
return super.onCreateOptionsMenu(menu)
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
if (item.itemId == R.id.singOut) {
auth.signOut()
finish()
}
return super.onOptionsItemSelected(item)
}
private fun setUpActionBar() {
val ab = supportActionBar
Thread {
val bMap = Picasso.get().load(auth.currentUser?.photoUrl).get()
val dIcon = BitmapDrawable(resources, bMap)
runOnUiThread {
ab?.setDisplayHomeAsUpEnabled(true)
ab?.setHomeAsUpIndicator(dIcon)
ab?.title = auth.currentUser?.displayName
}
}.start()
}
} |
Idont/app/src/main/java/com/example/idont/SingInAct.kt | 2693736459 | package com.example.idont
import android.content.Intent
import android.os.Bundle
import android.util.Log
import androidx.activity.result.ActivityResultLauncher
import androidx.activity.result.contract.ActivityResultContracts
import androidx.appcompat.app.AppCompatActivity
import com.example.idont.databinding.ActivityMainBinding
import com.example.idont.databinding.ActivitySingInBinding
import com.google.android.gms.auth.api.signin.GoogleSignIn
import com.google.android.gms.auth.api.signin.GoogleSignInClient
import com.google.android.gms.auth.api.signin.GoogleSignInOptions
import com.google.android.gms.common.api.ApiException
import com.google.firebase.auth.FirebaseAuth
import com.google.firebase.auth.GoogleAuthProvider
import com.google.firebase.auth.ktx.auth
import com.google.firebase.ktx.Firebase
class SingInAct : AppCompatActivity() {
lateinit var launcher: ActivityResultLauncher<Intent>
lateinit var auth:FirebaseAuth
lateinit var binding: ActivitySingInBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivitySingInBinding.inflate(layoutInflater)
setContentView(binding.root)
auth = Firebase.auth
launcher = registerForActivityResult(ActivityResultContracts.StartActivityForResult()){
val task = GoogleSignIn.getSignedInAccountFromIntent(it.data)
try {
val account = task.getResult(ApiException::class.java)
if(account!=null){
firabaseAuthWithGoogle(account.idToken!!)
}
}catch (e: ApiException){
Log.d("My log", "api exception")
}
}
binding.bSingIn.setOnClickListener {
signInWithGoogle()
}
checkAuth()
}
private fun getClient(): GoogleSignInClient{
val gso = GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestIdToken(getString(R.string.default_web_client_id))
.requestEmail()
.build()
return GoogleSignIn.getClient(this, gso)
}
private fun signInWithGoogle(){
val singInClient = getClient()
launcher.launch(singInClient.signInIntent)
}
private fun firabaseAuthWithGoogle(idToken: String){
val credencial =GoogleAuthProvider.getCredential(idToken, null)
auth.signInWithCredential(credencial).addOnCompleteListener {
if(it.isSuccessful){
Log.d("My log ", "Google sign IN ")
checkAuth()
}else {
Log.d("My log", "Error")
}
}
}
private fun checkAuth(){
if(auth.currentUser != null){
val i = Intent(this, MainActivity::class.java)
startActivity(i);
}
}
} |
Idont/app/src/main/java/com/example/idont/User/User.kt | 3467433111 | package com.example.idont.User
data class User(
val name: String? = null,
val message: String? = null
)
|
Idont/app/src/main/java/com/example/idont/adapter/UserAdapter.kt | 4248673786 | package com.example.idont.adapter
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView
import com.example.idont.User.User
import com.example.idont.databinding.UserListItemBinding
class UserAdapter : ListAdapter<User, UserAdapter.ItemHolder>(ItemComporator()){
class ItemHolder(private val binding: UserListItemBinding) : RecyclerView.ViewHolder(binding.root){
fun bind(user: User) = with(binding){
message.text = user.message
UserName.text = user.name
}
companion object{
fun create(parent: ViewGroup):ItemHolder{
return ItemHolder(UserListItemBinding
.inflate(LayoutInflater.from(parent.context), parent, false))
}
}
}
class ItemComporator: DiffUtil.ItemCallback<User>(){
override fun areItemsTheSame(oldItem: User, newItem: User): Boolean {
return oldItem == newItem
}
override fun areContentsTheSame(oldItem: User, newItem: User): Boolean {
return oldItem == newItem
}
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemHolder {
return ItemHolder.create(parent)
}
override fun onBindViewHolder(holder: ItemHolder, position: Int) {
holder.bind(getItem(position))
}
} |
ChatbotProject/app/src/main/java/template/ui/NavHost.kt | 4262550228 | /*
* MIT License
*
* Copyright (c) 2024 Hridoy Chandra Das
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package template.ui
import androidx.activity.compose.BackHandler
import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.runtime.Composable
import androidx.navigation.NavHostController
import androidx.navigation.compose.NavHost
import template.navigation.ScreenDestinations
import template.navigation.canGoBack
import template.navigation.navigateTo
import template.navigation.screen
import template.screens.HomeScreen
import template.screens.ViewScreen
@OptIn(ExperimentalAnimationApi::class)
@Composable
fun MainAnimationNavHost(
navController: NavHostController,
startDestination: String = ScreenDestinations.HomeScreen.route,
) {
NavHost(
navController = navController,
startDestination = startDestination,
) {
screen(ScreenDestinations.HomeScreen.route) {
HomeScreen(navController = navController)
}
screen(ScreenDestinations.ViewScreen.route) {
ViewScreen(
onBackPress = {
// navigateTo のためNavHostControllerを作成します。
navController.navigateTo(ScreenDestinations.HomeScreen.route)
},
)
}
}
// Back Handler
BackHandler {
if (navController.canGoBack) {
if (navController.currentBackStackEntry?.destination?.route != ScreenDestinations.HomeScreen.route) {
navController.popBackStack()
}
}
}
}
|
ChatbotProject/app/src/main/java/template/MainActivity.kt | 2291859955 | /*
* MIT License
*
* Copyright (c) 2024 Hridoy Chandra Das
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package template
import android.animation.ObjectAnimator
import android.os.Bundle
import android.view.View
import android.view.animation.OvershootInterpolator
import androidx.activity.ComponentActivity
import androidx.activity.SystemBarStyle
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.activity.viewModels
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.ui.graphics.toArgb
import androidx.core.animation.doOnEnd
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import androidx.core.view.WindowCompat
import androidx.navigation.compose.rememberNavController
import dagger.hilt.android.AndroidEntryPoint
import template.common.DURATION
import template.common.VALUES_X
import template.common.VALUES_Y
import template.common.utils.RootUtil
import template.theme.TemplateTheme
import template.theme.splashScreen.SplashViewModel
import template.ui.MainAnimationNavHost
import timber.log.Timber
@AndroidEntryPoint
class MainActivity : ComponentActivity() {
companion object {
private val Tag = MainActivity::class.java.simpleName
}
private val splashViewModel: SplashViewModel by viewModels()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
configureEdgeToEdgeWindow()
// Check Rooted Device
if (RootUtil.isDeviceRooted()) {
Timber.tag(Tag).e("onCreate - Rooted device.")
finish()
return
}
Timber.tag(Tag).d("onCreate")
installSplashScreen().apply {
setKeepOnScreenCondition {
!splashViewModel.isLoading.value
}
setOnExitAnimationListener { screen ->
val zoomX = ObjectAnimator.ofFloat(
screen.iconView,
View.SCALE_X,
VALUES_X,
VALUES_Y,
)
zoomX.interpolator = OvershootInterpolator()
zoomX.duration = DURATION
zoomX.doOnEnd { screen.remove() }
val zoomY = ObjectAnimator.ofFloat(
screen.iconView,
View.SCALE_Y,
VALUES_X,
VALUES_Y,
)
zoomY.interpolator = OvershootInterpolator()
zoomY.duration = DURATION
zoomY.doOnEnd { screen.remove() }
zoomX.start()
zoomY.start()
}
}
// splashViewModel.checkStartScreen() { route -> }
enableEdgeToEdge()
setContent {
TemplateTheme {
ChangeSystemBarsTheme(!isSystemInDarkTheme())
Surface(
color = MaterialTheme.colorScheme.background,
) {
val navController = rememberNavController()
MainAnimationNavHost(navController)
}
}
}
}
/**
* Configures our [MainActivity] window so that it reaches edge to edge of the device, meaning
* content can be rendered underneath the status and navigation bars.
*
* This method works hand in hand with [ConfigureTransparentSystemBars], to make sure content
* behind these bars is visible.
*
* Keep in mind that if you need to make sure your content padding doesn't clash with the status bar text/icons,
* you can leverage modifiers like `windowInsetsPadding()` and `systemBarsPadding()`. For more information,
* read the Compose WindowInsets docs: https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/WindowInsets
*/
private fun configureEdgeToEdgeWindow() {
WindowCompat.setDecorFitsSystemWindows(window, false)
}
@Composable
private fun ChangeSystemBarsTheme(lightTheme: Boolean) {
val barColor = MaterialTheme.colorScheme.background.toArgb()
LaunchedEffect(lightTheme) {
if (lightTheme) {
enableEdgeToEdge(
statusBarStyle = SystemBarStyle.light(
barColor,
barColor,
),
navigationBarStyle = SystemBarStyle.light(
barColor,
barColor,
),
)
} else {
enableEdgeToEdge(
statusBarStyle = SystemBarStyle.dark(
barColor,
),
navigationBarStyle = SystemBarStyle.dark(
barColor,
),
)
}
}
}
}
@Composable
fun Greeting(name: String) {
Text(text = "Hello $name!")
}
|
ChatbotProject/app/src/main/java/template/screens/ViewScreen.kt | 1353271653 | /*
* MIT License
*
* Copyright (c) 2024 Hridoy Chandra Das
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package template.screens
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun ViewScreen(onBackPress: () -> Unit) {
Scaffold(
topBar = {
TopAppBar(
title = {
Text(
text = "Welcome",
modifier = Modifier,
color = MaterialTheme.colorScheme.onSurfaceVariant,
style = MaterialTheme.typography.titleSmall,
)
},
navigationIcon = {
IconButton(
onClick = {
onBackPress()
},
modifier = Modifier,
) {
Icon(Icons.AutoMirrored.Filled.ArrowBack, contentDescription = "Back")
}
},
)
},
content = {
Box(modifier = Modifier.padding(it)) {
Column(
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally,
modifier = Modifier
.fillMaxSize(),
) {
Text(
text = "Nice to meet you..!",
modifier = Modifier.padding(16.dp),
)
}
}
},
)
}
|
ChatbotProject/app/src/main/java/template/screens/HomeScreen.kt | 3473827853 | /*
* MIT License
*
* Copyright (c) 2024 Hridoy Chandra Das
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package template.screens
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material3.Button
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import androidx.navigation.NavController
import androidx.navigation.compose.rememberNavController
import template.common.components.TemplatePreview
import template.navigation.ScreenDestinations
@Composable
fun HomeScreen(navController: NavController) {
Box(modifier = Modifier.fillMaxSize()) {
Column(
modifier = Modifier.fillMaxSize(),
Arrangement.Center,
Alignment.CenterHorizontally,
) {
Text(
text = "Hello Developer!",
style = MaterialTheme.typography.bodyLarge,
modifier = Modifier.padding(bottom = 16.dp),
color = MaterialTheme.colorScheme.onSurfaceVariant,
)
Button(
modifier = Modifier
.size(120.dp, 40.dp),
onClick = {
navController.navigate(ScreenDestinations.ViewScreen.route) {
popUpTo(ScreenDestinations.HomeScreen.route) {
inclusive = false
}
}
},
) {
Text(
modifier = Modifier
.align(Alignment.CenterVertically)
.fillMaxSize().padding(0.dp),
text = "Lets Start!",
color = MaterialTheme.colorScheme.background,
)
}
}
}
}
@TemplatePreview
@Composable
fun HomeScreenPreview() {
HomeScreen(navController = rememberNavController())
}
|
ChatbotProject/app/src/main/java/template/BaseApp.kt | 2475578477 | /*
* MIT License
*
* Copyright (c) 2024 Hridoy Chandra Das
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package template
import android.app.Application
import dagger.hilt.android.HiltAndroidApp
@HiltAndroidApp
class BaseApp : Application()
|
ChatbotProject/navigation/src/androidTest/java/template/navigation/ExampleInstrumentedTest.kt | 1767100582 | /*
* MIT License
*
* Copyright (c) 2024 Hridoy Chandra Das
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package template.navigation
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import junit.framework.TestCase.assertEquals
import org.junit.Test
import org.junit.runner.RunWith
/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("template.navigation.test", appContext.packageName)
}
}
|
ChatbotProject/navigation/src/test/java/template/navigation/ExampleUnitTest.kt | 94408283 | /*
* MIT License
*
* Copyright (c) 2024 Hridoy Chandra Das
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package template.navigation
import junit.framework.TestCase.assertEquals
import org.junit.Test
/**
* Example local unit test, which will execute on the development machine (host).
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
class ExampleUnitTest {
@Test
fun addition_isCorrect() {
assertEquals(4, 2 + 2)
}
}
|
ChatbotProject/navigation/src/main/java/template/navigation/NavGraphBuilder.kt | 4278767517 | /*
* MIT License
*
* Copyright (c) 2024 Hridoy Chandra Das
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package template.navigation
import androidx.compose.animation.AnimatedVisibilityScope
import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.animation.core.FastOutSlowInEasing
import androidx.compose.animation.core.FiniteAnimationSpec
import androidx.compose.animation.core.tween
import androidx.compose.animation.slideInHorizontally
import androidx.compose.animation.slideOutHorizontally
import androidx.compose.runtime.Composable
import androidx.compose.ui.unit.IntOffset
import androidx.navigation.NamedNavArgument
import androidx.navigation.NavBackStackEntry
import androidx.navigation.NavGraphBuilder
import androidx.navigation.compose.composable
import template.common.DURATION_MILLIS
@ExperimentalAnimationApi
fun NavGraphBuilder.screen(
route: String,
arguments: List<NamedNavArgument> = listOf(),
content: @Composable AnimatedVisibilityScope.(NavBackStackEntry) -> Unit,
) {
val animSpec: FiniteAnimationSpec<IntOffset> = tween(DURATION_MILLIS, easing = FastOutSlowInEasing)
composable(
route,
arguments = arguments,
enterTransition = {
slideInHorizontally(
initialOffsetX = { screenWidth -> screenWidth },
animationSpec = animSpec,
)
},
popEnterTransition = {
slideInHorizontally(
initialOffsetX = { screenWidth -> -screenWidth },
animationSpec = animSpec,
)
},
exitTransition = {
slideOutHorizontally(
targetOffsetX = { screenWidth -> -screenWidth },
animationSpec = animSpec,
)
},
popExitTransition = {
slideOutHorizontally(
targetOffsetX = { screenWidth -> screenWidth },
animationSpec = animSpec,
)
},
content = content,
)
}
|
ChatbotProject/navigation/src/main/java/template/navigation/NavHostController.kt | 4095251056 | /*
* MIT License
*
* Copyright (c) 2024 Hridoy Chandra Das
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package template.navigation
import androidx.lifecycle.Lifecycle
import androidx.navigation.NavHostController
fun NavHostController.navigateTo(route: String) =
navigate(route) {
popUpTo(route)
launchSingleTop = true
}
// i want to back when
val NavHostController.canGoBack: Boolean
get() = this.currentBackStackEntry?.lifecycle?.currentState == Lifecycle.State.RESUMED
|
ChatbotProject/navigation/src/main/java/template/navigation/ScreenDestinations.kt | 1565820956 | /*
* MIT License
*
* Copyright (c) 2024 Hridoy Chandra Das
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package template.navigation
sealed class ScreenDestinations(val route: String) {
// Destinations
data object HomeScreen : ScreenDestinations("home_screen")
data object ViewScreen : ScreenDestinations("view_screen")
}
|
ChatbotProject/spotless/copyright.kt | 3142865241 | /*
* MIT License
*
* Copyright (c) $YEAR Hridoy Chandra Das
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
|
ChatbotProject/common/src/main/java/template/common/utils/Toast.kt | 574733622 | /*
* MIT License
*
* Copyright (c) 2024 Hridoy Chandra Das
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package template.common.utils
import android.content.Context
import android.os.Build
import android.widget.Toast
import androidx.annotation.StringRes
fun Context.toast(
message: String,
onToastDisplayChange: (Boolean) -> Unit,
) {
showToast(message, onToastDisplayChange)
}
fun Context.toast(
@StringRes message: Int,
onToastDisplayChange: (Boolean) -> Unit,
) {
showToast(getString(message), onToastDisplayChange)
}
private fun Context.showToast(
message: String,
onToastDisplayChange: (Boolean) -> Unit,
) {
Toast.makeText(this, message, Toast.LENGTH_SHORT).also {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
it.addCallback(object : Toast.Callback() {
override fun onToastHidden() {
super.onToastHidden()
onToastDisplayChange(false)
}
override fun onToastShown() {
super.onToastShown()
onToastDisplayChange(true)
}
})
}
}.show()
}
|
ChatbotProject/common/src/main/java/template/common/utils/RootUtil.kt | 1956882264 | /*
* MIT License
*
* Copyright (c) 2024 Hridoy Chandra Das
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package template.common.utils
import android.os.Build
import android.util.Log
import java.io.BufferedReader
import java.io.File
import java.io.InputStreamReader
/**
* ルート化されている兆候が見られるか確認するメソッドを提供する.
*/
@Suppress("UtilityClassWithPublicConstructor")
class RootUtil {
companion object {
private val Tag = RootUtil::class.java.simpleName
private const val PATH_TO_WHICH = "/system/xbin/which"
private const val CMD_SU = "su"
private val PATHS_SU = arrayOf(
"/system/app/Superuser.apk",
"/system/etc/init.d/99SuperSUDaemon",
"/dev/com.koushikdutta.superuser.daemon/",
"/system/xbin/daemonsu",
"/system/xbin/busybox",
"/system/xbin/su",
"/system/sd/xbin/su",
"/system/bin/su",
"/system/bin/failsafe/su",
"/su/bin/su",
"/sbin/su",
"/data/local/xbin/su",
"/data/local/bin/su",
"/data/local/su",
)
/**
* ルート化された端末かどうか確認する.
*/
fun isDeviceRooted(): Boolean {
return checkRootBuild() || checkRootApps() || checkRootSu()
}
/**
* テストビルドやカスタム ROM の兆候を確認する.
*/
private fun checkRootBuild(): Boolean {
val buildTags = Build.TAGS
val ret = buildTags != null && buildTags.contains("test-keys")
if (ret) {
Log.e(Tag, "Root check is false(Test build or custom build)")
}
return ret
}
/**
* ルート化されたデバイスに通常見つかるファイルをチェックする.
*/
private fun checkRootApps(): Boolean {
for (path in PATHS_SU) {
if (File(path).exists()) {
Log.e(Tag, "Root check is false(SU application is found)")
return true
}
}
return false
}
/**
* su が存在するかどうかを判断する別の方法は、Runtime.getRuntime.exec() で実行を試みる.
*/
@Suppress("SwallowedException", "TooGenericExceptionCaught")
private fun checkRootSu(): Boolean {
var process: Process? = null
val ret = try {
process = Runtime.getRuntime().exec(arrayOf(PATH_TO_WHICH, CMD_SU))
val inputStream = BufferedReader(InputStreamReader(process.inputStream))
inputStream.readLine() != null
} catch (t: Throwable) {
false
} finally {
process?.destroy()
}
if (ret.not()) {
Log.e(Tag, "Root check is false(SU is enabled)")
}
return ret
}
}
}
|
ChatbotProject/common/src/main/java/template/common/components/ProgressIndicators.kt | 1597716894 | /*
* MIT License
*
* Copyright (c) 2024 Hridoy Chandra Das
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package template.common.components
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import template.theme.TemplateTheme
@Composable
fun FullScreenCircularProgressIndicator() {
Box(
modifier = Modifier
.fillMaxSize()
.background(MaterialTheme.colorScheme.background),
contentAlignment = Alignment.Center,
) {
CircularProgressIndicator()
}
}
@TemplatePreview
@Composable
fun FullScreenCircularProgressIndicatorPreview() {
TemplateTheme {
Surface {
FullScreenCircularProgressIndicator()
}
}
}
|
ChatbotProject/common/src/main/java/template/common/components/TextFields.kt | 3139571799 | /*
* MIT License
*
* Copyright (c) 2024 Hridoy Chandra Das
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package template.common.components
import androidx.annotation.StringRes
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Email
import androidx.compose.material.icons.filled.Info
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.material3.TextField
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusDirection
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.platform.LocalFocusManager
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.text.input.PasswordVisualTransformation
import androidx.compose.ui.text.input.VisualTransformation
import androidx.compose.ui.unit.dp
import template.common.R
import template.theme.TemplateTheme
@Composable
fun AppTextField(
value: String,
@StringRes label: Int,
hint: String = "",
onValueChanged: (value: String) -> Unit,
isPasswordField: Boolean = false,
isClickOnly: Boolean = false,
onClick: () -> Unit = {},
leadingIcon: ImageVector? = null,
@StringRes error: Int? = null,
keyboardType: KeyboardType = KeyboardType.Text,
imeAction: ImeAction = ImeAction.Done,
onDone: () -> Unit = {},
) {
val focusManager = LocalFocusManager.current
Box(
modifier = Modifier
.fillMaxWidth()
.height(90.dp),
) {
TextField(
modifier = Modifier
.fillMaxWidth()
.clickable {
if (isClickOnly) {
onClick()
}
},
value = value,
onValueChange = { onValueChanged(it) },
singleLine = true,
isError = error != null,
readOnly = isClickOnly,
enabled = !isClickOnly,
supportingText = {
if (error != null) {
Text(
modifier = Modifier.fillMaxWidth(),
text = stringResource(error),
color = MaterialTheme.colorScheme.error,
)
}
},
visualTransformation = if (isPasswordField) PasswordVisualTransformation() else VisualTransformation.None,
label = { Text(text = stringResource(label)) },
placeholder = { Text(text = hint) },
leadingIcon = {
leadingIcon?.let {
Icon(it, hint, tint = MaterialTheme.colorScheme.onSurfaceVariant)
}
},
trailingIcon = {
if (error != null) {
Icon(Icons.Filled.Info, "error", tint = MaterialTheme.colorScheme.error)
}
},
keyboardActions = KeyboardActions(
onDone = {
focusManager.clearFocus()
onDone()
},
onNext = { focusManager.moveFocus(FocusDirection.Down) },
),
keyboardOptions = KeyboardOptions(
keyboardType = keyboardType,
imeAction = imeAction,
),
)
}
}
@TemplatePreview
@Composable
fun AppTextFieldPreview() {
TemplateTheme {
Surface {
TextField(
modifier = Modifier
.fillMaxWidth()
.clickable {},
value = "",
onValueChange = { },
singleLine = true,
isError = true,
readOnly = false,
enabled = true,
supportingText = {
Text(text = "Error Message or Supporting Message")
},
placeholder = { Text(text = "Hint") },
)
}
}
}
@TemplatePreview
@Composable
fun LoginScreenPreview() {
TemplateTheme {
Surface(modifier = Modifier.fillMaxSize()) {
AppTextField(
value = "[email protected]",
label = R.string.email,
hint = "[email protected]",
error = com.google.android.material.R.string.error_a11y_label,
leadingIcon = Icons.Filled.Email,
onValueChanged = { },
imeAction = ImeAction.Next,
)
}
}
}
|
ChatbotProject/common/src/main/java/template/common/components/AppBar.kt | 1069187939 | /*
* MIT License
*
* Copyright (c) 2024 Hridoy Chandra Das
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package template.common.components
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.vector.ImageVector
@Composable
fun AppBar(
title: String,
navIcon: ImageVector? = null,
onNav: () -> Unit = {},
) {
TopAppBar(
colors = TopAppBarDefaults.topAppBarColors(
containerColor = MaterialTheme.colorScheme.primaryContainer,
titleContentColor = MaterialTheme.colorScheme.primary,
),
title = {
Text(text = title)
},
navigationIcon = {
navIcon?.let {
IconButton(onClick = { onNav() }) {
Icon(navIcon, contentDescription = "Nav Icon")
}
}
},
)
}
|
ChatbotProject/common/src/main/java/template/common/components/TemplatePreview.kt | 4188115053 | /*
* MIT License
*
* Copyright (c) 2024 Hridoy Chandra Das
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package template.common.components
import android.content.res.Configuration.UI_MODE_NIGHT_NO
import android.content.res.Configuration.UI_MODE_NIGHT_YES
import androidx.compose.ui.tooling.preview.Preview
@Preview(
name = "Preview Day",
showBackground = true,
uiMode = UI_MODE_NIGHT_NO,
)
@Preview(
name = "Preview Night",
showBackground = true,
uiMode = UI_MODE_NIGHT_YES,
)
annotation class TemplatePreview
|
ChatbotProject/common/src/main/java/template/common/Constents.kt | 186668979 | /*
* MIT License
*
* Copyright (c) 2024 Hridoy Chandra Das
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package template.common
const val DURATION_MILLIS = 500
const val VALUES_X = 0.4f
const val VALUES_Y = 0.0f
const val DURATION = 500L
|
ChatbotProject/theme/src/main/java/template/theme/Shape.kt | 3115525955 | /*
* MIT License
*
* Copyright (c) 2024 Hridoy Chandra Das
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package template.theme
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Shapes
import androidx.compose.ui.unit.dp
val Shapes =
Shapes(
small = RoundedCornerShape(4.dp),
medium = RoundedCornerShape(4.dp),
large = RoundedCornerShape(0.dp),
)
|
ChatbotProject/theme/src/main/java/template/theme/splashScreen/SplashViewModel.kt | 3932454659 | /*
* MIT License
*
* Copyright (c) 2024 Hridoy Chandra Das
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package template.theme.splashScreen
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.launch
@HiltViewModel
class SplashViewModel :
// @Inject constructor(
// @ApplicationContext context: Context,
// // private val prefDataStore: PrefDataStore)
ViewModel() {
private val _isLoading = MutableStateFlow(false)
val isLoading = _isLoading.asStateFlow()
companion object {
const val DELAY_DURATION = 3000L
}
init {
viewModelScope.launch {
delay(DELAY_DURATION)
_isLoading.value = true
}
}
}
|
ChatbotProject/theme/src/main/java/template/theme/Color.kt | 483642369 | /*
* MIT License
*
* Copyright (c) 2024 Hridoy Chandra Das
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package template.theme
import androidx.compose.ui.graphics.Color
const val LIGHT_PRIMARY = 0xFF3F51B5
const val LIGHT_ON_PRIMARY = 0xFFFFFFFF
const val LIGHT_PRIMARY_CONTAINER = 0xFFFFFFFF
const val LIGHT_ON_PRIMARY_CONTAINER = 0xFF000000
const val LIGHT_SECONDARY = 0xFF303F9F
const val LIGHT_ON_SECONDARY = 0xFFFFFFFF
const val LIGHT_SECONDARY_CONTAINER = 0xFFFFFFFF
const val LIGHT_ON_SECONDARY_CONTAINER = 0xFF000000
const val LIGHT_TERTIARY = 0xFFC5CAE9
const val LIGHT_ON_TERTIARY = 0xFF000000
const val LIGHT_TERTIARY_CONTAINER = 0xFFFFFFFF
const val LIGHT_ON_TERTIARY_CONTAINER = 0xFF000000
const val LIGHT_ERROR = 0xFFB00020
const val LIGHT_ERROR_CONTAINER = 0xFFFFFFFF
const val LIGHT_ON_ERROR = 0xFFFFFFFF
const val LIGHT_ON_ERROR_CONTAINER = 0xFF000000
const val LIGHT_BACKGROUND = 0xFFFFFFFF
const val LIGHT_ON_BACKGROUND = 0xFF000000
const val LIGHT_SURFACE = 0xFFFFFFFF
const val LIGHT_ON_SURFACE = 0xFF000000
const val LIGHT_SURFACE_VARIANT = 0xFFE8EAF6
const val LIGHT_ON_SURFACE_VARIANT = 0xFF000000
const val LIGHT_OUTLINE = 0xFF000000
const val LIGHT_INVERSE_ON_SURFACE = 0xFFFFFFFF
const val LIGHT_INVERSE_SURFACE = 0xFF000000
const val LIGHT_INVERSE_PRIMARY = 0xFF000000
const val LIGHT_SHADOW = 0x14000000
const val LIGHT_SURFACE_TINT = 0x0A000000
const val LIGHT_OUTLINE_VARIANT = 0x1F000000
const val LIGHT_SCRIM = 0x33000000
const val DARK_PRIMARY = 0xFF7986CB
const val DARK_ON_PRIMARY = 0xFFFFFFFF
const val DARK_PRIMARY_CONTAINER = 0xFF303F9F
const val DARK_ON_PRIMARY_CONTAINER = 0xFFFFFFFF
const val DARK_SECONDARY = 0xFF303F9F
const val DARK_ON_SECONDARY = 0xFFFFFFFF
const val DARK_SECONDARY_CONTAINER = 0xFF3F51B5
const val DARK_ON_SECONDARY_CONTAINER = 0xFFFFFFFF
const val DARK_TERTIARY = 0xFFC5CAE9
const val DARK_ON_TERTIARY = 0xFF000000
const val DARK_TERTIARY_CONTAINER = 0xFFFFFFFF
const val DARK_ON_TERTIARY_CONTAINER = 0xFF000000
const val DARK_ERROR = 0xFFB00020
const val DARK_ERROR_CONTAINER = 0xFFFFFFFF
const val DARK_ON_ERROR = 0xFFFFFFFF
const val DARK_ON_ERROR_CONTAINER = 0xFF000000
const val DARK_BACKGROUND = 0xFF121212
const val DARK_ON_BACKGROUND = 0xFFFFFFFF
const val DARK_SURFACE = 0xFF121212
const val DARK_ON_SURFACE = 0xFFFFFFFF
const val DARK_SURFACE_VARIANT = 0xFF1E1E1E
const val DARK_ON_SURFACE_VARIANT = 0xFFFFFFFF
const val DARK_OUTLINE = 0xFF000000
const val DARK_INVERSE_ON_SURFACE = 0xFFFFFFFF
const val DARK_INVERSE_SURFACE = 0xFF000000
const val DARK_INVERSE_PRIMARY = 0xFF000000
const val DARK_SHADOW = 0x14000000
const val DARK_SURFACE_TINT = 0x0A000000
const val DARK_OUTLINE_VARIANT = 0x1F000000
const val DARK_SCRIM = 0x33000000
const val SEED = 0xFF3F51B5
val template_theme_light_primary = Color(LIGHT_PRIMARY)
val template_theme_light_onPrimary = Color(LIGHT_ON_PRIMARY)
val template_theme_light_primaryContainer = Color(LIGHT_PRIMARY_CONTAINER)
val template_theme_light_onPrimaryContainer = Color(LIGHT_ON_PRIMARY_CONTAINER)
val template_theme_light_secondary = Color(LIGHT_SECONDARY)
val template_theme_light_onSecondary = Color(LIGHT_ON_SECONDARY)
val template_theme_light_secondaryContainer = Color(LIGHT_SECONDARY_CONTAINER)
val template_theme_light_onSecondaryContainer = Color(LIGHT_ON_SECONDARY_CONTAINER)
val template_theme_light_tertiary = Color(LIGHT_TERTIARY)
val template_theme_light_onTertiary = Color(LIGHT_ON_TERTIARY)
val template_theme_light_tertiaryContainer = Color(LIGHT_TERTIARY_CONTAINER)
val template_theme_light_onTertiaryContainer = Color(LIGHT_ON_TERTIARY_CONTAINER)
val template_theme_light_error = Color(LIGHT_ERROR)
val template_theme_light_errorContainer = Color(LIGHT_ERROR_CONTAINER)
val template_theme_light_onError = Color(LIGHT_ON_ERROR)
val template_theme_light_onErrorContainer = Color(LIGHT_ON_ERROR_CONTAINER)
val template_theme_light_background = Color(LIGHT_BACKGROUND)
val template_theme_light_onBackground = Color(LIGHT_ON_BACKGROUND)
val template_theme_light_surface = Color(LIGHT_SURFACE)
val template_theme_light_onSurface = Color(LIGHT_ON_SURFACE)
val template_theme_light_surfaceVariant = Color(LIGHT_SURFACE_VARIANT)
val template_theme_light_onSurfaceVariant = Color(LIGHT_ON_SURFACE_VARIANT)
val template_theme_light_outline = Color(LIGHT_OUTLINE)
val template_theme_light_inverseOnSurface = Color(LIGHT_INVERSE_ON_SURFACE)
val template_theme_light_inverseSurface = Color(LIGHT_INVERSE_SURFACE)
val template_theme_light_inversePrimary = Color(LIGHT_INVERSE_PRIMARY)
val template_theme_light_shadow = Color(LIGHT_SHADOW)
val template_theme_light_surfaceTint = Color(LIGHT_SURFACE_TINT)
val template_theme_light_outlineVariant = Color(LIGHT_OUTLINE_VARIANT)
val template_theme_light_scrim = Color(LIGHT_SCRIM)
val template_theme_dark_primary = Color(DARK_PRIMARY)
val template_theme_dark_onPrimary = Color(DARK_ON_PRIMARY)
val template_theme_dark_primaryContainer = Color(DARK_PRIMARY_CONTAINER)
val template_theme_dark_onPrimaryContainer = Color(DARK_ON_PRIMARY_CONTAINER)
val template_theme_dark_secondary = Color(DARK_SECONDARY)
val template_theme_dark_onSecondary = Color(DARK_ON_SECONDARY)
val template_theme_dark_secondaryContainer = Color(DARK_SECONDARY_CONTAINER)
val template_theme_dark_onSecondaryContainer = Color(DARK_ON_SECONDARY_CONTAINER)
val template_theme_dark_tertiary = Color(DARK_TERTIARY)
val template_theme_dark_onTertiary = Color(DARK_ON_TERTIARY)
val template_theme_dark_tertiaryContainer = Color(DARK_TERTIARY_CONTAINER)
val template_theme_dark_onTertiaryContainer = Color(DARK_ON_TERTIARY_CONTAINER)
val template_theme_dark_error = Color(DARK_ERROR)
val template_theme_dark_errorContainer = Color(DARK_ERROR_CONTAINER)
val template_theme_dark_onError = Color(DARK_ON_ERROR)
val template_theme_dark_onErrorContainer = Color(DARK_ON_ERROR_CONTAINER)
val template_theme_dark_background = Color(DARK_BACKGROUND)
val template_theme_dark_onBackground = Color(DARK_ON_BACKGROUND)
val template_theme_dark_surface = Color(DARK_SURFACE)
val template_theme_dark_onSurface = Color(DARK_ON_SURFACE)
val template_theme_dark_surfaceVariant = Color(DARK_SURFACE_VARIANT)
val template_theme_dark_onSurfaceVariant = Color(DARK_ON_SURFACE_VARIANT)
val template_theme_dark_outline = Color(DARK_OUTLINE)
val template_theme_dark_inverseOnSurface = Color(DARK_INVERSE_ON_SURFACE)
val template_theme_dark_inverseSurface = Color(DARK_INVERSE_SURFACE)
val template_theme_dark_inversePrimary = Color(DARK_INVERSE_PRIMARY)
val template_theme_dark_shadow = Color(DARK_SHADOW)
val template_theme_dark_surfaceTint = Color(DARK_SURFACE_TINT)
val template_theme_dark_outlineVariant = Color(DARK_OUTLINE_VARIANT)
val template_theme_dark_scrim = Color(DARK_SCRIM)
val seed = Color(SEED)
|
ChatbotProject/theme/src/main/java/template/theme/Theme.kt | 878384629 | /*
* MIT License
*
* Copyright (c) 2024 Hridoy Chandra Das
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package template.theme
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.darkColorScheme
import androidx.compose.material3.lightColorScheme
import androidx.compose.runtime.Composable
private val LightColors = lightColorScheme(
primary = template_theme_light_primary,
onPrimary = template_theme_light_onPrimary,
primaryContainer = template_theme_light_primaryContainer,
onPrimaryContainer = template_theme_light_onPrimaryContainer,
secondary = template_theme_light_secondary,
onSecondary = template_theme_light_onSecondary,
secondaryContainer = template_theme_light_secondaryContainer,
onSecondaryContainer = template_theme_light_onSecondaryContainer,
tertiary = template_theme_light_tertiary,
onTertiary = template_theme_light_onTertiary,
tertiaryContainer = template_theme_light_tertiaryContainer,
onTertiaryContainer = template_theme_light_onTertiaryContainer,
error = template_theme_light_error,
errorContainer = template_theme_light_errorContainer,
onError = template_theme_light_onError,
onErrorContainer = template_theme_light_onErrorContainer,
background = template_theme_light_background,
onBackground = template_theme_light_onBackground,
surface = template_theme_light_surface,
onSurface = template_theme_light_onSurface,
surfaceVariant = template_theme_light_surfaceVariant,
onSurfaceVariant = template_theme_light_onSurfaceVariant,
outline = template_theme_light_outline,
inverseOnSurface = template_theme_light_inverseOnSurface,
inverseSurface = template_theme_light_inverseSurface,
inversePrimary = template_theme_light_inversePrimary,
surfaceTint = template_theme_light_surfaceTint,
outlineVariant = template_theme_light_outlineVariant,
scrim = template_theme_light_scrim,
)
private val DarkColors = darkColorScheme(
primary = template_theme_dark_primary,
onPrimary = template_theme_dark_onPrimary,
primaryContainer = template_theme_dark_primaryContainer,
onPrimaryContainer = template_theme_dark_onPrimaryContainer,
secondary = template_theme_dark_secondary,
onSecondary = template_theme_dark_onSecondary,
secondaryContainer = template_theme_dark_secondaryContainer,
onSecondaryContainer = template_theme_dark_onSecondaryContainer,
tertiary = template_theme_dark_tertiary,
onTertiary = template_theme_dark_onTertiary,
tertiaryContainer = template_theme_dark_tertiaryContainer,
onTertiaryContainer = template_theme_dark_onTertiaryContainer,
error = template_theme_dark_error,
errorContainer = template_theme_dark_errorContainer,
onError = template_theme_dark_onError,
onErrorContainer = template_theme_dark_onErrorContainer,
background = template_theme_dark_background,
onBackground = template_theme_dark_onBackground,
surface = template_theme_dark_surface,
onSurface = template_theme_dark_onSurface,
surfaceVariant = template_theme_dark_surfaceVariant,
onSurfaceVariant = template_theme_dark_onSurfaceVariant,
outline = template_theme_dark_outline,
inverseOnSurface = template_theme_dark_inverseOnSurface,
inverseSurface = template_theme_dark_inverseSurface,
inversePrimary = template_theme_dark_inversePrimary,
surfaceTint = template_theme_dark_surfaceTint,
outlineVariant = template_theme_dark_outlineVariant,
scrim = template_theme_dark_scrim,
)
@Composable
fun TemplateTheme(
useDarkTheme: Boolean = isSystemInDarkTheme(),
content:
@Composable()
() -> Unit,
) {
val colors = if (!useDarkTheme) {
LightColors
} else {
DarkColors
}
MaterialTheme(
colorScheme = colors,
typography = Typography,
shapes = Shapes,
content = content,
)
}
|
ChatbotProject/theme/src/main/java/template/theme/Type.kt | 360953294 | /*
* MIT License
*
* Copyright (c) 2024 Hridoy Chandra Das
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package template.theme
import androidx.compose.material3.Typography
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.sp
// Set of Material typography styles to start with
val Typography =
Typography(
bodyMedium =
TextStyle(
fontFamily = FontFamily.Default,
fontWeight = FontWeight.Normal,
fontSize = 16.sp,
),
)
|
press/src/main/kotlin/Main.kt | 1717384775 | fun main() {
println(sentence("Barnie","bakes","brown","bagels","buns"))
isPandrome()
}
fun sentence(b1:String,b2:String,b3:String,b4:String,b5:String){
var words = "Barnie bakes brown bagels and buns"
}
fun isPalindrome(word:String):Boolean{
var words = "madam wow kayak"
if(words == "gender" ){
println("madam wow kayak")
}
} |
VolumeTechTest/app/src/main/java/com/pacheco/volumetechtest/ui/viewmodel/MainViewModel.kt | 1109229957 | package com.pacheco.volumetechtest.ui.viewmodel
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.pacheco.volumetechtest.domain.model.WeatherModel
import com.pacheco.volumetechtest.domain.usecase.GetWeatherUseCase
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.*
import java.util.concurrent.TimeUnit
import javax.inject.Inject
@HiltViewModel
class MainViewModel @Inject constructor(
private val getWeatherUseCase: GetWeatherUseCase
) : ViewModel() {
fun getWeather(onSuccess: (WeatherModel) -> Unit) {
viewModelScope.launch(context = CoroutineExceptionHandler { _, _ ->
getWeather(onSuccess = onSuccess)
}) {
while (currentCoroutineContext().isActive) {
onSuccess(getWeatherUseCase())
delay(timeMillis = TimeUnit.HOURS.toMillis(1))
}
}
}
} |
VolumeTechTest/app/src/main/java/com/pacheco/volumetechtest/ui/MainActivity.kt | 3002005988 | package com.pacheco.volumetechtest.ui
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.viewModels
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
import com.pacheco.volumetechtest.domain.model.WeatherModel
import com.pacheco.volumetechtest.router.ApplicationNavHost
import com.pacheco.volumetechtest.ui.theme.VolumeTechTestTheme
import com.pacheco.volumetechtest.ui.viewmodel.MainViewModel
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.delay
import java.util.concurrent.TimeUnit
@AndroidEntryPoint
class MainActivity : ComponentActivity() {
private val viewModel: MainViewModel by viewModels()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
VolumeTechTestTheme {
Scaffold(modifier = Modifier.fillMaxSize()) {
WeatherLayer(viewModel = viewModel)
ApplicationNavHost()
}
}
}
}
}
@Composable
private fun WeatherLayer(viewModel: MainViewModel) {
var weather: WeatherModel? by remember {
mutableStateOf(null)
}
var alignment: Pair<Alignment?, Alignment.Horizontal?> by remember {
mutableStateOf(null to null)
}
LaunchedEffect(key1 = Unit) {
while (true) {
alignment = when(alignment.first) {
Alignment.TopStart -> Alignment.TopEnd to Alignment.End
Alignment.TopEnd -> Alignment.TopStart to Alignment.Start
else -> Alignment.TopStart to Alignment.Start
}
delay(timeMillis = TimeUnit.SECONDS.toMillis(30))
}
}
weather?.let {
Box(
contentAlignment = alignment.first ?: Alignment.TopStart,
modifier = Modifier.fillMaxWidth()
) {
Column(
modifier = Modifier
.background(color = Color.Blue)
.padding(all = 10.dp),
horizontalAlignment = alignment.second ?: Alignment.Start
) {
Text(text = it.temp.toString() + "ºC")
Text(text = it.city)
}
}
} ?: viewModel.getWeather {
weather = it
}
} |
VolumeTechTest/app/src/main/java/com/pacheco/volumetechtest/ui/theme/Color.kt | 2180895376 | package com.pacheco.volumetechtest.ui.theme
import androidx.compose.material3.darkColorScheme
val colorScheme = darkColorScheme() |
VolumeTechTest/app/src/main/java/com/pacheco/volumetechtest/ui/theme/Theme.kt | 2752708008 | package com.pacheco.volumetechtest.ui.theme
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
@Composable
fun VolumeTechTestTheme(content: @Composable () -> Unit) {
MaterialTheme(
colorScheme = colorScheme,
typography = typography,
content = content
)
} |
VolumeTechTest/app/src/main/java/com/pacheco/volumetechtest/ui/theme/Type.kt | 1390371375 | package com.pacheco.volumetechtest.ui.theme
import androidx.compose.material3.Typography
val typography = Typography() |
VolumeTechTest/app/src/main/java/com/pacheco/volumetechtest/ui/view/HomeView.kt | 4089622524 | package com.pacheco.volumetechtest.ui.view
import androidx.compose.runtime.Composable
@Composable
fun HomeView() {
} |
VolumeTechTest/app/src/main/java/com/pacheco/volumetechtest/di/MapperModule.kt | 2350524149 | package com.pacheco.volumetechtest.di
import com.pacheco.volumetechtest.data.mapper.WeatherMapper
import com.pacheco.volumetechtest.data.mapper.WeatherMapperImp
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton
@Module
@InstallIn(SingletonComponent::class)
abstract class MapperModule {
@Singleton
@Binds
abstract fun bindWeatherMapper(mapper: WeatherMapperImp): WeatherMapper
} |
VolumeTechTest/app/src/main/java/com/pacheco/volumetechtest/di/ServiceModule.kt | 2454644355 | package com.pacheco.volumetechtest.di
import com.pacheco.volumetechtest.data.RetrofitClient
import com.pacheco.volumetechtest.data.service.WeatherService
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton
@Module
@InstallIn(SingletonComponent::class)
object ServiceModule {
@Singleton
@Provides
fun provideWeatherService(): WeatherService = RetrofitClient.create(classType = WeatherService::class.java)
} |
VolumeTechTest/app/src/main/java/com/pacheco/volumetechtest/di/RepositoryModule.kt | 162967843 | package com.pacheco.volumetechtest.di
import com.pacheco.volumetechtest.data.repository.WeatherRepositoryImp
import com.pacheco.volumetechtest.domain.repository.WeatherRepository
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton
@Module
@InstallIn(SingletonComponent::class)
abstract class RepositoryModule {
@Singleton
@Binds
abstract fun bindWeatherRepository(repository: WeatherRepositoryImp): WeatherRepository
} |
VolumeTechTest/app/src/main/java/com/pacheco/volumetechtest/di/UseCaseModule.kt | 691662648 | package com.pacheco.volumetechtest.di
import com.pacheco.volumetechtest.domain.usecase.GetWeatherUseCase
import com.pacheco.volumetechtest.domain.usecase.GetWeatherUseCaseImp
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton
@Module
@InstallIn(SingletonComponent::class)
abstract class UseCaseModule {
@Singleton
@Binds
abstract fun bindGetWeatherUseCase(usecase: GetWeatherUseCaseImp): GetWeatherUseCase
} |
VolumeTechTest/app/src/main/java/com/pacheco/volumetechtest/HiltApplication.kt | 1126531550 | package com.pacheco.volumetechtest
import android.app.Application
import dagger.hilt.android.HiltAndroidApp
@HiltAndroidApp
class HiltApplication : Application() |
VolumeTechTest/app/src/main/java/com/pacheco/volumetechtest/data/dto/WeatherDto.kt | 3844164055 | package com.pacheco.volumetechtest.data.dto
data class WeatherDto(
val name: String?,
val main: MainDto?
)
|
VolumeTechTest/app/src/main/java/com/pacheco/volumetechtest/data/dto/MainDto.kt | 1357034274 | package com.pacheco.volumetechtest.data.dto
data class MainDto(
val temp: Float?
)
|
VolumeTechTest/app/src/main/java/com/pacheco/volumetechtest/data/repository/WeatherRepositoryImp.kt | 2805144711 | package com.pacheco.volumetechtest.data.repository
import com.pacheco.volumetechtest.data.mapper.WeatherMapper
import com.pacheco.volumetechtest.data.service.WeatherService
import com.pacheco.volumetechtest.domain.model.City
import com.pacheco.volumetechtest.domain.repository.WeatherRepository
import javax.inject.Inject
import javax.inject.Singleton
@Singleton
class WeatherRepositoryImp @Inject constructor(
private val service: WeatherService,
private val mapper: WeatherMapper
) : WeatherRepository {
override suspend fun getWeather(city: City) = mapper.toModel(
dto = service.getWeather(city = city.name),
city = city
)
} |
VolumeTechTest/app/src/main/java/com/pacheco/volumetechtest/data/Endpoint.kt | 1257965398 | package com.pacheco.volumetechtest.data
object Endpoint {
const val BASE_URL = "https://api.openweathermap.org/data/2.5/"
const val WEATHER = "weather"
} |
VolumeTechTest/app/src/main/java/com/pacheco/volumetechtest/data/RetrofitClient.kt | 2215922688 | package com.pacheco.volumetechtest.data
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
object RetrofitClient {
const val API_KEY = "433f0a05409361125a827f77654820e4"
private val INSTANCE: Retrofit = Retrofit.Builder()
.baseUrl(Endpoint.BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
.build()
fun <T> create(classType: Class<T>): T = INSTANCE.create(classType)
} |
VolumeTechTest/app/src/main/java/com/pacheco/volumetechtest/data/mapper/WeatherMapperImp.kt | 3517455199 | package com.pacheco.volumetechtest.data.mapper
import com.pacheco.volumetechtest.data.dto.WeatherDto
import com.pacheco.volumetechtest.domain.model.City
import com.pacheco.volumetechtest.domain.model.WeatherModel
import javax.inject.Inject
import kotlin.math.roundToInt
class WeatherMapperImp @Inject constructor() : WeatherMapper {
override fun toModel(dto: WeatherDto?, city: City): WeatherModel {
if (dto?.name == null || dto.main?.temp == null) {
throw Exception()
}
return WeatherModel(
city = dto.name.ifBlank(city::name),
temp = dto.main.temp.roundToInt()
)
}
} |
VolumeTechTest/app/src/main/java/com/pacheco/volumetechtest/data/mapper/WeatherMapper.kt | 263600258 | package com.pacheco.volumetechtest.data.mapper
import com.pacheco.volumetechtest.data.dto.WeatherDto
import com.pacheco.volumetechtest.domain.model.City
import com.pacheco.volumetechtest.domain.model.WeatherModel
interface WeatherMapper {
fun toModel(dto: WeatherDto?, city: City): WeatherModel
} |
VolumeTechTest/app/src/main/java/com/pacheco/volumetechtest/data/TempUnit.kt | 1032046605 | package com.pacheco.volumetechtest.data
sealed class TempUnit(open val name: String) {
data class Metric(override val name: String = "metric"): TempUnit(name = name)
} |
VolumeTechTest/app/src/main/java/com/pacheco/volumetechtest/data/service/WeatherService.kt | 1540185752 | package com.pacheco.volumetechtest.data.service
import com.pacheco.volumetechtest.data.Endpoint
import com.pacheco.volumetechtest.data.RetrofitClient
import com.pacheco.volumetechtest.data.TempUnit
import com.pacheco.volumetechtest.data.dto.WeatherDto
import retrofit2.http.GET
import retrofit2.http.Query
interface WeatherService {
@GET(Endpoint.WEATHER)
suspend fun getWeather(
@Query("q") city: String,
@Query("appid") id: String = RetrofitClient.API_KEY,
@Query("units") unit: String = TempUnit.Metric().name
): WeatherDto?
} |
VolumeTechTest/app/src/main/java/com/pacheco/volumetechtest/domain/repository/WeatherRepository.kt | 2808971097 | package com.pacheco.volumetechtest.domain.repository
import com.pacheco.volumetechtest.domain.model.City
import com.pacheco.volumetechtest.domain.model.WeatherModel
interface WeatherRepository {
suspend fun getWeather(city: City): WeatherModel
} |
VolumeTechTest/app/src/main/java/com/pacheco/volumetechtest/domain/model/City.kt | 408236956 | package com.pacheco.volumetechtest.domain.model
sealed class City(open val name: String) {
data class London(override val name: String = "London"): City(name = name)
} |
VolumeTechTest/app/src/main/java/com/pacheco/volumetechtest/domain/model/WeatherModel.kt | 912934264 | package com.pacheco.volumetechtest.domain.model
import java.util.*
data class WeatherModel(
val city: String,
val temp: Int,
private val uuid: UUID = UUID.randomUUID()
) {
override fun equals(other: Any?) = (other as? WeatherModel)?.uuid == this.uuid
override fun hashCode() = temp.hashCode()
}
|
VolumeTechTest/app/src/main/java/com/pacheco/volumetechtest/domain/usecase/GetWeatherUseCase.kt | 3519947041 | package com.pacheco.volumetechtest.domain.usecase
import com.pacheco.volumetechtest.domain.model.WeatherModel
interface GetWeatherUseCase {
suspend operator fun invoke(): WeatherModel
} |
VolumeTechTest/app/src/main/java/com/pacheco/volumetechtest/domain/usecase/GetWeatherUseCaseImp.kt | 3832702606 | package com.pacheco.volumetechtest.domain.usecase
import com.pacheco.volumetechtest.domain.model.City
import com.pacheco.volumetechtest.domain.repository.WeatherRepository
import javax.inject.Inject
class GetWeatherUseCaseImp @Inject constructor(
private val repository: WeatherRepository
): GetWeatherUseCase {
override suspend fun invoke() = repository.getWeather(city = City.London())
} |
VolumeTechTest/app/src/main/java/com/pacheco/volumetechtest/router/ApplicationNavHost.kt | 76017845 | package com.pacheco.volumetechtest.router
import androidx.compose.runtime.Composable
import androidx.navigation.NavHostController
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController
import com.pacheco.volumetechtest.ui.view.HomeView
@Composable
fun ApplicationNavHost(navController: NavHostController = rememberNavController()) {
NavHost(navController = navController, startDestination = Destination.HOME.name) {
composable(route = Destination.HOME.name) {
HomeView()
}
}
} |
VolumeTechTest/app/src/main/java/com/pacheco/volumetechtest/router/Destination.kt | 2554851313 | package com.pacheco.volumetechtest.router
enum class Destination {
HOME
} |
gea_rent_mobile_app_dummy_data/app/src/androidTest/java/il/massive/gea_rent/ExampleInstrumentedTest.kt | 2803171677 | package il.massive.gea_rent
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.Assert.*
/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("il.massive.gea_rent", appContext.packageName)
}
} |
gea_rent_mobile_app_dummy_data/app/src/test/java/il/massive/gea_rent/ExampleUnitTest.kt | 313246408 | package il.massive.gea_rent
import org.junit.Test
import org.junit.Assert.*
/**
* Example local unit test, which will execute on the development machine (host).
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
class ExampleUnitTest {
@Test
fun addition_isCorrect() {
assertEquals(4, 2 + 2)
}
} |
gea_rent_mobile_app_dummy_data/app/src/main/java/il/massive/gea_rent/ui/DetailBarangActivity.kt | 2753137881 | package il.massive.gea_rent.ui
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import il.massive.gea_rent.R
import il.massive.gea_rent.databinding.ActivityDetailBarangBinding
class DetailBarangActivity : AppCompatActivity() {
private lateinit var binding: ActivityDetailBarangBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityDetailBarangBinding.inflate(layoutInflater)
setContentView(binding.root)
val gambar_barang = intent.getIntExtra("gambar_barang",0)
val nama_barang = intent.getStringExtra("nama_barang")
val deskripsi_produk = intent.getStringExtra("deskripsi_barang")
val nama_toko = intent.getStringExtra("nama_toko")
val profil_toko = intent.getIntExtra("profil_toko",0)
val skor_barang = intent.getIntExtra("skor_barang",0)
binding.gambarProduk.setImageResource(gambar_barang)
binding.namaProduk.text = nama_barang
binding.deskripsiProduk.text = deskripsi_produk
binding.namaToko.text = nama_toko
binding.profilToko.setImageResource(profil_toko)
binding.skorBarang.setImageResource(skor_barang)
binding.icArrowBack.setOnClickListener {
finish()
}
}
} |
gea_rent_mobile_app_dummy_data/app/src/main/java/il/massive/gea_rent/ui/PanduanSleepingBagActivity.kt | 457126949 | package il.massive.gea_rent.ui
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import android.widget.ImageButton
import android.widget.Toast
import il.massive.gea_rent.R
class PanduanSleepingBagActivity : AppCompatActivity(), View.OnClickListener {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_panduan_sleeping_bag)
val btnPanduan: ImageButton = findViewById(R.id.back_panduan3)
btnPanduan.setOnClickListener(this)
}
override fun onClick(v: View?) {
when(v?.id){
R.id.back_panduan3-> {
Toast.makeText(this@PanduanSleepingBagActivity,"Kembali", Toast.LENGTH_LONG).show()
finish()
}
}
}
} |
gea_rent_mobile_app_dummy_data/app/src/main/java/il/massive/gea_rent/ui/MainActivity.kt | 4145805212 | package il.massive.gea_rent.ui
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.fragment.app.Fragment
import com.google.android.material.bottomnavigation.BottomNavigationView
import il.massive.gea_rent.R
import il.massive.gea_rent.databinding.ActivityMainBinding
import il.massive.gea_rent.ui.panduan.PanduanFragment
class MainActivity : AppCompatActivity() {
private lateinit var binding: ActivityMainBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)
loadFragment(BerandaFragment()).run {
setTitles("Beranda","","")
}
binding.bottomNav.setOnNavigationItemSelectedListener { item ->
when (item.itemId) {
R.id.beranda -> {
loadFragment(BerandaFragment())
setTitles("Beranda", "", "")
return@setOnNavigationItemSelectedListener true
}
R.id.panduan -> {
loadFragment(PanduanFragment())
setTitles("", "Panduan", "")
return@setOnNavigationItemSelectedListener true
}
R.id.profile -> {
loadFragment(ProfileFragment())
setTitles("", "", "Profile")
return@setOnNavigationItemSelectedListener true
}
else -> return@setOnNavigationItemSelectedListener false
}
}
}
private fun loadFragment(fragment: Fragment) {
supportFragmentManager.beginTransaction()
.replace(R.id.fragment_container, fragment) // Replace with your fragment container ID
.commit()
}
//set title for bottom nav
private fun setTitles(berandaTitle: String, panduanTitle: String, profileTitle: String) {
val bottomNavigationView: BottomNavigationView = findViewById(R.id.bottom_nav)
bottomNavigationView.menu.findItem(R.id.beranda).setTitle(berandaTitle)
bottomNavigationView.menu.findItem(R.id.panduan).setTitle(panduanTitle)
bottomNavigationView.menu.findItem(R.id.profile).setTitle(profileTitle)
}
} |
gea_rent_mobile_app_dummy_data/app/src/main/java/il/massive/gea_rent/ui/PanduanKomporActivity.kt | 2222057770 | package il.massive.gea_rent.ui
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import android.widget.ImageButton
import android.widget.Toast
import il.massive.gea_rent.R
class PanduanKomporActivity : AppCompatActivity(), View.OnClickListener {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_panduan_kompor)
val btnPanduan: ImageButton = findViewById(R.id.back_panduan)
btnPanduan.setOnClickListener(this)
}
override fun onClick(v: View?) {
when (v?.id) {
R.id.back_panduan -> {
Toast.makeText(this@PanduanKomporActivity, "Kembali", Toast.LENGTH_LONG).show()
finish()
}
}
}
} |
gea_rent_mobile_app_dummy_data/app/src/main/java/il/massive/gea_rent/ui/SplashScreenActivity.kt | 3969244705 | package il.massive.gea_rent.ui
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.os.Handler
import il.massive.gea_rent.R
class SplashScreenActivity : AppCompatActivity() {
//timer
private val SPLASH_TIME_OUT: Long = 3000 //delay 3 detik
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_splash_screen)
Handler().postDelayed({
startActivity((Intent(this@SplashScreenActivity, OnBoardingActivity::class.java)))
finish()
}, SPLASH_TIME_OUT)
}
} |
gea_rent_mobile_app_dummy_data/app/src/main/java/il/massive/gea_rent/ui/RegisterActivity.kt | 1615699775 | package il.massive.gea_rent.ui
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import il.massive.gea_rent.R
import il.massive.gea_rent.databinding.ActivityLoginBinding
import il.massive.gea_rent.databinding.ActivityRegisterBinding
class RegisterActivity : AppCompatActivity() {
private lateinit var binding : ActivityRegisterBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_register)
binding = ActivityRegisterBinding.inflate(layoutInflater)
setContentView(binding.root)
binding.btnDaftar.setOnClickListener {
startActivity(Intent(this@RegisterActivity, MainActivity::class.java))
}
}
} |
gea_rent_mobile_app_dummy_data/app/src/main/java/il/massive/gea_rent/ui/DaftarTokoActivity.kt | 3145188433 | package il.massive.gea_rent.ui
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import android.widget.Button
import android.widget.ImageButton
import il.massive.gea_rent.R
class DaftarTokoActivity : AppCompatActivity(), View.OnClickListener {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_daftar_toko)
val btnHalamanProfil: ImageButton = findViewById(R.id.backhalaman)
btnHalamanProfil.setOnClickListener(this)
val btnDaftarToko: Button = findViewById(R.id.btnDaftarToko)
btnDaftarToko.setOnClickListener(this)
}
override fun onClick(v: View?) {
when(v?.id){
R.id.btnDaftarToko-> {
val intent = Intent(this@DaftarTokoActivity, TokoSayaActivity::class.java)
startActivity(intent)
}
R.id.backhalaman-> {
finish()
}
}
}
} |
gea_rent_mobile_app_dummy_data/app/src/main/java/il/massive/gea_rent/ui/BerandaFragment.kt | 837889703 | package il.massive.gea_rent.ui
import android.content.Intent
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import androidx.recyclerview.widget.LinearLayoutManager
import il.massive.gea_rent.adapter.BarangAdapter
import il.massive.gea_rent.adapter.TokoAdapter
import il.massive.gea_rent.data.barang.DataBarang
import il.massive.gea_rent.data.toko.DataToko
import il.massive.gea_rent.databinding.FragmentBerandaBinding
import il.massive.gea_rent.model.BarangModel
import il.massive.gea_rent.model.TokoModel
class BerandaFragment : Fragment() {
private var _binding: FragmentBerandaBinding? = null
private val binding get() = _binding!!
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
_binding = FragmentBerandaBinding.inflate(inflater, container, false)
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
// Set layout manager for RecyclerView
binding.rvTokoTerdekat.layoutManager = LinearLayoutManager(requireContext(),LinearLayoutManager.HORIZONTAL, false)
// Set adapter for RecyclerView
binding.rvTokoTerdekat.adapter = tokoAdapter
binding.rvBarangTerlengkap.layoutManager = LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)
binding.rvBarangTerlengkap.adapter = barangAdapter
binding.lyBerandaTerdekat.setOnClickListener {
startActivity(Intent(requireContext(), TokoTerdekatActivity::class.java))
}
}
private val tokoAdapter by lazy {
val items = DataToko.dummyTokoData
TokoAdapter(items, object : TokoAdapter.onAdapterListener{
override fun onClick(result: TokoModel) {
val intent = Intent(requireContext(),DetailTokoActivity::class.java)
intent.putExtra("gambar_toko", result.image)
intent.putExtra("nama_toko", result.nama)
intent.putExtra("alamat_toko", result.alamat)
intent.putExtra("no_telepon", result.telpon)
startActivity(intent)
}
})
}
private val barangAdapter by lazy {
val items = DataBarang.dummyDataBarang
BarangAdapter(items, object: BarangAdapter.onAdapterListener{
override fun onClick(barang: BarangModel) {
openDetailBarang(barang)
}
})
}
private fun openDetailBarang(barang: BarangModel) {
val intent = Intent(requireContext(), DetailBarangActivity::class.java)
intent.putExtra("gambar_barang", barang.gambar)
intent.putExtra("harga_barang", barang.harga)
intent.putExtra("nama_barang", barang.nama)
intent.putExtra("deskripsi_barang", barang.deskripsi)
intent.putExtra("nama_toko", barang.toko.nama)
intent.putExtra("profil_toko", barang.toko.image)
intent.putExtra("skor_barang", barang.skor)
startActivity(intent)
}
override fun onDestroyView() {
super.onDestroyView()
_binding = null
}
}
|
gea_rent_mobile_app_dummy_data/app/src/main/java/il/massive/gea_rent/ui/ProdukSewaActivity.kt | 1637028727 | package il.massive.gea_rent.ui
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import android.widget.Button
import android.widget.ImageButton
import il.massive.gea_rent.R
class ProdukSewaActivity : AppCompatActivity(), View.OnClickListener {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_produk_sewa)
val btnkembalitoko: ImageButton = findViewById(R.id.backTokoSy)
btnkembalitoko.setOnClickListener(this)
val btnUpdateProduk:Button = findViewById(R.id.updateproduk)
btnUpdateProduk.setOnClickListener(this)
}
override fun onClick(v: View?) {
when(v?.id){
R.id.updateproduk-> {
val intent = Intent(this@ProdukSewaActivity, TokoSayaActivity::class.java)
startActivity(intent)
}
R.id.backTokoSy-> {
val intent = Intent(this@ProdukSewaActivity, TokoSayaActivity::class.java)
startActivity(intent)
}
}
}
} |
gea_rent_mobile_app_dummy_data/app/src/main/java/il/massive/gea_rent/ui/TokoTerdekatActivity.kt | 2384351951 | package il.massive.gea_rent.ui
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.Toast
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import il.massive.gea_rent.R
import il.massive.gea_rent.adapter.TokoAdapter
import il.massive.gea_rent.adapter.TokoTerdekatAdapter
import il.massive.gea_rent.data.toko.DataToko
import il.massive.gea_rent.databinding.ActivityTokoTerdekatBinding
import il.massive.gea_rent.databinding.TokoTerdekatBinding
import il.massive.gea_rent.model.TokoModel
class TokoTerdekatActivity : AppCompatActivity() {
private lateinit var binding: ActivityTokoTerdekatBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityTokoTerdekatBinding.inflate(layoutInflater)
setContentView(binding.root)
binding.icArrowBack.setOnClickListener {
finish()
}
}
override fun onStart() {
super.onStart()
setUpRecyclerView()
}
private fun setUpRecyclerView(){
val items = DataToko.dummyTokoData
var tokoAdapter = TokoTerdekatAdapter(items, object: TokoTerdekatAdapter.OnAdapterListener{
override fun onClick(result: TokoModel) {
val intent = Intent(this@TokoTerdekatActivity, DetailTokoActivity::class.java)
intent.putExtra("gambar_toko", result.image)
intent.putExtra("nama_toko", result.nama)
intent.putExtra("alamat_toko", result.alamat)
intent.putExtra("no_telepon", result.telpon)
startActivity(intent)
}
})
binding.rvTokoTerdekatLihatSemua.apply {
layoutManager = LinearLayoutManager(this@TokoTerdekatActivity)
adapter = tokoAdapter
}
}
} |
gea_rent_mobile_app_dummy_data/app/src/main/java/il/massive/gea_rent/ui/OnBoardingActivity.kt | 1515152278 | package il.massive.gea_rent.ui
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.Button
import android.widget.TextView
import il.massive.gea_rent.R
import il.massive.gea_rent.databinding.ActivityOnBoardingBinding
class OnBoardingActivity : AppCompatActivity() {
private lateinit var binding: ActivityOnBoardingBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityOnBoardingBinding.inflate(layoutInflater)
setContentView(binding.root)
binding.btnDaftarOnboarding.setOnClickListener {
startActivity(Intent(this@OnBoardingActivity, RegisterActivity::class.java))
}
binding.tvMasukDisini.setOnClickListener {
startActivity(Intent(this@OnBoardingActivity, LoginActivity::class.java))
}
}
} |
gea_rent_mobile_app_dummy_data/app/src/main/java/il/massive/gea_rent/ui/PanduanKompasActivity.kt | 2624494533 | package il.massive.gea_rent.ui
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import android.widget.ImageButton
import android.widget.Toast
import il.massive.gea_rent.R
class PanduanKompasActivity : AppCompatActivity(), View.OnClickListener {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_panduan_kompas)
val btnPanduan: ImageButton = findViewById(R.id.back_panduan5)
btnPanduan.setOnClickListener(this)
}
override fun onClick(v: View?) {
when(v?.id){
R.id.back_panduan5-> {
Toast.makeText(this@PanduanKompasActivity,"Kembali", Toast.LENGTH_LONG).show()
finish()
}
}
}
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.