Skip to content

Commit e2e771e

Browse files
committed
feat: Add language settings shortcut in settings menu
This commit introduces a new language settings shortcut in the settings menu. It adds a new icon for the language settings and adds the functionality to open the language settings when the new shortcut in the setting menu is pressed. - Added `ic_language.xml` drawable for the language settings icon. - Added a new menu item `settings_language_icon` to `settings_menu.xml`. - Added the logic in `SettingsFragment.kt` to start the language settings when the new shortcut is pressed.
1 parent 355ad86 commit e2e771e

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

app/src/main/java/com/warbler/ui/settings/SettingsFragment.kt

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
package com.warbler.ui.settings
22

33
import android.content.Intent
4+
import android.net.Uri
45
import android.os.Bundle
6+
import android.provider.Settings
57
import android.view.View
68
import androidx.browser.customtabs.CustomTabsIntent
7-
import androidx.compose.runtime.getValue
8-
import androidx.compose.runtime.setValue
99
import androidx.core.net.toUri
1010
import androidx.fragment.app.Fragment
1111
import androidx.fragment.app.viewModels
1212
import androidx.navigation.findNavController
1313
import com.google.android.material.snackbar.Snackbar
14+
import com.google.firebase.crashlytics.internal.model.CrashlyticsReport.Session.Event.Log
1415
import com.warbler.R
1516
import com.warbler.databinding.FragmentSettingsBinding
1617
import com.warbler.utilities.Constants
@@ -64,6 +65,12 @@ class SettingsFragment : Fragment(R.layout.fragment_settings) {
6465
handleShareClick(Constants.WEATHER_WARBLER_URL)
6566
true
6667
}
68+
R.id.settings_language_icon -> {
69+
val intent = Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
70+
intent.data = Uri.parse("package:" + context?.packageName)
71+
startActivity(intent)
72+
true
73+
}
6774

6875
else -> false
6976
}
@@ -174,6 +181,8 @@ class SettingsFragment : Fragment(R.layout.fragment_settings) {
174181
Snackbar
175182
.make(binding.root, "Error opening link", Snackbar.LENGTH_LONG)
176183
.show()
184+
185+
Log.builder().setContent("Error opening link: ${exception.message}").build()
177186
}
178187
}
179188

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="24dp"
3+
android:height="24dp"
4+
android:viewportWidth="960"
5+
android:viewportHeight="960"
6+
android:tint="@color/colorPrimary">
7+
<path
8+
android:fillColor="@android:color/white"
9+
android:pathData="M480,880Q398,880 325,848.5Q252,817 197.5,762.5Q143,708 111.5,635Q80,562 80,480Q80,397 111.5,324.5Q143,252 197.5,197.5Q252,143 325,111.5Q398,80 480,80Q563,80 635.5,111.5Q708,143 762.5,197.5Q817,252 848.5,324.5Q880,397 880,480Q880,562 848.5,635Q817,708 762.5,762.5Q708,817 635.5,848.5Q563,880 480,880ZM480,798Q506,762 525,723Q544,684 556,640L404,640Q416,684 435,723Q454,762 480,798ZM376,782Q358,749 344.5,713.5Q331,678 322,640L204,640Q233,690 276.5,727Q320,764 376,782ZM584,782Q640,764 683.5,727Q727,690 756,640L638,640Q629,678 615.5,713.5Q602,749 584,782ZM170,560L306,560Q303,540 301.5,520.5Q300,501 300,480Q300,459 301.5,439.5Q303,420 306,400L170,400Q165,420 162.5,439.5Q160,459 160,480Q160,501 162.5,520.5Q165,540 170,560ZM386,560L574,560Q577,540 578.5,520.5Q580,501 580,480Q580,459 578.5,439.5Q577,420 574,400L386,400Q383,420 381.5,439.5Q380,459 380,480Q380,501 381.5,520.5Q383,540 386,560ZM654,560L790,560Q795,540 797.5,520.5Q800,501 800,480Q800,459 797.5,439.5Q795,420 790,400L654,400Q657,420 658.5,439.5Q660,459 660,480Q660,501 658.5,520.5Q657,540 654,560ZM638,320L756,320Q727,270 683.5,233Q640,196 584,178Q602,211 615.5,246.5Q629,282 638,320ZM404,320L556,320Q544,276 525,237Q506,198 480,162Q454,198 435,237Q416,276 404,320ZM204,320L322,320Q331,282 344.5,246.5Q358,211 376,178Q320,196 276.5,233Q233,270 204,320Z"/>
10+
</vector>

app/src/main/res/menu/settings_menu.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22
<menu xmlns:android="http://schemas.android.com/apk/res/android"
33
xmlns:app="http://schemas.android.com/apk/res-auto">
44

5+
<item
6+
android:id="@+id/settings_language_icon"
7+
android:contentDescription="@string/share_icon"
8+
android:icon="@drawable/ic_language"
9+
android:title="@string/share_icon"
10+
android:iconTint="@color/colorPrimary"
11+
android:iconTintMode="screen"
12+
app:showAsAction="ifRoom" />
13+
514
<item
615
android:id="@+id/settings_share_icon"
716
android:contentDescription="@string/share_icon"

0 commit comments

Comments
 (0)