Merge pull request #48 from wallabag/dev

1.7
This commit is contained in:
Thomas Citharel 2014-11-16 14:41:38 +01:00
commit b778cb0b21
57 changed files with 2386 additions and 440 deletions

4
.gitignore vendored
View File

@ -7,3 +7,7 @@ gen/
*.apk
*.ap_
*.class
.idea/
.gradle/
build/
local.properties

26
.travis.yml Normal file
View File

@ -0,0 +1,26 @@
language: android
android:
components:
# Uncomment the lines below if you want to
# use the latest revision of Android SDK Tools
- platform-tools
- tools
# The BuildTools version used by your project
- build-tools-21.0.0
# The SDK version used to compile your project
- android-21
# Additional components
# - extra-google-google_play_services
# - extra-google-m2repository
# - extra-android-m2repository
# - addon-google_apis-google-19
# Specify at least one system image,
# if you need to run emulator(s) during your tests
# - sys-img-armeabi-v7a-android-19
# - sys-img-x86-android-17
script: ./gradlew build check

View File

@ -1,27 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="fr.gaulupeau.apps.InThePoche"
android:versionCode="3"
android:versionName="1.0.2">
<uses-sdk android:minSdkVersion="4"
android:targetSdkVersion="8" />
<uses-permission android:name="android.permission.INTERNET"/>
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name="fr.gaulupeau.apps.Poche.Poche"
android:label="@string/app_name" android:theme="@android:style/Theme.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter android:label="@string/label_name">
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
</activity>
<activity android:name="fr.gaulupeau.apps.Poche.ReadArticle" android:label="@string/app_name" android:theme="@android:style/Theme.Light"></activity>
</application>
</manifest>

5
README
View File

@ -1,5 +0,0 @@
Poche by Jonathan GAULUPEAU <jo.gaulupeau-at-gmail.com>
Google Androïd application to add post to Poche <http://www.inthepoche.com>
This application is released under GPL.

7
README.md Normal file
View File

@ -0,0 +1,7 @@
# wallabag - Android App [![Build Status](https://travis-ci.org/wallabag/android-app.svg?branch=rss-feed)](https://travis-ci.org/wallabag/android-app)
wallabag app for Android, originally written by Jonathan GAULUPEAU <jo.gaulupeau-at-gmail.com>
Android application to add post to wallabag <https://www.wallabag.org>
This application is released under GPL. wallabag is released under the MIT licence.

19
android-app.iml Normal file
View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="java-gradle" name="Java-Gradle">
<configuration>
<option name="BUILD_FOLDER_PATH" value="$MODULE_DIR$/build" />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

1
app/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/build

88
app/app.iml Normal file
View File

@ -0,0 +1,88 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="android-app" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="android-gradle" name="Android-Gradle">
<configuration>
<option name="GRADLE_PROJECT_PATH" value=":app" />
</configuration>
</facet>
<facet type="android" name="Android">
<configuration>
<option name="SELECTED_BUILD_VARIANT" value="debug" />
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugJava" />
<option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugTest" />
<option name="SOURCE_GEN_TASK_NAME" value="generateDebugSources" />
<option name="TEST_SOURCE_GEN_TASK_NAME" value="generateDebugTestSources" />
<option name="ALLOW_USER_CONFIGURATION" value="false" />
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
<option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
<option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/src/main/res" />
<option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/build/intermediates/classes/debug" />
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/test/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/test/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/test/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/test/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/test/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/aidl" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/assets" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/aidl" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/coverage-instrumented-classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaResources" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/libs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/ndk" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/proguard" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
</content>
<orderEntry type="jdk" jdkName="Android API 21 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="support-annotations-21.0.0" level="project" />
<orderEntry type="library" exported="" name="support-v4-21.0.0" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-21.0.0" level="project" />
</component>
</module>

24
app/build.gradle Normal file
View File

@ -0,0 +1,24 @@
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion '21'
defaultConfig {
applicationId "fr.gaulupeau.apps.InThePoche"
minSdkVersion 8
targetSdkVersion 21
versionCode 9
versionName "1.6"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:21.0.0'
}

16
app/proguard-rules.pro vendored Normal file
View File

@ -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 *;
#}

View File

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="fr.gaulupeau.apps.InThePoche" >
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<application
android:allowBackup="true"
android:icon="@drawable/icon"
android:label="@string/app_name"
android:theme="@style/app_theme" >
<activity
android:name="fr.gaulupeau.apps.Poche.Poche"
android:theme="@style/mainActivity_theme" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter
android:label="@string/label_name" >
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
</activity>
<activity android:name="fr.gaulupeau.apps.Poche.ReadArticle" />
<activity android:name="fr.gaulupeau.apps.Poche.ListArticles" />
<activity android:name="fr.gaulupeau.apps.Poche.Settings" />
</application>
</manifest>

243
app/src/main/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;
}
}

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

@ -0,0 +1,35 @@
package fr.gaulupeau.apps.Poche;
import java.net.URL;
public class Article {
public String url;
public String id;
public String title;
public String content;
public String archive;
private URL m_url = null;
public Article(String url, String id, String title, String content, String archive) {
super();
this.url = url;
this.id = id;
this.title = title;
this.content = content;
this.archive = archive;
try {
this.m_url = new URL(url);
} catch (Exception e) {
e.printStackTrace();
}
}
public String getHostOfUrl() {
if (this.m_url != null) {
return m_url.getHost();
}
return "";
}
}

View File

