Add a Toast when we fail to fetch the list of folders

This commit is contained in:
Philip Whitehouse 2017-04-05 01:04:23 +01:00
parent b461ce4092
commit c84fe2312b
4 changed files with 12 additions and 3 deletions

View file

@ -477,7 +477,7 @@ class ImapResponseParser {
private void checkTokenIsString(Object token) throws IOException { private void checkTokenIsString(Object token) throws IOException {
if (!(token instanceof String)) { if (!(token instanceof String)) {
throw new IOException("Unexpected non-string token: " + token); throw new IOException("Unexpected non-string token: " + token.getClass().getSimpleName() + " - " + token);
} }
} }
} }

View file

@ -384,6 +384,14 @@ public class ImapResponseParserTest {
assertEquals("[FolderName]", response.get(3)); assertEquals("[FolderName]", response.get(3));
} }
@Test(expected = IOException.class)
public void testListResponseContainingFolderNameContainingBracketsThrowsException() throws Exception {
ImapResponseParser parser = createParser(
"* LIST (\\NoInferiors) \"/\" Root/Folder/Subfolder()\r\n");
parser.readResponse();
}
@Test @Test
public void readResponseShouldReadWholeListResponseLine() throws Exception { public void readResponseShouldReadWholeListResponseLine() throws Exception {
ImapResponseParser parser = createParser("* LIST (\\HasNoChildren) \".\" [FolderName]\r\n" + ImapResponseParser parser = createParser("* LIST (\\HasNoChildren) \".\" [FolderName]\r\n" +
@ -417,7 +425,7 @@ public class ImapResponseParserTest {
parser.readResponse(); parser.readResponse();
fail("Expected exception"); fail("Expected exception");
} catch (IOException e) { } catch (IOException e) {
assertEquals("Unexpected non-string token: [1, 2]", e.getMessage()); assertEquals("Unexpected non-string token: ImapList - [1, 2]", e.getMessage());
} }
} }

View file

@ -706,8 +706,8 @@ public class FolderList extends K9ListActivity {
@Override @Override
public void listFoldersFailed(Account account, String message) { public void listFoldersFailed(Account account, String message) {
if (account.equals(mAccount)) { if (account.equals(mAccount)) {
mHandler.progress(false); mHandler.progress(false);
Toast.makeText(context, R.string.fetching_folders_failed, Toast.LENGTH_SHORT).show();
} }
super.listFoldersFailed(account, message); super.listFoldersFailed(account, message);
} }

View file

@ -1229,4 +1229,5 @@ Please submit bug reports, contribute new features and ask questions at
<string name="mail_list_widget_text">K-9 Message List</string> <string name="mail_list_widget_text">K-9 Message List</string>
<string name="mail_list_widget_loading">Loading messages…</string> <string name="mail_list_widget_loading">Loading messages…</string>
<string name="fetching_folders_failed">Fetching folder list failed</string>
</resources> </resources>