Commit 8a687c24 authored by Evan W. Patton's avatar Evan W. Patton

Tie ActionBar to Theme setting

Fixes #1121

Change-Id: I64c464a96614ee9f0d4f5b9f55ab350ddeeb12f5
parent fe79635e
......@@ -475,7 +475,7 @@ public final class MockForm extends MockContainer {
}
if (propertyName.equals(PROPERTY_NAME_ACTIONBAR)) {
return editor.isScreen1();
return false;
}
if (propertyName.equals(PROPERTY_NAME_PRIMARY_COLOR)) {
......@@ -958,9 +958,20 @@ public final class MockForm extends MockContainer {
} else if (propertyName.equals(PROPERTY_NAME_TUTORIAL_URL)) {
setTutorialURLProperty(newValue);
} else if (propertyName.equals(PROPERTY_NAME_ACTIONBAR)) {
setActionBarProperty(newValue);
// ActionBar is now tied to the Theme. This can be removed once Companion 2.47 is the minimum version supported.
String theme = getProperties().hasProperty(PROPERTY_NAME_THEME) ? getPropertyValue(PROPERTY_NAME_THEME) : null;
if (theme == null || theme.isEmpty() || theme.equals("Classic")) {
setActionBarProperty("False");
} else {
setActionBarProperty("True");
}
} else if (propertyName.equals(PROPERTY_NAME_THEME)) {
setTheme(newValue);
if ("Classic".equals(newValue)) {
getProperties().getExistingProperty(PROPERTY_NAME_ACTIONBAR).setValue("False");
} else {
getProperties().getExistingProperty(PROPERTY_NAME_ACTIONBAR).setValue("True");
}
} else if (propertyName.equals(PROPERTY_NAME_PRIMARY_COLOR)) {
setPrimaryColor(newValue);
} else if (propertyName.equals(PROPERTY_NAME_PRIMARY_COLOR_DARK)) {
......
......@@ -945,6 +945,17 @@ public final class YoungAndroidFormUpgrader {
srcCompVersion = 22;
}
if (srcCompVersion < 23) {
// The ActionBar property was deprecated. It should always be true in new themes, and false
// in classic themes.
if (componentProperties.containsKey("Theme") && !"Classic".equals(componentProperties.get("Theme").asString().toString())) {
componentProperties.put("ActionBar", new ClientJsonString("True"));
} else if (componentProperties.containsKey("ActionBar")) { // Theme is Classic
componentProperties.remove("ActionBar"); // Resets ActionBar to default (False)
}
srcCompVersion = 23;
}
return srcCompVersion;
}
......
......@@ -2213,7 +2213,11 @@ Blockly.Versioning.AllUpgradeMaps =
// For FORM_COMPONENT_VERSION 22:
// - The Classic option was added to the Theme property. No blocks need to be changed
22: "noUpgrade"
22: "noUpgrade",
// For FORM_COMPONENT_VERSION 23:
// - The ActionBar designer property was hidden and tied to the Theme property. No blocks need to be changed.
23: "noUpgrade"
}, // End Screen
......
......@@ -419,8 +419,10 @@ public class YaVersion {
// For YOUNG_ANDROID_VERSION 166:
// - MAP_COMPONENT_VERSION was incremented to 3
// - FEATURE_COLLECTION_COMPONENT_VERSION was incremented to 2
// For YOUNG_ANDROID_VERSION 167:
// - FORM_COMPONENT_VERSION was incremented to 23
public static final int YOUNG_ANDROID_VERSION = 166;
public static final int YOUNG_ANDROID_VERSION = 167;
// ............................... Blocks Language Version Number ...............................
......@@ -734,7 +736,9 @@ public class YaVersion {
// - The Screen.Theme property was added
// For FORM_COMPONENT_VERSION 22:
// - The Classic option for themes was added
public static final int FORM_COMPONENT_VERSION = 22;
// For FORM_COMPONENT_VERSION 23:
// - The ActionBar property was deprecated
public static final int FORM_COMPONENT_VERSION = 23;
// For FUSIONTABLESCONTROL_COMPONENT_VERSION 2:
// - The Fusiontables API was migrated from SQL to V1
......
......@@ -266,6 +266,7 @@ public class AppInventorCompatActivity extends Activity implements AppCompatCall
@SuppressWarnings("WeakerAccess")
protected void setAppInventorTheme(Theme theme) {
if (!Form.getActiveForm().isRepl()) return; // Theme changing only allowed in REPL
if (theme == currentTheme) {
return;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment