diff --git a/catroid/src/androidTest/java/org/catrobat/catroid/test/devices/mindstorms/nxt/LegoNXTImplTest.java b/catroid/src/androidTest/java/org/catrobat/catroid/test/devices/mindstorms/nxt/LegoNXTImplTest.java index a9b4c4107fa..40236bfaed1 100644 --- a/catroid/src/androidTest/java/org/catrobat/catroid/test/devices/mindstorms/nxt/LegoNXTImplTest.java +++ b/catroid/src/androidTest/java/org/catrobat/catroid/test/devices/mindstorms/nxt/LegoNXTImplTest.java @@ -1,6 +1,6 @@ /* * Catroid: An on-device visual programming system for Android devices - * Copyright (C) 2010-2020 The Catrobat Team + * Copyright (C) 2010-2022 The Catrobat Team * () * * This program is free software: you can redistribute it and/or modify @@ -80,10 +80,10 @@ public void setUp() throws Exception { .getDefaultSharedPreferences(ApplicationProvider.getApplicationContext()); nxtSettingBuffer = sharedPreferences - .getBoolean(SettingsFragment.SETTINGS_MINDSTORMS_NXT_BRICKS_ENABLED, false); + .getBoolean(SettingsFragment.SETTINGS_MINDSTORMS_NXT_BRICKS_CHECKBOX_PREFERENCE, false); sharedPreferences.edit() - .putBoolean(SettingsFragment.SETTINGS_MINDSTORMS_NXT_BRICKS_ENABLED, true) + .putBoolean(SettingsFragment.SETTINGS_MINDSTORMS_NXT_BRICKS_CHECKBOX_PREFERENCE, true) .commit(); sensorMappingBuffer = SettingsFragment.getLegoNXTSensorMapping(ApplicationProvider.getApplicationContext()); @@ -105,7 +105,7 @@ public void tearDown() throws Exception { logger.disconnectAndDestroy(); PreferenceManager.getDefaultSharedPreferences(ApplicationProvider.getApplicationContext()).edit() - .putBoolean(SettingsFragment.SETTINGS_MINDSTORMS_NXT_BRICKS_ENABLED, nxtSettingBuffer) + .putBoolean(SettingsFragment.SETTINGS_MINDSTORMS_NXT_BRICKS_CHECKBOX_PREFERENCE, nxtSettingBuffer) .commit(); setSensorMapping(sensorMappingBuffer); } diff --git a/catroid/src/androidTest/java/org/catrobat/catroid/uiespresso/content/brick/rtl/RtlBrickTest.java b/catroid/src/androidTest/java/org/catrobat/catroid/uiespresso/content/brick/rtl/RtlBrickTest.java index 2f6088b5976..48d9ce6802f 100644 --- a/catroid/src/androidTest/java/org/catrobat/catroid/uiespresso/content/brick/rtl/RtlBrickTest.java +++ b/catroid/src/androidTest/java/org/catrobat/catroid/uiespresso/content/brick/rtl/RtlBrickTest.java @@ -1,6 +1,6 @@ /* * Catroid: An on-device visual programming system for Android devices - * Copyright (C) 2010-2021 The Catrobat Team + * Copyright (C) 2010-2022 The Catrobat Team * () * * This program is free software: you can redistribute it and/or modify @@ -213,8 +213,8 @@ import static junit.framework.Assert.assertEquals; import static junit.framework.Assert.assertTrue; -import static org.catrobat.catroid.ui.settingsfragments.SettingsFragment.SETTINGS_MINDSTORMS_EV3_BRICKS_ENABLED; -import static org.catrobat.catroid.ui.settingsfragments.SettingsFragment.SETTINGS_MINDSTORMS_NXT_BRICKS_ENABLED; +import static org.catrobat.catroid.ui.settingsfragments.SettingsFragment.SETTINGS_MINDSTORMS_EV3_BRICKS_CHECKBOX_PREFERENCE; +import static org.catrobat.catroid.ui.settingsfragments.SettingsFragment.SETTINGS_MINDSTORMS_NXT_BRICKS_CHECKBOX_PREFERENCE; import static org.catrobat.catroid.ui.settingsfragments.SettingsFragment.SETTINGS_SHOW_AI_FACE_DETECTION_SENSORS; import static org.catrobat.catroid.ui.settingsfragments.SettingsFragment.SETTINGS_SHOW_AI_POSE_DETECTION_SENSORS; import static org.catrobat.catroid.ui.settingsfragments.SettingsFragment.SETTINGS_SHOW_AI_SPEECH_RECOGNITION_SENSORS; @@ -224,7 +224,7 @@ import static org.catrobat.catroid.ui.settingsfragments.SettingsFragment.SETTINGS_SHOW_JUMPING_SUMO_BRICKS; import static org.catrobat.catroid.ui.settingsfragments.SettingsFragment.SETTINGS_SHOW_NFC_BRICKS; import static org.catrobat.catroid.ui.settingsfragments.SettingsFragment.SETTINGS_SHOW_PARROT_AR_DRONE_BRICKS; -import static org.catrobat.catroid.ui.settingsfragments.SettingsFragment.SETTINGS_SHOW_PHIRO_BRICKS; +import static org.catrobat.catroid.ui.settingsfragments.SettingsFragment.SETTINGS_SHOW_PHIRO_BRICKS_CHECKBOX_PREFERENCE; import static org.catrobat.catroid.ui.settingsfragments.SettingsFragment.SETTINGS_SHOW_RASPI_BRICKS; import static org.catrobat.catroid.uiespresso.util.matchers.rtl.RtlViewDirection.isViewRtl; import static org.hamcrest.Matchers.allOf; @@ -247,8 +247,8 @@ public class RtlBrickTest { SpriteActivity.FRAGMENT_SCRIPTS); private Locale arLocale = new Locale("ar"); - private List allPeripheralCategories = new ArrayList<>(Arrays.asList(SETTINGS_MINDSTORMS_NXT_BRICKS_ENABLED, - SETTINGS_MINDSTORMS_EV3_BRICKS_ENABLED, SETTINGS_SHOW_PARROT_AR_DRONE_BRICKS, SETTINGS_SHOW_PHIRO_BRICKS, + private List allPeripheralCategories = new ArrayList<>(Arrays.asList(SETTINGS_MINDSTORMS_NXT_BRICKS_CHECKBOX_PREFERENCE, + SETTINGS_MINDSTORMS_EV3_BRICKS_CHECKBOX_PREFERENCE, SETTINGS_SHOW_PARROT_AR_DRONE_BRICKS, SETTINGS_SHOW_PHIRO_BRICKS_CHECKBOX_PREFERENCE, SETTINGS_SHOW_ARDUINO_BRICKS, SETTINGS_SHOW_RASPI_BRICKS, SETTINGS_SHOW_NFC_BRICKS, SETTINGS_SHOW_JUMPING_SUMO_BRICKS, SETTINGS_SHOW_AI_SPEECH_RECOGNITION_SENSORS, SETTINGS_SHOW_AI_SPEECH_SYNTHETIZATION_SENSORS, diff --git a/catroid/src/androidTest/java/org/catrobat/catroid/uiespresso/formulaeditor/FormulaEditorSensorListTest.kt b/catroid/src/androidTest/java/org/catrobat/catroid/uiespresso/formulaeditor/FormulaEditorSensorListTest.kt index 4787db2e4b8..250a5add38c 100644 --- a/catroid/src/androidTest/java/org/catrobat/catroid/uiespresso/formulaeditor/FormulaEditorSensorListTest.kt +++ b/catroid/src/androidTest/java/org/catrobat/catroid/uiespresso/formulaeditor/FormulaEditorSensorListTest.kt @@ -1,6 +1,6 @@ /* * Catroid: An on-device visual programming system for Android devices - * Copyright (C) 2010-2021 The Catrobat Team + * Copyright (C) 2010-2022 The Catrobat Team * () * * This program is free software: you can redistribute it and/or modify @@ -789,10 +789,10 @@ class FormulaEditorSensorListTest( private val allShowBrickSettings: List = listOf( SettingsFragment.SETTINGS_SHOW_ARDUINO_BRICKS, - SettingsFragment.SETTINGS_SHOW_PHIRO_BRICKS, + SettingsFragment.SETTINGS_SHOW_PHIRO_BRICKS_CHECKBOX_PREFERENCE, SettingsFragment.SETTINGS_SHOW_NFC_BRICKS, - SettingsFragment.SETTINGS_MINDSTORMS_NXT_BRICKS_ENABLED, - SettingsFragment.SETTINGS_MINDSTORMS_EV3_BRICKS_ENABLED, + SettingsFragment.SETTINGS_MINDSTORMS_NXT_BRICKS_CHECKBOX_PREFERENCE, + SettingsFragment.SETTINGS_MINDSTORMS_EV3_BRICKS_CHECKBOX_PREFERENCE, SettingsFragment.SETTINGS_SHOW_PARROT_AR_DRONE_BRICKS, SettingsFragment.SETTINGS_SHOW_RASPI_BRICKS, SettingsFragment.SETTINGS_CAST_GLOBALLY_ENABLED, diff --git a/catroid/src/androidTest/java/org/catrobat/catroid/uiespresso/ui/activity/SettingsFragmentTest.java b/catroid/src/androidTest/java/org/catrobat/catroid/uiespresso/ui/activity/SettingsFragmentTest.java index 8446d994f59..6070eeea0f9 100644 --- a/catroid/src/androidTest/java/org/catrobat/catroid/uiespresso/ui/activity/SettingsFragmentTest.java +++ b/catroid/src/androidTest/java/org/catrobat/catroid/uiespresso/ui/activity/SettingsFragmentTest.java @@ -1,6 +1,6 @@ /* * Catroid: An on-device visual programming system for Android devices - * Copyright (C) 2010-2021 The Catrobat Team + * Copyright (C) 2010-2022 The Catrobat Team * () * * This program is free software: you can redistribute it and/or modify @@ -28,8 +28,10 @@ import android.content.Intent; import android.content.SharedPreferences; import android.net.Uri; +import android.os.Build; import android.preference.PreferenceManager; +import org.catrobat.catroid.BuildConfig; import org.catrobat.catroid.R; import org.catrobat.catroid.common.Constants; import org.catrobat.catroid.testsuites.annotations.Cat; @@ -64,9 +66,9 @@ import static org.catrobat.catroid.common.SharedPreferenceKeys.LANGUAGE_TAGS; import static org.catrobat.catroid.ui.settingsfragments.SettingsFragment.SETTINGS_CAST_GLOBALLY_ENABLED; import static org.catrobat.catroid.ui.settingsfragments.SettingsFragment.SETTINGS_CRASH_REPORTS; -import static org.catrobat.catroid.ui.settingsfragments.SettingsFragment.SETTINGS_MINDSTORMS_EV3_BRICKS_ENABLED; +import static org.catrobat.catroid.ui.settingsfragments.SettingsFragment.SETTINGS_MINDSTORMS_EV3_BRICKS_CHECKBOX_PREFERENCE; import static org.catrobat.catroid.ui.settingsfragments.SettingsFragment.SETTINGS_MINDSTORMS_EV3_SHOW_SENSOR_INFO_BOX_DISABLED; -import static org.catrobat.catroid.ui.settingsfragments.SettingsFragment.SETTINGS_MINDSTORMS_NXT_BRICKS_ENABLED; +import static org.catrobat.catroid.ui.settingsfragments.SettingsFragment.SETTINGS_MINDSTORMS_NXT_BRICKS_CHECKBOX_PREFERENCE; import static org.catrobat.catroid.ui.settingsfragments.SettingsFragment.SETTINGS_MINDSTORMS_NXT_SHOW_SENSOR_INFO_BOX_DISABLED; import static org.catrobat.catroid.ui.settingsfragments.SettingsFragment.SETTINGS_MULTIPLAYER_VARIABLES_ENABLED; import static org.catrobat.catroid.ui.settingsfragments.SettingsFragment.SETTINGS_SHOW_AI_FACE_DETECTION_SENSORS; @@ -75,11 +77,12 @@ import static org.catrobat.catroid.ui.settingsfragments.SettingsFragment.SETTINGS_SHOW_AI_SPEECH_SYNTHETIZATION_SENSORS; import static org.catrobat.catroid.ui.settingsfragments.SettingsFragment.SETTINGS_SHOW_AI_TEXT_RECOGNITION_SENSORS; import static org.catrobat.catroid.ui.settingsfragments.SettingsFragment.SETTINGS_SHOW_ARDUINO_BRICKS; +import static org.catrobat.catroid.ui.settingsfragments.SettingsFragment.SETTINGS_SHOW_EMBROIDERY_BRICKS_CHECKBOX_PREFERENCE; import static org.catrobat.catroid.ui.settingsfragments.SettingsFragment.SETTINGS_SHOW_HINTS; import static org.catrobat.catroid.ui.settingsfragments.SettingsFragment.SETTINGS_SHOW_JUMPING_SUMO_BRICKS; import static org.catrobat.catroid.ui.settingsfragments.SettingsFragment.SETTINGS_SHOW_NFC_BRICKS; import static org.catrobat.catroid.ui.settingsfragments.SettingsFragment.SETTINGS_SHOW_PARROT_AR_DRONE_BRICKS; -import static org.catrobat.catroid.ui.settingsfragments.SettingsFragment.SETTINGS_SHOW_PHIRO_BRICKS; +import static org.catrobat.catroid.ui.settingsfragments.SettingsFragment.SETTINGS_SHOW_PHIRO_BRICKS_CHECKBOX_PREFERENCE; import static org.catrobat.catroid.ui.settingsfragments.SettingsFragment.SETTINGS_SHOW_RASPI_BRICKS; import static org.hamcrest.Matchers.hasToString; import static org.hamcrest.Matchers.instanceOf; @@ -108,9 +111,12 @@ public class SettingsFragmentTest { BaseActivityTestRule<>(SettingsActivity.class, true, false); private List allSettings = new ArrayList<>(Arrays.asList(SETTINGS_SHOW_ARDUINO_BRICKS, - SETTINGS_SHOW_PHIRO_BRICKS, SETTINGS_SHOW_NFC_BRICKS, SETTINGS_SHOW_HINTS, SETTINGS_CRASH_REPORTS, - SETTINGS_MINDSTORMS_NXT_BRICKS_ENABLED, SETTINGS_MINDSTORMS_NXT_SHOW_SENSOR_INFO_BOX_DISABLED, - SETTINGS_MINDSTORMS_EV3_BRICKS_ENABLED, SETTINGS_MINDSTORMS_EV3_SHOW_SENSOR_INFO_BOX_DISABLED, + SETTINGS_SHOW_PHIRO_BRICKS_CHECKBOX_PREFERENCE, SETTINGS_SHOW_NFC_BRICKS, SETTINGS_SHOW_HINTS, + SETTINGS_CRASH_REPORTS, SETTINGS_MINDSTORMS_NXT_BRICKS_CHECKBOX_PREFERENCE, + SETTINGS_MINDSTORMS_NXT_SHOW_SENSOR_INFO_BOX_DISABLED, + SETTINGS_MINDSTORMS_EV3_BRICKS_CHECKBOX_PREFERENCE, + SETTINGS_MINDSTORMS_EV3_SHOW_SENSOR_INFO_BOX_DISABLED, + SETTINGS_SHOW_EMBROIDERY_BRICKS_CHECKBOX_PREFERENCE, SETTINGS_SHOW_PARROT_AR_DRONE_BRICKS, SETTINGS_SHOW_JUMPING_SUMO_BRICKS, SETTINGS_SHOW_RASPI_BRICKS, SETTINGS_MULTIPLAYER_VARIABLES_ENABLED, SETTINGS_CAST_GLOBALLY_ENABLED, SETTINGS_SHOW_AI_SPEECH_RECOGNITION_SENSORS, @@ -168,7 +174,19 @@ public void tearDown() { @Test public void basicSettingsTest() { checkPreference(R.string.preference_title_enable_arduino_bricks, SETTINGS_SHOW_ARDUINO_BRICKS); - checkPreference(R.string.preference_title_enable_phiro_bricks, SETTINGS_SHOW_PHIRO_BRICKS); + + if (BuildConfig.FLAVOR.equals(Constants.FLAVOR_PHIRO)) { + checkPreference(R.string.preference_title_enable_phiro_bricks, SETTINGS_SHOW_PHIRO_BRICKS_CHECKBOX_PREFERENCE); + } else { + openAppstoreDialog(R.string.preference_title_enable_phiro_bricks); + } + + if (BuildConfig.FLAVOR.equals(Constants.FLAVOR_EMBROIDERY_DESIGNER)) { + checkPreference(R.string.preference_title_enable_embroidery_bricks, SETTINGS_SHOW_EMBROIDERY_BRICKS_CHECKBOX_PREFERENCE); + } else { + openAppstoreDialog(R.string.preference_title_enable_embroidery_bricks); + } + checkPreference(R.string.preference_title_enable_jumpingsumo_bricks, SETTINGS_SHOW_JUMPING_SUMO_BRICKS); checkPreference(R.string.preference_title_enable_nfc_bricks, SETTINGS_SHOW_NFC_BRICKS); checkPreference(R.string.preference_title_enable_hints, SETTINGS_SHOW_HINTS); @@ -196,7 +214,12 @@ public void legoNxtSettingsTest() { onData(PreferenceMatchers.withTitle(R.string.preference_title_enable_mindstorms_nxt_bricks)) .perform(click()); - checkPreference(R.string.preference_title_enable_mindstorms_nxt_bricks, SETTINGS_MINDSTORMS_NXT_BRICKS_ENABLED); + if (BuildConfig.FLAVOR.equals(Constants.FLAVOR_LEGO_NXT_EV3)) { + checkPreference(R.string.preference_title_enable_mindstorms_nxt_bricks, SETTINGS_MINDSTORMS_NXT_BRICKS_CHECKBOX_PREFERENCE); + } else { + openAppstoreDialog(R.string.preference_title_enable_mindstorms_nxt_bricks); + } + checkPreference(R.string.preference_disable_nxt_info_dialog, SETTINGS_MINDSTORMS_NXT_SHOW_SENSOR_INFO_BOX_DISABLED); } @@ -206,7 +229,12 @@ public void legoEv3SettingsTest() { onData(PreferenceMatchers.withTitle(R.string.preference_title_enable_mindstorms_ev3_bricks)) .perform(click()); - checkPreference(R.string.preference_title_enable_mindstorms_ev3_bricks, SETTINGS_MINDSTORMS_EV3_BRICKS_ENABLED); + if (BuildConfig.FLAVOR.equals(Constants.FLAVOR_LEGO_NXT_EV3)) { + checkPreference(R.string.preference_title_enable_mindstorms_ev3_bricks, SETTINGS_MINDSTORMS_EV3_BRICKS_CHECKBOX_PREFERENCE); + } else { + openAppstoreDialog(R.string.preference_title_enable_mindstorms_ev3_bricks); + } + checkPreference(R.string.preference_disable_nxt_info_dialog, SETTINGS_MINDSTORMS_EV3_SHOW_SENSOR_INFO_BOX_DISABLED); } @@ -296,4 +324,20 @@ private void checkPreference(int displayedTitleResourceString, String sharedPref assertTrue(sharedPreferences.getBoolean(sharedPreferenceTag, false)); } + + private void openAppstoreDialog(int displayedTitleResourceString) { + onData(PreferenceMatchers.withTitle(displayedTitleResourceString)) + .perform(click()); + + if (!Build.BRAND.equals(Constants.DEVICE_BRAND_HUAWEI)) { + onView(withText(R.string.preference_dialog_google_play)) + .check(matches(isDisplayed())); + } else { + onView(withText(R.string.preference_dialog_appgallery)) + .check(matches(isDisplayed())); + } + + onView(withText(R.string.cancel_button_text)) + .perform(click()); + } } diff --git a/catroid/src/androidTest/java/org/catrobat/catroid/uiespresso/ui/dialog/LegoSensorPortConfigDialogTest.java b/catroid/src/androidTest/java/org/catrobat/catroid/uiespresso/ui/dialog/LegoSensorPortConfigDialogTest.java index dc092c8d51a..224591d5f52 100644 --- a/catroid/src/androidTest/java/org/catrobat/catroid/uiespresso/ui/dialog/LegoSensorPortConfigDialogTest.java +++ b/catroid/src/androidTest/java/org/catrobat/catroid/uiespresso/ui/dialog/LegoSensorPortConfigDialogTest.java @@ -1,6 +1,6 @@ /* * Catroid: An on-device visual programming system for Android devices - * Copyright (C) 2010-2020 The Catrobat Team + * Copyright (C) 2010-2022 The Catrobat Team * () * * This program is free software: you can redistribute it and/or modify @@ -83,10 +83,10 @@ public void setUp() throws Exception { .getDefaultSharedPreferences(ApplicationProvider.getApplicationContext()); nxtSettingBuffer = sharedPreferences - .getBoolean(SettingsFragment.SETTINGS_MINDSTORMS_NXT_BRICKS_ENABLED, false); + .getBoolean(SettingsFragment.SETTINGS_MINDSTORMS_NXT_BRICKS_CHECKBOX_PREFERENCE, false); sharedPreferences.edit() - .putBoolean(SettingsFragment.SETTINGS_MINDSTORMS_NXT_BRICKS_ENABLED, true) + .putBoolean(SettingsFragment.SETTINGS_MINDSTORMS_NXT_BRICKS_CHECKBOX_PREFERENCE, true) .commit(); sensorMappingBuffer = SettingsFragment.getLegoNXTSensorMapping(ApplicationProvider.getApplicationContext()); @@ -130,7 +130,7 @@ public void checkDialogTest() { @After public void tearDown() throws IOException { PreferenceManager.getDefaultSharedPreferences(ApplicationProvider.getApplicationContext()).edit() - .putBoolean(SettingsFragment.SETTINGS_MINDSTORMS_NXT_BRICKS_ENABLED, nxtSettingBuffer) + .putBoolean(SettingsFragment.SETTINGS_MINDSTORMS_NXT_BRICKS_CHECKBOX_PREFERENCE, nxtSettingBuffer) .commit(); SettingsFragment diff --git a/catroid/src/androidTest/java/org/catrobat/catroid/uiespresso/ui/regression/activitydestroy/LegoConfigDialogActivityRecreationRegressionTest.java b/catroid/src/androidTest/java/org/catrobat/catroid/uiespresso/ui/regression/activitydestroy/LegoConfigDialogActivityRecreationRegressionTest.java index 7b5372be6a6..717d978d05c 100644 --- a/catroid/src/androidTest/java/org/catrobat/catroid/uiespresso/ui/regression/activitydestroy/LegoConfigDialogActivityRecreationRegressionTest.java +++ b/catroid/src/androidTest/java/org/catrobat/catroid/uiespresso/ui/regression/activitydestroy/LegoConfigDialogActivityRecreationRegressionTest.java @@ -1,6 +1,6 @@ /* * Catroid: An on-device visual programming system for Android devices - * Copyright (C) 2010-2018 The Catrobat Team + * Copyright (C) 2010-2022 The Catrobat Team * () * * This program is free software: you can redistribute it and/or modify @@ -75,7 +75,7 @@ public void setUp() throws Exception { script.addBrick(new ChangeSizeByNBrick(0)); nxtSettingBuffer = PreferenceManager.getDefaultSharedPreferences(ApplicationProvider.getApplicationContext()) - .getBoolean(SettingsFragment.SETTINGS_MINDSTORMS_NXT_BRICKS_ENABLED, false); + .getBoolean(SettingsFragment.SETTINGS_MINDSTORMS_NXT_BRICKS_CHECKBOX_PREFERENCE, false); setNXTBrickSetting(true); @@ -118,7 +118,7 @@ public void tearDown() throws IOException { private void setNXTBrickSetting(boolean bricksEnabled) { PreferenceManager.getDefaultSharedPreferences(ApplicationProvider.getApplicationContext()).edit() - .putBoolean(SettingsFragment.SETTINGS_MINDSTORMS_NXT_BRICKS_ENABLED, bricksEnabled) + .putBoolean(SettingsFragment.SETTINGS_MINDSTORMS_NXT_BRICKS_CHECKBOX_PREFERENCE, bricksEnabled) .commit(); } } diff --git a/catroid/src/main/java/org/catrobat/catroid/common/Constants.java b/catroid/src/main/java/org/catrobat/catroid/common/Constants.java index ce3346e9b00..7bc071560bd 100644 --- a/catroid/src/main/java/org/catrobat/catroid/common/Constants.java +++ b/catroid/src/main/java/org/catrobat/catroid/common/Constants.java @@ -1,6 +1,6 @@ /* * Catroid: An on-device visual programming system for Android devices - * Copyright (C) 2010-2021 The Catrobat Team + * Copyright (C) 2010-2022 The Catrobat Team * () * * This program is free software: you can redistribute it and/or modify @@ -357,6 +357,22 @@ public final class Constants { ExifInterface.TAG_CAMARA_OWNER_NAME )); + public static final String FLAVOR_POCKET_CODE = "catroid"; + public static final String FLAVOR_EMBROIDERY_DESIGNER = "embroideryDesigner"; + public static final String FLAVOR_LEGO_NXT_EV3 = "mindstorms"; + public static final String FLAVOR_PHIRO = "phiro"; + public static final String FLAVOR_LUNA_AND_CAT = "lunaAndCat"; + public static final String FLAVOR_CREATE_AT_SCHOOL = "createAtSchool"; + + public static final String PREFRENCE_PLAYSTORE_EMBROIDERY_URL = "https://play.google.com/store/apps/details?id=org.catrobat.catroid.embroiderydesigner"; + public static final String PREFRENCE_APPGALLERY_EMBROIDERY_URL = "https://appgallery.huawei.com/app/C100085769"; + public static final String PREFRENCE_PLAYSTORE_MINDSTORMS_URL = "https://play.google.com/store/apps/details?id=org.catrobat.catroid"; + public static final String PREFRENCE_APPGALLERY_MINDSTORMS_URL = "https://appgallery.huawei.com/app/C100085769"; + public static final String PREFRENCE_PLAYSTORE_PHIRO_URL = "https://play.google.com/store/apps/details?id=org.catrobat.catroid.phiro"; + public static final String PREFRENCE_APPGALLERY_PHIRO_URL = "https://appgallery.huawei.com/app/C100085769"; + + public static final String DEVICE_BRAND_HUAWEI = "huawei"; + private Constants() { throw new AssertionError("No."); } diff --git a/catroid/src/main/java/org/catrobat/catroid/ui/recyclerview/dialog/AppStoreDialogFragment.kt b/catroid/src/main/java/org/catrobat/catroid/ui/recyclerview/dialog/AppStoreDialogFragment.kt new file mode 100644 index 00000000000..9d68019a1a2 --- /dev/null +++ b/catroid/src/main/java/org/catrobat/catroid/ui/recyclerview/dialog/AppStoreDialogFragment.kt @@ -0,0 +1,102 @@ +/* + * Catroid: An on-device visual programming system for Android devices + * Copyright (C) 2010-2022 The Catrobat Team + * () + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * An additional term exception under section 7 of the GNU Affero + * General Public License, version 3, is available at + * http://developer.catrobat.org/license_additional_term + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package org.catrobat.catroid.ui.recyclerview.dialog + +import android.app.Dialog +import android.content.Intent +import android.net.Uri +import android.os.Bundle +import android.view.View +import android.widget.TextView +import androidx.appcompat.app.AlertDialog +import androidx.fragment.app.DialogFragment +import org.catrobat.catroid.R +import org.catrobat.catroid.common.Constants + +class AppStoreDialogFragment : DialogFragment() { + + companion object { + val TAG: String = AppStoreDialogFragment::class.java.simpleName + + enum class Extension { + LEGO_NXT_EV3, + PHIRO, + EMBROIDERY + } + + @JvmStatic + fun newInstance(extension: Extension): AppStoreDialogFragment { + val dialog = AppStoreDialogFragment() + dialog.extension = extension + return dialog + } + } + + private lateinit var extension: Extension + + override fun onCreateDialog(bundle: Bundle?): Dialog { + val view = View.inflate(activity, R.layout.dialog_google_play, null) + + val text = view.findViewById(R.id.dialog_google_play_text) + text.text = when (extension) { + Extension.LEGO_NXT_EV3 -> getString(R.string.preference_lego_dialog_text) + Extension.EMBROIDERY -> getString(R.string.preference_embroidery_dialog_text) + Extension.PHIRO -> getString(R.string.preference_phiro_dialog_text) + } + + val builder: AlertDialog.Builder = AlertDialog.Builder(requireActivity()) + .setTitle(getString(R.string.preference_dialog_use_full_features)) + .setView(view) + .setNegativeButton(R.string.cancel_button_text, null) + + val buttonText = if (android.os.Build.BRAND != Constants.DEVICE_BRAND_HUAWEI) { + getString(R.string.preference_dialog_google_play) + } else { + getString(R.string.preference_dialog_appgallery) + } + + builder.setPositiveButton(buttonText) { _, _ -> + val intent = Intent(Intent.ACTION_VIEW) + intent.data = Uri.parse(getCorrectUrl()) + startActivity(intent) + } + + return builder.create() + } + + private fun getCorrectUrl(): String { + return if (android.os.Build.BRAND != Constants.DEVICE_BRAND_HUAWEI) { + when (extension) { + Extension.LEGO_NXT_EV3 -> Constants.PREFRENCE_PLAYSTORE_MINDSTORMS_URL + Extension.EMBROIDERY -> Constants.PREFRENCE_PLAYSTORE_EMBROIDERY_URL + Extension.PHIRO -> Constants.PREFRENCE_PLAYSTORE_PHIRO_URL + } + } else { + when (extension) { + Extension.LEGO_NXT_EV3 -> Constants.PREFRENCE_APPGALLERY_MINDSTORMS_URL + Extension.EMBROIDERY -> Constants.PREFRENCE_APPGALLERY_EMBROIDERY_URL + Extension.PHIRO -> Constants.PREFRENCE_APPGALLERY_PHIRO_URL + } + } + } +} diff --git a/catroid/src/main/java/org/catrobat/catroid/ui/settingsfragments/Ev3SensorsSettingsFragment.java b/catroid/src/main/java/org/catrobat/catroid/ui/settingsfragments/Ev3SensorsSettingsFragment.java index ab3318d8936..901c8411084 100644 --- a/catroid/src/main/java/org/catrobat/catroid/ui/settingsfragments/Ev3SensorsSettingsFragment.java +++ b/catroid/src/main/java/org/catrobat/catroid/ui/settingsfragments/Ev3SensorsSettingsFragment.java @@ -1,6 +1,6 @@ /* * Catroid: An on-device visual programming system for Android devices - * Copyright (C) 2010-2018 The Catrobat Team + * Copyright (C) 2010-2022 The Catrobat Team * () * * This program is free software: you can redistribute it and/or modify @@ -29,18 +29,22 @@ import android.preference.Preference; import android.preference.PreferenceCategory; import android.preference.PreferenceFragment; +import android.preference.PreferenceScreen; import org.catrobat.catroid.BuildConfig; import org.catrobat.catroid.R; +import org.catrobat.catroid.common.Constants; import org.catrobat.catroid.devices.mindstorms.ev3.sensors.EV3Sensor; +import org.catrobat.catroid.ui.recyclerview.dialog.AppStoreDialogFragment; import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatActivity; +import androidx.fragment.app.FragmentActivity; +import static org.catrobat.catroid.ui.recyclerview.dialog.AppStoreDialogFragment.Companion.Extension; import static org.catrobat.catroid.ui.settingsfragments.SettingsFragment.EV3_SCREEN_KEY; import static org.catrobat.catroid.ui.settingsfragments.SettingsFragment.EV3_SENSORS; import static org.catrobat.catroid.ui.settingsfragments.SettingsFragment.EV3_SETTINGS_CATEGORY; -import static org.catrobat.catroid.ui.settingsfragments.SettingsFragment.SETTINGS_MINDSTORMS_EV3_BRICKS_ENABLED; public class Ev3SensorsSettingsFragment extends PreferenceFragment { public static final String TAG = Ev3SensorsSettingsFragment.class.getSimpleName(); @@ -58,21 +62,34 @@ public void onActivityCreated(@Nullable Bundle savedInstanceState) { addPreferencesFromResource(R.xml.ev3_preferences); + CheckBoxPreference ev3CheckBoxPreference = + (CheckBoxPreference) findPreference(SettingsFragment.SETTINGS_MINDSTORMS_EV3_BRICKS_CHECKBOX_PREFERENCE); + Preference simplePreferenceField = findPreference(SettingsFragment.SETTINGS_MINDSTORMS_EV3_BRICKS_PREFERENCE); + PreferenceScreen preferenceScreen = getPreferenceScreen(); + if (!BuildConfig.FEATURE_LEGO_EV3_ENABLED) { CheckBoxPreference legoEv3Preference = (CheckBoxPreference) findPreference(EV3_SCREEN_KEY); legoEv3Preference.setEnabled(false); - getPreferenceScreen().removePreference(legoEv3Preference); + preferenceScreen.removePreference(legoEv3Preference); } else { - CheckBoxPreference ev3CheckBoxPreference = (CheckBoxPreference) findPreference(SETTINGS_MINDSTORMS_EV3_BRICKS_ENABLED); - final PreferenceCategory ev3ConnectionSettings = (PreferenceCategory) findPreference(EV3_SETTINGS_CATEGORY); - ev3ConnectionSettings.setEnabled(ev3CheckBoxPreference.isChecked()); + if (BuildConfig.FLAVOR != Constants.FLAVOR_LEGO_NXT_EV3) { + preferenceScreen.removePreference(ev3CheckBoxPreference); + + simplePreferenceField.setOnPreferenceClickListener(preference -> { + AppStoreDialogFragment.newInstance(Extension.LEGO_NXT_EV3).show(((FragmentActivity) getActivity()).getSupportFragmentManager(), + AppStoreDialogFragment.Companion.getTAG()); + return true; + }); + } else { + preferenceScreen.removePreference(simplePreferenceField); + final PreferenceCategory ev3ConnectionSettings = (PreferenceCategory) findPreference(EV3_SETTINGS_CATEGORY); + ev3ConnectionSettings.setEnabled(ev3CheckBoxPreference.isChecked()); - ev3CheckBoxPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { - public boolean onPreferenceChange(Preference preference, Object isChecked) { + ev3CheckBoxPreference.setOnPreferenceChangeListener((preference, isChecked) -> { ev3ConnectionSettings.setEnabled((Boolean) isChecked); return true; - } - }); + }); + } final String[] sensorPreferences = EV3_SENSORS; for (String sensorPreference : sensorPreferences) { diff --git a/catroid/src/main/java/org/catrobat/catroid/ui/settingsfragments/NXTSensorsSettingsFragment.java b/catroid/src/main/java/org/catrobat/catroid/ui/settingsfragments/NXTSensorsSettingsFragment.java index 831da378a24..7c640a65aae 100644 --- a/catroid/src/main/java/org/catrobat/catroid/ui/settingsfragments/NXTSensorsSettingsFragment.java +++ b/catroid/src/main/java/org/catrobat/catroid/ui/settingsfragments/NXTSensorsSettingsFragment.java @@ -1,6 +1,6 @@ /* * Catroid: An on-device visual programming system for Android devices - * Copyright (C) 2010-2018 The Catrobat Team + * Copyright (C) 2010-2022 The Catrobat Team * () * * This program is free software: you can redistribute it and/or modify @@ -33,10 +33,14 @@ import org.catrobat.catroid.BuildConfig; import org.catrobat.catroid.R; +import org.catrobat.catroid.common.Constants; import org.catrobat.catroid.devices.mindstorms.nxt.sensors.NXTSensor; +import org.catrobat.catroid.ui.recyclerview.dialog.AppStoreDialogFragment; +import org.catrobat.catroid.ui.recyclerview.dialog.AppStoreDialogFragment.Companion.Extension; import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatActivity; +import androidx.fragment.app.FragmentActivity; import static org.catrobat.catroid.ui.settingsfragments.SettingsFragment.NXT_SENSORS; @@ -55,21 +59,34 @@ public void onActivityCreated(@Nullable Bundle savedInstanceState) { SettingsFragment.setToChosenLanguage(getActivity()); addPreferencesFromResource(R.xml.nxt_preferences); + + CheckBoxPreference nxtCheckBoxPreference = (CheckBoxPreference) findPreference(SettingsFragment.SETTINGS_MINDSTORMS_NXT_BRICKS_CHECKBOX_PREFERENCE); + Preference simplePreferenceField = findPreference(SettingsFragment.SETTINGS_MINDSTORMS_NXT_BRICKS_PREFERENCE); + PreferenceScreen preferenceScreen = getPreferenceScreen(); + if (!BuildConfig.FEATURE_LEGO_NXT_ENABLED) { PreferenceScreen legoNxtPreference = (PreferenceScreen) findPreference(SettingsFragment.NXT_SCREEN_KEY); legoNxtPreference.setEnabled(false); - getPreferenceScreen().removePreference(legoNxtPreference); + preferenceScreen.removePreference(legoNxtPreference); } else { - CheckBoxPreference nxtCheckBoxPreference = (CheckBoxPreference) findPreference(SettingsFragment.SETTINGS_MINDSTORMS_NXT_BRICKS_ENABLED); - final PreferenceCategory nxtConnectionSettings = (PreferenceCategory) findPreference(SettingsFragment.NXT_SETTINGS_CATEGORY); - nxtConnectionSettings.setEnabled(nxtCheckBoxPreference.isChecked()); + if (BuildConfig.FLAVOR != Constants.FLAVOR_LEGO_NXT_EV3) { + preferenceScreen.removePreference(nxtCheckBoxPreference); - nxtCheckBoxPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { - public boolean onPreferenceChange(Preference preference, Object isChecked) { + simplePreferenceField.setOnPreferenceClickListener(preference -> { + AppStoreDialogFragment.newInstance(Extension.LEGO_NXT_EV3).show(((FragmentActivity) getActivity()).getSupportFragmentManager(), + AppStoreDialogFragment.Companion.getTAG()); + return true; + }); + } else { + preferenceScreen.removePreference(simplePreferenceField); + final PreferenceCategory nxtConnectionSettings = (PreferenceCategory) findPreference(SettingsFragment.NXT_SETTINGS_CATEGORY); + nxtConnectionSettings.setEnabled(nxtCheckBoxPreference.isChecked()); + + nxtCheckBoxPreference.setOnPreferenceChangeListener((preference, isChecked) -> { nxtConnectionSettings.setEnabled((Boolean) isChecked); return true; - } - }); + }); + } final String[] sensorPreferences = NXT_SENSORS; for (String sensorPreference : sensorPreferences) { diff --git a/catroid/src/main/java/org/catrobat/catroid/ui/settingsfragments/SettingsFragment.java b/catroid/src/main/java/org/catrobat/catroid/ui/settingsfragments/SettingsFragment.java index 7e8b1ba84f5..58c9d5de666 100644 --- a/catroid/src/main/java/org/catrobat/catroid/ui/settingsfragments/SettingsFragment.java +++ b/catroid/src/main/java/org/catrobat/catroid/ui/settingsfragments/SettingsFragment.java @@ -40,12 +40,15 @@ import org.catrobat.catroid.BuildConfig; import org.catrobat.catroid.ProjectManager; import org.catrobat.catroid.R; +import org.catrobat.catroid.common.Constants; import org.catrobat.catroid.common.DroneConfigPreference; import org.catrobat.catroid.devices.mindstorms.ev3.sensors.EV3Sensor; import org.catrobat.catroid.devices.mindstorms.nxt.sensors.NXTSensor; import org.catrobat.catroid.formulaeditor.SensorHandler; import org.catrobat.catroid.sync.ProjectsCategoriesSync; import org.catrobat.catroid.ui.MainMenuActivity; +import org.catrobat.catroid.ui.recyclerview.dialog.AppStoreDialogFragment; +import org.catrobat.catroid.ui.recyclerview.dialog.AppStoreDialogFragment.Companion.Extension; import org.catrobat.catroid.utils.SnackbarUtil; import java.util.ArrayList; @@ -55,6 +58,7 @@ import androidx.annotation.VisibleForTesting; import androidx.appcompat.app.AppCompatActivity; +import androidx.fragment.app.FragmentActivity; import static org.catrobat.catroid.CatroidApplication.defaultSystemLanguage; import static org.catrobat.catroid.common.SharedPreferenceKeys.DEVICE_LANGUAGE; @@ -64,32 +68,30 @@ public class SettingsFragment extends PreferenceFragment { - public static final String SETTINGS_MINDSTORMS_NXT_BRICKS_ENABLED = "settings_mindstorms_nxt_bricks_enabled"; + public static final String SETTINGS_MINDSTORMS_NXT_BRICKS_PREFERENCE = "settings_mindstorms_nxt_bricks_preference"; + public static final String SETTINGS_MINDSTORMS_NXT_BRICKS_CHECKBOX_PREFERENCE = "settings_mindstorms_nxt_bricks_checkbox_preference"; public static final String SETTINGS_MINDSTORMS_NXT_SHOW_SENSOR_INFO_BOX_DISABLED = "settings_mindstorms_nxt_show_sensor_info_box_disabled"; - public static final String SETTINGS_MINDSTORMS_EV3_BRICKS_ENABLED = "settings_mindstorms_ev3_bricks_enabled"; + public static final String SETTINGS_MINDSTORMS_EV3_BRICKS_PREFERENCE = "settings_mindstorms_ev3_bricks_preference"; + public static final String SETTINGS_MINDSTORMS_EV3_BRICKS_CHECKBOX_PREFERENCE = "settings_mindstorms_ev3_bricks_checkbox_preference"; public static final String SETTINGS_MINDSTORMS_EV3_SHOW_SENSOR_INFO_BOX_DISABLED = "settings_mindstorms_ev3_show_sensor_info_box_disabled"; public static final String SETTINGS_SHOW_PARROT_AR_DRONE_BRICKS = "setting_parrot_ar_drone_bricks"; public static final String SETTINGS_EDIT_TRUSTED_DOMAINS = "setting_trusted_domains"; public static final String SETTINGS_SHOW_JUMPING_SUMO_BRICKS = "setting_parrot_jumping_sumo_bricks"; - public static final String SETTINGS_SHOW_EMBROIDERY_BRICKS = "setting_embroidery_bricks"; - public static final String SETTINGS_SHOW_PHIRO_BRICKS = "setting_enable_phiro_bricks"; + public static final String SETTINGS_SHOW_EMBROIDERY_BRICKS_PREFERENCE = "setting_embroidery_bricks_preference"; + public static final String SETTINGS_SHOW_EMBROIDERY_BRICKS_CHECKBOX_PREFERENCE = "setting_embroidery_bricks_checkbox_preference"; + public static final String SETTINGS_SHOW_PHIRO_BRICKS_CHECKBOX_PREFERENCE = "setting_enable_phiro_bricks_checkbox_preference"; + public static final String SETTINGS_SHOW_PHIRO_BRICKS_PREFERENCE = "setting_enable_phiro_bricks_preference"; public static final String SETTINGS_SHOW_ARDUINO_BRICKS = "setting_arduino_bricks"; public static final String SETTINGS_SHOW_RASPI_BRICKS = "setting_raspi_bricks"; public static final String SETTINGS_SHOW_NFC_BRICKS = "setting_nfc_bricks"; public static final String SETTINGS_PARROT_AR_DRONE_CATROBAT_TERMS_OF_SERVICE_ACCEPTED_PERMANENTLY = "setting_parrot_ar_drone_catrobat_terms_of_service_accepted_permanently"; public static final String SETTINGS_CAST_GLOBALLY_ENABLED = "setting_cast_globally_enabled"; - public static final String SETTINGS_SHOW_AI_SPEECH_RECOGNITION_SENSORS = - "setting_ai_speech_recognition"; - public static final String SETTINGS_SHOW_AI_SPEECH_SYNTHETIZATION_SENSORS = - "setting_ai_speech_synthetization"; - public static final String SETTINGS_SHOW_AI_FACE_DETECTION_SENSORS = - "setting_ai_face_detection"; - public static final String SETTINGS_SHOW_AI_POSE_DETECTION_SENSORS = - "setting_ai_pose_detection"; - public static final String SETTINGS_SHOW_AI_TEXT_RECOGNITION_SENSORS = - "setting_ai_text_recognition"; - public static final String SETTINGS_SHOW_AI_OBJECT_DETECTION_SENSORS = - "setting_ai_object_detection"; + public static final String SETTINGS_SHOW_AI_SPEECH_RECOGNITION_SENSORS = "setting_ai_speech_recognition"; + public static final String SETTINGS_SHOW_AI_SPEECH_SYNTHETIZATION_SENSORS = "setting_ai_speech_synthetization"; + public static final String SETTINGS_SHOW_AI_FACE_DETECTION_SENSORS = "setting_ai_face_detection"; + public static final String SETTINGS_SHOW_AI_POSE_DETECTION_SENSORS = "setting_ai_pose_detection"; + public static final String SETTINGS_SHOW_AI_TEXT_RECOGNITION_SENSORS = "setting_ai_text_recognition"; + public static final String SETTINGS_SHOW_AI_OBJECT_DETECTION_SENSORS = "setting_ai_object_detection"; public static final String SETTINGS_MULTIPLAYER_VARIABLES_ENABLED = "setting_multiplayer_variables_enabled"; public static final String SETTINGS_SHOW_HINTS = "setting_enable_hints"; @@ -144,13 +146,15 @@ public void onCreate(Bundle savedInstanceState) { screen = getPreferenceScreen(); if (!BuildConfig.FEATURE_EMBROIDERY_ENABLED) { - CheckBoxPreference embroideryPreference = (CheckBoxPreference) findPreference(SETTINGS_SHOW_EMBROIDERY_BRICKS); + CheckBoxPreference embroideryPreference = + (CheckBoxPreference) findPreference(SETTINGS_SHOW_EMBROIDERY_BRICKS_CHECKBOX_PREFERENCE); embroideryPreference.setEnabled(false); screen.removePreference(embroideryPreference); } if (!BuildConfig.FEATURE_PHIRO_ENABLED) { - CheckBoxPreference phiroPreference = (CheckBoxPreference) findPreference(SETTINGS_SHOW_PHIRO_BRICKS); + CheckBoxPreference phiroPreference = + (CheckBoxPreference) findPreference(SETTINGS_SHOW_PHIRO_BRICKS_CHECKBOX_PREFERENCE); phiroPreference.setEnabled(false); screen.removePreference(phiroPreference); } @@ -198,6 +202,9 @@ public void onCreate(Bundle savedInstanceState) { testPreference.setEnabled(BuildConfig.DEBUG); screen.removePreference(testPreference); } + + setCorrectPreferenceViewForEmbroidery(); + setCorrectPreferenceViewForPhiro(); } @Override @@ -265,7 +272,7 @@ public boolean onPreferenceChange(Preference preference, Object newValue) { } public static boolean isEmroiderySharedPreferenceEnabled(Context context) { - return getBooleanSharedPreference(false, SETTINGS_SHOW_EMBROIDERY_BRICKS, context); + return getBooleanSharedPreference(false, SETTINGS_SHOW_EMBROIDERY_BRICKS_CHECKBOX_PREFERENCE, context); } public static boolean isDroneSharedPreferenceEnabled(Context context) { @@ -277,15 +284,16 @@ public static boolean isJSSharedPreferenceEnabled(Context context) { } public static boolean isMindstormsNXTSharedPreferenceEnabled(Context context) { - return getBooleanSharedPreference(false, SETTINGS_MINDSTORMS_NXT_BRICKS_ENABLED, context); + return getBooleanSharedPreference(false, SETTINGS_MINDSTORMS_NXT_BRICKS_CHECKBOX_PREFERENCE, context); } public static boolean isMindstormsEV3SharedPreferenceEnabled(Context context) { - return getBooleanSharedPreference(false, SETTINGS_MINDSTORMS_EV3_BRICKS_ENABLED, context); + return getBooleanSharedPreference(false, SETTINGS_MINDSTORMS_EV3_BRICKS_CHECKBOX_PREFERENCE, context); } public static boolean isPhiroSharedPreferenceEnabled(Context context) { - return getBooleanSharedPreference(false, SETTINGS_SHOW_PHIRO_BRICKS, context); + return getBooleanSharedPreference(false, SETTINGS_SHOW_PHIRO_BRICKS_CHECKBOX_PREFERENCE, + context); } public static boolean isCastSharedPreferenceEnabled(Context context) { @@ -294,7 +302,7 @@ public static boolean isCastSharedPreferenceEnabled(Context context) { public static void setPhiroSharedPreferenceEnabled(Context context, boolean value) { getSharedPreferences(context).edit() - .putBoolean(SETTINGS_SHOW_PHIRO_BRICKS, value) + .putBoolean(SETTINGS_SHOW_PHIRO_BRICKS_CHECKBOX_PREFERENCE, value) .apply(); } @@ -484,13 +492,13 @@ public static DroneConfigPreference.Preferences getDronePreferenceMapping(Contex public static void enableLegoMindstormsNXTBricks(Context context) { getSharedPreferences(context).edit() - .putBoolean(SETTINGS_MINDSTORMS_NXT_BRICKS_ENABLED, true) + .putBoolean(SETTINGS_MINDSTORMS_NXT_BRICKS_CHECKBOX_PREFERENCE, true) .apply(); } public static void enableLegoMindstormsEV3Bricks(Context context) { getSharedPreferences(context).edit() - .putBoolean(SETTINGS_MINDSTORMS_EV3_BRICKS_ENABLED, true) + .putBoolean(SETTINGS_MINDSTORMS_EV3_BRICKS_CHECKBOX_PREFERENCE, true) .apply(); } @@ -580,4 +588,40 @@ public static void setUseCatBlocks(Context context, boolean useCatBlocks) { .putBoolean(SETTINGS_USE_CATBLOCKS, useCatBlocks) .apply(); } + + private void setCorrectPreferenceViewForEmbroidery() { + CheckBoxPreference embroideryCheckBoxPreference = + (CheckBoxPreference) findPreference(SettingsFragment.SETTINGS_SHOW_EMBROIDERY_BRICKS_CHECKBOX_PREFERENCE); + Preference simplePreferenceField = findPreference(SettingsFragment.SETTINGS_SHOW_EMBROIDERY_BRICKS_PREFERENCE); + + if (BuildConfig.FLAVOR != Constants.FLAVOR_EMBROIDERY_DESIGNER) { + getPreferenceScreen().removePreference(embroideryCheckBoxPreference); + + simplePreferenceField.setOnPreferenceClickListener(preference -> { + AppStoreDialogFragment.newInstance(Extension.EMBROIDERY).show(((FragmentActivity) getActivity()).getSupportFragmentManager(), + AppStoreDialogFragment.Companion.getTAG()); + return true; + }); + } else { + getPreferenceScreen().removePreference(simplePreferenceField); + } + } + + private void setCorrectPreferenceViewForPhiro() { + CheckBoxPreference phiroCheckBoxPreference = + (CheckBoxPreference) findPreference(SettingsFragment.SETTINGS_SHOW_PHIRO_BRICKS_CHECKBOX_PREFERENCE); + Preference simplePreferenceField = findPreference(SettingsFragment.SETTINGS_SHOW_PHIRO_BRICKS_PREFERENCE); + + if (BuildConfig.FLAVOR != Constants.FLAVOR_PHIRO) { + getPreferenceScreen().removePreference(phiroCheckBoxPreference); + + simplePreferenceField.setOnPreferenceClickListener(preference -> { + AppStoreDialogFragment.newInstance(Extension.PHIRO).show(((FragmentActivity) getActivity()).getSupportFragmentManager(), + AppStoreDialogFragment.Companion.getTAG()); + return true; + }); + } else { + getPreferenceScreen().removePreference(simplePreferenceField); + } + } } diff --git a/catroid/src/main/res/layout/dialog_google_play.xml b/catroid/src/main/res/layout/dialog_google_play.xml new file mode 100644 index 00000000000..2aca5909fc2 --- /dev/null +++ b/catroid/src/main/res/layout/dialog_google_play.xml @@ -0,0 +1,44 @@ + + + + + + + + + + \ No newline at end of file diff --git a/catroid/src/main/res/values/strings.xml b/catroid/src/main/res/values/strings.xml index 44b4194e6f8..bd89f2a8208 100644 --- a/catroid/src/main/res/values/strings.xml +++ b/catroid/src/main/res/values/strings.xml @@ -1,7 +1,7 @@ Parrot AR.Drone 2.0 extension diff --git a/catroid/src/main/res/xml/ev3_preferences.xml b/catroid/src/main/res/xml/ev3_preferences.xml index 2620ea4db9b..18a4f9556d4 100644 --- a/catroid/src/main/res/xml/ev3_preferences.xml +++ b/catroid/src/main/res/xml/ev3_preferences.xml @@ -1,7 +1,7 @@