Skip to content

Commit

Permalink
Update web code
Browse files Browse the repository at this point in the history
  • Loading branch information
ismartcoding committed Jan 17, 2024
1 parent dedb77b commit f618629
Show file tree
Hide file tree
Showing 124 changed files with 660 additions and 639 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ android {
else -> 0
}

val vCode = 220
val vCode = 223
versionCode = vCode - singleAbiNum
versionName = "1.2.29"
versionName = "1.2.30"

ndk {
//noinspection ChromeOsAbiSupport
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ enum class DarkTheme(val value: Int) {
}

fun parse(value: Int): DarkTheme {
return DarkTheme.values().find { it.value == value } ?: UseDeviceTheme
return entries.find { it.value == value } ?: UseDeviceTheme
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ enum class PasswordType(val value: Int) {
}

fun parse(value: Int): PasswordType {
return PasswordType.values().find { it.value == value } ?: RANDOM
return entries.find { it.value == value } ?: RANDOM
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ object DeviceSortByPreference : BasePreference<Int>() {

suspend fun getValueAsync(context: Context): DeviceSortBy {
val value = getAsync(context)
return DeviceSortBy.values().find { it.ordinal == value } ?: DeviceSortBy.LAST_ACTIVE
return DeviceSortBy.entries.find { it.ordinal == value } ?: DeviceSortBy.LAST_ACTIVE
}
}

Expand All @@ -299,7 +299,7 @@ object AudioPlayModePreference : BasePreference<Int>() {

suspend fun getValueAsync(context: Context): MediaPlayMode {
val value = getAsync(context)
return MediaPlayMode.values().find { it.ordinal == value } ?: MediaPlayMode.REPEAT
return MediaPlayMode.entries.find { it.ordinal == value } ?: MediaPlayMode.REPEAT
}
}

Expand All @@ -316,7 +316,7 @@ object AudioSortByPreference : BasePreference<Int>() {

suspend fun getValueAsync(context: Context): FileSortBy {
val value = getAsync(context)
return FileSortBy.values().find { it.ordinal == value } ?: FileSortBy.DATE_DESC
return FileSortBy.entries.find { it.ordinal == value } ?: FileSortBy.DATE_DESC
}
}

Expand All @@ -333,7 +333,7 @@ object VideoSortByPreference : BasePreference<Int>() {

suspend fun getValueAsync(context: Context): FileSortBy {
val value = getAsync(context)
return FileSortBy.values().find { it.ordinal == value } ?: FileSortBy.DATE_DESC
return FileSortBy.entries.find { it.ordinal == value } ?: FileSortBy.DATE_DESC
}
}

Expand All @@ -350,7 +350,7 @@ object ImageSortByPreference : BasePreference<Int>() {

suspend fun getValueAsync(context: Context): FileSortBy {
val value = getAsync(context)
return FileSortBy.values().find { it.ordinal == value } ?: FileSortBy.DATE_DESC
return FileSortBy.entries.find { it.ordinal == value } ?: FileSortBy.DATE_DESC
}
}

Expand All @@ -367,7 +367,7 @@ object FileSortByPreference : BasePreference<Int>() {

suspend fun getValueAsync(context: Context): FileSortBy {
val value = getAsync(context)
return FileSortBy.values().find { it.ordinal == value } ?: FileSortBy.NAME_ASC
return FileSortBy.entries.find { it.ordinal == value } ?: FileSortBy.NAME_ASC
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ fun ColorAndStylePage(navController: NavHostController) {
)
PListItem(
title = stringResource(R.string.dark_theme),
desc = DarkTheme.values().find { it.value == darkTheme }?.getText(context) ?: "",
desc = DarkTheme.entries.find { it.value == darkTheme }?.getText(context) ?: "",
separatedActions = true,
onClick = {
navController.navigate(RouteName.DARK_THEME)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ fun DarkThemePage(navController: NavHostController) {
VerticalSpace(dp = 16.dp)
}
item {
DarkTheme.values().map {
DarkTheme.entries.map {
PListItem(
title = it.getText(context),
onClick = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ fun PasswordPage(navController: NavHostController) {
}
},
itemRadioGroups =
PasswordType.values().map {
PasswordType.entries.map {
BlockRadioGroupButtonItem(
text = it.getText(),
onClick = {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ fun WebSettingsPage(
val context = LocalContext.current
val webConsole = LocalWeb.current
val scope = rememberCoroutineScope()
var isHttps by remember { mutableStateOf(true) }
var isHttps by remember { mutableStateOf(false) }
val httpsPort = LocalHttpsPort.current
val httpPort = LocalHttpPort.current
val passwordType = LocalPasswordType.current
Expand Down Expand Up @@ -254,16 +254,16 @@ fun WebSettingsPage(
}
item {
BlockRadioButton(
selected = if (isHttps) 0 else 1,
onSelected = { isHttps = it == 0 },
selected = if (isHttps) 1 else 0,
onSelected = { isHttps = it == 1 },
itemRadioGroups =
listOf(
BlockRadioGroupButtonItem(
text = stringResource(R.string.recommended_https),
text = "HTTP",
onClick = {},
) {},
BlockRadioGroupButtonItem(
text = "HTTP",
text = stringResource(R.string.advanced_https),
onClick = {},
) {},
),
Expand Down
8 changes: 4 additions & 4 deletions app/src/main/java/com/ismartcoding/plain/ui/views/ChipItem.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,31 +25,31 @@ data class ChipItem(val text: String, val value: String) {
companion object {
fun getRuleActions(): List<ChipItem> {
val items = mutableListOf<ChipItem>()
RuleAction.values().forEach {
RuleAction.entries.forEach {
items.add(ChipItem(it.getText(), it.value))
}
return items
}

fun getRuleDirections(): List<ChipItem> {
val items = mutableListOf<ChipItem>()
RuleDirection.values().forEach {
RuleDirection.entries.forEach {
items.add(ChipItem(it.getText(), it.value))
}
return items
}

fun getPasswordTypes(): List<ChipItem> {
val items = mutableListOf<ChipItem>()
PasswordType.values().forEach {
PasswordType.entries.forEach {
items.add(ChipItem(it.getText(), it.name))
}
return items
}

fun getRuleTargetTypes(): List<ChipItem> {
val items = mutableListOf<ChipItem>()
TargetType.values().forEach {
TargetType.entries.forEach {
items.add(ChipItem(it.getText(), it.value))
}
return items
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class LoadingButtonView(context: Context, attrs: AttributeSet?) : LinearLayout(c
val a = context.obtainStyledAttributes(attrs, R.styleable.LoadingButtonView)
normalText = a.getString(R.styleable.LoadingButtonView_text) ?: ""
loadingText = a.getString(R.styleable.LoadingButtonView_loadingText) ?: ""
buttonType = ButtonType.values()[a.getInt(R.styleable.LoadingButtonView_buttonType, 0)]
buttonType = ButtonType.entries.toTypedArray()[a.getInt(R.styleable.LoadingButtonView_buttonType, 0)]

a.recycle()
binding.text.text = normalText
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/java/com/ismartcoding/plain/web/SXGraphQL.kt
Original file line number Diff line number Diff line change
Expand Up @@ -624,13 +624,15 @@ class SXGraphQL(val schema: Schema) {
App(
usbConnected = PlugInControlReceiver.isUSBConnected(context),
urlToken = TempData.urlToken,
httpPort = TempData.httpPort,
httpsPort = TempData.httpsPort,
externalFilesDir = context.getExternalFilesDir(null)?.path ?: "",
if (TempData.demoMode) "Demo phone" else PhoneHelper.getDeviceName(context),
PhoneHelper.getBatteryPercentage(context),
BuildConfig.VERSION_CODE,
android.os.Build.VERSION.SDK_INT,
BuildConfig.CHANNEL,
Permission.values().filter { apiPermissions.contains(it.name) && it.can(MainApp.instance) },
Permission.entries.filter { apiPermissions.contains(it.name) && it.can(MainApp.instance) },
AudioPlaylistPreference.getValueAsync(context).map { it.toModel() },
AudioPlayModePreference.getValueAsync(context),
AudioPlayingPreference.getValueAsync(context)?.path ?: "",
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/com/ismartcoding/plain/web/models/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import com.ismartcoding.plain.features.audio.MediaPlayMode
data class App(
val usbConnected: Boolean,
val urlToken: String,
val httpPort: Int,
val httpsPort: Int,
val externalFilesDir: String,
val deviceName: String,
val battery: Int,
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-bn/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<string name="app_name">প্লেনঅ্যাপ</string>
<string name="vpn_web_conflict_warning">আপনার ডিভাইসে সক্রিয় ভিপিএন আছে, যা একটি পিসি থেকে অ্যাক্সেস করার সময় ওয়েব সংযোগের সমস্যা উত্পন্ন করতে পারে। এটি সমাধান করতে, আমরা আপনাকে আপনার ভিপিএন সেটিংস পরিবর্তন করে এলএএন ট্র্যাফিক অনুমতি দেওয়া বা আপনার ভিপিএন নিষ্ক্রিয় করতে প্রস্তাবনা দিচ্ছি।</string>
<string name="warning">সতর্কবার্তা</string>
<string name="advanced_https">এইচটিপিএস (উন্নত)</string>
<string name="version_name_with_code">সংস্করণ {{version_name}} ({{version_code}})</string>
<string name="optimized_batter_usage_warning">অপটিমাইজড ব্যাটারি ব্যবহার সক্রিয় আছে। অবিরত কাজের জন্য, এই অ্যাপ এর জন্য ব্যাটারি অপটিমাইজেশন অক্ষম করতে বিবেচনা করুন।</string>
<string name="apps">অ্যাপস</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<string name="app_name">EinfacheApp</string>
<string name="vpn_web_conflict_warning">Ihr VPN ist derzeit auf Ihrem Gerät aktiviert, was potenziell zu Webverbindungsproblemen führen kann, wenn es von Ihrem PC aus zugegriffen wird. Um dies zu lösen, empfehlen wir Ihnen, Ihre VPN-Einstellungen anzupassen, um LAN-Verkehr zuzulassen oder Ihr VPN zu deaktivieren.</string>
<string name="warning">Warnung</string>
<string name="advanced_https">HTTPS (Fortgeschritten)</string>
<string name="version_name_with_code">Version {{version_name}} ({{version_code}})</string>
<string name="optimized_batter_usage_warning">Optimierte Batterienutzung ist derzeit aktiv. Um eine unterbrechungsfreie Leistung zu gewährleisten, erwägen Sie bitte, die Batterieoptimierung speziell für diese App zu deaktivieren.</string>
<string name="apps">Apps</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<string name="app_name">PlainApp</string>
<string name="vpn_web_conflict_warning">Su VPN está actualmente habilitado en su dispositivo, lo que podría provocar problemas de conexión web cuando se accede desde su PC. Para resolver esto, le recomendamos ajustar la configuración de su VPN para permitir el tráfico de LAN o desactivar su VPN.</string>
<string name="warning">Advertencia</string>
<string name="advanced_https">HTTPS (Avanzado)</string>
<string name="version_name_with_code">Versión {{version_name}} ({{version_code}})</string>
<string name="optimized_batter_usage_warning">La optimización de la batería está actualmente activa. Para garantizar un rendimiento ininterrumpido, considere desactivar la optimización de la batería específicamente para esta aplicación.</string>
<string name="apps">Aplicaciones</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<string name="app_name">PlainApp</string>
<string name="vpn_web_conflict_warning">Votre VPN est actuellement activé sur votre appareil, ce qui pourrait potentiellement entraîner des problèmes de connexion Web lorsqu\'il est accédé depuis un PC. Pour résoudre cela, nous vous recommandons d\'ajuster les paramètres de votre VPN pour autoriser le trafic LAN ou de désactiver votre VPN.</string>
<string name="warning">Avertissement</string>
<string name="advanced_https">HTTPS (Avancé)</string>
<string name="version_name_with_code">Version {{version_name}} ({{version_code}})</string>
<string name="optimized_batter_usage_warning">L\'optimisation de l\'utilisation de la batterie est actuellement active. Pour garantir des performances ininterrompues, veuillez envisager de désactiver l\'optimisation de la batterie spécifiquement pour cette application.</string>
<string name="apps">Applications</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-hi/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<string name="app_name">प्लेन ऐप</string>
<string name="vpn_web_conflict_warning">आपके डिवाइस पर वर्तमान में आपका VPN सक्रिय है, जिससे PC से एक्सेस करते समay वेब कनेक्शन समस्याएँ उत्पन्न हो सकती हैं। इसे हल करने के लिए, हम सुझाव देते हैं कि आप अपने VPN सेटिंग्स को LAN ट्रैफ़िक की अनुमति देने या अपने VPN को अक्षम करने के लिए समायोजित करें।</string>
<string name="warning">चेतावनी</string>
<string name="advanced_https">एचटीटपीएस (उन्नत)</string>
<string name="version_name_with_code">संस्करण {{version_name}} ({{version_code}})</string>
<string name="optimized_batter_usage_warning">अद्यतित बैटरी उपयोग सतर्कता वर्तमान में सक्रिय है। अविघातित प्रदर्शन सुनिश्चित करने के लिए, कृपया इस एप्लिकेशन के लिए विशेष रूप से बैटरी अनुकूलन को अक्षम करने का विचार करें।</string>
<string name="apps">ऐप्स</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-it/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<string name="app_name">PlainApp</string>
<string name="vpn_web_conflict_warning">Attualmente, il tuo VPN è attivo sul tuo dispositivo, il che potrebbe portare a problemi di connessione web quando si accede da un PC. Per risolvere questo problema, ti consigliamo di regolare le impostazioni del tuo VPN per consentire il traffico LAN o disattivare il tuo VPN.</string>
<string name="warning">Attenzione</string>
<string name="advanced_https">HTTPS (Avanzato)</string>
<string name="version_name_with_code">Versione {{version_name}} ({{version_code}})</string>
<string name="optimized_batter_usage_warning">L\'ottimizzazione dell\'uso della batteria è attualmente attiva. Per garantire prestazioni ininterrotte, considera di disabilitare l\'ottimizzazione della batteria specificamente per questa app.</string>
<string name="apps">App</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-ja/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<string name="app_name">PlainApp</string>
<string name="vpn_web_conflict_warning">お使いのデバイスでは現在VPNが有効になっており、PCからアクセスした際にWeb接続の問題が発生する可能性があります。これを解決するために、LANトラフィックを許可するようにVPNの設定を調整するか、VPNを無効にすることをお勧めします。</string>
<string name="warning">警告</string>
<string name="advanced_https">HTTPS(高度)</string>
<string name="version_name_with_code">バージョン {{version_name}} ({{version_code}})</string>
<string name="optimized_batter_usage_warning">最適化されたバッテリー使用が現在有効です。中断のないパフォーマンスを確保するために、このアプリケーションのために特にバッテリーオプティマイゼーションを無効にすることを検討してください。</string>
<string name="apps">アプリ</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-ko/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<string name="app_name">PlainApp</string>
<string name="vpn_web_conflict_warning">현재 기기에서 VPN이 활성화되어 있어 PC에서 액세스할 때 웹 연결 문제가 발생할 수 있습니다. 이를 해결하기 위해 LAN 트래픽을 허용하거나 VPN을 비활성화하는 것을 권장합니다.</string>
<string name="warning">경고</string>
<string name="advanced_https">HTTPS (고급)</string>
<string name="version_name_with_code">버전 {{version_name}} ({{version_code}})</string>
<string name="optimized_batter_usage_warning">최적화된 배터리 사용이 현재 활성화되어 있습니다. 중단없는 성능을 보장하기 위해 이 앱에 대한 배터리 최적화를 비활성화하는 것을 고려해보십시오.</string>
<string name="apps">앱</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-nl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<string name="app_name">PlainApp</string>
<string name="vpn_web_conflict_warning">Uw VPN is momenteel ingeschakeld op uw apparaat, wat mogelijk kan leiden tot webverbinding problemen bij toegang vanaf uw pc. Om dit op te lossen, raden we aan om uw VPN-instellingen aan te passen om LAN-verkeer toe te staan of uw VPN uit te schakelen.</string>
<string name="warning">Waarschuwing</string>
<string name="advanced_https">HTTPS (Geavanceerd)</string>
<string name="version_name_with_code">Versie {{version_name}} ({{version_code}})</string>
<string name="optimized_batter_usage_warning">Geoptimaliseerd batterijgebruik is momenteel actief. Om ononderbroken prestaties te garanderen, overweeg batterijoptimalisatie specifiek voor deze app uit te schakelen.</string>
<string name="apps">Apps</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-pt/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<string name="app_name">PlainApp</string>
<string name="vpn_web_conflict_warning">O seu VPN está atualmente ativado no seu dispositivo, o que pode potencialmente levar a problemas de conexão web quando acessado a partir do PC. Para resolver isso, recomendamos ajustar as configurações do seu VPN para permitir o tráfego de LAN ou desativar o seu VPN.</string>
<string name="warning">Aviso</string>
<string name="advanced_https">HTTPS (Avançado)</string>
<string name="version_name_with_code">Versão {{version_name}} ({{version_code}})</string>
<string name="optimized_batter_usage_warning">A otimização do uso da bateria está atualmente ativa. Para garantir um desempenho ininterrupto, considere desativar a otimização da bateria especificamente para este aplicativo.</string>
<string name="apps">Aplicativos</string>
Expand Down
Loading

0 comments on commit f618629

Please sign in to comment.