diff --git a/app/src/main/java/fr/gaulupeau/apps/Poche/ListArticles.java b/app/src/main/java/fr/gaulupeau/apps/Poche/ListArticles.java index bc0b359..409bc80 100644 --- a/app/src/main/java/fr/gaulupeau/apps/Poche/ListArticles.java +++ b/app/src/main/java/fr/gaulupeau/apps/Poche/ListArticles.java @@ -7,6 +7,7 @@ import android.app.Activity; import android.content.Intent; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; +import android.os.Build; import android.os.Bundle; import android.view.Menu; import android.view.MenuInflater; @@ -24,6 +25,15 @@ public class ListArticles extends Activity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.list); + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { + try { + getActionBar().setDisplayHomeAsUpEnabled(true); + } catch (Exception e) { + // + } + } + setupDB(); setupList(false); } @@ -55,7 +65,10 @@ public class ListArticles extends Activity { ArticlesSQLiteOpenHelper helper = new ArticlesSQLiteOpenHelper(this); helper.truncateTables(database); setupList(false); - super.onOptionsItemSelected(item); + return super.onOptionsItemSelected(item); + case android.R.id.home: + this.finish(); + return super.onOptionsItemSelected(item); default: return super.onOptionsItemSelected(item); } diff --git a/app/src/main/java/fr/gaulupeau/apps/Poche/Poche.java b/app/src/main/java/fr/gaulupeau/apps/Poche/Poche.java index f92e307..62d716a 100644 --- a/app/src/main/java/fr/gaulupeau/apps/Poche/Poche.java +++ b/app/src/main/java/fr/gaulupeau/apps/Poche/Poche.java @@ -84,6 +84,7 @@ import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_DATE; Button btnDone; Button btnGetPost; Button btnSync; + Button btnSettings; EditText editPocheUrl; SharedPreferences settings; static String apiUsername; @@ -91,9 +92,8 @@ import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_DATE; static String pocheUrl; String action; - - - + + /** Called when the activity is first created. @@ -195,7 +195,14 @@ import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_DATE; startActivity(new Intent(getBaseContext(), ListArticles.class)); } }); - + + btnSettings = (Button)findViewById(R.id.btnSettings); + btnSettings.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View view) { + startActivity(new Intent(getBaseContext(), Settings.class)); + } + }); } } @@ -236,23 +243,6 @@ import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_DATE; } } - @Override - public boolean onCreateOptionsMenu(Menu menu) { - 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)); - default: - return super.onOptionsItemSelected(item); - } - } - @Override protected void onDestroy() { super.onDestroy(); @@ -268,7 +258,7 @@ import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_DATE; 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"); + btnGetPost.setText(String.format(getString(R.string.btnGetPost), news)); } }); } diff --git a/app/src/main/java/fr/gaulupeau/apps/Poche/ReadArticle.java b/app/src/main/java/fr/gaulupeau/apps/Poche/ReadArticle.java index bc722c5..39a54c8 100644 --- a/app/src/main/java/fr/gaulupeau/apps/Poche/ReadArticle.java +++ b/app/src/main/java/fr/gaulupeau/apps/Poche/ReadArticle.java @@ -14,7 +14,9 @@ import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; +import android.os.Build; import android.os.Bundle; +import android.view.MenuItem; import android.view.MotionEvent; import android.view.View; import android.view.View.OnClickListener; @@ -43,6 +45,15 @@ public class ReadArticle extends Activity { requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); requestWindowFeature(Window.FEATURE_PROGRESS); setContentView(R.layout.article); + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { + try { + getActionBar().setDisplayHomeAsUpEnabled(true); + } catch (Exception e) { + // + } + } + view = (ScrollView) findViewById(R.id.scroll); ArticlesSQLiteOpenHelper helper = new ArticlesSQLiteOpenHelper(getApplicationContext()); database = helper.getWritableDatabase(); @@ -137,5 +148,15 @@ public class ReadArticle extends Activity { super.onDestroy(); database.close(); } - + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case android.R.id.home: + this.finish(); + return super.onOptionsItemSelected(item); + default: + return super.onOptionsItemSelected(item); + } + } } diff --git a/app/src/main/java/fr/gaulupeau/apps/Poche/Settings.java b/app/src/main/java/fr/gaulupeau/apps/Poche/Settings.java index 35f6f9b..7cbd66b 100644 --- a/app/src/main/java/fr/gaulupeau/apps/Poche/Settings.java +++ b/app/src/main/java/fr/gaulupeau/apps/Poche/Settings.java @@ -4,7 +4,9 @@ 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.os.Build; import android.os.Bundle; +import android.view.MenuItem; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; @@ -23,6 +25,15 @@ public class Settings extends Activity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.settings); + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { + try { + getActionBar().setDisplayHomeAsUpEnabled(true); + } catch (Exception e) { + // + } + } + SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); String pocheUrl = settings.getString("pocheUrl", "http://"); String apiUsername = settings.getString("APIUsername", ""); @@ -52,4 +63,15 @@ public class Settings extends Activity { // } } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case android.R.id.home: + this.finish(); + return true; + default: + return super.onOptionsItemSelected(item); + } + } } diff --git a/app/src/main/res/layout/main.xml b/app/src/main/res/layout/main.xml index d121274..d42d94a 100644 --- a/app/src/main/res/layout/main.xml +++ b/app/src/main/res/layout/main.xml @@ -30,7 +30,8 @@ android:layout_height="match_parent" android:layout_gravity="center" android:text="@string/hello" - android:textSize="25sp" /> + android:textSize="25sp" + android:visibility="gone" /> +