added a new key
This commit is contained in:
parent
8c110aeced
commit
5e62ad8508
|
@ -29,228 +29,226 @@ import org.mariotaku.twidere.constant.SharedPreferenceConstants;
|
|||
*/
|
||||
public interface TwidereConstants extends SharedPreferenceConstants, IntentConstants {
|
||||
|
||||
public static final String TWIDERE_APP_NAME = "Twidere";
|
||||
public static final String TWIDERE_PACKAGE_NAME = "org.mariotaku.twidere";
|
||||
public static final String TWIDERE_PROJECT_URL = "https://github.com/mariotaku/twidere";
|
||||
public static final String TWIDERE_PROJECT_EMAIL = "twidere.project@gmail.com";
|
||||
String TWIDERE_APP_NAME = "Twidere";
|
||||
String TWIDERE_PACKAGE_NAME = "org.mariotaku.twidere";
|
||||
String TWIDERE_PROJECT_URL = "https://github.com/mariotaku/twidere";
|
||||
String TWIDERE_PROJECT_EMAIL = "twidere.project@gmail.com";
|
||||
|
||||
public static final String LOGTAG = TWIDERE_APP_NAME;
|
||||
String LOGTAG = TWIDERE_APP_NAME;
|
||||
|
||||
public static final String USER_NICKNAME_PREFERENCES_NAME = "user_nicknames";
|
||||
public static final String USER_COLOR_PREFERENCES_NAME = "user_colors";
|
||||
public static final String HOST_MAPPING_PREFERENCES_NAME = "host_mapping";
|
||||
public static final String MESSAGE_DRAFTS_PREFERENCES_NAME = "message_drafts";
|
||||
public static final String SHARED_PREFERENCES_NAME = "preferences";
|
||||
public static final String PERMISSION_PREFERENCES_NAME = "app_permissions";
|
||||
public static final String SILENT_NOTIFICATIONS_PREFERENCE_NAME = "silent_notifications";
|
||||
public static final String TIMELINE_POSITIONS_PREFERENCES_NAME = "timeline_positions";
|
||||
public static final String ACCOUNT_PREFERENCES_NAME_PREFIX = "account_preferences_";
|
||||
public static final String KEYBOARD_SHORTCUTS_PREFERENCES_NAME = "keyboard_shortcuts_preferences";
|
||||
String USER_NICKNAME_PREFERENCES_NAME = "user_nicknames";
|
||||
String USER_COLOR_PREFERENCES_NAME = "user_colors";
|
||||
String HOST_MAPPING_PREFERENCES_NAME = "host_mapping";
|
||||
String MESSAGE_DRAFTS_PREFERENCES_NAME = "message_drafts";
|
||||
String SHARED_PREFERENCES_NAME = "preferences";
|
||||
String PERMISSION_PREFERENCES_NAME = "app_permissions";
|
||||
String SILENT_NOTIFICATIONS_PREFERENCE_NAME = "silent_notifications";
|
||||
String TIMELINE_POSITIONS_PREFERENCES_NAME = "timeline_positions";
|
||||
String ACCOUNT_PREFERENCES_NAME_PREFIX = "account_preferences_";
|
||||
String KEYBOARD_SHORTCUTS_PREFERENCES_NAME = "keyboard_shortcuts_preferences";
|
||||
|
||||
public static final String TWITTER_CONSUMER_KEY = "uAFVpMhBntJutfVj6abfA";
|
||||
public static final String TWITTER_CONSUMER_SECRET = "JARXkJTfxo0F8MyctYy9bUmrLISjo8vXAHsZHYuk2E";
|
||||
public static final String TWITTER_CONSUMER_KEY_2 = "UyaS0xmUQXKiJ48vZP4dXQ";
|
||||
public static final String TWITTER_CONSUMER_SECRET_2 = "QlYVMWA751Dl5yNve41CNEN46GV4nxk57FmLeAXAV0";
|
||||
public static final String TWITTER_CONSUMER_KEY_3 = "YljS7Zmbw3JkouhZkxCINAsn6";
|
||||
public static final String TWITTER_CONSUMER_SECRET_3 = "AYrXN6eAJ3Luf9o5zS4Flq2bSBhrB6A9eioI8JENRx8HMh9YuS";
|
||||
String TWITTER_CONSUMER_KEY_LEGACY = "uAFVpMhBntJutfVj6abfA";
|
||||
String TWITTER_CONSUMER_SECRET_LEGACY = "JARXkJTfxo0F8MyctYy9bUmrLISjo8vXAHsZHYuk2E";
|
||||
String TWITTER_CONSUMER_KEY = "YVROlQkXFvkPfH3jcFaR4A";
|
||||
String TWITTER_CONSUMER_SECRET = "0UnEHDq5IzVK9nstiz2nWOtG5rOMM5JkUpATfM78Do";
|
||||
|
||||
public static final String SCHEME_HTTP = "http";
|
||||
public static final String SCHEME_HTTPS = "https";
|
||||
public static final String SCHEME_CONTENT = "content";
|
||||
public static final String SCHEME_TWIDERE = "twidere";
|
||||
String SCHEME_HTTP = "http";
|
||||
String SCHEME_HTTPS = "https";
|
||||
String SCHEME_CONTENT = "content";
|
||||
String SCHEME_TWIDERE = "twidere";
|
||||
|
||||
public static final String PROTOCOL_HTTP = SCHEME_HTTP + "://";
|
||||
public static final String PROTOCOL_HTTPS = SCHEME_HTTPS + "://";
|
||||
public static final String PROTOCOL_CONTENT = SCHEME_CONTENT + "://";
|
||||
public static final String PROTOCOL_TWIDERE = SCHEME_TWIDERE + "://";
|
||||
String PROTOCOL_HTTP = SCHEME_HTTP + "://";
|
||||
String PROTOCOL_HTTPS = SCHEME_HTTPS + "://";
|
||||
String PROTOCOL_CONTENT = SCHEME_CONTENT + "://";
|
||||
String PROTOCOL_TWIDERE = SCHEME_TWIDERE + "://";
|
||||
|
||||
public static final String AUTHORITY_USER = "user";
|
||||
public static final String AUTHORITY_HOME = "home";
|
||||
public static final String AUTHORITY_MENTIONS = "mentions";
|
||||
public static final String AUTHORITY_DIRECT_MESSAGES = "direct_messages";
|
||||
public static final String AUTHORITY_USERS = "users";
|
||||
public static final String AUTHORITY_USER_TIMELINE = "user_timeline";
|
||||
public static final String AUTHORITY_USER_MEDIA_TIMELINE = "user_media_timeline";
|
||||
public static final String AUTHORITY_USER_FAVORITES = "user_favorites";
|
||||
public static final String AUTHORITY_USER_FOLLOWERS = "user_followers";
|
||||
public static final String AUTHORITY_USER_FRIENDS = "user_friends";
|
||||
public static final String AUTHORITY_USER_BLOCKS = "user_blocks";
|
||||
public static final String AUTHORITY_STATUS = "status";
|
||||
public static final String AUTHORITY_STATUSES = "statuses";
|
||||
public static final String AUTHORITY_DIRECT_MESSAGES_CONVERSATION = "direct_messages_conversation";
|
||||
public static final String AUTHORITY_SEARCH = "search";
|
||||
public static final String AUTHORITY_MAP = "map";
|
||||
public static final String AUTHORITY_USER_LIST = "user_list";
|
||||
public static final String AUTHORITY_USER_LIST_TIMELINE = "user_list_timeline";
|
||||
public static final String AUTHORITY_USER_LIST_MEMBERS = "user_list_members";
|
||||
public static final String AUTHORITY_USER_LIST_SUBSCRIBERS = "user_list_subscribers";
|
||||
public static final String AUTHORITY_USER_LIST_MEMBERSHIPS = "user_list_memberships";
|
||||
public static final String AUTHORITY_USER_LISTS = "user_lists";
|
||||
public static final String AUTHORITY_USERS_RETWEETED_STATUS = "users_retweeted_status";
|
||||
public static final String AUTHORITY_SAVED_SEARCHES = "saved_searches";
|
||||
public static final String AUTHORITY_SEARCH_USERS = "search_users";
|
||||
public static final String AUTHORITY_SEARCH_TWEETS = "search_tweets";
|
||||
public static final String AUTHORITY_TRENDS = "trends";
|
||||
public static final String AUTHORITY_USER_MENTIONS = "user_mentions";
|
||||
public static final String AUTHORITY_ACTIVITIES_ABOUT_ME = "activities_about_me";
|
||||
public static final String AUTHORITY_ACTIVITIES_BY_FRIENDS = "activities_by_friends";
|
||||
public static final String AUTHORITY_INCOMING_FRIENDSHIPS = "incoming_friendships";
|
||||
public static final String AUTHORITY_STATUS_RETWEETERS = "status_retweeters";
|
||||
public static final String AUTHORITY_STATUS_FAVORITERS = "status_favoriters";
|
||||
public static final String AUTHORITY_STATUS_REPLIES = "status_replies";
|
||||
public static final String AUTHORITY_RETWEETS_OF_ME = "retweets_of_me";
|
||||
public static final String AUTHORITY_MUTES_USERS = "mutes_users";
|
||||
public static final String AUTHORITY_NOTIFICATIONS = "notifications";
|
||||
public static final String AUTHORITY_ACCOUNTS = "accounts";
|
||||
public static final String AUTHORITY_DRAFTS = "drafts";
|
||||
public static final String AUTHORITY_FILTERS = "filters";
|
||||
public static final String AUTHORITY_PROFILE_EDITOR = "profile_editor";
|
||||
String AUTHORITY_USER = "user";
|
||||
String AUTHORITY_HOME = "home";
|
||||
String AUTHORITY_MENTIONS = "mentions";
|
||||
String AUTHORITY_DIRECT_MESSAGES = "direct_messages";
|
||||
String AUTHORITY_USERS = "users";
|
||||
String AUTHORITY_USER_TIMELINE = "user_timeline";
|
||||
String AUTHORITY_USER_MEDIA_TIMELINE = "user_media_timeline";
|
||||
String AUTHORITY_USER_FAVORITES = "user_favorites";
|
||||
String AUTHORITY_USER_FOLLOWERS = "user_followers";
|
||||
String AUTHORITY_USER_FRIENDS = "user_friends";
|
||||
String AUTHORITY_USER_BLOCKS = "user_blocks";
|
||||
String AUTHORITY_STATUS = "status";
|
||||
String AUTHORITY_STATUSES = "statuses";
|
||||
String AUTHORITY_DIRECT_MESSAGES_CONVERSATION = "direct_messages_conversation";
|
||||
String AUTHORITY_SEARCH = "search";
|
||||
String AUTHORITY_MAP = "map";
|
||||
String AUTHORITY_USER_LIST = "user_list";
|
||||
String AUTHORITY_USER_LIST_TIMELINE = "user_list_timeline";
|
||||
String AUTHORITY_USER_LIST_MEMBERS = "user_list_members";
|
||||
String AUTHORITY_USER_LIST_SUBSCRIBERS = "user_list_subscribers";
|
||||
String AUTHORITY_USER_LIST_MEMBERSHIPS = "user_list_memberships";
|
||||
String AUTHORITY_USER_LISTS = "user_lists";
|
||||
String AUTHORITY_USERS_RETWEETED_STATUS = "users_retweeted_status";
|
||||
String AUTHORITY_SAVED_SEARCHES = "saved_searches";
|
||||
String AUTHORITY_SEARCH_USERS = "search_users";
|
||||
String AUTHORITY_SEARCH_TWEETS = "search_tweets";
|
||||
String AUTHORITY_TRENDS = "trends";
|
||||
String AUTHORITY_USER_MENTIONS = "user_mentions";
|
||||
String AUTHORITY_ACTIVITIES_ABOUT_ME = "activities_about_me";
|
||||
String AUTHORITY_ACTIVITIES_BY_FRIENDS = "activities_by_friends";
|
||||
String AUTHORITY_INCOMING_FRIENDSHIPS = "incoming_friendships";
|
||||
String AUTHORITY_STATUS_RETWEETERS = "status_retweeters";
|
||||
String AUTHORITY_STATUS_FAVORITERS = "status_favoriters";
|
||||
String AUTHORITY_STATUS_REPLIES = "status_replies";
|
||||
String AUTHORITY_RETWEETS_OF_ME = "retweets_of_me";
|
||||
String AUTHORITY_MUTES_USERS = "mutes_users";
|
||||
String AUTHORITY_NOTIFICATIONS = "notifications";
|
||||
String AUTHORITY_ACCOUNTS = "accounts";
|
||||
String AUTHORITY_DRAFTS = "drafts";
|
||||
String AUTHORITY_FILTERS = "filters";
|
||||
String AUTHORITY_PROFILE_EDITOR = "profile_editor";
|
||||
|
||||
public static final String QUERY_PARAM_ACCOUNT_ID = "account_id";
|
||||
public static final String QUERY_PARAM_ACCOUNT_IDS = "account_ids";
|
||||
public static final String QUERY_PARAM_ACCOUNT_NAME = "account_name";
|
||||
public static final String QUERY_PARAM_STATUS_ID = "status_id";
|
||||
public static final String QUERY_PARAM_USER_ID = "user_id";
|
||||
public static final String QUERY_PARAM_LIST_ID = "list_id";
|
||||
public static final String QUERY_PARAM_SCREEN_NAME = "screen_name";
|
||||
public static final String QUERY_PARAM_LIST_NAME = "list_name";
|
||||
public static final String QUERY_PARAM_QUERY = "query";
|
||||
public static final String QUERY_PARAM_TYPE = "type";
|
||||
public static final String QUERY_PARAM_VALUE_USERS = "users";
|
||||
public static final String QUERY_PARAM_VALUE_TWEETS = "tweets";
|
||||
public static final String QUERY_PARAM_NOTIFY = "notify";
|
||||
public static final String QUERY_PARAM_LAT = "lat";
|
||||
public static final String QUERY_PARAM_LNG = "lng";
|
||||
public static final String QUERY_PARAM_URL = "url";
|
||||
public static final String QUERY_PARAM_NAME = "name";
|
||||
public static final String QUERY_PARAM_FINISH_ONLY = "finish_only";
|
||||
public static final String QUERY_PARAM_NEW_ITEMS_COUNT = "new_items_count";
|
||||
public static final String QUERY_PARAM_RECIPIENT_ID = "recipient_id";
|
||||
public static final String QUERY_PARAM_READ_POSITION = "param_read_position";
|
||||
public static final String QUERY_PARAM_READ_POSITIONS = "param_read_positions";
|
||||
String QUERY_PARAM_ACCOUNT_ID = "account_id";
|
||||
String QUERY_PARAM_ACCOUNT_IDS = "account_ids";
|
||||
String QUERY_PARAM_ACCOUNT_NAME = "account_name";
|
||||
String QUERY_PARAM_STATUS_ID = "status_id";
|
||||
String QUERY_PARAM_USER_ID = "user_id";
|
||||
String QUERY_PARAM_LIST_ID = "list_id";
|
||||
String QUERY_PARAM_SCREEN_NAME = "screen_name";
|
||||
String QUERY_PARAM_LIST_NAME = "list_name";
|
||||
String QUERY_PARAM_QUERY = "query";
|
||||
String QUERY_PARAM_TYPE = "type";
|
||||
String QUERY_PARAM_VALUE_USERS = "users";
|
||||
String QUERY_PARAM_VALUE_TWEETS = "tweets";
|
||||
String QUERY_PARAM_NOTIFY = "notify";
|
||||
String QUERY_PARAM_LAT = "lat";
|
||||
String QUERY_PARAM_LNG = "lng";
|
||||
String QUERY_PARAM_URL = "url";
|
||||
String QUERY_PARAM_NAME = "name";
|
||||
String QUERY_PARAM_FINISH_ONLY = "finish_only";
|
||||
String QUERY_PARAM_NEW_ITEMS_COUNT = "new_items_count";
|
||||
String QUERY_PARAM_RECIPIENT_ID = "recipient_id";
|
||||
String QUERY_PARAM_READ_POSITION = "param_read_position";
|
||||
String QUERY_PARAM_READ_POSITIONS = "param_read_positions";
|
||||
|
||||
public static final String DEFAULT_PROTOCOL = PROTOCOL_HTTPS;
|
||||
String DEFAULT_PROTOCOL = PROTOCOL_HTTPS;
|
||||
|
||||
public static final String OAUTH_CALLBACK_OOB = "oob";
|
||||
public static final String OAUTH_CALLBACK_URL = PROTOCOL_TWIDERE + "com.twitter.oauth/";
|
||||
String OAUTH_CALLBACK_OOB = "oob";
|
||||
String OAUTH_CALLBACK_URL = PROTOCOL_TWIDERE + "com.twitter.oauth/";
|
||||
|
||||
public static final int REQUEST_TAKE_PHOTO = 1;
|
||||
public static final int REQUEST_PICK_IMAGE = 2;
|
||||
public static final int REQUEST_SELECT_ACCOUNT = 3;
|
||||
public static final int REQUEST_COMPOSE = 4;
|
||||
public static final int REQUEST_EDIT_API = 5;
|
||||
public static final int REQUEST_BROWSER_SIGN_IN = 6;
|
||||
public static final int REQUEST_SET_COLOR = 7;
|
||||
public static final int REQUEST_SAVE_FILE = 8;
|
||||
public static final int REQUEST_EDIT_IMAGE = 9;
|
||||
public static final int REQUEST_EXTENSION_COMPOSE = 10;
|
||||
public static final int REQUEST_ADD_TAB = 11;
|
||||
public static final int REQUEST_EDIT_TAB = 12;
|
||||
public static final int REQUEST_PICK_FILE = 13;
|
||||
public static final int REQUEST_PICK_DIRECTORY = 14;
|
||||
public static final int REQUEST_ADD_TO_LIST = 15;
|
||||
public static final int REQUEST_SELECT_USER = 16;
|
||||
public static final int REQUEST_SELECT_USER_LIST = 17;
|
||||
public static final int REQUEST_PICK_ACTIVITY = 18;
|
||||
public static final int REQUEST_SETTINGS = 19;
|
||||
public static final int REQUEST_OPEN_DOCUMENT = 20;
|
||||
public static final int REQUEST_SWIPEBACK_ACTIVITY = 101;
|
||||
int REQUEST_TAKE_PHOTO = 1;
|
||||
int REQUEST_PICK_IMAGE = 2;
|
||||
int REQUEST_SELECT_ACCOUNT = 3;
|
||||
int REQUEST_COMPOSE = 4;
|
||||
int REQUEST_EDIT_API = 5;
|
||||
int REQUEST_BROWSER_SIGN_IN = 6;
|
||||
int REQUEST_SET_COLOR = 7;
|
||||
int REQUEST_SAVE_FILE = 8;
|
||||
int REQUEST_EDIT_IMAGE = 9;
|
||||
int REQUEST_EXTENSION_COMPOSE = 10;
|
||||
int REQUEST_ADD_TAB = 11;
|
||||
int REQUEST_EDIT_TAB = 12;
|
||||
int REQUEST_PICK_FILE = 13;
|
||||
int REQUEST_PICK_DIRECTORY = 14;
|
||||
int REQUEST_ADD_TO_LIST = 15;
|
||||
int REQUEST_SELECT_USER = 16;
|
||||
int REQUEST_SELECT_USER_LIST = 17;
|
||||
int REQUEST_PICK_ACTIVITY = 18;
|
||||
int REQUEST_SETTINGS = 19;
|
||||
int REQUEST_OPEN_DOCUMENT = 20;
|
||||
int REQUEST_SWIPEBACK_ACTIVITY = 101;
|
||||
|
||||
public static final int TABLE_ID_ACCOUNTS = 1;
|
||||
public static final int TABLE_ID_STATUSES = 12;
|
||||
public static final int TABLE_ID_MENTIONS = 13;
|
||||
public static final int TABLE_ID_DIRECT_MESSAGES = 21;
|
||||
public static final int TABLE_ID_DIRECT_MESSAGES_INBOX = 22;
|
||||
public static final int TABLE_ID_DIRECT_MESSAGES_OUTBOX = 23;
|
||||
public static final int TABLE_ID_DIRECT_MESSAGES_CONVERSATION = 24;
|
||||
public static final int TABLE_ID_DIRECT_MESSAGES_CONVERSATION_SCREEN_NAME = 25;
|
||||
public static final int TABLE_ID_DIRECT_MESSAGES_CONVERSATIONS_ENTRIES = 26;
|
||||
public static final int TABLE_ID_FILTERED_USERS = 31;
|
||||
public static final int TABLE_ID_FILTERED_KEYWORDS = 32;
|
||||
public static final int TABLE_ID_FILTERED_SOURCES = 33;
|
||||
public static final int TABLE_ID_FILTERED_LINKS = 34;
|
||||
public static final int TABLE_ID_TRENDS_LOCAL = 41;
|
||||
public static final int TABLE_ID_SAVED_SEARCHES = 42;
|
||||
public static final int TABLE_ID_SEARCH_HISTORY = 43;
|
||||
public static final int TABLE_ID_DRAFTS = 51;
|
||||
public static final int TABLE_ID_TABS = 52;
|
||||
public static final int TABLE_ID_CACHED_USERS = 61;
|
||||
public static final int TABLE_ID_CACHED_STATUSES = 62;
|
||||
public static final int TABLE_ID_CACHED_HASHTAGS = 63;
|
||||
public static final int TABLE_ID_CACHED_RELATIONSHIPS = 64;
|
||||
public static final int VIRTUAL_TABLE_ID_DATABASE_READY = 100;
|
||||
public static final int VIRTUAL_TABLE_ID_NOTIFICATIONS = 101;
|
||||
public static final int VIRTUAL_TABLE_ID_PREFERENCES = 102;
|
||||
public static final int VIRTUAL_TABLE_ID_ALL_PREFERENCES = 103;
|
||||
public static final int VIRTUAL_TABLE_ID_PERMISSIONS = 104;
|
||||
public static final int VIRTUAL_TABLE_ID_DNS = 105;
|
||||
public static final int VIRTUAL_TABLE_ID_CACHED_IMAGES = 106;
|
||||
public static final int VIRTUAL_TABLE_ID_CACHE_FILES = 107;
|
||||
public static final int VIRTUAL_TABLE_ID_UNREAD_COUNTS = 108;
|
||||
public static final int VIRTUAL_TABLE_ID_UNREAD_COUNTS_BY_TYPE = 109;
|
||||
public static final int VIRTUAL_TABLE_ID_CACHED_USERS_WITH_RELATIONSHIP = 121;
|
||||
public static final int VIRTUAL_TABLE_ID_CACHED_USERS_WITH_SCORE = 122;
|
||||
public static final int VIRTUAL_TABLE_ID_DRAFTS_UNSENT = 131;
|
||||
int TABLE_ID_ACCOUNTS = 1;
|
||||
int TABLE_ID_STATUSES = 12;
|
||||
int TABLE_ID_MENTIONS = 13;
|
||||
int TABLE_ID_DIRECT_MESSAGES = 21;
|
||||
int TABLE_ID_DIRECT_MESSAGES_INBOX = 22;
|
||||
int TABLE_ID_DIRECT_MESSAGES_OUTBOX = 23;
|
||||
int TABLE_ID_DIRECT_MESSAGES_CONVERSATION = 24;
|
||||
int TABLE_ID_DIRECT_MESSAGES_CONVERSATION_SCREEN_NAME = 25;
|
||||
int TABLE_ID_DIRECT_MESSAGES_CONVERSATIONS_ENTRIES = 26;
|
||||
int TABLE_ID_FILTERED_USERS = 31;
|
||||
int TABLE_ID_FILTERED_KEYWORDS = 32;
|
||||
int TABLE_ID_FILTERED_SOURCES = 33;
|
||||
int TABLE_ID_FILTERED_LINKS = 34;
|
||||
int TABLE_ID_TRENDS_LOCAL = 41;
|
||||
int TABLE_ID_SAVED_SEARCHES = 42;
|
||||
int TABLE_ID_SEARCH_HISTORY = 43;
|
||||
int TABLE_ID_DRAFTS = 51;
|
||||
int TABLE_ID_TABS = 52;
|
||||
int TABLE_ID_CACHED_USERS = 61;
|
||||
int TABLE_ID_CACHED_STATUSES = 62;
|
||||
int TABLE_ID_CACHED_HASHTAGS = 63;
|
||||
int TABLE_ID_CACHED_RELATIONSHIPS = 64;
|
||||
int VIRTUAL_TABLE_ID_DATABASE_READY = 100;
|
||||
int VIRTUAL_TABLE_ID_NOTIFICATIONS = 101;
|
||||
int VIRTUAL_TABLE_ID_PREFERENCES = 102;
|
||||
int VIRTUAL_TABLE_ID_ALL_PREFERENCES = 103;
|
||||
int VIRTUAL_TABLE_ID_PERMISSIONS = 104;
|
||||
int VIRTUAL_TABLE_ID_DNS = 105;
|
||||
int VIRTUAL_TABLE_ID_CACHED_IMAGES = 106;
|
||||
int VIRTUAL_TABLE_ID_CACHE_FILES = 107;
|
||||
int VIRTUAL_TABLE_ID_UNREAD_COUNTS = 108;
|
||||
int VIRTUAL_TABLE_ID_UNREAD_COUNTS_BY_TYPE = 109;
|
||||
int VIRTUAL_TABLE_ID_CACHED_USERS_WITH_RELATIONSHIP = 121;
|
||||
int VIRTUAL_TABLE_ID_CACHED_USERS_WITH_SCORE = 122;
|
||||
int VIRTUAL_TABLE_ID_DRAFTS_UNSENT = 131;
|
||||
|
||||
public static final int NOTIFICATION_ID_HOME_TIMELINE = 1;
|
||||
public static final int NOTIFICATION_ID_MENTIONS_TIMELINE = 2;
|
||||
public static final int NOTIFICATION_ID_DIRECT_MESSAGES = 3;
|
||||
public static final int NOTIFICATION_ID_DRAFTS = 4;
|
||||
public static final int NOTIFICATION_ID_DATA_PROFILING = 5;
|
||||
public static final int NOTIFICATION_ID_UPDATE_STATUS = 101;
|
||||
public static final int NOTIFICATION_ID_SEND_DIRECT_MESSAGE = 102;
|
||||
int NOTIFICATION_ID_HOME_TIMELINE = 1;
|
||||
int NOTIFICATION_ID_MENTIONS_TIMELINE = 2;
|
||||
int NOTIFICATION_ID_DIRECT_MESSAGES = 3;
|
||||
int NOTIFICATION_ID_DRAFTS = 4;
|
||||
int NOTIFICATION_ID_DATA_PROFILING = 5;
|
||||
int NOTIFICATION_ID_UPDATE_STATUS = 101;
|
||||
int NOTIFICATION_ID_SEND_DIRECT_MESSAGE = 102;
|
||||
|
||||
public static final String ICON_SPECIAL_TYPE_CUSTOMIZE = "_customize";
|
||||
String ICON_SPECIAL_TYPE_CUSTOMIZE = "_customize";
|
||||
|
||||
public static final String TASK_TAG_GET_HOME_TIMELINE = "get_home_tomeline";
|
||||
public static final String TASK_TAG_GET_MENTIONS = "get_mentions";
|
||||
public static final String TASK_TAG_GET_SENT_DIRECT_MESSAGES = "get_sent_direct_messages";
|
||||
public static final String TASK_TAG_GET_RECEIVED_DIRECT_MESSAGES = "get_received_direct_messages";
|
||||
public static final String TASK_TAG_GET_TRENDS = "get_trends";
|
||||
public static final String TASK_TAG_STORE_TRENDS = "store_trends";
|
||||
String TASK_TAG_GET_HOME_TIMELINE = "get_home_tomeline";
|
||||
String TASK_TAG_GET_MENTIONS = "get_mentions";
|
||||
String TASK_TAG_GET_SENT_DIRECT_MESSAGES = "get_sent_direct_messages";
|
||||
String TASK_TAG_GET_RECEIVED_DIRECT_MESSAGES = "get_received_direct_messages";
|
||||
String TASK_TAG_GET_TRENDS = "get_trends";
|
||||
String TASK_TAG_STORE_TRENDS = "store_trends";
|
||||
|
||||
public static final String SERVICE_COMMAND_REFRESH_ALL = "refresh_all";
|
||||
public static final String SERVICE_COMMAND_GET_HOME_TIMELINE = "get_home_timeline";
|
||||
public static final String SERVICE_COMMAND_GET_MENTIONS = "get_mentions";
|
||||
public static final String SERVICE_COMMAND_GET_SENT_DIRECT_MESSAGES = "get_sent_direct_messages";
|
||||
public static final String SERVICE_COMMAND_GET_RECEIVED_DIRECT_MESSAGES = "get_received_direct_messages";
|
||||
String SERVICE_COMMAND_REFRESH_ALL = "refresh_all";
|
||||
String SERVICE_COMMAND_GET_HOME_TIMELINE = "get_home_timeline";
|
||||
String SERVICE_COMMAND_GET_MENTIONS = "get_mentions";
|
||||
String SERVICE_COMMAND_GET_SENT_DIRECT_MESSAGES = "get_sent_direct_messages";
|
||||
String SERVICE_COMMAND_GET_RECEIVED_DIRECT_MESSAGES = "get_received_direct_messages";
|
||||
|
||||
public static final String METADATA_KEY_EXTENSION = "org.mariotaku.twidere.extension";
|
||||
public static final String METADATA_KEY_EXTENSION_PERMISSIONS = "org.mariotaku.twidere.extension.permissions";
|
||||
public static final String METADATA_KEY_EXTENSION_SETTINGS = "org.mariotaku.twidere.extension.settings";
|
||||
public static final String METADATA_KEY_EXTENSION_ICON = "org.mariotaku.twidere.extension.icon";
|
||||
public static final String METADATA_KEY_EXTENSION_USE_JSON = "org.mariotaku.twidere.extension.use_json";
|
||||
String METADATA_KEY_EXTENSION = "org.mariotaku.twidere.extension";
|
||||
String METADATA_KEY_EXTENSION_PERMISSIONS = "org.mariotaku.twidere.extension.permissions";
|
||||
String METADATA_KEY_EXTENSION_SETTINGS = "org.mariotaku.twidere.extension.settings";
|
||||
String METADATA_KEY_EXTENSION_ICON = "org.mariotaku.twidere.extension.icon";
|
||||
String METADATA_KEY_EXTENSION_USE_JSON = "org.mariotaku.twidere.extension.use_json";
|
||||
|
||||
public static final char SEPARATOR_PERMISSION = '|';
|
||||
public static final String SEPARATOR_PERMISSION_REGEX = "\\" + SEPARATOR_PERMISSION;
|
||||
char SEPARATOR_PERMISSION = '|';
|
||||
String SEPARATOR_PERMISSION_REGEX = "\\" + SEPARATOR_PERMISSION;
|
||||
|
||||
public static final String PERMISSION_DENIED = "denied";
|
||||
public static final String PERMISSION_REFRESH = "refresh";
|
||||
public static final String PERMISSION_READ = "read";
|
||||
public static final String PERMISSION_WRITE = "write";
|
||||
public static final String PERMISSION_DIRECT_MESSAGES = "direct_messages";
|
||||
public static final String PERMISSION_ACCOUNTS = "accounts";
|
||||
public static final String PERMISSION_PREFERENCES = "preferences";
|
||||
String PERMISSION_DENIED = "denied";
|
||||
String PERMISSION_REFRESH = "refresh";
|
||||
String PERMISSION_READ = "read";
|
||||
String PERMISSION_WRITE = "write";
|
||||
String PERMISSION_DIRECT_MESSAGES = "direct_messages";
|
||||
String PERMISSION_ACCOUNTS = "accounts";
|
||||
String PERMISSION_PREFERENCES = "preferences";
|
||||
|
||||
public static final String TAB_TYPE_HOME_TIMELINE = "home_timeline";
|
||||
public static final String TAB_TYPE_MENTIONS_TIMELINE = "mentions_timeline";
|
||||
public static final String TAB_TYPE_TRENDS_SUGGESTIONS = "trends_suggestions";
|
||||
public static final String TAB_TYPE_DIRECT_MESSAGES = "direct_messages";
|
||||
public static final String TAB_TYPE_FAVORITES = "favorites";
|
||||
public static final String TAB_TYPE_USER_TIMELINE = "user_timeline";
|
||||
public static final String TAB_TYPE_SEARCH_STATUSES = "search_statuses";
|
||||
public static final String TAB_TYPE_LIST_TIMELINE = "list_timeline";
|
||||
public static final String TAB_TYPE_ACTIVITIES_ABOUT_ME = "activities_about_me";
|
||||
public static final String TAB_TYPE_ACTIVITIES_BY_FRIENDS = "activities_by_friends";
|
||||
public static final String TAB_TYPE_RETWEETS_OF_ME = "retweets_of_me";
|
||||
String TAB_TYPE_HOME_TIMELINE = "home_timeline";
|
||||
String TAB_TYPE_MENTIONS_TIMELINE = "mentions_timeline";
|
||||
String TAB_TYPE_TRENDS_SUGGESTIONS = "trends_suggestions";
|
||||
String TAB_TYPE_DIRECT_MESSAGES = "direct_messages";
|
||||
String TAB_TYPE_FAVORITES = "favorites";
|
||||
String TAB_TYPE_USER_TIMELINE = "user_timeline";
|
||||
String TAB_TYPE_SEARCH_STATUSES = "search_statuses";
|
||||
String TAB_TYPE_LIST_TIMELINE = "list_timeline";
|
||||
String TAB_TYPE_ACTIVITIES_ABOUT_ME = "activities_about_me";
|
||||
String TAB_TYPE_ACTIVITIES_BY_FRIENDS = "activities_by_friends";
|
||||
String TAB_TYPE_RETWEETS_OF_ME = "retweets_of_me";
|
||||
|
||||
|
||||
public static final int TAB_CODE_HOME_TIMELINE = 1;
|
||||
public static final int TAB_CODE_MENTIONS_TIMELINE = 2;
|
||||
public static final int TAB_CODE_DIRECT_MESSAGES = 4;
|
||||
int TAB_CODE_HOME_TIMELINE = 1;
|
||||
int TAB_CODE_MENTIONS_TIMELINE = 2;
|
||||
int TAB_CODE_DIRECT_MESSAGES = 4;
|
||||
|
||||
public static final int TWITTER_MAX_IMAGE_SIZE = 3145728;
|
||||
public static final int TWITTER_MAX_IMAGE_WIDTH = 1024;
|
||||
public static final int TWITTER_MAX_IMAGE_HEIGHT = 2048;
|
||||
int TWITTER_MAX_IMAGE_SIZE = 3145728;
|
||||
int TWITTER_MAX_IMAGE_WIDTH = 1024;
|
||||
int TWITTER_MAX_IMAGE_HEIGHT = 2048;
|
||||
|
||||
}
|
||||
|
|
|
@ -250,9 +250,9 @@ public interface SharedPreferenceConstants {
|
|||
String KEY_NO_VERSION_SUFFIX = "no_version_suffix";
|
||||
@Preference(type = INT, hasDefault = true, defaultInt = Accounts.AUTH_TYPE_OAUTH)
|
||||
String KEY_AUTH_TYPE = "auth_type";
|
||||
@Preference(type = STRING, hasDefault = true, defaultString = TwidereConstants.TWITTER_CONSUMER_KEY_3)
|
||||
@Preference(type = STRING, hasDefault = true, defaultString = TwidereConstants.TWITTER_CONSUMER_KEY)
|
||||
String KEY_CONSUMER_KEY = "consumer_key";
|
||||
@Preference(type = STRING, hasDefault = true, defaultString = TwidereConstants.TWITTER_CONSUMER_SECRET_3)
|
||||
@Preference(type = STRING, hasDefault = true, defaultString = TwidereConstants.TWITTER_CONSUMER_SECRET)
|
||||
String KEY_CONSUMER_SECRET = "consumer_secret";
|
||||
String KEY_SETTINGS_WIZARD_COMPLETED = "settings_wizard_completed";
|
||||
@Preference(type = BOOLEAN, hasDefault = true, defaultBoolean = true)
|
||||
|
|
|
@ -15,4 +15,5 @@ public interface RestClient {
|
|||
Converter getConverter();
|
||||
|
||||
Authorization getAuthorization();
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package org.mariotaku.simplerestapi.http;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
|
@ -7,6 +9,7 @@ import java.io.IOException;
|
|||
*/
|
||||
public interface RestHttpClient {
|
||||
|
||||
@NonNull
|
||||
RestResponse execute(RestRequest request) throws IOException;
|
||||
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ import java.util.List;
|
|||
/**
|
||||
* Created by mariotaku on 15/2/7.
|
||||
*/
|
||||
public class RestRequest {
|
||||
public final class RestRequest {
|
||||
|
||||
private final String method;
|
||||
private final String url;
|
||||
|
@ -104,6 +104,7 @@ public class RestRequest {
|
|||
RestRequest create(@NonNull Endpoint endpoint, @NonNull RestMethodInfo info, @Nullable Authorization authorization);
|
||||
}
|
||||
|
||||
|
||||
public static final class DefaultFactory implements Factory {
|
||||
|
||||
@Override
|
||||
|
|
|
@ -70,13 +70,6 @@ public final class TwitterFactory {
|
|||
|
||||
private final Configuration conf;
|
||||
|
||||
/**
|
||||
* Creates a TwitterFactory with the root configuration.
|
||||
*/
|
||||
public TwitterFactory() {
|
||||
this(ConfigurationContext.getInstance());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a TwitterFactory with the given configuration.
|
||||
*
|
||||
|
|
|
@ -154,8 +154,8 @@ public class APIEditorActivity extends BaseSupportDialogActivity implements Twit
|
|||
final int prefAuthType = pref.getInt(KEY_AUTH_TYPE, Accounts.AUTH_TYPE_OAUTH);
|
||||
final boolean prefSameOAuthSigningUrl = pref.getBoolean(KEY_SAME_OAUTH_SIGNING_URL, false);
|
||||
final boolean prefNoVersionSuffix = pref.getBoolean(KEY_NO_VERSION_SUFFIX, false);
|
||||
final String prefConsumerKey = getNonEmptyString(pref, KEY_CONSUMER_KEY, TWITTER_CONSUMER_KEY_3);
|
||||
final String prefConsumerSecret = getNonEmptyString(pref, KEY_CONSUMER_SECRET, TWITTER_CONSUMER_SECRET_3);
|
||||
final String prefConsumerKey = getNonEmptyString(pref, KEY_CONSUMER_KEY, TWITTER_CONSUMER_KEY);
|
||||
final String prefConsumerSecret = getNonEmptyString(pref, KEY_CONSUMER_SECRET, TWITTER_CONSUMER_SECRET);
|
||||
if (savedInstanceState != null) {
|
||||
apiUrlFormat = trim(savedInstanceState.getString(Accounts.API_URL_FORMAT, prefApiUrlFormat));
|
||||
authType = savedInstanceState.getInt(Accounts.AUTH_TYPE, prefAuthType);
|
||||
|
|
|
@ -234,9 +234,9 @@ public class BrowserSignInActivity extends BaseSupportDialogActivity implements
|
|||
final boolean enable_gzip_compressing = mPreferences.getBoolean(KEY_GZIP_COMPRESSING, false);
|
||||
final boolean ignore_ssl_error = mPreferences.getBoolean(KEY_IGNORE_SSL_ERROR, false);
|
||||
final boolean enable_proxy = mPreferences.getBoolean(KEY_ENABLE_PROXY, false);
|
||||
final String consumerKey = getNonEmptyString(mPreferences, KEY_CONSUMER_KEY, TWITTER_CONSUMER_KEY_3);
|
||||
final String consumerKey = getNonEmptyString(mPreferences, KEY_CONSUMER_KEY, TWITTER_CONSUMER_KEY);
|
||||
final String consumerSecret = getNonEmptyString(mPreferences, KEY_CONSUMER_SECRET,
|
||||
TWITTER_CONSUMER_SECRET_3);
|
||||
TWITTER_CONSUMER_SECRET);
|
||||
cb.setHostAddressResolverFactory(new TwidereHostResolverFactory(mApplication));
|
||||
Utils.setClientUserAgent(mActivity, consumerKey, consumerSecret, cb);
|
||||
cb.setRestBaseURL(DEFAULT_REST_BASE_URL);
|
||||
|
|
|
@ -397,8 +397,8 @@ public class SignInActivity extends BaseAppCompatActivity implements TwitterCons
|
|||
cb.setSigningUploadBaseURL(DEFAULT_SIGNING_UPLOAD_BASE_URL);
|
||||
}
|
||||
if (isEmpty(mConsumerKey) || isEmpty(mConsumerSecret)) {
|
||||
cb.setOAuthConsumerKey(TWITTER_CONSUMER_KEY_3);
|
||||
cb.setOAuthConsumerSecret(TWITTER_CONSUMER_SECRET_3);
|
||||
cb.setOAuthConsumerKey(TWITTER_CONSUMER_KEY);
|
||||
cb.setOAuthConsumerSecret(TWITTER_CONSUMER_SECRET);
|
||||
} else {
|
||||
cb.setOAuthConsumerKey(mConsumerKey);
|
||||
cb.setOAuthConsumerSecret(mConsumerSecret);
|
||||
|
@ -428,8 +428,8 @@ public class SignInActivity extends BaseAppCompatActivity implements TwitterCons
|
|||
final int authType = mPreferences.getInt(KEY_AUTH_TYPE, Accounts.AUTH_TYPE_OAUTH);
|
||||
final boolean sameOAuthSigningUrl = mPreferences.getBoolean(KEY_SAME_OAUTH_SIGNING_URL, false);
|
||||
final boolean noVersionSuffix = mPreferences.getBoolean(KEY_NO_VERSION_SUFFIX, false);
|
||||
final String consumerKey = getNonEmptyString(mPreferences, KEY_CONSUMER_KEY, TWITTER_CONSUMER_KEY_3);
|
||||
final String consumerSecret = getNonEmptyString(mPreferences, KEY_CONSUMER_SECRET, TWITTER_CONSUMER_SECRET_3);
|
||||
final String consumerKey = getNonEmptyString(mPreferences, KEY_CONSUMER_KEY, TWITTER_CONSUMER_KEY);
|
||||
final String consumerSecret = getNonEmptyString(mPreferences, KEY_CONSUMER_SECRET, TWITTER_CONSUMER_SECRET);
|
||||
if (isEmpty(mAPIUrlFormat) || defaultApiChanged) {
|
||||
mAPIUrlFormat = apiUrlFormat;
|
||||
}
|
||||
|
|
|
@ -102,8 +102,8 @@ public class DefaultAPIPreference extends DialogPreference implements Constants,
|
|||
final int authType = pref.getInt(KEY_AUTH_TYPE, Accounts.AUTH_TYPE_OAUTH);
|
||||
final boolean sameOAuthSigningUrl = pref.getBoolean(KEY_SAME_OAUTH_SIGNING_URL, false);
|
||||
final boolean noVersionSuffix = pref.getBoolean(KEY_NO_VERSION_SUFFIX, false);
|
||||
final String consumerKey = getNonEmptyString(pref, KEY_CONSUMER_KEY, TWITTER_CONSUMER_KEY_3);
|
||||
final String consumerSecret = getNonEmptyString(pref, KEY_CONSUMER_SECRET, TWITTER_CONSUMER_SECRET_3);
|
||||
final String consumerKey = getNonEmptyString(pref, KEY_CONSUMER_KEY, TWITTER_CONSUMER_KEY);
|
||||
final String consumerSecret = getNonEmptyString(pref, KEY_CONSUMER_SECRET, TWITTER_CONSUMER_SECRET);
|
||||
setValues(apiUrlFormat, authType, noVersionSuffix, sameOAuthSigningUrl, consumerKey, consumerSecret);
|
||||
}
|
||||
|
||||
|
@ -162,8 +162,8 @@ public class DefaultAPIPreference extends DialogPreference implements Constants,
|
|||
final String prefApiUrlFormat = getNonEmptyString(pref, KEY_API_URL_FORMAT, DEFAULT_REST_BASE_URL);
|
||||
final int prefAuthType = pref.getInt(KEY_AUTH_TYPE, Accounts.AUTH_TYPE_OAUTH);
|
||||
final boolean prefSameOAuthSigningUrl = pref.getBoolean(KEY_API_URL_FORMAT, false);
|
||||
final String prefConsumerKey = getNonEmptyString(pref, KEY_CONSUMER_KEY, TWITTER_CONSUMER_KEY_3);
|
||||
final String prefConsumerSecret = getNonEmptyString(pref, KEY_CONSUMER_SECRET, TWITTER_CONSUMER_SECRET_3);
|
||||
final String prefConsumerKey = getNonEmptyString(pref, KEY_CONSUMER_KEY, TWITTER_CONSUMER_KEY);
|
||||
final String prefConsumerSecret = getNonEmptyString(pref, KEY_CONSUMER_SECRET, TWITTER_CONSUMER_SECRET);
|
||||
final String apiUrlFormat = trim(savedInstanceState.getString(Accounts.API_URL_FORMAT, prefApiUrlFormat));
|
||||
final int authType = savedInstanceState.getInt(Accounts.AUTH_TYPE, prefAuthType);
|
||||
final boolean sameOAuthSigningUrl = savedInstanceState.getBoolean(Accounts.SAME_OAUTH_SIGNING_URL,
|
||||
|
|
|
@ -2,10 +2,16 @@ package org.mariotaku.twidere.util;
|
|||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.net.SSLCertificateSocketFactory;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Pair;
|
||||
|
||||
import com.squareup.okhttp.OkHttpClient;
|
||||
import com.squareup.okhttp.internal.Internal;
|
||||
import com.squareup.okhttp.internal.Network;
|
||||
|
||||
import org.mariotaku.simplerestapi.http.Authorization;
|
||||
import org.mariotaku.simplerestapi.http.RestHttpClient;
|
||||
import org.mariotaku.simplerestapi.http.RestRequest;
|
||||
|
@ -24,26 +30,30 @@ import org.mariotaku.twidere.provider.TwidereDataStore;
|
|||
import org.mariotaku.twidere.util.net.TwidereHostResolverFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.Proxy;
|
||||
import java.net.SocketAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import twitter4j.Twitter;
|
||||
import twitter4j.TwitterConstants;
|
||||
import twitter4j.TwitterFactory;
|
||||
import twitter4j.conf.Configuration;
|
||||
import twitter4j.conf.ConfigurationBuilder;
|
||||
import twitter4j.http.HostAddressResolverFactory;
|
||||
import twitter4j.http.HostAddressResolver;
|
||||
|
||||
import static android.text.TextUtils.isEmpty;
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 15/5/7.
|
||||
*/
|
||||
public class TwitterAPIUtils {
|
||||
public class TwitterAPIUtils implements TwidereConstants {
|
||||
|
||||
@NonNull
|
||||
public static RestResponse getRedirectedHttpResponse(@NonNull final RestHttpClient client, @NonNull final String url,
|
||||
final String signUrl, final Authorization auth,
|
||||
final List<Pair<String, String>> additionalHeaders)
|
||||
|
@ -53,7 +63,7 @@ public class TwitterAPIUtils {
|
|||
RestResponse resp;
|
||||
RestRequest req = new RestRequest.Builder().method(GET.METHOD).url(url).headers(additionalHeaders).build();
|
||||
resp = client.execute(req);
|
||||
while (resp != null && Utils.isRedirected(resp.getStatus())) {
|
||||
while (Utils.isRedirected(resp.getStatus())) {
|
||||
final String requestUrl = resp.getHeader("Location");
|
||||
if (requestUrl == null) return null;
|
||||
if (urls.contains(requestUrl)) throw new IOException("Too many redirects");
|
||||
|
@ -82,8 +92,8 @@ public class TwitterAPIUtils {
|
|||
|
||||
@Nullable
|
||||
public static Twitter getTwitterInstance(final Context context, final long accountId,
|
||||
final boolean includeEntities,
|
||||
final boolean includeRetweets) {
|
||||
final boolean includeEntities,
|
||||
final boolean includeRetweets) {
|
||||
return getTwitterInstance(context, accountId, includeEntities, includeRetweets, Twitter.class);
|
||||
}
|
||||
|
||||
|
@ -101,7 +111,7 @@ public class TwitterAPIUtils {
|
|||
private static Configuration getConfiguration(Context context, boolean includeEntities, boolean includeRetweets, ParcelableAccount.ParcelableCredentials credentials) {
|
||||
final TwidereApplication app = TwidereApplication.getInstance(context);
|
||||
final SharedPreferences prefs = context.getSharedPreferences(TwidereConstants.SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
|
||||
final int connection_timeout = prefs.getInt(SharedPreferenceConstants.KEY_CONNECTION_TIMEOUT, 10) * 1000;
|
||||
final int connectionTimeout = prefs.getInt(SharedPreferenceConstants.KEY_CONNECTION_TIMEOUT, 10) * 1000;
|
||||
final boolean enableGzip = prefs.getBoolean(SharedPreferenceConstants.KEY_GZIP_COMPRESSING, true);
|
||||
final boolean ignoreSslError = prefs.getBoolean(SharedPreferenceConstants.KEY_IGNORE_SSL_ERROR, false);
|
||||
final boolean enableProxy = prefs.getBoolean(SharedPreferenceConstants.KEY_ENABLE_PROXY, false);
|
||||
|
@ -109,7 +119,7 @@ public class TwitterAPIUtils {
|
|||
// versions
|
||||
final ConfigurationBuilder cb = new ConfigurationBuilder();
|
||||
cb.setHostAddressResolverFactory(new TwidereHostResolverFactory(app));
|
||||
cb.setHttpConnectionTimeout(connection_timeout);
|
||||
cb.setHttpConnectionTimeout(connectionTimeout);
|
||||
cb.setGZIPEnabled(enableGzip);
|
||||
cb.setIgnoreSSLError(ignoreSslError);
|
||||
cb.setIncludeCards(true);
|
||||
|
@ -153,8 +163,12 @@ public class TwitterAPIUtils {
|
|||
switch (credentials.auth_type) {
|
||||
case TwidereDataStore.Accounts.AUTH_TYPE_OAUTH:
|
||||
case TwidereDataStore.Accounts.AUTH_TYPE_XAUTH: {
|
||||
return new OAuthAuthorization(credentials.consumer_key, credentials.consumer_secret,
|
||||
new OAuthToken(credentials.oauth_token, credentials.oauth_token_secret));
|
||||
final String consumerKey = TextUtils.isEmpty(credentials.consumer_key) ?
|
||||
TWITTER_CONSUMER_KEY_LEGACY : credentials.consumer_key;
|
||||
final String consumerSecret = TextUtils.isEmpty(credentials.consumer_secret) ?
|
||||
TWITTER_CONSUMER_SECRET_LEGACY : credentials.consumer_secret;
|
||||
final OAuthToken accessToken = new OAuthToken(credentials.oauth_token, credentials.oauth_token_secret);
|
||||
return new OAuthAuthorization(consumerKey, consumerSecret, accessToken);
|
||||
}
|
||||
case TwidereDataStore.Accounts.AUTH_TYPE_BASIC: {
|
||||
final String screenName = credentials.screen_name;
|
||||
|
@ -168,44 +182,52 @@ public class TwitterAPIUtils {
|
|||
return new EmptyAuthorization();
|
||||
}
|
||||
|
||||
public static RestHttpClient getHttpClient(final Context context, final int timeoutMillis,
|
||||
final boolean ignoreSslError, final Proxy proxy,
|
||||
final HostAddressResolverFactory resolverFactory,
|
||||
final String userAgent, final boolean twitterClientHeader) {
|
||||
final ConfigurationBuilder cb = new ConfigurationBuilder();
|
||||
cb.setHttpConnectionTimeout(timeoutMillis);
|
||||
cb.setIgnoreSSLError(ignoreSslError);
|
||||
cb.setIncludeTwitterClientHeader(twitterClientHeader);
|
||||
if (proxy != null && !Proxy.NO_PROXY.equals(proxy)) {
|
||||
final SocketAddress address = proxy.address();
|
||||
if (address instanceof InetSocketAddress) {
|
||||
cb.setHttpProxyHost(((InetSocketAddress) address).getHostName());
|
||||
cb.setHttpProxyPort(((InetSocketAddress) address).getPort());
|
||||
}
|
||||
}
|
||||
cb.setHostAddressResolverFactory(resolverFactory);
|
||||
return new OkHttpRestClient();
|
||||
}
|
||||
|
||||
public static RestHttpClient getDefaultHttpClient(final Context context) {
|
||||
if (context == null) return null;
|
||||
final SharedPreferences prefs = context.getSharedPreferences(TwidereConstants.SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
|
||||
final int timeoutMillis = prefs.getInt(SharedPreferenceConstants.KEY_CONNECTION_TIMEOUT, 10000) * 1000;
|
||||
final Proxy proxy = Utils.getProxy(context);
|
||||
final String userAgent = TwidereApplication.getInstance(context).getDefaultUserAgent();
|
||||
final HostAddressResolverFactory resolverFactory = new TwidereHostResolverFactory(
|
||||
TwidereApplication.getInstance(context));
|
||||
return getHttpClient(context, timeoutMillis, true, proxy, resolverFactory, userAgent, false);
|
||||
final SharedPreferencesWrapper prefs = SharedPreferencesWrapper.getInstance(context, SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
|
||||
//TODO set user agent
|
||||
TwidereApplication.getInstance(context).getDefaultUserAgent();
|
||||
return createHttpClient(context, prefs);
|
||||
}
|
||||
|
||||
public static RestHttpClient getImageLoaderHttpClient(final Context context) {
|
||||
if (context == null) return null;
|
||||
final SharedPreferences prefs = context.getSharedPreferences(TwidereConstants.SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
|
||||
final int timeoutMillis = prefs.getInt(SharedPreferenceConstants.KEY_CONNECTION_TIMEOUT, 10000) * 1000;
|
||||
final Proxy proxy = Utils.getProxy(context);
|
||||
final String userAgent = TwidereApplication.getInstance(context).getDefaultUserAgent();
|
||||
final HostAddressResolverFactory resolverFactory = new TwidereHostResolverFactory(
|
||||
TwidereApplication.getInstance(context));
|
||||
return getHttpClient(context, timeoutMillis, true, proxy, resolverFactory, userAgent, false);
|
||||
public static RestHttpClient createHttpClient(final Context context, final SharedPreferencesWrapper prefs) {
|
||||
final int connectionTimeout = prefs.getInt(KEY_CONNECTION_TIMEOUT, 10);
|
||||
final boolean ignoreSslError = prefs.getBoolean(KEY_IGNORE_SSL_ERROR, false);
|
||||
final boolean enableProxy = prefs.getBoolean(KEY_ENABLE_PROXY, false);
|
||||
|
||||
final OkHttpClient client = new OkHttpClient();
|
||||
client.setConnectTimeout(connectionTimeout, TimeUnit.SECONDS);
|
||||
if (ignoreSslError) {
|
||||
client.setSslSocketFactory(SSLCertificateSocketFactory.getInsecure(0, null));
|
||||
} else {
|
||||
client.setSslSocketFactory(SSLCertificateSocketFactory.getDefault(0, null));
|
||||
}
|
||||
if (enableProxy) {
|
||||
client.setProxy(getProxy(prefs));
|
||||
}
|
||||
final HostAddressResolver resolver = TwidereApplication.getInstance(context).getHostAddressResolver();
|
||||
Internal.instance.setNetwork(client, new Network() {
|
||||
@Override
|
||||
public InetAddress[] resolveInetAddresses(String host) throws UnknownHostException {
|
||||
try {
|
||||
return resolver.resolve(host);
|
||||
} catch (IOException e) {
|
||||
if (e instanceof UnknownHostException) throw (UnknownHostException) e;
|
||||
throw new UnknownHostException("Unable to resolve address " + e.getMessage());
|
||||
}
|
||||
}
|
||||
});
|
||||
return new OkHttpRestClient(client);
|
||||
}
|
||||
|
||||
|
||||
public static Proxy getProxy(final SharedPreferencesWrapper prefs) {
|
||||
final String proxyHost = prefs.getString(KEY_PROXY_HOST, null);
|
||||
final int proxyPort = ParseUtils.parseInt(prefs.getString(KEY_PROXY_PORT, "-1"));
|
||||
if (!isEmpty(proxyHost) && proxyPort >= 0 && proxyPort < 65535) {
|
||||
final SocketAddress addr = InetSocketAddress.createUnresolved(proxyHost, proxyPort);
|
||||
return new Proxy(Proxy.Type.HTTP, addr);
|
||||
}
|
||||
return Proxy.NO_PROXY;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -232,9 +232,6 @@ import java.io.InputStream;
|
|||
import java.io.OutputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.Proxy;
|
||||
import java.net.SocketAddress;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.Charset;
|
||||
import java.text.NumberFormat;
|
||||
|
@ -2093,20 +2090,6 @@ public final class Utils implements Constants, TwitterConstants {
|
|||
return VALUE_MEDIA_PREVIEW_STYLE_CODE_CROP;
|
||||
}
|
||||
|
||||
public static Proxy getProxy(final Context context) {
|
||||
if (context == null) return null;
|
||||
final SharedPreferences prefs = context.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
|
||||
final boolean enable_proxy = prefs.getBoolean(KEY_ENABLE_PROXY, false);
|
||||
if (!enable_proxy) return Proxy.NO_PROXY;
|
||||
final String proxyHost = prefs.getString(KEY_PROXY_HOST, null);
|
||||
final int proxyPort = ParseUtils.parseInt(prefs.getString(KEY_PROXY_PORT, "-1"));
|
||||
if (!isEmpty(proxyHost) && proxyPort >= 0 && proxyPort < 65535) {
|
||||
final SocketAddress addr = InetSocketAddress.createUnresolved(proxyHost, proxyPort);
|
||||
return new Proxy(Proxy.Type.HTTP, addr);
|
||||
}
|
||||
return Proxy.NO_PROXY;
|
||||
}
|
||||
|
||||
public static String getQuoteStatus(final Context context, long statusId, final String screen_name, final String text) {
|
||||
if (context == null) return null;
|
||||
String quoteFormat = context.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE).getString(
|
||||
|
@ -2281,8 +2264,8 @@ public final class Utils implements Constants, TwitterConstants {
|
|||
// Here I use old consumer key/secret because it's default
|
||||
// key for older
|
||||
// versions
|
||||
final String prefConsumerKey = prefs.getString(KEY_CONSUMER_KEY, TWITTER_CONSUMER_KEY);
|
||||
final String prefConsumerSecret = prefs.getString(KEY_CONSUMER_SECRET, TWITTER_CONSUMER_SECRET);
|
||||
final String prefConsumerKey = prefs.getString(KEY_CONSUMER_KEY, TWITTER_CONSUMER_KEY_LEGACY);
|
||||
final String prefConsumerSecret = prefs.getString(KEY_CONSUMER_SECRET, TWITTER_CONSUMER_SECRET_LEGACY);
|
||||
final ConfigurationBuilder cb = new ConfigurationBuilder();
|
||||
if (!isEmpty(account.api_url_format)) {
|
||||
final String versionSuffix = account.no_version_suffix ? null : "/1.1/";
|
||||
|
@ -2303,8 +2286,8 @@ public final class Utils implements Constants, TwitterConstants {
|
|||
cb.setOAuthConsumerKey(prefConsumerKey);
|
||||
cb.setOAuthConsumerSecret(prefConsumerSecret);
|
||||
} else {
|
||||
cb.setOAuthConsumerKey(TWITTER_CONSUMER_KEY);
|
||||
cb.setOAuthConsumerSecret(TWITTER_CONSUMER_SECRET);
|
||||
cb.setOAuthConsumerKey(TWITTER_CONSUMER_KEY_LEGACY);
|
||||
cb.setOAuthConsumerSecret(TWITTER_CONSUMER_SECRET_LEGACY);
|
||||
}
|
||||
final Configuration conf = cb.build();
|
||||
return new OAuthAuthorization(conf.getOAuthConsumerKey(), conf.getOAuthConsumerSecret(),
|
||||
|
@ -2341,8 +2324,8 @@ public final class Utils implements Constants, TwitterConstants {
|
|||
// Here I use old consumer key/secret because it's default
|
||||
// key for older
|
||||
// versions
|
||||
final String prefConsumerKey = prefs.getString(KEY_CONSUMER_KEY, TWITTER_CONSUMER_KEY);
|
||||
final String prefConsumerSecret = prefs.getString(KEY_CONSUMER_SECRET, TWITTER_CONSUMER_SECRET);
|
||||
final String prefConsumerKey = prefs.getString(KEY_CONSUMER_KEY, TWITTER_CONSUMER_KEY_LEGACY);
|
||||
final String prefConsumerSecret = prefs.getString(KEY_CONSUMER_SECRET, TWITTER_CONSUMER_SECRET_LEGACY);
|
||||
final ConfigurationBuilder cb = new ConfigurationBuilder();
|
||||
final String apiUrlFormat = c.getString(c.getColumnIndex(Accounts.API_URL_FORMAT));
|
||||
final String consumerKey = trim(c.getString(c.getColumnIndex(Accounts.CONSUMER_KEY)));
|
||||
|
@ -2366,8 +2349,8 @@ public final class Utils implements Constants, TwitterConstants {
|
|||
cb.setOAuthConsumerKey(prefConsumerKey);
|
||||
cb.setOAuthConsumerSecret(prefConsumerSecret);
|
||||
} else {
|
||||
cb.setOAuthConsumerKey(TWITTER_CONSUMER_KEY);
|
||||
cb.setOAuthConsumerSecret(TWITTER_CONSUMER_SECRET);
|
||||
cb.setOAuthConsumerKey(TWITTER_CONSUMER_KEY_LEGACY);
|
||||
cb.setOAuthConsumerSecret(TWITTER_CONSUMER_SECRET_LEGACY);
|
||||
}
|
||||
final Configuration conf = cb.build();
|
||||
final String token = c.getString(c.getColumnIndexOrThrow(Accounts.OAUTH_TOKEN));
|
||||
|
|
|
@ -201,8 +201,8 @@ public final class TwidereSQLiteOpenHelper extends SQLiteOpenHelper implements C
|
|||
.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
|
||||
// Here I use old consumer key/secret because it's default key for
|
||||
// older versions
|
||||
final String pref_consumer_key = prefs.getString(KEY_CONSUMER_KEY, TWITTER_CONSUMER_KEY);
|
||||
final String pref_consumer_secret = prefs.getString(KEY_CONSUMER_SECRET, TWITTER_CONSUMER_SECRET);
|
||||
final String pref_consumer_key = prefs.getString(KEY_CONSUMER_KEY, TWITTER_CONSUMER_KEY_LEGACY);
|
||||
final String pref_consumer_secret = prefs.getString(KEY_CONSUMER_SECRET, TWITTER_CONSUMER_SECRET_LEGACY);
|
||||
values.put(Accounts.CONSUMER_KEY, trim(pref_consumer_key));
|
||||
values.put(Accounts.CONSUMER_SECRET, trim(pref_consumer_secret));
|
||||
db.update(Accounts.TABLE_NAME, values, null, null);
|
||||
|
|
|
@ -44,6 +44,8 @@ import org.mariotaku.twidere.model.ParcelableAccount.ParcelableCredentials;
|
|||
import org.mariotaku.twidere.model.ParcelableMedia;
|
||||
import org.mariotaku.twidere.util.MediaPreviewUtils;
|
||||
import org.mariotaku.twidere.util.SharedPreferencesWrapper;
|
||||
import org.mariotaku.twidere.util.TwidereLinkify;
|
||||
import org.mariotaku.twidere.util.TwitterAPIUtils;
|
||||
import org.mariotaku.twidere.util.Utils;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -54,13 +56,6 @@ import java.util.Locale;
|
|||
|
||||
import twitter4j.TwitterException;
|
||||
|
||||
import static org.mariotaku.twidere.util.TwidereLinkify.PATTERN_TWITTER_PROFILE_IMAGES;
|
||||
import static org.mariotaku.twidere.util.TwitterAPIUtils.getImageLoaderHttpClient;
|
||||
import static org.mariotaku.twidere.util.TwitterAPIUtils.getRedirectedHttpResponse;
|
||||
import static org.mariotaku.twidere.util.Utils.getNormalTwitterProfileImage;
|
||||
import static org.mariotaku.twidere.util.Utils.getTwitterAuthorization;
|
||||
import static org.mariotaku.twidere.util.Utils.getTwitterProfileImageOfSize;
|
||||
|
||||
public class TwidereImageDownloader extends BaseImageDownloader implements Constants {
|
||||
|
||||
private final Context mContext;
|
||||
|
@ -85,7 +80,7 @@ public class TwidereImageDownloader extends BaseImageDownloader implements Const
|
|||
}
|
||||
|
||||
public void reloadConnectivitySettings() {
|
||||
mClient = getImageLoaderHttpClient(mContext);
|
||||
mClient = TwitterAPIUtils.getDefaultHttpClient(mContext);
|
||||
mFastImageLoading = mPreferences.getBoolean(KEY_FAST_IMAGE_LOADING);
|
||||
if (mUseThumbor && mPreferences.getBoolean(KEY_THUMBOR_ENABLED)) {
|
||||
final String address = mPreferences.getString(KEY_THUMBOR_ADDRESS, null);
|
||||
|
@ -112,7 +107,7 @@ public class TwidereImageDownloader extends BaseImageDownloader implements Const
|
|||
try {
|
||||
final String mediaUrl = media != null ? media.media_url : uriString;
|
||||
if (isTwitterProfileImage(uriString)) {
|
||||
final String replaced = getTwitterProfileImageOfSize(mediaUrl, mTwitterProfileImageSize);
|
||||
final String replaced = Utils.getTwitterProfileImageOfSize(mediaUrl, mTwitterProfileImageSize);
|
||||
return getStreamFromNetworkInternal(replaced, extras);
|
||||
} else
|
||||
return getStreamFromNetworkInternal(mediaUrl, extras);
|
||||
|
@ -120,7 +115,7 @@ public class TwidereImageDownloader extends BaseImageDownloader implements Const
|
|||
final int statusCode = e.getStatusCode();
|
||||
if (statusCode != -1 && isTwitterProfileImage(uriString) && !uriString.contains("_normal.")) {
|
||||
try {
|
||||
return getStreamFromNetworkInternal(getNormalTwitterProfileImage(uriString), extras);
|
||||
return getStreamFromNetworkInternal(Utils.getNormalTwitterProfileImage(uriString), extras);
|
||||
} catch (final TwitterException ignored) {
|
||||
}
|
||||
}
|
||||
|
@ -159,7 +154,7 @@ public class TwidereImageDownloader extends BaseImageDownloader implements Const
|
|||
if (isTwitterAuthRequired(uri) && extras instanceof AccountExtra) {
|
||||
final AccountExtra accountExtra = (AccountExtra) extras;
|
||||
account = ParcelableAccount.getCredentials(mContext, accountExtra.account_id);
|
||||
auth = getTwitterAuthorization(mContext, accountExtra.account_id);
|
||||
auth = Utils.getTwitterAuthorization(mContext, accountExtra.account_id);
|
||||
} else {
|
||||
account = null;
|
||||
auth = null;
|
||||
|
@ -172,7 +167,7 @@ public class TwidereImageDownloader extends BaseImageDownloader implements Const
|
|||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
||||
additionalHeaders.add(Pair.create("Accept", "image/webp, */*"));
|
||||
}
|
||||
final RestResponse resp = getRedirectedHttpResponse(mClient, modifiedUri, uriString, auth, additionalHeaders);
|
||||
final RestResponse resp = TwitterAPIUtils.getRedirectedHttpResponse(mClient, modifiedUri, uriString, auth, additionalHeaders);
|
||||
final TypedData body = resp.getBody();
|
||||
return new ContentLengthInputStream(body.stream(), (int) body.length());
|
||||
}
|
||||
|
@ -184,7 +179,7 @@ public class TwidereImageDownloader extends BaseImageDownloader implements Const
|
|||
|
||||
private boolean isTwitterProfileImage(final String uriString) {
|
||||
if (TextUtils.isEmpty(uriString)) return false;
|
||||
return PATTERN_TWITTER_PROFILE_IMAGES.matcher(uriString).matches();
|
||||
return TwidereLinkify.PATTERN_TWITTER_PROFILE_IMAGES.matcher(uriString).matches();
|
||||
}
|
||||
|
||||
private boolean isTwitterUri(final Uri uri) {
|
||||
|
|
|
@ -23,6 +23,7 @@ import android.content.Context;
|
|||
import android.content.SharedPreferences;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.util.Log;
|
||||
import android.util.LruCache;
|
||||
|
||||
import org.apache.http.conn.util.InetAddressUtils;
|
||||
import org.mariotaku.twidere.Constants;
|
||||
|
@ -46,14 +47,11 @@ import java.net.InetAddress;
|
|||
import java.net.UnknownHostException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import twitter4j.http.HostAddressResolver;
|
||||
|
||||
import static android.text.TextUtils.isEmpty;
|
||||
|
||||
public class TwidereHostAddressResolver implements Constants, HostAddressResolver {
|
||||
|
||||
private static final String RESOLVER_LOGTAG = "Twidere.Host";
|
||||
|
@ -62,22 +60,16 @@ public class TwidereHostAddressResolver implements Constants, HostAddressResolve
|
|||
|
||||
private final SharedPreferences mHostMapping, mPreferences;
|
||||
private final HostsFileParser mSystemHosts = new HostsFileParser();
|
||||
private final HostCache mHostCache = new HostCache(512);
|
||||
private final boolean mLocalMappingOnly;
|
||||
private final LruCache<String, InetAddress[]> mHostCache = new LruCache<>(512);
|
||||
private final String mDnsAddress;
|
||||
|
||||
private Resolver mDns;
|
||||
|
||||
public TwidereHostAddressResolver(final Context context) {
|
||||
this(context, false);
|
||||
}
|
||||
|
||||
public TwidereHostAddressResolver(final Context context, final boolean localOnly) {
|
||||
mHostMapping = context.getSharedPreferences(HOST_MAPPING_PREFERENCES_NAME, Context.MODE_PRIVATE);
|
||||
mPreferences = context.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
|
||||
final String address = mPreferences.getString(KEY_DNS_SERVER, DEFAULT_DNS_SERVER_ADDRESS);
|
||||
mDnsAddress = isValidIpAddress(address) ? address : DEFAULT_DNS_SERVER_ADDRESS;
|
||||
mLocalMappingOnly = localOnly;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
|
@ -91,15 +83,16 @@ public class TwidereHostAddressResolver implements Constants, HostAddressResolve
|
|||
return resolveInternal(host, host);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
private InetAddress[] resolveInternal(String originalHost, String host) throws IOException {
|
||||
if (isValidIpAddress(host)) return fromAddressString(originalHost, host);
|
||||
// First, I'll try to load address cached.
|
||||
if (mHostCache.containsKey(host)) {
|
||||
final InetAddress[] hostAddr = mHostCache.get(host);
|
||||
final InetAddress[] cachedHostAddr = mHostCache.get(host);
|
||||
if (cachedHostAddr != null) {
|
||||
if (Utils.isDebugBuild()) {
|
||||
Log.d(RESOLVER_LOGTAG, "Got cached " + Arrays.toString(hostAddr));
|
||||
Log.d(RESOLVER_LOGTAG, "Got cached " + Arrays.toString(cachedHostAddr));
|
||||
return cachedHostAddr;
|
||||
}
|
||||
return hostAddr;
|
||||
}
|
||||
// Then I'll try to load from custom host mapping.
|
||||
// Stupid way to find top domain, but really fast.
|
||||
|
@ -209,22 +202,7 @@ public class TwidereHostAddressResolver implements Constants, HostAddressResolve
|
|||
}
|
||||
|
||||
private static boolean isValidIpAddress(final String address) {
|
||||
if (isEmpty(address)) return false;
|
||||
return InetAddressUtils.isIPv4Address(address) || InetAddressUtils.isIPv6Address(address);
|
||||
}
|
||||
|
||||
private static class HostCache extends LinkedHashMap<String, InetAddress[]> {
|
||||
|
||||
private static final long serialVersionUID = -9216545511009449147L;
|
||||
|
||||
HostCache(final int initialCapacity) {
|
||||
super(initialCapacity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InetAddress[] put(final String key, final InetAddress... value) {
|
||||
if (value == null) return null;
|
||||
return super.put(key, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue