mirror of
https://github.com/moparisthebest/android-app
synced 2024-08-13 16:53:46 -04:00
cleaning up source code
This commit is contained in:
parent
440354e578
commit
cb2c1dc04b
@ -1,7 +1,5 @@
|
|||||||
package fr.gaulupeau.apps.Poche;
|
package fr.gaulupeau.apps.Poche;
|
||||||
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
|
||||||
public class Article {
|
public class Article {
|
||||||
|
@ -4,6 +4,7 @@ import android.content.Context;
|
|||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.database.sqlite.SQLiteDatabase;
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
import android.database.sqlite.SQLiteOpenHelper;
|
import android.database.sqlite.SQLiteOpenHelper;
|
||||||
|
|
||||||
import static fr.gaulupeau.apps.Poche.Helpers.PREFS_NAME;
|
import static fr.gaulupeau.apps.Poche.Helpers.PREFS_NAME;
|
||||||
import static fr.gaulupeau.apps.Poche.Helpers.zeroUpdate;
|
import static fr.gaulupeau.apps.Poche.Helpers.zeroUpdate;
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@ package fr.gaulupeau.apps.Poche;
|
|||||||
|
|
||||||
|
|
||||||
import android.annotation.TargetApi;
|
import android.annotation.TargetApi;
|
||||||
import android.app.Activity;
|
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.app.ActionBarActivity;
|
import android.support.v7.app.ActionBarActivity;
|
||||||
|
@ -1,36 +1,32 @@
|
|||||||
package fr.gaulupeau.apps.Poche;
|
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.HttpResponse;
|
||||||
import org.apache.http.client.HttpClient;
|
import org.apache.http.client.HttpClient;
|
||||||
import org.apache.http.client.methods.HttpGet;
|
import org.apache.http.client.methods.HttpGet;
|
||||||
import org.apache.http.impl.client.DefaultHttpClient;
|
import org.apache.http.impl.client.DefaultHttpClient;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
|
||||||
public class Helpers {
|
public class Helpers {
|
||||||
|
|
||||||
public static final String PREFS_NAME = "InThePoche";
|
public static final String PREFS_NAME = "InThePoche";
|
||||||
public final static String zeroUpdate = "2011-01-01 00:00:00";
|
public final static String zeroUpdate = "2011-01-01 00:00:00";
|
||||||
|
|
||||||
public static String InputStreamtoString(InputStream is)
|
public static String InputStreamtoString(InputStream is) {
|
||||||
{
|
String s = "", line = "";
|
||||||
String s = "",line="";
|
|
||||||
BufferedReader rd = new BufferedReader(new InputStreamReader(is));
|
BufferedReader rd = new BufferedReader(new InputStreamReader(is));
|
||||||
try{
|
try {
|
||||||
for(; ; rd.readLine())
|
for (; ; rd.readLine()) {
|
||||||
{
|
if ((line = rd.readLine()) != null) {
|
||||||
if((line = rd.readLine())!=null)
|
s += line;
|
||||||
{
|
} else {
|
||||||
s +=line;
|
|
||||||
}else
|
|
||||||
{
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}catch (IOException e) {
|
} catch (IOException e) {
|
||||||
// TODO: handle exception
|
// TODO: handle exception
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -38,7 +34,7 @@ public class Helpers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String getInputStreamFromUrl(String url) {
|
public static String getInputStreamFromUrl(String url) {
|
||||||
InputStream content = null;
|
InputStream content;
|
||||||
String res = "";
|
String res = "";
|
||||||
try {
|
try {
|
||||||
HttpGet httpGet = new HttpGet(url);
|
HttpGet httpGet = new HttpGet(url);
|
||||||
|
@ -1,13 +1,8 @@
|
|||||||
package fr.gaulupeau.apps.Poche;
|
package fr.gaulupeau.apps.Poche;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.*;
|
|
||||||
import fr.gaulupeau.apps.InThePoche.R;
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.database.sqlite.SQLiteDatabase;
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuInflater;
|
import android.view.MenuInflater;
|
||||||
@ -16,10 +11,21 @@ import android.view.View;
|
|||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import fr.gaulupeau.apps.InThePoche.R;
|
||||||
|
|
||||||
|
import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARCHIVE;
|
||||||
|
import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_CONTENT;
|
||||||
|
import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_DATE;
|
||||||
|
import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_TABLE;
|
||||||
|
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.MY_ID;
|
||||||
|
|
||||||
public class ListArticles extends BaseActionBarActivity {
|
public class ListArticles extends BaseActionBarActivity {
|
||||||
|
|
||||||
private ArrayList<Article> readArticlesInfo;
|
private ArrayList<Article> readArticlesInfo;
|
||||||
private ListView readList;
|
|
||||||
private SQLiteDatabase database;
|
private SQLiteDatabase database;
|
||||||
|
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
@ -63,10 +69,10 @@ public class ListArticles extends BaseActionBarActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setupList(Boolean showAll) {
|
public void setupList(Boolean showAll) {
|
||||||
readList = (ListView) findViewById(R.id.liste_articles);
|
ListView readList = (ListView) findViewById(R.id.liste_articles);
|
||||||
readArticlesInfo = new ArrayList<Article>();
|
readArticlesInfo = new ArrayList<Article>();
|
||||||
String filter = null;
|
String filter = null;
|
||||||
if (showAll == false) {
|
if (!showAll) {
|
||||||
filter = ARCHIVE + "=0";
|
filter = ARCHIVE + "=0";
|
||||||
}
|
}
|
||||||
ReadingListAdapter ad = getAdapterQuery(filter, readArticlesInfo);
|
ReadingListAdapter ad = getAdapterQuery(filter, readArticlesInfo);
|
||||||
@ -76,7 +82,7 @@ public class ListArticles extends BaseActionBarActivity {
|
|||||||
|
|
||||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||||
Intent i = new Intent(getBaseContext(), ReadArticle.class);
|
Intent i = new Intent(getBaseContext(), ReadArticle.class);
|
||||||
i.putExtra("id", (String) readArticlesInfo.get(position).id);
|
i.putExtra("id", readArticlesInfo.get(position).id);
|
||||||
startActivity(i);
|
startActivity(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,15 +92,15 @@ public class ListArticles extends BaseActionBarActivity {
|
|||||||
public ReadingListAdapter getAdapterQuery(String filter, ArrayList<Article> articleInfo) {
|
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 url, String domain, String id, String title, String content
|
||||||
String[] getStrColumns = new String[] {ARTICLE_URL, MY_ID, ARTICLE_TITLE, ARTICLE_CONTENT, ARCHIVE};
|
String[] getStrColumns = new String[]{ARTICLE_URL, MY_ID, ARTICLE_TITLE, ARTICLE_CONTENT, ARCHIVE};
|
||||||
Cursor ac = database.query(
|
Cursor ac = database.query(
|
||||||
ARTICLE_TABLE,
|
ARTICLE_TABLE,
|
||||||
getStrColumns,
|
getStrColumns,
|
||||||
filter, null, null, null, ARTICLE_DATE + " DESC");
|
filter, null, null, null, ARTICLE_DATE + " DESC");
|
||||||
ac.moveToFirst();
|
ac.moveToFirst();
|
||||||
if(!ac.isAfterLast()) {
|
if (!ac.isAfterLast()) {
|
||||||
do {
|
do {
|
||||||
Article tempArticle = new Article(ac.getString(0),ac.getString(1),ac.getString(2),ac.getString(3),ac.getString(4));
|
Article tempArticle = new Article(ac.getString(0), ac.getString(1), ac.getString(2), ac.getString(3), ac.getString(4));
|
||||||
articleInfo.add(tempArticle);
|
articleInfo.add(tempArticle);
|
||||||
} while (ac.moveToNext());
|
} while (ac.moveToNext());
|
||||||
}
|
}
|
||||||
|
@ -8,38 +8,6 @@
|
|||||||
|
|
||||||
package fr.gaulupeau.apps.Poche;
|
package fr.gaulupeau.apps.Poche;
|
||||||
|
|
||||||
import fr.gaulupeau.apps.InThePoche.R;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.net.HttpURLConnection;
|
|
||||||
import java.net.MalformedURLException;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.security.SecureRandom;
|
|
||||||
import java.security.cert.CertificateException;
|
|
||||||
import java.security.cert.X509Certificate;
|
|
||||||
import java.text.DateFormat;
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
import javax.net.ssl.HostnameVerifier;
|
|
||||||
import javax.net.ssl.HttpsURLConnection;
|
|
||||||
import javax.net.ssl.SSLContext;
|
|
||||||
import javax.net.ssl.SSLSession;
|
|
||||||
import javax.net.ssl.X509TrustManager;
|
|
||||||
import javax.xml.parsers.DocumentBuilder;
|
|
||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
|
||||||
|
|
||||||
import org.w3c.dom.DOMException;
|
|
||||||
import org.w3c.dom.Document;
|
|
||||||
import org.w3c.dom.Element;
|
|
||||||
import org.w3c.dom.Node;
|
|
||||||
import org.w3c.dom.NodeList;
|
|
||||||
import org.xml.sax.InputSource;
|
|
||||||
import org.xml.sax.SAXException;
|
|
||||||
|
|
||||||
import android.annotation.TargetApi;
|
import android.annotation.TargetApi;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
@ -55,40 +23,58 @@ import android.net.NetworkInfo;
|
|||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.PreferenceManager;
|
|
||||||
import android.provider.Browser;
|
import android.provider.Browser;
|
||||||
import android.text.Html;
|
|
||||||
import android.util.Base64;
|
import android.util.Base64;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.Menu;
|
|
||||||
import android.view.MenuInflater;
|
|
||||||
import android.view.MenuItem;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.EditText;
|
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
import static fr.gaulupeau.apps.Poche.Helpers.PREFS_NAME;
|
|
||||||
import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_TABLE;
|
|
||||||
import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_URL;
|
|
||||||
import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_TITLE;
|
|
||||||
import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_CONTENT;
|
|
||||||
import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARCHIVE;
|
|
||||||
import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_SYNC;
|
|
||||||
import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_DATE;
|
|
||||||
|
|
||||||
|
import org.w3c.dom.Document;
|
||||||
|
import org.w3c.dom.Element;
|
||||||
|
import org.w3c.dom.Node;
|
||||||
|
import org.w3c.dom.NodeList;
|
||||||
|
import org.xml.sax.InputSource;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.security.SecureRandom;
|
||||||
|
import java.security.cert.CertificateException;
|
||||||
|
import java.security.cert.X509Certificate;
|
||||||
|
|
||||||
|
import javax.net.ssl.HostnameVerifier;
|
||||||
|
import javax.net.ssl.HttpsURLConnection;
|
||||||
|
import javax.net.ssl.SSLContext;
|
||||||
|
import javax.net.ssl.SSLSession;
|
||||||
|
import javax.net.ssl.X509TrustManager;
|
||||||
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
|
|
||||||
|
import fr.gaulupeau.apps.InThePoche.R;
|
||||||
|
|
||||||
|
import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARCHIVE;
|
||||||
|
import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_CONTENT;
|
||||||
|
import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_DATE;
|
||||||
|
import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_SYNC;
|
||||||
|
import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_TABLE;
|
||||||
|
import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_TITLE;
|
||||||
|
import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_URL;
|
||||||
|
import static fr.gaulupeau.apps.Poche.Helpers.PREFS_NAME;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Main activity class
|
* Main activity class
|
||||||
*/
|
*/
|
||||||
@TargetApi(Build.VERSION_CODES.FROYO) public class Poche extends Activity {
|
@TargetApi(Build.VERSION_CODES.FROYO)
|
||||||
|
public class Poche extends Activity {
|
||||||
private static SQLiteDatabase database;
|
private static SQLiteDatabase database;
|
||||||
Button btnDone;
|
|
||||||
Button btnGetPost;
|
Button btnGetPost;
|
||||||
Button btnSync;
|
Button btnSync;
|
||||||
Button btnSettings;
|
Button btnSettings;
|
||||||
EditText editPocheUrl;
|
|
||||||
SharedPreferences settings;
|
SharedPreferences settings;
|
||||||
static String apiUsername;
|
static String apiUsername;
|
||||||
static String apiToken;
|
static String apiToken;
|
||||||
@ -96,12 +82,11 @@ import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_DATE;
|
|||||||
String action;
|
String action;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the activity is first created.
|
||||||
|
|
||||||
/** Called when the activity is first created.
|
|
||||||
* Will act differently depending on whether sharing or
|
* Will act differently depending on whether sharing or
|
||||||
* displaying information page. */
|
* displaying information page.
|
||||||
|
*/
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
@ -111,7 +96,7 @@ import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_DATE;
|
|||||||
|
|
||||||
getSettings();
|
getSettings();
|
||||||
// Find out if Sharing or if app has been launched from icon
|
// Find out if Sharing or if app has been launched from icon
|
||||||
if (action.equals(Intent.ACTION_SEND) && pocheUrl != "http://") {
|
if (action.equals(Intent.ACTION_SEND) && !pocheUrl.equals("http://")) {
|
||||||
setContentView(R.layout.main);
|
setContentView(R.layout.main);
|
||||||
findViewById(R.id.btnSync).setVisibility(View.GONE);
|
findViewById(R.id.btnSync).setVisibility(View.GONE);
|
||||||
findViewById(R.id.btnGetPost).setVisibility(View.GONE);
|
findViewById(R.id.btnGetPost).setVisibility(View.GONE);
|
||||||
@ -151,19 +136,18 @@ import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_DATE;
|
|||||||
// Afficher alerte connectivité
|
// Afficher alerte connectivité
|
||||||
showToast(getString(R.string.txtNetOffline));
|
showToast(getString(R.string.txtNetOffline));
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
setContentView(R.layout.main);
|
setContentView(R.layout.main);
|
||||||
checkAndHandleAfterUpdate();
|
checkAndHandleAfterUpdate();
|
||||||
|
|
||||||
btnSync = (Button)findViewById(R.id.btnSync);
|
btnSync = (Button) findViewById(R.id.btnSync);
|
||||||
btnSync.setOnClickListener(new OnClickListener() {
|
btnSync.setOnClickListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
// Vérification de la connectivité Internet
|
// Vérification de la connectivité Internet
|
||||||
final ConnectivityManager conMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
|
final ConnectivityManager conMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||||
final NetworkInfo activeNetwork = conMgr.getActiveNetworkInfo();
|
final NetworkInfo activeNetwork = conMgr.getActiveNetworkInfo();
|
||||||
if (pocheUrl == "http://") {
|
if (pocheUrl.equals("http://")) {
|
||||||
showToast(getString(R.string.txtConfigNotSet));
|
showToast(getString(R.string.txtConfigNotSet));
|
||||||
} else if (activeNetwork != null && activeNetwork.isConnected()) {
|
} else if (activeNetwork != null && activeNetwork.isConnected()) {
|
||||||
// Exécution de la synchro en arrière-plan
|
// Exécution de la synchro en arrière-plan
|
||||||
@ -189,7 +173,7 @@ import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_DATE;
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
btnGetPost = (Button)findViewById(R.id.btnGetPost);
|
btnGetPost = (Button) findViewById(R.id.btnGetPost);
|
||||||
//updateUnread();
|
//updateUnread();
|
||||||
|
|
||||||
btnGetPost.setOnClickListener(new OnClickListener() {
|
btnGetPost.setOnClickListener(new OnClickListener() {
|
||||||
@ -199,7 +183,7 @@ import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_DATE;
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
btnSettings = (Button)findViewById(R.id.btnSettings);
|
btnSettings = (Button) findViewById(R.id.btnSettings);
|
||||||
btnSettings.setOnClickListener(new OnClickListener() {
|
btnSettings.setOnClickListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
@ -212,7 +196,7 @@ import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_DATE;
|
|||||||
private void checkAndHandleAfterUpdate() {
|
private void checkAndHandleAfterUpdate() {
|
||||||
SharedPreferences pref = getSharedPreferences(PREFS_NAME, 0);
|
SharedPreferences pref = getSharedPreferences(PREFS_NAME, 0);
|
||||||
|
|
||||||
if (pref.getInt("update_checker",0) < 9) {
|
if (pref.getInt("update_checker", 0) < 9) {
|
||||||
// Wipe Database, because we now save HTML content instead of plain text
|
// Wipe Database, because we now save HTML content instead of plain text
|
||||||
ArticlesSQLiteOpenHelper helper = new ArticlesSQLiteOpenHelper(this);
|
ArticlesSQLiteOpenHelper helper = new ArticlesSQLiteOpenHelper(this);
|
||||||
database = helper.getReadableDatabase();
|
database = helper.getReadableDatabase();
|
||||||
@ -230,7 +214,7 @@ import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_DATE;
|
|||||||
pref.edit().putInt("update_checker", versionCode).commit();
|
pref.edit().putInt("update_checker", versionCode).commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getSettings(){
|
private void getSettings() {
|
||||||
settings = getSharedPreferences(PREFS_NAME, 0);
|
settings = getSharedPreferences(PREFS_NAME, 0);
|
||||||
pocheUrl = settings.getString("pocheUrl", "http://");
|
pocheUrl = settings.getString("pocheUrl", "http://");
|
||||||
apiUsername = settings.getString("APIUsername", "");
|
apiUsername = settings.getString("APIUsername", "");
|
||||||
@ -241,7 +225,7 @@ import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_DATE;
|
|||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
getSettings();
|
getSettings();
|
||||||
if (! action.equals(Intent.ACTION_SEND)){
|
if (!action.equals(Intent.ACTION_SEND)) {
|
||||||
updateUnread();
|
updateUnread();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -254,10 +238,9 @@ import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_DATE;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateUnread(){
|
private void updateUnread() {
|
||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(new Runnable() {
|
||||||
public void run()
|
public void run() {
|
||||||
{
|
|
||||||
ArticlesSQLiteOpenHelper helper = new ArticlesSQLiteOpenHelper(getApplicationContext());
|
ArticlesSQLiteOpenHelper helper = new ArticlesSQLiteOpenHelper(getApplicationContext());
|
||||||
database = helper.getReadableDatabase();
|
database = helper.getReadableDatabase();
|
||||||
int news = database.query(ARTICLE_TABLE, null, ARCHIVE + "=0", null, null, null, null).getCount();
|
int news = database.query(ARTICLE_TABLE, null, ARCHIVE + "=0", null, null, null, null).getCount();
|
||||||
@ -266,18 +249,15 @@ import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_DATE;
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showToast(final String toast)
|
public void showToast(final String toast) {
|
||||||
{
|
|
||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(new Runnable() {
|
||||||
public void run()
|
public void run() {
|
||||||
{
|
|
||||||
Toast.makeText(Poche.this, toast, Toast.LENGTH_SHORT).show();
|
Toast.makeText(Poche.this, toast, Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showErrorMessage(final String message)
|
private void showErrorMessage(final String message) {
|
||||||
{
|
|
||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -285,7 +265,7 @@ import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_DATE;
|
|||||||
messageBox.setMessage(message);
|
messageBox.setMessage(message);
|
||||||
messageBox.setTitle(getString(R.string.error));
|
messageBox.setTitle(getString(R.string.error));
|
||||||
// messageBox.setIconAttribute(android.R.attr.alertDialogIcon);
|
// messageBox.setIconAttribute(android.R.attr.alertDialogIcon);
|
||||||
messageBox.setPositiveButton("OK",null);
|
messageBox.setPositiveButton("OK", null);
|
||||||
messageBox.setCancelable(false);
|
messageBox.setCancelable(false);
|
||||||
messageBox.create().show();
|
messageBox.create().show();
|
||||||
}
|
}
|
||||||
@ -342,7 +322,7 @@ import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_DATE;
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
public String cleanString(String s){
|
public String cleanString(String s) {
|
||||||
|
|
||||||
s = s.replace("é", "é");
|
s = s.replace("é", "é");
|
||||||
s = s.replace("è", "è");
|
s = s.replace("è", "è");
|
||||||
@ -366,19 +346,25 @@ import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_DATE;
|
|||||||
|
|
||||||
private void trustEveryone() {
|
private void trustEveryone() {
|
||||||
try {
|
try {
|
||||||
HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier(){
|
HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() {
|
||||||
public boolean verify(String hostname, SSLSession session) {
|
public boolean verify(String hostname, SSLSession session) {
|
||||||
return true;
|
return true;
|
||||||
}});
|
}
|
||||||
|
});
|
||||||
SSLContext context = SSLContext.getInstance("TLS");
|
SSLContext context = SSLContext.getInstance("TLS");
|
||||||
context.init(null, new X509TrustManager[]{new X509TrustManager(){
|
context.init(null, new X509TrustManager[]{new X509TrustManager() {
|
||||||
public void checkClientTrusted(X509Certificate[] chain,
|
public void checkClientTrusted(X509Certificate[] chain,
|
||||||
String authType) throws CertificateException {}
|
String authType) throws CertificateException {
|
||||||
|
}
|
||||||
|
|
||||||
public void checkServerTrusted(X509Certificate[] chain,
|
public void checkServerTrusted(X509Certificate[] chain,
|
||||||
String authType) throws CertificateException {}
|
String authType) throws CertificateException {
|
||||||
|
}
|
||||||
|
|
||||||
public X509Certificate[] getAcceptedIssuers() {
|
public X509Certificate[] getAcceptedIssuers() {
|
||||||
return new X509Certificate[0];
|
return new X509Certificate[0];
|
||||||
}}}, new SecureRandom());
|
}
|
||||||
|
}}, new SecureRandom());
|
||||||
HttpsURLConnection.setDefaultSSLSocketFactory(
|
HttpsURLConnection.setDefaultSSLSocketFactory(
|
||||||
context.getSocketFactory());
|
context.getSocketFactory());
|
||||||
} catch (Exception e) { // should never happen
|
} catch (Exception e) { // should never happen
|
||||||
@ -387,11 +373,10 @@ import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_DATE;
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void parseRSS(){
|
public void parseRSS() {
|
||||||
|
|
||||||
URL url;
|
URL url;
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
// Set the url (you will need to change this to your RSS URL
|
// Set the url (you will need to change this to your RSS URL
|
||||||
url = new URL(pocheUrl + "/?feed&type=home&user_id=" + apiUsername + "&token=" + apiToken);
|
url = new URL(pocheUrl + "/?feed&type=home&user_id=" + apiUsername + "&token=" + apiToken);
|
||||||
if (pocheUrl.startsWith("https")) {
|
if (pocheUrl.startsWith("https")) {
|
||||||
@ -399,7 +384,7 @@ import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_DATE;
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Setup the connection
|
// Setup the connection
|
||||||
HttpURLConnection urlConnection = null;
|
HttpURLConnection urlConnection;
|
||||||
urlConnection = (HttpURLConnection) url.openConnection();
|
urlConnection = (HttpURLConnection) url.openConnection();
|
||||||
|
|
||||||
if ((urlConnection != null) && (urlConnection.getResponseCode() == HttpURLConnection.HTTP_OK)) {
|
if ((urlConnection != null) && (urlConnection.getResponseCode() == HttpURLConnection.HTTP_OK)) {
|
||||||
@ -409,7 +394,7 @@ import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_DATE;
|
|||||||
DocumentBuilder db = dbf.newDocumentBuilder();
|
DocumentBuilder db = dbf.newDocumentBuilder();
|
||||||
Document doc = null;
|
Document doc = null;
|
||||||
|
|
||||||
InputSource is = null;
|
InputSource is;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
is = new InputSource(
|
is = new InputSource(
|
||||||
@ -440,12 +425,10 @@ import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_DATE;
|
|||||||
arrays.PodcastDate = new String[itemLst.getLength()];
|
arrays.PodcastDate = new String[itemLst.getLength()];
|
||||||
|
|
||||||
// Loop through the XML passing the data to the arrays
|
// Loop through the XML passing the data to the arrays
|
||||||
for (int i = 0; i < itemLst.getLength(); i++)
|
for (int i = 0; i < itemLst.getLength(); i++) {
|
||||||
{
|
|
||||||
|
|
||||||
Node item = itemLst.item(i);
|
Node item = itemLst.item(i);
|
||||||
if (item.getNodeType() == Node.ELEMENT_NODE)
|
if (item.getNodeType() == Node.ELEMENT_NODE) {
|
||||||
{
|
|
||||||
Element ielem = (Element) item;
|
Element ielem = (Element) item;
|
||||||
|
|
||||||
// This section gets the elements from the XML
|
// This section gets the elements from the XML
|
||||||
@ -468,11 +451,9 @@ import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_DATE;
|
|||||||
// data retrieved from above. I have surrounded each
|
// data retrieved from above. I have surrounded each
|
||||||
// with try/catch just incase the element does not
|
// with try/catch just incase the element does not
|
||||||
// exist
|
// exist
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
arrays.PodcastTitle[i] = cleanString(title.item(0).getChildNodes().item(0).getNodeValue());
|
arrays.PodcastTitle[i] = cleanString(title.item(0).getChildNodes().item(0).getNodeValue());
|
||||||
} catch (NullPointerException e)
|
} catch (NullPointerException e) {
|
||||||
{
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
arrays.PodcastTitle[i] = "Echec";
|
arrays.PodcastTitle[i] = "Echec";
|
||||||
}
|
}
|
||||||
@ -482,21 +463,17 @@ import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_DATE;
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
arrays.PodcastDate[i] = null;
|
arrays.PodcastDate[i] = null;
|
||||||
}
|
}
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
arrays.PodcastURL[i] = link.item(0).getChildNodes()
|
arrays.PodcastURL[i] = link.item(0).getChildNodes()
|
||||||
.item(0).getNodeValue();
|
.item(0).getNodeValue();
|
||||||
} catch (NullPointerException e)
|
} catch (NullPointerException e) {
|
||||||
{
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
arrays.PodcastURL[i] = "Echec";
|
arrays.PodcastURL[i] = "Echec";
|
||||||
}
|
}
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
arrays.PodcastContent[i] = content.item(0)
|
arrays.PodcastContent[i] = content.item(0)
|
||||||
.getChildNodes().item(0).getNodeValue();
|
.getChildNodes().item(0).getNodeValue();
|
||||||
} catch (NullPointerException e)
|
} catch (NullPointerException e) {
|
||||||
{
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
arrays.PodcastContent[i] = "Echec";
|
arrays.PodcastContent[i] = "Echec";
|
||||||
}
|
}
|
||||||
|
@ -1,39 +1,28 @@
|
|||||||
package fr.gaulupeau.apps.Poche;
|
package fr.gaulupeau.apps.Poche;
|
||||||
|
|
||||||
import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARCHIVE;
|
|
||||||
import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_CONTENT;
|
|
||||||
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.ArticlesSQLiteOpenHelper.ARTICLE_AUTHOR;
|
|
||||||
import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.MY_ID;
|
|
||||||
|
|
||||||
import android.annotation.TargetApi;
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.content.ContentValues;
|
import android.content.ContentValues;
|
||||||
import android.content.Context;
|
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.database.sqlite.SQLiteDatabase;
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.MenuItem;
|
|
||||||
import android.view.MotionEvent;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.view.View.OnTouchListener;
|
|
||||||
import android.view.Window;
|
|
||||||
import android.webkit.WebChromeClient;
|
|
||||||
import android.webkit.WebView;
|
import android.webkit.WebView;
|
||||||
import android.webkit.WebViewClient;
|
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.ScrollView;
|
import android.widget.ScrollView;
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
|
||||||
import fr.gaulupeau.apps.InThePoche.R;
|
import fr.gaulupeau.apps.InThePoche.R;
|
||||||
|
|
||||||
|
import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARCHIVE;
|
||||||
|
import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_AUTHOR;
|
||||||
|
import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_CONTENT;
|
||||||
|
import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_ID;
|
||||||
|
import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_TABLE;
|
||||||
|
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.MY_ID;
|
||||||
|
|
||||||
public class ReadArticle extends BaseActionBarActivity {
|
public class ReadArticle extends BaseActionBarActivity {
|
||||||
WebView webViewContent;
|
WebView webViewContent;
|
||||||
Button btnMarkRead;
|
Button btnMarkRead;
|
||||||
@ -42,17 +31,15 @@ public class ReadArticle extends BaseActionBarActivity {
|
|||||||
ScrollView view;
|
ScrollView view;
|
||||||
|
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
|
|
||||||
requestWindowFeature(Window.FEATURE_PROGRESS);
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.article);
|
setContentView(R.layout.article);
|
||||||
|
|
||||||
view = (ScrollView) findViewById(R.id.scroll);
|
view = (ScrollView) findViewById(R.id.scroll);
|
||||||
ArticlesSQLiteOpenHelper helper = new ArticlesSQLiteOpenHelper(getApplicationContext());
|
ArticlesSQLiteOpenHelper helper = new ArticlesSQLiteOpenHelper(getApplicationContext());
|
||||||
database = helper.getWritableDatabase();
|
database = helper.getWritableDatabase();
|
||||||
String[] getStrColumns = new String[] {ARTICLE_URL, MY_ID, ARTICLE_TITLE, ARTICLE_CONTENT, ARCHIVE, ARTICLE_AUTHOR};
|
String[] getStrColumns = new String[]{ARTICLE_URL, MY_ID, ARTICLE_TITLE, ARTICLE_CONTENT, ARCHIVE, ARTICLE_AUTHOR};
|
||||||
Bundle data = getIntent().getExtras();
|
Bundle data = getIntent().getExtras();
|
||||||
if(data != null) {
|
if (data != null) {
|
||||||
id = data.getString("id");
|
id = data.getString("id");
|
||||||
}
|
}
|
||||||
Cursor ac = database.query(ARTICLE_TABLE, getStrColumns, MY_ID + "=" + id, null, null, null, null);
|
Cursor ac = database.query(ARTICLE_TABLE, getStrColumns, MY_ID + "=" + id, null, null, null, null);
|
||||||
@ -66,8 +53,7 @@ public class ReadArticle extends BaseActionBarActivity {
|
|||||||
try {
|
try {
|
||||||
URL originalUrl = new URL(originalUrlText);
|
URL originalUrl = new URL(originalUrlText);
|
||||||
originalUrlDesc = originalUrl.getHost();
|
originalUrlDesc = originalUrl.getHost();
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch (Exception e) {
|
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,8 +69,8 @@ public class ReadArticle extends BaseActionBarActivity {
|
|||||||
"\t\t\t\t<div id=\"content\" class=\"w600p center\">\n" +
|
"\t\t\t\t<div id=\"content\" class=\"w600p center\">\n" +
|
||||||
"\t\t\t\t\t<div id=\"article\">\n" +
|
"\t\t\t\t\t<div id=\"article\">\n" +
|
||||||
"\t\t\t\t\t\t<header class=\"mbm\">\n" +
|
"\t\t\t\t\t\t<header class=\"mbm\">\n" +
|
||||||
"\t\t\t\t\t\t\t<h1>"+ titleText +"</h1>\n" +
|
"\t\t\t\t\t\t\t<h1>" + titleText + "</h1>\n" +
|
||||||
"\t\t\t\t\t\t\t<p>Open Original: <a href=\""+ originalUrlText +"\">"+ originalUrlDesc +"</a></p>\n" +
|
"\t\t\t\t\t\t\t<p>Open Original: <a href=\"" + originalUrlText + "\">" + originalUrlDesc + "</a></p>\n" +
|
||||||
"\t\t\t\t\t\t</header>\n" +
|
"\t\t\t\t\t\t</header>\n" +
|
||||||
"\t\t\t\t\t\t<article>";
|
"\t\t\t\t\t\t<article>";
|
||||||
String htmlFooter = "</article>\n" +
|
String htmlFooter = "</article>\n" +
|
||||||
@ -95,22 +81,10 @@ public class ReadArticle extends BaseActionBarActivity {
|
|||||||
"</html>";
|
"</html>";
|
||||||
|
|
||||||
|
|
||||||
setProgressBarIndeterminateVisibility(true);
|
webViewContent = (WebView) findViewById(R.id.webViewContent);
|
||||||
setProgressBarVisibility(true);
|
|
||||||
|
|
||||||
webViewContent = (WebView)findViewById(R.id.webViewContent);
|
|
||||||
webViewContent.setWebChromeClient(new WebChromeClient() {
|
|
||||||
public void onProgressChanged(WebView view, int progress) {
|
|
||||||
setProgress(progress * 100);
|
|
||||||
if(progress == 100) {
|
|
||||||
setProgressBarIndeterminateVisibility(false);
|
|
||||||
setProgressBarVisibility(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
webViewContent.loadDataWithBaseURL("file:///android_asset/", htmlHeader + htmlContent + htmlFooter, "text/html", "utf-8", null);
|
webViewContent.loadDataWithBaseURL("file:///android_asset/", htmlHeader + htmlContent + htmlFooter, "text/html", "utf-8", null);
|
||||||
|
|
||||||
btnMarkRead = (Button)findViewById(R.id.btnMarkRead);
|
btnMarkRead = (Button) findViewById(R.id.btnMarkRead);
|
||||||
btnMarkRead.setOnClickListener(new OnClickListener() {
|
btnMarkRead.setOnClickListener(new OnClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,17 +1,16 @@
|
|||||||
package fr.gaulupeau.apps.Poche;
|
package fr.gaulupeau.apps.Poche;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import fr.gaulupeau.apps.InThePoche.R;
|
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.text.Html;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.BaseAdapter;
|
import android.widget.BaseAdapter;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import fr.gaulupeau.apps.InThePoche.R;
|
||||||
|
|
||||||
public class ReadingListAdapter extends BaseAdapter {
|
public class ReadingListAdapter extends BaseAdapter {
|
||||||
private Context context;
|
private Context context;
|
||||||
private List<Article> listArticles;
|
private List<Article> listArticles;
|
||||||
@ -37,8 +36,7 @@ public class ReadingListAdapter extends BaseAdapter {
|
|||||||
public View getView(int position, View convertView, ViewGroup parent) {
|
public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
Article entry = listArticles.get(position);
|
Article entry = listArticles.get(position);
|
||||||
if (convertView == null) {
|
if (convertView == null) {
|
||||||
LayoutInflater inflater = (LayoutInflater) context
|
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
|
||||||
convertView = inflater.inflate(R.layout.article_list, parent, false);
|
convertView = inflater.inflate(R.layout.article_list, parent, false);
|
||||||
}
|
}
|
||||||
TextView tvTitle = (TextView) convertView.findViewById(R.id.listitem_titre);
|
TextView tvTitle = (TextView) convertView.findViewById(R.id.listitem_titre);
|
||||||
@ -50,7 +48,4 @@ public class ReadingListAdapter extends BaseAdapter {
|
|||||||
return convertView;
|
return convertView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,22 @@
|
|||||||
package fr.gaulupeau.apps.Poche;
|
package fr.gaulupeau.apps.Poche;
|
||||||
|
|
||||||
import static fr.gaulupeau.apps.Poche.Helpers.PREFS_NAME;
|
|
||||||
import fr.gaulupeau.apps.InThePoche.R;
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.MenuItem;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import fr.gaulupeau.apps.InThePoche.R;
|
||||||
|
|
||||||
|
import static fr.gaulupeau.apps.Poche.Helpers.PREFS_NAME;
|
||||||
|
|
||||||
public class Settings extends BaseActionBarActivity {
|
public class Settings extends BaseActionBarActivity {
|
||||||
Button btnDone;
|
Button btnDone;
|
||||||
EditText editPocheUrl;
|
EditText editPocheUrl;
|
||||||
EditText editAPIUsername;
|
EditText editAPIUsername;
|
||||||
EditText editAPIToken;
|
EditText editAPIToken;
|
||||||
EditText editGlobalToken;
|
|
||||||
TextView textViewVersion;
|
TextView textViewVersion;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -30,13 +28,13 @@ public class Settings extends BaseActionBarActivity {
|
|||||||
String pocheUrl = settings.getString("pocheUrl", "http://");
|
String pocheUrl = settings.getString("pocheUrl", "http://");
|
||||||
String apiUsername = settings.getString("APIUsername", "");
|
String apiUsername = settings.getString("APIUsername", "");
|
||||||
String apiToken = settings.getString("APIToken", "");
|
String apiToken = settings.getString("APIToken", "");
|
||||||
editPocheUrl = (EditText)findViewById(R.id.pocheUrl);
|
editPocheUrl = (EditText) findViewById(R.id.pocheUrl);
|
||||||
editPocheUrl.setText(pocheUrl);
|
editPocheUrl.setText(pocheUrl);
|
||||||
editAPIUsername = (EditText)findViewById(R.id.APIUsername);
|
editAPIUsername = (EditText) findViewById(R.id.APIUsername);
|
||||||
editAPIUsername.setText(apiUsername);
|
editAPIUsername.setText(apiUsername);
|
||||||
editAPIToken = (EditText)findViewById(R.id.APIToken);
|
editAPIToken = (EditText) findViewById(R.id.APIToken);
|
||||||
editAPIToken.setText(apiToken);
|
editAPIToken.setText(apiToken);
|
||||||
btnDone = (Button)findViewById(R.id.btnDone);
|
btnDone = (Button) findViewById(R.id.btnDone);
|
||||||
btnDone.setOnClickListener(new OnClickListener() {
|
btnDone.setOnClickListener(new OnClickListener() {
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
|
SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user