@ -0,0 +1,79 @@
package fr.gaulupeau.apps.Poche;
import android.content.Context;
import android.content.SharedPreferences;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import static fr.gaulupeau.apps.Poche.Helpers.PREFS_NAME;
import static fr.gaulupeau.apps.Poche.Helpers.zeroUpdate;
public class ArticlesSQLiteOpenHelper extends SQLiteOpenHelper {
public static final int VERSION = 1;
public static final String DB_NAME = "article_db.sqlite";
public static String MY_ID = "my_id";
public static String ARTICLE_TABLE = "article";
public static String ARTICLE_DATE = "update_date";
public static String ARTICLE_ID = "article_id";
public static String ARTICLE_AUTHOR = "author";
public static String ARTICLE_CONTENT = "content";
public static String ARTICLE_TITLE = "title";
public static String ARTICLE_URL = "url";
public static String ARCHIVE = "archive";
public static String ARTICLE_SYNC = "sync";
public static String ARTICLE_READAT = "read_at";
Context c;
public ArticlesSQLiteOpenHelper(Context context) {
super(context, DB_NAME, null, VERSION);
c = context;
}
@Override
public void onCreate(SQLiteDatabase db) {
createTables(db);
}
@Override
public void onOpen(SQLiteDatabase db) {
// TODO Auto-generated method stub
super.onOpen(db);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.delete(ARTICLE_TABLE, null, null);
SharedPreferences preferences = c.getSharedPreferences(PREFS_NAME, 0);
SharedPreferences.Editor editor = preferences.edit();
editor.putString("previous_update", zeroUpdate);
editor.commit();
}
protected void createTables(SQLiteDatabase db) {
db.execSQL(
"create table " + ARTICLE_TABLE + " (" +
MY_ID + " integer primary key autoincrement not null, " +
ARTICLE_AUTHOR + " text, " +
ARTICLE_DATE + " datetime, " +
ARTICLE_CONTENT + " text, " +
ARTICLE_TITLE + " text, " +
ARTICLE_URL + " text, " +
ARTICLE_ID + " integer, " +
ARCHIVE + " integer," +
ARTICLE_SYNC + " integer," +
ARTICLE_READAT + " integer," +
"UNIQUE (" + ARTICLE_URL + ")" +
");"
);
}
public void truncateTables(SQLiteDatabase db) {
db.execSQL("DELETE FROM " + ARTICLE_TABLE + ";");
}
}

View File

@ -0,0 +1,37 @@
package fr.gaulupeau.apps.Poche;
import android.annotation.TargetApi;
import android.os.Build;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.MenuItem;
public class BaseActionBarActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addBackButtonToActionBar();
}
@TargetApi(11)
protected void addBackButtonToActionBar() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
try {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
} catch (Exception e) {
//
}
}
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == android.R.id.home) {
this.finish();
return true;
}
return super.onOptionsItemSelected(item);
}
}

View File

