Skip to content

Commit

Permalink
v0.1.8 - intents transition fix, search field fix
Browse files Browse the repository at this point in the history
  • Loading branch information
dadencukillia committed Nov 16, 2024
1 parent 49ae486 commit d905111
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 17 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ android {
applicationId = "com.crocoby.animeplayerua"
minSdk = 28
targetSdk = 34
versionCode = 7
versionName = "0.1.7"
versionCode = 8
versionName = "0.1.8"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
Expand Down
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
android:label="@string/app_name"
android:configChanges="orientation|keyboardHidden|screenSize"
android:theme="@style/Theme.AnimePlayerUA">

<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
6 changes: 6 additions & 0 deletions app/src/main/java/com/crocoby/animeplayerua/Models.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.crocoby.animeplayerua

import android.content.Intent
import android.os.Parcel
import android.os.Parcelable
import androidx.compose.ui.graphics.vector.ImageVector
Expand Down Expand Up @@ -100,4 +101,9 @@ data class AnimeDBEntity(
slug, name, imageUrl
)
}
}

fun Intent.noAnimation(): Intent {
addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION)
return this
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import com.crocoby.animeplayerua.logic.CustomActivity
import com.crocoby.animeplayerua.logic.LatestAppVersionAndDownloadUrl
import com.crocoby.animeplayerua.logic.parser
import com.crocoby.animeplayerua.logic.runParser
import com.crocoby.animeplayerua.noAnimation
import com.crocoby.animeplayerua.widgets.AnimeCategory
import com.crocoby.animeplayerua.widgets.AnimeCategoryLoading
import com.crocoby.animeplayerua.widgets.ApplicationScaffold
Expand Down Expand Up @@ -95,7 +96,8 @@ class HomeActivity : CustomActivity() {
HorizontalPadding {
SearchField {
if (it.isNotEmpty()) {
startActivity(SearchActivity.createIntent(this@HomeActivity, it))
startActivity(SearchActivity.createIntent(this@HomeActivity, it).noAnimation())
overridePendingTransition(0, 0)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,9 @@ class PlaylistsActivity: CustomActivity() {
}
}
}

override fun onPause() {
super.onPause()
overridePendingTransition(0,0)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import androidx.compose.ui.unit.dp
import com.crocoby.animeplayerua.AnimeItem
import com.crocoby.animeplayerua.logic.CustomActivity
import com.crocoby.animeplayerua.logic.runParser
import com.crocoby.animeplayerua.noAnimation
import com.crocoby.animeplayerua.widgets.AnimeCategory
import com.crocoby.animeplayerua.widgets.AnimeCategoryLoading
import com.crocoby.animeplayerua.widgets.ApplicationScaffold
Expand Down Expand Up @@ -58,7 +59,7 @@ class SearchActivity: CustomActivity() {
HorizontalPadding {
SearchField(searchQuery) {
if (it.isNotEmpty() && searchQuery != it) {
startActivity(createIntent(this@SearchActivity, it))
startActivity(createIntent(this@SearchActivity, it).noAnimation())
finish()
}
}
Expand All @@ -76,4 +77,9 @@ class SearchActivity: CustomActivity() {
}
}
}

override fun onPause() {
super.onPause()
overridePendingTransition(0,0)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import com.crocoby.animeplayerua.activities.HomeActivity
import com.crocoby.animeplayerua.activities.PlaylistsActivity
import com.crocoby.animeplayerua.activities.SearchActivity
import com.crocoby.animeplayerua.logic.CustomActivity
import com.crocoby.animeplayerua.noAnimation

@Composable
fun CustomActivity.ApplicationScaffold(activity: Class<out CustomActivity>, content: @Composable () -> Unit) {
Expand Down Expand Up @@ -85,8 +86,7 @@ fun CustomActivity.ApplicationScaffold(activity: Class<out CustomActivity>, cont
finish()
} else {
if (item.activities[0] != HomeActivity::class.java) {
val newIntent = Intent(this@ApplicationScaffold, item.activities[0])
startActivity(newIntent)
startActivity(Intent(this@ApplicationScaffold, item.activities[0]).noAnimation())
}
if (this@ApplicationScaffold::class.java != HomeActivity::class.java && this@ApplicationScaffold::class.java != SearchActivity::class.java) {
finish()
Expand Down
24 changes: 15 additions & 9 deletions app/src/main/java/com/crocoby/animeplayerua/widgets/SearchField.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,25 @@ fun SearchField(
query: String = "",
onSubmit: (String) -> Unit
) {
var searchQuery by remember { mutableStateOf(query) }
var textFieldValueState by remember {
mutableStateOf(
TextFieldValue(
text = query,
selection = TextRange(query.length)
)
)
}

BasicTextField(
modifier = Modifier
.fillMaxWidth()
.height(48.dp),
value = TextFieldValue(
searchQuery,
selection = TextRange(searchQuery.length)
),
value = textFieldValueState,
onValueChange = {
val text = it.text
searchQuery = text.substring(0, min(text.length, 32))
val text = it.text.substring(0, min(it.text.length, 32))
textFieldValueState = TextFieldValue(
text, it.selection, it.composition
)
},
singleLine = true,
textStyle = TextStyle(
Expand All @@ -61,13 +67,13 @@ fun SearchField(
keyboardOptions = KeyboardOptions(imeAction = ImeAction.Search),
keyboardActions = KeyboardActions(
onSearch = {
onSubmit(searchQuery)
onSubmit(textFieldValueState.text)
}
),
cursorBrush = SolidColor(Color.White)
) {
TextFieldDefaults.DecorationBox(
value = searchQuery,
value = textFieldValueState.text,
leadingIcon = {
Icon(
modifier = Modifier.height(16.dp),
Expand Down
4 changes: 2 additions & 2 deletions releaseVersion
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
0.1.7
https://github.com/dadencukillia/animeplayerua/releases/tag/v0.1.7
0.1.8
https://github.com/dadencukillia/animeplayerua/releases/tag/v0.1.8

0 comments on commit d905111

Please sign in to comment.