getting and setting application preferences with the App SDK - rally

How do you store and retrieve application preferences using the App SDK?
I see in some of the scripts they seem to use use:
rallyDataSource.preferences.getAppPreferences()
rallyDataSource.preferences.update()
rally.sdk.data.Preferences.parse()
Are these documented anywhere?
Thanks...

Those functions are for unsupported and undocumented in the AppSDK. We never were able to make the preference functionality simple enough for us to fully include in the AppSdk.
I would recommend saving the Preferences manually.
Here are some things to remember when dealing with preferences.
Preferences require a name and a scoping parameter.
The combination of the scoping and the name must be unique. This code will show you how to save a preference that is name spaced to your current workspace and namespace it by the apps current id. It will not work external to a Rally App tab unless you replace WORKSPACE_OID with a workspace's object id.
var value = { value : true };
rallyDataSource.create("preference",
{
Name: prefNameKey + rally.sdk.util.Context.getAppInfo().getAppId(),
Workspace: "/workspace/__WORKSPACE_OID__",
Value: dojo.toJson(value)
}, function() {
}, function() {
});

Related

Store an array on the app group for WidgetKit

I'm trying to store an struct array into the app group container to use it later on the widget.
let's assume, I have an array of string
let = array = ["object1", "object2", "object3"]
and I saw here I can access to the app group container url
let applicationGroupId = "group.com.development.widget"
guard let groupURL = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: applicationGroupId) else {
fatalError("could not get shared app group directory.")
}
Now, I need to know how I can store this array on app group and how I can read from it on the Widgetkit SwiftUI class
Your help will be appreciated.
Signing, Capabilities, Entitlements
Right now it should be possible to do all of this from within Xcode (12+). In the app's project settings go to the Signing & Capabilities tab and make sure Automatically manage signing is enabled and the Team has a valid development team (either company or personal account).
Tap on the + Capability button on the top left to enter the App Group Capability (this will also add an entitlements file). Now you will find an App Group section. Hit the + button for App Groups and enter a globally unique identifier (something like group.<appid>). This will create the app group on the developer platform and add it to your app's provisioning profile and entitlements.
You must repeat the same steps and use the same app group for all targets (app target, widget extension target and (optionally) intent targets). If you hit the reload button for the other targets' app group it should automatically show the app group you previously registered and you can check the checkbox. If not, hitting + and using the same id should work as well.
Finally, check all entitlements files and ensure that they have the same String in App Groups (copy and paste just to make sure).
Code
In code you now just have to access the user defaults using the chosen app group as suitName. To test whether everything is set up correctly, I would put the following line in application(_:didFinishLaunchingWithOptions):
UserDefaults(suiteName: "group.id.test")!.setValue(["object1", "object2", "object3"], forKey: "test")
In the Widget just try to put it in a Text view:
struct WidgetTestEntryView : View {
var entry: Provider.Entry
var text: String {
(UserDefaults(suiteName: "group.id.test")!.value(forKey: "test") as? [String])?.joined(separator: " ") ?? "Nothing stored yet"
}
var body: some View {
Text(text)
}
}
Note: I force unwrap the user defaults on purpose to fail early and check whether the setup of capabilities/signing worked. In production you should guard against a failure.
Alternative Storage
As you pointed out it's also possible to persist data in a shared container by writing to url provided by FileManager.default.containerURL(forSecurityApplicationGroupIdentifier:) but I don't think you need that for your simple example. If you want to share data that is more complex than String, Int, Array ... make sure to convert it to Data since user defaults cannot handle arbitrary data (even if it's Codable).
Manual Signing
If you use manual signing you just have to do the same step in the developer console starting with registering an app group. After that, add the group to all identifiers' capabilities and recreate all provisioning profiles. From there you should be use similar steps to the ones described above.

How to find the current Microphone MediaStream and apply constraints - WEBRTC

I want to edit the Microphone signal used by BigBlueButton conference and disable the Automatic Gain Control and Echo Cancelling.
However, I don't have information about the MediaStream instance used in the conference page. So, first issue is whether it is possible to find such active stream on the page? to later apply constraints to it. There is this question that says it is not possible to find active streams. But time has past and maybe options have changed. Plus, there might some other ways to get to this stream object.
Other than that, maybe there is a possibility to change the browsers' own flags for these AGC or AEC from a JS script or extension? (and not from the browser itself)
In a more specific detail of this issue: inside the BBB distribution I have looked for the js files ( sip.js and bbb_webrtc_bridge_sip.js) that use the getUserMedia method and I have edited them to give it the desired constraints, but to no avail. If someone knows about this specific platform I would like to ask for your help.
Note: In the mentioned page, there is an audio object that proves a srcObject which resolves to a MediaStream, I can access this and apply limited actions to it, but only in the echo test. Once past this test and inside the actual conference, access to this audio object has no effect.
Solution turned out to not access the MediaStream from a new JS script or extension but, in as in the specifics of the issue: from inside BigBlueButton JS files:
sip.js and bbb_wertc_bridge_sip.js files mentioned above belonged to the flash client, now out of use favouring the html5 client, so the right file to edit was:
/usr/share/meteor/bundle/programs/web.browser/app/compatibility/sip.js
and so what I did was to look for the instances of constraints or where the media stream is created, and inserted custom constraints and forced them in:
line 11941->. mediaHint = Object.keys(mediaHint || {}).length ? mediaHint : this.mediaHint;
replaced with-> mediaHint = this.mediaHint to force the entry into the following condition that creates a new stream with my own constraints in:
line 11956->
var constraints = mediaHint.constraints ||
(this.mediaHint && this.mediaHint.constraints) ||
{audio: true, video: true};
inserted my own constraints:
var constraints = {
audio: {
autoGainControl: false,
echoCancellation: false,
noiseSuppression: false,
},
video:false
};
This works and now these constraints disable AGC, AEC and NS.

Does the "/Volumes" name changes based on system language, if yes how to adapt this?

I am using this code to check if the client runs from DMG /Volume, and show an alert and quit.
private void IsRunningFromDMG()
{
var currentPath = NSBundle.MainBundle.BundlePath;
if (currentPath.StartsWith("/Volumes", StringComparison.Ordinal))
{
using (var alert = new NSAlert
{
MessageText = "Warning",
InformativeText = "You cannot run this application from DMG, drag move to the " +
"\"/Applications\" folder"
})
{
alert.RunModal();
NSApplication.SharedApplication.Terminate(null);
}
}
}
This is fine if the system language is set to English. I doubt if the /Volumes reacts to localization in that case how to do it?
There should be a system defined constant that would take care of it?
If it is, please help me to know what is it.
Filesystem paths do not change based on localization, they are localized for "display" though (i.e. Pictures, Music, etc... would be localized in Finder for display to the user but the filesystem path is still /User/xxx/Pictures, etc...)
Localized names. The system provides localized names for many system directories, such as Applications, Library, Music, Movies. An app may similarly provide localized names for itself and for any directories it creates.
Display names do not affect the actual name of the file in the file system. Code that accesses a file or directory programmatically must specify the item’s actual name when opening or manipulating the item using the file system interfaces. The only time your app should ever use display names is when displaying the name of a file or directory to the user. You can get the display name for any file or directory using the displayNameAtPath: method of NSFileManager.
i.e.
var urls = NSFileManager.DefaultManager.GetUrls(NSSearchPathDirectory.ApplicationsDirectory, NSSearchPathDomain.System);
var applicationDisplayName = NSFileManager.DefaultManager.DisplayName(urls[0].AbsoluteString);
Note: You should use NSSearchPathDirectory.AllApplicationsDirectory within the NSSearchPathDomain.All domain to obtain a valid list of "Application" urls where your application might/should be located at, instead of hard coding it to the "System" application location.

Custom Grid App

So I am trying to make modifications to the custom grid app that rally has already created. I found the source code at https://github.com/RallyApps/app-catalog/tree/master/src/apps/grid. However, I cannot get that code to work. I have added it to a js and then ran build (I also changed the json). However, when I then add the app to rally it doesn't give me the settings options (object, query, pagesize, etc) and just generates a table. This table generates 4 rows (the number of user stories I have), but the rows are completely blank except for gears at the beginning of each row. I was wondering if I was building this app incorrectly or if I had grabbed the wrong code. If not, is there a place where can I get the complete code or a way to modify the already existing code?
Thanks
You may add a fetch to the config as below:
config: {
defaultSettings: {
types: 'hierarchicalrequirement',
fetch: 'FormattedID,Name'
}
}
and it will display a grid.
It will not display settings dialog however. The source code in this github repo is not exactly the CustomGrid app available from the AppCatalog in the UI. It does not have the full functionality and not ready yet. I submitted a defect.

User Specific App Settings

I have started working with server side app settings and it would appear the default mechanics for a shared app is to save the app settings across the entire project scope; so if an individual makes changes to the app settings, those changes are reflected for all future users. This is not the ideal use in my specific case. I would like it if I could have different settings for each user, without them each adding separate instances of my custom HTML. Is this possible using server side settings, or will I need to look into using cookies to save the settings on each user?
Note: I've read the documentation on app setting scope (https://help.rallydev.com/apps/2.0rc1/doc/#!/guide/settings-section-define-scope) but it doesn't appear as though "user" is an option.
Thanks!
Conner, you're making a good argument for User-level settings for an app.
Unfortunately, we don't support that currently. The settingsScope option in AppSettings only supports the values app, project, or workspace.
Creating an instance of the app for each user (such as on their individual dashboard) is the best alternative I can think of. But as you mentioned, this is not ideal for you.
I have solved this issue by prepending the user ObjectID to each setting value before I save or load it from the Rally servers. Here is the code for my user settings set/get functions:
setUserSetting : function(settingName, settingValue, callback) {
var settings = {};
settings[App.getContext().getUser().ObjectID + settingName] = settingValue;
App.updateSettingsValues({
settings : settings,
success : function() {
App.setSettings(Ext.Object.merge(App.getSettings(), settings));
callback();
}
});
},
getUserSetting : function(settingName) {
return App.getSetting(App.getContext().getUser().ObjectID + settingName);
}
BTW, it seems kind of strange that I have to save the settings in the way I have. The "updateSettingsValues" function sets the settings on the next load of the app and the "setSettings" function sets it for the current runtime of the app. It's a strange way to have to do it, but it works.