improved article style: using same style as in iphone app

This commit is contained in:
Kevin Meyer 2014-08-19 13:15:02 +02:00
parent 4c5c27fedc
commit 65089ff16c
4 changed files with 444 additions and 44 deletions

243
assets/main.css Executable file
View File

@ -0,0 +1,243 @@
/* ==========================================================================
Sommaire
1 = Style Guide
2 = Layout
3 = Pictos
4 = Messages
5 = Article
6 = Media queries
========================================================================== */
html {
min-height: 100%;
}
body {
background: #EEE;
}
/* ==========================================================================
1 = Style Guide
========================================================================== */
::selection {
color: #FFF;
background: #000;
}
h2, h3, h4 {
font-family: 'PT Sans', sans-serif;
text-transform: uppercase;
}
p, li {
color: #666;
}
a {
color: #000;
font-weight: bold;
}
a:hover, a:focus {
text-decoration: none;
}
h2:after {
content: "";
height: 4px;
width: 70px;
background: #000;
display: block;
}
.links {
padding: 0;
margin: 0;
}
.links li {
list-style: none;
margin: 0;
padding: 0;
}
#links {
position: fixed;
top: 0;
width: 10em;
left: 0;
text-align: right;
background: #333;
padding-top: 9.5em;
height: 100%;
box-shadow:inset -4px 0 20px rgba(0,0,0,0.6);
z-index: 10;
}
#main {
margin-left: 13em;
position: relative;
z-index: 10;
padding-right: 5%;
padding-bottom: 1em;
}
#links a {
display: block;
padding: 0.5em 2em 0.5em 1em;
color: #FFF;
position: relative;
text-transform: uppercase;
text-decoration: none;
font-weight: normal;
font-family: 'PT Sans', sans-serif;
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
-ms-transition: all 0.5s ease;
-o-transition: all 0.5s ease;
transition: all 0.5s ease;
}
#links a:hover, #links a:focus {
background: #999;
color: #000;
}
#links .current:after {
content: "";
width: 0;
height: 0;
position: absolute;
border-style: solid;
border-width: 10px;
border-color: transparent #EEE transparent transparent;
right: 0;
top: 50%;
margin-top: -10px;
}
#links li:last-child {
position: fixed;
bottom: 1em;
width: 10em;
}
#links li:last-child a:before {
font-size: 1.2em;
position: relative;
top: 2px;
}
/* ==========================================================================
2 = Layout
========================================================================== */
#content {
margin-top: 1em;
min-height: 30em;
}
footer {
text-align: right;
position: relative;
bottom: 0;
right: 5em;
color: #999;
font-size: 0.8em;
font-style: italic;
z-index: 20;
}
footer a {
color: #999;
font-weight: normal;
}
/* ==========================================================================
5 = Article
========================================================================== */
header.mbm {
text-align: left;
}
#article {
width: 70%;
/* margin-bottom: 3em; */
text-align: justify;
word-wrap: break-word;
}
#article .tags {
margin-bottom: 1em;
}
#article i {
font-style: normal;
}
blockquote {
border:1px solid #999;
background: #FFF;
padding: 1em;
margin: 0;
}
#article h2, #article h3, #article h4 {
text-transform: none;
}
#article h2:after {
content: none;
}
/* ==========================================================================
6 = Media Queries
========================================================================== */
@media screen {
body > header {
background: #333;
position: fixed;
top: 0;
width: 100%;
height: 3em;
z-index: 11;
}
#links li:last-child {
position: static;
width: auto;
}
#links li:last-child a:before {
content: none;
}
#links {
display: none;
width: 100%;
height: auto;
padding-top: 3em;
}
footer {
position: static;
margin-right: 3em;
}
#main {
margin-left: 1.5em;
padding-right: 1.5em;
position: static;
}
#article {
width: 100%;
}
#article h1 {
font-size: 1.2em;
}
}

155
assets/ratatouille.css Normal file
View File

@ -0,0 +1,155 @@
/*
Ratatouille mini Framework css by Thomas LEBEAU
Base on KNACSS => www.KNACSS.com (2013-10) @author: Raphael Goetter, Alsacreations
and normalize.css
*/
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
html {
font-family: sans-serif; /* 1 */
-ms-text-size-adjust: 100%; /* 2 */
-webkit-text-size-adjust: 100%; /* 2 */
}
body {
font-size: 1em;
line-height:1.5;
margin: 0;
}
/* ==========================================================================
Mise en forme
========================================================================== */
h1:first-child,
h2:first-child,
h3:first-child,
h4:first-child,
h5:first-child,
h6:first-child,
p:first-child,
ul:first-child,
ol:first-child,
dl:first-child{
margin-top: 0;
}
code,
kbd,
pre,
samp {
font-family: monospace, serif;
}
pre {
white-space: pre-wrap;
}
.upper {
text-transform: uppercase;
}
.bold {
font-weight: bold;
}
.inner {
margin: 0 auto;
max-width: 61.25em;/*980px*/
}
table, img {
max-width: 100%;
height :auto;
}
iframe {
max-width: 100%;
}
.fl {
float: left;
}
.fr {
float: right;
}
table {
border-collapse: collapse;
}
figure {
margin: 0;
}
button,
input,
select,
textarea {
font-family: inherit;
font-size: 100%;
margin: 0;
}
input[type="search"] {
-webkit-appearance: textfield;
}
/* ==========================================================================
Mise en page
========================================================================== */
.dib {
display: inline-block;
vertical-align: middle;
}
.dnone {
display: none;
}
.dtable { display:table }
.dtable > * { display:table-row; }
.dtable > * > * { display:table-cell; }
.element-invisible {
border: 0;
clip: rect(0 0 0 0);
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
}
.small {
font-size:0.8em;
}
.big {
font-size: 1.2em;
}
/*Width*/
.w100 { width:100%; }
.w90 { width:90%; }
.w80 { width:80%; }
.w70 { width:70%; }
.w60 { width:60%; }
.w50 { width:50%; }
.w40 { width:40%; }
.w30 { width:30%; }
.w20 { width:20%; }
.w10 { width:10%; }

View File

@ -7,49 +7,36 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="15sp"
android:paddingRight="15sp"
android:paddingTop="15dp" >
<TextView
android:id="@+id/txtTitre"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="25sp" />
<TextView
android:id="@+id/txtAuthor"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="12sp" />
<View
android:id="@+id/viewLine"
android:layout_width="fill_parent"
android:layout_height="1dip"
android:layout_marginBottom="5sp"
android:layout_marginTop="5sp"
android:background="#000000" />
android:orientation="vertical" >
<WebView
android:id="@+id/webViewContent"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<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"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/btnMarkRead" />
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:text="@string/btnMarkRead" />
</LinearLayout>
</LinearLayout>

View File

@ -23,12 +23,13 @@ import android.webkit.WebView;
import android.widget.Button;
import android.widget.ScrollView;
import android.widget.TextView;
import java.net.URL;
import fr.gaulupeau.apps.InThePoche.R;
public class ReadArticle extends Activity {
TextView txtTitre;
WebView webViewContent;
TextView txtAuthor;
Button btnMarkRead;
SQLiteDatabase database;
String id = "";
@ -47,18 +48,35 @@ public class ReadArticle extends Activity {
}
Cursor ac = database.query(ARTICLE_TABLE, getStrColumns, MY_ID + "=" + id, null, null, null, null);
ac.moveToFirst();
txtTitre = (TextView)findViewById(R.id.txtTitre);
txtTitre.setText(ac.getString(2));
String titleText = ac.getString(2);
String originalUrlText = ac.getString(0);
String originalUrlDesc = originalUrlText;
String htmlContent = ac.getString(3);
try {
URL originalUrl = new URL(originalUrlText);
originalUrlDesc = originalUrl.getHost();
}
catch (Exception e) {
//
}
String htmlHeader = "<html>\n" +
"\t<head>\n" +
"\t\t<meta name=\"viewport\" content=\"initial-scale=1.0, maximum-scale=1.0, user-scalable=no\" />\n" +
"\t\t<meta charset=\"utf-8\">\n" +
"\t\t<link rel=\"stylesheet\" href=\"main.css\" media=\"all\" id=\"main-theme\">\n" +
"\t\t<link rel=\"stylesheet\" href=\"ratatouille.css\" media=\"all\" id=\"extra-theme\">\n" +
"\t</head>\n" +
"\t\t<div id=\"main\">\n" +
"\t\t\t<body>\n" +
"\t\t\t\t<div id=\"content\" class=\"w600p center\">\n" +
"\t\t\t\t\t<div id=\"article\">\n" +
"\t\t\t\t\t\t<header class=\"mbm\">\n" +
"\t\t\t\t\t\t\t<h1>"+ titleText +"</h1>\n" +
"\t\t\t\t\t\t\t<p>Open Original: <a href=\""+ originalUrlText +"\">"+ originalUrlDesc +"</a></p>\n" +
"\t\t\t\t\t\t</header>\n" +
"\t\t\t\t\t\t<article>";
String htmlFooter = "</article>\n" +
"\t\t\t\t\t</div>\n" +
@ -66,15 +84,12 @@ public class ReadArticle extends Activity {
"\t\t\t</body>\n" +
"\t\t</div>\n" +
"</html>";
String htmlContent = ac.getString(3);
webViewContent = (WebView)findViewById(R.id.webViewContent);
webViewContent.loadData(htmlHeader + htmlContent + htmlFooter, "text/html; charset=utf-8", null);
webViewContent.loadDataWithBaseURL("file:///android_asset/", htmlHeader + htmlContent + htmlFooter, "text/html", "utf-8", null);
txtAuthor = (TextView)findViewById(R.id.txtAuthor);
txtAuthor.setText(ac.getString(0));
btnMarkRead = (Button)findViewById(R.id.btnMarkRead);
btnMarkRead.setOnClickListener(new OnClickListener() {