@ -1,36 +1,32 @@
package fr.gaulupeau.apps.Poche;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
public class Helpers {
public static final String PREFS_NAME = "InThePoche";
public final static String zeroUpdate = "2011-01-01 00:00:00";
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
public static String InputStreamtoString(InputStream is)
{
String s = "",line="";
public class Helpers {
public static final String PREFS_NAME = "InThePoche";
public final static String zeroUpdate = "2011-01-01 00:00:00";
public static String InputStreamtoString(InputStream is) {
String s = "", line = "";
BufferedReader rd = new BufferedReader(new InputStreamReader(is));
try{
for(; ; rd.readLine())
{
if((line = rd.readLine())!=null)
{
s +=line;
}else
{
try {
for (; ; rd.readLine()) {
if ((line = rd.readLine()) != null) {
s += line;
} else {
break;
}
}
}catch (IOException e) {
} catch (IOException e) {
// TODO: handle exception
e.printStackTrace();
}
@ -38,7 +34,7 @@ public class Helpers {
}
public static String getInputStreamFromUrl(String url) {
InputStream content = null;
InputStream content;
String res = "";
try {
HttpGet httpGet = new HttpGet(url);

View File

@ -0,0 +1,111 @@
package fr.gaulupeau.apps.Poche;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import java.util.ArrayList;
import fr.gaulupeau.apps.InThePoche.R;
import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARCHIVE;
import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_CONTENT;
import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_DATE;
import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_TABLE;
import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_TITLE;
import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_URL;
import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.MY_ID;
public class ListArticles extends BaseActionBarActivity {
private ArrayList<Article> readArticlesInfo;
private SQLiteDatabase database;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.list);
setupDB();
setupList(false);
}
public void onDestroy() {
super.onDestroy();
database.close();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.option_list, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.menuShowAll:
setupList(true);
return true;
case R.id.menuWipeDb:
ArticlesSQLiteOpenHelper helper = new ArticlesSQLiteOpenHelper(this);
helper.truncateTables(database);
setupList(false);
return true;
default:
return super.onOptionsItemSelected(item);
}
}
public void setupDB() {
ArticlesSQLiteOpenHelper helper = new ArticlesSQLiteOpenHelper(this);
database = helper.getWritableDatabase();
}
public void setupList(Boolean showAll) {
ListView readList = (ListView) findViewById(R.id.liste_articles);
readArticlesInfo = new ArrayList<Article>();
String filter = null;
if (!showAll) {
filter = ARCHIVE + "=0";
}
ReadingListAdapter ad = getAdapterQuery(filter, readArticlesInfo);
readList.setAdapter(ad);
readList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent i = new Intent(getBaseContext(), ReadArticle.class);
i.putExtra("id", readArticlesInfo.get(position).id);
startActivity(i);
}
});
}
public ReadingListAdapter getAdapterQuery(String filter, ArrayList<Article> articleInfo) {
//Log.e("getAdapterQuery", "running query");
//String url, String domain, String id, String title, String content
String[] getStrColumns = new String[]{ARTICLE_URL, MY_ID, ARTICLE_TITLE, ARTICLE_CONTENT, ARCHIVE};
Cursor ac = database.query(
ARTICLE_TABLE,
getStrColumns,
filter, null, null, null, ARTICLE_DATE + " DESC");
ac.moveToFirst();
if (!ac.isAfterLast()) {
do {
Article tempArticle = new Article(ac.getString(0), ac.getString(1), ac.getString(2), ac.getString(3), ac.getString(4));
articleInfo.add(tempArticle);
} while (ac.moveToNext());
}
ac.close();
return new ReadingListAdapter(getBaseContext(), articleInfo);
}
}

View File

@ -0,0 +1,634 @@
/**
* Android to Poche
* A simple app to make the full save bookmark to Poche
* web page available via the Share menu on Android tablets
* @author GAULUPEAU Jonathan
* August 2013
*/
package fr.gaulupeau.apps.Poche;
import android.annotation.TargetApi;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.database.sqlite.SQLiteConstraintException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.provider.Browser;
import android.util.Base64;
import android.util.Patterns;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.security.SecureRandom;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.X509TrustManager;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import fr.gaulupeau.apps.InThePoche.R;
import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARCHIVE;
import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_CONTENT;
import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_DATE;
import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_SYNC;
import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_TABLE;
import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_TITLE;
import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_URL;
import static fr.gaulupeau.apps.Poche.Helpers.PREFS_NAME;
/**
* Main activity class
*/
@TargetApi(Build.VERSION_CODES.FROYO)
public class Poche extends Activity {
private static SQLiteDatabase database;
Button btnGetPost;
Button btnSync;
Button btnSettings;
SharedPreferences settings;
static String apiUsername;
static String apiToken;
static String pocheUrl;
String action;
/**
* Called when the activity is first created.
* Will act differently depending on whether sharing or
* displaying information page.
*/
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = getIntent();
Bundle extras = intent.getExtras();
action = intent.getAction();
getSettings();
// Find out if Sharing or if app has been launched from icon
if (action.equals(Intent.ACTION_SEND) && !pocheUrl.equals("http://")) {
setContentView(R.layout.main);
findViewById(R.id.btnSync).setVisibility(View.GONE);
findViewById(R.id.btnGetPost).setVisibility(View.GONE);
findViewById(R.id.progressBar1).setVisibility(View.VISIBLE);
final String extraText = extras.getString("android.intent.extra.TEXT");
final String pageUrl;
// Parsing string for urls.
Matcher matcher = Patterns.WEB_URL.matcher(extraText);
if (matcher.find()) {
pageUrl = matcher.group();
} else {
showErrorMessage("Couldn't find a URL in share string:\n"+extraText);
return;
}
// Vérification de la connectivité Internet
final ConnectivityManager conMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
final NetworkInfo activeNetwork = conMgr.getActiveNetworkInfo();
if (activeNetwork != null && activeNetwork.isConnected()) {
// Start to build the poche URL
Uri.Builder pocheSaveUrl = Uri.parse(pocheUrl).buildUpon();
// Add the parameters from the call
pocheSaveUrl.appendQueryParameter("action", "add");
byte[] data = null;
try {
data = pageUrl.getBytes("UTF-8");
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String base64 = Base64.encodeToString(data, Base64.DEFAULT);
pocheSaveUrl.appendQueryParameter("url", base64);
System.out.println("base64 : " + base64);
System.out.println("pageurl : " + pageUrl);
// Load the constructed URL in the browser
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(pocheSaveUrl.build());
i.putExtra(Browser.EXTRA_APPLICATION_ID, getPackageName());
// If user has more then one browser installed give them a chance to
// select which one they want to use
startActivity(i);
// That is all this app needs to do, so call finish()
this.finish();
} else {
// Afficher alerte connectivité
showToast(getString(R.string.txtNetOffline));
}
} else {
setContentView(R.layout.main);
checkAndHandleAfterUpdate();
btnSync = (Button) findViewById(R.id.btnSync);
btnSync.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// Vérification de la connectivité Internet
final ConnectivityManager conMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
final NetworkInfo activeNetwork = conMgr.getActiveNetworkInfo();
if (pocheUrl.equals("http://")) {
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 {
// Afficher alerte connectivité
showToast(getString(R.string.txtNetOffline));
}
}
});
btnGetPost = (Button) findViewById(R.id.btnGetPost);
//updateUnread();
btnGetPost.setOnClickListener(new OnClickListener() {
@Override
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));
}
});
}
}
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://");
apiUsername = settings.getString("APIUsername", "");
apiToken = settings.getString("APIToken", "");
}
@Override
protected void onResume() {
super.onResume();
getSettings();
if (!action.equals(Intent.ACTION_SEND)) {
updateUnread();
}
}
@Override
protected void onDestroy() {
super.onDestroy();
if (database != null) {
database.close();
}
}
private void updateUnread() {
runOnUiThread(new Runnable() {
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(String.format(getString(R.string.btnGetPost), news));
}
});
}
public void showToast(final String toast) {
runOnUiThread(new Runnable() {
public void run() {
Toast.makeText(Poche.this, toast, Toast.LENGTH_SHORT).show();
}
});
}
private void showErrorMessage(final String message) {
runOnUiThread(new Runnable() {
@Override
public void run() {
AlertDialog.Builder messageBox = new AlertDialog.Builder(Poche.this);
messageBox.setMessage(message);
messageBox.setTitle(getString(R.string.error));
// messageBox.setIconAttribute(android.R.attr.alertDialogIcon);
messageBox.setPositiveButton("OK", null);
messageBox.setCancelable(false);
messageBox.create().show();
}
});
}
// public void pocheIt(String url){
// String id ="req-001";
// JSONRPC2Request reqOut = null;
// try{
// reqOut = JSONRPC2Request.parse("{\"jsonrpc\":\"2.0\",\"method\":\"item.add\",\"id\":\"" + id + "\",\"params\":[{\"username\":\""+ apiUsername + "\",\"api_token\":\""+ apiToken +"\"}, \"" + url + "\", true]}");
// System.err.println(reqOut.toString());
// JSONRPC2Response response = sendRequest(reqOut);
// if (response.indicatesSuccess()) {
// showToast(getString(R.string.txtSyncDone));
// }
// } catch (JSONRPC2ParseException e2) {
// e2.printStackTrace();
// showToast(getString(R.string.txtSyncFailed));
// }
// finish();
// }
// public void pushRead(){
// JSONRPC2Request reqOut = null;
// String filter = ARCHIVE + "=1 AND " + ARTICLE_SYNC + "=0";
// String[] getStrColumns = new String[] {ARTICLE_ID};
// Cursor ac = database.query(
// ARTICLE_TABLE,
// getStrColumns,
// filter, null, null, null, null);
// ac.moveToFirst();
// if(!ac.isAfterLast()) {
// do {
// String article_id = ac.getString(0);
// String id ="req-001";
// try{
// reqOut = JSONRPC2Request.parse("{\"jsonrpc\":\"2.0\",\"method\":\"item.mark_as_read\",\"id\":\"" + id + "\",\"params\":[{\"username\":\""+ apiUsername + "\",\"api_token\":\""+ apiToken +"\"}, " + article_id + "]}");
// System.err.println(reqOut.toString());
// JSONRPC2Response response = sendRequest(reqOut);
// if (response.indicatesSuccess()) {
// ContentValues values = new ContentValues();
// values.put(ARTICLE_SYNC, 1);
// database.update(ARTICLE_TABLE, values, ARTICLE_ID + "=" + article_id, null);
// }
// } catch (JSONRPC2ParseException e2) {
// e2.printStackTrace();
// }
// } while (ac.moveToNext());
// }
// ac.close();
//
// }
public String cleanString(String s) {
s = s.replace("&Atilde;&copy;", "&eacute;");
s = s.replace("&Atilde;&uml;", "&egrave;");
s = s.replace("&Atilde;&ordf;", "&ecirc;");
s = s.replace("&Atilde;&laquo;", "&euml;");
s = s.replace("&Atilde;&nbsp;", "&agrave;");
s = s.replace("&Atilde;&curren;", "&auml;");
s = s.replace("&Atilde;&cent;", "&acirc;");
s = s.replace("&Atilde;&sup1;", "&ugrave;");
s = s.replace("&Atilde;&raquo;", "&ucirc;");
s = s.replace("&Atilde;&frac14;", "&uuml;");
s = s.replace("&Atilde;&acute;", "&ocirc;");
s = s.replace("&Atilde;&para;", "&ouml;");
s = s.replace("&Atilde;&reg;", "&icirc;");
s = s.replace("&Atilde;&macr;", "&iuml;");
s = s.replace("&Atilde;&sect;", "&ccedil;");
s = s.replace("&amp;", "&amp;");
// Replace multiple whitespaces with single space
s = s.replaceAll("\\s+", " ");
s = s.trim();
return s;
}
private void trustEveryone() {
try {
HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() {
public boolean verify(String hostname, SSLSession session) {
return true;
}
});
SSLContext context = SSLContext.getInstance("TLS");
context.init(null, new X509TrustManager[]{new X509TrustManager() {
public void checkClientTrusted(X509Certificate[] chain,
String authType) throws CertificateException {
}
public void checkServerTrusted(X509Certificate[] chain,
String authType) throws CertificateException {
}
public X509Certificate[] getAcceptedIssuers() {
return new X509Certificate[0];
}
}}, new SecureRandom());
HttpsURLConnection.setDefaultSSLSocketFactory(
context.getSocketFactory());
} catch (Exception e) { // should never happen
e.printStackTrace();
}
}
public void parseRSS() {
URL url;
try {
// Set the url (you will need to change this to your RSS URL
url = new URL(pocheUrl + "/?feed&type=home&user_id=" + apiUsername + "&token=" + apiToken);
if (pocheUrl.startsWith("https")) {
trustEveryone();
}
// Setup the connection
HttpURLConnection urlConnection;
urlConnection = (HttpURLConnection) url.openConnection();
if ((urlConnection != null) && (urlConnection.getResponseCode() == HttpURLConnection.HTTP_OK)) {
// Retreive the XML from the URL
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = null;
InputSource is;
try {
is = new InputSource(
new InputStreamReader(
urlConnection.getInputStream()));
doc = db.parse(is);
doc.getDocumentElement().normalize();
} catch (SAXException e) {
e.printStackTrace();
InputStream inputStream = url.openStream();
int ch;
StringBuffer stringBuffer = new StringBuffer();
while ((ch = inputStream.read()) != -1) {
stringBuffer.append((char) ch);
}
showErrorMessage("Got invalid response:\n\"" + stringBuffer.toString() + "\"");
}
// This is the root node of each section you want to parse
NodeList itemLst = doc.getElementsByTagName("item");
// This sets up some arrays to hold the data parsed
arrays.PodcastTitle = new String[itemLst.getLength()];
arrays.PodcastURL = new String[itemLst.getLength()];
arrays.PodcastContent = new String[itemLst.getLength()];
arrays.PodcastMedia = new String[itemLst.getLength()];
arrays.PodcastDate = new String[itemLst.getLength()];
// Loop through the XML passing the data to the arrays
for (int i = 0; i < itemLst.getLength(); i++) {
Node item = itemLst.item(i);
if (item.getNodeType() == Node.ELEMENT_NODE) {
Element ielem = (Element) item;
// This section gets the elements from the XML
// that we want to use you will need to add
// and remove elements that you want / don't want
NodeList title = ielem.getElementsByTagName("title");
NodeList link = ielem.getElementsByTagName("link");
NodeList date = ielem.getElementsByTagName("pubDate");
NodeList content = ielem
.getElementsByTagName("description");
//NodeList media = ielem
// .getElementsByTagName("media:content");
// This is an attribute of an element so I create
// a string to make it easier to use
//String mediaurl = media.item(0).getAttributes()
// .getNamedItem("url").getNodeValue();
// This section adds an entry to the arrays with the
// data retrieved from above. I have surrounded each
// with try/catch just incase the element does not
// exist
try {
arrays.PodcastTitle[i] = cleanString(title.item(0).getChildNodes().item(0).getNodeValue());
} catch (NullPointerException e) {
e.printStackTrace();
arrays.PodcastTitle[i] = "Echec";
}
try {
arrays.PodcastDate[i] = date.item(0).getChildNodes().item(0).getNodeValue();
} catch (NullPointerException e) {
e.printStackTrace();
arrays.PodcastDate[i] = null;
}
try {
arrays.PodcastURL[i] = link.item(0).getChildNodes()
.item(0).getNodeValue();
} catch (NullPointerException e) {
e.printStackTrace();
arrays.PodcastURL[i] = "Echec";
}
try {
arrays.PodcastContent[i] = content.item(0)
.getChildNodes().item(0).getNodeValue();
} catch (NullPointerException e) {
e.printStackTrace();
arrays.PodcastContent[i] = "Echec";
}
ContentValues values = new ContentValues();
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, arrays.PodcastURL[i]);
values.put(ARTICLE_DATE, arrays.PodcastDate[i]);
values.put(ARCHIVE, 0);
values.put(ARTICLE_SYNC, 0);
try {
database.insertOrThrow(ARTICLE_TABLE, null, values);
} catch (SQLiteConstraintException e) {
continue;
} catch (SQLiteException e) {
database.execSQL("ALTER TABLE " + ARTICLE_TABLE + " ADD COLUMN " + ARTICLE_DATE + " datetime;");
database.insertOrThrow(ARTICLE_TABLE, null, values);
}
}
}
showToast(getString(R.string.txtSyncDone));
} else {
// HTTP Connection not successful
if (urlConnection == null) {
showErrorMessage(getString(R.string.error_feed));
} else {
showErrorMessage(getString(R.string.error_feed) + ":\n" + urlConnection.getResponseCode() + " " + urlConnection.getResponseMessage());
}
}
updateUnread();
} catch (Exception e) {
e.printStackTrace();
}
}
// public void fetchUnread(){
// String id = "req-001";
// JSONRPC2Request reqOut = null;
// try {
// // POCHE A LINK
// //reqOut = JSONRPC2Request.parse("{\"jsonrpc\":\"2.0\",\"method\":\"item.add\",\"id\":\"req-001\",\"params\":[{\"username\":\"poche\",\"api_token\":\"cPG2urVgA+ToMXY\"},\"http://cdetc.fr\",true]}");
// // GET A LINK
// //reqOut = JSONRPC2Request.parse("{\"jsonrpc\":\"2.0\",\"method\":\"item.info\",\"id\":\"" + id + "\",\"params\":[{\"username\":\""+ apiUsername + "\",\"api_token\":\""+ apiToken +"\"}, 1]}");
// // GET ALL UNREAD
// reqOut = JSONRPC2Request.parse("{\"jsonrpc\":\"2.0\",\"method\":\"item.list_unread\",\"id\":\"" + id + "\",\"params\":[{\"username\":\""+ apiUsername + "\",\"api_token\":\""+ apiToken +"\"}, null, null]}");
// System.err.println(reqOut.toString());
// } catch (JSONRPC2ParseException e2) {
// e2.printStackTrace();
// }
// System.out.println(reqOut.toString());
// URL url = null;
// try {
// final String rpcuser ="api_user";
// final String rpcpassword = globalToken;
//
// Authenticator.setDefault(new Authenticator() {
// protected PasswordAuthentication getPasswordAuthentication() {
// return new PasswordAuthentication (rpcuser, rpcpassword.toCharArray());
// }});
// url = new URL(pocheUrl + "/jsonrpc.php");
// } catch (MalformedURLException e1) {
// e1.printStackTrace();
// }
// JSONRPC2Session session = new JSONRPC2Session(url);
// JSONRPC2Response response = null;
// try{
// response = session.send(reqOut);
// } catch (JSONRPC2SessionException e) {
//
// System.err.println(e.getMessage());
// }
// if (response.indicatesSuccess()){
// JSONObject article = null;
// ContentValues values = new ContentValues();
// try {
// JSONArray ret = new JSONArray(response.getResult().toString());
// for (int i = 0; i < ret.length(); i++) {
// article = ret.getJSONObject(i);
// values.put(ARTICLE_TITLE, Html.fromHtml(article.getString("title")).toString());
// values.put(ARTICLE_CONTENT, Html.fromHtml(article.getString("content")).toString());
// values.put(ARTICLE_ID, Html.fromHtml(article.getString("id")).toString());
// values.put(ARTICLE_URL, Html.fromHtml(article.getString("url")).toString());
// values.put(ARCHIVE, 0);
// values.put(ARTICLE_SYNC, 0);
// try {
// database.insertOrThrow(ARTICLE_TABLE, null, values);
// } catch (SQLiteConstraintException e) {
// continue;
// }
// }
// } catch (JSONException e) {
// e.printStackTrace();
// showToast(getString(R.string.txtSyncFailed));
// }
//
// showToast(getString(R.string.txtSyncDone));
// updateUnread();
// }else{
// System.out.println(response.getError().getMessage( ));
// showToast(getString(R.string.txtSyncFailed));
// }
// }
//
// public JSONRPC2Response sendRequest(JSONRPC2Request reqOut){
// URL url = null;
// try {
// final String rpcuser ="api_user";
// final String rpcpassword = globalToken;
//
// Authenticator.setDefault(new Authenticator() {
// protected PasswordAuthentication getPasswordAuthentication() {
// return new PasswordAuthentication (rpcuser, rpcpassword.toCharArray());
// }});
// url = new URL(pocheUrl + "/jsonrpc.php");
// } catch (MalformedURLException e1) {
// e1.printStackTrace();
// }
// JSONRPC2Session session = new JSONRPC2Session(url);
// JSONRPC2Response response = null;
// try{
// response = session.send(reqOut);
// } catch (JSONRPC2SessionException e) {
//
// System.err.println(e.getMessage());
// }
// return response;
// }
}

