1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-14 00:14:18 +00:00

Fixed exporting global/fallback path settings for Android exporter by moving Android SDK/NDK DependencyPathValueSource ownership into the project.

This commit is contained in:
Timur Doumler 2015-08-13 14:47:24 +01:00
parent af9762885b
commit f4c91eca99
3 changed files with 66 additions and 50 deletions

View file

@ -38,7 +38,8 @@ public:
}
//==============================================================================
AndroidProjectExporter (Project& p, const ValueTree& t) : ProjectExporter (p, t)
AndroidProjectExporter (Project& p, const ValueTree& t)
: ProjectExporter (p, t)
{
name = getNameAndroid();
@ -62,6 +63,18 @@ public:
if (getKeyAliasValue().getValue().isVoid()) getKeyAliasValue() = "androiddebugkey";
if (getKeyAliasPassValue().getValue().isVoid()) getKeyAliasPassValue() = "android";
if (getCPP11EnabledValue().getValue().isVoid()) getCPP11EnabledValue() = true;
sdkPath = Value (new DependencyPathValueSource (
getSetting (Ids::androidSDKPath),
DependencyPath::androidSdkKeyName,
DependencyPath::getThisOS()
));
ndkPath = Value (new DependencyPathValueSource (
getSetting (Ids::androidNDKPath),
DependencyPath::androidNdkKeyName,
DependencyPath::getThisOS()
));
}
//==============================================================================
@ -83,10 +96,10 @@ public:
props.add (new TextPropertyComponent (getVersionCodeValue(), "Android Version Code", 32, false),
"An integer value that represents the version of the application code, relative to other versions.");
props.add (new DependencyPathPropertyComponent (getSDKPathValue(), "Android SDK Path", DependencyPath::androidSdkKeyName),
props.add (new DependencyPathPropertyComponent (getSDKPathValue(), "Android SDK Path"),
"The path to the Android SDK folder on the target build machine");
props.add (new DependencyPathPropertyComponent (getNDKPathValue(), "Android NDK Path", DependencyPath::androidNdkKeyName),
props.add (new DependencyPathPropertyComponent (getNDKPathValue(), "Android NDK Path"),
"The path to the Android NDK folder on the target build machine");
props.add (new TextPropertyComponent (getMinimumSDKVersionValue(), "Minimum SDK version", 32, false),
@ -132,10 +145,10 @@ public:
String getActivitySubClassPath() const { return settings [Ids::androidActivitySubClassName]; }
Value getVersionCodeValue() { return getSetting (Ids::androidVersionCode); }
String getVersionCodeString() const { return settings [Ids::androidVersionCode]; }
Value getSDKPathValue() { return getSetting (Ids::androidSDKPath); }
String getSDKPathString() const { return settings [Ids::androidSDKPath]; }
Value getNDKPathValue() { return getSetting (Ids::androidNDKPath); }
String getNDKPathString() const { return settings [Ids::androidNDKPath]; }
Value getSDKPathValue() { return sdkPath; }
String getSDKPathString() const { return sdkPath.toString(); }
Value getNDKPathValue() { return ndkPath; }
String getNDKPathString() const { return ndkPath.toString(); }
Value getNDKToolchainVersionValue() { return getSetting (Ids::toolset); }
String getNDKToolchainVersionString() const { return settings [Ids::toolset]; }
@ -749,5 +762,7 @@ private:
}
//==============================================================================
Value sdkPath, ndkPath;
JUCE_DECLARE_NON_COPYABLE (AndroidProjectExporter)
};

View file

@ -22,6 +22,18 @@ const String DependencyPath::androidNdkKeyName = "androidNdkPath";
//==============================================================================
DependencyPathValueSource::DependencyPathValueSource (const Value& projectSettingsPath,
String globalSettingsKey,
DependencyPathOS osThisSettingAppliesTo)
: projectSettingsValue (projectSettingsPath),
globalKey (globalSettingsKey),
os (osThisSettingAppliesTo),
globalSettingsValue (PathSettingsTab::getPathByKey (globalKey, os)),
fallbackValue (PathSettingsTab::getFallbackPathByKey (globalKey, os))
{
globalSettingsValue.addListener (this);
}
bool DependencyPathValueSource::isValidPath() const
{
// if we are on another OS than the one which this path setting is for,
@ -34,16 +46,10 @@ bool DependencyPathValueSource::isValidPath() const
//==============================================================================
DependencyPathPropertyComponent::DependencyPathPropertyComponent (const Value& value,
const String& propertyName,
const String& globalKey,
DependencyPathOS os)
: TextPropertyComponent (propertyName, 1024, false),
pathValueSource (new DependencyPathValueSource (value,
PathSettingsTab::getPathByKey (globalKey, os),
PathSettingsTab::getFallbackPathByKey (globalKey, os),
globalKey,
os)),
pathValue (pathValueSource)
const String& propertyName)
try : TextPropertyComponent (propertyName, 1024, false),
pathValue (value),
pathValueSource (dynamic_cast<DependencyPathValueSource&> (pathValue.getValueSource()))
{
bool initialValueIsEmpty = value.toString().isEmpty();
@ -60,12 +66,19 @@ DependencyPathPropertyComponent::DependencyPathPropertyComponent (const Value& v
else
jassertfalse;
}
catch (const std::bad_cast&)
{
// a DependencyPathPropertyComponent must be initialised with a Value
// that is referring to a DependencyPathValueSource!
jassertfalse;
throw;
}
void DependencyPathPropertyComponent::valueChanged (Value& value)
{
// this callback handles the update of this setting in case
// the user changed the global preferences.
if (value.refersToSameSourceAs (pathValue) && pathValueSource->isUsingGlobalSettings())
if (value.refersToSameSourceAs (pathValue) && pathValueSource.isUsingGlobalSettings())
textWasEdited();
}
@ -77,11 +90,11 @@ void DependencyPathPropertyComponent::textWasEdited()
Colour DependencyPathPropertyComponent::getTextColourToDisplay() const
{
if (! pathValueSource->isUsingProjectSettings())
return pathValueSource->isValidPath() ? Colours::grey
if (! pathValueSource.isUsingProjectSettings())
return pathValueSource.isValidPath() ? Colours::grey
: Colours::lightpink;
return pathValueSource->isValidPath() ? Colours::black
return pathValueSource.isValidPath() ? Colours::black
: Colours::red;
}
@ -91,7 +104,7 @@ void DependencyPathPropertyComponent::labelTextChanged (Label*)
void DependencyPathPropertyComponent::editorShown (Label* /*label*/, TextEditor& editor)
{
if (! pathValueSource->isUsingProjectSettings())
if (! pathValueSource.isUsingProjectSettings())
editor.setText (String::empty, dontSendNotification);
}

View file

@ -54,18 +54,8 @@ class DependencyPathValueSource : public Value::ValueSource,
{
public:
DependencyPathValueSource (const Value& projectSettingsPath,
const Value& globalSettingsPath,
const String& fallbackPath,
String globalSettingsKey,
DependencyPathOS osThisSettingAppliesTo)
: projectSettingsValue (projectSettingsPath),
globalSettingsValue (globalSettingsPath),
fallbackValue (fallbackPath),
globalKey (globalSettingsKey),
os (osThisSettingAppliesTo)
{
globalSettingsValue.addListener (this);
}
DependencyPathOS osThisSettingAppliesTo = DependencyPath::getThisOS());
/** This gets the currently used value, which may be either
the project setting, the global setting, or the fallback value. */
@ -142,6 +132,16 @@ private:
/** the dependency path setting as set in this Introjucer project. */
Value projectSettingsValue;
/** the global key used in the application settings for the global setting value.
needed for checking whether the path is valid. */
String globalKey;
/** on what operating system should this dependency path be used?
note that this is *not* the os that is targeted by the project,
but rather the os on which the project will be compiled
(= on which the path settings need to be set correctly). */
DependencyPathOS os;
/** the dependency path global setting on this machine.
used when there value set for this project is invalid. */
Value globalSettingsValue;
@ -150,16 +150,6 @@ private:
whenever the latter doesn't apply, e.g. the setting is for another
OS than the ome this machine is running. */
String fallbackValue;
/** the global key used in the application settings for the global setting value.
needed for checking whether the path is valid. */
String globalKey;
/** on what operating system should this dependency path be used?
note that this is *not* the os that is targeted by the project,
but rather the os on which the project will be compiled
(= on which the path settings need to be set correctly). */
DependencyPathOS os;
};
@ -170,9 +160,7 @@ class DependencyPathPropertyComponent : public TextPropertyComponent,
{
public:
DependencyPathPropertyComponent (const Value& value,
const String& propertyName,
const String& globalKey,
DependencyPathOS os = DependencyPath::getThisOS());
const String& propertyName);
private:
@ -186,12 +174,12 @@ private:
/** This function handles path changes because the global path changed. */
void valueChanged (Value& value) override;
/** the value source of this dependency path setting. */
DependencyPathValueSource* pathValueSource;
/** the value object around the value source. */
/** the value that represents this dependency path setting. */
Value pathValue;
/** a reference to the value source that this value refers to. */
DependencyPathValueSource& pathValueSource;
// Label::Listener overrides:
void labelTextChanged (Label* labelThatHasChanged) override;
void editorShown (Label*, TextEditor&) override;