From b8061a6a1e0c11b73ce6224c64cae66ef0714bfd Mon Sep 17 00:00:00 2001 From: jendib Date: Wed, 22 Apr 2015 23:18:14 +0200 Subject: [PATCH 1/4] Android: upgrade to AppCompat 22.1 --- docs-android/app/app.iml | 6 +++--- docs-android/app/build.gradle | 2 +- .../sismics/docs/activity/DocumentEditActivity.java | 4 ++-- .../sismics/docs/activity/DocumentViewActivity.java | 10 ++++++---- .../java/com/sismics/docs/activity/LoginActivity.java | 4 ++-- .../java/com/sismics/docs/activity/MainActivity.java | 11 +++++++---- .../com/sismics/docs/activity/SettingsActivity.java | 10 ++++++---- 7 files changed, 27 insertions(+), 20 deletions(-) diff --git a/docs-android/app/app.iml b/docs-android/app/app.iml index 11564944..999cb6ee 100644 --- a/docs-android/app/app.iml +++ b/docs-android/app/app.iml @@ -101,15 +101,15 @@ - - - + + + \ No newline at end of file diff --git a/docs-android/app/build.gradle b/docs-android/app/build.gradle index 3f7040d8..e1f591d4 100644 --- a/docs-android/app/build.gradle +++ b/docs-android/app/build.gradle @@ -35,7 +35,7 @@ android { dependencies { compile fileTree(dir: 'libs', include: '*.jar') - compile 'com.android.support:appcompat-v7:22.0.0' + compile 'com.android.support:appcompat-v7:22.1.0' compile 'com.android.support:recyclerview-v7:22.0.0' compile 'com.loopj.android:android-async-http:1.4.6' compile 'it.sephiroth.android.library.imagezoom:imagezoom:1.0.5' diff --git a/docs-android/app/src/main/java/com/sismics/docs/activity/DocumentEditActivity.java b/docs-android/app/src/main/java/com/sismics/docs/activity/DocumentEditActivity.java index 36cac205..56cde065 100644 --- a/docs-android/app/src/main/java/com/sismics/docs/activity/DocumentEditActivity.java +++ b/docs-android/app/src/main/java/com/sismics/docs/activity/DocumentEditActivity.java @@ -3,7 +3,7 @@ package com.sismics.docs.activity; import android.app.ProgressDialog; import android.content.DialogInterface; import android.os.Bundle; -import android.support.v7.app.ActionBarActivity; +import android.support.v7.app.AppCompatActivity; import android.util.Log; import android.view.Menu; import android.view.MenuInflater; @@ -43,7 +43,7 @@ import de.greenrobot.event.EventBus; * * @author bgamard. */ -public class DocumentEditActivity extends ActionBarActivity { +public class DocumentEditActivity extends AppCompatActivity { /** * Document edited. */ diff --git a/docs-android/app/src/main/java/com/sismics/docs/activity/DocumentViewActivity.java b/docs-android/app/src/main/java/com/sismics/docs/activity/DocumentViewActivity.java index 305e363c..6b982c6d 100644 --- a/docs-android/app/src/main/java/com/sismics/docs/activity/DocumentViewActivity.java +++ b/docs-android/app/src/main/java/com/sismics/docs/activity/DocumentViewActivity.java @@ -13,7 +13,7 @@ import android.os.Bundle; import android.os.Environment; import android.support.v4.app.DialogFragment; import android.support.v4.view.ViewPager; -import android.support.v7.app.ActionBarActivity; +import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.text.TextUtils; import android.text.format.DateFormat; @@ -57,7 +57,7 @@ import de.greenrobot.event.EventBus; * * @author bgamard */ -public class DocumentViewActivity extends ActionBarActivity { +public class DocumentViewActivity extends AppCompatActivity { /** * Request code of adding file. */ @@ -116,8 +116,10 @@ public class DocumentViewActivity extends ActionBarActivity { // Setup the activity setContentView(R.layout.document_view_activity); - getSupportActionBar().setDisplayHomeAsUpEnabled(true); - getSupportActionBar().setHomeButtonEnabled(true); + if (getSupportActionBar() != null) { + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + getSupportActionBar().setHomeButtonEnabled(true); + } // Fill the view refreshDocument(document); diff --git a/docs-android/app/src/main/java/com/sismics/docs/activity/LoginActivity.java b/docs-android/app/src/main/java/com/sismics/docs/activity/LoginActivity.java index 27ff193b..dc10323b 100644 --- a/docs-android/app/src/main/java/com/sismics/docs/activity/LoginActivity.java +++ b/docs-android/app/src/main/java/com/sismics/docs/activity/LoginActivity.java @@ -3,7 +3,7 @@ package com.sismics.docs.activity; import android.content.Intent; import android.os.Bundle; import android.preference.PreferenceManager; -import android.support.v7.app.ActionBarActivity; +import android.support.v7.app.AppCompatActivity; import android.text.Html; import android.text.method.LinkMovementMethod; import android.view.View; @@ -30,7 +30,7 @@ import org.json.JSONObject; * * @author bgamard */ -public class LoginActivity extends ActionBarActivity { +public class LoginActivity extends AppCompatActivity { /** * User interface. diff --git a/docs-android/app/src/main/java/com/sismics/docs/activity/MainActivity.java b/docs-android/app/src/main/java/com/sismics/docs/activity/MainActivity.java index fd8a8aba..b013f29b 100644 --- a/docs-android/app/src/main/java/com/sismics/docs/activity/MainActivity.java +++ b/docs-android/app/src/main/java/com/sismics/docs/activity/MainActivity.java @@ -7,8 +7,8 @@ import android.content.res.Configuration; import android.os.Bundle; import android.provider.SearchRecentSuggestions; import android.support.v4.widget.DrawerLayout; -import android.support.v7.app.ActionBarActivity; import android.support.v7.app.ActionBarDrawerToggle; +import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.SearchView; import android.view.Menu; import android.view.MenuInflater; @@ -39,7 +39,8 @@ import de.greenrobot.event.EventBus; * * @author bgamard */ -public class MainActivity extends ActionBarActivity { + +public class MainActivity extends AppCompatActivity { private ActionBarDrawerToggle drawerToggle; private MenuItem searchItem; @@ -61,8 +62,10 @@ public class MainActivity extends ActionBarActivity { // Enable ActionBar app icon to behave as action to toggle nav drawer drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); - getSupportActionBar().setDisplayHomeAsUpEnabled(true); - getSupportActionBar().setHomeButtonEnabled(true); + if (getSupportActionBar() != null) { + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + getSupportActionBar().setHomeButtonEnabled(true); + } // ActionBarDrawerToggle ties together the the proper interactions // between the sliding drawer and the action bar app icon diff --git a/docs-android/app/src/main/java/com/sismics/docs/activity/SettingsActivity.java b/docs-android/app/src/main/java/com/sismics/docs/activity/SettingsActivity.java index 510c3489..176e8120 100644 --- a/docs-android/app/src/main/java/com/sismics/docs/activity/SettingsActivity.java +++ b/docs-android/app/src/main/java/com/sismics/docs/activity/SettingsActivity.java @@ -1,7 +1,7 @@ package com.sismics.docs.activity; import android.os.Bundle; -import android.support.v7.app.ActionBarActivity; +import android.support.v7.app.AppCompatActivity; import android.view.MenuItem; import com.sismics.docs.fragment.SettingsFragment; @@ -11,14 +11,16 @@ import com.sismics.docs.fragment.SettingsFragment; * * @author bgamard. */ -public class SettingsActivity extends ActionBarActivity { +public class SettingsActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - getSupportActionBar().setDisplayHomeAsUpEnabled(true); - getSupportActionBar().setHomeButtonEnabled(true); + if (getSupportActionBar() != null) { + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + getSupportActionBar().setHomeButtonEnabled(true); + } // Display the fragment as the main content. getFragmentManager().beginTransaction() From c283607063f9a70317bd0b15c09368d76f87b0de Mon Sep 17 00:00:00 2001 From: jendib Date: Wed, 29 Apr 2015 01:28:42 +0200 Subject: [PATCH 2/4] Don't crash if a file is deleted before OCR is completed --- .../docs/core/listener/async/FileCreatedAsyncListener.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs-core/src/main/java/com/sismics/docs/core/listener/async/FileCreatedAsyncListener.java b/docs-core/src/main/java/com/sismics/docs/core/listener/async/FileCreatedAsyncListener.java index be688334..1b76cb0d 100644 --- a/docs-core/src/main/java/com/sismics/docs/core/listener/async/FileCreatedAsyncListener.java +++ b/docs-core/src/main/java/com/sismics/docs/core/listener/async/FileCreatedAsyncListener.java @@ -48,6 +48,11 @@ public class FileCreatedAsyncListener { @Override public void run() { FileDao fileDao = new FileDao(); + if (fileDao.getById(file.getId()) == null) { + // The file has been deleted since the OCR-ization started, ignore the result + return; + } + file.setContent(content); fileDao.update(file); } From a1af1f369fffddaa0e3b068d1dbb52fca29e4cdf Mon Sep 17 00:00:00 2001 From: jendib Date: Fri, 1 May 2015 19:44:20 +0200 Subject: [PATCH 3/4] Fixes #10: Page size for pagination --- docs-web/src/main/webapp/src/partial/docs/document.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs-web/src/main/webapp/src/partial/docs/document.html b/docs-web/src/main/webapp/src/partial/docs/document.html index 66647a32..762b2ad3 100644 --- a/docs-web/src/main/webapp/src/partial/docs/document.html +++ b/docs-web/src/main/webapp/src/partial/docs/document.html @@ -48,7 +48,7 @@
- +