Skip to content

Commit

Permalink
Merge pull request #370 from wallabag/v2_api
Browse files Browse the repository at this point in the history
v2 API
  • Loading branch information
di72nn authored Feb 28, 2017
2 parents 15766d4 + f0ddd91 commit 12e8746
Show file tree
Hide file tree
Showing 112 changed files with 6,233 additions and 4,433 deletions.
17 changes: 13 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,14 @@ android {
applicationId "fr.gaulupeau.apps.InThePoche"
minSdkVersion 11
targetSdkVersion 25
versionCode 32
versionName "1.12.2"
versionCode 100
versionName "2.0.0a"

javaCompileOptions {
annotationProcessorOptions {
arguments = [ eventBusIndex : 'fr.gaulupeau.apps.Poche.EventBusIndex' ]
}
}
}

lintOptions {
Expand Down Expand Up @@ -39,7 +45,7 @@ android {
}

greendao {
schemaVersion 6
schemaVersion 100
daoPackage 'fr.gaulupeau.apps.Poche.data.dao'
}

Expand All @@ -50,9 +56,12 @@ dependencies {
compile 'com.android.support:design:25.2.0'
compile 'org.greenrobot:eventbus:3.0.0'
compile 'org.greenrobot:greendao:3.2.0'
annotationProcessor 'org.greenrobot:eventbus-annotation-processor:3.0.1'
compile 'com.squareup.okhttp3:okhttp:3.6.0'
compile 'com.github.franmontiel:PersistentCookieJar:v1.0.0'
compile 'com.squareup.okhttp3:okhttp-urlconnection:3.6.0'
compile 'com.facebook.stetho:stetho:1.4.2'
compile 'com.facebook.stetho:stetho-okhttp3:1.4.2'
compile 'com.mikepenz:aboutlibraries:5.7.3'
compile 'com.github.di72nn.wallabag-api-wrapper:api-wrapper:0fd11d1'
compile 'org.slf4j:slf4j-android:1.7.23'
}
1 change: 1 addition & 0 deletions app/lint.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<!-- Workaround for https://github.com/square/okio/issues/58 -->
<issue id="InvalidPackage">
<ignore regexp="okio-.*\.jar" />
<ignore regexp="retrofit-.*\.jar" />
</issue>

<!-- Consider localization issues as Warnings -->
Expand Down
14 changes: 9 additions & 5 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,23 @@
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/LightTheme">
<activity android:name="fr.gaulupeau.apps.Poche.ui.ArticlesListActivity">
<activity
android:name="fr.gaulupeau.apps.Poche.ui.MainActivity"
android:theme="@style/LightTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.SEARCH" />
<action android:name="android.intent.action.MAIN"/>
<action android:name="android.intent.action.SEARCH"/>

<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<meta-data android:name="android.app.searchable"
android:resource="@xml/searchable" />
android:resource="@xml/searchable"/>
</activity>
<activity
android:name="fr.gaulupeau.apps.Poche.ui.ReadArticleActivity"
android:hardwareAccelerated="true" />
<activity
android:name="fr.gaulupeau.apps.Poche.ui.ManageArticleTagsActivity"/>
<activity
android:name="fr.gaulupeau.apps.Poche.ui.BagItProxyActivity"
android:theme="@style/ProxyTheme">
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/java/fr/gaulupeau/apps/Poche/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

import com.facebook.stetho.Stetho;

import org.greenrobot.eventbus.EventBus;

import fr.gaulupeau.apps.InThePoche.BuildConfig;
import fr.gaulupeau.apps.Poche.data.DbConnection;
import fr.gaulupeau.apps.Poche.data.Settings;
Expand All @@ -21,6 +23,13 @@ public void onCreate() {

if(BuildConfig.DEBUG) Stetho.initializeWithDefaults(this);

EventBus.builder()
.sendNoSubscriberEvent(false)
.sendSubscriberExceptionEvent(false)
.throwSubscriberException(BuildConfig.DEBUG)
.addIndex(new EventBusIndex())
.installDefaultEventBus();

Settings.init(this);
settings = new Settings(this);
settings.initPreferences();
Expand Down
20 changes: 18 additions & 2 deletions app/src/main/java/fr/gaulupeau/apps/Poche/data/DbConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Build;
import android.util.Log;

import org.greenrobot.eventbus.EventBus;
Expand All @@ -16,6 +17,8 @@
import fr.gaulupeau.apps.InThePoche.BuildConfig;
import fr.gaulupeau.apps.Poche.data.dao.DaoMaster;
import fr.gaulupeau.apps.Poche.data.dao.DaoSession;
import fr.gaulupeau.apps.Poche.data.dao.QueueItemDao;
import fr.gaulupeau.apps.Poche.data.dao.entities.QueueItem;
import fr.gaulupeau.apps.Poche.events.OfflineQueueChangedEvent;

public class DbConnection {
Expand All @@ -34,7 +37,15 @@ public static DaoSession getSession() {

Log.d(TAG, "creating new db session");
WallabagOpenHelper dbHelper = new WallabagOpenHelper(context, "wallabag", null);
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
dbHelper.setWriteAheadLoggingEnabled(true);
}
Database db = dbHelper.getWritableDb();
if(Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
if(!((SQLiteDatabase)db.getRawDatabase()).enableWriteAheadLogging()) {
Log.w(TAG, "write ahead logging was not enabled");
}
}
DaoMaster daoMaster = new DaoMaster(db);
Holder.session = daoMaster.newSession();
} else {
Expand Down Expand Up @@ -111,14 +122,19 @@ public void onUpgrade(Database db, int oldVersion, int newVersion) {
db.beginTransaction();
try {
DatabaseStatement stmt = db.compileStatement(
"insert into queue_item(_id, queue_number, action, extra) values(?, ?, ?, ?)");
"insert into " + QueueItemDao.TABLENAME + "("
+ QueueItemDao.Properties.Id.columnName + ", "
+ QueueItemDao.Properties.QueueNumber.columnName + ", "
+ QueueItemDao.Properties.Action.columnName + ", "
+ QueueItemDao.Properties.Extra.columnName
+ ") values(?, ?, ?, ?)");

int i = 1;
for(String url: offlineUrls) {
try {
stmt.bindLong(1, i);
stmt.bindLong(2, i);
stmt.bindLong(3, QueueHelper.QI_ACTION_ADD_LINK);
stmt.bindLong(3, QueueItem.Action.ADD_LINK.getId());
stmt.bindString(4, url);

stmt.executeInsert();
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ class LegacySettingsHelper {
static final String PREFS_NAME = "InThePoche";

static final String URL = "pocheUrl";
static final String USER_ID = "APIUsername";
static final String TOKEN = "APIToken";
static final String ALL_CERTS = "all_certs";
static final String CUSTOM_SSL_SETTINGS = "custom_ssl_settings";
static final String FONT_SIZE = "font_size";
static final String SERIF_FONT = "serif_font";
Expand All @@ -22,7 +19,6 @@ class LegacySettingsHelper {
static final String HTTP_AUTH_USERNAME = "http_auth_username";
static final String HTTP_AUTH_PASSWORD = "http_auth_password";
static final String THEME = "theme";
static final String WALLABAG_VERSION = "wallabag_version";
static final String TTS_VISIBLE = "tts.visible";
static final String TTS_OPTIONS_VISIBLE = "tts.options.visible";
static final String TTS_SPEED = "tts.speed";
Expand All @@ -42,27 +38,20 @@ class LegacySettingsHelper {
static final String FIRST_SYNC_DONE = "first_sync_done";
static final String PENDING_OFFLINE_QUEUE = "offline_queue.pending";

static boolean migrateLegacySettings(Context cx, SharedPreferences pref) {
static boolean migrateLegacySettings(Context cx, SharedPreferences.Editor prefEditor) {
SharedPreferences legacyPref = cx.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);

if(!legacyPref.contains("pocheUrl")) return false;

SharedPreferences.Editor prefEditor = pref.edit();
migrateStringPref(cx, URL, R.string.pref_key_connection_url, legacyPref, prefEditor);
migrateIntPref(cx, WALLABAG_VERSION,
R.string.pref_key_connection_serverVersion, legacyPref, prefEditor, -1);
migrateStringPref(cx, USERNAME, R.string.pref_key_connection_username, legacyPref, prefEditor);
migrateStringPref(cx, PASSWORD, R.string.pref_key_connection_password, legacyPref, prefEditor);
migrateStringPref(cx, USER_ID, R.string.pref_key_connection_feedsUserID, legacyPref, prefEditor);
migrateStringPref(cx, TOKEN, R.string.pref_key_connection_feedsToken, legacyPref, prefEditor);

migrateStringPref(cx, HTTP_AUTH_USERNAME,
R.string.pref_key_connection_advanced_httpAuthUsername, legacyPref, prefEditor);
migrateStringPref(cx, HTTP_AUTH_PASSWORD,
R.string.pref_key_connection_advanced_httpAuthPassword, legacyPref, prefEditor);

migrateBooleanPref(cx, ALL_CERTS,
R.string.pref_key_connection_advanced_acceptAllCertificates, legacyPref, prefEditor);
migrateBooleanPref(cx, CUSTOM_SSL_SETTINGS,
R.string.pref_key_connection_advanced_customSSLSettings, legacyPref, prefEditor);

Expand Down
13 changes: 1 addition & 12 deletions app/src/main/java/fr/gaulupeau/apps/Poche/data/ListAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,13 @@
import android.widget.ImageView;
import android.widget.TextView;

import java.net.URL;
import java.util.List;

import fr.gaulupeau.apps.InThePoche.R;
import fr.gaulupeau.apps.Poche.data.dao.entities.Article;

import static fr.gaulupeau.apps.Poche.data.ListTypes.*;

/**
* @author Victor Häggqvist
* @since 10/19/15
*/
public class ListAdapter extends RecyclerView.Adapter<ListAdapter.ViewHolder> {

private List<Article> articles;
Expand Down Expand Up @@ -70,14 +65,8 @@ public ViewHolder(View itemView, OnItemClickListener listener) {
}

public void bind(Article article) {
String urlText = article.getUrl();
try {
URL url = new URL(urlText);
urlText = url.getHost();
} catch (Exception ignored) {}

title.setText(article.getTitle());
url.setText(urlText);
url.setText(article.getDomain());

boolean showFavourite = false;
boolean showRead = false;
Expand Down
Loading

0 comments on commit 12e8746

Please sign in to comment.