commit 740c8c277412db9c466bc62820a0d8d5ab12118d
parent f266afe72f6261e412777b2eeb3180e6e4b8c8ff
Author: Jan Dankert <devnull@localhost>
Date: Thu, 2 Feb 2012 23:27:33 +0100
Schreibzuriff: Nachrichten schreiben, Neue Themen, Antworten verfassen.
Diffstat:
17 files changed, 912 insertions(+), 13 deletions(-)
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
@@ -32,6 +32,11 @@
<activity android:name="MailboxActivity" android:label="@string/news"></activity>
<activity android:name="MailActivity" android:label="@string/news"></activity>
<activity android:name="MessageActivity" android:label="@string/news"></activity>
+ <activity android:name="ReplyMailActivity" android:label="@string/mailbox"></activity>
+ <activity android:name="ReplyPostActivity" android:label="@string/mailbox"></activity>
+ <activity android:name="CreateTopicActivity" android:label="@string/mailbox"></activity>
+ <activity android:name="SubscriptionForenActivity" android:label="@string/mailbox"></activity>
+ <activity android:name="SubscriptionTopicsActivity" android:label="@string/mailbox"></activity>
<!-- declare the default searchable Activity for the whole app -->
<meta-data android:name="android.app.default_searchable"
diff --git a/res/layout/post.xml b/res/layout/post.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent" android:layout_height="fill_parent">
+
+ <LinearLayout android:orientation="vertical"
+ android:layout_width="fill_parent" android:layout_height="wrap_content"
+ android:paddingLeft="5sp" android:background="#E3E3E3">
+
+
+ <TextView android:layout_width="wrap_content" android:text="@string/subject"
+ android:layout_height="wrap_content" style="@style/normalText"></TextView>
+ <EditText android:id="@+id/subject" android:layout_width="fill_parent"
+ android:layout_height="wrap_content" />
+
+ <TextView android:layout_width="wrap_content" android:text="@string/recipient"
+ android:layout_height="wrap_content" style="@style/normalText"></TextView>
+ <EditText android:id="@+id/recipient" android:layout_width="fill_parent"
+ android:layout_height="wrap_content" />
+
+ <TextView android:text="@string/text" android:layout_width="wrap_content"
+ android:layout_height="wrap_content" style="@style/titleText"></TextView>
+ <EditText android:layout_width="fill_parent"
+ android:layout_height="fill_parent" android:id="@+id/content"></EditText>
+
+ <Button android:text="@string/send" android:layout_width="fill_parent"
+ android:layout_height="wrap_content" android:id="@+id/send" style="@style/normalText"></Button>
+
+ </LinearLayout>
+
+</ScrollView>+
\ No newline at end of file
diff --git a/res/menu/forum.xml b/res/menu/forum.xml
@@ -1,6 +1,8 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/menu_mailbox" android:title="@string/mailbox"
android:icon="@android:drawable/ic_menu_send"></item>
+ <item android:id="@+id/menu_create_topic" android:title="@string/new_topic"
+ android:icon="@android:drawable/ic_menu_edit"></item>
<item android:id="@+id/menu_participated_topics" android:title="@string/participated_topics"
android:icon="@android:drawable/ic_menu_view"></item>
<item android:id="@+id/menu_latest_topics" android:title="@string/latest_topics"
diff --git a/res/menu/message.xml b/res/menu/message.xml
@@ -0,0 +1,7 @@
+<menu xmlns:android="http://schemas.android.com/apk/res/android">
+
+ <item android:id="@+id/menu_reply" android:title="@string/reply"
+ android:icon="@android:drawable/ic_menu_gallery"></item>
+
+</menu>
+ +
\ No newline at end of file
diff --git a/res/values/ibc.xml b/res/values/ibc.xml
@@ -33,7 +33,7 @@
<style name="normalText">
<item name="android:background">#E3E3E3</item>
- <item name="android:textSize">13sp</item>
+ <item name="android:textSize">16sp</item>
<item name="android:textColor">#000000</item>
</style>
<style name="titleText">
diff --git a/res/values/strings.xml b/res/values/strings.xml
@@ -14,6 +14,10 @@
<string name="mailbox">Nachrichten</string>
<string name="hostname">Hostname</string>
<string name="password">Kennwort</string>
+ <string name="subject">Betreff</string>
+ <string name="text">Text</string>
+ <string name="send">Senden</string>
+ <string name="recipient">Empfänger</string>
<string name="port">Port</string>
<string name="version">Version</string>
<string name="connect">Mit Server verbinden</string>
@@ -135,6 +139,8 @@
<string name="goto_top">Nach oben</string>
<string name="goto_buttom">Nach unten</string>
<string name="reply">Antworten</string>
+ <string name="sent_ok">Nachricht wurde veschickt</string>
+ <string name="sent_fail">Nicht verschickt</string>
<string name="new_topic">Neues Thema</string>
<string name="parse_bbcode">BB-Code auswerten</string>
<string name="parse_bbcode_desc">In Forumbeiträgen den BB-Code auflösen. Kann die Anzeige von Beiträgen stark verlangsamen.</string>
diff --git a/src/de/mtbnews/android/CreateTopicActivity.java b/src/de/mtbnews/android/CreateTopicActivity.java
@@ -0,0 +1,96 @@
+package de.mtbnews.android;
+
+import java.io.IOException;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.os.Bundle;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.Button;
+import android.widget.TextView;
+import android.widget.Toast;
+import de.mtbnews.android.tapatalk.TapatalkClient;
+import de.mtbnews.android.tapatalk.TapatalkException;
+import de.mtbnews.android.util.ServerAsyncTask;
+
+public class CreateTopicActivity extends Activity
+{
+ private String forumId;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState)
+ {
+ if (((IBCApplication) getApplication()).ibcTheme)
+ setTheme(R.style.IBC);
+
+ setContentView(R.layout.post);
+ super.onCreate(savedInstanceState);
+
+ forumId = getIntent().getStringExtra("forum_id");
+
+ new ServerAsyncTask(this, R.string.waitingforcontent)
+ {
+ private TapatalkClient client;
+
+ @Override
+ protected void callServer() throws IOException
+ {
+ client = ((IBCApplication) getApplication())
+ .getTapatalkClient();
+ // try
+ // {
+ // message = client.getMessage(boxId, messageId);
+ // }
+ // catch (TapatalkException e)
+ // {
+ // throw new RuntimeException(e);
+ // }
+ }
+
+ protected void doOnSuccess()
+ {
+ // MessageActivity.this.setTitle(feed.getTitle());
+
+ final TextView recipient = (TextView) findViewById(R.id.recipient);
+ recipient.setText("");
+ recipient.setVisibility(View.INVISIBLE);
+
+ // TextView name = (TextView) findViewById(R.id.item_title);
+ // name.setText(item.getTitle());
+
+ final TextView subject = (TextView) findViewById(R.id.subject);
+ subject.setText("");
+
+ final TextView text = (TextView) findViewById(R.id.content);
+ text.setText("");
+
+ Button button = (Button) findViewById(R.id.send);
+ button.setOnClickListener(new OnClickListener()
+ {
+ @Override
+ public void onClick(View v)
+ {
+ try
+ {
+ client.createTopic(forumId, subject.getText()
+ .toString(), text.getText().toString());
+ Toast.makeText(CreateTopicActivity.this,
+ R.string.sent_ok, Toast.LENGTH_LONG);
+ CreateTopicActivity.this.finish();
+ }
+ catch (TapatalkException e)
+ {
+ new AlertDialog.Builder(CreateTopicActivity.this)
+ .setTitle(R.string.sent_fail).setMessage(
+ e.getMessage()).show();
+ }
+ }
+ });
+
+ }
+ }.execute();
+
+ }
+
+}
diff --git a/src/de/mtbnews/android/ForumActivity.java b/src/de/mtbnews/android/ForumActivity.java
@@ -205,6 +205,12 @@ public class ForumActivity extends EndlessListActivity<Topic>
case R.id.menu_mailbox:
startActivity(new Intent(this, MailboxActivity.class));
return true;
+
+ case R.id.menu_create_topic:
+ Intent intent5 = new Intent(this, CreateTopicActivity.class);
+ intent5.putExtra("forum_id",forumId);
+ startActivity(intent5);
+ return true;
case R.id.menu_participated_topics:
Intent intent = new Intent(this, SearchActivity.class);
diff --git a/src/de/mtbnews/android/MailActivity.java b/src/de/mtbnews/android/MailActivity.java
@@ -10,6 +10,7 @@ import android.widget.AdapterView;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.AdapterView.OnItemClickListener;
+import android.widget.AdapterView.OnItemLongClickListener;
import de.mtbnews.android.adapter.ListEntryContentAdapter;
import de.mtbnews.android.tapatalk.TapatalkClient;
import de.mtbnews.android.tapatalk.TapatalkException;
@@ -32,8 +33,6 @@ public class MailActivity extends EndlessListActivity<Message>
super.onCreate(savedInstanceState);
- setContentView(R.layout.listing);
-
boxId = getIntent().getStringExtra("box_id");
ListAdapter adapter = new ListEntryContentAdapter(MailActivity.this,
@@ -42,9 +41,9 @@ public class MailActivity extends EndlessListActivity<Message>
initialLoad();
- final ListView list2 = getListView();
+ final ListView list = getListView();
- list2.setOnItemClickListener(new OnItemClickListener()
+ list.setOnItemClickListener(new OnItemClickListener()
{
@Override
@@ -53,8 +52,24 @@ public class MailActivity extends EndlessListActivity<Message>
{
Intent i = new Intent(MailActivity.this, MessageActivity.class);
i.putExtra("box_id", boxId);
- i.putExtra("message_id", MailActivity.super.entries.get(position).id);
+ i.putExtra("message_id", MailActivity.super.entries
+ .get(position).id);
+ startActivity(i);
+ }
+ });
+ list.setOnItemLongClickListener(new OnItemLongClickListener()
+ {
+ @Override
+ public boolean onItemLongClick(AdapterView<?> arg0, View arg1,
+ int arg2, long arg3)
+ {
+ Intent i = new Intent(MailActivity.this,
+ ReplyMailActivity.class);
+ i.putExtra("box_id", boxId);
+ i.putExtra("message_id",
+ MailActivity.super.entries.get(arg2).id);
startActivity(i);
+ return true;
}
});
diff --git a/src/de/mtbnews/android/MessageActivity.java b/src/de/mtbnews/android/MessageActivity.java
@@ -5,11 +5,16 @@ import java.io.IOException;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
+import android.text.TextUtils;
import android.text.format.DateFormat;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
+import android.widget.Toast;
import de.mtbnews.android.tapatalk.TapatalkClient;
import de.mtbnews.android.tapatalk.TapatalkException;
import de.mtbnews.android.tapatalk.wrapper.Message;
@@ -86,4 +91,31 @@ public class MessageActivity extends Activity
}.execute();
}
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu)
+ {
+ super.onCreateOptionsMenu(menu);
+ MenuInflater mi = new MenuInflater(getApplication());
+
+ mi.inflate(R.menu.message, menu);
+
+ return true;
+ }
+
+ public boolean onOptionsItemSelected(MenuItem item)
+ {
+ switch (item.getItemId())
+ {
+ case R.id.menu_reply:
+ Intent intent = new Intent(this, ReplyMailActivity.class);
+ intent.putExtra("message_id", messageId);
+ intent.putExtra("box_id", boxId);
+ startActivity(intent);
+ return true;
+
+ }
+ return false;
+ }
+
}
diff --git a/src/de/mtbnews/android/ReplyMailActivity.java b/src/de/mtbnews/android/ReplyMailActivity.java
@@ -0,0 +1,101 @@
+package de.mtbnews.android;
+
+import java.io.IOException;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.os.Bundle;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.Button;
+import android.widget.TextView;
+import android.widget.Toast;
+import de.mtbnews.android.tapatalk.TapatalkClient;
+import de.mtbnews.android.tapatalk.TapatalkException;
+import de.mtbnews.android.tapatalk.wrapper.Message;
+import de.mtbnews.android.util.ServerAsyncTask;
+
+public class ReplyMailActivity extends Activity
+{
+ private String boxId;
+ private String messageId;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState)
+ {
+ if (((IBCApplication) getApplication()).ibcTheme)
+ setTheme(R.style.IBC);
+
+ setContentView(R.layout.post);
+ super.onCreate(savedInstanceState);
+
+ boxId = getIntent().getStringExtra("box_id");
+ messageId = getIntent().getStringExtra("message_id");
+
+ new ServerAsyncTask(this, R.string.waitingforcontent)
+ {
+ private Message message;
+ private TapatalkClient client;
+
+ @Override
+ protected void callServer() throws IOException
+ {
+ client = ((IBCApplication) getApplication())
+ .getTapatalkClient();
+ try
+ {
+ message = client.getMessage(boxId, messageId);
+ }
+ catch (TapatalkException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ protected void doOnSuccess()
+ {
+ // MessageActivity.this.setTitle(feed.getTitle());
+
+ final TextView recipient = (TextView) findViewById(R.id.recipient);
+ recipient.setText(message.from);
+
+ // TextView name = (TextView) findViewById(R.id.item_title);
+ // name.setText(item.getTitle());
+
+ final TextView subject = (TextView) findViewById(R.id.subject);
+ subject.setText(message.subject.startsWith("Re: ") ? ""
+ : "Re: " + message.subject);
+
+ final TextView text = (TextView) findViewById(R.id.content);
+ text.setText("[quote]" + message.getContent() + "[/quote]\n\n");
+
+ Button button = (Button) findViewById(R.id.send);
+ button.setOnClickListener(new OnClickListener()
+ {
+ @Override
+ public void onClick(View v)
+ {
+ try
+ {
+ client.createMessage(new String[] { recipient
+ .getText().toString() }, subject.getText()
+ .toString(), text.getText().toString());
+ Toast.makeText(ReplyMailActivity.this,
+ R.string.sent_ok, Toast.LENGTH_LONG);
+ ReplyMailActivity.this.finish();
+ }
+ catch (TapatalkException e)
+ {
+ new AlertDialog.Builder(ReplyMailActivity.this)
+ .setTitle(R.string.sent_fail).setMessage(
+ e.getMessage()).show();
+ }
+ }
+ });
+
+ }
+ }.execute();
+
+ }
+
+}
diff --git a/src/de/mtbnews/android/ReplyPostActivity.java b/src/de/mtbnews/android/ReplyPostActivity.java
@@ -0,0 +1,102 @@
+package de.mtbnews.android;
+
+import java.io.IOException;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.os.Bundle;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.Button;
+import android.widget.TextView;
+import android.widget.Toast;
+import de.mtbnews.android.tapatalk.TapatalkClient;
+import de.mtbnews.android.tapatalk.TapatalkException;
+import de.mtbnews.android.util.ServerAsyncTask;
+
+public class ReplyPostActivity extends Activity
+{
+ private String forumId;
+ private String topicId;
+ private String subject;
+ private String quote;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState)
+ {
+ if (((IBCApplication) getApplication()).ibcTheme)
+ setTheme(R.style.IBC);
+
+ setContentView(R.layout.post);
+ super.onCreate(savedInstanceState);
+
+ topicId = getIntent().getStringExtra("topic_id");
+ forumId = getIntent().getStringExtra("forum_id");
+ subject = getIntent().getStringExtra("subject");
+ quote = getIntent().getStringExtra("quote");
+
+ new ServerAsyncTask(this, R.string.waitingforcontent)
+ {
+ private TapatalkClient client;
+
+ @Override
+ protected void callServer() throws IOException
+ {
+ client = ((IBCApplication) getApplication())
+ .getTapatalkClient();
+ // try
+ // {
+ // message = client.getMessage(boxId, messageId);
+ // }
+ // catch (TapatalkException e)
+ // {
+ // throw new RuntimeException(e);
+ // }
+ }
+
+ protected void doOnSuccess()
+ {
+ ReplyPostActivity.this.setTitle(R.string.reply);
+
+ final TextView recipient = (TextView) findViewById(R.id.recipient);
+ recipient.setVisibility(View.INVISIBLE);
+
+ final TextView subject = (TextView) findViewById(R.id.subject);
+ subject
+ .setText(ReplyPostActivity.this.subject != null ? ReplyPostActivity.this.subject
+ : "");
+
+ final TextView text = (TextView) findViewById(R.id.content);
+ text.setText(quote != null ? "[quote]"+quote+"[/quote]" : "");
+
+ Button button = (Button) findViewById(R.id.send);
+ button.setOnClickListener(new OnClickListener()
+ {
+
+ @Override
+ public void onClick(View v)
+ {
+ try
+ {
+ client.createReply(forumId, topicId, subject
+ .getText().toString(), text.getText()
+ .toString());
+ Toast.makeText(ReplyPostActivity.this,
+ R.string.sent_ok, Toast.LENGTH_LONG);
+ ReplyPostActivity.this.finish();
+ }
+ catch (TapatalkException e)
+ {
+ new AlertDialog.Builder(ReplyPostActivity.this)
+ .setTitle(R.string.sent_fail).setMessage(
+ e.getMessage()).show();
+ }
+ }
+ });
+
+ }
+ }.execute();
+
+ }
+
+}
diff --git a/src/de/mtbnews/android/SubscriptionForenActivity.java b/src/de/mtbnews/android/SubscriptionForenActivity.java
@@ -0,0 +1,302 @@
+/**
+ *
+ */
+package de.mtbnews.android;
+
+import java.io.IOException;
+import java.util.Map;
+
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.os.Bundle;
+import android.preference.PreferenceManager;
+import android.text.TextUtils;
+import android.view.ContextMenu;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.ContextMenu.ContextMenuInfo;
+import android.view.View.OnCreateContextMenuListener;
+import android.widget.AdapterView;
+import android.widget.ListAdapter;
+import android.widget.ListView;
+import android.widget.Toast;
+import android.widget.AdapterView.OnItemClickListener;
+import de.mtbnews.android.adapter.ListEntryContentAdapter;
+import de.mtbnews.android.tapatalk.TapatalkClient;
+import de.mtbnews.android.tapatalk.TapatalkException;
+import de.mtbnews.android.tapatalk.wrapper.Forum;
+import de.mtbnews.android.tapatalk.wrapper.Topic;
+import de.mtbnews.android.util.ServerAsyncTask;
+
+/**
+ * @author dankert
+ *
+ */
+public class SubscriptionForenActivity extends EndlessListActivity<Topic>
+{
+ private SharedPreferences prefs;
+ private int totalSize;
+ private String forumId;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState)
+ {
+ if (((IBCApplication) getApplication()).ibcTheme)
+ setTheme(R.style.IBC);
+
+ super.onCreate(savedInstanceState);
+
+ setContentView(R.layout.listing);
+
+ prefs = PreferenceManager.getDefaultSharedPreferences(this);
+
+ TapatalkClient client = ((IBCApplication) getApplication())
+ .getTapatalkClient();
+
+ if (!client.loggedIn && prefs.getBoolean("auto_login", false))
+ {
+ login();
+ }
+
+ forumId = getIntent().getStringExtra("forum_id");
+
+ ListAdapter adapter = new ListEntryContentAdapter(SubscriptionForenActivity.this,
+ entries);
+ setListAdapter(adapter);
+ initialLoad();
+
+ // TODO: ggf. das hier in die Oberklasse?
+ ListView list = getListView();
+ list.setOnCreateContextMenuListener(new OnCreateContextMenuListener()
+ {
+
+ @Override
+ public void onCreateContextMenu(ContextMenu menu, View v,
+ ContextMenuInfo menuInfo)
+ {
+ MenuInflater menuInflater = new MenuInflater(getApplication());
+ menuInflater.inflate(R.menu.topic_context, menu);
+
+ }
+ });
+ list.setOnItemClickListener(new OnItemClickListener()
+ {
+ @Override
+ public void onItemClick(AdapterView<?> parent, View view,
+ int position, long id)
+ {
+ // int aktPosition = displayFrom + position + 1;
+ final Intent intent = new Intent(SubscriptionForenActivity.this,
+ TopicActivity.class);
+ Topic topic = SubscriptionForenActivity.super.entries.get(position);
+ intent.putExtra(TopicActivity.TOPIC_ID, topic.getId());
+ startActivity(intent);
+ }
+ });
+ }
+
+ // TODO: Das auch in die anderen Listviews einbauen.
+ @Override
+ public boolean onContextItemSelected(MenuItem item)
+ {
+ AdapterView.AdapterContextMenuInfo menuInfo = (AdapterView.AdapterContextMenuInfo) item
+ .getMenuInfo();
+
+ switch (item.getItemId())
+ {
+ case R.id.menu_goto_top:
+
+ final Intent intent = new Intent(SubscriptionForenActivity.this,
+ TopicActivity.class);
+ intent.putExtra("topic_id", super.entries
+ .get(menuInfo.position).getId());
+ intent.putExtra("first_post", true);
+ startActivity(intent);
+ return true;
+
+ case R.id.menu_goto_bottom:
+
+ final Intent intent2 = new Intent(SubscriptionForenActivity.this,
+ TopicActivity.class);
+ intent2.putExtra("topic_id", super.entries.get(
+ menuInfo.position).getId());
+ intent2.putExtra("last_post", true);
+ startActivity(intent2);
+ return true;
+ }
+
+ return super.onContextItemSelected(item);
+ }
+
+ private void login()
+ {
+ final TapatalkClient client = ((IBCApplication) getApplication()).client;
+ new ServerAsyncTask(this, R.string.waitingfor_login)
+ {
+
+ @Override
+ protected synchronized void callServer() throws IOException
+ {
+
+ try
+ {
+ Map<String, Object> map = client.login(prefs.getString(
+ "username", ""), prefs.getString("password", ""));
+
+ }
+ catch (TapatalkException e)
+ {
+ e.printStackTrace();
+ throw new RuntimeException(e);
+ }
+
+ }
+
+ }.executeSynchronized();
+ }
+
+ private void logout()
+ {
+ final TapatalkClient client = ((IBCApplication) getApplication()).client;
+
+ new ServerAsyncTask(this, R.string.waitingfor_logout)
+ {
+
+ @Override
+ protected synchronized void callServer() throws IOException
+ {
+
+ try
+ {
+ client.logout();
+
+ }
+ catch (TapatalkException e)
+ {
+ e.printStackTrace();
+ throw new RuntimeException(e);
+ }
+
+ }
+
+ }.executeSynchronized();
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu)
+ {
+ super.onCreateOptionsMenu(menu);
+ MenuInflater mi = new MenuInflater(getApplication());
+
+ if (((IBCApplication) getApplication()).client.loggedIn)
+ mi.inflate(R.menu.forum, menu);
+ else
+ mi.inflate(R.menu.forum_guest, menu);
+
+ return true;
+ }
+
+ public boolean onOptionsItemSelected(MenuItem item)
+ {
+ switch (item.getItemId())
+ {
+ case R.id.menu_mailbox:
+ startActivity(new Intent(this, MailboxActivity.class));
+ return true;
+
+ case R.id.menu_participated_topics:
+ Intent intent = new Intent(this, SearchActivity.class);
+ intent
+ .setAction(SearchActivity.ACTION_SEARCH_PARTICIPATED_TOPICS);
+ startActivity(intent);
+ return true;
+
+ case R.id.menu_latest_topics:
+ Intent intent2 = new Intent(this, SearchActivity.class);
+ intent2.setAction(SearchActivity.ACTION_SEARCH_LATEST_TOPICS);
+ startActivity(intent2);
+ return true;
+ case R.id.menu_unread_topics:
+ Intent intent3 = new Intent(this, SearchActivity.class);
+ intent3.setAction(SearchActivity.ACTION_SEARCH_UNREAD_TOPICS);
+ startActivity(intent3);
+ return true;
+
+ case R.id.menu_logout:
+ logout();
+ return true;
+
+ case R.id.menu_login:
+
+ if (TextUtils.isEmpty(prefs.getString("username", "")))
+ {
+ Toast
+ .makeText(this, R.string.nousername,
+ Toast.LENGTH_LONG).show();
+
+ Intent intent4 = new Intent(this, Configuration.class);
+ startActivity(intent4);
+ }
+ // Evtl. gibt es jetzt einen Benutzernamen ...
+
+ if (!TextUtils.isEmpty(prefs.getString("username", "")))
+ {
+ login();
+ }
+ else
+ {
+ Toast
+ .makeText(this, R.string.nousername,
+ Toast.LENGTH_LONG).show();
+ }
+
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ protected int getTotalSize()
+ {
+ return totalSize;
+ }
+
+ @Override
+ protected void loadEntries(
+ final de.mtbnews.android.EndlessListActivity.OnListLoadedListener<Topic> onListLoaded,
+ final int from, final int to, boolean firstLoad)
+ {
+
+ new ServerAsyncTask(this, R.string.waitingfor_forum)
+ {
+ private Forum forum;
+
+ @Override
+ protected void callServer() throws IOException
+ {
+
+ TapatalkClient client = ((IBCApplication) getApplication()).client;
+ try
+ {
+ this.forum = client.getForum(forumId, from, to);
+ totalSize = this.forum.topicCount;
+ }
+ catch (TapatalkException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ protected void doOnSuccess()
+ {
+ SubscriptionForenActivity.this.setTitle(forum.getTitle());
+ onListLoaded.listLoaded(this.forum.getTopics());
+ }
+
+ }.execute();
+
+ }
+
+}
diff --git a/src/de/mtbnews/android/SubscriptionTopicsActivity.java b/src/de/mtbnews/android/SubscriptionTopicsActivity.java
@@ -0,0 +1,121 @@
+/**
+ *
+ */
+package de.mtbnews.android;
+
+import java.io.IOException;
+import java.util.List;
+
+import android.os.Bundle;
+import android.view.View;
+import android.widget.AdapterView;
+import android.widget.ListAdapter;
+import android.widget.ListView;
+import android.widget.Toast;
+import android.widget.AdapterView.OnItemClickListener;
+import de.mtbnews.android.adapter.ListEntryContentAdapter;
+import de.mtbnews.android.tapatalk.TapatalkClient;
+import de.mtbnews.android.tapatalk.TapatalkException;
+import de.mtbnews.android.tapatalk.wrapper.Post;
+import de.mtbnews.android.tapatalk.wrapper.Topic;
+import de.mtbnews.android.util.ServerAsyncTask;
+
+/**
+ * Anzeige aller Beiträge eines Themas.
+ *
+ * @author dankert
+ *
+ */
+public class SubscriptionTopicsActivity extends EndlessListActivity<Post>
+{
+ public static final String TOPIC_ID = "topic_id";
+
+ private int totalSize;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState)
+ {
+ if (((IBCApplication) getApplication()).ibcTheme)
+ setTheme(R.style.IBC);
+
+ super.onCreate(savedInstanceState);
+
+ setContentView(R.layout.listing);
+
+ ListAdapter adapter = new ListEntryContentAdapter(SubscriptionTopicsActivity.this,
+ entries);
+ setListAdapter(adapter);
+
+ initialLoad();
+
+ final ListView list = getListView();
+
+ list.setOnItemClickListener(new OnItemClickListener()
+ {
+ @Override
+ public void onItemClick(AdapterView<?> parent, View view,
+ int position, long id)
+ {
+ int aktPosition = displayFrom + position + 1;
+ Toast.makeText(SubscriptionTopicsActivity.this, "" + aktPosition,
+ Toast.LENGTH_SHORT).show();
+
+ // final Intent intent = new Intent(TopicActivity.this,
+ // PostActivity.class);
+ // intent.putExtra("itemid", position);
+ // startActivity(intent);
+ }
+ });
+
+ Toast.makeText(this, R.string.hint_press_long, Toast.LENGTH_SHORT)
+ .show();
+ }
+
+ @Override
+ protected int getTotalSize()
+ {
+ return this.totalSize;
+ }
+
+ @Override
+ protected void loadEntries(
+ final OnListLoadedListener<Post> onListLoadedListener,
+ final int from, final int to, boolean firstLoad)
+ {
+ new ServerAsyncTask(SubscriptionTopicsActivity.this,
+ firstLoad ? R.string.waitingfor_topic
+ : R.string.waitingfor_loadmore)
+ {
+ private List<Post> posts;
+ private Topic topic;
+
+ @Override
+ protected void callServer() throws IOException
+ {
+ TapatalkClient client = ((IBCApplication) getApplication()).client;
+
+ try
+ {
+ String topicId = SubscriptionTopicsActivity.this.getIntent()
+ .getStringExtra(TOPIC_ID);
+
+ topic = client.getTopic(topicId, from, to);
+
+ totalSize = topic.getPostCount();
+ this.posts = topic.getPosts();
+ }
+ catch (TapatalkException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ protected void doOnSuccess()
+ {
+ SubscriptionTopicsActivity.this.setTitle(topic.getTitle());
+ onListLoadedListener.listLoaded(this.posts);
+ }
+
+ }.execute();
+ }
+}
diff --git a/src/de/mtbnews/android/TopicActivity.java b/src/de/mtbnews/android/TopicActivity.java
@@ -6,7 +6,11 @@ package de.mtbnews.android;
import java.io.IOException;
import java.util.List;
+import android.content.Intent;
import android.os.Bundle;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListAdapter;
@@ -30,8 +34,12 @@ public class TopicActivity extends EndlessListActivity<Post>
{
public static final String TOPIC_ID = "topic_id";
- private int totalSize;
+ private String forumId;
+ private String topicId;
+ private String topicTitle;
+ private int totalSize;
+
@Override
protected void onCreate(Bundle savedInstanceState)
{
@@ -40,6 +48,9 @@ public class TopicActivity extends EndlessListActivity<Post>
super.onCreate(savedInstanceState);
+ topicId = TopicActivity.this.getIntent().getStringExtra(TOPIC_ID);
+ //forumId = TopicActivity.this.getIntent().getStringExtra("forum_id");
+
setContentView(R.layout.listing);
ListAdapter adapter = new ListEntryContentAdapter(TopicActivity.this,
@@ -96,11 +107,11 @@ public class TopicActivity extends EndlessListActivity<Post>
try
{
- String topicId = TopicActivity.this.getIntent()
- .getStringExtra(TOPIC_ID);
topic = client.getTopic(topicId, from, to);
+ forumId = topic.forumId;
+ topicTitle = topic.getTitle();
totalSize = topic.getPostCount();
this.posts = topic.getPosts();
}
@@ -118,4 +129,32 @@ public class TopicActivity extends EndlessListActivity<Post>
}.execute();
}
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu)
+ {
+ super.onCreateOptionsMenu(menu);
+ MenuInflater mi = new MenuInflater(getApplication());
+
+ mi.inflate(R.menu.message, menu);
+
+ return true;
+ }
+
+ public boolean onOptionsItemSelected(MenuItem item)
+ {
+ switch (item.getItemId())
+ {
+ case R.id.menu_reply:
+ Intent intent = new Intent(this, ReplyPostActivity.class);
+ intent.putExtra("topic_id", topicId);
+ intent.putExtra("forum_id", forumId);
+ intent.putExtra("subject", topicTitle);
+ startActivity(intent);
+ return true;
+
+ }
+ return false;
+ }
+
}
diff --git a/src/de/mtbnews/android/tapatalk/TapatalkClient.java b/src/de/mtbnews/android/tapatalk/TapatalkClient.java
@@ -103,6 +103,7 @@ public class TapatalkClient
List<Post> posts = new ArrayList<Post>();
Topic topic = new Topic(id, posts, title, null, null, null,
postCount);
+ topic.forumId = (String) map.get("forum_id");
for (Object o1 : (Object[]) map.get("posts"))
{
@@ -415,7 +416,19 @@ public class TapatalkClient
final Object[] params = new Object[] { forumId, subject.getBytes(),
content.getBytes() };
- Map mapMap = toMap(client.callEx("new_topic", params));
+ Object o = client.callEx("new_topic", params);
+ Map map = (Map) o;
+
+ Object object = map.get("result");
+
+ boolean ok = (Boolean) object;
+ if (!ok)
+ throw new TapatalkException(byteArrayToString(map
+ .get("result_text")));
+
+ @SuppressWarnings("unused")
+ // the newly generated post ID for this new topic.
+ String msgId = (String) map.get("post_id");
}
catch (XMLRPCException e)
{
@@ -440,10 +453,18 @@ public class TapatalkClient
final Object[] params = new Object[] { forumId, topicId,
subject.getBytes(), content.getBytes() };
- Map mapMap = toMap(client.callEx("reply_post", params));
+ Object o = client.callEx("reply_post", params);
+ Map map = (Map) o;
+
+ Object object = map.get("result");
+
+ boolean ok = (Boolean) object;
+ if (!ok)
+ throw new TapatalkException(byteArrayToString(map
+ .get("result_text")));
@SuppressWarnings("unused")
- String msgId = (String) mapMap.get("msg_id");
+ String msgId = (String) map.get("topic_id");
}
catch (XMLRPCException e)
{
@@ -468,7 +489,16 @@ public class TapatalkClient
final Object[] params = new Object[] { to, subject.getBytes(),
content.getBytes() };
- Map mapMap = toMap(client.callEx("create_message", params));
+ Object o = client.callEx("create_message", params);
+
+ Map map = (Map) o;
+
+ Object object = map.get("result");
+
+ boolean ok = (Boolean) object;
+ if (!ok)
+ throw new TapatalkException(byteArrayToString(map
+ .get("result_text")));
}
catch (XMLRPCException e)
{
diff --git a/src/de/mtbnews/android/tapatalk/wrapper/Topic.java b/src/de/mtbnews/android/tapatalk/wrapper/Topic.java
@@ -15,6 +15,8 @@ public class Topic implements ListEntry
private String content;
private String name;
private int postCount;
+
+ public String forumId;
/**
* @param id