diff --git a/app/src/main/java/us/koller/cameraroll/data/Provider/Provider.java b/app/src/main/java/us/koller/cameraroll/data/Provider/Provider.java index d810d167..ed391df8 100644 --- a/app/src/main/java/us/koller/cameraroll/data/Provider/Provider.java +++ b/app/src/main/java/us/koller/cameraroll/data/Provider/Provider.java @@ -70,6 +70,9 @@ public static boolean isPathPermanentlyExcluded(String path) { } public static boolean searchDir(String path) { + if (path == null) { + return false; + } boolean search = true; for (int i = 0; i < Provider.permanentlyExcludedPaths.length; i++) { if (path.contains(Provider.permanentlyExcludedPaths[i])) { diff --git a/app/src/main/java/us/koller/cameraroll/data/Provider/Retriever/StorageRetriever.java b/app/src/main/java/us/koller/cameraroll/data/Provider/Retriever/StorageRetriever.java index c2aaed8b..eb8b0704 100644 --- a/app/src/main/java/us/koller/cameraroll/data/Provider/Retriever/StorageRetriever.java +++ b/app/src/main/java/us/koller/cameraroll/data/Provider/Retriever/StorageRetriever.java @@ -120,7 +120,8 @@ public static StorageRoot[] loadRoots(Activity context) { ArrayList temp = new ArrayList<>(); StorageRoot externalStorage - = new StorageRoot(Environment.getExternalStorageDirectory().getPath()); + = new StorageRoot(Environment + .getExternalStorageDirectory().getPath()); externalStorage.setName(context.getString(R.string.storage)); temp.add(externalStorage); @@ -145,14 +146,17 @@ public void loadDir(final Activity context, String dirPath, threads = new ArrayList<>(); - AdaptableThread.Callback adaptableThreadCallback = new AdaptableThread.Callback() { + AdaptableThread.Callback adaptableThreadCallback + = new AdaptableThread.Callback() { @Override public void done(AdaptableThread thread, ItemLoader.Result result, ArrayList filesToSearch) { File_POJO files = result.files; boolean filesContainMedia = false; for (int i = 0; i < files.getChildren().size(); i++) { - if (MediaType.isMedia(context, files.getChildren().get(i).getPath())) { + if (files.getChildren().get(i) != null && + MediaType.isMedia(context, + files.getChildren().get(i).getPath())) { filesContainMedia = true; break; } @@ -205,12 +209,15 @@ private static File[] getRemovableStorageRoots(Context context) { ArrayList rootsArrayList = new ArrayList<>(); for (int i = 0; i < roots.length; i++) { - String path = roots[i].getPath(); - int index = path.lastIndexOf("/Android/data/"); - if (index > 0) { - path = path.substring(0, index); - if (!path.equals(Environment.getExternalStorageDirectory().getPath())) { - rootsArrayList.add(new File(path)); + if (roots[i] != null) { + String path = roots[i].getPath(); + int index = path.lastIndexOf("/Android/data/"); + if (index > 0) { + path = path.substring(0, index); + if (!path.equals(Environment + .getExternalStorageDirectory().getPath())) { + rootsArrayList.add(new File(path)); + } } } } @@ -226,7 +233,8 @@ private static File[] getDirectoriesToSearch(Context context) { File[] dirs = dir.listFiles(new FileFilter() { @Override public boolean accept(File file) { - return Provider.searchDir(file.getPath()); + return file != null + && Provider.searchDir(file.getPath()); } }); @@ -235,7 +243,8 @@ public boolean accept(File file) { temp.addAll(Arrays.asList(dirs)); File[] removableStorageRoots = getRemovableStorageRoots(context); for (int i = 0; i < removableStorageRoots.length; i++) { - Log.d("StorageRetriever", "removableStorageRoot: " + removableStorageRoots[i].getPath()); + Log.d("StorageRetriever", "removableStorageRoot: " + + removableStorageRoots[i].getPath()); File root = removableStorageRoots[i]; File[] files = root.listFiles(); if (files != null) { diff --git a/app/src/main/java/us/koller/cameraroll/ui/AboutActivity.java b/app/src/main/java/us/koller/cameraroll/ui/AboutActivity.java index 239e9575..0a02b9b6 100644 --- a/app/src/main/java/us/koller/cameraroll/ui/AboutActivity.java +++ b/app/src/main/java/us/koller/cameraroll/ui/AboutActivity.java @@ -1,6 +1,9 @@ package us.koller.cameraroll.ui; +import android.app.ActivityManager; import android.content.pm.PackageManager; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; import android.graphics.PorterDuff; import android.os.Build; import android.os.Bundle; @@ -59,7 +62,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { ImageView headerImage = (ImageView) findViewById(R.id.header_image); Glide.with(this) - .load("http://koller.us/Lukas/camera_roll/logo_guidelines.png") + .load("http://koller.us/Lukas/camera_roll/new_logo.png") .into(headerImage); TextView version = (TextView) findViewById(R.id.version); @@ -137,10 +140,10 @@ public void onGlobalLayout() { toolbar.getPaddingEnd(), toolbar.getPaddingBottom()); - aboutText.setPadding(aboutText.getPaddingStart(), + /*aboutText.setPadding(aboutText.getPaddingStart(), aboutText.getPaddingTop(), aboutText.getPaddingEnd(), - aboutText.getPaddingBottom() + windowInsets[3]); + aboutText.getPaddingBottom() + windowInsets[3]);*/ View viewGroup = findViewById(R.id.swipeBackView); ViewGroup.MarginLayoutParams viewGroupParams @@ -162,6 +165,10 @@ public void onGlobalLayout() { } } + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + setupTaskDescription(); + } + setSystemUiFlags(); } @@ -173,6 +180,15 @@ private void setSystemUiFlags() { | View.SYSTEM_UI_FLAG_IMMERSIVE); } + @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) + private void setupTaskDescription() { + Bitmap overviewIcon = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher_round); + setTaskDescription(new ActivityManager.TaskDescription(getString(R.string.app_name), + overviewIcon, + ContextCompat.getColor(this, R.color.colorPrimary))); + overviewIcon.recycle(); + } + @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { 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 e6676723..98b04df5 100644 --- a/app/src/main/java/us/koller/cameraroll/ui/AlbumActivity.java +++ b/app/src/main/java/us/koller/cameraroll/ui/AlbumActivity.java @@ -880,10 +880,10 @@ public void onSaveInstanceState(Bundle outState) { @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) private void setupTaskDescription() { - Bitmap overviewIcon = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher); + Bitmap overviewIcon = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher_round); setTaskDescription(new ActivityManager.TaskDescription(getString(R.string.app_name), overviewIcon, - ContextCompat.getColor(this, R.color.colorAccent))); + ContextCompat.getColor(this, R.color.colorPrimary))); overviewIcon.recycle(); } diff --git a/app/src/main/java/us/koller/cameraroll/ui/FileExplorerActivity.java b/app/src/main/java/us/koller/cameraroll/ui/FileExplorerActivity.java index 307dd504..f98ea302 100644 --- a/app/src/main/java/us/koller/cameraroll/ui/FileExplorerActivity.java +++ b/app/src/main/java/us/koller/cameraroll/ui/FileExplorerActivity.java @@ -2,8 +2,11 @@ import android.animation.Animator; import android.animation.AnimatorListenerAdapter; +import android.app.ActivityManager; import android.content.DialogInterface; import android.content.Intent; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; import android.graphics.drawable.Animatable; import android.graphics.drawable.Drawable; import android.os.Build; @@ -244,6 +247,10 @@ public boolean onPreDraw() { | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + setupTaskDescription(); + } + //load files if (savedInstanceState != null && savedInstanceState.containsKey(CURRENT_DIR) @@ -359,6 +366,15 @@ public void run() { filesProvider.loadDir(this, path, callback); } + @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) + private void setupTaskDescription() { + Bitmap overviewIcon = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher_round); + setTaskDescription(new ActivityManager.TaskDescription(getString(R.string.app_name), + overviewIcon, + ContextCompat.getColor(this, R.color.colorPrimary))); + overviewIcon.recycle(); + } + @Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); 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 b8a4c1c7..b7695bb8 100644 --- a/app/src/main/java/us/koller/cameraroll/ui/ItemActivity.java +++ b/app/src/main/java/us/koller/cameraroll/ui/ItemActivity.java @@ -338,7 +338,8 @@ public void onGlobalLayout() { VideoViewHolder.onBottomInset(windowInsets); - rootView.getViewTreeObserver().removeOnGlobalLayoutListener(this); + rootView.getViewTreeObserver() + .removeOnGlobalLayoutListener(this); } }); } @@ -353,11 +354,10 @@ public void onGlobalLayout() { setupTaskDescription(); } - if (view_only || Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { + if (view_only + || Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP + || savedInstanceState != null) { albumItem.isSharedElement = false; - } - - if (view_only || savedInstanceState != null) { //config was changed //skipping sharedElement transition ((ViewPagerAdapter) viewPager.getAdapter()) @@ -374,6 +374,10 @@ public boolean onInstantiateItem(ViewHolder viewHolder) { } }); } + + /*if (view_only || savedInstanceState != null) { + + }*/ } @Override @@ -755,11 +759,11 @@ public void run() { @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) private void setupTaskDescription() { - Bitmap icon = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher); + Bitmap overviewIcon = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher_round); setTaskDescription(new ActivityManager.TaskDescription(getString(R.string.app_name), - icon, - ContextCompat.getColor(this, R.color.colorAccent))); - icon.recycle(); + overviewIcon, + ContextCompat.getColor(this, R.color.colorPrimary))); + overviewIcon.recycle(); } 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 67150ce7..3c30802d 100644 --- a/app/src/main/java/us/koller/cameraroll/ui/MainActivity.java +++ b/app/src/main/java/us/koller/cameraroll/ui/MainActivity.java @@ -16,6 +16,7 @@ import android.support.v4.graphics.drawable.DrawableCompat; import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; +import android.support.v7.widget.GridLayoutManager; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.support.v7.widget.Toolbar; @@ -369,10 +370,10 @@ public boolean onOptionsItemSelected(MenuItem item) { @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) private void setupTaskDescription() { - Bitmap overviewIcon = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher); + Bitmap overviewIcon = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher_round); setTaskDescription(new ActivityManager.TaskDescription(getString(R.string.app_name), overviewIcon, - ContextCompat.getColor(this, R.color.colorAccent))); + ContextCompat.getColor(this, R.color.colorPrimary))); overviewIcon.recycle(); } diff --git a/app/src/main/res/layout/album_cover.xml b/app/src/main/res/layout/album_cover.xml index 8f39da84..9457dbb0 100644 --- a/app/src/main/res/layout/album_cover.xml +++ b/app/src/main/res/layout/album_cover.xml @@ -24,6 +24,7 @@ android:layout_height="wrap_content" android:layout_weight="1" android:orientation="vertical" + android:layout_gravity="center_vertical" android:layout_margin="16dp">