Skip to content

Commit

Permalink
closes #137
Browse files Browse the repository at this point in the history
  • Loading branch information
yamin8000 committed Sep 5, 2024
1 parent 0ec7570 commit 28071a6
Show file tree
Hide file tree
Showing 89 changed files with 1,200 additions and 592 deletions.
5 changes: 3 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ android {
applicationId = appId
minSdk = 21
targetSdk = 35
versionCode = 43
versionName = "1.7.0"
versionCode = 44
versionName = "1.7.1"
vectorDrawables.useSupportLibrary = true
base.archivesName = "$applicationId-v$versionCode-n$versionName"
}
Expand Down Expand Up @@ -96,6 +96,7 @@ dependencies {
implementation(project(":feature_settings"))
implementation(project(":feature_history"))
implementation(project(":feature_favourites"))
implementation(project(":feature_overlay"))
//core android/kotlin
coreLibraryDesugaring(libs.desugar.jdk.libs)
implementation(libs.androidx.core.ktx)
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
</activity>

<activity
android:name=".ui.FloatingActivity"
android:name=".ui.OverlayActivity"
android:configChanges="orientation|screenSize|keyboardHidden|keyboard|locale|screenLayout|screenSize"
android:excludeFromRecents="true"
android:exported="true"
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/io/github/yamin8000/owl/ui/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ internal class MainActivity : BaseActivity() {

enableEdgeToEdge()

intentSearch = intent.getStringExtra("Search")

showContent {
Scaffold {
MainNav(onThemeChanged = { appTheme = it })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,44 +24,33 @@ package io.github.yamin8000.owl.ui
import android.content.Intent
import android.os.Build
import android.os.Bundle
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material3.BasicAlertDialog
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.DialogProperties
import androidx.core.os.bundleOf
import androidx.hilt.navigation.compose.hiltViewModel
import io.github.yamin8000.owl.feature_overlay.di.OverlayViewModelFactory
import io.github.yamin8000.owl.feature_overlay.ui.OverlayScreen
import io.github.yamin8000.owl.feature_overlay.ui.OverlayWindowViewModel

internal class FloatingActivity : BaseActivity() {
internal class OverlayActivity : BaseActivity() {

@OptIn(ExperimentalMaterial3Api::class)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

val data = handleOutsideInputIntent()

showContent {
val configuration = LocalConfiguration.current
val screenHeight = configuration.screenHeightDp.dp
BasicAlertDialog(
OverlayScreen(
onDismissRequest = { finish() },
properties = DialogProperties(
dismissOnClickOutside = false,
usePlatformDefaultWidth = false
),
content = {
Surface(
modifier = Modifier
.size(screenHeight / 2)
.padding(horizontal = 10.dp),
content = {
Text("is this what you want? $data")
}
)
}
navigateToApp = {
val intent = Intent(this, MainActivity::class.java)
intent.putExtras(bundleOf("Search" to it))
startActivity(intent)
finish()
},
vm = hiltViewModel<OverlayWindowViewModel, OverlayViewModelFactory>(
creationCallback = { factory ->
factory.create(intentSearch = data)
}
)
)
}
}
Expand Down
Empty file removed common/consumer-rules.pro
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ import androidx.compose.foundation.lazy.grid.items
import androidx.compose.foundation.text.selection.LocalTextSelectionColors
import androidx.compose.foundation.text.selection.SelectionContainer
import androidx.compose.foundation.text.selection.TextSelectionColors
import androidx.compose.material.ripple.rememberRipple
import androidx.compose.material3.ElevatedSuggestionChip
import androidx.compose.material3.Icon
import androidx.compose.material3.LocalTextStyle
Expand Down Expand Up @@ -222,7 +221,7 @@ fun CopyAbleRippleText(
onLongClick = onLongClick
)
)
if (isDialogShown) {
if (isDialogShown && onDoubleClick != null) {
Dialog(
onDismissRequest = onDismissDialog,
content = {
Expand All @@ -240,7 +239,7 @@ fun CopyAbleRippleText(
items(words) { item ->
val onItemClick = remember(onDoubleClick, item) {
{
onDoubleClick?.invoke(item)
onDoubleClick(item)
isDialogShown = false
}
}
Expand Down
Empty file removed datastore/consumer-rules.pro
Empty file.
1 change: 1 addition & 0 deletions fastlane/metadata/android/en-US/changelogs/44.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Added Overlay/Floating Window feature
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
Empty file removed feature_history/consumer-rules.pro
Empty file.
15 changes: 1 addition & 14 deletions feature_home/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ plugins {
alias(libs.plugins.jetbrains.kotlin.android)
alias(libs.plugins.google.ksp)
alias(libs.plugins.jetbrains.compose.plugin)
id("org.jetbrains.kotlin.kapt")
alias(libs.plugins.hilt)
}

Expand All @@ -13,7 +12,6 @@ android {

defaultConfig {
minSdk = 21
ksp.arg("room.schemaLocation", "$projectDir/schemas")
}

compileOptions {
Expand All @@ -31,6 +29,7 @@ dependencies {
implementation(project(":common"))
implementation(project(":strings"))
implementation(project(":datastore"))
implementation(project(":search"))
//core android/kotlin
coreLibraryDesugaring(libs.desugar.jdk.libs)
implementation(libs.androidx.core.ktx)
Expand All @@ -50,16 +49,4 @@ dependencies {
implementation(libs.hilt.android)
ksp(libs.hilt.android.compiler)
implementation(libs.androidx.hilt.navigation.compose)
//room
implementation(libs.androidx.room.runtime)
annotationProcessor(libs.androidx.room.compiler)
ksp(libs.androidx.room.compiler)
api(libs.androidx.room.ktx)
//retrofit
api(libs.retrofit.main)
implementation(libs.retrofit.converter.moshi)
kapt(libs.retrofit.type.keeper)
//moshi
implementation(libs.moshi.kotlin)
ksp(libs.moshi.kotlin.codegen)
}
Empty file removed feature_home/consumer-rules.pro
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ package io.github.yamin8000.owl.feature_home.data.repository
import android.app.Application
import android.content.res.Resources.NotFoundException
import io.github.yamin8000.owl.feature_home.R
import io.github.yamin8000.owl.feature_home.data.datasource.local.dao.DAOs
import io.github.yamin8000.owl.search.data.datasource.local.dao.DAOs
import io.github.yamin8000.owl.feature_home.domain.repository.TermSuggesterRepository
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
Expand All @@ -37,8 +37,8 @@ class TermSuggesterRepositoryImpl(
private val dao: DAOs.TermDao,
private val app: Application
) : TermSuggesterRepository {
val DEFAULT_N_GRAM_SIZE = 3
val NOT_WORD_CHARS_REGEX = Regex("\\W+")
private val DEFAULT_N_GRAM_SIZE = 3
private val NOT_WORD_CHARS_REGEX = Regex("\\W+")

override suspend fun suggestTerms(searchTerm: String): List<String> {
items = items.plus(getOldSearchData())
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* freeDictionaryApp/freeDictionaryApp.feature_home.main
* HomeModule.kt Copyrighted by Yamin Siahmargooei at 2024/9/5
* HomeModule.kt Last modified at 2024/9/5
* This file is part of freeDictionaryApp/freeDictionaryApp.feature_home.main.
* Copyright (C) 2024 Yamin Siahmargooei
*
* freeDictionaryApp/freeDictionaryApp.feature_home.main is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* freeDictionaryApp/freeDictionaryApp.feature_home.main is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with freeDictionaryApp. If not, see <https://www.gnu.org/licenses/>.
*/

package io.github.yamin8000.owl.feature_home.di

import android.app.Application
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import io.github.yamin8000.owl.feature_home.data.repository.TermSuggesterRepositoryImpl
import io.github.yamin8000.owl.feature_home.domain.repository.TermSuggesterRepository
import io.github.yamin8000.owl.search.data.datasource.local.AppDatabase
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
object HomeModule {

@Provides
@Singleton
fun providesTermSuggesterRepository(
db: AppDatabase,
app: Application
): TermSuggesterRepository = TermSuggesterRepositoryImpl(db.termDao(), app)
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,43 +25,14 @@ import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import io.github.yamin8000.owl.feature_home.data.datasource.local.entity.TermEntity
import io.github.yamin8000.owl.feature_home.data.repository.local.BaseRoomRepository
import io.github.yamin8000.owl.feature_home.domain.repository.local.DefinitionRepository
import io.github.yamin8000.owl.feature_home.domain.repository.local.EntryRepository
import io.github.yamin8000.owl.feature_home.domain.repository.local.MeaningRepository
import io.github.yamin8000.owl.feature_home.domain.repository.local.PhoneticRepository
import io.github.yamin8000.owl.feature_home.domain.repository.local.TermRepository
import io.github.yamin8000.owl.feature_home.domain.usecase.CacheWord
import io.github.yamin8000.owl.feature_home.domain.usecase.CacheWordData
import io.github.yamin8000.owl.feature_home.domain.usecase.GetCachedWord
import io.github.yamin8000.owl.feature_home.domain.usecase.GetRandomWord
import io.github.yamin8000.owl.feature_home.domain.usecase.WordCacheUseCases
import io.github.yamin8000.owl.search.domain.repository.local.TermRepository
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
object HomeUseCases {

@Provides
@Singleton
fun providesWordCacheUseCases(
entryRepository: EntryRepository,
phoneticRepository: PhoneticRepository,
meaningRepository: MeaningRepository,
definitionRepository: DefinitionRepository,
termRepository: TermRepository
) = WordCacheUseCases(
getCachedWord = GetCachedWord(entryRepository),
cacheWord = CacheWord(
entryRepository = entryRepository,
meaningRepository = meaningRepository,
definitionRepository = definitionRepository,
phoneticRepository = phoneticRepository
),
cacheWordData = CacheWordData(termRepository)
)

@Provides
@Singleton
fun providesRandomWordUseCase(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

package io.github.yamin8000.owl.feature_home.domain.usecase

import io.github.yamin8000.owl.feature_home.domain.repository.local.TermRepository
import io.github.yamin8000.owl.search.domain.repository.local.TermRepository

class GetRandomWord(
private val repository: TermRepository
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ import androidx.compose.material3.SnackbarHost
import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.Immutable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.remember
Expand All @@ -66,13 +65,13 @@ import io.github.yamin8000.owl.common.ui.components.LockScreenOrientation
import io.github.yamin8000.owl.common.ui.components.MySnackbar
import io.github.yamin8000.owl.common.ui.components.PersianText
import io.github.yamin8000.owl.common.ui.util.LocalTTS
import io.github.yamin8000.owl.feature_home.domain.model.Meaning
import io.github.yamin8000.owl.feature_home.ui.components.MainBottomBar
import io.github.yamin8000.owl.feature_home.ui.components.MainTopBar
import io.github.yamin8000.owl.feature_home.ui.components.MeaningCard
import io.github.yamin8000.owl.feature_home.ui.components.SuggestionsChips
import io.github.yamin8000.owl.feature_home.ui.components.WordCard
import io.github.yamin8000.owl.feature_home.ui.util.ShareUtils.handleShareIntent
import io.github.yamin8000.owl.search.domain.model.Meaning
import io.github.yamin8000.owl.search.ui.components.MeaningCard
import io.github.yamin8000.owl.search.ui.components.WordCard
import io.github.yamin8000.owl.strings.R
import kotlinx.collections.immutable.toPersistentList
import kotlinx.coroutines.Dispatchers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
package io.github.yamin8000.owl.feature_home.ui

import androidx.compose.material3.SnackbarHostState
import io.github.yamin8000.owl.feature_home.domain.model.Entry
import io.github.yamin8000.owl.search.domain.model.Entry

data class HomeState(
val isOnline: Boolean = false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ import io.github.yamin8000.owl.datastore.domain.usecase.favourites.FavouriteUseC
import io.github.yamin8000.owl.datastore.domain.usecase.history.HistoryUseCases
import io.github.yamin8000.owl.datastore.domain.usecase.settings.SettingUseCases
import io.github.yamin8000.owl.feature_home.di.HomeViewModelFactory
import io.github.yamin8000.owl.feature_home.domain.model.Entry
import io.github.yamin8000.owl.search.domain.model.Entry
import io.github.yamin8000.owl.feature_home.domain.repository.TermSuggesterRepository
import io.github.yamin8000.owl.feature_home.domain.usecase.GetRandomWord
import io.github.yamin8000.owl.feature_home.domain.usecase.SearchFreeDictionary
import io.github.yamin8000.owl.feature_home.domain.usecase.WordCacheUseCases
import io.github.yamin8000.owl.search.domain.usecase.SearchFreeDictionary
import io.github.yamin8000.owl.search.domain.usecase.WordCacheUseCases
import kotlinx.coroutines.CoroutineExceptionHandler
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
Expand Down Expand Up @@ -122,7 +122,7 @@ class HomeViewModel @AssistedInject constructor(
init {
scope.launch {
_state.update { it.copy(isVibrating = settingsUseCases.getVibration()) }
if (!settingsUseCases.getStartingBlank()) {
if (!settingsUseCases.getStartingBlank() && searchTerm.value.isBlank()) {
savedState["Search"] = "free"
}
if (searchTerm.value.isNotBlank()) {
Expand Down
Loading

0 comments on commit 28071a6

Please sign in to comment.