Skip to content

Commit

Permalink
Add settings for script system access policy
Browse files Browse the repository at this point in the history
  • Loading branch information
levinli303 committed Feb 19, 2023
1 parent becf3a6 commit c051e5f
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 3 deletions.
17 changes: 17 additions & 0 deletions Celestia/src/main/cpp/CelestiaAppCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1084,4 +1084,21 @@ Java_space_celestia_celestia_AppCore_c_1getLanguage(JNIEnv *env, jclass clazz) {
if (strcmp(lang, "LANGUAGE") == 0)
return env->NewStringUTF("en");
return env->NewStringUTF(lang);
}

extern "C"
JNIEXPORT void JNICALL
Java_space_celestia_celestia_AppCore_c_1setScriptSystemAccessPolicy(JNIEnv *env, jclass clazz,
jlong pointer,
jint script_system_access_policy) {
auto core = (CelestiaCore *)pointer;
core->setScriptSystemAccessPolicy((CelestiaCore::ScriptSystemAccessPolicy)script_system_access_policy);
}

extern "C"
JNIEXPORT jint JNICALL
Java_space_celestia_celestia_AppCore_c_1getScriptSystemAccessPolicy(JNIEnv *env, jclass clazz,
jlong pointer) {
auto core = (CelestiaCore *)pointer;
return (jint)core->getScriptSystemAccessPolicy();
}
6 changes: 6 additions & 0 deletions Celestia/src/main/java/space/celestia/celestia/AppCore.java
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,12 @@ public double getDoubleValueForField(@NonNull String field) {
public int getTemperatureScale() { return c_getTemperatureScale(pointer); }
private static native void c_setTemperatureScale(long pointer, int temperatureScale);
private static native int c_getTemperatureScale(long pointer);

public void setScriptSystemAccessPolicy(int scriptSystemAccessPolicy) { c_setScriptSystemAccessPolicy(pointer, scriptSystemAccessPolicy); }
public int getScriptSystemAccessPolicy() { return c_getScriptSystemAccessPolicy(pointer); }
private static native void c_setScriptSystemAccessPolicy(long pointer, int scriptSystemAccessPolicy);
private static native int c_getScriptSystemAccessPolicy(long pointer);

public void setTimeZone(int timeZone) { c_setTimeZone(pointer, timeZone); }
public int getTimeZone() { return c_getTimeZone(pointer); }
private static native void c_setTimeZone(long pointer, int TimeZone);
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:installLocation="auto"
android:versionCode="328"
android:versionCode="329"
android:versionName="1.5.17">

<uses-feature android:glEsVersion="0x00020000" android:required="true" />
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/assets/defaults.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,6 @@
"ShowHorizonGrid": 0,
"ShowGalacticGrid": 0,
"MeasurementSystem": 0,
"TemperatureScale": 0
"TemperatureScale": 0,
"ScriptSystemAccessPolicy": 0
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ enum class SettingsKey(private val rawDisplayName: String) : PreferenceManager.K
HudDetail("Info Display"),
MeasurementSystem("Measure Units"),
TemperatureScale("Temperature Scale"),
ScriptSystemAccessPolicy("Script System Access Policy"),
// Double values
FaintestVisible("Faintest Stars"),
AmbientLightLevel("Ambient Light"),
Expand Down Expand Up @@ -188,6 +189,7 @@ enum class SettingsKey(private val rawDisplayName: String) : PreferenceManager.K
HudDetail,
MeasurementSystem,
TemperatureScale,
ScriptSystemAccessPolicy,
)

val allDoubleCases: List<SettingsKey>
Expand Down Expand Up @@ -490,7 +492,21 @@ private val staticRendererItems: List<SettingsItem> = listOf(
)

private val staticAdvancedItems: List<SettingsItem> = listOf(
SettingsDataLocationItem()
SettingsDataLocationItem(),
SettingsCommonItem(
CelestiaString("Security", ""),
listOf(
SettingsCommonItem.Section(
listOf(
SettingsKeyedSelectionItem(SettingsKey.ScriptSystemAccessPolicy, CelestiaString("Ask", ""), 0),
SettingsKeyedSelectionItem(SettingsKey.ScriptSystemAccessPolicy, CelestiaString("Allow", ""), 1),
SettingsKeyedSelectionItem(SettingsKey.ScriptSystemAccessPolicy, CelestiaString("Deny", ""), 2)
),
header = CelestiaString(SettingsKey.ScriptSystemAccessPolicy.displayName, ""),
footer = CelestiaString("This policy decides whether Lua scripts have access to the files on the system or not.", "")
)
)
),
)

class SettingsRenderInfoItem : SettingsItem, Serializable {
Expand Down
16 changes: 16 additions & 0 deletions app/src/main/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
<!--
~ strings.xml
~
~ Copyright (C) 2001-2020, Celestia Development Team
~
~ This program is free software; you can redistribute it and/or
~ modify it under the terms of the GNU General Public License
~ as published by the Free Software Foundation; either version 2
~ of the License, or (at your option) any later version.
-->

<resources>
<string name="app_name">Celestia</string>
<string name="celestia_language">ru</string>
<string name="privacy_policy_alert_title">Политика конфиденциальности и Договор об оказании услуг</string>
<string name="privacy_policy_alert_detail">Пожалуйста, внимательно прочтите Политику конфиденциальности и Договор об оказании услуг.</string>
<string name="privacy_policy_alert_show_policy_button_title">Показать</string>
<string name="privacy_policy_alert_accept_button_title">Принимаю</string>
<string name="privacy_policy_alert_decline_button_title">Не сейчас</string>
</resources>

0 comments on commit c051e5f

Please sign in to comment.