Releases: Zhuinden/simple-stack
Simple Stack 1.11.0
Simple Stack 1.11.0 (2018-07-01)
- ADDED: Ability to share data across screens via scoped services.
To use, the key must implement ScopeKey
and define its scope's tag. If ScopeKey
is used, then a ScopedServices
must be provided.
Currently, a scope can be shared across keys, but there is no scope inheritance, and there is no way to have multiple scopes for a given key.
To use, one must set an implementation of ScopedServices
on either BackstackDelegate
, Navigator.Installer
, or BackstackManager
.
Services that are Bundleable
and registered in a given scope receive callbacks to toBundle()
and fromBundle()
to persist/restore their state.
Services registered in a given scope receive onEnterScope()
and onExitScope()
callbacks if they implement ScopedServices.Scoped
.
Tip: A possible way to simplify the usage of service tags
is to define an inline reified extension function for ServiceBinder
to default to using T::class.java.name
.
Simple Stack 1.9.3
Simple Stack 1.9.3 (2018-06-28)
-
ADDED: Ability to change duration, interpolation and start delay of
AnimatorViewChangeHandler
-
ADDED:
jumpToRoot(direction)
.
Simple Stack 1.9.2
Simple Stack 1.9.2 (2018-06-01)
- CHANGE:
DefaultStateChanger
appliesFADE
by default forStateChange.REPLACE
direction, instead of no-op.
Simple Stack 1.9.1
Simple-Stack 1.9.1 (2018-05-20)
-
Fix:
History.single()
should returnHistory<T>
, notList<T>
. -
ADDED:
jumpToRoot()
andmoveToTop()
convenience operators toBackstack
. -
ADDED:
goUp(Object, boolean fallbackToBack)
andgoUpChain(List<?>, boolean fallbackToBack)
to allow opt-in for the newly provided navigation principle: "Up and Back are equivalent within your app's task". To retain previous behavior without breaking changes, this is opt-in with a boolean flag. Default behavior does NOT fall back to back, but clears top to the parent instead.
Up and Back are equivalent within your app's task
When the system Back button would not exit your app, such as when you are on your own task and not on the start destination, the Up button should function identically to the system Back button.
Simple Stack 1.9.0
Simple Stack 1.9.0 (2018-03-04)
- DEPRECATED: HistoryBuilder's factory methods are moved from HistoryBuilder to the newly added
History
class.
HistoryBuilder.from(T... objects)
-> History.builderOf(T... objects)
HistoryBuilder.from(...)
-> History.builderFrom(...)
HistoryBuilder.single()
-> History.single()
HistoryBuilder.newBuilder()
-> History.newBuilder()
Also adds History.of(T... objects)
instead of HistoryBuilder.of(...).build()
.
- ADDED:
History
class, an immutable list with additional operations overList<T>
- as some methods' return type.
I also changed some return types (in history building) from List<Object>
to <T> List<T>
,
this resulted in having to change some List<Object>
s to List<?>
on the receiving side if used in assignment.
So if you run into that, just change List<Object>
to List<?>
and it should work.
-
ADDED: Long-overdue empty constructor for
BackstackDelegate
andbackstack.setStateChanger(StateChanger)
. -
UPDATE: Kotlin sample replaces
PaperParcel
with@Parcelize
.
Simple Stack 1.8.2
Simple Stack 1.8.2 (2018-01-20)
-
CRITICAL FIX:
1.8.1 (2018-01-17)
didn't retrievestate-bundle 1.2.0
as transitive dependency because ofcom.github.dcendents:android-maven-gradle-plugin:1.5
. It is updated to2.0
to fix publishing to Jitpack. -
ADDED / CHANGE:
Navigator.findActivity(Context)
is now public. It also casts the returned Activity to whatever subclass type is expected. -
ADDED:
Backstack.fromTop(int offset)
method, which provides the element in the backstack from the top with a given offset. -
UPDATE: Updated State-Bundle to 1.2.0.
-
INTERNAL: Updated to use implementation/api and AS 3.0's tooling.
-
INTERNAL: Updated implementation lib versions in samples and tests.
-
SAMPLE: Updated Kotlin example to use Fragment-based usage.
Simple Stack 1.8.0
Simple Stack 1.8.0 (2017-10-25)
- BREAKING(?) CHANGE / FIX: when
goBack()
returns false, then the backstack is not cleared automatically. Addedreset()
to allow imitating the previous behavior.
Previous behavior would now be the same as:
if(!backstack.goBack() && !backstack.isStateChangePending()) {
backstack.reset();
}
Honestly, this might have been unexpected, as goBack()
returning false
had the side-effect of clearing the stack, and next state change using the initial key!
The test that checks for this has been changed to use the above construct. Another test of course has been added to validate new behavior.
Also, to eliminate the possibility of reset()
misuse, it is only allowed when there are no pending state changes.
-
BREAKING CHANGE:
getInitialParameters()
is renamed togetInitialKeys()
. -
FIX:
getInitialParameters()
returned the actual list instead of an unmodifiable copy, it returns the keys provided at initialization. -
ADDED:
replaceTop()
backstack operator, which replaces current top with the provided key. -
ADDED:
goUp()
backstack operator, which will go back to the provided key if exists, replace top with new key otherwise. -
ADDED:
goUpChain()
backstack operator, which will:- If the chain of parents is found as previous elements, then it works as back navigation to that chain.
- If the whole chain is not found, but at least one element of it is found, then the history is kept up to that point, then the chain is added, any duplicate element in the chain is added to the end as part of the chain.
- If none of the chain is found, the current top is removed, and the provided parent chain is added.
I added a bunch of tests for this, hopefully I didn't forget anything!
-
ENHANCEMENT/FIX:
HistoryBuilder.get()
is now@NonNull
, becauseHistoryBuilder.from(List<?>)
throws if List containsnull
. -
ENHANCEMENT:
getHistory()
andgetInitialParameters()
also returns aList<T>
in which each element is cast toT
. -
FIX:
BackstackDelegate.setStateChanger()
should have been allowed even without callingbackstackDelegate.onCreate()
first. All the samples usenew BackstackDelegate(null)
so it never came up. -
ENHANCEMENT: Some improvement to
persistViewToState()
exception message if the view has no key (so that it referencesKeyContextWrapper
andstateChange.createContext()
).
Simple Stack 1.7.2
Simple Stack 1.7.2 (2017-07-24)
- MINOR CHANGE + ENHANCEMENT:
StateChange.getNewState()
and StateChange.getPreviousState()
return a copy of the list (it was already a copy, don't worry), where each item is casted to <T>
specified as generic parameter.
For example, the following can be changed from:
for(Object _newKey : stateChange.getNewState()) {
Key newKey = (Key)_newKey;
// ...
}
to:
for(Key newKey : stateChange.<Key>getNewState()) {
// ...
}
And the following works now as well:
List<Key> newKeys = stateChange.getNewState(); // used to return List<Object>
-
ADDED: MVVM sample.
-
ADDED: Shared Element Transition Fragments sample.
Simple Stack 1.7.1
Simple Stack 1.7.1 (2017-07-11)
- ADDED:
BackstackDelegate.registerForLifecycleCallbacks(Activity)
convenience method (API 14+).
This method allows you to call this after BackstackDelegate.onCreate()
, after which the following 4 methods no longer need to be called manually:
-
onPostResume()
-
onPause()
-
onSaveInstanceState(Bundle)
-
onDestroy()
Therefore the callbacks that ought to be called remain as onCreate()
, onRetainCustomNonConfigurationInstance()
, and of course onBackPressed()
.
Simple Stack 1.7.0
Simple-Stack 1.7.0 (2017-07-04)
- REMOVED:
BackstackManager.StateChangeCompletionListener
. It is replaced byBackstack.CompletionListener
, which was added back in 0.9.1 (and is more reliable).
This also fixes a possible bug with incorrect call order of state change completion listeners.
The API is otherwise exactly the same, StateChangeCompletionListener
should have been Backstack.CompletionListener
from the start.
- ADDED:
backstackDelegate.getManager()
, just to make sure its API mirrorsNavigator
.