View File

@ -0,0 +1,118 @@
package fr.gaulupeau.apps.Poche;
import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.webkit.WebView;
import android.widget.Button;
import android.widget.ScrollView;
import java.net.URL;
import fr.gaulupeau.apps.InThePoche.R;
import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARCHIVE;
import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_AUTHOR;
import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_CONTENT;
import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_ID;
import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_TABLE;
import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_TITLE;
import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_URL;
import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.MY_ID;
public class ReadArticle extends BaseActionBarActivity {
WebView webViewContent;
Button btnMarkRead;
SQLiteDatabase database;
String id = "";
ScrollView view;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.article);
view = (ScrollView) findViewById(R.id.scroll);
ArticlesSQLiteOpenHelper helper = new ArticlesSQLiteOpenHelper(getApplicationContext());
database = helper.getWritableDatabase();
String[] getStrColumns = new String[]{ARTICLE_URL, MY_ID, ARTICLE_TITLE, ARTICLE_CONTENT, ARCHIVE, ARTICLE_AUTHOR};
Bundle data = getIntent().getExtras();
if (data != null) {
id = data.getString("id");
}
Cursor ac = database.query(ARTICLE_TABLE, getStrColumns, MY_ID + "=" + id, null, null, null, null);
ac.moveToFirst();
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" +
"\t\t\t\t</div>\n" +
"\t\t\t</body>\n" +
"\t\t</div>\n" +
"</html>";
webViewContent = (WebView) findViewById(R.id.webViewContent);
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
protected void onStop() {
// TODO Auto-generated method stub
ContentValues values = new ContentValues();
values.put("read_at", view.getScrollY());
database.update(ARTICLE_TABLE, values, ARTICLE_ID + "=" + id, null);
System.out.println(view.getScrollY());
super.onStop();
}
@Override
protected void onDestroy() {
super.onDestroy();
database.close();
}
}

