From 7fcd254b80917c86e3f05b0ac7daef898babc64d Mon Sep 17 00:00:00 2001 From: Kevin Meyer Date: Wed, 20 Aug 2014 10:53:12 +0200 Subject: [PATCH 1/3] added "settings" button to main view. Removed options menu from main view. --- .../java/fr/gaulupeau/apps/Poche/Poche.java | 34 +++++++------------ app/src/main/res/layout/main.xml | 10 +++++- app/src/main/res/menu/option.xml | 5 --- app/src/main/res/values/strings.xml | 6 ++-- 4 files changed, 24 insertions(+), 31 deletions(-) delete mode 100644 app/src/main/res/menu/option.xml 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 f92e307f8..62d716a80 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 @@ Button btnDone; Button btnGetPost; Button btnSync; + Button btnSettings; EditText editPocheUrl; SharedPreferences settings; static String apiUsername; @@ -91,9 +92,8 @@ static String pocheUrl; String action; - - - + + /** Called when the activity is first created. @@ -195,7 +195,14 @@ public void onClick(View v) { 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 @@ protected void onResume() { } } - @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 @@ public void run() 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/res/layout/main.xml b/app/src/main/res/layout/main.xml index d121274ac..d42d94a33 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" /> +