Skip to content

Select Language #126

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 34 commits into
base: kt-rewrite
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
70f72f0
Added some French strings
yoann256 Apr 8, 2025
5df44b1
Update some strings
yoann256 Apr 8, 2025
89ba0d3
Update strings
yoann256 Apr 8, 2025
a371487
Translated more strings
yoann256 Apr 8, 2025
5d283f5
Translated more strings
yoann256 Apr 8, 2025
137942c
Replace "'" with "\'" and translated more strings
yoann256 Apr 8, 2025
806d99c
Translated more strings
yoann256 Apr 8, 2025
195de0a
Fix spacing
yoann256 Apr 8, 2025
05a6103
Translated more strings + Fix
yoann256 Apr 8, 2025
a53ea04
Update translation (no fix)
yoann256 Apr 8, 2025
fe42483
\' Fix
yoann256 Apr 8, 2025
6dd43c5
Delete for reupload
yoann256 Apr 18, 2025
68fa680
Create directory
yoann256 Apr 18, 2025
fe82d80
Reuploaded strings.xml
yoann256 Apr 18, 2025
2c39e2f
Delete dummy file
yoann256 Apr 18, 2025
2ec5c64
Merge branch 'nethical6:kt-rewrite' into kt-rewrite
yoann256 Apr 30, 2025
00e8213
Update MainActivity layout to include test button
yoann256 Apr 30, 2025
160ad94
Create Select Language dialog
yoann256 Apr 30, 2025
f754f95
Fix SelectLang.kt
yoann256 Apr 30, 2025
938104b
Update MainActivity.kt
yoann256 May 1, 2025
0f60d20
Update MainActivity.kt
yoann256 May 1, 2025
39cf143
Fix MainActivity.kt
yoann256 May 1, 2025
8eb5c8f
Update MainActivity.kt
yoann256 May 1, 2025
4fc6a46
Update strings.xml
yoann256 May 1, 2025
ed01e15
Replaced & Updated SelectLang.kt
yoann256 May 1, 2025
86247bb
Create dialog_select_lang.xml
yoann256 May 1, 2025
d0556a4
Update SelectLang.kt
yoann256 May 1, 2025
89b5f79
Update SelectLang.kt
yoann256 May 1, 2025
be13f83
Update MainActivity.kt
yoann256 May 1, 2025
21df083
Update Constants.kt
yoann256 May 1, 2025
0ea583b
Update SelectLang.kt
yoann256 May 1, 2025
725d526
Update MainActivity.kt
yoann256 May 1, 2025
d3ae400
Update SelectLang.kt
yoann256 May 1, 2025
4be72b2
Update MainActivity.kt
yoann256 May 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion app/src/main/java/nethical/digipaws/Constants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,10 @@ class Constants {
const val GRAYSCALE_MODE_ONLY_SELECTED = 2 // apply to only selected
const val GRAYSCALE_MODE_ALL_EXCEPT_SELECTED = 3 // apply to all except selected
const val GRAYSCALE_MODE_OFF = 4 // turned off

// availabe types for the language selector
const val EN_SELECTED = 1
const val FR_SELECTED = 2
const val HELLO = 3
}
}
}
16 changes: 15 additions & 1 deletion app/src/main/java/nethical/digipaws/ui/activity/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import nethical.digipaws.R
import nethical.digipaws.databinding.ActivityMainBinding
import nethical.digipaws.databinding.DialogPermissionInfoBinding
import nethical.digipaws.databinding.DialogRemoveAntiUninstallBinding
import nethical.digipaws.databinding.DialogSelectLang
import nethical.digipaws.receivers.AdminReceiver
import nethical.digipaws.services.AppBlockerService
import nethical.digipaws.services.GeneralFeaturesService
Expand All @@ -58,6 +59,7 @@ import nethical.digipaws.ui.dialogs.TweakKeywordPack
import nethical.digipaws.ui.dialogs.TweakUsageTracker
import nethical.digipaws.ui.dialogs.TweakViewBlockerCheatHours
import nethical.digipaws.ui.dialogs.TweakViewBlockerWarning
import nethical.digipaws.ui.dialogs.SelectLang
import nethical.digipaws.ui.fragments.anti_uninstall.ChooseModeFragment
import nethical.digipaws.ui.fragments.installation.AccessibilityGuide
import nethical.digipaws.ui.fragments.installation.WelcomeFragment
Expand Down Expand Up @@ -156,6 +158,8 @@ class MainActivity : AppCompatActivity() {
startActivity(intent, options.toBundle())
}
showDonationDialog()


}

