Project: titanium
Issue TIMOB-8812: BlackBerry: Implement important Titanium.UI.Clipboard functionality
Implement the methods for accessing and modifying data within the clipboard. h3. Acceptance Test {code:javascript} // Custom application MIME types for clipboard data. const kTypeText = 'application/x-text', kTypeBlob = 'application/x-blob'; var win = Ti.UI.createWindow({	backgroundColor: 'red',	layout: 'vertical' }); // Displays the current "plain text" in the clipboard. var textLabel = Ti.UI.createLabel({	text: Ti.UI.Clipboard.getText() || "No text." }); win.add(textLabel); // Displays the current custom text in the clipboard. var customTextLabel = Ti.UI.createLabel({	text: (Ti.UI.Clipboard.getData(kTypeText) || {text: 'No custom text.'}).text }); win.add(customTextLabel); // Displays the current custom blob data in the clipboard. var customBlobLabel = Ti.UI.createLabel({	text: (Ti.UI.Clipboard.getData(kTypeBlob) || {text: 'No custom blob.'}).text }); win.add(customBlobLabel); // Clears all data in clipboard. var clearDataButton = Ti.UI.createButton({	title: 'Clear Data' }); clearDataButton.addEventListener('click', function() {	Ti.UI.Clipboard.clearData(); }); win.add(clearDataButton); // Paste some text into the clipboard. var setTextButton = Ti.UI.createButton({	title: 'Set Text' }); setTextButton.addEventListener('click', function() {	Ti.UI.Clipboard.setText('Text Inserted!'); }); win.add(setTextButton); // Paste custom application data into the clipboard. var setCustomDataButton = Ti.UI.createButton({	title: 'Set Custom Data' }); setCustomDataButton.addEventListener('click', function() {	Ti.UI.Clipboard.setData(kTypeText, 'Custom Text!');	var buffer = Ti.createBuffer({length: 16});	'Custom Blob!'.split('').forEach(function(char, index) {	buffer.fill(char.charCodeAt(0), index, 1);	});	Ti.UI.Clipboard.setData(kTypeBlob, buffer.toBlob()); }); win.add(setCustomDataButton); win.open(); {code} # The three labels should display (in order from top to bottom)... #* No text. #* No custom text. #* No custom blob. # Click "Set Text" then restart the app. The first label should read "Text Inserted!" now. # Close the app and open another app on the device (ex: browser). Copy some text into the clipboard. # Relaunch the test case app and the first label should now contained the text you copied. # Click "Set Custom Data" then restart the app. # The second label should read "Custom Text!" and the third label "Custom Blob!". # Click "Clear Data" and restart the app. The labels should be back to their initial values (step 1).
Story points: 15