View File

@ -0,0 +1,51 @@
package fr.gaulupeau.apps.Poche;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import java.util.List;
import fr.gaulupeau.apps.InThePoche.R;
public class ReadingListAdapter extends BaseAdapter {
private Context context;
private List<Article> listArticles;
public ReadingListAdapter(Context context, List<Article> listArticles) {
this.context = context;
this.listArticles = listArticles;
}
public int getCount() {
return listArticles.size();
}
public Object getItem(int position) {
return listArticles.get(position);
}
public long getItemId(int position) {
return position;
}
public View getView(int position, View convertView, ViewGroup parent) {
Article entry = listArticles.get(position);
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.article_list, parent, false);
}
TextView tvTitle = (TextView) convertView.findViewById(R.id.listitem_titre);
TextView tvHost = (TextView) convertView.findViewById(R.id.listitem_textview_url);
tvTitle.setText(entry.title);
tvHost.setText(entry.getHostOfUrl());
return convertView;
}
}

View File

@ -0,0 +1,56 @@
package fr.gaulupeau.apps.Poche;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import fr.gaulupeau.apps.InThePoche.R;
import static fr.gaulupeau.apps.Poche.Helpers.PREFS_NAME;
public class Settings extends BaseActionBarActivity {
Button btnDone;
EditText editPocheUrl;
EditText editAPIUsername;
EditText editAPIToken;
TextView textViewVersion;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.settings);
SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
String pocheUrl = settings.getString("pocheUrl", "http://");
String apiUsername = settings.getString("APIUsername", "");
String apiToken = settings.getString("APIToken", "");
editPocheUrl = (EditText) findViewById(R.id.pocheUrl);
editPocheUrl.setText(pocheUrl);
editAPIUsername = (EditText) findViewById(R.id.APIUsername);
editAPIUsername.setText(apiUsername);
editAPIToken = (EditText) findViewById(R.id.APIToken);
editAPIToken.setText(apiToken);
btnDone = (Button) findViewById(R.id.btnDone);
btnDone.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
SharedPreferences.Editor editor = settings.edit();
editor.putString("pocheUrl", editPocheUrl.getText().toString());
editor.putString("APIUsername", editAPIUsername.getText().toString());
editor.putString("APIToken", editAPIToken.getText().toString());
editor.commit();
finish();
}
});
try {
textViewVersion = (TextView) findViewById(R.id.version);
textViewVersion.setText(getApplicationContext().getPackageManager().getPackageInfo(getApplicationContext().getPackageName(), 0).versionName);
} catch (Exception e) {
//
}
}
}

