Skip to content

Commit 12e8746

Browse files
authored
Merge pull request #370 from wallabag/v2_api
v2 API
2 parents 15766d4 + f0ddd91 commit 12e8746

File tree

112 files changed

+6233
-4433
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+6233
-4433
lines changed

app/build.gradle

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,14 @@ android {
99
applicationId "fr.gaulupeau.apps.InThePoche"
1010
minSdkVersion 11
1111
targetSdkVersion 25
12-
versionCode 32
13-
versionName "1.12.2"
12+
versionCode 100
13+
versionName "2.0.0a"
14+
15+
javaCompileOptions {
16+
annotationProcessorOptions {
17+
arguments = [ eventBusIndex : 'fr.gaulupeau.apps.Poche.EventBusIndex' ]
18+
}
19+
}
1420
}
1521

1622
lintOptions {
@@ -39,7 +45,7 @@ android {
3945
}
4046

4147
greendao {
42-
schemaVersion 6
48+
schemaVersion 100
4349
daoPackage 'fr.gaulupeau.apps.Poche.data.dao'
4450
}
4551

@@ -50,9 +56,12 @@ dependencies {
5056
compile 'com.android.support:design:25.2.0'
5157
compile 'org.greenrobot:eventbus:3.0.0'
5258
compile 'org.greenrobot:greendao:3.2.0'
59+
annotationProcessor 'org.greenrobot:eventbus-annotation-processor:3.0.1'
5360
compile 'com.squareup.okhttp3:okhttp:3.6.0'
54-
compile 'com.github.franmontiel:PersistentCookieJar:v1.0.0'
61+
compile 'com.squareup.okhttp3:okhttp-urlconnection:3.6.0'
5562
compile 'com.facebook.stetho:stetho:1.4.2'
5663
compile 'com.facebook.stetho:stetho-okhttp3:1.4.2'
5764
compile 'com.mikepenz:aboutlibraries:5.7.3'
65+
compile 'com.github.di72nn.wallabag-api-wrapper:api-wrapper:0fd11d1'
66+
compile 'org.slf4j:slf4j-android:1.7.23'
5867
}

app/lint.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<!-- Workaround for https://github.com/square/okio/issues/58 -->
44
<issue id="InvalidPackage">
55
<ignore regexp="okio-.*\.jar" />
6+
<ignore regexp="retrofit-.*\.jar" />
67
</issue>
78

89
<!-- Consider localization issues as Warnings -->

app/src/main/AndroidManifest.xml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,23 @@
1616
android:label="@string/app_name"
1717
android:supportsRtl="true"
1818
android:theme="@style/LightTheme">
19-
<activity android:name="fr.gaulupeau.apps.Poche.ui.ArticlesListActivity">
19+
<activity
20+
android:name="fr.gaulupeau.apps.Poche.ui.MainActivity"
21+
android:theme="@style/LightTheme.NoActionBar">
2022
<intent-filter>
21-
<action android:name="android.intent.action.MAIN" />
22-
<action android:name="android.intent.action.SEARCH" />
23+
<action android:name="android.intent.action.MAIN"/>
24+
<action android:name="android.intent.action.SEARCH"/>
2325

24-
<category android:name="android.intent.category.LAUNCHER" />
26+
<category android:name="android.intent.category.LAUNCHER"/>
2527
</intent-filter>
2628
<meta-data android:name="android.app.searchable"
27-
android:resource="@xml/searchable" />
29+
android:resource="@xml/searchable"/>
2830
</activity>
2931
<activity
3032
android:name="fr.gaulupeau.apps.Poche.ui.ReadArticleActivity"
3133
android:hardwareAccelerated="true" />
34+
<activity
35+
android:name="fr.gaulupeau.apps.Poche.ui.ManageArticleTagsActivity"/>
3236
<activity
3337
android:name="fr.gaulupeau.apps.Poche.ui.BagItProxyActivity"
3438
android:theme="@style/ProxyTheme">

app/src/main/java/fr/gaulupeau/apps/Poche/App.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
import com.facebook.stetho.Stetho;
66

7+
import org.greenrobot.eventbus.EventBus;
8+
79
import fr.gaulupeau.apps.InThePoche.BuildConfig;
810
import fr.gaulupeau.apps.Poche.data.DbConnection;
911
import fr.gaulupeau.apps.Poche.data.Settings;
@@ -21,6 +23,13 @@ public void onCreate() {
2123

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

26+
EventBus.builder()
27+
.sendNoSubscriberEvent(false)
28+
.sendSubscriberExceptionEvent(false)
29+
.throwSubscriberException(BuildConfig.DEBUG)
30+
.addIndex(new EventBusIndex())
31+
.installDefaultEventBus();
32+
2433
Settings.init(this);
2534
settings = new Settings(this);
2635
settings.initPreferences();

app/src/main/java/fr/gaulupeau/apps/Poche/data/DbConnection.java

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import android.content.Context;
44
import android.database.Cursor;
55
import android.database.sqlite.SQLiteDatabase;
6+
import android.os.Build;
67
import android.util.Log;
78

89
import org.greenrobot.eventbus.EventBus;
@@ -16,6 +17,8 @@
1617
import fr.gaulupeau.apps.InThePoche.BuildConfig;
1718
import fr.gaulupeau.apps.Poche.data.dao.DaoMaster;
1819
import fr.gaulupeau.apps.Poche.data.dao.DaoSession;
20+
import fr.gaulupeau.apps.Poche.data.dao.QueueItemDao;
21+
import fr.gaulupeau.apps.Poche.data.dao.entities.QueueItem;
1922
import fr.gaulupeau.apps.Poche.events.OfflineQueueChangedEvent;
2023

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

3538
Log.d(TAG, "creating new db session");
3639
WallabagOpenHelper dbHelper = new WallabagOpenHelper(context, "wallabag", null);
40+
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
41+
dbHelper.setWriteAheadLoggingEnabled(true);
42+
}
3743
Database db = dbHelper.getWritableDb();
44+
if(Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
45+
if(!((SQLiteDatabase)db.getRawDatabase()).enableWriteAheadLogging()) {
46+
Log.w(TAG, "write ahead logging was not enabled");
47+
}
48+
}
3849
DaoMaster daoMaster = new DaoMaster(db);
3950
Holder.session = daoMaster.newSession();
4051
} else {
@@ -111,14 +122,19 @@ public void onUpgrade(Database db, int oldVersion, int newVersion) {
111122
db.beginTransaction();
112123
try {
113124
DatabaseStatement stmt = db.compileStatement(
114-
"insert into queue_item(_id, queue_number, action, extra) values(?, ?, ?, ?)");
125+
"insert into " + QueueItemDao.TABLENAME + "("
126+
+ QueueItemDao.Properties.Id.columnName + ", "
127+
+ QueueItemDao.Properties.QueueNumber.columnName + ", "
128+
+ QueueItemDao.Properties.Action.columnName + ", "
129+
+ QueueItemDao.Properties.Extra.columnName
130+
+ ") values(?, ?, ?, ?)");
115131

116132
int i = 1;
117133
for(String url: offlineUrls) {
118134
try {
119135
stmt.bindLong(1, i);
120136
stmt.bindLong(2, i);
121-
stmt.bindLong(3, QueueHelper.QI_ACTION_ADD_LINK);
137+
stmt.bindLong(3, QueueItem.Action.ADD_LINK.getId());
122138
stmt.bindString(4, url);
123139

124140
stmt.executeInsert();

app/src/main/java/fr/gaulupeau/apps/Poche/data/FeedsCredentials.java

Lines changed: 0 additions & 17 deletions
This file was deleted.

app/src/main/java/fr/gaulupeau/apps/Poche/data/LegacySettingsHelper.java

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ class LegacySettingsHelper {
1111
static final String PREFS_NAME = "InThePoche";
1212

1313
static final String URL = "pocheUrl";
14-
static final String USER_ID = "APIUsername";
15-
static final String TOKEN = "APIToken";
16-
static final String ALL_CERTS = "all_certs";
1714
static final String CUSTOM_SSL_SETTINGS = "custom_ssl_settings";
1815
static final String FONT_SIZE = "font_size";
1916
static final String SERIF_FONT = "serif_font";
@@ -22,7 +19,6 @@ class LegacySettingsHelper {
2219
static final String HTTP_AUTH_USERNAME = "http_auth_username";
2320
static final String HTTP_AUTH_PASSWORD = "http_auth_password";
2421
static final String THEME = "theme";
25-
static final String WALLABAG_VERSION = "wallabag_version";
2622
static final String TTS_VISIBLE = "tts.visible";
2723
static final String TTS_OPTIONS_VISIBLE = "tts.options.visible";
2824
static final String TTS_SPEED = "tts.speed";
@@ -42,27 +38,20 @@ class LegacySettingsHelper {
4238
static final String FIRST_SYNC_DONE = "first_sync_done";
4339
static final String PENDING_OFFLINE_QUEUE = "offline_queue.pending";
4440

45-
static boolean migrateLegacySettings(Context cx, SharedPreferences pref) {
41+
static boolean migrateLegacySettings(Context cx, SharedPreferences.Editor prefEditor) {
4642
SharedPreferences legacyPref = cx.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
4743

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

50-
SharedPreferences.Editor prefEditor = pref.edit();
5146
migrateStringPref(cx, URL, R.string.pref_key_connection_url, legacyPref, prefEditor);
52-
migrateIntPref(cx, WALLABAG_VERSION,
53-
R.string.pref_key_connection_serverVersion, legacyPref, prefEditor, -1);
5447
migrateStringPref(cx, USERNAME, R.string.pref_key_connection_username, legacyPref, prefEditor);
5548
migrateStringPref(cx, PASSWORD, R.string.pref_key_connection_password, legacyPref, prefEditor);
56-
migrateStringPref(cx, USER_ID, R.string.pref_key_connection_feedsUserID, legacyPref, prefEditor);
57-
migrateStringPref(cx, TOKEN, R.string.pref_key_connection_feedsToken, legacyPref, prefEditor);
5849

5950
migrateStringPref(cx, HTTP_AUTH_USERNAME,
6051
R.string.pref_key_connection_advanced_httpAuthUsername, legacyPref, prefEditor);
6152
migrateStringPref(cx, HTTP_AUTH_PASSWORD,
6253
R.string.pref_key_connection_advanced_httpAuthPassword, legacyPref, prefEditor);
6354

64-
migrateBooleanPref(cx, ALL_CERTS,
65-
R.string.pref_key_connection_advanced_acceptAllCertificates, legacyPref, prefEditor);
6655
migrateBooleanPref(cx, CUSTOM_SSL_SETTINGS,
6756
R.string.pref_key_connection_advanced_customSSLSettings, legacyPref, prefEditor);
6857

app/src/main/java/fr/gaulupeau/apps/Poche/data/ListAdapter.java

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,13 @@
77
import android.widget.ImageView;
88
import android.widget.TextView;
99

10-
import java.net.URL;
1110
import java.util.List;
1211

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

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

18-
/**
19-
* @author Victor Häggqvist
20-
* @since 10/19/15
21-
*/
2217
public class ListAdapter extends RecyclerView.Adapter<ListAdapter.ViewHolder> {
2318

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

7267
public void bind(Article article) {
73-
String urlText = article.getUrl();
74-
try {
75-
URL url = new URL(urlText);
76-
urlText = url.getHost();
77-
} catch (Exception ignored) {}
78-
7968
title.setText(article.getTitle());
80-
url.setText(urlText);
69+
url.setText(article.getDomain());
8170

8271
boolean showFavourite = false;
8372
boolean showRead = false;

0 commit comments

Comments
 (0)