articleView: moving MarkAsRead-button to actionBar (see issue #53)

This commit is contained in:
Kevin Meyer 2014-12-16 19:33:11 +01:00
parent e982dfb1b6
commit 038139b5b4
3 changed files with 33 additions and 53 deletions

View File

@ -4,6 +4,9 @@ import android.content.ContentValues;
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.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.webkit.WebView; import android.webkit.WebView;
@ -25,7 +28,6 @@ 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;
SQLiteDatabase database; SQLiteDatabase database;
String id = ""; String id = "";
ScrollView view; ScrollView view;
@ -86,22 +88,30 @@ public class ReadArticle extends BaseActionBarActivity {
webViewContent = (WebView) findViewById(R.id.webViewContent); webViewContent = (WebView) findViewById(R.id.webViewContent);
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.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
ContentValues values = new ContentValues();
values.put(ARCHIVE, 1);
database.update(ARTICLE_TABLE, values, MY_ID + "=" + id, null);
finish();
}
});
} }
@Override @Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.option_article, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.menuArticleMarkAsRead:
ContentValues values = new ContentValues();
values.put(ARCHIVE, 1);
database.update(ARTICLE_TABLE, values, MY_ID + "=" + id, null);
finish();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
@Override
protected void onStop() { protected void onStop() {
// TODO Auto-generated method stub // TODO Auto-generated method stub

View File

@ -7,43 +7,9 @@
android:id="@+id/scroll" android:id="@+id/scroll"
tools:context="fr.gaulupeau.apps.Poche.ReadArticle" > tools:context="fr.gaulupeau.apps.Poche.ReadArticle" >
<LinearLayout <WebView
android:layout_width="match_parent" android:id="@+id/webViewContent"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:orientation="vertical" android:layout_height="wrap_content" />
tools:ignore="WebViewLayout" >
<WebView
android:id="@+id/webViewContent"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="15sp"
android:paddingRight="15sp" >
<View
android:id="@+id/view1"
android:layout_width="fill_parent"
android:layout_height="1dip"
android:layout_marginBottom="5sp"
android:layout_marginTop="5sp"
android:background="#000000" />
<Button
android:id="@+id/btnMarkRead"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:text="@string/btnMarkRead" />
</LinearLayout>
</LinearLayout>
</ScrollView> </ScrollView>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/menuArticleMarkAsRead" android:title="@string/btnMarkRead" />
</menu>