diff --git a/app/build.gradle b/app/build.gradle index e4d4f73f..ef250d64 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -7,8 +7,8 @@ android { applicationId "com.dar.nclientv2" minSdkVersion 14 targetSdkVersion 30 - versionCode 272 - versionName "2.7.2" + versionCode 273 + versionName "2.7.3-stable" vectorDrawables.useSupportLibrary true proguardFiles 'proguard-rules.pro' } @@ -17,6 +17,7 @@ android { minifyEnabled true shrinkResources true proguardFiles getDefaultProguardFile('proguard-android-optimize.txt') + versionNameSuffix "-release" resValue "string", "app_name", "NClientV2" } debug { diff --git a/app/src/main/java/com/dar/nclientv2/ZoomActivity.java b/app/src/main/java/com/dar/nclientv2/ZoomActivity.java index d3675bcf..5ec0d598 100644 --- a/app/src/main/java/com/dar/nclientv2/ZoomActivity.java +++ b/app/src/main/java/com/dar/nclientv2/ZoomActivity.java @@ -40,6 +40,7 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder; import java.io.File; +import java.util.concurrent.atomic.AtomicLong; public class ZoomActivity extends GeneralActivity { @TargetApi(Build.VERSION_CODES.JELLY_BEAN) @@ -53,6 +54,8 @@ public class ZoomActivity extends GeneralActivity { private final static int showFlags = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE; private static final String VOLUME_SIDE_KEY = "volumeSide"; private static final String SCROLL_TYPE_KEY = "zoomScrollType"; + private static final int CHANGE_VISIBILITY_DELAY=150; + private final AtomicLong aLong=new AtomicLong(System.currentTimeMillis()); private GenericGallery gallery; private int actualPage = 0; private boolean isHidden = false; @@ -86,7 +89,6 @@ protected void onCreate(Bundle savedInstanceState) { getSupportActionBar().setDisplayShowTitleEnabled(true); setTitle(gallery.getTitle()); - //getWindow().getDecorView().setLayoutDirection(View.LAYOUT_DIRECTION_RTL); getWindow().setFlags( WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, @@ -125,8 +127,8 @@ public void onPageScrolled(int position, float positionOffset, int positionOffse public void onPageSelected(int newPage) { int oldPage = actualPage; actualPage = newPage; - setPageText(Global.useRtl() ? gallery.getPageCount() - newPage : newPage + 1); - seekBar.setProgress(Global.useRtl() ? gallery.getPageCount() - 1 - newPage : newPage); + setPageText(offsetPage(newPage)+1); + seekBar.setProgress(offsetPage(newPage)); clearFarRequests(oldPage, newPage); } @@ -169,7 +171,7 @@ public void onStopTrackingTouch(SeekBar seekBar) { changePage(offsetPage(page)); setPageText(page + 1); - seekBar.setProgress(Global.useRtl() ? gallery.getPageCount() - 1 - offsetPage(page) : offsetPage(page)); + seekBar.setProgress(offsetPage(offsetPage(page))); } private void setPageText(int page) { @@ -178,7 +180,11 @@ private void setPageText(int page) { } int offsetPage(int page) { - return Global.useRtl() ? gallery.getPageCount() - 1 - page : page; + return invertDirection() ? gallery.getPageCount() - 1 - page : page; + } + + private boolean invertDirection(){ + return Global.useRtl()&&scrollType==ScrollType.HORIZONTAL; } @Override @@ -221,19 +227,16 @@ private void changeSide() { } private void changeClosePage(boolean next) { + if(scrollType==ScrollType.VERTICAL)next=!next; if (next && mViewPager.getCurrentItem() < (mViewPager.getAdapter().getCount() - 1)) changePage(mViewPager.getCurrentItem() + 1); if (!next && mViewPager.getCurrentItem() > 0) changePage(mViewPager.getCurrentItem() - 1); } @Override - public void onConfigurationChanged(Configuration newConfig) { + public void onConfigurationChanged(@NonNull Configuration newConfig) { super.onConfigurationChanged(newConfig); - if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) { - changeLayout(true); - } else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) { - changeLayout(false); - } + changeLayout(newConfig.orientation==Configuration.ORIENTATION_LANDSCAPE); } private boolean hardwareKeys() { @@ -242,7 +245,7 @@ private boolean hardwareKeys() { private void applyMargin(boolean landscape, View view) { ConstraintLayout.LayoutParams lp = (ConstraintLayout.LayoutParams) view.getLayoutParams(); - lp.setMargins(0, 0, landscape || hardwareKeys() ? Global.getNavigationBarHeight(this) : 0, 0); + lp.setMargins(0, 0, landscape && !hardwareKeys() ? Global.getNavigationBarHeight(this) : 0, 0); view.setLayoutParams(lp); } @@ -267,6 +270,7 @@ private void changeScrollTypeDialog() { scrollType = tmpScrollType; mViewPager.setVerticalMode(scrollType == ScrollType.VERTICAL); getSharedPreferences("Settings", 0).edit().putInt(SCROLL_TYPE_KEY, scrollType.ordinal()).apply(); + changePage(gallery.getPageCount()-1-mViewPager.getCurrentItem()); } }).setNegativeButton(R.string.cancel, null); builder.show(); @@ -403,7 +407,7 @@ public SectionsPagerAdapter(@NonNull FragmentManager fm) { @NonNull @Override public Fragment getItem(int position) { - ZoomFragment f = ZoomFragment.newInstance(gallery, position, directory); + ZoomFragment f = ZoomFragment.newInstance(gallery, offsetPage(position), directory); f.setClickListener(v -> { isHidden = !isHidden; LogUtility.d("Clicked " + isHidden); diff --git a/app/src/main/java/com/dar/nclientv2/adapters/GalleryAdapter.java b/app/src/main/java/com/dar/nclientv2/adapters/GalleryAdapter.java index c5a91468..8e920ab8 100644 --- a/app/src/main/java/com/dar/nclientv2/adapters/GalleryAdapter.java +++ b/app/src/main/java/com/dar/nclientv2/adapters/GalleryAdapter.java @@ -26,6 +26,7 @@ import com.dar.nclientv2.api.components.TagList; import com.dar.nclientv2.api.enums.SpecialTagIds; import com.dar.nclientv2.api.enums.TagType; +import com.dar.nclientv2.api.local.LocalGallery; import com.dar.nclientv2.async.database.Queries; import com.dar.nclientv2.components.GlideX; import com.dar.nclientv2.components.classes.Size; @@ -65,7 +66,7 @@ public class GalleryAdapter extends RecyclerView.Adapter map = new HashMap<>(5); private final HashSet toDelete = new HashSet<>(); private Size maxImageSize = null; @@ -79,15 +80,16 @@ public GalleryAdapter(GalleryActivity cont, GenericGallery gallery, int colCount minSize = gallery.getMinSize(); setColCount(colCount); try { - if (Global.hasStoragePermission(cont)) { + if(gallery instanceof LocalGallery){ + directory=gallery.getGalleryFolder(); + }else if (Global.hasStoragePermission(cont)) { if (gallery.getId() != -1) { File f = Global.findGalleryFolder(context, gallery.getId()); if (f != null) directory = new GalleryFolder(f); - else directory = null; } else { directory = new GalleryFolder(gallery.getTitle()); } - } else directory = null; + } } catch (IllegalArgumentException ignore) { directory = null; } diff --git a/app/src/main/java/com/dar/nclientv2/async/VersionChecker.java b/app/src/main/java/com/dar/nclientv2/async/VersionChecker.java index 6e634ebe..1cce5860 100644 --- a/app/src/main/java/com/dar/nclientv2/async/VersionChecker.java +++ b/app/src/main/java/com/dar/nclientv2/async/VersionChecker.java @@ -81,6 +81,8 @@ public void onResponse(@NonNull Call call, @NonNull Response response) throws IO } private static int extractVersion(String version) { + int index=version.indexOf('-'); + if(index>=0)version=version.substring(0,index); return Integer.parseInt(version.replace(".", "")); } diff --git a/app/src/main/java/com/dar/nclientv2/components/views/VerticalViewPager.java b/app/src/main/java/com/dar/nclientv2/components/views/VerticalViewPager.java index 8f103ae7..39af79c3 100644 --- a/app/src/main/java/com/dar/nclientv2/components/views/VerticalViewPager.java +++ b/app/src/main/java/com/dar/nclientv2/components/views/VerticalViewPager.java @@ -6,6 +6,8 @@ import android.view.MotionEvent; import android.view.View; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import androidx.viewpager.widget.ViewPager; import com.dar.nclientv2.components.widgets.CustomViewPager; @@ -14,10 +16,11 @@ public class VerticalViewPager extends ViewPager { private CustomViewPager.OnItemClickListener mOnItemClickListener; private boolean verticalMode = true; + @Nullable + private OnClickListener onClickListener; public VerticalViewPager(Context context) { this(context, null); - init(); } public VerticalViewPager(Context context, AttributeSet attrs) { @@ -48,6 +51,11 @@ private void init() { setup(); } + @Override + public void setOnClickListener(@Nullable final OnClickListener onClickListener) { + this.onClickListener = onClickListener; + } + @Override public boolean onInterceptTouchEvent(MotionEvent ev) { @@ -97,8 +105,12 @@ private MotionEvent flipXY(MotionEvent ev) { private void setup() { final GestureDetector tapGestureDetector = new GestureDetector(getContext(), new VerticalViewPager.TapGestureListener()); + final GestureDetector onSingleTapConfirmedGestureDetector = + new GestureDetector(getContext(), new OnSingleTapConfirmedGestureListener(this)); + setOnTouchListener((v, event) -> { tapGestureDetector.onTouchEvent(event); + onSingleTapConfirmedGestureDetector.onTouchEvent(event); performClick(); return false; }); @@ -140,6 +152,22 @@ public boolean onSingleTapConfirmed(MotionEvent e) { return true; } } + private class OnSingleTapConfirmedGestureListener extends GestureDetector.SimpleOnGestureListener { + + @NonNull + private final View view; + public OnSingleTapConfirmedGestureListener(@NonNull final View view) { + this.view = view; + } + + @Override + public boolean onSingleTapConfirmed(final MotionEvent e) { + if (onClickListener != null) { + onClickListener.onClick(view); + } + return true; + } + } } diff --git a/app/src/main/java/com/dar/nclientv2/components/views/ZoomFragment.java b/app/src/main/java/com/dar/nclientv2/components/views/ZoomFragment.java index 2c2b8bdc..97b67058 100644 --- a/app/src/main/java/com/dar/nclientv2/components/views/ZoomFragment.java +++ b/app/src/main/java/com/dar/nclientv2/components/views/ZoomFragment.java @@ -45,7 +45,6 @@ public ZoomFragment() { public static ZoomFragment newInstance(GenericGallery gallery, int page, @Nullable GalleryFolder directory) { Bundle args = new Bundle(); - if (Global.useRtl()) page = gallery.getPageCount() - 1 - page; args.putInt("PAGE", page); args.putInt("ID", gallery.getId()); args.putString("URL", gallery.isLocal() ? null : ((Gallery) gallery).getPageUrl(page).toString()); diff --git a/app/src/main/res/values-ar-rSA/strings.xml b/app/src/main/res/values-ar-rSA/strings.xml index e6d70e4c..265a117e 100644 --- a/app/src/main/res/values-ar-rSA/strings.xml +++ b/app/src/main/res/values-ar-rSA/strings.xml @@ -310,5 +310,6 @@ Insert path: Requesting storage access Due to some restriction in Android 11 to the storage access this app will require you to give additional permission to use custom paths.\nIf you want to give those permission please enable the setting in the next dialog. + Updating to a beta version can make you unable to return to a stable version without uninstalling diff --git a/app/src/main/res/values-de-rDE/strings.xml b/app/src/main/res/values-de-rDE/strings.xml index 0e404cd7..d5b224b1 100644 --- a/app/src/main/res/values-de-rDE/strings.xml +++ b/app/src/main/res/values-de-rDE/strings.xml @@ -332,5 +332,6 @@ Insert path: Requesting storage access Due to some restriction in Android 11 to the storage access this app will require you to give additional permission to use custom paths.\nIf you want to give those permission please enable the setting in the next dialog. + Updating to a beta version can make you unable to return to a stable version without uninstalling diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 3bbe0c77..392d9cc5 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -307,5 +307,6 @@ Insert path: Requesting storage access Due to some restriction in Android 11 to the storage access this app will require you to give additional permission to use custom paths.\nIf you want to give those permission please enable the setting in the next dialog. + Updating to a beta version can make you unable to return to a stable version without uninstalling diff --git a/app/src/main/res/values-it-rIT/strings.xml b/app/src/main/res/values-it-rIT/strings.xml index 66402632..b9e67b78 100644 --- a/app/src/main/res/values-it-rIT/strings.xml +++ b/app/src/main/res/values-it-rIT/strings.xml @@ -332,5 +332,6 @@ Inserisci percorso Richiesta accesso alla memoria Per via di alcune restrizioni sull\'accesso alla memoria su Android 11 sono richiesti ulteriori permessi per usare i percorsi personalizzati.\nSe vuoi dare questi permessi abilitali nella prossima schermata. + Updating to a beta version can make you unable to return to a stable version without uninstalling diff --git a/app/src/main/res/values-tr-rTR/strings.xml b/app/src/main/res/values-tr-rTR/strings.xml index 990f27af..55242b2e 100644 --- a/app/src/main/res/values-tr-rTR/strings.xml +++ b/app/src/main/res/values-tr-rTR/strings.xml @@ -330,4 +330,5 @@ Dizin Gir: Depolamaya erişim izni isteniyor Android 11\'de depolama erişimine yönelik bazı kısıtlamalar nedeniyle, bu uygulama özel yolları kullanmak için ek izin vermenizi gerektirecektir. \nBu izinleri vermek istiyorsanız, lütfen sonraki iletişim kutusunda uygulamaya izin verin. + Updating to a beta version can make you unable to return to a stable version without uninstalling diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index d5725d14..dd6f4e06 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -310,6 +310,7 @@ Insert path: Requesting storage access Due to some restriction in Android 11 to the storage access this app will require you to give additional permission to use custom paths.\nIf you want to give those permission please enable the setting in the next dialog. + Updating to a beta version can make you unable to return to a stable version without uninstalling diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index 8b8ea08b..cbc9b2ba 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -336,6 +336,7 @@ Insert path: Requesting storage access Due to some restriction in Android 11 to the storage access this app will require you to give additional permission to use custom paths.\nIf you want to give those permission please enable the setting in the next dialog. + Updating to a beta version can make you unable to return to a stable version without uninstalling diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index a909aee2..3331d4c1 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -339,6 +339,7 @@ Insert path: Requesting storage access Due to some restriction in Android 11 to the storage access this app will require you to give additional permission to use custom paths.\nIf you want to give those permission please enable the setting in the next dialog. + Updating to a beta version can make you unable to return to a stable version without uninstalling Horizontal diff --git a/app/src/main/res/xml/settings.xml b/app/src/main/res/xml/settings.xml index bab38d85..6e0aa9c4 100644 --- a/app/src/main/res/xml/settings.xml +++ b/app/src/main/res/xml/settings.xml @@ -213,6 +213,7 @@ android:defaultValue="false" android:key="@string/key_enable_beta" android:title="@string/check_beta_releases" + android:summary="@string/summary_beta" app:iconSpaceReserved="false" />