Skip to content

Commit

Permalink
Added translations and per app language
Browse files Browse the repository at this point in the history
Took 1 hour 49 minutes
  • Loading branch information
JulesPvx committed May 31, 2024
1 parent d2fd457 commit 8818f67
Show file tree
Hide file tree
Showing 25 changed files with 1,696 additions and 248 deletions.
25 changes: 23 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/*
*
* * Copyright (c) 2024 Angel Studio
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * http://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*/

import com.google.firebase.crashlytics.buildtools.gradle.CrashlyticsExtension

plugins {
Expand All @@ -23,8 +41,8 @@ android {
applicationId = "fr.angel.soundtap"
minSdk = 30
targetSdk = 34
versionCode = 35
versionName = "1.1.1"
versionCode = 38
versionName = "1.1.2"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
Expand Down Expand Up @@ -131,4 +149,7 @@ dependencies {
implementation(libs.androidx.datastore)
implementation(libs.kotlinx.collections.immutable)
implementation(libs.kotlinx.serialization.json)

implementation(libs.androidx.appcompat)
implementation(libs.androidx.appcompat.resources)
}
31 changes: 29 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?><!--
~ /*
~ * Copyright (c) 2024 Angel Studio
~ *
~ * Licensed under the Apache License, Version 2.0 (the "License");
~ * you may not use this file except in compliance with the License.
~ * You may obtain a copy of the License at
~ *
~ * http://www.apache.org/licenses/LICENSE-2.0
~ *
~ * Unless required by applicable law or agreed to in writing, software
~ * distributed under the License is distributed on an "AS IS" BASIS,
~ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ * See the License for the specific language governing permissions and
~ * limitations under the License.
~ */
-->

<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<queries>
Expand Down Expand Up @@ -26,6 +43,7 @@
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:largeHeap="true"
android:localeConfig="@xml/locales_config"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.SoundTap">
Expand All @@ -43,7 +61,7 @@
<service
android:name=".service.SoundTapAccessibilityService"
android:exported="true"
android:label="@string/accessibility_service_label"
android:label="@string/app_name"
android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE">
<intent-filter>
<action android:name="android.accessibilityservice.AccessibilityService" />
Expand Down Expand Up @@ -88,5 +106,14 @@
<action android:name="android.bluetooth.headset.profile.action.CONNECTION_STATE_CHANGED" />
</intent-filter>
</receiver>

<service
android:name="androidx.appcompat.app.AppLocalesMetadataHolderService"
android:enabled="false"
android:exported="false">
<meta-data
android:name="autoStoreLocales"
android:value="true" />
</service>
</application>
</manifest>
3 changes: 2 additions & 1 deletion app/src/main/java/fr/angel/soundtap/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.input.nestedscroll.nestedScroll
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
Expand Down Expand Up @@ -164,7 +165,7 @@ class MainActivity : ComponentActivity() {
horizontal = 16.dp,
vertical = 8.dp,
),
text = "SoundTap",
text = stringResource(id = R.string.app_name).uppercase(),
style = MaterialTheme.typography.displayMedium,
fontFamily = FontPilowlava,
fontWeight = FontWeight.ExtraBold,
Expand Down
28 changes: 23 additions & 5 deletions app/src/main/java/fr/angel/soundtap/NotificationHelper.kt
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/*
*
* * Copyright (c) 2024 Angel Studio
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * http://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*/

package fr.angel.soundtap

import android.app.NotificationChannel
Expand Down Expand Up @@ -30,7 +48,7 @@ class NotificationHelper
// id =
CHANNEL_ID_SLEEP_TIMER,
// name =
"Sleep Timer",
context.getString(R.string.app_sleep_timer),
// importance =
NotificationManager.IMPORTANCE_MIN,
)
Expand All @@ -40,8 +58,8 @@ class NotificationHelper
fun showSleepTimerNotification(millisUntilFinished: Long) {
val notification =
NotificationCompat.Builder(context, CHANNEL_ID_SLEEP_TIMER)
.setContentTitle("Sleep Timer")
.setContentText("Music will stop when the timer ends.")
.setContentTitle(context.getString(R.string.app_sleep_timer))
.setContentText(context.getString(R.string.app_sleep_timer_message))
.setSilent(true)
.setOngoing(true)
.setUsesChronometer(true)
Expand All @@ -54,14 +72,14 @@ class NotificationHelper
// icon =
R.drawable.twotone_stop_circle_24,
// title =
"Stop",
context.getString(R.string.stop),
// intent =
GlobalHelper.createStopSleepTimerIntent(context),
).addAction(
// icon =
R.drawable.twotone_more_time_24,
// title =
"Add 15 minutes",
context.getString(R.string.app_sleep_timer_add_time_15_min),
// intent =
GlobalHelper.createAddTimeSleepTimerIntent(context, 15 * 60 * 1000),
).setContentIntent(GlobalHelper.createNotificationOpenAppIntent(context))
Expand Down
34 changes: 19 additions & 15 deletions app/src/main/java/fr/angel/soundtap/data/enums/AutoPlayMode.kt
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
/*
* Copyright 2024 Angel Studio
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* * Copyright (c) 2024 Angel Studio
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * http://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package fr.angel.soundtap.data.enums

import androidx.annotation.StringRes
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.foundation.layout.BoxScope
import androidx.compose.foundation.layout.Row
Expand All @@ -32,13 +35,14 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
import androidx.compose.ui.unit.dp
import fr.angel.soundtap.R

enum class AutoPlayMode(
val title: String,
@StringRes val title: Int,
val selectedComposable: @Composable BoxScope.(selected: Boolean) -> Unit,
) {
ON_HEADSET_CONNECTED(
title = "On headset connected",
title = R.string.auto_play_mode_on_headset_connected,
selectedComposable = { selected ->
val alpha by animateFloatAsState(
if (selected) 1f else 0.2f,
Expand All @@ -60,7 +64,7 @@ enum class AutoPlayMode(
},
),
ON_DOUBLE_VOLUME_LONG_PRESS(
title = "On double volume long press",
title = R.string.auto_play_mode_on_double_volume_long_press,
selectedComposable = { selected ->
val alpha by animateFloatAsState(
if (selected) 1f else 0.2f,
Expand All @@ -82,7 +86,7 @@ enum class AutoPlayMode(
},
),
BOTH(
title = "Both",
title = R.string.auto_play_mode_both,
selectedComposable = { selected ->
val alpha by animateFloatAsState(
if (selected) 1f else 0.2f,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,44 @@
/*
* Copyright 2024 Angel Studio
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* * Copyright (c) 2024 Angel Studio
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * http://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package fr.angel.soundtap.data.enums

import androidx.annotation.DrawableRes
import androidx.annotation.StringRes
import fr.angel.soundtap.R

enum class HapticFeedbackLevel(
val title: String,
@StringRes val title: Int,
@DrawableRes val icon: Int,
) {
NONE("None", R.drawable.haptic_feedback_none),
LIGHT("Light", R.drawable.haptic_feedback_light),
MEDIUM("Medium", R.drawable.haptic_feedback_medium),
STRONG("Strong", R.drawable.haptic_feedback_strong),
NONE(
R.string.haptic_feedback_none,
R.drawable.haptic_feedback_none,
),
LIGHT(
R.string.haptic_feedback_light,
R.drawable.haptic_feedback_light,
),
MEDIUM(
R.string.haptic_feedback_medium,
R.drawable.haptic_feedback_medium,
),
STRONG(
R.string.haptic_feedback_strong,
R.drawable.haptic_feedback_strong,
),
}
39 changes: 22 additions & 17 deletions app/src/main/java/fr/angel/soundtap/data/enums/WorkingMode.kt
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
/*
* Copyright 2024 Angel Studio
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* * Copyright (c) 2024 Angel Studio
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * http://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package fr.angel.soundtap.data.enums

import androidx.annotation.StringRes
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.foundation.layout.BoxScope
import androidx.compose.foundation.layout.aspectRatio
Expand All @@ -30,15 +33,17 @@ import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import fr.angel.soundtap.R

enum class WorkingMode(
val title: String,
@StringRes val title: Int,
val selectedComposable: @Composable BoxScope.(selected: Boolean) -> Unit,
) {
SCREEN_ON_OFF(
title = "Screen ON and OFF",
title = R.string.working_mode_screen_on_off,
selectedComposable = { selected ->
val alpha by animateFloatAsState(
if (selected) 1f else 0.2f,
Expand All @@ -59,7 +64,7 @@ enum class WorkingMode(
)
},
),
SCREEN_ON(title = "Screen ON", selectedComposable = { selected ->
SCREEN_ON(title = R.string.working_mode_screen_on, selectedComposable = { selected ->
val alpha by animateFloatAsState(
if (selected) 1f else 0.2f,
label = "alpha",
Expand All @@ -70,13 +75,13 @@ enum class WorkingMode(
Modifier
.padding(4.dp)
.alpha(alpha),
text = "ON",
text = stringResource(id = R.string.awake),
style = MaterialTheme.typography.labelLarge,
color = MaterialTheme.colorScheme.primary,
fontWeight = FontWeight.Black,
)
}),
SCREEN_OFF(title = "Screen OFF", selectedComposable = { selected ->
SCREEN_OFF(title = R.string.working_mode_screen_off, selectedComposable = { selected ->
val alpha by animateFloatAsState(
if (selected) 1f else 0.2f,
label = "alpha",
Expand All @@ -87,7 +92,7 @@ enum class WorkingMode(
Modifier
.padding(4.dp)
.alpha(alpha),
text = "SLEEP",
text = stringResource(id = R.string.sleep),
style = MaterialTheme.typography.labelLarge,
color = MaterialTheme.colorScheme.primary,
fontWeight = FontWeight.Black,
Expand Down
Loading

0 comments on commit 8818f67

Please sign in to comment.