Skip to content

Commit

Permalink
Rename enum values according to code style conventions
Browse files Browse the repository at this point in the history
  • Loading branch information
di72nn committed Jan 2, 2017
1 parent 7cacba9 commit d3e3b95
Show file tree
Hide file tree
Showing 22 changed files with 194 additions and 194 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ public static void archiveArticle(Context context, int articleID, boolean archiv
Log.v(TAG, "archiveArticle() after getArticleDao().update()");

ArticlesChangedEvent.ChangeType changeType = archive
? ArticlesChangedEvent.ChangeType.Archived
: ArticlesChangedEvent.ChangeType.Unarchived;
? ArticlesChangedEvent.ChangeType.ARCHIVED
: ArticlesChangedEvent.ChangeType.UNARCHIVED;

Log.v(TAG, "archiveArticle() before notifyAboutArticleChange()");
notifyAboutArticleChange(article, changeType);
Expand Down Expand Up @@ -82,8 +82,8 @@ public static void favoriteArticle(Context context, int articleID, boolean favor
articleDao.update(article);

ArticlesChangedEvent.ChangeType changeType = favorite
? ArticlesChangedEvent.ChangeType.Favorited
: ArticlesChangedEvent.ChangeType.Unfavorited;
? ArticlesChangedEvent.ChangeType.FAVORITED
: ArticlesChangedEvent.ChangeType.UNFAVORITED;

notifyAboutArticleChange(article, changeType);

Expand Down Expand Up @@ -112,7 +112,7 @@ public static void deleteArticle(Context context, int articleID) {

articleDao.delete(article);

notifyAboutArticleChange(article, ArticlesChangedEvent.ChangeType.Deleted);
notifyAboutArticleChange(article, ArticlesChangedEvent.ChangeType.DELETED);

Log.d(TAG, "deleteArticle() article object deleted");

Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/fr/gaulupeau/apps/Poche/data/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public void initPreferences() {
}

Themes.Theme theme = android.os.Build.MODEL.equals("NOOK")
? Themes.Theme.LightContrast : Themes.Theme.Light;
? Themes.Theme.LIGHT_CONTRAST : Themes.Theme.LIGHT;
pref.edit().putString(context.getString(R.string.pref_key_ui_theme), theme.toString())
.apply();
}
Expand Down Expand Up @@ -368,7 +368,7 @@ public Themes.Theme getTheme() {
} catch(IllegalArgumentException ignored) {}
}

return theme != null ? theme : Themes.Theme.Light;
return theme != null ? theme : Themes.Theme.LIGHT;
}

