修改BackupUtils.java中private void exportNoteToText方法复杂度过高(if嵌套过多)的问题

Signed-off-by: qianji <1535486312@qq.com>
a_branch
qianji 2 years ago
parent b24c51aeea
commit b2ccda6a2c

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AndroidTestResultsUserPreferences">
<option name="androidTestResultsTableState">
<map>
<entry key="28629151">
<value>
<AndroidTestResultsTableState>
<option name="preferredColumnWidths">
<map>
<entry key="Duration" value="90" />
<entry key="Tests" value="360" />
</map>
</option>
</AndroidTestResultsTableState>
</value>
</entry>
</map>
</option>
</component>
</project>

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="deploymentTargetDropDown">
<targetSelectedWithDropDown>
<Target>
<type value="QUICK_BOOT_TARGET" />
<deviceKey>
<Key>
<type value="VIRTUAL_DEVICE_PATH" />
<value value="C:\Users\Lenovo\.android\avd\Pixel_2_API_29.avd" />
</Key>
</deviceKey>
</Target>
</targetSelectedWithDropDown>
<timeTargetWasSelectedWithDropDown value="2023-05-02T16:19:10.809824900Z" />
</component>
</project>

@ -1,15 +1,14 @@
r java:S116w"VRename this field "TEXT_FORMAT" to match the regular expression '^[a-z][a-zA-Z0-9]*$'.(Ñ›–¼8±ü©µý0
p
java:S3776¨"RRefactor this method to reduce its Cognitive Complexity from 27 to the 15 allowed.(œÃÁí8´ü©µý0
r java:S116w"VRename this field "TEXT_FORMAT" to match the regular expression '^[a-z][a-zA-Z0-9]*$'.(Ñ›–¼8åäÐéý0
p java:S100¿"NRename this method name to match the regular expression '^[a-z][a-zA-Z0-9]*$'.(<28>é߯ûÿÿÿÿ8¢Ûßéý0
o
java:S3776Ý"RRefactor this method to reduce its Cognitive Complexity from 23 to the 15 allowed.(ì´ê8¸ü©µý0
java:S3776ß"RRefactor this method to reduce its Cognitive Complexity from 23 to the 15 allowed.(ì´ê8ëäÐéý0
b
java:S2147°"ECombine this catch with the one at line 301, which has the same body.(‰üú8¼ü©µý0
java:S2147²"ECombine this catch with the one at line 303, which has the same body.(‰üú8õäÐéý0
c
java:S2147Ñ"ECombine this catch with the one at line 335, which has the same body.(ï­£Ä8¾ü©µý0
d java:S899Ì"BDo something with the "boolean" value returned by "createNewFile".(ôÃáæüÿÿÿÿ8¿ü©µý0
java:S2147Ó"ECombine this catch with the one at line 337, which has the same body.(ï­£Ä8õäÐéý0
d java:S899Î"BDo something with the "boolean" value returned by "createNewFile".(ôÃáæüÿÿÿÿ8õäÐéý0
F
java:S3398»"#Move this method into "TextExport".(¨ä¿ÿýÿÿÿÿ8¿ü©µý0
java:S3398½"#Move this method into "TextExport".(¨ä¿ÿýÿÿÿÿ8õäÐéý0
@
java:S3398H"#Move this method into "TextExport".(…´<C2B4>8¿ü©µý0
java:S3398H"#Move this method into "TextExport".(…´<C2B4>8õäÐéý0

@ -155,17 +155,17 @@ p
@app/src/main/java/net/micode/notes/data/NotesDatabaseHelper.java,1\e\1eb2363b523dbcae43d3c6e4790c64436af61b13
j
:app/src/main/java/net/micode/notes/data/NotesProvider.java,6\a\6a65e747031f27aef20597b4181148a9fbf963d5
h
8app/src/main/java/net/micode/notes/tool/BackupUtils.java,a\4\a446c87b1013132f8adaf83656b582028e8809af
d
4app/src/main/java/net/micode/notes/data/Contact.java,9\a\9a3a19793537958b8b1b03a81985999e22705a2f
g
7app/src/main/java/net/micode/notes/ui/NoteEditText.java,5\0\503adcf2a0be1ecdb94a15efba4433b6589877b9
b
2app/src/main/java/net/micode/notes/model/Note.java,d\d\dd970bd8ce083850fca1d4d159647ccd110e57cb
b
2app/src/main/java/net/micode/notes/data/Notes.java,a\7\a7641cfac724321d508c2a284223a711011a93f5
k
;app/src/main/java/net/micode/notes/ui/NoteEditActivity.java,5\7\577f30d26378ec8a2bd2e4a43f3c79b3f04c402c
h
8app/src/main/java/net/micode/notes/tool/BackupUtils.java,a\4\a446c87b1013132f8adaf83656b582028e8809af
i
9app/src/main/java/net/micode/notes/model/WorkingNote.java,8\7\876016634c6642b35109680ccac740dc8271b236
k
;app/src/main/java/net/micode/notes/ui/NoteEditActivity.java,5\7\577f30d26378ec8a2bd2e4a43f3c79b3f04c402c
b
2app/src/main/java/net/micode/notes/model/Note.java,d\d\dd970bd8ce083850fca1d4d159647ccd110e57cb
g
7app/src/main/java/net/micode/notes/ui/NoteEditText.java,5\0\503adcf2a0be1ecdb94a15efba4433b6589877b9
d
4app/src/main/java/net/micode/notes/data/Contact.java,9\a\9a3a19793537958b8b1b03a81985999e22705a2f

