mirror of
https://github.com/moparisthebest/android-app
synced 2024-11-15 05:15:04 -05:00
Modifications cosmetiques. Ajout champs ARTICLE_ID unique
This commit is contained in:
parent
b50a7c1286
commit
c5406fc96b
@ -2,14 +2,14 @@
|
||||
<manifest package="fr.gaulupeau.apps.InThePoche"
|
||||
android:versionCode="3"
|
||||
android:versionName="1.0.2" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<uses-sdk android:minSdkVersion="4"
|
||||
<uses-sdk android:minSdkVersion="8"
|
||||
android:targetSdkVersion="8" />
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
|
||||
|
||||
<application android:icon="@drawable/icon" android:label="@string/app_name">
|
||||
<activity android:name="fr.gaulupeau.apps.Poche.Poche"
|
||||
android:label="@string/app_name" android:theme="@android:style/Theme.NoTitleBar">
|
||||
android:label="@string/app_name" android:theme="@android:style/Theme.Light.NoTitleBar">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
|
@ -15,11 +15,31 @@
|
||||
android:text="Titre"
|
||||
android:textSize="25sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtAuthor"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Author"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<View
|
||||
android:id="@+id/viewLine"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="2dip"
|
||||
android:background="#000000" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtContent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Contenu" />
|
||||
android:text="Contenu"
|
||||
android:textSize="18sp" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnMarkRead"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/btnMarkRead" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
@ -8,7 +8,10 @@
|
||||
<ListView
|
||||
android:id="@+id/liste_articles"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" >
|
||||
android:layout_height="wrap_content"
|
||||
android:divider="#000000"
|
||||
android:dividerHeight="1dp" >
|
||||
|
||||
</ListView>
|
||||
|
||||
</LinearLayout>
|
||||
|
@ -9,7 +9,8 @@
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="30sp"
|
||||
android:paddingRight="30sp" >
|
||||
android:paddingRight="30sp"
|
||||
android:paddingTop="15dp" >
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
@ -78,22 +79,20 @@
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnDone"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/btnDone" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnGetPost"
|
||||
style="?android:attr/buttonStyleSmall"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/btnGetPost" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnSync"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/btnSync" />
|
||||
|
@ -10,6 +10,7 @@
|
||||
<string name="authorSite">http://cv.gaulupeau.fr</string>
|
||||
<string name="url_label"><b><u>Your poche URL :</u></b></string>
|
||||
<string name="url_help">Examples:\n<i>http://poche.example.fr</i>\n<i>http://www.example.fr/poche</i></string>
|
||||
<string name="btnGetPost">Save the post</string>
|
||||
<string name="btnSync">Syncroniser</string>
|
||||
<string name="btnGetPost">List articles</string>
|
||||
<string name="btnSync">Syncronise</string>
|
||||
<string name="btnMarkRead">Mark as Read</string>
|
||||
</resources>
|
||||
|
@ -52,7 +52,8 @@ public class ArticlesSQLiteOpenHelper extends SQLiteOpenHelper {
|
||||
ARTICLE_TITLE + " text, " +
|
||||
ARTICLE_URL + " text, " +
|
||||
ARTICLE_ID + " integer, " +
|
||||
ARCHIVE + " integer" +
|
||||
ARCHIVE + " integer," +
|
||||
"UNIQUE (" + ARTICLE_ID + ")" +
|
||||
");"
|
||||
);
|
||||
db.execSQL(
|
||||
|
@ -59,7 +59,7 @@ public class ListArticles extends Activity {
|
||||
}
|
||||
|
||||
public ReadingListAdapter getAdapterQuery(String filter, ArrayList<Article> articleInfo) {
|
||||
Log.e("getAdapterQuery", "running query");
|
||||
//Log.e("getAdapterQuery", "running query");
|
||||
//String url, String domain, String id, String title, String content
|
||||
String[] getStrColumns = new String[] {ARTICLE_URL, ARTICLE_ID, ARTICLE_TITLE, ARTICLE_CONTENT, ARCHIVE};
|
||||
Cursor ac = database.query(
|
||||
|
@ -11,6 +11,7 @@ package fr.gaulupeau.apps.Poche;
|
||||
import fr.gaulupeau.apps.InThePoche.R;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
@ -19,6 +20,7 @@ import android.app.Activity;
|
||||
import android.content.ContentValues;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.database.sqlite.SQLiteConstraintException;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
@ -80,8 +82,6 @@ import static fr.gaulupeau.apps.Poche.Helpers.getInputStreamFromUrl;
|
||||
}
|
||||
String base64 = Base64.encodeToString(data, Base64.DEFAULT);
|
||||
pocheSaveUrl.appendQueryParameter("url", base64);
|
||||
System.out.println("base64 : " + base64);
|
||||
System.out.println("pageurl : " + pageUrl);
|
||||
|
||||
|
||||
// Load the constructed URL in the browser
|
||||
@ -119,17 +119,25 @@ import static fr.gaulupeau.apps.Poche.Helpers.getInputStreamFromUrl;
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
String ret = getInputStreamFromUrl("http://poche.gaulupeau.fr/toto.php");
|
||||
try {
|
||||
JSONObject rootobj = new JSONObject(ret);
|
||||
ArticlesSQLiteOpenHelper helper = new ArticlesSQLiteOpenHelper(getApplicationContext());
|
||||
database = helper.getWritableDatabase();
|
||||
try {
|
||||
JSONArray rootobj = new JSONArray(ret);
|
||||
for (int i=0; i<rootobj.length(); i++) {
|
||||
JSONObject article = rootobj.getJSONObject(i);
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(ARTICLE_TITLE, Html.fromHtml(rootobj.getString("titre")).toString());
|
||||
values.put(ARTICLE_CONTENT, Html.fromHtml(rootobj.getString("content")).toString());
|
||||
values.put(ARTICLE_ID, Html.fromHtml(rootobj.getString("id")).toString());
|
||||
values.put(ARTICLE_URL, Html.fromHtml(rootobj.getString("url")).toString());
|
||||
values.put(ARTICLE_TITLE, Html.fromHtml(article.getString("titre")).toString());
|
||||
values.put(ARTICLE_CONTENT, Html.fromHtml(article.getString("content")).toString());
|
||||
values.put(ARTICLE_ID, Html.fromHtml(article.getString("id")).toString());
|
||||
values.put(ARTICLE_URL, Html.fromHtml(article.getString("url")).toString());
|
||||
values.put(ARCHIVE, 0);
|
||||
database.insert(ARTICLE_TABLE, null, values);
|
||||
try {
|
||||
database.insertOrThrow(ARTICLE_TABLE, null, values);
|
||||
} catch (SQLiteConstraintException e) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -6,22 +6,24 @@ import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_ID;
|
||||
import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_TITLE;
|
||||
import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_URL;
|
||||
import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_TABLE;
|
||||
import static fr.gaulupeau.apps.Poche.Helpers.getInputStreamFromUrl;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_AUTHOR;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.ContentValues;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.os.Bundle;
|
||||
import android.text.Html;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
import fr.gaulupeau.apps.InThePoche.R;
|
||||
|
||||
public class ReadArticle extends Activity {
|
||||
TextView txtTitre;
|
||||
TextView txtContent;
|
||||
TextView txtAuthor;
|
||||
Button btnMarkRead;
|
||||
SQLiteDatabase database;
|
||||
String id = "";
|
||||
|
||||
@ -30,7 +32,7 @@ public class ReadArticle extends Activity {
|
||||
setContentView(R.layout.article);
|
||||
ArticlesSQLiteOpenHelper helper = new ArticlesSQLiteOpenHelper(getApplicationContext());
|
||||
database = helper.getWritableDatabase();
|
||||
String[] getStrColumns = new String[] {ARTICLE_URL, ARTICLE_ID, ARTICLE_TITLE, ARTICLE_CONTENT, ARCHIVE};
|
||||
String[] getStrColumns = new String[] {ARTICLE_URL, ARTICLE_ID, ARTICLE_TITLE, ARTICLE_CONTENT, ARCHIVE, ARTICLE_AUTHOR};
|
||||
Bundle data = getIntent().getExtras();
|
||||
if(data != null) {
|
||||
id = data.getString("id");
|
||||
@ -41,18 +43,18 @@ public class ReadArticle extends Activity {
|
||||
txtTitre.setText(ac.getString(2));
|
||||
txtContent = (TextView)findViewById(R.id.txtContent);
|
||||
txtContent.setText(ac.getString(3));
|
||||
// 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();
|
||||
// }
|
||||
txtAuthor = (TextView)findViewById(R.id.txtAuthor);
|
||||
txtAuthor.setText(ac.getString(5));
|
||||
btnMarkRead = (Button)findViewById(R.id.btnMarkRead);
|
||||
btnMarkRead.setOnClickListener(new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(ARCHIVE, 1);
|
||||
database.update(ARTICLE_TABLE, values, ARTICLE_ID + "=" + id, null);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ public class ReadingListAdapter extends BaseAdapter {
|
||||
convertView = inflater.inflate(R.layout.article_list, null);
|
||||
}
|
||||
TextView tvTitle = (TextView) convertView.findViewById(R.id.listitem_titre);
|
||||
Log.e("title", entry.title);
|
||||
//Log.e("title", entry.title);
|
||||
tvTitle.setText(entry.title);
|
||||
|
||||
return convertView;
|
||||
|
Loading…
Reference in New Issue
Block a user