public void setTheme(Themes.Theme theme) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
public class ArticlesChangedEvent extends FeedsChangedEvent {

public enum ChangeType {
Archived, Unarchived, Favorited, Unfavorited, Added, Deleted, Unspecified
ARCHIVED, UNARCHIVED, FAVORITED, UNFAVORITED, ADDED, DELETED, UNSPECIFIED
}

public static class ArticleEntry {
Expand Down Expand Up @@ -57,7 +57,7 @@ public ChangeType getArticleChangeType(Article article) {
}

public ChangeType getArticleChangeType(Integer articleID) {
if(isInvalidateAll()) return ChangeType.Unspecified;
if(isInvalidateAll()) return ChangeType.UNSPECIFIED;

if(getChangedArticles() == null) return null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,20 @@ public static void notifyAboutArticleChange(
boolean favoriteUpdated = false;

switch(changeType) {
case Archived:
case Unarchived:
case ARCHIVED:
case UNARCHIVED:
mainUpdated = archiveUpdated = true;
if(article.getFavorite()) favoriteUpdated = true;
break;

case Favorited:
case Unfavorited:
case FAVORITED:
case UNFAVORITED:
favoriteUpdated = true;
if(article.getArchive()) archiveUpdated = true;
else mainUpdated = true;
break;

case Deleted:
case DELETED:
if(article.getArchive()) archiveUpdated = true;
else mainUpdated = true;
if(article.getFavorite()) favoriteUpdated = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ public void onAlarmReceivedEvent(AlarmReceivedEvent event) {
}

int updateTypeVal = settings.getAutoSyncType();
FeedUpdater.FeedType feedType = updateTypeVal == 0 ? FeedUpdater.FeedType.Main : null;
FeedUpdater.UpdateType updateType = updateTypeVal == 0 ? FeedUpdater.UpdateType.Fast : null;
FeedUpdater.FeedType feedType = updateTypeVal == 0 ? FeedUpdater.FeedType.MAIN : null;
FeedUpdater.UpdateType updateType = updateTypeVal == 0 ? FeedUpdater.UpdateType.FAST : null;

Context context = getContext();
// TODO: if the queue sync operation fails, the update feed operation should not be started
Expand Down Expand Up @@ -209,7 +209,7 @@ public void onSyncQueueStartedEvent(SyncQueueStartedEvent event) {
Log.d(TAG, "onSyncQueueStartedEvent() started");

ActionRequest request = event.getRequest();
if(request.getRequestType() != ActionRequest.RequestType.ManualByOperation
if(request.getRequestType() != ActionRequest.RequestType.MANUAL_BY_OPERATION
|| (request.getQueueLength() != null && request.getQueueLength() > 1)) {
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(getContext())
.setSmallIcon(R.drawable.ic_action_refresh)
Expand Down Expand Up @@ -317,15 +317,15 @@ public void onActionResultEvent(ActionResultEvent event) {
Log.d(TAG, "onActionResultEvent() result message: " + result.getMessage());

switch(errorType) {
case Temporary:
case NoNetwork:
case TEMPORARY:
case NO_NETWORK:
// don't show it to user at all or make it suppressible
// optionally schedule auto-retry
// TODO: not important: implement
break;

case IncorrectConfiguration:
case IncorrectCredentials: {
case INCORRECT_CONFIGURATION:
case INCORRECT_CREDENTIALS: {
// notify user -- user must fix something before retry
// maybe suppress notification if:
// - the action was not requested by user (that probably implies the second case), or
Expand All @@ -339,7 +339,7 @@ public void onActionResultEvent(ActionResultEvent event) {
settings.setConfigurationOk(false);
}

if(request.getRequestType() != ActionRequest.RequestType.Auto
if(request.getRequestType() != ActionRequest.RequestType.AUTO
|| !settings.isConfigurationErrorShown()) {
settings.setConfigurationErrorShown(true);

Expand All @@ -354,7 +354,7 @@ public void onActionResultEvent(ActionResultEvent event) {
.setSmallIcon(R.drawable.ic_warning_24dp)
.setContentTitle(context.getString(R.string.notification_error))
.setContentText(context.getString(
errorType == ActionResult.ErrorType.IncorrectCredentials
errorType == ActionResult.ErrorType.INCORRECT_CREDENTIALS
? R.string.notification_incorrectCredentials
: R.string.notification_incorrectConfiguration))
.setContentIntent(contentIntent);
Expand All @@ -364,7 +364,7 @@ public void onActionResultEvent(ActionResultEvent event) {
break;
}

case Unknown: {
case UNKNOWN: {
// this is undecided yet
// show notification + schedule auto-retry
// TODO: decide on behavior
Expand All @@ -386,10 +386,10 @@ public void onActionResultEvent(ActionResultEvent event) {
break;
}

case NegativeResponse:
case NEGATIVE_RESPONSE:
// server acknowledged the operation but failed/refused to performed it;
// detection of such response is not implemented on client yet
Log.w(TAG, "onActionResultEvent() got a NegativeResponse; that was not expected");
Log.w(TAG, "onActionResultEvent() got a NEGATIVE_RESPONSE; that was not expected");
break;
}
}
Expand Down Expand Up @@ -417,7 +417,7 @@ public void onLinkUploadedEvent(LinkUploadedEvent event) {
Log.d(TAG, "onLinkUploadedEvent() autoDlNew enabled, triggering fast update");

ServiceHelper.updateFeed(getContext(),
FeedUpdater.FeedType.Main, FeedUpdater.UpdateType.Fast, null, true);
FeedUpdater.FeedType.MAIN, FeedUpdater.UpdateType.FAST, null, true);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ public void setChangedByFeedType(FeedUpdater.FeedType feedType) {
if(feedType == null) return;

switch(feedType) {
case Main:
case MAIN:
mainFeedChanged = true;
break;

case Favorite:
case FAVORITE:
favoriteFeedChanged = true;
break;

case Archive:
case ARCHIVE:
archiveFeedChanged = true;
break;
}
Expand Down
60 changes: 30 additions & 30 deletions app/src/main/java/fr/gaulupeau/apps/Poche/network/FeedUpdater.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@

public class FeedUpdater {

public enum UpdateType { Full, Fast }
public enum UpdateType { FULL, FAST }

public enum FeedType {
Main("home", "unread.xml", R.string.feedName_unread),
Favorite("fav", "starred.xml", R.string.feedName_favorites),
Archive("archive", "archive.xml", R.string.feedName_archived);
MAIN("home", "unread.xml", R.string.feedName_unread),
FAVORITE("fav", "starred.xml", R.string.feedName_favorites),
ARCHIVE("archive", "archive.xml", R.string.feedName_archived);

String urlPartV1, urlPartV2;
int nameResID;
Expand Down Expand Up @@ -103,7 +103,7 @@ public ArticlesChangedEvent update(FeedType feedType, UpdateType updateType)
throw new IllegalArgumentException("If updateType is set, feedType must be set too");
}
if(updateType == null) {
updateType = UpdateType.Full;
updateType = UpdateType.FULL;
}

updateInternal(feedType, updateType, event);
Expand All @@ -120,14 +120,14 @@ private void updateAllFeeds() throws IncorrectFeedException, RequestException, I
Log.d(TAG, "updateAllFeeds() deleting old articles");
articleDao.deleteAll();

Log.d(TAG, "updateAllFeeds() updating Main feed");
updateByFeed(articleDao, FeedType.Main, UpdateType.Full, 0, null);
Log.d(TAG, "updateAllFeeds() updating MAIN feed");
updateByFeed(articleDao, FeedType.MAIN, UpdateType.FULL, 0, null);

Log.d(TAG, "updateAllFeeds() updating Archive feed");
updateByFeed(articleDao, FeedType.Archive, UpdateType.Full, 0, null);
Log.d(TAG, "updateAllFeeds() updating ARCHIVE feed");
updateByFeed(articleDao, FeedType.ARCHIVE, UpdateType.FULL, 0, null);

Log.d(TAG, "updateAllFeeds() updating Favorite feed");
updateByFeed(articleDao, FeedType.Favorite, UpdateType.Fast, 0, null);
Log.d(TAG, "updateAllFeeds() updating FAVORITE feed");
updateByFeed(articleDao, FeedType.FAVORITE, UpdateType.FAST, 0, null);

Log.d(TAG, "updateAllFeeds() finished");
}
Expand All @@ -140,8 +140,8 @@ private void updateInternal(
ArticleDao articleDao = DbConnection.getSession().getArticleDao();

Integer latestID = null;
if(feedType == FeedType.Main || feedType == FeedType.Archive) {
WhereCondition cond = feedType == FeedType.Main
if(feedType == FeedType.MAIN || feedType == FeedType.ARCHIVE) {
WhereCondition cond = feedType == FeedType.MAIN
? ArticleDao.Properties.Archive.notEq(true)
: ArticleDao.Properties.Archive.eq(true);
List<Article> l = articleDao.queryBuilder().where(cond)
Expand Down Expand Up @@ -263,11 +263,11 @@ private void processFeed(ArticleDao articleDao, InputStream is,

Log.v(TAG, "processFeed() parser.getName()=" + parser.getName());
if ("item".equals(parser.getName())) {
if(feedType == FeedType.Main || feedType == FeedType.Archive
|| (feedType == FeedType.Favorite && updateType == UpdateType.Full)) {
// Main: Full, Fast
// Archive: Full, Fast
// Favorite: Full
if(feedType == FeedType.MAIN || feedType == FeedType.ARCHIVE
|| (feedType == FeedType.FAVORITE && updateType == UpdateType.FULL)) {
// MAIN: FULL, FAST
// ARCHIVE: FULL, FAST
// FAVORITE: FULL

Item item = parseItem(parser);

Expand All @@ -277,7 +277,7 @@ private void processFeed(ArticleDao articleDao, InputStream is,
continue;
}

if(updateType == UpdateType.Fast && latestID != null && latestID >= id) {
if(updateType == UpdateType.FAST && latestID != null && latestID >= id) {
Log.d(TAG, "processFeed(): update type fast, everything up to date");
break;
}
Expand All @@ -301,30 +301,30 @@ private void processFeed(ArticleDao articleDao, InputStream is,
e.printStackTrace();
}
if(existing) {
if(feedType == FeedType.Archive) {
if(feedType == FeedType.ARCHIVE) {
article.setArchive(true);
} else if(feedType == FeedType.Favorite) {
} else if(feedType == FeedType.FAVORITE) {
article.setFavorite(true);
}
} else {
article.setArchive(feedType == FeedType.Archive);
article.setFavorite(feedType == FeedType.Favorite);
article.setArchive(feedType == FeedType.ARCHIVE);
article.setFavorite(feedType == FeedType.FAVORITE);
}
article.setImagesDownloaded(false);

if(event != null) {
ArticlesChangedEvent.ChangeType changeType = existing
? ArticlesChangedEvent.ChangeType.Unspecified
: ArticlesChangedEvent.ChangeType.Added;
? ArticlesChangedEvent.ChangeType.UNSPECIFIED
: ArticlesChangedEvent.ChangeType.ADDED;

event.setChangedByFeedType(feedType);
event.addChangedArticle(article, changeType);
}

articleDao.insertOrReplace(article);
} else if(feedType == FeedType.Favorite) {
// Favorite: Fast (ONLY applicable if Main and Archive feeds are up to date)
// probably a bit faster then "Favorite: Full"
} else if(feedType == FeedType.FAVORITE) {
// FAVORITE: FAST (ONLY applicable if MAIN and ARCHIVE feeds are up to date)
// probably a bit faster then "FAVORITE: FULL"

Integer id = parseItemID(parser);
if(id == null) continue;
Expand All @@ -333,7 +333,7 @@ private void processFeed(ArticleDao articleDao, InputStream is,
.where(ArticleDao.Properties.ArticleId.eq(id))
.build().unique();
if(article == null) {
Log.w(TAG, "processFeed() Favorite: Fast; couldn't find article with ID: "
Log.w(TAG, "processFeed() FAVORITE: FAST; couldn't find article with ID: "
+ id);
continue;
}
Expand All @@ -352,7 +352,7 @@ private void processFeed(ArticleDao articleDao, InputStream is,
}

event.addChangedArticle(article,
ArticlesChangedEvent.ChangeType.Favorited);
ArticlesChangedEvent.ChangeType.FAVORITED);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ public abstract class WallabagServiceEndpoint {
private static final String TAG = WallabagServiceEndpoint.class.getSimpleName();

public enum ConnectionTestResult {
OK, IncorrectURL, IncorrectServerVersion, WallabagNotFound,
HTTPAuth, NoCSRF, IncorrectCredentials,
AuthProblem, UnknownPageAfterLogin
OK, INCORRECT_URL, INCORRECT_SERVER_VERSION, WALLABAG_NOT_FOUND,
HTTP_AUTH, NO_CSRF, INCORRECT_CREDENTIALS,
AUTH_PROBLEM, UNKNOWN_PAGE_AFTER_LOGIN
}

protected String endpoint;
Expand Down
Loading

0 comments on commit d3e3b95

Please sign in to comment.