-
Notifications
You must be signed in to change notification settings - Fork 279
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #499 from Logan676/feature/support_built-in_activi…
…ties Support build-in ActivitiesFragment
- Loading branch information
Showing
46 changed files
with
1,963 additions
and
293 deletions.
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
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
108 changes: 108 additions & 0 deletions
108
app/src/main/java/com/seafile/seadroid2/data/CommitDetails.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,108 @@ | ||
package com.seafile.seadroid2.data; | ||
|
||
import com.google.common.collect.Lists; | ||
import com.seafile.seadroid2.util.Utils; | ||
|
||
import org.json.JSONArray; | ||
import org.json.JSONException; | ||
import org.json.JSONObject; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Commit details for activities history changes | ||
*/ | ||
public class CommitDetails { | ||
public List<String> addedFiles; | ||
public List<String> deletedFiles; | ||
public List<String> modifiedFiles; | ||
public List<String> renamedFiles; | ||
public List<String> addedDirs; | ||
public List<String> deletedDirs; | ||
|
||
public CommitDetails() { | ||
addedFiles = Lists.newArrayList(); | ||
deletedFiles = Lists.newArrayList(); | ||
modifiedFiles = Lists.newArrayList(); | ||
renamedFiles = Lists.newArrayList(); | ||
addedDirs = Lists.newArrayList(); | ||
deletedDirs = Lists.newArrayList(); | ||
} | ||
|
||
public static CommitDetails fromJson(String json) throws JSONException { | ||
final JSONObject jsonObject = Utils.parseJsonObject(json); | ||
final JSONArray addedFiles = jsonObject.optJSONArray("added_files"); | ||
final JSONArray deletedFiles = jsonObject.optJSONArray("deleted_files"); | ||
final JSONArray modifiedFiles = jsonObject.optJSONArray("modified_files"); | ||
final JSONArray renamedFiles = jsonObject.optJSONArray("renamed_files"); | ||
final JSONArray addedDirs = jsonObject.optJSONArray("added_dirs"); | ||
final JSONArray deletedDirs = jsonObject.optJSONArray("deleted_dirs"); | ||
|
||
CommitDetails details = new CommitDetails(); | ||
processFileList(details.addedFiles, addedFiles); | ||
processFileList(details.deletedFiles, deletedFiles); | ||
processFileList(details.modifiedFiles, modifiedFiles); | ||
processFileList(details.renamedFiles, renamedFiles); | ||
processFileList(details.addedDirs, addedDirs); | ||
processFileList(details.deletedDirs, deletedDirs); | ||
|
||
return details; | ||
} | ||
|
||
private static void processFileList(List<String> list, JSONArray jsonArray) throws JSONException { | ||
if (jsonArray == null) return; | ||
|
||
for (int i = 0; i < jsonArray.length(); i++) { | ||
list.add(jsonArray.getString(i)); | ||
} | ||
} | ||
|
||
public List<String> getDeletedDirs() { | ||
return deletedDirs; | ||
} | ||
|
||
public void setDeletedDirs(List<String> deletedDirs) { | ||
this.deletedDirs = deletedDirs; | ||
} | ||
|
||
public List<String> getRenamedFiles() { | ||
return renamedFiles; | ||
} | ||
|
||
public void setRenamedFiles(List<String> renamedFiles) { | ||
this.renamedFiles = renamedFiles; | ||
} | ||
|
||
public List<String> getModifiedFiles() { | ||
return modifiedFiles; | ||
} | ||
|
||
public void setModifiedFiles(List<String> modifiedFiles) { | ||
this.modifiedFiles = modifiedFiles; | ||
} | ||
|
||
public List<String> getAddedFiles() { | ||
return addedFiles; | ||
} | ||
|
||
public void setAddedFiles(List<String> addedFiles) { | ||
this.addedFiles = addedFiles; | ||
} | ||
|
||
public List<String> getDeletedFiles() { | ||
return deletedFiles; | ||
} | ||
|
||
public void setDeletedFiles(List<String> deletedFiles) { | ||
this.deletedFiles = deletedFiles; | ||
} | ||
|
||
public List<String> getAddedDirs() { | ||
return addedDirs; | ||
} | ||
|
||
public void setAddedDirs(List<String> addedDirs) { | ||
this.addedDirs = addedDirs; | ||
} | ||
|
||
} |
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
55 changes: 55 additions & 0 deletions
55
app/src/main/java/com/seafile/seadroid2/data/EventDetailsFileItem.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,55 @@ | ||
package com.seafile.seadroid2.data; | ||
|
||
public class EventDetailsFileItem { | ||
|
||
public enum EType { | ||
FILE_ADDED, | ||
FILE_DELETED, | ||
FILE_MODIFIED, | ||
FILE_RENAMED, | ||
DIR_ADDED, | ||
DIR_DELETED | ||
} | ||
|
||
private String path; | ||
private EType eType; | ||
private SeafEvent event; | ||
|
||
public EventDetailsFileItem(SeafEvent event, String path, EType etype) { | ||
this.path = path; | ||
this.eType = etype; | ||
this.event = event; | ||
} | ||
|
||
public String getPath() { | ||
return path; | ||
} | ||
|
||
public void setPath(String path) { | ||
this.path = path; | ||
} | ||
|
||
public EType geteType() { | ||
return eType; | ||
} | ||
|
||
public SeafEvent getEvent() { | ||
return event; | ||
} | ||
|
||
public void setEvent(SeafEvent event) { | ||
this.event = event; | ||
} | ||
|
||
public boolean isFileOpenable() { | ||
return eType == EType.FILE_ADDED || | ||
eType == EType.FILE_MODIFIED || | ||
eType == EType.FILE_RENAMED || | ||
eType == EType.DIR_ADDED; | ||
} | ||
|
||
public boolean isDir() { | ||
return eType == EType.DIR_ADDED; | ||
} | ||
|
||
} |
52 changes: 52 additions & 0 deletions
52
app/src/main/java/com/seafile/seadroid2/data/EventDetailsTree.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,52 @@ | ||
package com.seafile.seadroid2.data; | ||
|
||
import com.google.common.collect.Lists; | ||
import com.seafile.seadroid2.data.EventDetailsFileItem.EType; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Event details tree of each commit | ||
*/ | ||
public class EventDetailsTree { | ||
private List<EventDetailsFileItem> items; | ||
private SeafEvent event; | ||
|
||
public EventDetailsTree(SeafEvent event) { | ||
this.items = Lists.newArrayList(); | ||
this.event = event; | ||
} | ||
|
||
public List<EventDetailsFileItem> setCommitDetails(CommitDetails details) { | ||
|
||
items.clear(); | ||
|
||
processEventCategory(details.addedFiles, "Added files", EType.FILE_ADDED); | ||
processEventCategory(details.deletedFiles, "Deleted files", EType.FILE_DELETED); | ||
processEventCategory(details.modifiedFiles, "Modified files", EType.FILE_MODIFIED); | ||
|
||
processEventCategory(details.addedDirs, "Added folders", EType.DIR_ADDED); | ||
processEventCategory(details.deletedDirs, "Deleted folders", EType.DIR_DELETED); | ||
|
||
// renamed files is a list of (before rename, after rename) pair | ||
List<String> renamedFiles = Lists.newArrayList(); | ||
for (int i = 1, n = details.renamedFiles.size(); i < n; i += 2) { | ||
final String rename = details.renamedFiles.get(i); | ||
renamedFiles.add(rename); | ||
} | ||
processEventCategory(renamedFiles, "Renamed files", EType.FILE_RENAMED); | ||
|
||
return items; | ||
} | ||
|
||
private void processEventCategory(List<String> files, String desc, EType etype) { | ||
if (files == null || files.isEmpty()) { | ||
return; | ||
} | ||
|
||
for (int i = 0, n = files.size(); i < n; i++) { | ||
EventDetailsFileItem item = new EventDetailsFileItem(event, files.get(i), etype); | ||
items.add(item); | ||
} | ||
} | ||
} |
Oops, something went wrong.