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