diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index d449baa..035261a 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -1,10 +1,11 @@
+ package="fr.gaulupeau.apps.InThePoche"
+ android:versionCode="3"
+ android:versionName="1.0.2">
+
@@ -20,6 +21,7 @@
+
diff --git a/res/layout/article.xml b/res/layout/article.xml
new file mode 100644
index 0000000..e17a34f
--- /dev/null
+++ b/res/layout/article.xml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/res/layout/main.xml b/res/layout/main.xml
index 69ee3b1..6c978a4 100644
--- a/res/layout/main.xml
+++ b/res/layout/main.xml
@@ -43,7 +43,7 @@
android:textSize="20sp" />
+
+
+
+
http://links.gaulupeau.fr
Your Poche URL :
Examples:\nhttp://poche.example.fr\nhttp://www.example.fr/poche
+ Save the post
diff --git a/src/fr/gaulupeau/apps/Poche/ArticlesSQLiteOpenHelper.java b/src/fr/gaulupeau/apps/Poche/ArticlesSQLiteOpenHelper.java
new file mode 100644
index 0000000..3c51709
--- /dev/null
+++ b/src/fr/gaulupeau/apps/Poche/ArticlesSQLiteOpenHelper.java
@@ -0,0 +1,60 @@
+package fr.gaulupeau.apps.Poche;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.database.sqlite.SQLiteDatabase;
+import android.database.sqlite.SQLiteOpenHelper;
+import static fr.gaulupeau.apps.Poche.Helpers.PREFS_NAME;
+import static fr.gaulupeau.apps.Poche.Helpers.zeroUpdate;
+
+
+public class ArticlesSQLiteOpenHelper extends SQLiteOpenHelper {
+
+
+ public static final int VERSION = 1;
+ public static final String DB_NAME = "article_db.sqlite";
+ public static String MY_ID = "my_id";
+ public static String ARTICLE_TABLE = "article";
+ public static String ARTICLE_ID = "article_id";
+ public static String ARTICLE_AUTHOR = "author";
+ public static String ARTICLE_CONTENT = "content";
+ public static String ARTICLE_TITLE = "title";
+ public static String ARTICLE_URL = "url";
+ Context c;
+
+ public ArticlesSQLiteOpenHelper(Context context) {
+ super(context, DB_NAME, null, VERSION);
+ c = context;
+ }
+
+ @Override
+ public void onCreate(SQLiteDatabase db) {
+ createTables(db);
+ }
+
+
+ @Override
+ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
+ db.delete(ARTICLE_TABLE, null, null);
+ SharedPreferences preferences = c.getSharedPreferences(PREFS_NAME, 0);
+ SharedPreferences.Editor editor = preferences.edit();
+ editor.putString("previous_update", zeroUpdate);
+ editor.commit();
+ }
+
+ protected void createTables(SQLiteDatabase db) {
+ db.execSQL(
+ "create table " + ARTICLE_TABLE + " (" +
+ MY_ID + " integer primary key autoincrement not null, " +
+ ARTICLE_AUTHOR + " text, " +
+ ARTICLE_CONTENT + " text, " +
+ ARTICLE_TITLE + " text, " +
+ ARTICLE_URL + " text, " +
+ ARTICLE_ID + " integer, " +
+ ");"
+ );
+ }
+
+
+
+}
diff --git a/src/fr/gaulupeau/apps/Poche/Helpers.java b/src/fr/gaulupeau/apps/Poche/Helpers.java
new file mode 100644
index 0000000..c799f3a
--- /dev/null
+++ b/src/fr/gaulupeau/apps/Poche/Helpers.java
@@ -0,0 +1,56 @@
+package fr.gaulupeau.apps.Poche;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+import org.apache.http.HttpResponse;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.impl.client.DefaultHttpClient;
+
+public class Helpers {
+
+ public static final String PREFS_NAME = "InThePoche";
+ public final static String zeroUpdate = "2011-01-01 00:00:00";
+
+ public static String InputStreamtoString(InputStream is)
+ {
+ String s = "",line="";
+ BufferedReader rd = new BufferedReader(new InputStreamReader(is));
+ try{
+ for(; ; rd.readLine())
+ {
+ if((line = rd.readLine())!=null)
+ {
+ s +=line;
+ }else
+ {
+ break;
+ }
+ }
+ }catch (IOException e) {
+ // TODO: handle exception
+ e.printStackTrace();
+ }
+ return s;
+ }
+
+ public static String getInputStreamFromUrl(String url) {
+ InputStream content = null;
+ String res = "";
+ try {
+ HttpGet httpGet = new HttpGet(url);
+ HttpClient httpclient = new DefaultHttpClient();
+ // Execute HTTP Get Request
+ HttpResponse response = httpclient.execute(httpGet);
+ content = response.getEntity().getContent();
+ res = InputStreamtoString(content);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ return res;
+ }
+}
diff --git a/src/fr/gaulupeau/apps/Poche/Poche.java b/src/fr/gaulupeau/apps/Poche/Poche.java
index 8914ae7..39fe7ee 100644
--- a/src/fr/gaulupeau/apps/Poche/Poche.java
+++ b/src/fr/gaulupeau/apps/Poche/Poche.java
@@ -8,8 +8,14 @@
package fr.gaulupeau.apps.Poche;
+import fr.gaulupeau.apps.InThePoche.R;
+import static fr.gaulupeau.apps.Poche.Helpers.getInputStreamFromUrl;
+
import java.io.UnsupportedEncodingException;
+import org.json.JSONException;
+import org.json.JSONObject;
+
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Intent;
@@ -18,32 +24,33 @@ import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.provider.Browser;
+import android.text.Html;
import android.util.Base64;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
+import static fr.gaulupeau.apps.Poche.Helpers.PREFS_NAME;
/**
* Main activity class
*/
@TargetApi(Build.VERSION_CODES.FROYO) public class Poche extends Activity {
- TextView authorSite; // the author and site line on the information page
- Button btnDone; // done/close button
+ TextView authorSite;
+
+ Button btnDone;
+ Button btnGetPost;
EditText editPocheUrl;
- public static final String PREFS_NAME = "MyPrefsFile";
/** Called when the activity is first created.
* Will act differently depending on whether sharing or
* displaying information page. */
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- // Get information about the call to start this activity
Intent intent = getIntent();
Bundle extras = intent.getExtras();
String action = intent.getAction();
-
SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
String pocheUrl = settings.getString("pocheUrl", "http://");
@@ -68,6 +75,7 @@ import android.widget.TextView;
System.out.println("base64 : " + base64);
System.out.println("pageurl : " + pageUrl);
+
// Load the constructed URL in the browser
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(pocheSaveUrl.build());
@@ -97,6 +105,19 @@ import android.widget.TextView;
Poche.this.finish();
}
});
+
+
+ btnGetPost = (Button)findViewById(R.id.btnGetPost);
+ btnGetPost.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ startActivity(new Intent(getBaseContext(), ReadArticle.class));
+ }
+ });
+
}
}
+
+
+
}
diff --git a/src/fr/gaulupeau/apps/Poche/ReadArticle.java b/src/fr/gaulupeau/apps/Poche/ReadArticle.java
new file mode 100644
index 0000000..5da6fc0
--- /dev/null
+++ b/src/fr/gaulupeau/apps/Poche/ReadArticle.java
@@ -0,0 +1,36 @@
+package fr.gaulupeau.apps.Poche;
+
+import static fr.gaulupeau.apps.Poche.Helpers.getInputStreamFromUrl;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.text.Html;
+import android.widget.TextView;
+import fr.gaulupeau.apps.InThePoche.R;
+
+public class ReadArticle extends Activity {
+ TextView txtTitre;
+ TextView txtContent;
+
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.article);
+ String ret = getInputStreamFromUrl("http://poche.gaulupeau.fr/toto.php");
+ try {
+ JSONObject rootobj = new JSONObject(ret);
+ System.out.println(rootobj);
+ txtTitre = (TextView)findViewById(R.id.txtTitre);
+ txtContent = (TextView)findViewById(R.id.txtContent);
+ txtTitre.setText(Html.fromHtml(rootobj.getString("titre")));
+ txtContent.setText(Html.fromHtml(rootobj.getString("content")));
+ } catch (JSONException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+
+}