android: fix crashes/bugs, adjust ui a little

This commit is contained in:
Emin 2024-12-26 16:37:49 +05:00
parent fb493aceee
commit fef69f5eec
9 changed files with 72 additions and 67 deletions

View file

@ -375,44 +375,44 @@ android {
}
dependencies {
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.8.1'
implementation 'androidx.activity:activity-compose:1.9.0'
implementation platform('androidx.compose:compose-bom:2024.05.00')
implementation 'androidx.compose.ui:ui'
implementation 'androidx.compose.ui:ui-graphics'
implementation 'androidx.compose.ui:ui-tooling-preview'
implementation 'androidx.compose.material3:material3'
androidTestImplementation platform('androidx.compose:compose-bom:2024.05.00')
androidTestImplementation 'androidx.compose.ui:ui-test-junit4'
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.4'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.8.7'
implementation 'androidx.activity:activity-compose:1.9.3'
implementation platform('androidx.compose:compose-bom:2024.12.01')
implementation 'androidx.compose.ui:ui'
implementation 'androidx.compose.ui:ui-graphics'
implementation 'androidx.compose.ui:ui-tooling-preview'
implementation 'androidx.compose.material3:material3'
androidTestImplementation platform('androidx.compose:compose-bom:2024.12.01')
androidTestImplementation 'androidx.compose.ui:ui-test-junit4'
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.4'
debugImplementation 'androidx.compose.ui:ui-tooling'
debugImplementation 'androidx.compose.ui:ui-test-manifest'
debugImplementation 'androidx.compose.ui:ui-tooling'
debugImplementation 'androidx.compose.ui:ui-test-manifest'
// hilt
def hilt = '2.51.1'
implementation "com.google.dagger:hilt-android:$hilt"
kapt "com.google.dagger:hilt-compiler:$hilt"
kapt "androidx.hilt:hilt-compiler:1.2.0"
implementation 'androidx.hilt:hilt-navigation-compose:1.2.0'
// hilt
def hilt = '2.51.1'
implementation "com.google.dagger:hilt-android:$hilt"
kapt "com.google.dagger:hilt-compiler:$hilt"
kapt "androidx.hilt:hilt-compiler:1.2.0"
implementation 'androidx.hilt:hilt-navigation-compose:1.2.0'
// navigation
implementation "androidx.navigation:navigation-compose:2.8.0-beta03"
// navigation
implementation 'androidx.navigation:navigation-compose:2.8.5'
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.3"
// countries
implementation 'com.hbb20:ccp:2.7.3'
// webview
implementation "androidx.webkit:webkit:1.11.0"
// compress
implementation 'id.zelory:compressor:3.0.1'
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.3"
// countries
implementation 'com.hbb20:ccp:2.7.3'
// webview
implementation "androidx.webkit:webkit:1.11.0"
// compress
implementation 'id.zelory:compressor:3.0.1'
//Background processing
def coroutines = '1.8.1'
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines"
// Coroutine Lifecycle Scopes
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.8.2'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.8.7'
// region Network
// Retrofit
@ -423,7 +423,7 @@ dependencies {
implementation "com.squareup.okhttp3:okhttp:$okhttp"
implementation "com.squareup.okhttp3:logging-interceptor:$okhttp"
implementation 'com.google.code.gson:gson:2.11.0'
def coil_version = '2.6.0'
def coil_version = '2.7.0'
implementation("io.coil-kt:coil-compose:$coil_version")
implementation("io.coil-kt:coil-svg:$coil_version")
// endregion

View file

@ -7,7 +7,6 @@ import android.location.Location;
import android.os.Handler;
import android.os.Looper;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
@ -15,22 +14,22 @@ import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.Nullable;
import androidx.core.view.ViewCompat;
import java.util.List;
import java.util.Objects;
import app.organicmaps.MwmActivity;
import app.organicmaps.R;
import app.organicmaps.location.LocationHelper;
import app.organicmaps.routing.RoutingController;
import app.organicmaps.widget.WheelProgressView;
import app.organicmaps.util.Config;
import app.organicmaps.util.ConnectionState;
import app.organicmaps.util.StringUtils;
import app.organicmaps.util.UiUtils;
import app.organicmaps.widget.WheelProgressView;
import app.tourism.MainActivity;
import java.util.List;
import java.util.Objects;
public class OnmapDownloader implements MwmActivity.LeftAnimationTrackListener
{
private static boolean sAutodownloadLocked;
@ -90,13 +89,14 @@ public class OnmapDownloader implements MwmActivity.LeftAnimationTrackListener
private void navigationToMainActivityHandling() {
Handler handler = new Handler(Looper.getMainLooper());
Runnable delayedAction = () -> {
if(mCurrentCountry.present && !alreadyNavigating) {
alreadyNavigating = true;
mActivity.removeScreenBlock();
Intent intent = new Intent(mActivity, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(mActivity, intent, null);
alreadyNavigating = true;
if(mCurrentCountry != null) {
if(mCurrentCountry.present && !alreadyNavigating) {
alreadyNavigating = true;
mActivity.removeScreenBlock();
Intent intent = new Intent(mActivity, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(mActivity, intent, null);
}
}
};
handler.postDelayed(delayedAction, 1000);

View file

@ -30,7 +30,7 @@ interface PlacesDao {
fun getTopPlacesByCategoryId(categoryId: Long): Flow<List<PlaceEntity>>
@Query("SELECT * FROM places WHERE id = :placeId")
fun getPlaceById(placeId: Long): Flow<PlaceEntity>
fun getPlaceById(placeId: Long): Flow<PlaceEntity?>
@Query("SELECT * FROM places WHERE isFavorite = 1 AND UPPER(name) LIKE UPPER(:q)")
fun getFavoritePlacesFlow(q: String = ""): Flow<List<PlaceEntity>>

View file

@ -165,10 +165,12 @@ class PlacesRepository(
}
fun getPlaceById(id: Long): Flow<Resource<PlaceFull>> = channelFlow {
placesDao.getPlaceById(id)
.collectLatest { placeEntity ->
placesDao.getPlaceById(id).collectLatest { placeEntity ->
if(placeEntity != null)
send(Resource.Success(placeEntity.toPlaceFull()))
}
else
send(Resource.Error(message = "Не найдено"))
}
}
fun getFavorites(q: String): Flow<Resource<List<PlaceShort>>> = channelFlow {

View file

@ -123,7 +123,7 @@ fun SignInScreen(
),
keyboardOptions = KeyboardOptions(imeAction = ImeAction.Next),
)
VerticalSpace(height = 32.dp)
VerticalSpace(height = 16.dp)
PasswordEditText(
value = password,
onValueChange = { vm.setPassword(it) },
@ -131,7 +131,7 @@ fun SignInScreen(
keyboardActions = KeyboardActions(onDone = { onSignInComplete() }),
keyboardOptions = KeyboardOptions(imeAction = ImeAction.Done),
)
VerticalSpace(height = 48.dp)
VerticalSpace(height = 32.dp)
PrimaryButton(
modifier = Modifier.fillMaxWidth(),
label = stringResource(id = R.string.sign_in),

View file

@ -9,8 +9,10 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
@ -39,7 +41,6 @@ import app.tourism.ui.common.VerticalSpace
import app.tourism.ui.common.buttons.PrimaryButton
import app.tourism.ui.common.nav.BackButton
import app.tourism.ui.common.textfields.AuthEditText
import app.tourism.ui.screens.auth.navigateToMainActivity
import app.tourism.ui.theme.TextStyles
import app.tourism.ui.utils.showToast
import app.tourism.utils.openUrlInBrowser
@ -65,7 +66,7 @@ fun SignUpScreen(
ObserveAsEvents(flow = vm.uiEventsChannelFlow) { event ->
when (event) {
is UiEvent.NavigateToMainActivity -> navigateToMainActivity(context)
is UiEvent.NavigateToMainActivity -> onSignUpComplete()
is UiEvent.ShowToast -> context.showToast(event.message)
}
}
@ -80,22 +81,25 @@ fun SignUpScreen(
contentDescription = null
)
Box(Modifier.padding(Constants.SCREEN_PADDING)) {
BackButton(
modifier = Modifier.align(Alignment.TopStart),
onBackClick = onBackClick,
tint = Color.White
)
}
Column(
Modifier
.fillMaxWidth()
.verticalScroll(rememberScrollState())
.align(alignment = Alignment.TopCenter)
) {
VerticalSpace(height = 48.dp)
Box(Modifier.padding(Constants.SCREEN_PADDING)
.drawDarkContainerBehind()) {
Box(modifier = Modifier.padding(16.dp)) {
BackButton(
onBackClick = onBackClick,
tint = Color.White
)
}
VerticalSpace(height = 16.dp)
Box(
Modifier
.padding(Constants.SCREEN_PADDING)
.drawDarkContainerBehind()
) {
Column(
Modifier.padding(36.dp)
) {
@ -134,7 +138,6 @@ fun SignUpScreen(
color = Color.White,
thickness = 1.dp
)
VerticalSpace(height = 16.dp)
AuthEditText(
value = email ?: "",
onValueChange = { vm.setEmail(it) },
@ -146,7 +149,6 @@ fun SignUpScreen(
),
keyboardOptions = KeyboardOptions(imeAction = ImeAction.Next),
)
VerticalSpace(height = 16.dp)
PasswordEditText(
value = password ?: "",
onValueChange = { vm.setPassword(it) },
@ -158,7 +160,6 @@ fun SignUpScreen(
),
keyboardOptions = KeyboardOptions(imeAction = ImeAction.Next),
)
VerticalSpace(height = 16.dp)
PasswordEditText(
value = confirmPassword ?: "",
onValueChange = { vm.setConfirmPassword(it) },

View file

@ -71,7 +71,9 @@ fun MainNavigation(rootNavController: NavHostController, themeVM: ThemeViewModel
rootNavController.navigate(FullscreenImageViewer(selectedImage, imageUrls))
}
val onSearchClick: (q: String) -> Unit = { q ->
rootNavController.navigate(Search(query = q))
if (q.isNotEmpty()) {
rootNavController.navigate(Search(query = q))
}
}
val onMapClick = { navigateToMap(context) }
val onBackClick: () -> Unit = { rootNavController.navigateUp() }

View file

@ -2222,7 +2222,7 @@
<string name="passwords_not_same">Пароли не схожи</string>
<string name="wrong_email_format">Неправильный формат имейла</string>
<string name="saved">Сохранено</string>
<string name="great_success">Мне нраится😄</string>
<string name="great_success">Отзыв успешно отправлен</string>
<string name="review_deleted">Отзыв успешно удален</string>
<string name="delete_review">Удалить отзыв</string>
<string name="deletion_warning">Вы уверены что хотите удалить это?</string>

View file

@ -2270,7 +2270,7 @@
<string name="deletion_warning">Are you sure you wanna delete this?</string>
<string name="deletionPlanned">Deleting…</string>
<string name="plz_wait_dowloading">Please, wait, data being downloaded</string>
<string name="empty_list">Пусто</string>
<string name="empty_list">Empty</string>
<string name="review_will_be_published_when_online">Review will be published when you are online</string>
<string name="review_was_published">Review was successfully published</string>
<string name="failed_to_publish_review">Failed to publish review\n</string>