OpenGL Check
Invert Disable Setting
This commit is contained in:
sergosm 2020-10-08 16:12:07 +03:00
parent ba5b407cea
commit 73e42e9557
3 changed files with 33 additions and 19 deletions

View file

@ -1,13 +1,15 @@
package net.osmand.plus;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import net.osmand.plus.inapp.InAppPurchaseHelper;
import java.io.File;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
public class Version {
private final String appVersion;
@ -149,4 +151,21 @@ public class Version {
return v;
}
public static boolean isOpenGlAvailable(OsmandApplication app) {
if ("qnx".equals(System.getProperty("os.name"))) {
return false;
}
File nativeLibraryDir = new File(app.getApplicationInfo().nativeLibraryDir);
if (nativeLibraryDir.exists() && nativeLibraryDir.canRead()) {
File[] files = nativeLibraryDir.listFiles();
if (files != null) {
for (File file : files) {
if ("libOsmAndCoreWithJNI.so".equals(file.getName())) {
return true;
}
}
}
}
return false;
}
}

View file

@ -14,12 +14,11 @@ import android.preference.PreferenceScreen;
import net.osmand.plus.OsmAndLocationSimulation;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.Version;
import net.osmand.plus.activities.SettingsBaseActivity;
import net.osmand.plus.render.NativeOsmandLibrary;
import net.osmand.plus.views.corenative.NativeCoreContext;
import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.util.SunriseSunset;
import java.text.SimpleDateFormat;
@ -38,9 +37,9 @@ public class SettingsDevelopmentActivity extends SettingsBaseActivity {
PreferenceScreen category = getPreferenceScreen();
Preference pref;
if (app.getSettings().USE_OPENGL_RENDER.get() && NativeCoreContext.isInit()) {
CheckBoxPreference useOpenglRender = createCheckBoxPreference(settings.USE_OPENGL_RENDER, R.string.use_opengl_render, R.string.use_opengl_render_descr);
category.addPreference(useOpenglRender);
if (Version.isOpenGlAvailable(app)) {
category.addPreference(createCheckBoxPreference(settings.USE_OPENGL_RENDER,
R.string.use_opengl_render, R.string.use_opengl_render_descr));
}
if (!Version.isBlackberry(app)) {
@ -113,10 +112,6 @@ public class SettingsDevelopmentActivity extends SettingsBaseActivity {
R.string.show_free_version_banner,
R.string.show_free_version_banner_description));
pref = new Preference(this);
pref.setTitle(R.string.test_voice_prompts);
pref.setSummary(R.string.play_commands_of_currently_selected_voice);

View file

@ -168,16 +168,14 @@ public class RouteParametersFragment extends BaseSettingsFragment implements OnP
}
private void setupNativePublicTransport() {
if (!Version.isBlackberry(app)) {
SwitchPreferenceEx setupNativePublicTransport = createSwitchPreferenceEx(settings.PT_SAFE_MODE.getId(),
R.string.use_native_pt, R.layout.preference_with_descr_dialog_and_switch);
if (!Version.isBlackberry(app)) {
setupNativePublicTransport.setDescription(getString(R.string.use_native_pt_desc));
setupNativePublicTransport.setSummaryOn(R.string.shared_string_enabled);
setupNativePublicTransport.setSummaryOff(R.string.shared_string_disabled);
setupNativePublicTransport.setIconSpaceReserved(true);
getPreferenceScreen().addPreference(setupNativePublicTransport);
} else {
setupNativePublicTransport.setVisible(false);
}
}
@ -192,12 +190,14 @@ public class RouteParametersFragment extends BaseSettingsFragment implements OnP
}
private void setupDisableComplexRoutingPref() {
boolean enabled = !settings.DISABLE_COMPLEX_ROUTING.get(); // pref ui was inverted
SwitchPreferenceEx disableComplexRouting = createSwitchPreferenceEx(settings.DISABLE_COMPLEX_ROUTING.getId(),
R.string.use_complex_routing, R.layout.preference_with_descr_dialog_and_switch);
disableComplexRouting.setDescription(getString(R.string.disable_complex_routing_descr));
disableComplexRouting.setSummaryOn(R.string.shared_string_enabled);
disableComplexRouting.setSummaryOff(R.string.shared_string_disabled);
disableComplexRouting.setIconSpaceReserved(true);
disableComplexRouting.setChecked(enabled);
getPreferenceScreen().addPreference(disableComplexRouting);
}
@ -330,7 +330,7 @@ public class RouteParametersFragment extends BaseSettingsFragment implements OnP
setupSelectRouteRecalcDistance(screen);
setupReverseDirectionRecalculation(screen);
addDivider(screen);
setupDevelopmentcategoryHeader(screen);
setupDevelopmentCategoryHeader(screen);
if (am.isDerivedRoutingFrom(ApplicationMode.PUBLIC_TRANSPORT)) {
setupOsmLiveForPublicTransportPref();
setupNativePublicTransport();
@ -367,7 +367,7 @@ public class RouteParametersFragment extends BaseSettingsFragment implements OnP
screen.addPreference(routingCategory);
}
private void setupDevelopmentcategoryHeader (PreferenceScreen screen) {
private void setupDevelopmentCategoryHeader (PreferenceScreen screen) {
PreferenceCategory developmentCategory = new PreferenceCategory(requireContext());
developmentCategory.setLayoutResource(R.layout.preference_category_with_descr);
developmentCategory.setTitle(R.string.development);