-
-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Version 2.0.0 #39
Open
cketti
wants to merge
37
commits into
dev
Choose a base branch
from
version_2
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Version 2.0.0 #39
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
94f4412
Rename library module to ckChangeLog-core
cketti 1c3e60e
Extract dialog code to separate module
cketti 8f6183d
Make ReleaseItem a top-level class
cketti 2af8329
Clean up the code a bit
cketti 507d9d2
Remove white spaces and line breaks from changes text.
johnjohndoe 0169c57
Re-use newInstance constuctor.
johnjohndoe 6cd83f6
Extract method to clean text of change item
cketti 111ee98
Merge pull request #37 into version_2
cketti f97ba78
Merge pull request #38 from johnjohndoe/new-instance
cketti cd8d027
Update build tools etc.
cketti 0f42533
Extract core functionality into multiple classes
cketti 33da70d
Add tests
cketti 5ff4e47
Make API to get change log nicer
cketti faab3ed
Make XmlParser more strict
cketti 726a00a
Extract library version to variable
cketti 26d7801
Move POM metadata to root project's build.gradle
cketti 14e3cfa
Dynamically write string resource with library version
cketti 82a42ba
Update copyright notices
cketti 2637881
Move change log from README to separate file
cketti 94eb31c
Extract code to generate the change log HTML to separate class
cketti 3b4f673
Expose the used ChangeLog instance to users of DialogChangeLog
cketti 5cae803
Clean up and add more JavaDoc
cketti ee69936
Update Change Log with migration instructions
cketti 1752fac
Update README
cketti e6d9ee8
Add Maven Central snapshot repository
cketti 5e61cbd
Make XmlParser return an unmodifiable list
cketti 30dcb54
Update build tools
cketti 0b40bcf
Update test dependencies
cketti 2af0af4
Change package name to de.cketti.changelog
cketti 445a0ae
Update dependencies
cketti 36c48f8
Clean up code to remove some warnings
cketti c0db1c4
Move change log files from res/xml/ to res/raw/
cketti 89238f7
Add "date" attribute
cketti ce3de32
Rename ckChangeLog-dialog to ckChangeLog-legacy-dialog
cketti 7c9f838
Make writeCurrentVersion() update internal state
cketti c4ff306
Update copyright headers
cketti d483d5d
Update README and CHANGELOG
cketti File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
ckChangeLog-core/src/main/java/de/cketti/library/changelog/ChangeLogProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright (C) 2012-2016 cketti and contributors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package de.cketti.library.changelog; | ||
|
||
|
||
import java.util.List; | ||
|
||
|
||
public interface ChangeLogProvider { | ||
List<ReleaseItem> getChangeLog(); | ||
List<ReleaseItem> getChangeLogSince(int lastVersionCode); | ||
} |
90 changes: 90 additions & 0 deletions
90
ckChangeLog-core/src/main/java/de/cketti/library/changelog/MergedChangeLogProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/* | ||
* Copyright (C) 2012-2016 cketti and contributors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package de.cketti.library.changelog; | ||
|
||
|
||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.Comparator; | ||
import java.util.List; | ||
|
||
import android.util.SparseArray; | ||
|
||
import static de.cketti.library.changelog.Preconditions.checkNotNull; | ||
|
||
|
||
public final class MergedChangeLogProvider implements ChangeLogProvider { | ||
private final ChangeLogProvider masterChangeLogProvider; | ||
private final ChangeLogProvider localizedChangeLogProvider; | ||
|
||
|
||
public MergedChangeLogProvider(ChangeLogProvider masterChangeLogProvider, | ||
ChangeLogProvider localizedChangeLogProvider) { | ||
this.masterChangeLogProvider = checkNotNull(masterChangeLogProvider, "masterChangeLogProvider == null"); | ||
this.localizedChangeLogProvider = checkNotNull(localizedChangeLogProvider, | ||
"localizedChangeLogProvider == null"); | ||
} | ||
|
||
@Override | ||
public List<ReleaseItem> getChangeLog() { | ||
List<ReleaseItem> masterChangeLog = masterChangeLogProvider.getChangeLog(); | ||
List<ReleaseItem> localizedChangeLog = localizedChangeLogProvider.getChangeLog(); | ||
return merge(masterChangeLog, localizedChangeLog); | ||
} | ||
|
||
@Override | ||
public List<ReleaseItem> getChangeLogSince(int lastVersionCode) { | ||
List<ReleaseItem> masterChangeLog = masterChangeLogProvider.getChangeLogSince(lastVersionCode); | ||
List<ReleaseItem> localizedChangeLog = localizedChangeLogProvider.getChangeLogSince(lastVersionCode); | ||
return merge(masterChangeLog, localizedChangeLog); | ||
} | ||
|
||
private List<ReleaseItem> merge(List<ReleaseItem> masterChangeLog, List<ReleaseItem> localizedChangeLog) { | ||
SparseArray<ReleaseItem> localizedChangeLogMap = new SparseArray<>(); | ||
for (ReleaseItem releaseItem : localizedChangeLog) { | ||
localizedChangeLogMap.put(releaseItem.versionCode, releaseItem); | ||
} | ||
|
||
List<ReleaseItem> mergedChangeLog = new ArrayList<>(masterChangeLog.size()); | ||
for (int i = 0, len = masterChangeLog.size(); i < len; i++) { | ||
ReleaseItem masterReleaseItem = masterChangeLog.get(i); | ||
int key = masterReleaseItem.versionCode; | ||
|
||
// Use release information from localized change log and fall back to the master file if necessary. | ||
ReleaseItem release = localizedChangeLogMap.get(key, masterReleaseItem); | ||
|
||
mergedChangeLog.add(release); | ||
} | ||
|
||
Collections.sort(mergedChangeLog, new VersionCodeComparator()); | ||
|
||
return mergedChangeLog; | ||
} | ||
|
||
|
||
class VersionCodeComparator implements Comparator<ReleaseItem> { | ||
@Override | ||
public int compare(ReleaseItem lhs, ReleaseItem rhs) { | ||
if (lhs.versionCode < rhs.versionCode) { | ||
return 1; | ||
} else if (lhs.versionCode > rhs.versionCode) { | ||
return -1; | ||
} else { | ||
return 0; | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a technical reason for raising the
minSdkVersion
forckChangeLog-core
andckChangeLog-dialog
here? I changed it back to4
and compiled locally and could run my app without an issue.