diff --git a/Configure b/Configure new file mode 100644 index 000000000..e69de29bb diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 579e9fe74..a8765d16c 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -49,8 +49,7 @@ android:theme="@style/StyledIndicatorsWhite" android:usesCleartextTraffic="true" android:vmSafeMode="${appSafeMode}" - tools:overrideLibrary="androidx.car.app" - tools:replace="label, icon, roundIcon"> + tools:overrideLibrary="androidx.car.app"> { NO_SERIES = " (" + getString(R.string.without_series) + ")"; - handler = new Handler(); + handler = new Handler(Looper.getMainLooper()); secondTopPanel = view.findViewById(R.id.secondTopPanel); countBooks = (TextView) view.findViewById(R.id.countBooks); @@ -448,7 +449,7 @@ public class SearchFragment2 extends UIFragment { @Override public void run() { - Prefs.get().remove(SearchAllBooksWorker.SEARCH_ERRORS,0); + Prefs.get().remove(SearchAllBooksWorker.SEARCH_ERRORS, 0); recyclerView.scrollToPosition(0); seachAll(); } diff --git a/app/src/main/java/com/foobnix/ui2/fragment/UIFragment.java b/app/src/main/java/com/foobnix/ui2/fragment/UIFragment.java index 7b18fde4d..d345c5429 100644 --- a/app/src/main/java/com/foobnix/ui2/fragment/UIFragment.java +++ b/app/src/main/java/com/foobnix/ui2/fragment/UIFragment.java @@ -8,6 +8,7 @@ import android.content.res.Configuration; import android.os.AsyncTask; import android.os.Bundle; import android.os.Handler; +import android.os.Looper; import android.view.View; import android.widget.ImageView; @@ -21,6 +22,7 @@ import androidx.recyclerview.widget.RecyclerView; import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; import com.bumptech.glide.Glide; +import com.foobnix.LibreraApp; import com.foobnix.android.utils.Apps; import com.foobnix.android.utils.Dips; import com.foobnix.android.utils.LOG; @@ -43,7 +45,6 @@ import com.foobnix.ui2.adapter.FileMetaAdapter; import com.foobnix.ui2.fast.FastScrollRecyclerView; import com.foobnix.ui2.fast.FastScrollStateChangeListener; -import com.foobnix.LibreraApp; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; @@ -79,7 +80,7 @@ public abstract class UIFragment extends Fragment { @Override public void onAttach(Context context) { super.onAttach(context); - handler = new Handler(); + handler = new Handler(Looper.getMainLooper()); } @Override @@ -137,7 +138,7 @@ public abstract class UIFragment extends Fragment { public abstract void resetFragment(); - public void onDoubleClick(){ + public void onDoubleClick() { } diff --git a/app/src/main/java/org/ebookdroid/ui/viewer/VerticalViewActivity.java b/app/src/main/java/org/ebookdroid/ui/viewer/VerticalViewActivity.java index bdb56e8eb..aad180744 100644 --- a/app/src/main/java/org/ebookdroid/ui/viewer/VerticalViewActivity.java +++ b/app/src/main/java/org/ebookdroid/ui/viewer/VerticalViewActivity.java @@ -10,6 +10,7 @@ import android.content.res.Configuration; import android.os.Build; import android.os.Bundle; import android.os.Handler; +import android.os.Looper; import android.util.DisplayMetrics; import android.view.KeyEvent; import android.view.MotionEvent; @@ -20,7 +21,6 @@ import com.foobnix.android.utils.Dips; import com.foobnix.android.utils.Intents; import com.foobnix.android.utils.Keyboards; import com.foobnix.android.utils.LOG; -import com.foobnix.android.utils.TxtUtils; import com.foobnix.drive.GFile; import com.foobnix.model.AppBook; import com.foobnix.model.AppProfile; @@ -159,7 +159,7 @@ public class VerticalViewActivity extends AbstractActionActivity[] m_interfaces; - - /** - * Real listeners. - */ - private final Map, List> m_listeners = new HashMap, List>(); - - private final Object m_proxy; - - private final InvocationHandler m_handler; - - /** - * Constructor - * - * @param type - * invocation type - * @param target - * target object - * @param listeners - * a list of listener interfaces - */ - public EventDispatcher(final Activity base, final InvokationType type, final Class... listeners) { - - if (LengthUtils.isEmpty(listeners)) { - throw new IllegalArgumentException("Listeners list cannot be empty"); - } - - for (final Class listener : listeners) { - if (listener == null) { - throw new IllegalArgumentException("Listener class cannot be null"); - } - if (!listener.isInterface()) { - throw new IllegalArgumentException("Listener class should be an interface"); - } - } - - m_base = base; - m_type = type; - m_handler = new Handler(); - m_interfaces = listeners; - m_proxy = Proxy.newProxyInstance(this.getClass().getClassLoader(), listeners, m_handler); - } - - /** - * Adds the target listener. - * - * @param listener - * the listener to add - */ - public void addListener(final Object listener) { - if (listener != null) { - for (final Class listenerClass : m_interfaces) { - if (listenerClass.isInstance(listener)) { - List list = m_listeners.get(listenerClass); - if (list == null) { - list = new LinkedList(); - m_listeners.put(listenerClass, list); - } - - if (!list.contains(listener)) { - list.add(listener); - } - } - } - } - } - - /** - * Removes the target listener. - * - * @param listener - * the listener to remove - */ - public void removeListener(final Object listener) { - if (listener != null) { - for (final Class listenerClass : m_interfaces) { - if (listenerClass.isInstance(listener)) { - final List list = m_listeners.get(listenerClass); - if (list != null) { - list.remove(listener); - } - } - } - } - } - - /** - * Gets a listener of the given type. - * - * @param - * listener type - * @return listener proxy object casted to the given type - */ - @SuppressWarnings("unchecked") - public Listener getListener() { - return (Listener) m_proxy; - } - - /** - * This class implements invocation handler for event listeners. - */ - private class Handler implements InvocationHandler { - - /** - * Processes a method invocation on a proxy instance and returns the - * result. - * - * @param proxy - * the proxy instance that the method was invoked on - * @param method - * the Method instance corresponding to - * the interface method invoked on the proxy instance. - * @param args - * an array of objects containing the values of the - * arguments passed in the method invocation on the proxy - * instance. - * @return the value to return from the method invocation on the - * proxy instance. - * @throws Throwable - * the exception to throw from the method - * invocation on the proxy instance. - * @see InvocationHandler#invoke(Object, Method, Object[]) - */ - @Override - public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable { - final Class listenerClass = method.getDeclaringClass(); - final List targets = m_listeners.get(listenerClass); - if (LengthUtils.isNotEmpty(targets)) { - final Task task = new Task(targets, method, args); - switch (m_type) { - case AsyncUI: - m_base.runOnUiThread(task); - break; - case SeparatedThread: - new Thread(task,"@T event invoke").start(); - break; - case Direct: - default: - task.run(); - break; - } - } - return null; - } - - } - - /** - * This class implements thread task for listener invocation. - */ - private class Task implements Runnable { - - private final List m_targets; - - private final Method m_method; - - private final Object[] m_args; - - /** - * Constructor - * - * @param method - * called method - * @param args - * method parameters - */ - public Task(final List targets, final Method method, final Object[] args) { - m_targets = targets; - m_method = method; - m_args = args; - } - - /** - * - * @see java.lang.Runnable#run() - */ - @Override - public synchronized void run() { - directInvoke(); - } - - /** - * Direct invoke of the action. - * - * @param method - * called method - * @param args - * method parameters - */ - protected void directInvoke() { - for (final Object target : m_targets) { - try { - m_method.invoke(target, m_args); - } catch (final Throwable ex) { - ex.printStackTrace(); - } - } - } - } -} diff --git a/app/src/main/java/test/TestActivity.java b/app/src/main/java/test/TestActivity.java index 606d70bc4..30568d4e7 100644 --- a/app/src/main/java/test/TestActivity.java +++ b/app/src/main/java/test/TestActivity.java @@ -9,6 +9,7 @@ import android.graphics.Paint; import android.os.Bundle; import android.os.Handler; import android.os.HandlerThread; +import android.os.Looper; import android.os.Message; import android.view.MotionEvent; import android.view.ScaleGestureDetector; @@ -29,7 +30,8 @@ public class TestActivity extends Activity implements View.OnTouchListener, static int dx = 0; static int dy = 0; ScaleGestureDetector scaleGestureDetector; - static float zoom =1; + static float zoom = 1; + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -40,7 +42,7 @@ public class TestActivity extends Activity implements View.OnTouchListener, setContentView(mSurface); - Handler h = new Handler(); + Handler h = new Handler(Looper.getMainLooper()); h.postDelayed(new Runnable() { @Override public void run() { @@ -49,10 +51,10 @@ public class TestActivity extends Activity implements View.OnTouchListener, } }, 200); - scaleGestureDetector = new ScaleGestureDetector(this, new ScaleGestureDetector.OnScaleGestureListener() { + scaleGestureDetector = new ScaleGestureDetector(this, new ScaleGestureDetector.OnScaleGestureListener() { @Override public boolean onScale(ScaleGestureDetector detector) { - zoom =zoom* detector.getScaleFactor(); + zoom = zoom * detector.getScaleFactor(); LOG.d("ScaleGestureDetector onScale", detector.getScaleFactor(), detector.getCurrentSpan(), detector.getPreviousSpan()); return true; @@ -79,7 +81,6 @@ public class TestActivity extends Activity implements View.OnTouchListener, int initX, initY; - public boolean onTouch(View v, MotionEvent event) { boolean res = scaleGestureDetector.onTouchEvent(event); if (event.getAction() == MotionEvent.ACTION_DOWN) { @@ -89,8 +90,8 @@ public class TestActivity extends Activity implements View.OnTouchListener, } if (event.getAction() == MotionEvent.ACTION_MOVE) { // mThread.addItem((int) event.getX(), (int) event.getY()); - dx = (int) event.getX()-initX; - dy = (int)event.getY()-initY; + dx = (int) event.getX() - initX; + dy = (int) event.getY() - initY; } return res; } @@ -200,12 +201,12 @@ public class TestActivity extends Activity implements View.OnTouchListener, // Clear Canvas first c.drawColor(Color.BLACK); - c.translate(dx*3,dy*3); - c.scale(zoom,zoom); + c.translate(dx * 3, dy * 3); + c.scale(zoom, zoom); //c.getMatrix().postTranslate(dx,dy); //c.getMatrix().preScale(2,2); - c.drawRect(1,1,mDrawingWidth-1, mDrawingHeight-1,bPaint); + c.drawRect(1, 1, mDrawingWidth - 1, mDrawingHeight - 1, bPaint); // Draw each item for (DrawingItem item : mLocations) { @@ -230,7 +231,6 @@ public class TestActivity extends Activity implements View.OnTouchListener, c.restore(); - // Release to be rendered to the screen mDrawingSurface.unlockCanvasAndPost(c); break; diff --git a/appCompose/build.gradle.kts b/appCompose/build.gradle.kts index fc41c9ff2..6ff5ece95 100644 --- a/appCompose/build.gradle.kts +++ b/appCompose/build.gradle.kts @@ -12,12 +12,12 @@ plugins { android { namespace = "mobi.librera.appcompose" - compileSdk = 36 + compileSdk = rootProject.extra["compileSdk"] as Int defaultConfig { applicationId = "mobi.librera.appcompose" - minSdk = 30 - targetSdk = 36 + minSdk = rootProject.extra["minSdk"] as Int + targetSdk = rootProject.extra["targetSdk"] as Int versionCode = 1 versionName = "1.0" diff --git a/build.gradle.kts b/build.gradle.kts index a042d6d3c..7195b0967 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,6 +1,6 @@ plugins { - id("com.android.application") version "8.11.1" apply false - id("com.android.library") version "8.11.1" apply false + id("com.android.application") version "8.12.0" apply false + id("com.android.library") version "8.12.0" apply false id("org.jetbrains.kotlin.android") version "2.2.0" apply false id("org.jetbrains.kotlin.plugin.compose") version "2.2.0" apply false id("androidx.room") version "2.7.2" apply false diff --git a/googleDrive/build.gradle.kts b/googleDrive/build.gradle.kts index 76c613191..792d7ded5 100644 --- a/googleDrive/build.gradle.kts +++ b/googleDrive/build.gradle.kts @@ -7,11 +7,18 @@ plugins { android { namespace = "com.foobnix.googledrive" - compileSdk = 36 + compileSdk = rootProject.extra["compileSdk"] as Int defaultConfig { - minSdk = 24 - targetSdk = 36 + minSdk = rootProject.extra["minSdk"] as Int + } + + lint { + targetSdk = rootProject.extra["targetSdk"] as Int + } + + testOptions { + targetSdk = rootProject.extra["targetSdk"] as Int } compileOptions {