*/
public SocialScreen() {
setBorder(BorderFactory.createBitmapBorder(new XYEdges(9, 9, 9, 9), Bitmap.getBitmapResource("border.png")));
setTitle(new LabelField("(: The Social App :)", DrawStyle.HCENTER|Field.FIELD_HCENTER));
filePickButton = new ButtonField("Photo Share", Field.FIELD_HCENTER) {
protected boolean navigationClick(int status, int time) {
FilePicker picker = FilePicker.getInstance();
picker.setFilter(".jpg:.png");
picker.setView(FilePicker.VIEW_PICTURES);
String path = picker.show();
if (path != null) {
// Creating the data context as a JSONObject
JSONObject context = new JSONObject();
try {
context.put(SendCommandContextKeys.PATH, path);
/**
* Since we are sharing a file path, you CANNOT add a
* SUBJECT or TEXT type data. Only PATH seems to be
* allowed.
*/
} catch (JSONException e) {
}
/**
* Getting the available SendCommand(s) for our SendCommand
* type TYPE_TEXT by providing our data context. The 3rd
* parameter is a boolean that indicates whether you want
* all results or just the results that are possible based on the context.
* Ideally this boolean param would be set to false,
* but there seems to be a bug with BBM as it throws an
* exception during the query. As a workaround, I am getting
* all first and then filtering out the ones I dont need.
*/
commandsAll = SendCommandRepository.getInstance().get(SendCommand.TYPE_PATH, context, true);
commands = new SendCommand[2];
for (int i = 0; i < commandsAll.length; i++) {
if (commandsAll[i].getId().equals(TWITTER_PATH_ID)) {
commands[0] = commandsAll[i];
}
if (commandsAll[i].getId().equals(FACEBOOK_PATH_ID)) {
commands[1] = commandsAll[i];
}
}
// Displays our SendCommands to the user.
displayCommands();
}
return true;
}
public int getPreferredWidth() {
return Display.getWidth()/2;
}
};
add(filePickButton);
add(new SeparatorField());
add(new SeparatorField());
add(new SeparatorField());
// An EditField to let the user type in the text to share.
textField = new EditField("", "Share this please.");
textField.setBorder(BorderFactory.createRoundedBorder(new XYEdges(3, 3, 3, 3)));
// A button that initiates the Text Share
shareTextButton = new ButtonField("Text Share", Field.FIELD_HCENTER) {
protected boolean navigationClick(int arg0, int arg1) {
// Creating the data context as a JSONObject
JSONObject context = new JSONObject();
try {
context.put(SendCommandContextKeys.TEXT, textField.getText());