Skip to content

Commit 6bad56b

Browse files
committed
修改txt基本完成
1 parent d02f85d commit 6bad56b

28 files changed

Lines changed: 1048 additions & 477 deletions

app/src/main/AndroidManifest.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@
5858
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
5959
<uses-permission android:name="android.permission.READ_LOGS" />
6060

61+
<android:uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
62+
6163
<application
6264
android:name=".MyApp"
6365
android:allowBackup="true"
@@ -661,6 +663,11 @@
661663
android:name=".project.detail.file.FileDynamicActivity_"
662664
android:label="@string/title_activity_file_dynamic"
663665
android:screenOrientation="portrait" />
666+
<activity
667+
android:name=".project.detail.file.TxtEditActivity_"
668+
android:label="@string/title_activity_txt_edit"
669+
android:screenOrientation="portrait"
670+
android:windowSoftInputMode="adjustResize|stateUnspecified"></activity>
664671
</application>
665672

666673
</manifest>

app/src/main/java/net/coding/program/model/AttachmentFileHistoryObject.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ public class AttachmentFileHistoryObject extends AttachmentFileObject {
1414
private int action;
1515
private int version;
1616
private String action_msg = "";
17-
private int history_id;
1817

1918
public AttachmentFileHistoryObject(JSONObject json) {
2019
super(json);
@@ -23,7 +22,6 @@ public AttachmentFileHistoryObject(JSONObject json) {
2322
action = json.optInt("action");
2423
version = json.optInt("version");
2524
action_msg = json.optString("action_msg");
26-
history_id = json.optInt("history_id");
2725
}
2826

2927
public String getVersionString() {
@@ -42,10 +40,6 @@ public int getVersion() {
4240
return version;
4341
}
4442

45-
public int getHistory_id() {
46-
return history_id;
47-
}
48-
4943
public String getActionMsg() {
5044
return action_msg + " " + Global.dayToNow(created_at, true);
5145
}

app/src/main/java/net/coding/program/model/AttachmentFileObject.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public class AttachmentFileObject implements Serializable {
2424
// .file-icon.txt{background-color:#b5bbc4}
2525
// .file-icon.rar,.file-icon.zip{background-color:#8e6dd2}
2626
// .file-icon.html,.file-icon.markd,.file-icon.markdown,.file-icon.md,.file-icon.mdown{background-color:#c5f0e9}
27-
public static final String SAVE_NAME_SPLIT = "_";
27+
private static final String SAVE_NAME_SPLIT = "|||";
2828
public static String imagePatternStr = "(gif|png|jpeg|jpg|GIF|PNG|JPEG|JPG)"; // /\.(gif|png|jpeg|jpg)$/
2929
static Pattern imagePattern = Pattern.compile(imagePatternStr);
3030
static String docPatternStr = "(doc|docx)";
@@ -94,7 +94,7 @@ public class AttachmentFileObject implements Serializable {
9494
public AttachmentFolderObject folderObject;
9595
private String name = "";
9696
private int size = 0;
97-
private int projectId = 0;
97+
private int history_id;
9898

9999
public AttachmentFileObject() {
100100
}
@@ -117,6 +117,8 @@ public AttachmentFileObject(JSONObject json) {
117117
storage_type = json.optString("storage_type");
118118
type = json.optInt("type");
119119
updated_at = json.optLong("updated_at");
120+
121+
history_id = json.optInt("history_id");
120122
}
121123

122124
public static AttachmentFileObject parseFileObject(AttachmentFolderObject folderObject) {
@@ -144,9 +146,13 @@ public static AttachmentFileObject parseFileObject(AttachmentFolderObject folder
144146
return returnFileObject;
145147
}
146148

149+
public int getHistory_id() {
150+
return history_id;
151+
}
152+
147153
// 保存在本地的名字
148-
public String getSaveName() {
149-
return file_id + SAVE_NAME_SPLIT + name;
154+
public String getSaveName(int projectId) {
155+
return projectId + SAVE_NAME_SPLIT + file_id + SAVE_NAME_SPLIT + history_id + SAVE_NAME_SPLIT + name;
150156
}
151157

152158
public String getName() {

app/src/main/java/net/coding/program/model/util/FileRequestHelp.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@
22

33
import com.loopj.android.http.RequestParams;
44

5+
import net.coding.program.common.FileUtil;
56
import net.coding.program.common.Global;
67
import net.coding.program.model.AttachmentFileHistoryObject;
8+
import net.coding.program.model.AttachmentFileObject;
79
import net.coding.program.model.PostRequest;
810

911
import org.json.JSONArray;
1012
import org.json.JSONObject;
1113

14+
import java.io.File;
1215
import java.util.ArrayList;
1316

1417
/**
@@ -29,18 +32,29 @@ public String getHttpRequest() {
2932
return String.format(Global.HOST_API + mProjectPath + "/files/%d/histories", mFileId);
3033
}
3134

32-
public ArrayList<AttachmentFileHistoryObject> parseJson(JSONObject json) {
35+
public ArrayList<AttachmentFileHistoryObject> parseJson(JSONObject json, String downloadPath, int projectId) {
3336
JSONArray jsonArray = json.optJSONArray("data");
3437

3538
ArrayList<AttachmentFileHistoryObject> list = new ArrayList<>();
3639
for (int i = 0; i < jsonArray.length(); ++i) {
3740
AttachmentFileHistoryObject item = new AttachmentFileHistoryObject(jsonArray.optJSONObject(i));
41+
setDownloadStatus(item, downloadPath, projectId);
3842
list.add(item);
3943
}
4044

4145
return list;
4246
}
4347

48+
private void setDownloadStatus(AttachmentFileObject mFileObject, String downloadPath, int projectId) {
49+
File mFile = FileUtil.getDestinationInExternalPublicDir(downloadPath, mFileObject.getSaveName(projectId));
50+
if (mFile.exists() && mFile.isFile()) {
51+
mFileObject.isDownload = true;
52+
} else {
53+
mFileObject.downloadId = 0L;
54+
mFileObject.isDownload = false;
55+
}
56+
}
57+
4458
public PostRequest getHttpHistoryRemark(int historyId, String input) {
4559
String url = String.format(Global.HOST_API + mProjectPath + "/files/%s/histories/%s/remark",
4660
mFileId, historyId);

0 commit comments

Comments
 (0)