override fun onDestroy() {
Expand Down Expand Up @@ -256,6 +260,16 @@ class MainActivity : AppCompatActivity() {
}

private fun setupClickListeners() {
// click listener for select lang button
binding.langSelect.setOnClickListener {
Toast.makeText(applicationContext, "hey", Toast.LENGTH_SHORT).show()
val dialogSelectLang = DialogSelectLangBinding.inflate(layoutInflater)

val dialog = MaterialAlertDialogBuilder(this)
.setView(dialogSelectLang.root)
.show()
}

// click listeners for configuration options
binding.selectPinnedApps.setOnClickListener {
val intent = Intent(this, SelectAppsActivity::class.java)
Expand Down Expand Up @@ -1050,4 +1064,4 @@ class MainActivity : AppCompatActivity() {
)


}
}
78 changes: 78 additions & 0 deletions app/src/main/java/nethical/digipaws/ui/dialogs/SelectLang.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package nethical.digipaws.ui.dialogs

import android.annotation.SuppressLint
import android.app.Dialog
import android.content.Context
import android.content.SharedPreferences
import android.os.Bundle
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import nethical.digipaws.Constants
import nethical.digipaws.R
import nethical.digipaws.databinding.DialogSelectLangBinding
// import nethical.digipaws.services.GeneralFeaturesService
// import nethical.digipaws.utils.GrayscaleControl
import nethical.digipaws.utils.SavedPreferencesLoader

class SelectLang(
savedPreferencesLoader: SavedPreferencesLoader
) : BaseDialog(savedPreferencesLoader) {

private lateinit var trackerPreferences: SharedPreferences

@SuppressLint("ApplySharedPref")
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val dialogSelectLangBinding = DialogSelectLangBinding.inflate(layoutInflater)

// Load tracker preferences
trackerPreferences =
requireContext().getSharedPreferences("lang", Context.MODE_PRIVATE)
val getMode = trackerPreferences.getInt("language",Constants.EN_SELECTED)



when(getMode){
Constants.FR_SELECTED -> {
dialogSelectLangBinding.fr_lang.isChecked = true
}
Constants.EN_SELECTED -> {
dialogSelectLangBinding.en_lang.isChecked = true
}
Constants.HELLO -> {
dialogSelectLangBinding.hello.isChecked = true
}
}

// Build and display dialog
return MaterialAlertDialogBuilder(requireContext())
.setView(dialogSelectLangBinding.root)
.setCancelable(true)
.setPositiveButton(getString(R.string.apply)) { dialog, _ ->
when(dialogSelectLangBinding.modeType.checkedRadioButtonId){
dialogSelectLangBinding.fr_lang.id -> {
trackerPreferences.edit().putInt("language",Constants.FR_SELECTED).commit()
// val grayscaleControl = GrayscaleControl()
// grayscaleControl.enableGrayscale()
}
dialogSelectLangBinding.en_lang.id -> {
trackerPreferences.edit().putInt("language",Constants.EN_SELECTED).commit()
// val grayscaleControl = GrayscaleControl()
// grayscaleControl.disableGrayscale()
}
// dialogSelectLangBinding.blockSelected.id -> {
// trackerPreferences.edit().putInt("mode",Constants.GRAYSCALE_MODE_ONLY_SELECTED).commit()
// }
// dialogGrayscaleBinding.blockExceptSelected.id -> {
// trackerPreferences.edit().putInt("mode",Constants.GRAYSCALE_MODE_ALL_EXCEPT_SELECTED).commit()
// }

}
// Send broadcast to refresh UsageTrackingService
// sendRefreshRequest(GeneralFeaturesService.INTENT_ACTION_REFRESH_GRAYSCALE)
dialog.dismiss()
}
.setNegativeButton(getString(R.string.cancel)) { dialog, _ ->
dialog.dismiss()
}
.create()
}
}
12 changes: 10 additions & 2 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,15 @@
android:paddingBottom="32dp"
android:orientation="vertical"
tools:context=".ui.activity.MainActivity">

<!-- Test button SHOULD be replaced with a better one -->
<Button
android:id="@+id/lang_select"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="8dp"
android:text="Select Language"
android:textSize="12sp"
android:textColor="#000000" />
<com.google.android.material.card.MaterialCardView
android:id="@+id/launcher_card"
android:visibility="gone"
Expand Down Expand Up @@ -787,4 +795,4 @@
</com.google.android.material.card.MaterialCardView>

</LinearLayout>
</ScrollView>
</ScrollView>
55 changes: 55 additions & 0 deletions app/src/main/res/layout/dialog_select_lang.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="16dp">

<TextView
style="@style/TextAppearance.Material3.TitleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="8dp"
android:text="Select Language"
android:textSize="24sp"
android:textStyle="bold" />

<RadioGroup
android:id="@+id/mode_type"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="16dp">

<TextView
android:id="@+id/textView"
style="@style/TextAppearance.Material3.BodySmall"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="8dp"
android:text="Select your preference" />

<RadioButton
android:id="@+id/fr_lang"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="French language" />

<RadioButton
android:id="@+id/en_lang"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="English Language" />

<RadioButton
android:id="@+id/hello"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Hello" />

<RadioButton
android:id="@+id/world"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="world" />
</RadioGroup>
</LinearLayout>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -180,4 +180,5 @@
<string name="join_telegram">Join Telegram</string>
<string name="guide">Guide</string>
<string name="go_back">Go back</string>
<string name="apply">Apply</string>
</resources>
Loading