mirror of
https://github.com/nuclearfog/Shitter.git
synced 2025-02-01 03:36:56 +01:00
removed enum classes, added comments, bug fix
This commit is contained in:
parent
fbc489056c
commit
d9fc695fc9
@ -8,7 +8,7 @@ import androidx.appcompat.app.AppCompatDelegate;
|
|||||||
import org.nuclearfog.twidda.backend.utils.TLSSocketFactory;
|
import org.nuclearfog.twidda.backend.utils.TLSSocketFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* custom application class to initialize support for old android versions and proxy settings
|
* custom application class to to add support for Android devices below API 21
|
||||||
*
|
*
|
||||||
* @author nuclearfog
|
* @author nuclearfog
|
||||||
*/
|
*/
|
||||||
@ -18,12 +18,14 @@ public class CompatApplication extends Application {
|
|||||||
@Override
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
|
|
||||||
// enable support for vector drawables
|
// enable support for vector drawables
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
|
||||||
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
|
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// check and enable TLS 1.2 support
|
// check if TLS 1.2 is supported
|
||||||
|
// enable experimental TLS 1.2 support
|
||||||
TLSSocketFactory.setSupportTLS();
|
TLSSocketFactory.setSupportTLS();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -154,7 +154,7 @@ public class MessageAdapter extends Adapter<ViewHolder> {
|
|||||||
if (position != NO_POSITION) {
|
if (position != NO_POSITION) {
|
||||||
DirectMessage message = data.get(position);
|
DirectMessage message = data.get(position);
|
||||||
if (message != null) {
|
if (message != null) {
|
||||||
itemClickListener.onClick(message, OnMessageClickListener.Action.ANSWER);
|
itemClickListener.onClick(message, OnMessageClickListener.ANSWER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -166,7 +166,7 @@ public class MessageAdapter extends Adapter<ViewHolder> {
|
|||||||
if (position != NO_POSITION) {
|
if (position != NO_POSITION) {
|
||||||
DirectMessage message = data.get(position);
|
DirectMessage message = data.get(position);
|
||||||
if (message != null) {
|
if (message != null) {
|
||||||
itemClickListener.onClick(message, OnMessageClickListener.Action.DELETE);
|
itemClickListener.onClick(message, OnMessageClickListener.DELETE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -178,7 +178,7 @@ public class MessageAdapter extends Adapter<ViewHolder> {
|
|||||||
if (position != NO_POSITION) {
|
if (position != NO_POSITION) {
|
||||||
DirectMessage message = data.get(position);
|
DirectMessage message = data.get(position);
|
||||||
if (message != null) {
|
if (message != null) {
|
||||||
itemClickListener.onClick(message, OnMessageClickListener.Action.PROFILE);
|
itemClickListener.onClick(message, OnMessageClickListener.PROFILE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -190,7 +190,7 @@ public class MessageAdapter extends Adapter<ViewHolder> {
|
|||||||
if (position != NO_POSITION) {
|
if (position != NO_POSITION) {
|
||||||
DirectMessage message = data.get(position);
|
DirectMessage message = data.get(position);
|
||||||
if (message != null) {
|
if (message != null) {
|
||||||
itemClickListener.onClick(message, OnMessageClickListener.Action.MEDIA);
|
itemClickListener.onClick(message, OnMessageClickListener.MEDIA);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -278,22 +278,32 @@ public class MessageAdapter extends Adapter<ViewHolder> {
|
|||||||
public interface OnMessageClickListener extends OnTagClickListener {
|
public interface OnMessageClickListener extends OnTagClickListener {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Actions performed by clicking the buttons
|
* indicates that the "answer" button was clicked
|
||||||
*/
|
*/
|
||||||
enum Action {
|
int ANSWER = 1;
|
||||||
ANSWER,
|
|
||||||
DELETE,
|
/**
|
||||||
PROFILE,
|
* indicates that the "delete" button was clicked
|
||||||
MEDIA
|
*/
|
||||||
}
|
int DELETE = 10;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* indicates that the profile image was clicked
|
||||||
|
*/
|
||||||
|
int PROFILE = 100;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* indicates that the media button was clicked
|
||||||
|
*/
|
||||||
|
int MEDIA = 1000;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* called when a button was clicked
|
* called when a button was clicked
|
||||||
*
|
*
|
||||||
* @param message Message information
|
* @param message Message information
|
||||||
* @param action what button was clicked
|
* @param action what button was clicked {@link #ANSWER,#DELETE,#PROFILE,#MEDIA}
|
||||||
*/
|
*/
|
||||||
void onClick(DirectMessage message, Action action);
|
void onClick(DirectMessage message, int action);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* called when the footer was clicked
|
* called when the footer was clicked
|
||||||
|
@ -24,7 +24,7 @@ public class UserlistUpdate {
|
|||||||
* @param title Title of the list
|
* @param title Title of the list
|
||||||
* @param description short description of the list
|
* @param description short description of the list
|
||||||
* @param isPublic true if list should be public
|
* @param isPublic true if list should be public
|
||||||
* @param listId ID of the list to update or {@link UserlistUpdate#NEW_LIST} to create a new list
|
* @param listId ID of the list to update or {@link #NEW_LIST} to create a new list
|
||||||
*/
|
*/
|
||||||
public UserlistUpdate(String title, String description, boolean isPublic, long listId) {
|
public UserlistUpdate(String title, String description, boolean isPublic, long listId) {
|
||||||
this.title = title;
|
this.title = title;
|
||||||
|
@ -718,7 +718,7 @@ public class AppDatabase {
|
|||||||
*
|
*
|
||||||
* @param user user information
|
* @param user user information
|
||||||
* @param db SQLITE DB
|
* @param db SQLITE DB
|
||||||
* @param mode SQLITE mode {@link SQLiteDatabase#CONFLICT_IGNORE} or {@link SQLiteDatabase#CONFLICT_REPLACE}
|
* @param mode SQLITE mode {@link SQLiteDatabase#CONFLICT_IGNORE,SQLiteDatabase#CONFLICT_REPLACE}
|
||||||
*/
|
*/
|
||||||
private void storeUser(User user, SQLiteDatabase db, int mode) {
|
private void storeUser(User user, SQLiteDatabase db, int mode) {
|
||||||
int register = getUserRegister(db, user.getId());
|
int register = getUserRegister(db, user.getId());
|
||||||
|
@ -27,7 +27,6 @@ import org.nuclearfog.twidda.backend.async.MessageUpdater;
|
|||||||
import org.nuclearfog.twidda.backend.utils.AppStyles;
|
import org.nuclearfog.twidda.backend.utils.AppStyles;
|
||||||
import org.nuclearfog.twidda.backend.utils.ErrorHandler;
|
import org.nuclearfog.twidda.backend.utils.ErrorHandler;
|
||||||
import org.nuclearfog.twidda.ui.dialogs.ConfirmDialog;
|
import org.nuclearfog.twidda.ui.dialogs.ConfirmDialog;
|
||||||
import org.nuclearfog.twidda.ui.dialogs.ConfirmDialog.DialogType;
|
|
||||||
import org.nuclearfog.twidda.ui.dialogs.ConfirmDialog.OnConfirmListener;
|
import org.nuclearfog.twidda.ui.dialogs.ConfirmDialog.OnConfirmListener;
|
||||||
import org.nuclearfog.twidda.ui.dialogs.ProgressDialog;
|
import org.nuclearfog.twidda.ui.dialogs.ProgressDialog;
|
||||||
import org.nuclearfog.twidda.ui.dialogs.ProgressDialog.OnProgressStopListener;
|
import org.nuclearfog.twidda.ui.dialogs.ProgressDialog.OnProgressStopListener;
|
||||||
@ -99,7 +98,7 @@ public class MessageEditor extends MediaActivity implements OnClickListener, OnC
|
|||||||
if (receiver.getText().length() == 0 && message.getText().length() == 0 && holder.getMediaUri() == null) {
|
if (receiver.getText().length() == 0 && message.getText().length() == 0 && holder.getMediaUri() == null) {
|
||||||
super.onBackPressed();
|
super.onBackPressed();
|
||||||
} else {
|
} else {
|
||||||
confirmDialog.show(DialogType.MESSAGE_EDITOR_LEAVE);
|
confirmDialog.show(ConfirmDialog.MESSAGE_EDITOR_LEAVE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,13 +166,13 @@ public class MessageEditor extends MediaActivity implements OnClickListener, OnC
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConfirm(DialogType type, boolean rememberChoice) {
|
public void onConfirm(int type, boolean rememberChoice) {
|
||||||
// retry sending message
|
// retry sending message
|
||||||
if (type == DialogType.MESSAGE_EDITOR_ERROR) {
|
if (type == ConfirmDialog.MESSAGE_EDITOR_ERROR) {
|
||||||
sendMessage();
|
sendMessage();
|
||||||
}
|
}
|
||||||
// leave message editor
|
// leave message editor
|
||||||
else if (type == DialogType.MESSAGE_EDITOR_LEAVE) {
|
else if (type == ConfirmDialog.MESSAGE_EDITOR_LEAVE) {
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -193,8 +192,7 @@ public class MessageEditor extends MediaActivity implements OnClickListener, OnC
|
|||||||
*/
|
*/
|
||||||
public void onError(@Nullable ErrorHandler.TwitterError error) {
|
public void onError(@Nullable ErrorHandler.TwitterError error) {
|
||||||
String message = ErrorHandler.getErrorMessage(this, error);
|
String message = ErrorHandler.getErrorMessage(this, error);
|
||||||
confirmDialog.setMessage(message);
|
confirmDialog.show(ConfirmDialog.MESSAGE_EDITOR_ERROR, message);
|
||||||
confirmDialog.show(DialogType.MESSAGE_EDITOR_ERROR);
|
|
||||||
loadingCircle.dismiss();
|
loadingCircle.dismiss();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,7 +42,6 @@ import org.nuclearfog.twidda.backend.utils.PicassoBuilder;
|
|||||||
import org.nuclearfog.twidda.database.GlobalSettings;
|
import org.nuclearfog.twidda.database.GlobalSettings;
|
||||||
import org.nuclearfog.twidda.model.User;
|
import org.nuclearfog.twidda.model.User;
|
||||||
import org.nuclearfog.twidda.ui.dialogs.ConfirmDialog;
|
import org.nuclearfog.twidda.ui.dialogs.ConfirmDialog;
|
||||||
import org.nuclearfog.twidda.ui.dialogs.ConfirmDialog.DialogType;
|
|
||||||
import org.nuclearfog.twidda.ui.dialogs.ConfirmDialog.OnConfirmListener;
|
import org.nuclearfog.twidda.ui.dialogs.ConfirmDialog.OnConfirmListener;
|
||||||
import org.nuclearfog.twidda.ui.dialogs.ProgressDialog;
|
import org.nuclearfog.twidda.ui.dialogs.ProgressDialog;
|
||||||
import org.nuclearfog.twidda.ui.dialogs.ProgressDialog.OnProgressStopListener;
|
import org.nuclearfog.twidda.ui.dialogs.ProgressDialog.OnProgressStopListener;
|
||||||
@ -167,7 +166,7 @@ public class ProfileEditor extends MediaActivity implements OnClickListener, OnP
|
|||||||
} else if (username.isEmpty() && userLink.isEmpty() && userLoc.isEmpty() && userBio.isEmpty()) {
|
} else if (username.isEmpty() && userLink.isEmpty() && userLoc.isEmpty() && userBio.isEmpty()) {
|
||||||
finish();
|
finish();
|
||||||
} else {
|
} else {
|
||||||
confirmDialog.show(DialogType.PROFILE_EDITOR_LEAVE);
|
confirmDialog.show(ConfirmDialog.PROFILE_EDITOR_LEAVE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -241,13 +240,13 @@ public class ProfileEditor extends MediaActivity implements OnClickListener, OnP
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConfirm(DialogType type, boolean rememberChoice) {
|
public void onConfirm(int type, boolean rememberChoice) {
|
||||||
// leave without settings
|
// leave without settings
|
||||||
if (type == DialogType.PROFILE_EDITOR_LEAVE) {
|
if (type == ConfirmDialog.PROFILE_EDITOR_LEAVE) {
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
// retry
|
// retry
|
||||||
else if (type == DialogType.PROFILE_EDITOR_ERROR) {
|
else if (type == ConfirmDialog.PROFILE_EDITOR_ERROR) {
|
||||||
updateUser();
|
updateUser();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -284,8 +283,7 @@ public class ProfileEditor extends MediaActivity implements OnClickListener, OnP
|
|||||||
*/
|
*/
|
||||||
public void onError(ErrorHandler.TwitterError err) {
|
public void onError(ErrorHandler.TwitterError err) {
|
||||||
String message = ErrorHandler.getErrorMessage(this, err);
|
String message = ErrorHandler.getErrorMessage(this, err);
|
||||||
confirmDialog.setMessage(message);
|
confirmDialog.show(ConfirmDialog.PROFILE_EDITOR_ERROR, message);
|
||||||
confirmDialog.show(DialogType.PROFILE_EDITOR_ERROR);
|
|
||||||
loadingCircle.dismiss();
|
loadingCircle.dismiss();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,6 @@ import static android.os.AsyncTask.Status.RUNNING;
|
|||||||
import static android.view.View.GONE;
|
import static android.view.View.GONE;
|
||||||
import static android.view.View.OnClickListener;
|
import static android.view.View.OnClickListener;
|
||||||
import static android.view.View.VISIBLE;
|
import static android.view.View.VISIBLE;
|
||||||
import static org.nuclearfog.twidda.ui.dialogs.ConfirmDialog.DialogType;
|
|
||||||
|
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@ -283,7 +282,7 @@ public class SettingsActivity extends AppCompatActivity implements OnClickListen
|
|||||||
if (saveConnectionSettings()) {
|
if (saveConnectionSettings()) {
|
||||||
super.onBackPressed();
|
super.onBackPressed();
|
||||||
} else {
|
} else {
|
||||||
confirmDialog.show(DialogType.WRONG_PROXY);
|
confirmDialog.show(ConfirmDialog.WRONG_PROXY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -316,9 +315,9 @@ public class SettingsActivity extends AppCompatActivity implements OnClickListen
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConfirm(DialogType type, boolean rememberChoice) {
|
public void onConfirm(int type, boolean rememberChoice) {
|
||||||
// confirm log out
|
// confirm log out
|
||||||
if (type == DialogType.APP_LOG_OUT) {
|
if (type == ConfirmDialog.APP_LOG_OUT) {
|
||||||
settings.logout();
|
settings.logout();
|
||||||
// remove account from database
|
// remove account from database
|
||||||
AccountDatabase accountDB = new AccountDatabase(this);
|
AccountDatabase accountDB = new AccountDatabase(this);
|
||||||
@ -327,12 +326,12 @@ public class SettingsActivity extends AppCompatActivity implements OnClickListen
|
|||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
// confirm delete app data and cache
|
// confirm delete app data and cache
|
||||||
else if (type == DialogType.DELETE_APP_DATA) {
|
else if (type == ConfirmDialog.DELETE_APP_DATA) {
|
||||||
DatabaseAdapter.deleteDatabase(this);
|
DatabaseAdapter.deleteDatabase(this);
|
||||||
setResult(RETURN_DATA_CLEARED);
|
setResult(RETURN_DATA_CLEARED);
|
||||||
}
|
}
|
||||||
// confirm leaving without saving proxy changes
|
// confirm leaving without saving proxy changes
|
||||||
else if (type == DialogType.WRONG_PROXY) {
|
else if (type == ConfirmDialog.WRONG_PROXY) {
|
||||||
// exit without saving proxy settings
|
// exit without saving proxy settings
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
@ -343,11 +342,11 @@ public class SettingsActivity extends AppCompatActivity implements OnClickListen
|
|||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
// delete database
|
// delete database
|
||||||
if (v.getId() == R.id.delete_db) {
|
if (v.getId() == R.id.delete_db) {
|
||||||
confirmDialog.show(DialogType.DELETE_APP_DATA);
|
confirmDialog.show(ConfirmDialog.DELETE_APP_DATA);
|
||||||
}
|
}
|
||||||
// logout from twitter
|
// logout from twitter
|
||||||
else if (v.getId() == R.id.logout) {
|
else if (v.getId() == R.id.logout) {
|
||||||
confirmDialog.show(DialogType.APP_LOG_OUT);
|
confirmDialog.show(ConfirmDialog.APP_LOG_OUT);
|
||||||
}
|
}
|
||||||
// set background color
|
// set background color
|
||||||
else if (v.getId() == R.id.color_background) {
|
else if (v.getId() == R.id.color_background) {
|
||||||
|
@ -57,7 +57,6 @@ import org.nuclearfog.twidda.database.GlobalSettings;
|
|||||||
import org.nuclearfog.twidda.model.Tweet;
|
import org.nuclearfog.twidda.model.Tweet;
|
||||||
import org.nuclearfog.twidda.model.User;
|
import org.nuclearfog.twidda.model.User;
|
||||||
import org.nuclearfog.twidda.ui.dialogs.ConfirmDialog;
|
import org.nuclearfog.twidda.ui.dialogs.ConfirmDialog;
|
||||||
import org.nuclearfog.twidda.ui.dialogs.ConfirmDialog.DialogType;
|
|
||||||
import org.nuclearfog.twidda.ui.dialogs.ConfirmDialog.OnConfirmListener;
|
import org.nuclearfog.twidda.ui.dialogs.ConfirmDialog.OnConfirmListener;
|
||||||
import org.nuclearfog.twidda.ui.dialogs.LinkDialog;
|
import org.nuclearfog.twidda.ui.dialogs.LinkDialog;
|
||||||
import org.nuclearfog.twidda.ui.fragments.TweetFragment;
|
import org.nuclearfog.twidda.ui.fragments.TweetFragment;
|
||||||
@ -333,7 +332,7 @@ public class TweetActivity extends AppCompatActivity implements OnClickListener,
|
|||||||
User author = clickedTweet.getAuthor();
|
User author = clickedTweet.getAuthor();
|
||||||
// Delete tweet option
|
// Delete tweet option
|
||||||
if (item.getItemId() == R.id.menu_tweet_delete) {
|
if (item.getItemId() == R.id.menu_tweet_delete) {
|
||||||
confirmDialog.show(DialogType.TWEET_DELETE);
|
confirmDialog.show(ConfirmDialog.TWEET_DELETE);
|
||||||
}
|
}
|
||||||
// hide tweet
|
// hide tweet
|
||||||
else if (item.getItemId() == R.id.menu_tweet_hide) {
|
else if (item.getItemId() == R.id.menu_tweet_hide) {
|
||||||
@ -462,7 +461,7 @@ public class TweetActivity extends AppCompatActivity implements OnClickListener,
|
|||||||
mediaIntent.putExtra(VideoViewer.ENABLE_VIDEO_CONTROLS, true);
|
mediaIntent.putExtra(VideoViewer.ENABLE_VIDEO_CONTROLS, true);
|
||||||
startActivity(mediaIntent);
|
startActivity(mediaIntent);
|
||||||
} else {
|
} else {
|
||||||
confirmDialog.show(DialogType.PROXY_CONFIRM);
|
confirmDialog.show(ConfirmDialog.PROXY_CONFIRM);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// open embedded gif link
|
// open embedded gif link
|
||||||
@ -519,16 +518,16 @@ public class TweetActivity extends AppCompatActivity implements OnClickListener,
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConfirm(DialogType type, boolean rememberChoice) {
|
public void onConfirm(int type, boolean rememberChoice) {
|
||||||
if (tweet != null) {
|
if (tweet != null) {
|
||||||
Tweet clickedTweet = tweet;
|
Tweet clickedTweet = tweet;
|
||||||
if (tweet.getEmbeddedTweet() != null) {
|
if (tweet.getEmbeddedTweet() != null) {
|
||||||
clickedTweet = tweet.getEmbeddedTweet();
|
clickedTweet = tweet.getEmbeddedTweet();
|
||||||
}
|
}
|
||||||
if (type == DialogType.TWEET_DELETE) {
|
if (type == ConfirmDialog.TWEET_DELETE) {
|
||||||
statusAsync = new TweetAction(this, TweetAction.DELETE);
|
statusAsync = new TweetAction(this, TweetAction.DELETE);
|
||||||
statusAsync.execute(clickedTweet.getId(), clickedTweet.getRetweetId());
|
statusAsync.execute(clickedTweet.getId(), clickedTweet.getRetweetId());
|
||||||
} else if (type == DialogType.PROXY_CONFIRM) {
|
} else if (type == ConfirmDialog.PROXY_CONFIRM) {
|
||||||
settings.setIgnoreProxyWarning(rememberChoice);
|
settings.setIgnoreProxyWarning(rememberChoice);
|
||||||
|
|
||||||
Uri link = clickedTweet.getMediaUris()[0];
|
Uri link = clickedTweet.getMediaUris()[0];
|
||||||
|
@ -32,7 +32,6 @@ import org.nuclearfog.twidda.backend.utils.ErrorHandler;
|
|||||||
import org.nuclearfog.twidda.backend.utils.StringTools;
|
import org.nuclearfog.twidda.backend.utils.StringTools;
|
||||||
import org.nuclearfog.twidda.database.GlobalSettings;
|
import org.nuclearfog.twidda.database.GlobalSettings;
|
||||||
import org.nuclearfog.twidda.ui.dialogs.ConfirmDialog;
|
import org.nuclearfog.twidda.ui.dialogs.ConfirmDialog;
|
||||||
import org.nuclearfog.twidda.ui.dialogs.ConfirmDialog.DialogType;
|
|
||||||
import org.nuclearfog.twidda.ui.dialogs.ConfirmDialog.OnConfirmListener;
|
import org.nuclearfog.twidda.ui.dialogs.ConfirmDialog.OnConfirmListener;
|
||||||
import org.nuclearfog.twidda.ui.dialogs.ProgressDialog;
|
import org.nuclearfog.twidda.ui.dialogs.ProgressDialog;
|
||||||
import org.nuclearfog.twidda.ui.dialogs.ProgressDialog.OnProgressStopListener;
|
import org.nuclearfog.twidda.ui.dialogs.ProgressDialog.OnProgressStopListener;
|
||||||
@ -310,13 +309,13 @@ public class TweetEditor extends MediaActivity implements OnClickListener, OnPro
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConfirm(DialogType type, boolean rememberChoice) {
|
public void onConfirm(int type, boolean rememberChoice) {
|
||||||
// retry uploading tweet
|
// retry uploading tweet
|
||||||
if (type == DialogType.TWEET_EDITOR_ERROR) {
|
if (type == ConfirmDialog.TWEET_EDITOR_ERROR) {
|
||||||
updateTweet();
|
updateTweet();
|
||||||
}
|
}
|
||||||
// leave editor
|
// leave editor
|
||||||
else if (type == DialogType.TWEET_EDITOR_LEAVE) {
|
else if (type == ConfirmDialog.TWEET_EDITOR_LEAVE) {
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -334,8 +333,7 @@ public class TweetEditor extends MediaActivity implements OnClickListener, OnPro
|
|||||||
*/
|
*/
|
||||||
public void onError(@Nullable ErrorHandler.TwitterError error) {
|
public void onError(@Nullable ErrorHandler.TwitterError error) {
|
||||||
String message = ErrorHandler.getErrorMessage(this, error);
|
String message = ErrorHandler.getErrorMessage(this, error);
|
||||||
confirmDialog.setMessage(message);
|
confirmDialog.show(ConfirmDialog.TWEET_EDITOR_ERROR, message);
|
||||||
confirmDialog.show(DialogType.TWEET_EDITOR_ERROR);
|
|
||||||
loadingCircle.dismiss();
|
loadingCircle.dismiss();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -344,7 +342,7 @@ public class TweetEditor extends MediaActivity implements OnClickListener, OnPro
|
|||||||
*/
|
*/
|
||||||
private void showClosingMsg() {
|
private void showClosingMsg() {
|
||||||
if (tweetText.length() > 0 || tweetUpdate.mediaCount() > 0 || tweetUpdate.hasLocation()) {
|
if (tweetText.length() > 0 || tweetUpdate.mediaCount() > 0 || tweetUpdate.hasLocation()) {
|
||||||
confirmDialog.show(DialogType.TWEET_EDITOR_LEAVE);
|
confirmDialog.show(ConfirmDialog.TWEET_EDITOR_LEAVE);
|
||||||
} else {
|
} else {
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,6 @@ import org.nuclearfog.twidda.database.GlobalSettings;
|
|||||||
import org.nuclearfog.twidda.model.Relation;
|
import org.nuclearfog.twidda.model.Relation;
|
||||||
import org.nuclearfog.twidda.model.User;
|
import org.nuclearfog.twidda.model.User;
|
||||||
import org.nuclearfog.twidda.ui.dialogs.ConfirmDialog;
|
import org.nuclearfog.twidda.ui.dialogs.ConfirmDialog;
|
||||||
import org.nuclearfog.twidda.ui.dialogs.ConfirmDialog.DialogType;
|
|
||||||
import org.nuclearfog.twidda.ui.dialogs.ConfirmDialog.OnConfirmListener;
|
import org.nuclearfog.twidda.ui.dialogs.ConfirmDialog.OnConfirmListener;
|
||||||
|
|
||||||
import java.text.NumberFormat;
|
import java.text.NumberFormat;
|
||||||
@ -361,7 +360,7 @@ public class UserProfile extends AppCompatActivity implements OnClickListener, O
|
|||||||
profileAsync = new UserAction(this, UserAction.ACTION_FOLLOW, user.getId());
|
profileAsync = new UserAction(this, UserAction.ACTION_FOLLOW, user.getId());
|
||||||
profileAsync.execute();
|
profileAsync.execute();
|
||||||
} else {
|
} else {
|
||||||
confirmDialog.show(DialogType.PROFILE_UNFOLLOW);
|
confirmDialog.show(ConfirmDialog.PROFILE_UNFOLLOW);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -372,7 +371,7 @@ public class UserProfile extends AppCompatActivity implements OnClickListener, O
|
|||||||
profileAsync = new UserAction(this, UserAction.ACTION_UNMUTE, user.getId());
|
profileAsync = new UserAction(this, UserAction.ACTION_UNMUTE, user.getId());
|
||||||
profileAsync.execute();
|
profileAsync.execute();
|
||||||
} else {
|
} else {
|
||||||
confirmDialog.show(DialogType.PROFILE_MUTE);
|
confirmDialog.show(ConfirmDialog.PROFILE_MUTE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -383,7 +382,7 @@ public class UserProfile extends AppCompatActivity implements OnClickListener, O
|
|||||||
profileAsync = new UserAction(this, UserAction.ACTION_UNBLOCK, user.getId());
|
profileAsync = new UserAction(this, UserAction.ACTION_UNBLOCK, user.getId());
|
||||||
profileAsync.execute();
|
profileAsync.execute();
|
||||||
} else {
|
} else {
|
||||||
confirmDialog.show(DialogType.PROFILE_BLOCK);
|
confirmDialog.show(ConfirmDialog.PROFILE_BLOCK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -543,20 +542,20 @@ public class UserProfile extends AppCompatActivity implements OnClickListener, O
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConfirm(DialogType type, boolean rememberChoice) {
|
public void onConfirm(int type, boolean rememberChoice) {
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
// confirmed unfollowing user
|
// confirmed unfollowing user
|
||||||
if (type == DialogType.PROFILE_UNFOLLOW) {
|
if (type == ConfirmDialog.PROFILE_UNFOLLOW) {
|
||||||
profileAsync = new UserAction(this, UserAction.ACTION_UNFOLLOW, user.getId());
|
profileAsync = new UserAction(this, UserAction.ACTION_UNFOLLOW, user.getId());
|
||||||
profileAsync.execute();
|
profileAsync.execute();
|
||||||
}
|
}
|
||||||
// confirmed blocking user
|
// confirmed blocking user
|
||||||
else if (type == DialogType.PROFILE_BLOCK) {
|
else if (type == ConfirmDialog.PROFILE_BLOCK) {
|
||||||
profileAsync = new UserAction(this, UserAction.ACTION_BLOCK, user.getId());
|
profileAsync = new UserAction(this, UserAction.ACTION_BLOCK, user.getId());
|
||||||
profileAsync.execute();
|
profileAsync.execute();
|
||||||
}
|
}
|
||||||
// confirmed muting user
|
// confirmed muting user
|
||||||
else if (type == DialogType.PROFILE_MUTE) {
|
else if (type == ConfirmDialog.PROFILE_MUTE) {
|
||||||
profileAsync = new UserAction(this, UserAction.ACTION_MUTE, user.getId());
|
profileAsync = new UserAction(this, UserAction.ACTION_MUTE, user.getId());
|
||||||
profileAsync.execute();
|
profileAsync.execute();
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,6 @@ import org.nuclearfog.twidda.backend.utils.ErrorHandler;
|
|||||||
import org.nuclearfog.twidda.database.GlobalSettings;
|
import org.nuclearfog.twidda.database.GlobalSettings;
|
||||||
import org.nuclearfog.twidda.model.UserList;
|
import org.nuclearfog.twidda.model.UserList;
|
||||||
import org.nuclearfog.twidda.ui.dialogs.ConfirmDialog;
|
import org.nuclearfog.twidda.ui.dialogs.ConfirmDialog;
|
||||||
import org.nuclearfog.twidda.ui.dialogs.ConfirmDialog.DialogType;
|
|
||||||
import org.nuclearfog.twidda.ui.dialogs.ConfirmDialog.OnConfirmListener;
|
import org.nuclearfog.twidda.ui.dialogs.ConfirmDialog.OnConfirmListener;
|
||||||
|
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
@ -224,12 +223,12 @@ public class UserlistActivity extends AppCompatActivity implements OnTabSelected
|
|||||||
}
|
}
|
||||||
// delete user list
|
// delete user list
|
||||||
else if (item.getItemId() == R.id.menu_delete_list) {
|
else if (item.getItemId() == R.id.menu_delete_list) {
|
||||||
confirmDialog.show(DialogType.LIST_DELETE);
|
confirmDialog.show(ConfirmDialog.LIST_DELETE);
|
||||||
}
|
}
|
||||||
// follow user list
|
// follow user list
|
||||||
else if (item.getItemId() == R.id.menu_follow_list) {
|
else if (item.getItemId() == R.id.menu_follow_list) {
|
||||||
if (userList.isFollowing()) {
|
if (userList.isFollowing()) {
|
||||||
confirmDialog.show(DialogType.LIST_UNFOLLOW);
|
confirmDialog.show(ConfirmDialog.LIST_UNFOLLOW);
|
||||||
} else {
|
} else {
|
||||||
listLoaderTask = new ListAction(this, userList.getId(), ListAction.FOLLOW);
|
listLoaderTask = new ListAction(this, userList.getId(), ListAction.FOLLOW);
|
||||||
listLoaderTask.execute();
|
listLoaderTask.execute();
|
||||||
@ -276,16 +275,16 @@ public class UserlistActivity extends AppCompatActivity implements OnTabSelected
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConfirm(DialogType type, boolean rememberChoice) {
|
public void onConfirm(int type, boolean rememberChoice) {
|
||||||
// delete user list
|
// delete user list
|
||||||
if (type == DialogType.LIST_DELETE) {
|
if (type == ConfirmDialog.LIST_DELETE) {
|
||||||
if (userList != null) {
|
if (userList != null) {
|
||||||
listLoaderTask = new ListAction(this, userList.getId(), ListAction.DELETE);
|
listLoaderTask = new ListAction(this, userList.getId(), ListAction.DELETE);
|
||||||
listLoaderTask.execute();
|
listLoaderTask.execute();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// unfollow user list
|
// unfollow user list
|
||||||
else if (type == DialogType.LIST_UNFOLLOW) {
|
else if (type == ConfirmDialog.LIST_UNFOLLOW) {
|
||||||
if (userList != null) {
|
if (userList != null) {
|
||||||
listLoaderTask = new ListAction(this, userList.getId(), ListAction.UNFOLLOW);
|
listLoaderTask = new ListAction(this, userList.getId(), ListAction.UNFOLLOW);
|
||||||
listLoaderTask.execute();
|
listLoaderTask.execute();
|
||||||
|
@ -25,7 +25,6 @@ import org.nuclearfog.twidda.backend.utils.AppStyles;
|
|||||||
import org.nuclearfog.twidda.backend.utils.ErrorHandler;
|
import org.nuclearfog.twidda.backend.utils.ErrorHandler;
|
||||||
import org.nuclearfog.twidda.model.UserList;
|
import org.nuclearfog.twidda.model.UserList;
|
||||||
import org.nuclearfog.twidda.ui.dialogs.ConfirmDialog;
|
import org.nuclearfog.twidda.ui.dialogs.ConfirmDialog;
|
||||||
import org.nuclearfog.twidda.ui.dialogs.ConfirmDialog.DialogType;
|
|
||||||
import org.nuclearfog.twidda.ui.dialogs.ConfirmDialog.OnConfirmListener;
|
import org.nuclearfog.twidda.ui.dialogs.ConfirmDialog.OnConfirmListener;
|
||||||
import org.nuclearfog.twidda.ui.dialogs.ProgressDialog;
|
import org.nuclearfog.twidda.ui.dialogs.ProgressDialog;
|
||||||
import org.nuclearfog.twidda.ui.dialogs.ProgressDialog.OnProgressStopListener;
|
import org.nuclearfog.twidda.ui.dialogs.ProgressDialog.OnProgressStopListener;
|
||||||
@ -119,7 +118,7 @@ public class UserlistEditor extends AppCompatActivity implements OnClickListener
|
|||||||
} else if (title.isEmpty() && descr.isEmpty()) {
|
} else if (title.isEmpty() && descr.isEmpty()) {
|
||||||
super.onBackPressed();
|
super.onBackPressed();
|
||||||
} else {
|
} else {
|
||||||
confirmDialog.show(DialogType.LIST_EDITOR_LEAVE);
|
confirmDialog.show(ConfirmDialog.LIST_EDITOR_LEAVE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -150,13 +149,13 @@ public class UserlistEditor extends AppCompatActivity implements OnClickListener
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConfirm(DialogType type, boolean rememberChoice) {
|
public void onConfirm(int type, boolean rememberChoice) {
|
||||||
// retry updating list
|
// retry updating list
|
||||||
if (type == DialogType.LIST_EDITOR_ERROR) {
|
if (type == ConfirmDialog.LIST_EDITOR_ERROR) {
|
||||||
updateList();
|
updateList();
|
||||||
}
|
}
|
||||||
// leave editor
|
// leave editor
|
||||||
else if (type == DialogType.LIST_EDITOR_LEAVE) {
|
else if (type == ConfirmDialog.LIST_EDITOR_LEAVE) {
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -185,8 +184,7 @@ public class UserlistEditor extends AppCompatActivity implements OnClickListener
|
|||||||
*/
|
*/
|
||||||
public void onError(@Nullable ErrorHandler.TwitterError err) {
|
public void onError(@Nullable ErrorHandler.TwitterError err) {
|
||||||
String message = ErrorHandler.getErrorMessage(this, err);
|
String message = ErrorHandler.getErrorMessage(this, err);
|
||||||
confirmDialog.setMessage(message);
|
confirmDialog.show(ConfirmDialog.LIST_EDITOR_ERROR, message);
|
||||||
confirmDialog.show(DialogType.LIST_EDITOR_ERROR);
|
|
||||||
loadingCircle.dismiss();
|
loadingCircle.dismiss();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,8 +41,7 @@ public class UsersActivity extends AppCompatActivity implements OnTabSelectedLis
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* type of users to get from twitter
|
* type of users to get from twitter
|
||||||
* {@link #USERLIST_FRIENDS}, {@link #USERLIST_FOLLOWER}, {@link #USERLIST_RETWEETS},
|
* {@link #USERLIST_FRIENDS,#USERLIST_FOLLOWER,#USERLIST_RETWEETS,#USERLIST_FAVORIT,#USERLIST_EXCLUDED_USERS,#USERLIST_REQUESTS}
|
||||||
* {@link #USERLIST_FAVORIT}, {@link #USERLIST_EXCLUDED_USERS} or {@link #USERLIST_REQUESTS},
|
|
||||||
*/
|
*/
|
||||||
public static final String KEY_USERDETAIL_MODE = "userlist_mode";
|
public static final String KEY_USERDETAIL_MODE = "userlist_mode";
|
||||||
|
|
||||||
|
@ -46,7 +46,6 @@ import org.nuclearfog.twidda.backend.utils.AppStyles;
|
|||||||
import org.nuclearfog.twidda.backend.utils.StringTools;
|
import org.nuclearfog.twidda.backend.utils.StringTools;
|
||||||
import org.nuclearfog.twidda.database.GlobalSettings;
|
import org.nuclearfog.twidda.database.GlobalSettings;
|
||||||
import org.nuclearfog.twidda.ui.dialogs.ConfirmDialog;
|
import org.nuclearfog.twidda.ui.dialogs.ConfirmDialog;
|
||||||
import org.nuclearfog.twidda.ui.dialogs.ConfirmDialog.DialogType;
|
|
||||||
import org.nuclearfog.twidda.ui.dialogs.ConfirmDialog.OnConfirmListener;
|
import org.nuclearfog.twidda.ui.dialogs.ConfirmDialog.OnConfirmListener;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -341,7 +340,7 @@ public class VideoViewer extends MediaActivity implements OnSeekBarChangeListene
|
|||||||
@Override
|
@Override
|
||||||
public boolean onError(MediaPlayer mp, int what, int extra) {
|
public boolean onError(MediaPlayer mp, int what, int extra) {
|
||||||
if (what == MEDIA_ERROR_UNKNOWN) {
|
if (what == MEDIA_ERROR_UNKNOWN) {
|
||||||
confirmDialog.show(DialogType.VIDEO_ERROR);
|
confirmDialog.show(ConfirmDialog.VIDEO_ERROR);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -376,8 +375,8 @@ public class VideoViewer extends MediaActivity implements OnSeekBarChangeListene
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConfirm(DialogType type, boolean rememberChoice) {
|
public void onConfirm(int type, boolean rememberChoice) {
|
||||||
if (type == DialogType.VIDEO_ERROR) {
|
if (type == ConfirmDialog.VIDEO_ERROR) {
|
||||||
Uri link = getIntent().getParcelableExtra(VIDEO_URI);
|
Uri link = getIntent().getParcelableExtra(VIDEO_URI);
|
||||||
if (link != null) {
|
if (link != null) {
|
||||||
// open link in a browser
|
// open link in a browser
|
||||||
|
@ -9,6 +9,7 @@ import android.widget.Button;
|
|||||||
import android.widget.CompoundButton;
|
import android.widget.CompoundButton;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import org.nuclearfog.twidda.R;
|
import org.nuclearfog.twidda.R;
|
||||||
@ -16,39 +17,123 @@ import org.nuclearfog.twidda.backend.utils.AppStyles;
|
|||||||
import org.nuclearfog.twidda.database.GlobalSettings;
|
import org.nuclearfog.twidda.database.GlobalSettings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* this dialog is to confirm for user action
|
* Custom alert dialog class to show error and warning messages to user
|
||||||
|
* and to ask to confirm actions
|
||||||
*
|
*
|
||||||
* @author nuclearfog
|
* @author nuclearfog
|
||||||
*/
|
*/
|
||||||
public class ConfirmDialog extends Dialog implements OnClickListener {
|
public class ConfirmDialog extends Dialog implements OnClickListener {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* types of dialogs, every dialog has its own message and title
|
* setup a proxy error dialog
|
||||||
*/
|
*/
|
||||||
public enum DialogType {
|
public static final int WRONG_PROXY = 601;
|
||||||
WRONG_PROXY,
|
|
||||||
DELETE_APP_DATA,
|
/**
|
||||||
APP_LOG_OUT,
|
* show "delete app data" dialog
|
||||||
REMOVE_ACCOUNT,
|
*/
|
||||||
PROXY_CONFIRM,
|
public static final int DELETE_APP_DATA = 602;
|
||||||
VIDEO_ERROR,
|
|
||||||
TWEET_DELETE,
|
/**
|
||||||
TWEET_EDITOR_LEAVE,
|
* show "log out" dialog
|
||||||
TWEET_EDITOR_ERROR,
|
*/
|
||||||
MESSAGE_DELETE,
|
public static final int APP_LOG_OUT = 603;
|
||||||
MESSAGE_EDITOR_LEAVE,
|
|
||||||
MESSAGE_EDITOR_ERROR,
|
/**
|
||||||
PROFILE_EDITOR_LEAVE,
|
* show "remove account" dialog
|
||||||
PROFILE_EDITOR_ERROR,
|
*/
|
||||||
PROFILE_UNFOLLOW,
|
public static final int REMOVE_ACCOUNT = 604;
|
||||||
PROFILE_BLOCK,
|
|
||||||
PROFILE_MUTE,
|
/**
|
||||||
LIST_REMOVE_USER,
|
* show "proxy bypass" dialog
|
||||||
LIST_UNFOLLOW,
|
*/
|
||||||
LIST_DELETE,
|
public static final int PROXY_CONFIRM = 605;
|
||||||
LIST_EDITOR_LEAVE,
|
|
||||||
LIST_EDITOR_ERROR
|
/**
|
||||||
}
|
* show "video error" dialog
|
||||||
|
*/
|
||||||
|
public static final int VIDEO_ERROR = 606;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* show "delete Tweet?" dialog
|
||||||
|
*/
|
||||||
|
public static final int TWEET_DELETE = 607;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* show "discard tweet" dialog
|
||||||
|
*/
|
||||||
|
public static final int TWEET_EDITOR_LEAVE = 608;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* show "Tweet create error" dialog
|
||||||
|
*/
|
||||||
|
public static final int TWEET_EDITOR_ERROR = 609;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* show "delete directmessage" dialog
|
||||||
|
*/
|
||||||
|
public static final int MESSAGE_DELETE = 610;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* show "discard directmessage" dialog
|
||||||
|
*/
|
||||||
|
public static final int MESSAGE_EDITOR_LEAVE = 611;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* show "directmessage upload" error
|
||||||
|
*/
|
||||||
|
public static final int MESSAGE_EDITOR_ERROR = 612;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* show "discard profile changes" dialog
|
||||||
|
*/
|
||||||
|
public static final int PROFILE_EDITOR_LEAVE = 613;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* show "error profile update" dialog
|
||||||
|
*/
|
||||||
|
public static final int PROFILE_EDITOR_ERROR = 614;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* show "unfollow user" dialog
|
||||||
|
*/
|
||||||
|
public static final int PROFILE_UNFOLLOW = 615;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* show "block user" dialog
|
||||||
|
*/
|
||||||
|
public static final int PROFILE_BLOCK = 616;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* show "mute user" dialog
|
||||||
|
*/
|
||||||
|
public static final int PROFILE_MUTE = 617;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* show "remove user from list" dialog
|
||||||
|
*/
|
||||||
|
public static final int LIST_REMOVE_USER = 618;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* show "unfollow userlist" dialog
|
||||||
|
*/
|
||||||
|
public static final int LIST_UNFOLLOW = 619;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* show "delete userlsit" dialog
|
||||||
|
*/
|
||||||
|
public static final int LIST_DELETE = 620;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* show "discard changes" dialog
|
||||||
|
*/
|
||||||
|
public static final int LIST_EDITOR_LEAVE = 621;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* show "update userlist error" dialog
|
||||||
|
*/
|
||||||
|
public static final int LIST_EDITOR_ERROR = 622;
|
||||||
|
|
||||||
|
|
||||||
private TextView title, message, confirmDescr;
|
private TextView title, message, confirmDescr;
|
||||||
private CompoundButton confirmCheck;
|
private CompoundButton confirmCheck;
|
||||||
@ -83,61 +168,73 @@ public class ConfirmDialog extends Dialog implements OnClickListener {
|
|||||||
*
|
*
|
||||||
* @param type Type of dialog to show
|
* @param type Type of dialog to show
|
||||||
*/
|
*/
|
||||||
public void show(DialogType type) {
|
public void show(int type) {
|
||||||
|
show(type, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* creates an alert dialog
|
||||||
|
*
|
||||||
|
* @param type Type of dialog to show
|
||||||
|
* @param messageTxt override default message text
|
||||||
|
*/
|
||||||
|
public void show(int type, @NonNull String messageTxt) {
|
||||||
if (isShowing())
|
if (isShowing())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// attach type to the view
|
// attach type to the view
|
||||||
confirm.setTag(type);
|
confirm.setTag(type);
|
||||||
|
|
||||||
// default values
|
// default visibility values
|
||||||
int titleVis = View.GONE;
|
int titleVis = View.GONE;
|
||||||
int titleTxt = R.string.info_error;
|
|
||||||
int messageTxt = R.string.confirm_unknown_error;
|
|
||||||
int confirmTxt = android.R.string.ok;
|
|
||||||
int confirmIcon = R.drawable.check;
|
|
||||||
int confirmVis = View.INVISIBLE;
|
int confirmVis = View.INVISIBLE;
|
||||||
int cancelTxt = android.R.string.cancel;
|
|
||||||
int cancelIcon = R.drawable.cross;
|
|
||||||
int cancelVis = View.VISIBLE;
|
int cancelVis = View.VISIBLE;
|
||||||
|
|
||||||
|
// default resource values
|
||||||
|
int titleRes = R.string.info_error;
|
||||||
|
int messageRes = R.string.confirm_unknown_error;
|
||||||
|
int confirmRes = android.R.string.ok;
|
||||||
|
int confirmIconRes = R.drawable.check;
|
||||||
|
int cancelRes = android.R.string.cancel;
|
||||||
|
int cancelIconRes = R.drawable.cross;
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case MESSAGE_DELETE:
|
case MESSAGE_DELETE:
|
||||||
messageTxt = R.string.confirm_delete_message;
|
messageRes = R.string.confirm_delete_message;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WRONG_PROXY:
|
case WRONG_PROXY:
|
||||||
titleVis = View.VISIBLE;
|
titleVis = View.VISIBLE;
|
||||||
messageTxt = R.string.error_wrong_connection_settings;
|
messageRes = R.string.error_wrong_connection_settings;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DELETE_APP_DATA:
|
case DELETE_APP_DATA:
|
||||||
messageTxt = R.string.confirm_delete_database;
|
messageRes = R.string.confirm_delete_database;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case APP_LOG_OUT:
|
case APP_LOG_OUT:
|
||||||
messageTxt = R.string.confirm_log_lout;
|
messageRes = R.string.confirm_log_lout;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VIDEO_ERROR:
|
case VIDEO_ERROR:
|
||||||
titleVis = View.VISIBLE;
|
titleVis = View.VISIBLE;
|
||||||
messageTxt = R.string.error_cant_load_video;
|
messageRes = R.string.error_cant_load_video;
|
||||||
confirmIcon = 0;
|
confirmIconRes = 0;
|
||||||
confirmTxt = R.string.confirm_open_link;
|
confirmRes = R.string.confirm_open_link;
|
||||||
cancelVis = View.GONE;
|
cancelVis = View.GONE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LIST_EDITOR_LEAVE:
|
case LIST_EDITOR_LEAVE:
|
||||||
case PROFILE_EDITOR_LEAVE:
|
case PROFILE_EDITOR_LEAVE:
|
||||||
messageTxt = R.string.confirm_discard;
|
messageRes = R.string.confirm_discard;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TWEET_EDITOR_LEAVE:
|
case TWEET_EDITOR_LEAVE:
|
||||||
messageTxt = R.string.confirm_cancel_tweet;
|
messageRes = R.string.confirm_cancel_tweet;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MESSAGE_EDITOR_LEAVE:
|
case MESSAGE_EDITOR_LEAVE:
|
||||||
messageTxt = R.string.confirm_cancel_message;
|
messageRes = R.string.confirm_cancel_message;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LIST_EDITOR_ERROR:
|
case LIST_EDITOR_ERROR:
|
||||||
@ -145,62 +242,66 @@ public class ConfirmDialog extends Dialog implements OnClickListener {
|
|||||||
case TWEET_EDITOR_ERROR:
|
case TWEET_EDITOR_ERROR:
|
||||||
case PROFILE_EDITOR_ERROR:
|
case PROFILE_EDITOR_ERROR:
|
||||||
titleVis = View.VISIBLE;
|
titleVis = View.VISIBLE;
|
||||||
messageTxt = R.string.error_connection_failed;
|
messageRes = R.string.error_connection_failed;
|
||||||
confirmTxt = R.string.confirm_retry_button;
|
confirmRes = R.string.confirm_retry_button;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TWEET_DELETE:
|
case TWEET_DELETE:
|
||||||
messageTxt = R.string.confirm_delete_tweet;
|
messageRes = R.string.confirm_delete_tweet;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PROFILE_UNFOLLOW:
|
case PROFILE_UNFOLLOW:
|
||||||
messageTxt = R.string.confirm_unfollow;
|
messageRes = R.string.confirm_unfollow;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PROFILE_BLOCK:
|
case PROFILE_BLOCK:
|
||||||
messageTxt = R.string.confirm_block;
|
messageRes = R.string.confirm_block;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PROFILE_MUTE:
|
case PROFILE_MUTE:
|
||||||
messageTxt = R.string.confirm_mute;
|
messageRes = R.string.confirm_mute;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LIST_REMOVE_USER:
|
case LIST_REMOVE_USER:
|
||||||
messageTxt = R.string.confirm_remove_user_from_list;
|
messageRes = R.string.confirm_remove_user_from_list;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LIST_UNFOLLOW:
|
case LIST_UNFOLLOW:
|
||||||
messageTxt = R.string.confirm_unfollow_list;
|
messageRes = R.string.confirm_unfollow_list;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LIST_DELETE:
|
case LIST_DELETE:
|
||||||
messageTxt = R.string.confirm_delete_list;
|
messageRes = R.string.confirm_delete_list;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case REMOVE_ACCOUNT:
|
case REMOVE_ACCOUNT:
|
||||||
messageTxt = R.string.confirm_remove_account;
|
messageRes = R.string.confirm_remove_account;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PROXY_CONFIRM:
|
case PROXY_CONFIRM:
|
||||||
confirmVis = View.VISIBLE;
|
confirmVis = View.VISIBLE;
|
||||||
titleVis = View.VISIBLE;
|
titleVis = View.VISIBLE;
|
||||||
titleTxt = R.string.dialog_confirm_warning;
|
titleRes = R.string.dialog_confirm_warning;
|
||||||
messageTxt = R.string.dialog_warning_videoview;
|
messageRes = R.string.dialog_warning_videoview;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
title.setVisibility(titleVis);
|
title.setVisibility(titleVis);
|
||||||
title.setText(titleTxt);
|
title.setText(titleRes);
|
||||||
message.setText(messageTxt);
|
|
||||||
|
|
||||||
cancel.setVisibility(cancelVis);
|
cancel.setVisibility(cancelVis);
|
||||||
cancel.setText(cancelTxt);
|
cancel.setText(cancelRes);
|
||||||
cancel.setCompoundDrawablesWithIntrinsicBounds(cancelIcon, 0, 0, 0);
|
cancel.setCompoundDrawablesWithIntrinsicBounds(cancelIconRes, 0, 0, 0);
|
||||||
|
|
||||||
confirmCheck.setVisibility(confirmVis);
|
confirmCheck.setVisibility(confirmVis);
|
||||||
confirmDescr.setVisibility(confirmVis);
|
confirmDescr.setVisibility(confirmVis);
|
||||||
|
|
||||||
confirm.setText(confirmTxt);
|
confirm.setText(confirmRes);
|
||||||
confirm.setCompoundDrawablesWithIntrinsicBounds(confirmIcon, 0, 0, 0);
|
confirm.setCompoundDrawablesWithIntrinsicBounds(confirmIconRes, 0, 0, 0);
|
||||||
|
|
||||||
|
if (messageTxt.isEmpty())
|
||||||
|
message.setText(messageRes);
|
||||||
|
else
|
||||||
|
message.setText(messageTxt);
|
||||||
|
|
||||||
super.show();
|
super.show();
|
||||||
}
|
}
|
||||||
@ -210,8 +311,8 @@ public class ConfirmDialog extends Dialog implements OnClickListener {
|
|||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
if (v.getId() == R.id.confirm_yes) {
|
if (v.getId() == R.id.confirm_yes) {
|
||||||
Object tag = v.getTag();
|
Object tag = v.getTag();
|
||||||
if (listener != null && tag instanceof DialogType) {
|
if (listener != null && tag instanceof Integer) {
|
||||||
DialogType type = (DialogType) tag;
|
int type = (int) tag;
|
||||||
boolean remember = confirmCheck.getVisibility() == View.VISIBLE && confirmCheck.isChecked();
|
boolean remember = confirmCheck.getVisibility() == View.VISIBLE && confirmCheck.isChecked();
|
||||||
listener.onConfirm(type, remember);
|
listener.onConfirm(type, remember);
|
||||||
}
|
}
|
||||||
@ -228,15 +329,6 @@ public class ConfirmDialog extends Dialog implements OnClickListener {
|
|||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* set message text
|
|
||||||
*
|
|
||||||
* @param message message text
|
|
||||||
*/
|
|
||||||
public void setMessage(String message) {
|
|
||||||
this.message.setText(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Alert dialog listener
|
* Alert dialog listener
|
||||||
*/
|
*/
|
||||||
@ -244,10 +336,9 @@ public class ConfirmDialog extends Dialog implements OnClickListener {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* called when the positive button was clicked
|
* called when the positive button was clicked
|
||||||
*
|
* @param type type of dialog
|
||||||
* @param type type of dialog
|
|
||||||
* @param rememberChoice true if choice should be remembered
|
* @param rememberChoice true if choice should be remembered
|
||||||
*/
|
*/
|
||||||
void onConfirm(DialogType type, boolean rememberChoice);
|
void onConfirm(int type, boolean rememberChoice);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,7 +1,6 @@
|
|||||||
package org.nuclearfog.twidda.ui.fragments;
|
package org.nuclearfog.twidda.ui.fragments;
|
||||||
|
|
||||||
import static android.os.AsyncTask.Status.RUNNING;
|
import static android.os.AsyncTask.Status.RUNNING;
|
||||||
import static org.nuclearfog.twidda.ui.dialogs.ConfirmDialog.DialogType;
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -101,14 +100,14 @@ public class AccountFragment extends ListFragment implements OnAccountClickListe
|
|||||||
public void onAccountRemove(Account account) {
|
public void onAccountRemove(Account account) {
|
||||||
if (!dialog.isShowing()) {
|
if (!dialog.isShowing()) {
|
||||||
selection = account;
|
selection = account;
|
||||||
dialog.show(DialogType.REMOVE_ACCOUNT);
|
dialog.show(ConfirmDialog.REMOVE_ACCOUNT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConfirm(DialogType type, boolean rememberChoice) {
|
public void onConfirm(int type, boolean rememberChoice) {
|
||||||
if (type == DialogType.REMOVE_ACCOUNT) {
|
if (type == ConfirmDialog.REMOVE_ACCOUNT) {
|
||||||
loginTask = new AccountLoader(this);
|
loginTask = new AccountLoader(this);
|
||||||
loginTask.execute(selection);
|
loginTask.execute(selection);
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,6 @@ import org.nuclearfog.twidda.ui.activities.SearchActivity;
|
|||||||
import org.nuclearfog.twidda.ui.activities.TweetActivity;
|
import org.nuclearfog.twidda.ui.activities.TweetActivity;
|
||||||
import org.nuclearfog.twidda.ui.activities.UserProfile;
|
import org.nuclearfog.twidda.ui.activities.UserProfile;
|
||||||
import org.nuclearfog.twidda.ui.dialogs.ConfirmDialog;
|
import org.nuclearfog.twidda.ui.dialogs.ConfirmDialog;
|
||||||
import org.nuclearfog.twidda.ui.dialogs.ConfirmDialog.DialogType;
|
|
||||||
import org.nuclearfog.twidda.ui.dialogs.ConfirmDialog.OnConfirmListener;
|
import org.nuclearfog.twidda.ui.dialogs.ConfirmDialog.OnConfirmListener;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -130,7 +129,7 @@ public class MessageFragment extends ListFragment implements OnMessageClickListe
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DirectMessage message, Action action) {
|
public void onClick(DirectMessage message, int action) {
|
||||||
if (!isRefreshing()) {
|
if (!isRefreshing()) {
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case ANSWER:
|
case ANSWER:
|
||||||
@ -142,7 +141,7 @@ public class MessageFragment extends ListFragment implements OnMessageClickListe
|
|||||||
case DELETE:
|
case DELETE:
|
||||||
if (!confirmDialog.isShowing() && messageTask != null && messageTask.getStatus() != RUNNING) {
|
if (!confirmDialog.isShowing() && messageTask != null && messageTask.getStatus() != RUNNING) {
|
||||||
deleteId = message.getId();
|
deleteId = message.getId();
|
||||||
confirmDialog.show(DialogType.MESSAGE_DELETE);
|
confirmDialog.show(ConfirmDialog.MESSAGE_DELETE);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -176,8 +175,8 @@ public class MessageFragment extends ListFragment implements OnMessageClickListe
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConfirm(DialogType type, boolean rememberChoice) {
|
public void onConfirm(int type, boolean rememberChoice) {
|
||||||
if (type == DialogType.MESSAGE_DELETE) {
|
if (type == ConfirmDialog.MESSAGE_DELETE) {
|
||||||
if (messageTask != null && messageTask.getStatus() != RUNNING) {
|
if (messageTask != null && messageTask.getStatus() != RUNNING) {
|
||||||
messageTask = new MessageLoader(this, MessageLoader.DEL, null, deleteId);
|
messageTask = new MessageLoader(this, MessageLoader.DEL, null, deleteId);
|
||||||
messageTask.execute();
|
messageTask.execute();
|
||||||
|
@ -28,8 +28,7 @@ public class TweetFragment extends ListFragment implements TweetClickListener {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Key to define what type of tweets should be loaded
|
* Key to define what type of tweets should be loaded
|
||||||
* possible values are {@link #TWEET_FRAG_HOME}, {@link #TWEET_FRAG_MENT}, {@link #TWEET_FRAG_TWEETS}, {@link #TWEET_FRAG_FAVORS}
|
* possible values are {@link #TWEET_FRAG_HOME,#TWEET_FRAG_MENT,#TWEET_FRAG_TWEETS,#TWEET_FRAG_FAVORS,#TWEET_FRAG_ANSWER,#TWEET_FRAG_SEARCH,#TWEET_FRAG_LIST}
|
||||||
* {@link #TWEET_FRAG_ANSWER}, {@link #TWEET_FRAG_SEARCH}, {@link #TWEET_FRAG_LIST}
|
|
||||||
*/
|
*/
|
||||||
public static final String KEY_FRAG_TWEET_MODE = "tweet_mode";
|
public static final String KEY_FRAG_TWEET_MODE = "tweet_mode";
|
||||||
|
|
||||||
|
@ -24,7 +24,6 @@ import org.nuclearfog.twidda.backend.utils.ErrorHandler;
|
|||||||
import org.nuclearfog.twidda.model.User;
|
import org.nuclearfog.twidda.model.User;
|
||||||
import org.nuclearfog.twidda.ui.activities.UserProfile;
|
import org.nuclearfog.twidda.ui.activities.UserProfile;
|
||||||
import org.nuclearfog.twidda.ui.dialogs.ConfirmDialog;
|
import org.nuclearfog.twidda.ui.dialogs.ConfirmDialog;
|
||||||
import org.nuclearfog.twidda.ui.dialogs.ConfirmDialog.DialogType;
|
|
||||||
import org.nuclearfog.twidda.ui.dialogs.ConfirmDialog.OnConfirmListener;
|
import org.nuclearfog.twidda.ui.dialogs.ConfirmDialog.OnConfirmListener;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -36,10 +35,10 @@ public class UserFragment extends ListFragment implements UserClickListener, OnC
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* key to set the type of user list to show
|
* key to set the type of user list to show
|
||||||
* possible value types are {@link #USER_FRAG_FOLLOWER}, {@link #USER_FRAG_FOLLOWING}, {@link #USER_FRAG_RETWEET},
|
* possible value types are
|
||||||
* {@link #USER_FRAG_FAVORIT}, {@link #USER_FRAG_FAVORIT}, {@link #USER_FRAG_SEARCH}, {@link #USER_FRAG_LIST_SUBSCRIBER},
|
* {@link #USER_FRAG_FOLLOWER,#USER_FRAG_FOLLOWING,#USER_FRAG_RETWEET,#USER_FRAG_FAVORIT},
|
||||||
* {@link #USER_FRAG_LIST_MEMBERS}, {@link #USER_FRAG_BLOCKED_USERS}, {@link #USER_FRAG_MUTED_USERS},
|
* {@link #USER_FRAG_SEARCH,#USER_FRAG_LIST_SUBSCRIBER,#USER_FRAG_LIST_MEMBERS,#USER_FRAG_BLOCKED_USERS},
|
||||||
* {@link #USER_FRAG_FOLLOW_INCOMING} and {@link #USER_FRAG_FOLLOW_OUTGOING}
|
* {@link #USER_FRAG_MUTED_USERS,#USER_FRAG_FOLLOW_INCOMING,#USER_FRAG_FOLLOW_OUTGOING}
|
||||||
*/
|
*/
|
||||||
public static final String KEY_FRAG_USER_MODE = "user_mode";
|
public static final String KEY_FRAG_USER_MODE = "user_mode";
|
||||||
|
|
||||||
@ -244,14 +243,14 @@ public class UserFragment extends ListFragment implements UserClickListener, OnC
|
|||||||
public void onDelete(String name) {
|
public void onDelete(String name) {
|
||||||
if (!confirmDialog.isShowing()) {
|
if (!confirmDialog.isShowing()) {
|
||||||
deleteUserName = name;
|
deleteUserName = name;
|
||||||
confirmDialog.show(DialogType.LIST_REMOVE_USER);
|
confirmDialog.show(ConfirmDialog.LIST_REMOVE_USER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConfirm(DialogType type, boolean rememberChoice) {
|
public void onConfirm(int type, boolean rememberChoice) {
|
||||||
if (type == DialogType.LIST_REMOVE_USER) {
|
if (type == ConfirmDialog.LIST_REMOVE_USER) {
|
||||||
if (listTask == null || listTask.getStatus() != RUNNING) {
|
if (listTask == null || listTask.getStatus() != RUNNING) {
|
||||||
listTask = new ListManager(requireContext(), id, ListManager.DEL_USER, deleteUserName, this);
|
listTask = new ListManager(requireContext(), id, ListManager.DEL_USER, deleteUserName, this);
|
||||||
listTask.execute();
|
listTask.execute();
|
||||||
|
@ -44,7 +44,7 @@ public class UserListFragment extends ListFragment implements ListClickListener
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* key to define the type of the list
|
* key to define the type of the list
|
||||||
* {@link #LIST_USER_OWNS} or {@link #LIST_USER_SUBSCR_TO}
|
* {@link #LIST_USER_OWNS,#LIST_USER_SUBSCR_TO}
|
||||||
*/
|
*/
|
||||||
public static final String KEY_FRAG_LIST_LIST_TYPE = "list_type";
|
public static final String KEY_FRAG_LIST_LIST_TYPE = "list_type";
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user