From ea1ce6387b2c57fb3ec3689fd5ccc189f8716761 Mon Sep 17 00:00:00 2001 From: Lukas Date: Wed, 20 Sep 2017 09:56:46 +0200 Subject: [PATCH] - minor Bug fixes --- .../koller/cameraroll/ui/AlbumActivity.java | 12 ++++++----- .../us/koller/cameraroll/ui/ItemActivity.java | 6 ++++-- .../us/koller/cameraroll/ui/MainActivity.java | 16 +++++++-------- .../cameraroll/ui/VideoPlayerActivity.java | 20 ++++++++++--------- .../us/koller/cameraroll/util/MediaType.java | 7 +++++-- .../res/values-pl/strings_translatable.xml | 20 ++++++++++++++++--- 6 files changed, 52 insertions(+), 29 deletions(-) diff --git a/app/src/main/java/us/koller/cameraroll/ui/AlbumActivity.java b/app/src/main/java/us/koller/cameraroll/ui/AlbumActivity.java index 5e25b756..ae4db2cc 100644 --- a/app/src/main/java/us/koller/cameraroll/ui/AlbumActivity.java +++ b/app/src/main/java/us/koller/cameraroll/ui/AlbumActivity.java @@ -1013,12 +1013,14 @@ public void onBackPressed() { @Override public void onSaveInstanceState(Bundle outState) { + super.onSaveInstanceState(outState); //outState.putParcelable(ALBUM, album); - outState.putParcelable(RECYCLER_VIEW_SCROLL_STATE, - recyclerView.getLayoutManager().onSaveInstanceState()); - - RecyclerViewAdapter adapter = ((RecyclerViewAdapter) recyclerView.getAdapter()); - adapter.saveInstanceState(outState); + if (recyclerView != null) { + outState.putParcelable(RECYCLER_VIEW_SCROLL_STATE, + recyclerView.getLayoutManager().onSaveInstanceState()); + RecyclerViewAdapter adapter = ((RecyclerViewAdapter) recyclerView.getAdapter()); + adapter.saveInstanceState(outState); + } } @Override diff --git a/app/src/main/java/us/koller/cameraroll/ui/ItemActivity.java b/app/src/main/java/us/koller/cameraroll/ui/ItemActivity.java index a181ae41..6ee83797 100644 --- a/app/src/main/java/us/koller/cameraroll/ui/ItemActivity.java +++ b/app/src/main/java/us/koller/cameraroll/ui/ItemActivity.java @@ -272,7 +272,7 @@ private void onAlbumLoaded(Bundle savedInstanceState) { if (albumItem == null) { if (savedInstanceState == null) { int position = getIntent().getIntExtra(ITEM_POSITION, 0); - if (album != null && position < album.getAlbumItems().size()) { + if (album != null && position >= 0 && position < album.getAlbumItems().size()) { albumItem = album.getAlbumItems().get(position); albumItem.isSharedElement = true; } @@ -297,7 +297,8 @@ private void onAlbumLoaded(Bundle savedInstanceState) { viewPager = findViewById(R.id.view_pager); viewPager.setAdapter(new ViewPagerAdapter(album)); - viewPager.setCurrentItem(album.getAlbumItems().indexOf(albumItem), false); + int currentItem = album.getAlbumItems().indexOf(albumItem); + viewPager.setCurrentItem(currentItem >= 0 ? currentItem : 0, false); viewPager.setPageTransformer(false, new ParallaxTransformer()); viewPager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { private final int color = ContextCompat.getColor(ItemActivity.this, R.color.white); @@ -816,6 +817,7 @@ public void onPermissionGranted() { @Override public void onSaveInstanceState(Bundle outState) { + super.onSaveInstanceState(outState); if (albumItem instanceof Photo) { View itemView = viewPager.findViewWithTag(albumItem.getPath()); if (itemView != null) { diff --git a/app/src/main/java/us/koller/cameraroll/ui/MainActivity.java b/app/src/main/java/us/koller/cameraroll/ui/MainActivity.java index e31ca702..b1c374a7 100644 --- a/app/src/main/java/us/koller/cameraroll/ui/MainActivity.java +++ b/app/src/main/java/us/koller/cameraroll/ui/MainActivity.java @@ -75,7 +75,9 @@ public void onMapSharedElements(List names, Map sharedElem return; } - if (sharedElementViewHolder.sharedElementReturnPosition != -1) { + if (sharedElementViewHolder.sharedElementReturnPosition != -1 + && sharedElementViewHolder.sharedElementReturnPosition < + sharedElementViewHolder.getAlbum().getAlbumItems().size()) { String newTransitionName = sharedElementViewHolder.getAlbum().getAlbumItems() .get(sharedElementViewHolder.sharedElementReturnPosition).getPath(); View layout = sharedElementViewHolder.nestedRecyclerView.findViewWithTag(newTransitionName); @@ -87,7 +89,6 @@ public void onMapSharedElements(List names, Map sharedElem sharedElements.put(newTransitionName, newSharedElement); } sharedElementViewHolder.sharedElementReturnPosition = -1; - } else { View v = sharedElementViewHolder.itemView.getRootView(); View navigationBar = v.findViewById(android.R.id.navigationBarBackground); @@ -292,21 +293,20 @@ public WindowInsets onApplyWindowInsets(View view, WindowInsets insets) { // clear this listener so insets aren't re-applied rootView.setOnApplyWindowInsetsListener(null); Log.d("MainActivity", "onApplyWindowInsets()" - + "[" + - insets.getSystemWindowInsetLeft() + ", " + + + "[" + insets.getSystemWindowInsetLeft() + ", " + insets.getSystemWindowInsetTop() + ", " + insets.getSystemWindowInsetRight() + ", " + insets.getSystemWindowInsetBottom() + "]"); - toolbar.setPadding(toolbar.getPaddingStart() + insets.getSystemWindowInsetLeft(), + toolbar.setPadding(toolbar.getPaddingStart(), toolbar.getPaddingTop() + insets.getSystemWindowInsetTop(), - toolbar.getPaddingEnd() + insets.getSystemWindowInsetRight(), + toolbar.getPaddingEnd(), toolbar.getPaddingBottom()); ViewGroup.MarginLayoutParams toolbarParams = (ViewGroup.MarginLayoutParams) toolbar.getLayoutParams(); - toolbarParams.leftMargin += insets.getSystemWindowInsetLeft(); - toolbarParams.rightMargin += insets.getSystemWindowInsetRight(); + toolbarParams.leftMargin = insets.getSystemWindowInsetLeft(); + toolbarParams.rightMargin = insets.getSystemWindowInsetRight(); toolbar.setLayoutParams(toolbarParams); recyclerView.setPadding(recyclerView.getPaddingStart() + insets.getSystemWindowInsetLeft(), diff --git a/app/src/main/java/us/koller/cameraroll/ui/VideoPlayerActivity.java b/app/src/main/java/us/koller/cameraroll/ui/VideoPlayerActivity.java index ed030107..1494141e 100644 --- a/app/src/main/java/us/koller/cameraroll/ui/VideoPlayerActivity.java +++ b/app/src/main/java/us/koller/cameraroll/ui/VideoPlayerActivity.java @@ -2,6 +2,7 @@ import android.animation.Animator; import android.animation.AnimatorListenerAdapter; +import android.app.PictureInPictureParams; import android.content.Intent; import android.content.res.Configuration; import android.graphics.drawable.Animatable; @@ -294,9 +295,10 @@ public void onPlayerStateChanged(boolean playWhenReady, int playbackState) { @Override protected void onPause() { super.onPause(); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O - && player.getPlayWhenReady()) { - enterPictureInPictureMode(); + if (player.getPlayWhenReady() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + PictureInPictureParams params = new PictureInPictureParams.Builder() + .build(); + enterPictureInPictureMode(params); } } @@ -313,12 +315,6 @@ public void onPictureInPictureModeChanged(boolean isInPictureInPictureMode) { } } - @Override - public void onBackPressed() { - super.onBackPressed(); - this.finish(); - } - @Override protected void onStop() { super.onStop(); @@ -331,6 +327,12 @@ protected void onStop() { } } + @Override + public void onBackPressed() { + super.onBackPressed(); + this.finish(); + } + @Override public int getDarkThemeRes() { return R.style.CameraRoll_Theme_VideoPlayer; diff --git a/app/src/main/java/us/koller/cameraroll/util/MediaType.java b/app/src/main/java/us/koller/cameraroll/util/MediaType.java index c70fa621..7184e3b4 100644 --- a/app/src/main/java/us/koller/cameraroll/util/MediaType.java +++ b/app/src/main/java/us/koller/cameraroll/util/MediaType.java @@ -116,7 +116,10 @@ private static boolean checkExtension(String path, String[] extensions) { } public static boolean suitableAsWallpaper(Context context, Uri uri) { - String mimeType = getMimeType(context, uri); - return mimeType != null && checkExtension(mimeType, wallpaperMimeTypes); + if (uri != null) { + String mimeType = getMimeType(context, uri); + return mimeType != null && checkExtension(mimeType, wallpaperMimeTypes); + } + return false; } } diff --git a/app/src/main/res/values-pl/strings_translatable.xml b/app/src/main/res/values-pl/strings_translatable.xml index 18539b33..cb83435b 100644 --- a/app/src/main/res/values-pl/strings_translatable.xml +++ b/app/src/main/res/values-pl/strings_translatable.xml @@ -55,8 +55,8 @@ Edytuj %1$s Nie znaleziono aplikacji, aby edytować %1$s Usuń - Usuń %1$s - Usuń %1$d pliki/ów + Usunąć %1$s + Usunąć %1$d pliki/ów Przenieś Przenieś %1$d element do: Przenieś %1$d elementy/ów do: @@ -71,13 +71,16 @@ pomyślnie utworzono nowy folder pomyślnie zmieniono nazwę pliku - BRAK PLIKÓW + brak plików Pamięć + Skanuj + Skanowanie… Kopiuj %1$d plik Kopiuj %1$d pliki/ów Przenieś %1$d plik Przenieś %1$d pliki/ów Usuń %1$d plik + Nie możesz wkleić plików tutaj! Wygląd Motyw @@ -104,6 +107,17 @@ Zmiany zapisano Wykluczone ścieżki + + Wirtualne albumy + Utwórz wirtualny album + Utworzono wirtualny album %1$s + Wybierz inną nazwę + Dodaj ścieżkę do wirtualnego albumu + Dodano ścieżkę do wirtualnego albumu %1$s + Usunięto wirtualny album %1$s + ścieżka usunięta + Brak zawartych ścieżek + Brak wirtualnych albumów Nazwa pliku: Ścieżka pliku: