mirror of
https://github.com/moparisthebest/android-app
synced 2024-12-24 07:28:51 -05:00
Added ReadAll option + some cosmetic changes.
This commit is contained in:
parent
de64e6320e
commit
ef3f3b73bb
@ -7,7 +7,7 @@
|
|||||||
<uses-permission android:name="android.permission.INTERNET"/>
|
<uses-permission android:name="android.permission.INTERNET"/>
|
||||||
|
|
||||||
|
|
||||||
<application android:icon="@drawable/icon" android:label="@string/app_name">
|
<application android:icon="@drawable/icon" android:label="@string/app_name" >
|
||||||
<activity android:name="fr.gaulupeau.apps.Poche.Poche"
|
<activity android:name="fr.gaulupeau.apps.Poche.Poche"
|
||||||
android:label="@string/app_name" android:theme="@android:style/Theme.Light.NoTitleBar">
|
android:label="@string/app_name" android:theme="@android:style/Theme.Light.NoTitleBar">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
|
@ -5,21 +5,19 @@
|
|||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical" >
|
android:orientation="vertical" >
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/txtTitre"
|
android:id="@+id/txtTitre"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Titre"
|
|
||||||
android:textSize="25sp" />
|
android:textSize="25sp" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/txtAuthor"
|
android:id="@+id/txtAuthor"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Author"
|
|
||||||
android:textSize="12sp" />
|
android:textSize="12sp" />
|
||||||
|
|
||||||
<View
|
<View
|
||||||
@ -32,7 +30,6 @@
|
|||||||
android:id="@+id/txtContent"
|
android:id="@+id/txtContent"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Contenu"
|
|
||||||
android:textSize="18sp" />
|
android:textSize="18sp" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
|
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||||
<item android:id="@+id/menuSettings"
|
<item android:id="@+id/menuSettings"
|
||||||
android:title="@string/menuSettings" />
|
android:icon="@android:drawable/ic_menu_preferences" android:enabled="true" android:menuCategory="system" android:visible="true"/>
|
||||||
|
|
||||||
</menu>
|
</menu>
|
||||||
|
6
res/menu/option_list.xml
Normal file
6
res/menu/option_list.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||||
|
<item android:id="@+id/menuShowAll" android:title="@string/menuShowAll"></item>
|
||||||
|
|
||||||
|
|
||||||
|
</menu>
|
@ -14,4 +14,5 @@
|
|||||||
<string name="btnSync">Synchronize</string>
|
<string name="btnSync">Synchronize</string>
|
||||||
<string name="btnMarkRead">Mark as Read</string>
|
<string name="btnMarkRead">Mark as Read</string>
|
||||||
<string name="menuSettings">Settings</string>
|
<string name="menuSettings">Settings</string>
|
||||||
|
<string name="menuShowAll">Show All</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -8,7 +8,9 @@ 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.Bundle;
|
import android.os.Bundle;
|
||||||
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.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
@ -23,28 +25,49 @@ public class ListArticles extends Activity {
|
|||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.list);
|
setContentView(R.layout.list);
|
||||||
setupDB();
|
setupDB();
|
||||||
setupList();
|
setupList(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
setupList();
|
setupList(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
database.close();
|
database.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
|
MenuInflater inflater = getMenuInflater();
|
||||||
|
inflater.inflate(R.menu.option_list, menu);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
switch (item.getItemId()) {
|
||||||
|
case R.id.menuShowAll:
|
||||||
|
setupList(true);
|
||||||
|
default:
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void setupDB() {
|
public void setupDB() {
|
||||||
ArticlesSQLiteOpenHelper helper = new ArticlesSQLiteOpenHelper(this);
|
ArticlesSQLiteOpenHelper helper = new ArticlesSQLiteOpenHelper(this);
|
||||||
database = helper.getWritableDatabase();
|
database = helper.getWritableDatabase();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setupList() {
|
public void setupList(Boolean showAll) {
|
||||||
readList = (ListView) findViewById(R.id.liste_articles);
|
readList = (ListView) findViewById(R.id.liste_articles);
|
||||||
readArticlesInfo = new ArrayList<Article>();
|
readArticlesInfo = new ArrayList<Article>();
|
||||||
ReadingListAdapter ad = getAdapterQuery(ARCHIVE + "=0", readArticlesInfo);
|
String filter = null;
|
||||||
|
if (showAll == false) {
|
||||||
|
filter = ARCHIVE + "=0";
|
||||||
|
}
|
||||||
|
ReadingListAdapter ad = getAdapterQuery(filter, readArticlesInfo);
|
||||||
readList.setAdapter(ad);
|
readList.setAdapter(ad);
|
||||||
|
|
||||||
readList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
readList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||||
|
@ -21,7 +21,6 @@ import org.json.JSONObject;
|
|||||||
import android.annotation.TargetApi;
|
import android.annotation.TargetApi;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.ContentValues;
|
import android.content.ContentValues;
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.database.sqlite.SQLiteConstraintException;
|
import android.database.sqlite.SQLiteConstraintException;
|
||||||
@ -31,9 +30,7 @@ import android.os.Build;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.provider.Browser;
|
import android.provider.Browser;
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
import android.text.InputFilter.LengthFilter;
|
|
||||||
import android.util.Base64;
|
import android.util.Base64;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuInflater;
|
import android.view.MenuInflater;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
@ -41,7 +38,6 @@ 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 static fr.gaulupeau.apps.Poche.Helpers.PREFS_NAME;
|
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_TABLE;
|
||||||
import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_ID;
|
import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_ID;
|
||||||
@ -85,7 +81,6 @@ import static fr.gaulupeau.apps.Poche.Helpers.getInputStreamFromUrl;
|
|||||||
try {
|
try {
|
||||||
data = pageUrl.getBytes("UTF-8");
|
data = pageUrl.getBytes("UTF-8");
|
||||||
} catch (UnsupportedEncodingException e) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
String base64 = Base64.encodeToString(data, Base64.DEFAULT);
|
String base64 = Base64.encodeToString(data, Base64.DEFAULT);
|
||||||
@ -100,14 +95,10 @@ import static fr.gaulupeau.apps.Poche.Helpers.getInputStreamFromUrl;
|
|||||||
// select which one they want to use
|
// select which one they want to use
|
||||||
|
|
||||||
startActivity(i);
|
startActivity(i);
|
||||||
// That is all this app needs to do, so call finish()
|
|
||||||
this.finish();
|
this.finish();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// app has been launched from menu - show information window
|
|
||||||
setContentView(R.layout.main);
|
setContentView(R.layout.main);
|
||||||
// handle done/close button
|
|
||||||
|
|
||||||
|
|
||||||
btnSync = (Button)findViewById(R.id.btnSync);
|
btnSync = (Button)findViewById(R.id.btnSync);
|
||||||
btnSync.setOnClickListener(new OnClickListener() {
|
btnSync.setOnClickListener(new OnClickListener() {
|
||||||
@ -149,15 +140,13 @@ import static fr.gaulupeau.apps.Poche.Helpers.getInputStreamFromUrl;
|
|||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
updateUnread();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
ArticlesSQLiteOpenHelper helper = new ArticlesSQLiteOpenHelper(getApplicationContext());
|
|
||||||
database = helper.getReadableDatabase();
|
|
||||||
int news = database.query(ARTICLE_TABLE, null, ARCHIVE + "=0", null, null, null, null).getCount();
|
|
||||||
|
|
||||||
btnGetPost = (Button)findViewById(R.id.btnGetPost);
|
btnGetPost = (Button)findViewById(R.id.btnGetPost);
|
||||||
btnGetPost.append(" - " + news + " unread");
|
updateUnread();
|
||||||
|
|
||||||
btnGetPost.setOnClickListener(new OnClickListener() {
|
btnGetPost.setOnClickListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
@ -168,31 +157,34 @@ import static fr.gaulupeau.apps.Poche.Helpers.getInputStreamFromUrl;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
ArticlesSQLiteOpenHelper helper = new ArticlesSQLiteOpenHelper(getApplicationContext());
|
updateUnread();
|
||||||
database = helper.getReadableDatabase();
|
}
|
||||||
int news = database.query(ARTICLE_TABLE, null, ARCHIVE + "=0", null, null, null, null).getCount();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
MenuInflater inflater = getMenuInflater();
|
MenuInflater inflater = getMenuInflater();
|
||||||
inflater.inflate(R.menu.option, menu);
|
inflater.inflate(R.menu.option, menu);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
case R.id.menuSettings:
|
case R.id.menuSettings:
|
||||||
startActivity(new Intent(getBaseContext(), Settings.class));
|
startActivity(new Intent(getBaseContext(), Settings.class));
|
||||||
// write code to execute when clicked on this option
|
default:
|
||||||
//return true;
|
return super.onOptionsItemSelected(item);
|
||||||
default:
|
}
|
||||||
return super.onOptionsItemSelected(item);
|
}
|
||||||
}
|
|
||||||
|
private void updateUnread(){
|
||||||
|
ArticlesSQLiteOpenHelper helper = new ArticlesSQLiteOpenHelper(getApplicationContext());
|
||||||
|
database = helper.getReadableDatabase();
|
||||||
|
int news = database.query(ARTICLE_TABLE, null, ARCHIVE + "=0", null, null, null, null).getCount();
|
||||||
|
btnGetPost.setText(getString(R.string.btnGetPost) + " - " + news + " unread");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,6 @@ 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;
|
|
||||||
|
|
||||||
public class Settings extends Activity {
|
public class Settings extends Activity {
|
||||||
Button btnDone;
|
Button btnDone;
|
||||||
@ -17,7 +16,6 @@ public class Settings extends Activity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.settings);
|
setContentView(R.layout.settings);
|
||||||
SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
|
SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
|
||||||
@ -28,7 +26,6 @@ public class Settings extends Activity {
|
|||||||
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) {
|
||||||
// close the app
|
|
||||||
SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
|
SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
|
||||||
SharedPreferences.Editor editor = settings.edit();
|
SharedPreferences.Editor editor = settings.edit();
|
||||||
editor.putString("pocheUrl", editPocheUrl.getText().toString());
|
editor.putString("pocheUrl", editPocheUrl.getText().toString());
|
||||||
|
Loading…
Reference in New Issue
Block a user