Skip to content
This repository has been archived by the owner on Sep 8, 2019. It is now read-only.

Commit

Permalink
- minor Bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kollerlukas committed Sep 20, 2017
1 parent 0cb9cf6 commit ea1ce63
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 29 deletions.
12 changes: 7 additions & 5 deletions app/src/main/java/us/koller/cameraroll/ui/AlbumActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions app/src/main/java/us/koller/cameraroll/ui/ItemActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down
16 changes: 8 additions & 8 deletions app/src/main/java/us/koller/cameraroll/ui/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ public void onMapSharedElements(List<String> names, Map<String, View> 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);
Expand All @@ -87,7 +89,6 @@ public void onMapSharedElements(List<String> names, Map<String, View> sharedElem
sharedElements.put(newTransitionName, newSharedElement);
}
sharedElementViewHolder.sharedElementReturnPosition = -1;

} else {
View v = sharedElementViewHolder.itemView.getRootView();
View navigationBar = v.findViewById(android.R.id.navigationBarBackground);
Expand Down Expand Up @@ -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(),
Expand Down
20 changes: 11 additions & 9 deletions app/src/main/java/us/koller/cameraroll/ui/VideoPlayerActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}

Expand All @@ -313,12 +315,6 @@ public void onPictureInPictureModeChanged(boolean isInPictureInPictureMode) {
}
}

@Override
public void onBackPressed() {
super.onBackPressed();
this.finish();
}

@Override
protected void onStop() {
super.onStop();
Expand All @@ -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;
Expand Down
7 changes: 5 additions & 2 deletions app/src/main/java/us/koller/cameraroll/util/MediaType.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
20 changes: 17 additions & 3 deletions app/src/main/res/values-pl/strings_translatable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@
<string name="edit_item">Edytuj %1$s</string>
<string name="edit_error">Nie znaleziono aplikacji, aby edytować %1$s</string>
<string name="delete">Usuń</string>
<string name="delete_item">Usuń %1$s</string>
<string name="delete_files">Usuń %1$d pliki/ów</string>
<string name="delete_item">Usunąć %1$s</string>
<string name="delete_files">Usunąć %1$d pliki/ów</string>
<string name="move">Przenieś</string>
<string name="move_item_to">Przenieś %1$d element do:</string>
<string name="move_items_to">Przenieś %1$d elementy/ów do:</string>
Expand All @@ -71,13 +71,16 @@
<string name="successfully_created_new_folder">pomyślnie utworzono nowy folder</string>
<string name="successfully_renamed_file">pomyślnie zmieniono nazwę pliku</string>
<!--FileExplorerActivity-->
<string name="no_files">BRAK PLIKÓW</string>
<string name="no_files">brak plików</string>
<string name="storage">Pamięć</string>
<string name="scan">Skanuj</string>
<string name="scanning">Skanowanie…</string>
<string name="copy_file">Kopiuj %1$d plik</string>
<string name="copy_files">Kopiuj %1$d pliki/ów</string>
<string name="move_file">Przenieś %1$d plik</string>
<string name="move_files">Przenieś %1$d pliki/ów</string>
<string name="delete_file">Usuń %1$d plik</string>
<string name="paste_error">Nie możesz wkleić plików tutaj!</string>
<!--SettingsActivity-->
<string name="appearance">Wygląd</string>
<string name="theme">Motyw</string>
Expand All @@ -104,6 +107,17 @@
<string name="changes_saved">Zmiany zapisano</string>
<!--ExcludedPathsActivity-->
<string name="excluded_paths">Wykluczone ścieżki</string>
<!--VirtualAlbumsActivity-->
<string name="virtual_albums">Wirtualne albumy</string>
<string name="create_virtual_album">Utwórz wirtualny album</string>
<string name="virtual_album_created">Utworzono wirtualny album %1$s</string>
<string name="virtual_album_different_name">Wybierz inną nazwę</string>
<string name="add_path_to_virtual_album">Dodaj ścieżkę do wirtualnego albumu</string>
<string name="added_path_to_virtual_album">Dodano ścieżkę do wirtualnego albumu %1$s</string>
<string name="virtual_album_deleted">Usunięto wirtualny album %1$s</string>
<string name="path_removed">ścieżka usunięta</string>
<string name="no_paths">Brak zawartych ścieżek</string>
<string name="no_virtual_albums">Brak wirtualnych albumów</string>
<!--info Dialog Strings-->
<string name="info_filename">Nazwa pliku: </string>
<string name="info_filepath">Ścieżka pliku: </string>
Expand Down

0 comments on commit ea1ce63

Please sign in to comment.