diff --git a/.gitignore b/.gitignore index 7843a1d..7e05cf1 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,8 @@ gen/ *.apk *.ap_ *.class +.idea/ +.gradle/ +build/ +gradle/ +local.properties diff --git a/AndroidManifest.xml b/AndroidManifest.xml deleted file mode 100644 index 0df62b6..0000000 --- a/AndroidManifest.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/android-app.iml b/android-app.iml new file mode 100644 index 0000000..0bb6048 --- /dev/null +++ b/android-app.iml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/app.iml b/app/app.iml new file mode 100644 index 0000000..227bfdd --- /dev/null +++ b/app/app.iml @@ -0,0 +1,87 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..b8146b3 --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,24 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 20 + buildToolsVersion '20' + + defaultConfig { + applicationId "fr.gaulupeau.apps.InThePoche" + minSdkVersion 8 + targetSdkVersion 20 + versionCode 9 + versionName "1.6" + } + buildTypes { + release { + runProguard false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + compile 'com.android.support:appcompat-v7:20.0.0' +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..2d34300 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,16 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..9466ad0 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/assets/main.css b/app/src/main/assets/main.css new file mode 100755 index 0000000..40f485e --- /dev/null +++ b/app/src/main/assets/main.css @@ -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; + } +} diff --git a/app/src/main/assets/ratatouille.css b/app/src/main/assets/ratatouille.css new file mode 100644 index 0000000..1901693 --- /dev/null +++ b/app/src/main/assets/ratatouille.css @@ -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%; } + diff --git a/src/fr/gaulupeau/apps/Poche/Article.java b/app/src/main/java/fr/gaulupeau/apps/Poche/Article.java similarity index 100% rename from src/fr/gaulupeau/apps/Poche/Article.java rename to app/src/main/java/fr/gaulupeau/apps/Poche/Article.java diff --git a/src/fr/gaulupeau/apps/Poche/ArticlesSQLiteOpenHelper.java b/app/src/main/java/fr/gaulupeau/apps/Poche/ArticlesSQLiteOpenHelper.java similarity index 100% rename from src/fr/gaulupeau/apps/Poche/ArticlesSQLiteOpenHelper.java rename to app/src/main/java/fr/gaulupeau/apps/Poche/ArticlesSQLiteOpenHelper.java diff --git a/src/fr/gaulupeau/apps/Poche/Helpers.java b/app/src/main/java/fr/gaulupeau/apps/Poche/Helpers.java similarity index 100% rename from src/fr/gaulupeau/apps/Poche/Helpers.java rename to app/src/main/java/fr/gaulupeau/apps/Poche/Helpers.java diff --git a/src/fr/gaulupeau/apps/Poche/ListArticles.java b/app/src/main/java/fr/gaulupeau/apps/Poche/ListArticles.java similarity index 100% rename from src/fr/gaulupeau/apps/Poche/ListArticles.java rename to app/src/main/java/fr/gaulupeau/apps/Poche/ListArticles.java diff --git a/src/fr/gaulupeau/apps/Poche/Poche.java b/app/src/main/java/fr/gaulupeau/apps/Poche/Poche.java similarity index 94% rename from src/fr/gaulupeau/apps/Poche/Poche.java rename to app/src/main/java/fr/gaulupeau/apps/Poche/Poche.java index cb0c2c9..f92e307 100644 --- a/src/fr/gaulupeau/apps/Poche/Poche.java +++ b/app/src/main/java/fr/gaulupeau/apps/Poche/Poche.java @@ -53,6 +53,7 @@ import android.net.NetworkInfo; import android.net.Uri; import android.os.Build; import android.os.Bundle; +import android.preference.PreferenceManager; import android.provider.Browser; import android.text.Html; import android.util.Base64; @@ -150,6 +151,7 @@ import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_DATE; } else { setContentView(R.layout.main); + checkAndHandleAfterUpdate(); btnSync = (Button)findViewById(R.id.btnSync); btnSync.setOnClickListener(new OnClickListener() { @@ -162,10 +164,18 @@ import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_DATE; showToast(getString(R.string.txtConfigNotSet)); } else if (activeNetwork != null && activeNetwork.isConnected()) { // Exécution de la synchro en arrière-plan + findViewById(R.id.progressBar1).setVisibility(View.VISIBLE); new Thread(new Runnable() { + @Override public void run() { //pushRead(); parseRSS(); + runOnUiThread(new Runnable() { + @Override + public void run() { + findViewById(R.id.progressBar1).setVisibility(View.GONE); + } + }); } }).start(); } else { @@ -188,7 +198,28 @@ import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_DATE; } } - + + private void checkAndHandleAfterUpdate() { + SharedPreferences pref = getSharedPreferences(PREFS_NAME, 0); + + if (pref.getInt("update_checker",0) < 9) { + // Wipe Database, because we now save HTML content instead of plain text + ArticlesSQLiteOpenHelper helper = new ArticlesSQLiteOpenHelper(this); + database = helper.getReadableDatabase(); + helper.truncateTables(database); + showToast("Update: Wiped Database. Please synchronize."); + } + + int versionCode; + try { + versionCode = getApplicationContext().getPackageManager().getPackageInfo(getApplicationContext().getPackageName(), 0).versionCode; + } catch (Exception e) { + versionCode = 0; + } + + pref.edit().putInt("update_checker", versionCode).commit(); + } + private void getSettings(){ settings = getSharedPreferences(PREFS_NAME, 0); pocheUrl = settings.getString("pocheUrl", "http://"); @@ -461,10 +492,10 @@ import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_DATE; } ContentValues values = new ContentValues(); - values.put(ARTICLE_TITLE, Html.fromHtml(arrays.PodcastTitle[i]).toString()); - values.put(ARTICLE_CONTENT, Html.fromHtml(arrays.PodcastContent[i]).toString()); + values.put(ARTICLE_TITLE, arrays.PodcastTitle[i]); + values.put(ARTICLE_CONTENT, arrays.PodcastContent[i]); //values.put(ARTICLE_ID, Html.fromHtml(article.getString("id")).toString()); - values.put(ARTICLE_URL, Html.fromHtml(arrays.PodcastURL[i]).toString()); + values.put(ARTICLE_URL, arrays.PodcastURL[i]); values.put(ARTICLE_DATE, arrays.PodcastDate[i]); values.put(ARCHIVE, 0); values.put(ARTICLE_SYNC, 0); diff --git a/src/fr/gaulupeau/apps/Poche/ReadArticle.java b/app/src/main/java/fr/gaulupeau/apps/Poche/ReadArticle.java similarity index 55% rename from src/fr/gaulupeau/apps/Poche/ReadArticle.java rename to app/src/main/java/fr/gaulupeau/apps/Poche/ReadArticle.java index aa724e1..bc722c5 100644 --- a/src/fr/gaulupeau/apps/Poche/ReadArticle.java +++ b/app/src/main/java/fr/gaulupeau/apps/Poche/ReadArticle.java @@ -19,16 +19,20 @@ import android.view.MotionEvent; import android.view.View; import android.view.View.OnClickListener; import android.view.View.OnTouchListener; +import android.view.Window; +import android.webkit.WebChromeClient; import android.webkit.WebView; +import android.webkit.WebViewClient; 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; - TextView txtContent; - TextView txtAuthor; + WebView webViewContent; Button btnMarkRead; SQLiteDatabase database; String id = ""; @@ -36,6 +40,8 @@ public class ReadArticle extends Activity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); + requestWindowFeature(Window.FEATURE_PROGRESS); setContentView(R.layout.article); view = (ScrollView) findViewById(R.id.scroll); ArticlesSQLiteOpenHelper helper = new ArticlesSQLiteOpenHelper(getApplicationContext()); @@ -47,13 +53,59 @@ 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)); - txtContent = (TextView)findViewById(R.id.txtContent); - txtContent.setText(ac.getString(3)); - - txtAuthor = (TextView)findViewById(R.id.txtAuthor); - txtAuthor.setText(ac.getString(0)); + + 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 = "\n" + + "\t\n" + + "\t\t\n" + + "\t\t\n" + + "\t\t\n" + + "\t\t\n" + + "\t\n" + + "\t\t
\n" + + "\t\t\t\n" + + "\t\t\t\t
\n" + + "\t\t\t\t\t
\n" + + "\t\t\t\t\t\t
\n" + + "\t\t\t\t\t\t\t

"+ titleText +"

\n" + + "\t\t\t\t\t\t\t

Open Original: "+ originalUrlDesc +"

\n" + + "\t\t\t\t\t\t
\n" + + "\t\t\t\t\t\t
"; + String htmlFooter = "
\n" + + "\t\t\t\t\t
\n" + + "\t\t\t\t
\n" + + "\t\t\t\n" + + "\t\t
\n" + + ""; + + + setProgressBarIndeterminateVisibility(true); + setProgressBarVisibility(true); + + webViewContent = (WebView)findViewById(R.id.webViewContent); + webViewContent.setWebChromeClient(new WebChromeClient() { + public void onProgressChanged(WebView view, int progress) { + setProgress(progress * 100); + if(progress == 100) { + setProgressBarIndeterminateVisibility(false); + setProgressBarVisibility(false); + } + } + }); + webViewContent.loadDataWithBaseURL("file:///android_asset/", htmlHeader + htmlContent + htmlFooter, "text/html", "utf-8", null); + btnMarkRead = (Button)findViewById(R.id.btnMarkRead); btnMarkRead.setOnClickListener(new OnClickListener() { diff --git a/src/fr/gaulupeau/apps/Poche/ReadingListAdapter.java b/app/src/main/java/fr/gaulupeau/apps/Poche/ReadingListAdapter.java similarity index 100% rename from src/fr/gaulupeau/apps/Poche/ReadingListAdapter.java rename to app/src/main/java/fr/gaulupeau/apps/Poche/ReadingListAdapter.java diff --git a/src/fr/gaulupeau/apps/Poche/Settings.java b/app/src/main/java/fr/gaulupeau/apps/Poche/Settings.java similarity index 85% rename from src/fr/gaulupeau/apps/Poche/Settings.java rename to app/src/main/java/fr/gaulupeau/apps/Poche/Settings.java index ce2006b..35f6f9b 100644 --- a/src/fr/gaulupeau/apps/Poche/Settings.java +++ b/app/src/main/java/fr/gaulupeau/apps/Poche/Settings.java @@ -9,6 +9,7 @@ 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; @@ -16,6 +17,7 @@ public class Settings extends Activity { EditText editAPIUsername; EditText editAPIToken; EditText editGlobalToken; + TextView textViewVersion; @Override protected void onCreate(Bundle savedInstanceState) { @@ -43,5 +45,11 @@ public class Settings extends Activity { finish(); } }); + try { + textViewVersion = (TextView) findViewById(R.id.version); + textViewVersion.setText(getApplicationContext().getPackageManager().getPackageInfo(getApplicationContext().getPackageName(), 0).versionName); + } catch (Exception e) { + // + } } } diff --git a/src/fr/gaulupeau/apps/Poche/arrays.java b/app/src/main/java/fr/gaulupeau/apps/Poche/arrays.java similarity index 100% rename from src/fr/gaulupeau/apps/Poche/arrays.java rename to app/src/main/java/fr/gaulupeau/apps/Poche/arrays.java diff --git a/app/src/main/res/drawable-hdpi/icon.png b/app/src/main/res/drawable-hdpi/icon.png new file mode 100755 index 0000000..c6d179d Binary files /dev/null and b/app/src/main/res/drawable-hdpi/icon.png differ diff --git a/app/src/main/res/drawable-mdpi/icon.png b/app/src/main/res/drawable-mdpi/icon.png new file mode 100755 index 0000000..8d2a8b6 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/icon.png differ diff --git a/app/src/main/res/drawable-xhdpi/icon.png b/app/src/main/res/drawable-xhdpi/icon.png new file mode 100755 index 0000000..b3e9263 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/icon.png differ diff --git a/app/src/main/res/drawable-xxhdpi/icon.png b/app/src/main/res/drawable-xxhdpi/icon.png new file mode 100755 index 0000000..a6c2d0e Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/icon.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/icon.png b/app/src/main/res/drawable-xxxhdpi/icon.png new file mode 100755 index 0000000..542dff6 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/icon.png differ diff --git a/app/src/main/res/drawable/welcome.png b/app/src/main/res/drawable/welcome.png new file mode 100755 index 0000000..8aeb2b3 Binary files /dev/null and b/app/src/main/res/drawable/welcome.png differ diff --git a/app/src/main/res/layout/article.xml b/app/src/main/res/layout/article.xml new file mode 100644 index 0000000..5c857c5 --- /dev/null +++ b/app/src/main/res/layout/article.xml @@ -0,0 +1,48 @@ + + + + + + + + + + + +