@ -151,21 +151,21 @@ m
=app/src/main/java/net/micode/notes/ui/AlarmAlertActivity.java,3\e\3e688be40dc69cfd1062f41d0fc27fe261a26710
l
<app/src/main/java/net/micode/notes/ui/NotesListActivity.java,a\d\ad72331a1bed265bb9c0fe838faa74dbf69fce32
h
8app/src/main/java/net/micode/notes/tool/BackupUtils.java,a\4\a446c87b1013132f8adaf83656b582028e8809af
d
4app/src/main/java/net/micode/notes/data/Contact.java,9\a\9a3a19793537958b8b1b03a81985999e22705a2f
p
@app/src/main/java/net/micode/notes/data/NotesDatabaseHelper.java,1\e\1eb2363b523dbcae43d3c6e4790c64436af61b13
j
:app/src/main/java/net/micode/notes/data/NotesProvider.java,6\a\6a65e747031f27aef20597b4181148a9fbf963d5
d
4app/src/main/java/net/micode/notes/data/Contact.java,9\a\9a3a19793537958b8b1b03a81985999e22705a2f
b
2app/src/main/java/net/micode/notes/data/Notes.java,a\7\a7641cfac724321d508c2a284223a711011a93f5
k
;app/src/main/java/net/micode/notes/ui/NoteEditActivity.java,5\7\577f30d26378ec8a2bd2e4a43f3c79b3f04c402c
h
8app/src/main/java/net/micode/notes/tool/BackupUtils.java,a\4\a446c87b1013132f8adaf83656b582028e8809af
i
9app/src/main/java/net/micode/notes/model/WorkingNote.java,8\7\876016634c6642b35109680ccac740dc8271b236
g
7app/src/main/java/net/micode/notes/ui/NoteEditText.java,5\0\503adcf2a0be1ecdb94a15efba4433b6589877b9
b
2app/src/main/java/net/micode/notes/model/Note.java,d\d\dd970bd8ce083850fca1d4d159647ccd110e57cb
b
2app/src/main/java/net/micode/notes/data/Notes.java,a\7\a7641cfac724321d508c2a284223a711011a93f5
k
;app/src/main/java/net/micode/notes/ui/NoteEditActivity.java,5\7\577f30d26378ec8a2bd2e4a43f3c79b3f04c402c
g
7app/src/main/java/net/micode/notes/ui/NoteEditText.java,5\0\503adcf2a0be1ecdb94a15efba4433b6589877b9

@ -1,4 +1,4 @@
#Mon May 01 23:21:50 CST 2023
#Wed May 03 00:31:58 CST 2023
base.0=E\:\\Notes-master1\\app\\build\\intermediates\\dex\\debug\\mergeDexDebug\\classes.dex
renamed.0=classes.dex
path.0=classes.dex

@ -174,33 +174,7 @@ public class BackupUtils {
if (dataCursor != null) {
if (dataCursor.moveToFirst()) {
do {
String mimeType = dataCursor.getString(DATA_COLUMN_MIME_TYPE);
if (DataConstants.CALL_NOTE.equals(mimeType)) {
// Print phone number
String phoneNumber = dataCursor.getString(DATA_COLUMN_PHONE_NUMBER);
long callDate = dataCursor.getLong(DATA_COLUMN_CALL_DATE);
String location = dataCursor.getString(DATA_COLUMN_CONTENT);
if (!TextUtils.isEmpty(phoneNumber)) {
ps.println(String.format(getFormat(FORMAT_NOTE_CONTENT),
phoneNumber));
}
// Print call date
ps.println(String.format(getFormat(FORMAT_NOTE_CONTENT), DateFormat
.format(mContext.getString(R.string.format_datetime_mdhm),
callDate)));
// Print call attachment location
if (!TextUtils.isEmpty(location)) {
ps.println(String.format(getFormat(FORMAT_NOTE_CONTENT),
location));
}
} else if (DataConstants.NOTE.equals(mimeType)) {
String content = dataCursor.getString(DATA_COLUMN_CONTENT);
if (!TextUtils.isEmpty(content)) {
ps.println(String.format(getFormat(FORMAT_NOTE_CONTENT),
content));
}
}
Print_imformation(dataCursor,ps);
} while (dataCursor.moveToNext());
}
dataCursor.close();
@ -214,7 +188,35 @@ public class BackupUtils {
Log.e(TAG, e.toString());
}
}
private void Print_imformation(Cursor dataCursor,PrintStream ps) {
String mimeType = dataCursor.getString(DATA_COLUMN_MIME_TYPE);
if (DataConstants.CALL_NOTE.equals(mimeType)) {
// Print phone number
String phoneNumber = dataCursor.getString(DATA_COLUMN_PHONE_NUMBER);
long callDate = dataCursor.getLong(DATA_COLUMN_CALL_DATE);
String location = dataCursor.getString(DATA_COLUMN_CONTENT);
if (!TextUtils.isEmpty(phoneNumber)) {
ps.println(String.format(getFormat(FORMAT_NOTE_CONTENT),
phoneNumber));
}
// Print call date
ps.println(String.format(getFormat(FORMAT_NOTE_CONTENT), DateFormat
.format(mContext.getString(R.string.format_datetime_mdhm),
callDate)));
// Print call attachment location
if (!TextUtils.isEmpty(location)) {
ps.println(String.format(getFormat(FORMAT_NOTE_CONTENT),
location));
}
} else if (DataConstants.NOTE.equals(mimeType)) {
String content = dataCursor.getString(DATA_COLUMN_CONTENT);
if (!TextUtils.isEmpty(content)) {
ps.println(String.format(getFormat(FORMAT_NOTE_CONTENT),
content));
}
}
}
/**
* Note will be exported as text which is user readable
*/

Loading…
Cancel
Save