Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement changes to target Android SDK 30 #2293

Merged
merged 7 commits into from
Aug 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// -*- mode: java; c-basic-offset: 2; -*-
// Copyright 2009-2011 Google, All Rights reserved
// Copyright 2011-2020 MIT, All rights reserved
// Copyright 2011-2021 MIT, All rights reserved
// Released under the Apache License, Version 2.0
// http://www.apache.org/licenses/LICENSE-2.0

Expand Down Expand Up @@ -5297,4 +5297,30 @@ String newerVersionComponentException(String componentType, int srcCompVersion,
@DefaultMessage("Image, MainText, DetailText(Vertical)")
@Description("Display Text for ListView layout choice having an image and two lines of text.")
String imageTwoTextLayout();

// File Scope choices

@DefaultMessage("App")
@Description("")
String fileScopeApp();

@DefaultMessage("Asset")
@Description("")
String fileScopeAsset();

@DefaultMessage("Cache")
@Description("")
String fileScopeCache();

@DefaultMessage("Legacy")
@Description("")
String fileScopeLegacy();

@DefaultMessage("Private")
@Description("")
String fileScopePrivate();

@DefaultMessage("Shared")
@Description("")
String fileScopeShared();
}
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ public int getHeight() {
private static final String PROPERTY_NAME_PRIMARY_COLOR_DARK = "PrimaryColorDark";
private static final String PROPERTY_NAME_ACCENT_COLOR = "AccentColor";
private static final String PROPERTY_NAME_THEME = "Theme";
private static final String PROPERTY_NAME_DEFAULTFILESCOPE = "DefaultFileScope";

// Form UI components
AbsolutePanel formWidget;
Expand Down Expand Up @@ -757,7 +758,8 @@ protected boolean isPropertyVisible(String propertyName) {
case PROPERTY_NAME_PRIMARY_COLOR:
case PROPERTY_NAME_PRIMARY_COLOR_DARK:
case PROPERTY_NAME_ACCENT_COLOR:
case PROPERTY_NAME_THEME: {
case PROPERTY_NAME_THEME:
case PROPERTY_NAME_DEFAULTFILESCOPE: {
return editor.isScreen1();
}

Expand Down Expand Up @@ -1042,6 +1044,14 @@ private void setTheme(String theme) {

}

private void setDefaultFileScope(String defaultFileScope) {
if (editor.isScreen1()) {
editor.getProjectEditor().changeProjectSettingsProperty(
SettingsConstants.PROJECT_YOUNG_ANDROID_SETTINGS,
SettingsConstants.YOUNG_ANDROID_SETTINGS_DEFAULTFILESCOPE, defaultFileScope);
}
}

/**
* Forces a re-layout of the child components of the container.
*
Expand Down Expand Up @@ -1384,6 +1394,8 @@ public void onPropertyChange(String propertyName, String newValue) {
getProperties().getExistingProperty(PROPERTY_NAME_ACTIONBAR).setValue("True");
}
setTheme(newValue);
} else if (propertyName.equals(PROPERTY_NAME_DEFAULTFILESCOPE)) {
setDefaultFileScope(newValue);
} else if (propertyName.equals(PROPERTY_NAME_PRIMARY_COLOR)) {
setPrimaryColor(newValue);
if (idxPhonePreviewStyle == 2) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// -*- mode: java; c-basic-offset: 2; -*-
// Copyright 2009-2011 Google, All Rights reserved
// Copyright 2011-2019 MIT, All rights reserved
// Copyright 2011-2021 MIT, All rights reserved
// Released under the Apache License, Version 2.0
// http://www.apache.org/licenses/LICENSE-2.0

Expand All @@ -19,6 +19,7 @@
import com.google.appinventor.client.editor.youngandroid.properties.YoungAndroidColorChoicePropertyEditor;
import com.google.appinventor.client.editor.youngandroid.properties.YoungAndroidComponentSelectorPropertyEditor;
import com.google.appinventor.client.editor.youngandroid.properties.YoungAndroidDefaultURLPropertyEditor;
import com.google.appinventor.client.editor.youngandroid.properties.YoungAndroidFileScopePropertyEditor;
import com.google.appinventor.client.editor.youngandroid.properties.YoungAndroidFloatRangePropertyEditor;
import com.google.appinventor.client.editor.youngandroid.properties.YoungAndroidFontTypefaceChoicePropertyEditor;
import com.google.appinventor.client.editor.youngandroid.properties.YoungAndroidGeoJSONPropertyEditor;
Expand Down Expand Up @@ -201,6 +202,8 @@ public static PropertyEditor createPropertyEditor(String editorType, String defa
return new YoungAndroidColorChoicePropertyEditor(defaultValue);
} else if (editorType.equals(PropertyTypeConstants.PROPERTY_TYPE_COMPONENT)) {
return new YoungAndroidComponentSelectorPropertyEditor(editor);
} else if (editorType.equals(PropertyTypeConstants.PROPERTY_TYPE_FILESCOPE)) {
return new YoungAndroidFileScopePropertyEditor();
} else if (editorType.equals(PropertyTypeConstants.PROPERTY_TYPE_FLOAT)) {
return new FloatPropertyEditor();
} else if (editorType.equals(PropertyTypeConstants.PROPERTY_TYPE_GEOGRAPHIC_POINT)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// -*- mode: java; c-basic-offset: 2; -*-
// Copyright 2021 MIT, All rights reserved
// Released under the Apache License, Version 2.0
// http://www.apache.org/licenses/LICENSE-2.0

package com.google.appinventor.client.editor.youngandroid.properties;

import static com.google.appinventor.client.Ode.MESSAGES;

import com.google.appinventor.client.widgets.properties.ChoicePropertyEditor;

public class YoungAndroidFileScopePropertyEditor extends ChoicePropertyEditor {
private static final Choice[] CHOICES = new Choice[] {
new Choice(MESSAGES.fileScopeApp(), "App"),
new Choice(MESSAGES.fileScopeAsset(), "Asset"),
new Choice(MESSAGES.fileScopeCache(), "Cache"),
new Choice(MESSAGES.fileScopeLegacy(), "Legacy"),
new Choice(MESSAGES.fileScopePrivate(), "Private"),
new Choice(MESSAGES.fileScopeShared(), "Shared")
};

public YoungAndroidFileScopePropertyEditor() {
super(CHOICES);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,8 @@ public YoungAndroidSettings(Project project) {
addProperty(new EditableProperty(this,
SettingsConstants.YOUNG_ANDROID_SETTINGS_ACCENT_COLOR, "&HFF00728A",
EditableProperty.TYPE_INVISIBLE));
addProperty(new EditableProperty(this,
SettingsConstants.YOUNG_ANDROID_SETTINGS_DEFAULTFILESCOPE, "App",
EditableProperty.TYPE_INVISIBLE));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -891,6 +891,17 @@ private static int upgradeFileProperties(Map<String, JSONValue> componentPropert
// No properties need to be modified to upgrade to version 3.
srcCompVersion = 3;
}
if (srcCompVersion < 4) {
// AccessMode was added.
// LegacyMode was removed.
// If LegacyMode was set, AccessMode should be set to "2", which is Legacy.
if (componentProperties.containsKey("LegacyMode")) {
componentProperties.remove("LegacyMode");
// LegacyMode maps to AccessMode 2 (Legacy)
componentProperties.put("DefaultScope", new ClientJsonString("Legacy"));
}
srcCompVersion = 4;
}
return srcCompVersion;
}

Expand Down Expand Up @@ -1102,6 +1113,10 @@ private static int upgradeFormProperties(Map<String, JSONValue> componentPropert
// Adds Permission dropdown block.
srcCompVersion = 29;
}
if (srcCompVersion < 30) {
// The DefaultFileScope property was added.
srcCompVersion = 30;
}

return srcCompVersion;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.google.appinventor.common.utils.StringUtils;
import com.google.appinventor.server.flags.Flag;
import com.google.appinventor.server.project.youngandroid.YoungAndroidProjectService;
import com.google.appinventor.server.project.youngandroid.YoungAndroidSettingsBuilder;
import com.google.appinventor.server.storage.StorageIo;
import com.google.appinventor.server.storage.StorageIoInstanceHolder;
import com.google.appinventor.shared.rpc.UploadResponse;
Expand Down Expand Up @@ -101,9 +102,10 @@ public UserProject importProject(String userId, String projectName,
// The content for the youngandroidproject/project.properties file must be regenerated
// so that it contains the correct entries for "main" and "name", which are dependent on
// the projectName and qualifiedFormName.
String content = YoungAndroidProjectService.getProjectPropertiesFileContents(
projectName, qualifiedFormName, null, null, null, null, null, null, null, null,
null, null, null, null, null, null);
String content = new YoungAndroidSettingsBuilder()
.setProjectName(projectName)
.setQualifiedFormName(qualifiedFormName)
.toProperties();
project.addTextFile(new TextFile(fileName, content));
isProjectArchive = true;

Expand Down Expand Up @@ -150,8 +152,7 @@ public UserProject importProject(String userId, String projectName,
if (projectHistory != null) {
project.setProjectHistory(projectHistory);
}
String settings = YoungAndroidProjectService.getProjectSettings(null, null, null, null, null,
null, null, null, null, null, null, null, null, null);
String settings = new YoungAndroidSettingsBuilder().build();
long projectId = storageIo.createProject(userId, project, settings);
return storageIo.getUserProject(userId, projectId);
}
Expand Down
Loading