View File

@ -0,0 +1,9 @@
package fr.gaulupeau.apps.Poche;
public class arrays {
public static String[] PodcastTitle;
public static String[] PodcastURL;
public static String[] PodcastContent;
public static String[] PodcastMedia;
public static String[] PodcastDate;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

View File

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/scroll"
tools:context="fr.gaulupeau.apps.Poche.ReadArticle" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
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>

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:padding="8sp"
android:layout_width="fill_parent" android:layout_height="fill_parent" >
<TextView
android:id="@+id/listitem_titre"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="18sp"
android:textColor="@android:color/black"
android:paddingBottom="4sp"/>
<TextView
android:id="@+id/listitem_textview_url"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="12sp"
android:singleLine="true" />
</LinearLayout>

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="fr.gaulupeau.apps.Poche.ListArticles" >
<ListView
android:id="@+id/liste_articles"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:divider="#000000"
android:dividerHeight="1dp" >
</ListView>
</LinearLayout>

View File

@ -0,0 +1,77 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/scrollView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
tools:context="fr.gaulupeau.apps.Poche.Poche" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="30sp"
android:paddingRight="30sp"
android:paddingTop="15dp" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="256dp"
android:layout_height="256dp"
android:layout_gravity="center"
android:layout_weight="0"
android:contentDescription="@string/app_name"
android:scaleType="centerInside"
android:src="@drawable/welcome" />
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:text="@string/hello"
android:textSize="25sp"
android:visibility="gone" />
<View
android:id="@+id/view1"
android:layout_width="fill_parent"
android:layout_height="1dip"
android:layout_marginBottom="6sp"
android:layout_marginTop="6sp"
android:layout_weight="0"
android:background="#000000" />
<Button
android:id="@+id/btnGetPost"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/btnGetPost" />
<Button
android:id="@+id/btnSync"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/btnSync" />
<Button
android:id="@+id/btnSettings"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/btnSettings"/>
<ProgressBar
android:id="@+id/progressBar1"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_weight="0"
android:visibility="gone" />
</LinearLayout>
</ScrollView>

View File

@ -0,0 +1,118 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="fr.gaulupeau.apps.Poche.Settings" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="30sp"
android:paddingRight="30sp"
android:paddingTop="15dp"
android:orientation="vertical" >
<TextView
android:id="@+id/pageUrl_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/url_label"
android:textSize="18sp" />
<TextView
android:id="@+id/txtTitre"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/url_help" />
<EditText
android:id="@+id/pocheUrl"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:ems="10"
android:inputType="textUri"
android:linksClickable="false"
android:maxLines="1"
android:scrollHorizontally="false" >
<requestFocus />
</EditText>
<TextView
android:id="@+id/txtAPIUsername"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginTop="10dp"
android:text="@string/txtAPIUsername"
android:textSize="18sp" />
<EditText
android:id="@+id/APIUsername"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:inputType="text" />
<TextView
android:id="@+id/txtAPIToken"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginTop="10dp"
android:text="@string/txtAPIToken"
android:textSize="18sp" />
<EditText
android:id="@+id/APIToken"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:inputType="text" />
<TextView
android:id="@+id/instructions"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/toppadding"
android:layout_weight="1"
android:autoLink="web"
android:paddingTop="5sp"
android:text="@string/instructions" />
<Button
android:id="@+id/btnDone"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginTop="10dp"
android:text="@string/btnDone" />
<TextView
android:id="@+id/version"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginTop="10dp"
android:textSize="12sp" />
<TextView
android:id="@+id/author"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_marginBottom="10dp"
android:text="@string/author"
android:textSize="12sp" />
</LinearLayout>
</ScrollView>

View File

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

View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">Wilkommen!</string>
<string name="app_name">wallabag</string>
<string name="label_name">Bag it!</string>
<string name="author">GAULUPEAU Jonathan - 2013</string>
<string name="instructions">Um eine Website zu speichern benutze einfach den <i>Teilen</i> Button deines Browsers und drücke dann auf <i>Bag it!</i>.\nDann wirst du zur Login-Seite deiner wallabag weitergeleitet. \nFertig!\nErfahre mehr über wallabag auf:\n http://www.wallabag.org</string>
<string name="btnDone">Speichern</string>
<string name="url_label"><b><u>Deine wallabag URL:</u></b></string>
<string name="url_help">Beispiele:\n<i>http://wallabag.example.com</i>\n<i>http://www.example.com/wallabag</i></string>
<string name="btnGetPost">Artikelliste - %1$d ungelesene</string>
<string name="btnSync">Synchronisieren</string>
<string name="btnMarkRead">Als gelesen markieren</string>
<string name="btnSettings">Einstellungen</string>
<string name="menuShowAll">Alle anzeigen</string>
<string name="menuWipeDb">Datenbank leeren</string>
<string name="txtSyncDone">Synchronisieren erfolgreich!</string>
<string name="txtNetOffline">Internetverbindung prüfen!</string>
<string name="txtConfigNotSet">Bitte konfiguriere die App zunächst!</string>
<string name="txtAPIUsername"><b><u>Deine User ID:</u></b></string>
<string name="txtAPIToken"><b><u>Dein Token:</u></b></string>
<string name="error">Fehler</string>
<string name="error_feed">Fehler beim laden des Feeds</string>
</resources>

View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">Welcome to wallabag</string>
<string name="app_name">wallabag</string>
<string name="label_name">Bag it!</string>
<string name="author">GAULUPEAU Jonathan - 2013</string>
<string name="instructions">To save a web page to wallabag, open the page in a browser then tap <i>Share</i> and tap on <i>Bag it!</i>. \nYou could then see your wallabag login page. \nAnd it\'s done ! \nMore infos about wallabag at:\n http://www.wallabag.org</string>
<string name="btnDone">Save</string>
<string name="url_label"><b><u>Your wallabag URL :</u></b></string>
<string name="url_help">Examples:\n<i>http://wallabag.example.fr</i>\n<i>http://www.example.fr/wallabag</i></string>
<string name="btnGetPost">List articles - %1$d unread</string>
<string name="btnSync">Synchronize</string>
<string name="btnMarkRead">Mark as Read</string>
<string name="btnSettings">Settings</string>
<string name="menuShowAll">Show All</string>
<string name="menuWipeDb">Wipe Database</string>
<string name="txtSyncDone">Synchronize done !</string>
<string name="txtNetOffline">Check Internet Connectivity !</string>
<string name="txtConfigNotSet">Please configure the app before Syncing !</string>
<string name="txtAPIUsername"><b><u>Your User ID:</u></b></string>
<string name="txtAPIToken"><b><u>Your Token:</u></b></string>
<string name="error">Error</string>
<string name="error_feed">Error loading feed</string>
</resources>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="app_theme" parent="Theme.AppCompat.Light.DarkActionBar"/>
<style name="mainActivity_theme" parent="Theme.AppCompat.Light.NoActionBar" />
</resources>

16
build.gradle Normal file
View File

@ -0,0 +1,16 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.+'
}
}
allprojects {
repositories {
mavenCentral()
}
}

