diff --git a/OSJ Forum/AndroidManifest.xml b/OSJ Forum/AndroidManifest.xml index 6dfe1f4..a16af0f 100644 --- a/OSJ Forum/AndroidManifest.xml +++ b/OSJ Forum/AndroidManifest.xml @@ -1,5 +1,5 @@ Topics Forum Detail Forums - http://rickbarrette.org/forum/mobiquo/mobiquo.php + http://rickbarrette.org/forum/mobiquo/mobiquo.php Title Decription Post User Lastest Post New Posts - test - Test1 + test + Test1 + https://oceanstatejeepsters.ipower.com \ No newline at end of file diff --git a/OSJ Forum/src/com/RickBarrette/osj/forum/Constraints.java b/OSJ Forum/src/com/RickBarrette/osj/forum/Constraints.java index 6895866..269d68e 100644 --- a/OSJ Forum/src/com/RickBarrette/osj/forum/Constraints.java +++ b/OSJ Forum/src/com/RickBarrette/osj/forum/Constraints.java @@ -19,10 +19,6 @@ */ package com.RickBarrette.osj.forum; -import org.xmlrpc.android.XMLRPCClient; - -import android.content.Context; - /** * This class will be used to house the constraints of this application * @author ricky barrette @@ -30,12 +26,37 @@ import android.content.Context; public class Constraints { /** - * Creates an XML RPC Client - * @param Context - * @return - * @author ricky barrette + * Set this boolean to true to use the test server */ - public static XMLRPCClient getClient(Context context) { - return new XMLRPCClient(context.getString(R.string.server), context.getString(R.string.username), context.getString(R.string.password)); - } + public static final boolean TESTING = true; + + /** + * Set this boolean to true to enable debug logging + */ + public static final boolean DEBUG = true; + + /** + * Set this boolean to true to enable error logging + */ + public static final boolean ERROR = true; + + /** + * Set this boolean to true to enable info logging + */ + public static final boolean INFO = true; + + /** + * Set this boolean to true to enable verbose logging + */ + public static final boolean VERBOSE = true; + + /** + * Set this boolean to true to enable warning logging + */ + public static final boolean WARNING = true; + + /** + * Set this boolean to true to enable wtf logging + */ + public static final boolean WTF = true; } \ No newline at end of file diff --git a/OSJ Forum/src/com/RickBarrette/osj/forum/Log.java b/OSJ Forum/src/com/RickBarrette/osj/forum/Log.java new file mode 100644 index 0000000..b461426 --- /dev/null +++ b/OSJ Forum/src/com/RickBarrette/osj/forum/Log.java @@ -0,0 +1,165 @@ +/** + * Log.java + * @date Sep 14, 2012 + * @author ricky barrette + * + * Copyright 2012 Richard Barrette + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ +package com.RickBarrette.osj.forum; + +/** + * A convince class for logging with log level constraints + * @author ricky barrette + */ +public class Log { + + /** + * Send a DEBUG log message + * @param tag + * @param log + * @author ricky barrette + */ + public static void d(String tag, String log){ + if(Constraints.DEBUG) + android.util.Log.d(tag, log); + } + + /** + * Send a DEBUG log message and log the exception. + * @param tag + * @param log + * @param e + * @author ricky barrette + */ + public static void d(String tag, String log, Throwable e){ + if(Constraints.DEBUG) + android.util.Log.d(tag, log, e); + } + + /** + * Send a ERROR log message + * @param tag + * @param log + * @author ricky barrette + */ + public static void e(String tag, String log){ + if(Constraints.ERROR) + android.util.Log.e(tag, log); + } + + /** + * Send a ERROR log message and log the exception. + * @param tag + * @param log + * @param e + * @author ricky barrette + */ + public static void e(String tag, String log, Throwable e){ + if(Constraints.ERROR) + android.util.Log.e(tag, log, e); + } + + /** + * Send a INFO log message + * @param tag + * @param log + * @author ricky barrette + */ + public static void i(String tag, String log){ + if(Constraints.INFO) + android.util.Log.i(tag, log); + } + + /** + * Send a INFO log message and log the exception. + * @param tag + * @param log + * @param e + * @author ricky barrette + */ + public static void i(String tag, String log, Throwable e){ + if(Constraints.INFO) + android.util.Log.i(tag, log, e); + } + + /** + * Send a VERBOSE log message + * @param tag + * @param log + * @author ricky barrette + */ + public static void v(String tag, String log){ + if(Constraints.VERBOSE) + android.util.Log.v(tag, log); + } + + /** + * Send a VERBOSE log message and log the exception. + * @param tag + * @param log + * @param e + * @author ricky barrette + */ + public static void v(String tag, String log, Throwable e){ + if(Constraints.VERBOSE) + android.util.Log.v(tag, log, e); + } + + /** + * Send a WARNING log message + * @param tag + * @param log + * @author ricky barrette + */ + public static void w(String tag, String log){ + if(Constraints.WARNING) + android.util.Log.w(tag, log); + } + + /** + * Send a WARNING log message and log the exception. + * @param tag + * @param log + * @param e + * @author ricky barrette + */ + public static void w(String tag, String log, Throwable e){ + if(Constraints.WARNING) + android.util.Log.w(tag, log, e); + } + + /** + * Send a WTF log message + * @param tag + * @param log + * @author ricky barrette + */ + public static void wtf(String tag, String log){ + if(Constraints.WTF) + android.util.Log.wtf(tag, log); + } + + /** + * Send a WTF log message and log the exception. + * @param tag + * @param log + * @param e + * @author ricky barrette + */ + public static void wtf(String tag, String log, Throwable e){ + if(Constraints.WTF) + android.util.Log.wtf(tag, log, e); + } +} \ No newline at end of file diff --git a/OSJ Forum/src/com/RickBarrette/osj/forum/content/ForumContent.java b/OSJ Forum/src/com/RickBarrette/osj/forum/content/ForumContent.java index f4cca9f..84dc91b 100644 --- a/OSJ Forum/src/com/RickBarrette/osj/forum/content/ForumContent.java +++ b/OSJ Forum/src/com/RickBarrette/osj/forum/content/ForumContent.java @@ -28,12 +28,11 @@ import org.xmlrpc.android.XMLRPCClient; import org.xmlrpc.android.XMLRPCException; import android.content.Context; -import android.util.Log; -import com.RickBarrette.osj.forum.R; +import com.RickBarrette.osj.forum.Log; /** - * This class is used to maintian the forum's content data + * This class is used to maintain an instance of a forum's content data * @author ricky barrette */ public class ForumContent { @@ -59,7 +58,7 @@ public class ForumContent { this.content = content; for(Object key: content.keySet()) - Log.d(TAG, key.toString()); + Log.v(TAG, key.toString()); } /** @@ -103,7 +102,7 @@ public class ForumContent { ITEMS.clear(); ITEM_MAP.clear(); - final XMLRPCClient client = new XMLRPCClient((context.getString(R.string.server))); + final XMLRPCClient client = XMLRPCClient.getClient(context); Object[] result = null; try { diff --git a/OSJ Forum/src/com/RickBarrette/osj/forum/content/ThreadAdapter.java b/OSJ Forum/src/com/RickBarrette/osj/forum/content/ThreadAdapter.java index a53a09d..d674c97 100644 --- a/OSJ Forum/src/com/RickBarrette/osj/forum/content/ThreadAdapter.java +++ b/OSJ Forum/src/com/RickBarrette/osj/forum/content/ThreadAdapter.java @@ -22,7 +22,6 @@ package com.RickBarrette.osj.forum.content; import java.util.HashMap; import android.content.Context; -import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -33,7 +32,7 @@ import android.widget.TextView; import com.RickBarrette.osj.forum.R; /** - * + * This adapter will be used to populte a list view with post from a thread * @author ricky barrette */ public class ThreadAdapter extends BaseAdapter { @@ -45,13 +44,10 @@ public class ThreadAdapter extends BaseAdapter { QuickContactBadge badage; } - private static final String TAG = "TopicAdapter"; - - private LayoutInflater mInflater; /** - * + * Creates a new ThreadAdapter * @author ricky barrette */ public ThreadAdapter(Context context) { @@ -132,8 +128,6 @@ public class ThreadAdapter extends BaseAdapter { holder.user.setText(new String((byte[]) getItem(position).get("post_author_name"))); holder.post.setText(new String((byte[]) getItem(position).get("post_content"))); - for (Object key : getItem(position).keySet()) - Log.d(TAG, key.toString()); return convertView; } diff --git a/OSJ Forum/src/com/RickBarrette/osj/forum/content/ThreadContent.java b/OSJ Forum/src/com/RickBarrette/osj/forum/content/ThreadContent.java index 1075056..84b0b60 100644 --- a/OSJ Forum/src/com/RickBarrette/osj/forum/content/ThreadContent.java +++ b/OSJ Forum/src/com/RickBarrette/osj/forum/content/ThreadContent.java @@ -28,12 +28,11 @@ import org.xmlrpc.android.XMLRPCClient; import org.xmlrpc.android.XMLRPCException; import android.content.Context; -import android.util.Log; -import com.RickBarrette.osj.forum.Constraints; +import com.RickBarrette.osj.forum.Log; /** - * + * This class is used to maintain an instance of a thread's data content * @author ricky barrette */ public class ThreadContent { @@ -43,7 +42,7 @@ public class ThreadContent { * @author ricky barrette */ public static class ThreadItem { - private static final String TAG = "TopicItem"; + private static final String TAG = "ThreadItem"; public String id; public HashMap content; @@ -58,7 +57,7 @@ public class ThreadContent { this.content = content; for(Object key: content.keySet()) - Log.d(TAG, key.toString()); + Log.v(TAG, key.toString()); } } @@ -84,7 +83,7 @@ public class ThreadContent { * @author ricky barrette */ public static void getThread(String topicId, int startNumber, int lastNumber, final Context context){ - final XMLRPCClient client = Constraints.getClient(context); + final XMLRPCClient client = XMLRPCClient.getClient(context); ITEMS.clear(); ITEM_MAP.clear(); diff --git a/OSJ Forum/src/com/RickBarrette/osj/forum/content/TopicAdapter.java b/OSJ Forum/src/com/RickBarrette/osj/forum/content/TopicAdapter.java index 0595ddb..647ee0d 100644 --- a/OSJ Forum/src/com/RickBarrette/osj/forum/content/TopicAdapter.java +++ b/OSJ Forum/src/com/RickBarrette/osj/forum/content/TopicAdapter.java @@ -22,7 +22,6 @@ package com.RickBarrette.osj.forum.content; import java.util.HashMap; import android.content.Context; -import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -46,8 +45,6 @@ public class TopicAdapter extends BaseAdapter { QuickContactBadge badage; } - private static final String TAG = "TopicAdapter"; - private LayoutInflater mInflater; /** @@ -130,8 +127,6 @@ public class TopicAdapter extends BaseAdapter { holder.lastestPost.setText(new String((byte[]) getItem(position).get("short_content"))); holder.newPosts.setVisibility(((Boolean) getItem(position).get("new_post") ? View.VISIBLE : View.GONE)); - for(Object key: getItem(position).keySet()) - Log.d(TAG, key.toString()); return convertView; } diff --git a/OSJ Forum/src/com/RickBarrette/osj/forum/content/TopicContent.java b/OSJ Forum/src/com/RickBarrette/osj/forum/content/TopicContent.java index ebafd87..5b333ff 100644 --- a/OSJ Forum/src/com/RickBarrette/osj/forum/content/TopicContent.java +++ b/OSJ Forum/src/com/RickBarrette/osj/forum/content/TopicContent.java @@ -28,12 +28,11 @@ import org.xmlrpc.android.XMLRPCClient; import org.xmlrpc.android.XMLRPCException; import android.content.Context; -import android.util.Log; -import com.RickBarrette.osj.forum.Constraints; +import com.RickBarrette.osj.forum.Log; /** - * This class is used to maintain a topic's content data + * This class is used to maintain an instance of a topic's content data * @author ricky barrette */ public class TopicContent { @@ -58,7 +57,7 @@ public class TopicContent { this.content = content; for(Object key: content.keySet()) - Log.d(TAG, key.toString()); + Log.v(TAG, key.toString()); } } @@ -82,7 +81,7 @@ public class TopicContent { * @author ricky barrette */ public static void getTopics(String forumId, final Context context){ - final XMLRPCClient client = Constraints.getClient(context); + final XMLRPCClient client = XMLRPCClient.getClient(context); ITEMS.clear(); ITEM_MAP.clear(); diff --git a/OSJ Forum/src/org/xmlrpc/android/XMLRPCClient.java b/OSJ Forum/src/org/xmlrpc/android/XMLRPCClient.java index f18670b..261f5b3 100644 --- a/OSJ Forum/src/org/xmlrpc/android/XMLRPCClient.java +++ b/OSJ Forum/src/org/xmlrpc/android/XMLRPCClient.java @@ -29,6 +29,11 @@ import org.apache.http.params.HttpProtocolParams; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserFactory; +import android.content.Context; + +import com.RickBarrette.osj.forum.Constraints; +import com.RickBarrette.osj.forum.R; + /** * XMLRPCClient allows to call remote XMLRPC method. * @@ -94,7 +99,7 @@ public class XMLRPCClient extends XMLRPCCommon { public XMLRPCClient(URI uri) { SchemeRegistry registry = new SchemeRegistry(); registry.register(new Scheme("http", new PlainSocketFactory(), 80)); - registry.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443)); + registry.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443)); postMethod = new HttpPost(uri); postMethod.addHeader("Content-Type", "text/xml"); @@ -420,4 +425,17 @@ public class XMLRPCClient extends XMLRPCCommon { public Object call(String method, Object... params) throws XMLRPCException { return callEx(method, params); } + + /** + * Creates an XML RPC Client + * @param Context + * @return XMLRPCClient + * @author ricky barrette + */ + public static XMLRPCClient getClient(Context context) { + if(Constraints.TESTING) + return new XMLRPCClient(context.getString(R.string.test_server), context.getString(R.string.test_username), context.getString(R.string.test_password)); + else + return new XMLRPCClient(context.getString(R.string.osj_server), context.getString(R.string.test_username), context.getString(R.string.test_password)); + } }