From 908c30381f3a2b92dd368b519b74d3f3f2e01967 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Robaczy=C5=84ski?= Date: Thu, 29 Nov 2018 13:56:15 +0100 Subject: [PATCH] Release/5.3.0 (#198) * Version update * New changelog * Readme update + docs in Theme * Added theming to camera/local files fragments * Readme update --- CHANGELOG.md | 10 ++++++++ README.md | 15 ++++++++---- filestack/build.gradle | 2 +- .../com/filestack/android/FsActivity.java | 4 ++-- .../java/com/filestack/android/Theme.java | 21 ++++++++++++++++ .../android/internal/CameraFragment.java | 24 +++++++++++++++++-- .../android/internal/LocalFilesFragment.java | 17 +++++++++++-- 7 files changed, 82 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 27c2c2d1..1547d658 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ Change Log ========== +Version 5.3.0 *(2018-11-29)* +---------------------------- + + * [Feature] New way to open up the Filestack Picker! Use `FilestackPicker.Builder` class to customize your picker easily. + * [Feature] A way to set Picker's theme is now available. Use `Theme.Builder` class to set your own color scheme to a picker. + * [Feature] Picker's version is now available in the picker's menu. This feature can be disabled using `FilestackPicker.Builder`. + * [UI change] Files descriptions are now formatted in a better way (e.g: 15360 is now properly displayed as 15kB). + * [UI fix] Menu options are now properly hidden in places that doesn't require them. + * Tester module supports all of the new features introduced. Head to Settings to see new configuration options. + Version 5.2.0 *(2018-10-15)* ---------------------------- diff --git a/README.md b/README.md index 160fe959..f7d2e89f 100644 --- a/README.md +++ b/README.md @@ -3,13 +3,13 @@

- + - - + +

@@ -21,7 +21,7 @@ ## Install ```gradle -implementation 'com.filestack:filestack-android:5.1.0' +implementation 'com.filestack:filestack-android:5.3.0' ``` ## Tester and Samples @@ -202,6 +202,13 @@ if (savedInstanceState == null) { } ``` +## Theming +Filestack Android SDK provides a theming mechanism for Filestack Picker screen. + +Setting a theme requires passing a `Theme` to `Filestack.Builder#theme(Theme)` method call. +`Theme` objects can be constructed with a `Theme.Builder` instance. +If theme is not set, a default one will be used. + ## Native UI At present this SDK doesn't offer many customization options, but the [Java SDK][java-sdk] can be used to build a native UI. This SDK adds UI and diff --git a/filestack/build.gradle b/filestack/build.gradle index 831175bb..09b419d4 100644 --- a/filestack/build.gradle +++ b/filestack/build.gradle @@ -7,7 +7,7 @@ apply plugin: 'com.android.library' apply plugin: 'kotlin-android' group = 'com.filestack' -version = '5.2.0' +version = '5.3.0' project.archivesBaseName = 'filestack-android' android { diff --git a/filestack/src/main/java/com/filestack/android/FsActivity.java b/filestack/src/main/java/com/filestack/android/FsActivity.java index 269126aa..206adf66 100644 --- a/filestack/src/main/java/com/filestack/android/FsActivity.java +++ b/filestack/src/main/java/com/filestack/android/FsActivity.java @@ -311,10 +311,10 @@ public boolean onNavigationItemSelected(@NonNull MenuItem item) { switch (source) { case Sources.CAMERA: - fragment = new CameraFragment(); + fragment = CameraFragment.newInstance(theme); break; case Sources.DEVICE: - fragment = LocalFilesFragment.newInstance(allowMultipleFiles); + fragment = LocalFilesFragment.newInstance(allowMultipleFiles, theme); break; } diff --git a/filestack/src/main/java/com/filestack/android/Theme.java b/filestack/src/main/java/com/filestack/android/Theme.java index bc8dfcbb..5b65d366 100644 --- a/filestack/src/main/java/com/filestack/android/Theme.java +++ b/filestack/src/main/java/com/filestack/android/Theme.java @@ -47,26 +47,47 @@ public static class Builder { int accentColor = Color.parseColor("#FF9800"); int textColor = Color.parseColor("#89000000"); + /** + * Title of the Picker. + */ public Builder title(String title) { this.title = title; return this; } + /** + * Background color. Displayed in lists and a navigation drawer. + * Used also as a text color for toolbar title and + * buttons on authorization/local/camera screens. + * @param backgroundColor int representation of a color + */ public Builder backgroundColor(@ColorInt int backgroundColor) { this.backgroundColor = backgroundColor; return this; } + /** + * Accent color. Used as a color for toolbar, selection markers and navigation drawer items. + * @param accentColor int representation of a color + */ public Builder accentColor(@ColorInt int accentColor) { this.accentColor = accentColor; return this; } + /** + * Text color. Used as a color for text in camera/local/authorization/file list screens. + * @param textColor int representation of a color + */ public Builder textColor(@ColorInt int textColor) { this.textColor = textColor; return this; } + /** + * Builds a new theme based on provided parameters. + * @return new {@link Theme} instance + */ public Theme build() { return new Theme(this); } diff --git a/filestack/src/main/java/com/filestack/android/internal/CameraFragment.java b/filestack/src/main/java/com/filestack/android/internal/CameraFragment.java index f8613f93..dc65f96f 100644 --- a/filestack/src/main/java/com/filestack/android/internal/CameraFragment.java +++ b/filestack/src/main/java/com/filestack/android/internal/CameraFragment.java @@ -3,22 +3,27 @@ import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; +import android.content.res.ColorStateList; import android.net.Uri; import android.os.Bundle; import android.provider.MediaStore; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; +import android.support.v4.view.ViewCompat; +import android.support.v4.widget.ImageViewCompat; import android.view.LayoutInflater; import android.view.Menu; import android.view.View; import android.view.ViewGroup; import android.widget.Button; +import android.widget.ImageView; import com.filestack.Sources; import com.filestack.android.FsConstants; import com.filestack.android.R; import com.filestack.android.Selection; +import com.filestack.android.Theme; import java.io.File; import java.io.IOException; @@ -32,10 +37,21 @@ */ public class CameraFragment extends Fragment implements BackButtonListener, View.OnClickListener { + public static CameraFragment newInstance(Theme theme) { + Bundle args = new Bundle(); + args.putParcelable(ARG_THEME, theme); + CameraFragment fragment = new CameraFragment(); + fragment.setArguments(args); + return fragment; + } + private static final String TYPE_PHOTO = "photo"; private static final String TYPE_VIDEO = "video"; private static final String PREF_PATH = "path"; private static final String PREF_NAME= "name"; + private static final String ARG_THEME = "theme"; + + private Theme theme; @Nullable @Override @@ -58,10 +74,14 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c videoButton.setVisibility(View.GONE); } } - + theme = getArguments().getParcelable(ARG_THEME); + photoButton.setTextColor(theme.getBackgroundColor()); + ViewCompat.setBackgroundTintList(photoButton, ColorStateList.valueOf(theme.getAccentColor())); + ViewCompat.setBackgroundTintList(videoButton, ColorStateList.valueOf(theme.getAccentColor())); + videoButton.setTextColor(theme.getBackgroundColor()); photoButton.setOnClickListener(this); videoButton.setOnClickListener(this); - + ImageViewCompat.setImageTintList((ImageView) root.findViewById(R.id.icon), ColorStateList.valueOf(theme.getTextColor())); return root; } diff --git a/filestack/src/main/java/com/filestack/android/internal/LocalFilesFragment.java b/filestack/src/main/java/com/filestack/android/internal/LocalFilesFragment.java index deae32d6..48585b18 100644 --- a/filestack/src/main/java/com/filestack/android/internal/LocalFilesFragment.java +++ b/filestack/src/main/java/com/filestack/android/internal/LocalFilesFragment.java @@ -4,20 +4,26 @@ import android.content.ClipData; import android.content.ContentResolver; import android.content.Intent; +import android.content.res.ColorStateList; import android.database.Cursor; import android.net.Uri; import android.os.Bundle; import android.provider.OpenableColumns; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; +import android.support.v4.view.ViewCompat; +import android.support.v4.widget.ImageViewCompat; import android.view.LayoutInflater; import android.view.Menu; import android.view.View; import android.view.ViewGroup; +import android.widget.Button; +import android.widget.ImageView; import com.filestack.android.FsConstants; import com.filestack.android.R; import com.filestack.android.Selection; +import com.filestack.android.Theme; import java.util.ArrayList; @@ -32,11 +38,13 @@ public class LocalFilesFragment extends Fragment implements View.OnClickListener { private static final String ARG_ALLOW_MULTIPLE_FILES = "multipleFiles"; private static final int READ_REQUEST_CODE = RESULT_FIRST_USER; + private static final String ARG_THEME = "theme"; - public static Fragment newInstance(boolean allowMultipleFiles) { + public static Fragment newInstance(boolean allowMultipleFiles, Theme theme) { Fragment fragment = new LocalFilesFragment(); Bundle args = new Bundle(); args.putBoolean(ARG_ALLOW_MULTIPLE_FILES, allowMultipleFiles); + args.putParcelable(ARG_THEME, theme); fragment.setArguments(args); return fragment; } @@ -45,7 +53,12 @@ public static Fragment newInstance(boolean allowMultipleFiles) { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle state) { View view = inflater.inflate(R.layout.filestack__fragment_local_files, container, false); - view.findViewById(R.id.select_gallery).setOnClickListener(this); + Button openGalleryButton = view.findViewById(R.id.select_gallery); + openGalleryButton.setOnClickListener(this); + Theme theme = getArguments().getParcelable(ARG_THEME); + ViewCompat.setBackgroundTintList(openGalleryButton, ColorStateList.valueOf(theme.getAccentColor())); + openGalleryButton.setTextColor(theme.getBackgroundColor()); + ImageViewCompat.setImageTintList((ImageView) view.findViewById(R.id.icon), ColorStateList.valueOf(theme.getTextColor())); return view; }