renamed dialog enum types, added comments
This commit is contained in:
parent
e74e65a876
commit
cb5cf885ac
@ -53,8 +53,8 @@ import static android.view.View.GONE;
|
|||||||
import static android.view.View.VISIBLE;
|
import static android.view.View.VISIBLE;
|
||||||
import static org.nuclearfog.twidda.activity.MainActivity.RETURN_APP_LOGOUT;
|
import static org.nuclearfog.twidda.activity.MainActivity.RETURN_APP_LOGOUT;
|
||||||
import static org.nuclearfog.twidda.activity.MainActivity.RETURN_DB_CLEARED;
|
import static org.nuclearfog.twidda.activity.MainActivity.RETURN_DB_CLEARED;
|
||||||
|
import static org.nuclearfog.twidda.backend.utils.DialogBuilder.DialogType.APP_LOG_OUT;
|
||||||
import static org.nuclearfog.twidda.backend.utils.DialogBuilder.DialogType.DEL_DATABASE;
|
import static org.nuclearfog.twidda.backend.utils.DialogBuilder.DialogType.DEL_DATABASE;
|
||||||
import static org.nuclearfog.twidda.backend.utils.DialogBuilder.DialogType.LOGOUT_APP;
|
|
||||||
import static org.nuclearfog.twidda.backend.utils.DialogBuilder.DialogType.WRONG_PROXY;
|
import static org.nuclearfog.twidda.backend.utils.DialogBuilder.DialogType.WRONG_PROXY;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -175,7 +175,7 @@ public class AppSettings extends AppCompatActivity implements OnClickListener, O
|
|||||||
|
|
||||||
connectDialog = DialogBuilder.create(this, WRONG_PROXY, this);
|
connectDialog = DialogBuilder.create(this, WRONG_PROXY, this);
|
||||||
databaseDialog = DialogBuilder.create(this, DEL_DATABASE, this);
|
databaseDialog = DialogBuilder.create(this, DEL_DATABASE, this);
|
||||||
logoutDialog = DialogBuilder.create(this, LOGOUT_APP, this);
|
logoutDialog = DialogBuilder.create(this, APP_LOG_OUT, this);
|
||||||
appInfo = DialogBuilder.createInfoDialog(this);
|
appInfo = DialogBuilder.createInfoDialog(this);
|
||||||
|
|
||||||
for (Button btn : colorButtons)
|
for (Button btn : colorButtons)
|
||||||
@ -246,24 +246,23 @@ public class AppSettings extends AppCompatActivity implements OnClickListener, O
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConfirm(DialogBuilder.DialogType type) {
|
public void onConfirm(DialogBuilder.DialogType type) {
|
||||||
switch (type) {
|
// confirm log out
|
||||||
case LOGOUT_APP:
|
if (type == APP_LOG_OUT) {
|
||||||
settings.logout();
|
settings.logout();
|
||||||
TwitterEngine.resetTwitter();
|
TwitterEngine.resetTwitter();
|
||||||
DatabaseAdapter.deleteDatabase(getApplicationContext());
|
DatabaseAdapter.deleteDatabase(getApplicationContext());
|
||||||
setResult(RETURN_APP_LOGOUT);
|
setResult(RETURN_APP_LOGOUT);
|
||||||
finish();
|
finish();
|
||||||
break;
|
}
|
||||||
|
// confirm delete database
|
||||||
case DEL_DATABASE:
|
else if (type == DEL_DATABASE) {
|
||||||
DatabaseAdapter.deleteDatabase(getApplicationContext());
|
DatabaseAdapter.deleteDatabase(getApplicationContext());
|
||||||
setResult(RETURN_DB_CLEARED);
|
setResult(RETURN_DB_CLEARED);
|
||||||
break;
|
}
|
||||||
|
// confirm leaving without saving proxy changes
|
||||||
case WRONG_PROXY:
|
else if (type == WRONG_PROXY) {
|
||||||
// exit without saving proxy settings
|
// exit without saving proxy settings
|
||||||
finish();
|
finish();
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -254,16 +254,15 @@ public class ListDetail extends AppCompatActivity implements OnTabSelectedListen
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConfirm(DialogBuilder.DialogType type) {
|
public void onConfirm(DialogBuilder.DialogType type) {
|
||||||
switch (type) {
|
// delete user list
|
||||||
case LIST_DELETE:
|
if (type == LIST_DELETE) {
|
||||||
listLoaderTask = new ListAction(this, DELETE);
|
listLoaderTask = new ListAction(this, DELETE);
|
||||||
listLoaderTask.execute(listId);
|
listLoaderTask.execute(listId);
|
||||||
break;
|
}
|
||||||
|
// unfollow user list
|
||||||
case LIST_UNFOLLOW:
|
else if (type == LIST_UNFOLLOW) {
|
||||||
listLoaderTask = new ListAction(this, UNFOLLOW);
|
listLoaderTask = new ListAction(this, UNFOLLOW);
|
||||||
listLoaderTask.execute(listId);
|
listLoaderTask.execute(listId);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ import static org.nuclearfog.twidda.activity.TweetEditor.KEY_TWEETPOPUP_TEXT;
|
|||||||
import static org.nuclearfog.twidda.activity.UserDetail.KEY_USERDETAIL_ID;
|
import static org.nuclearfog.twidda.activity.UserDetail.KEY_USERDETAIL_ID;
|
||||||
import static org.nuclearfog.twidda.activity.UserDetail.KEY_USERDETAIL_MODE;
|
import static org.nuclearfog.twidda.activity.UserDetail.KEY_USERDETAIL_MODE;
|
||||||
import static org.nuclearfog.twidda.activity.UserDetail.USERLIST_RETWEETS;
|
import static org.nuclearfog.twidda.activity.UserDetail.USERLIST_RETWEETS;
|
||||||
import static org.nuclearfog.twidda.backend.utils.DialogBuilder.DialogType.DELETE_TWEET;
|
import static org.nuclearfog.twidda.backend.utils.DialogBuilder.DialogType.TWEET_DELETE;
|
||||||
import static org.nuclearfog.twidda.fragment.TweetFragment.INTENT_TWEET_REMOVED_ID;
|
import static org.nuclearfog.twidda.fragment.TweetFragment.INTENT_TWEET_REMOVED_ID;
|
||||||
import static org.nuclearfog.twidda.fragment.TweetFragment.INTENT_TWEET_UPDATE_DATA;
|
import static org.nuclearfog.twidda.fragment.TweetFragment.INTENT_TWEET_UPDATE_DATA;
|
||||||
import static org.nuclearfog.twidda.fragment.TweetFragment.RETURN_TWEET_NOT_FOUND;
|
import static org.nuclearfog.twidda.fragment.TweetFragment.RETURN_TWEET_NOT_FOUND;
|
||||||
@ -166,7 +166,7 @@ public class TweetActivity extends AppCompatActivity implements OnClickListener,
|
|||||||
retweeter.setCompoundDrawablesWithIntrinsicBounds(R.drawable.retweet, 0, 0, 0);
|
retweeter.setCompoundDrawablesWithIntrinsicBounds(R.drawable.retweet, 0, 0, 0);
|
||||||
tweetText.setMovementMethod(LinkAndScrollMovement.getInstance());
|
tweetText.setMovementMethod(LinkAndScrollMovement.getInstance());
|
||||||
tweetText.setLinkTextColor(settings.getHighlightColor());
|
tweetText.setLinkTextColor(settings.getHighlightColor());
|
||||||
deleteDialog = DialogBuilder.create(this, DELETE_TWEET, this);
|
deleteDialog = DialogBuilder.create(this, TWEET_DELETE, this);
|
||||||
toolbar.setTitle("");
|
toolbar.setTitle("");
|
||||||
setSupportActionBar(toolbar);
|
setSupportActionBar(toolbar);
|
||||||
AppStyles.setTheme(settings, root);
|
AppStyles.setTheme(settings, root);
|
||||||
@ -385,12 +385,14 @@ public class TweetActivity extends AppCompatActivity implements OnClickListener,
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConfirm(DialogBuilder.DialogType type) {
|
public void onConfirm(DialogBuilder.DialogType type) {
|
||||||
if (type == DELETE_TWEET && tweet != null) {
|
if (type == TWEET_DELETE) {
|
||||||
long tweetId = tweet.getId();
|
if (tweet != null) {
|
||||||
if (tweet.getEmbeddedTweet() != null)
|
long tweetId = tweet.getId();
|
||||||
tweetId = tweet.getEmbeddedTweet().getId();
|
if (tweet.getEmbeddedTweet() != null)
|
||||||
statusAsync = new TweetAction(this, tweetId);
|
tweetId = tweet.getEmbeddedTweet().getId();
|
||||||
statusAsync.execute(Action.DELETE);
|
statusAsync = new TweetAction(this, tweetId);
|
||||||
|
statusAsync.execute(Action.DELETE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,25 +30,25 @@ public final class DialogBuilder {
|
|||||||
* types of dialogs, every dialog has its own message and title
|
* types of dialogs, every dialog has its own message and title
|
||||||
*/
|
*/
|
||||||
public enum DialogType {
|
public enum DialogType {
|
||||||
DEL_MESSAGE,
|
|
||||||
WRONG_PROXY,
|
WRONG_PROXY,
|
||||||
DEL_DATABASE,
|
DEL_DATABASE,
|
||||||
LOGOUT_APP,
|
APP_LOG_OUT,
|
||||||
LIST_EDITOR_LEAVE,
|
TWEET_DELETE,
|
||||||
LIST_EDITOR_ERROR,
|
|
||||||
TWEET_EDITOR_LEAVE,
|
TWEET_EDITOR_LEAVE,
|
||||||
TWEET_EDITOR_ERROR,
|
TWEET_EDITOR_ERROR,
|
||||||
|
MESSAGE_DELETE,
|
||||||
MESSAGE_EDITOR_LEAVE,
|
MESSAGE_EDITOR_LEAVE,
|
||||||
MESSAGE_EDITOR_ERROR,
|
MESSAGE_EDITOR_ERROR,
|
||||||
PROFILE_EDITOR_LEAVE,
|
PROFILE_EDITOR_LEAVE,
|
||||||
PROFILE_EDITOR_ERROR,
|
PROFILE_EDITOR_ERROR,
|
||||||
DELETE_TWEET,
|
|
||||||
PROFILE_UNFOLLOW,
|
PROFILE_UNFOLLOW,
|
||||||
PROFILE_BLOCK,
|
PROFILE_BLOCK,
|
||||||
PROFILE_MUTE,
|
PROFILE_MUTE,
|
||||||
DEL_USER_LIST,
|
LIST_REMOVE_USER,
|
||||||
LIST_UNFOLLOW,
|
LIST_UNFOLLOW,
|
||||||
LIST_DELETE
|
LIST_DELETE,
|
||||||
|
LIST_EDITOR_LEAVE,
|
||||||
|
LIST_EDITOR_ERROR
|
||||||
}
|
}
|
||||||
|
|
||||||
private DialogBuilder() {
|
private DialogBuilder() {
|
||||||
@ -69,7 +69,7 @@ public final class DialogBuilder {
|
|||||||
int message = 0;
|
int message = 0;
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case DEL_MESSAGE:
|
case MESSAGE_DELETE:
|
||||||
message = R.string.confirm_delete_message;
|
message = R.string.confirm_delete_message;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -84,7 +84,7 @@ public final class DialogBuilder {
|
|||||||
message = R.string.confirm_delete_database;
|
message = R.string.confirm_delete_database;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LOGOUT_APP:
|
case APP_LOG_OUT:
|
||||||
message = R.string.confirm_log_lout;
|
message = R.string.confirm_log_lout;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -110,7 +110,7 @@ public final class DialogBuilder {
|
|||||||
message = R.string.confirm_cancel_message;
|
message = R.string.confirm_cancel_message;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DELETE_TWEET:
|
case TWEET_DELETE:
|
||||||
message = R.string.confirm_delete_tweet;
|
message = R.string.confirm_delete_tweet;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -126,7 +126,7 @@ public final class DialogBuilder {
|
|||||||
message = R.string.confirm_mute;
|
message = R.string.confirm_mute;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DEL_USER_LIST:
|
case LIST_REMOVE_USER:
|
||||||
message = R.string.confirm_remove_user_from_list;
|
message = R.string.confirm_remove_user_from_list;
|
||||||
posButton = R.string.dialog_button_ok;
|
posButton = R.string.dialog_button_ok;
|
||||||
negButton = R.string.dialog_button_cancel;
|
negButton = R.string.dialog_button_cancel;
|
||||||
@ -220,6 +220,9 @@ public final class DialogBuilder {
|
|||||||
*/
|
*/
|
||||||
public interface OnProgressStopListener {
|
public interface OnProgressStopListener {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* called when the progress stop button was clicked
|
||||||
|
*/
|
||||||
void stopProgress();
|
void stopProgress();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -31,7 +31,7 @@ import static org.nuclearfog.twidda.activity.TweetActivity.KEY_TWEET_ID;
|
|||||||
import static org.nuclearfog.twidda.activity.TweetActivity.KEY_TWEET_NAME;
|
import static org.nuclearfog.twidda.activity.TweetActivity.KEY_TWEET_NAME;
|
||||||
import static org.nuclearfog.twidda.activity.TweetActivity.LINK_PATTERN;
|
import static org.nuclearfog.twidda.activity.TweetActivity.LINK_PATTERN;
|
||||||
import static org.nuclearfog.twidda.activity.UserProfile.KEY_PROFILE_DATA;
|
import static org.nuclearfog.twidda.activity.UserProfile.KEY_PROFILE_DATA;
|
||||||
import static org.nuclearfog.twidda.backend.utils.DialogBuilder.DialogType.DEL_MESSAGE;
|
import static org.nuclearfog.twidda.backend.utils.DialogBuilder.DialogType.MESSAGE_DELETE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fragment class for direct message lists
|
* Fragment class for direct message lists
|
||||||
@ -50,7 +50,7 @@ public class MessageFragment extends ListFragment implements OnItemSelected, OnD
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate() {
|
protected void onCreate() {
|
||||||
deleteDialog = DialogBuilder.create(requireContext(), DEL_MESSAGE, this);
|
deleteDialog = DialogBuilder.create(requireContext(), MESSAGE_DELETE, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -162,8 +162,10 @@ public class MessageFragment extends ListFragment implements OnItemSelected, OnD
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConfirm(DialogBuilder.DialogType type) {
|
public void onConfirm(DialogBuilder.DialogType type) {
|
||||||
messageTask = new MessageLoader(this, MessageLoader.Action.DEL, null);
|
if (type == MESSAGE_DELETE) {
|
||||||
messageTask.execute(deleteId);
|
messageTask = new MessageLoader(this, MessageLoader.Action.DEL, null);
|
||||||
|
messageTask.execute(deleteId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -26,7 +26,7 @@ import static android.os.AsyncTask.Status.RUNNING;
|
|||||||
import static org.nuclearfog.twidda.activity.UserProfile.KEY_PROFILE_DATA;
|
import static org.nuclearfog.twidda.activity.UserProfile.KEY_PROFILE_DATA;
|
||||||
import static org.nuclearfog.twidda.backend.ListManager.Action.DEL_USER;
|
import static org.nuclearfog.twidda.backend.ListManager.Action.DEL_USER;
|
||||||
import static org.nuclearfog.twidda.backend.UserLoader.NO_CURSOR;
|
import static org.nuclearfog.twidda.backend.UserLoader.NO_CURSOR;
|
||||||
import static org.nuclearfog.twidda.backend.utils.DialogBuilder.DialogType.DEL_USER_LIST;
|
import static org.nuclearfog.twidda.backend.utils.DialogBuilder.DialogType.LIST_REMOVE_USER;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fragment class for lists a list of users
|
* Fragment class for lists a list of users
|
||||||
@ -129,7 +129,7 @@ public class UserFragment extends ListFragment implements UserClickListener,
|
|||||||
search = param.getString(KEY_FRAG_USER_SEARCH, "");
|
search = param.getString(KEY_FRAG_USER_SEARCH, "");
|
||||||
delUser = param.getBoolean(KEY_FRAG_DEL_USER, false);
|
delUser = param.getBoolean(KEY_FRAG_DEL_USER, false);
|
||||||
}
|
}
|
||||||
deleteDialog = DialogBuilder.create(requireContext(), DEL_USER_LIST, this);
|
deleteDialog = DialogBuilder.create(requireContext(), LIST_REMOVE_USER, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -217,7 +217,7 @@ public class UserFragment extends ListFragment implements UserClickListener,
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConfirm(DialogBuilder.DialogType type) {
|
public void onConfirm(DialogBuilder.DialogType type) {
|
||||||
if (type == DEL_USER_LIST) {
|
if (type == LIST_REMOVE_USER) {
|
||||||
if (listTask == null || listTask.getStatus() != RUNNING) {
|
if (listTask == null || listTask.getStatus() != RUNNING) {
|
||||||
listTask = new ListManager(id, DEL_USER, requireContext(), this);
|
listTask = new ListManager(id, DEL_USER, requireContext(), this);
|
||||||
listTask.execute(deleteUserName);
|
listTask.execute(deleteUserName);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user