Skip to content
This repository has been archived by the owner on Nov 7, 2019. It is now read-only.

Commit

Permalink
Enabled to create a new wave.
Browse files Browse the repository at this point in the history
  • Loading branch information
Santiago Martinez committed Aug 2, 2010
1 parent 3803b34 commit cfe48d5
Show file tree
Hide file tree
Showing 5 changed files with 148 additions and 3 deletions.
9 changes: 7 additions & 2 deletions android-gui/AndroidManifest.xml
Expand Up @@ -39,7 +39,12 @@
<category android:name="android.intent.category.DEFAULT"></category>
<action android:name="android.intent.action.VIEW"></action>
</intent-filter>
</activity>
</application>

</activity>
<activity android:name="NewWave"><intent-filter><action android:name="android.intent.action.VIEW"></action>
<category android:name="android.intent.category.DEFAULT"></category>
</intent-filter>
</activity>
</application>
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
</manifest>
68 changes: 68 additions & 0 deletions android-gui/res/layout/newwave.xml
@@ -0,0 +1,68 @@
<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout android:id="@+id/RelativeLayout01"
android:layout_width="wrap_content" android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android">

<TextView android:id="@+id/subjectLabel"
android:text="Subject"
android:layout_toLeftOf="@+id/subject"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingRight="5px"
android:paddingTop="5px"
android:layout_width="wrap_content"/>


<EditText android:id="@+id/subject"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/participanlabel"
android:gravity="top"/>

<TextView android:text="Participants"
android:id="@+id/participanlabel"
android:layout_below="@+id/subject"
android:layout_width="wrap_content"
android:gravity="center_vertical"
android:paddingRight="5px"
android:paddingTop="5px"
android:layout_height="wrap_content"/>

<EditText android:layout_toRightOf="@+id/participanlabel"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/subject"
android:id="@+id/participants"/>

<TextView android:id="@+id/messageLabel"
android:text="Message"
android:layout_below="@+id/participants"
android:layout_height="wrap_content"
android:layout_toLeftOf="@+id/message"
android:gravity="center_vertical"
android:paddingRight="5px"
android:paddingTop="5px"
android:layout_width="wrap_content"/>


<EditText android:id="@+id/message"
android:lines="10"
android:layout_toRightOf="@+id/participanlabel"
android:layout_height="100dip"
android:layout_width="fill_parent"
android:inputType="textMultiLine"
android:gravity="top"
android:layout_below="@+id/participants" />


<Button android:text="Create"
android:layout_toRightOf="@+id/messageLabel"
android:id="@+id/create"
android:layout_below="@+id/message"
android:layout_height="wrap_content"
android:layout_width="wrap_content"/>


</RelativeLayout>

53 changes: 53 additions & 0 deletions android-gui/src/net/processone/awc/NewWave.java
@@ -0,0 +1,53 @@
package net.processone.awc;

import java.util.HashSet;
import java.util.Set;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

public class NewWave extends Activity {

private OneWave ow;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

ow = (OneWave) getApplication();

setContentView(R.layout.newwave);

Button b = (Button) findViewById(R.id.create);

b.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
EditText textView = (EditText) findViewById(R.id.participants);
String[] p = textView.getText().toString().split(";"); //TODO improve this

Set<String> participants = new HashSet<String>();

for (String s : p)
participants.add(s.trim());

EditText subject = (EditText) findViewById(R.id.subject);

EditText message = (EditText) findViewById(R.id.message);

ow.createWave(subject.getText().toString(), participants,
message.getText().toString());
}
});

}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
}
}
18 changes: 17 additions & 1 deletion android-gui/src/net/processone/awc/OneWave.java
@@ -1,5 +1,7 @@
package net.processone.awc;

import java.util.Set;

import net.processone.oauth.ClientSettings;
import net.processone.oauth.Token;
import net.processone.wave.api.OneWaveAPI;
Expand Down Expand Up @@ -54,8 +56,22 @@ public SearchResult search(String query, int index, int count) {
return null;
}

public void createWave(String subject, Set<String> participants,
String message) {

try {
Wavelet w = waveAPI.newWavelet(participants);
w.setTitle(subject);
w.getRootBlip().appendMarkup(message);
waveAPI.send(w);
} catch (OneWaveException e) {
Log.e(getClass().getName(), e.getLocalizedMessage(), e);
}

}

public Wavelet fetchWavelet(WaveId waveId) {

try {
return waveAPI.fetchWavelet(waveId);
} catch (OneWaveException e) {
Expand Down
3 changes: 3 additions & 0 deletions android-gui/src/net/processone/awc/WaveList.java
Expand Up @@ -90,6 +90,9 @@ public boolean onCreateOptionsMenu(Menu menu) {
public boolean onMenuItemSelected(int featureId, MenuItem item) {
switch(item.getItemId()) {
case R.id.newWave:

startActivity(new Intent(this, NewWave.class));

return true;
case R.id.refresh:
showDialog(RELOAD);
Expand Down

0 comments on commit cfe48d5

Please sign in to comment.