BIN
gradle/wrapper/gradle-wrapper.jar vendored Normal file

Binary file not shown.

View File

@ -0,0 +1,6 @@
#Sun Jun 22 17:29:26 CEST 2014
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-1.12-all.zip

164
gradlew vendored Executable file
View File

@ -0,0 +1,164 @@
#!/usr/bin/env bash
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn ( ) {
echo "$*"
}
die ( ) {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
esac
# For Cygwin, ensure paths are in UNIX format before anything is touched.
if $cygwin ; then
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
fi
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >&-
APP_HOME="`pwd -P`"
cd "$SAVED" >&-
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"

90
gradlew.bat vendored Normal file
View File

@ -0,0 +1,90 @@
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windowz variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

View File

@ -1,3 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<lint>
</lint>

View File

@ -1,14 +0,0 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system edit
# "ant.properties", and override values to adapt the script to your
# project structure.
#
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
# Project target.
target=android-8

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 833 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

View File

@ -1,27 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/txtTitre"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Titre"
android:textSize="25sp" />
<TextView
android:id="@+id/txtContent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Contenu" />
</LinearLayout>
</ScrollView>

View File

@ -1,111 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scrollView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:paddingLeft="30sp"
android:paddingRight="30sp" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:scaleType="center"
android:src="@drawable/icon" />
<TextView
android:layout_width="230dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="3"
android:text="@string/hello"
android:textSize="25sp" />
</LinearLayout>
<TextView
android:id="@+id/pageUrl_label"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:text="@string/url_label"
android:textSize="20sp" />
<TextView
android:id="@+id/txtTitre"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/url_help" />
<EditText
android:id="@+id/pocheUrl"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:ems="10"
android:inputType="textFilter"
android:linksClickable="false"
android:maxLines="1"
android:scrollHorizontally="false" >
<requestFocus android:layout_width="wrap_content" />
</EditText>
<TextView
android:id="@+id/instructions"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/toppadding"
android:layout_weight="1"
android:paddingTop="5sp"
android:text="@string/instructions"
android:autoLink="web"
android:textSize="22sp" >
</TextView>
<Button
android:id="@+id/btnDone"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:text="@string/btnDone" />
<Button
android:id="@+id/btnGetPost"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/btnGetPost" />
<TextView
android:id="@+id/txtContent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="TextView" />
<TextView
android:id="@+id/author"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:text="@string/author"
android:textSize="10sp" />
</LinearLayout>
</ScrollView>

View File

@ -1,14 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">In the poche !</string>
<string name="app_name">In the poche</string>
<string name="label_name">Add in the poche</string>
<string name="author">By GAULUPEAU Jonathan</string>
<string name="instructions">To save a web page to poche, open the page in a browser then tap <i>Share</i> and tap on <i>In the poche</i>. \nYou could then see your Poche login page. \nAnd it\'s done ! \nMore infos about poche at http://www.inthepoche.com</string>
<string name="btnDone">Save</string>
<string name="which_browser">Which browser would you like to use?</string>
<string name="authorSite">http://cv.gaulupeau.fr</string>
<string name="url_label"><b><u>Your poche URL :</u></b></string>
<string name="url_help">Examples:\n<i>http://poche.example.fr</i>\n<i>http://www.example.fr/poche</i></string>
<string name="btnGetPost">Save the post</string>
</resources>

1
settings.gradle Normal file
View File

@ -0,0 +1 @@
include ':app'

View File

@ -1,60 +0,0 @@
package fr.gaulupeau.apps.Poche;
import android.content.Context;
import android.content.SharedPreferences;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import static fr.gaulupeau.apps.Poche.Helpers.PREFS_NAME;
import static fr.gaulupeau.apps.Poche.Helpers.zeroUpdate;
public class ArticlesSQLiteOpenHelper extends SQLiteOpenHelper {
public static final int VERSION = 1;
public static final String DB_NAME = "article_db.sqlite";
public static String MY_ID = "my_id";
public static String ARTICLE_TABLE = "article";
public static String ARTICLE_ID = "article_id";
public static String ARTICLE_AUTHOR = "author";
public static String ARTICLE_CONTENT = "content";
public static String ARTICLE_TITLE = "title";
public static String ARTICLE_URL = "url";
Context c;
public ArticlesSQLiteOpenHelper(Context context) {
super(context, DB_NAME, null, VERSION);
c = context;
}
@Override
public void onCreate(SQLiteDatabase db) {
createTables(db);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.delete(ARTICLE_TABLE, null, null);
SharedPreferences preferences = c.getSharedPreferences(PREFS_NAME, 0);
SharedPreferences.Editor editor = preferences.edit();
editor.putString("previous_update", zeroUpdate);
editor.commit();
}
protected void createTables(SQLiteDatabase db) {
db.execSQL(
"create table " + ARTICLE_TABLE + " (" +
MY_ID + " integer primary key autoincrement not null, " +
ARTICLE_AUTHOR + " text, " +
ARTICLE_CONTENT + " text, " +
ARTICLE_TITLE + " text, " +
ARTICLE_URL + " text, " +
ARTICLE_ID + " integer, " +
");"
);
}
}

View File

@ -1,121 +0,0 @@
/**
* Android to Poche
* A simple app to make the full save bookmark to Poche
* web page available via the Share menu on Android tablets
* @author GAULUPEAU Jonathan
* August 2013
*/
package fr.gaulupeau.apps.Poche;
import fr.gaulupeau.apps.InThePoche.R;
import static fr.gaulupeau.apps.Poche.Helpers.getInputStreamFromUrl;
import java.io.UnsupportedEncodingException;
import org.json.JSONException;
import org.json.JSONObject;
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.provider.Browser;
import android.text.Html;
import android.util.Base64;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import static fr.gaulupeau.apps.Poche.Helpers.PREFS_NAME;
/**
* Main activity class
*/
@TargetApi(Build.VERSION_CODES.FROYO) public class Poche extends Activity {
TextView authorSite;
Button btnDone;
Button btnGetPost;
EditText editPocheUrl;
/** Called when the activity is first created.
* Will act differently depending on whether sharing or
* displaying information page. */
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = getIntent();
Bundle extras = intent.getExtras();
String action = intent.getAction();
SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
String pocheUrl = settings.getString("pocheUrl", "http://");
// Find out if Sharing or if app has been launched from icon
if (action.equals(Intent.ACTION_SEND) && pocheUrl != "http://") {
// ACTION_SEND is called when sharing, get the title and URL from
// the call
String pageUrl = extras.getString("android.intent.extra.TEXT");
// Start to build the poche URL
Uri.Builder pocheSaveUrl = Uri.parse(pocheUrl).buildUpon();
// Add the parameters from the call
pocheSaveUrl.appendQueryParameter("action", "add");
byte[] data = null;
try {
data = pageUrl.getBytes("UTF-8");
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String base64 = Base64.encodeToString(data, Base64.DEFAULT);
pocheSaveUrl.appendQueryParameter("url", base64);
System.out.println("base64 : " + base64);
System.out.println("pageurl : " + pageUrl);
// Load the constructed URL in the browser
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(pocheSaveUrl.build());
i.putExtra(Browser.EXTRA_APPLICATION_ID, getPackageName());
// If user has more then one browser installed give them a chance to
// select which one they want to use
startActivity(i);
// That is all this app needs to do, so call finish()
this.finish();
}
else {
// app has been launched from menu - show information window
setContentView(R.layout.main);
// handle done/close button
editPocheUrl = (EditText)findViewById(R.id.pocheUrl);
editPocheUrl.setText(pocheUrl);
btnDone = (Button)findViewById(R.id.btnDone);
btnDone.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// close the app
SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
SharedPreferences.Editor editor = settings.edit();
editor.putString("pocheUrl", editPocheUrl.getText().toString());
editor.commit();
Poche.this.finish();
}
});
btnGetPost = (Button)findViewById(R.id.btnGetPost);
btnGetPost.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(getBaseContext(), ReadArticle.class));
}
});
}
}
}

View File

@ -1,36 +0,0 @@
package fr.gaulupeau.apps.Poche;
import static fr.gaulupeau.apps.Poche.Helpers.getInputStreamFromUrl;
import org.json.JSONException;
import org.json.JSONObject;
import android.app.Activity;
import android.os.Bundle;
import android.text.Html;
import android.widget.TextView;
import fr.gaulupeau.apps.InThePoche.R;
public class ReadArticle extends Activity {
TextView txtTitre;
TextView txtContent;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.article);
String ret = getInputStreamFromUrl("http://poche.gaulupeau.fr/toto.php");
try {
JSONObject rootobj = new JSONObject(ret);
System.out.println(rootobj);
txtTitre = (TextView)findViewById(R.id.txtTitre);
txtContent = (TextView)findViewById(R.id.txtContent);
txtTitre.setText(Html.fromHtml(rootobj.getString("titre")));
txtContent.setText(Html.fromHtml(rootobj.getString("content")));
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}