Make a bunch of objects and vals const

This commit is contained in:
TacoTheDank 2020-06-08 17:11:06 -04:00
parent a9f5129d95
commit 973237dff9
48 changed files with 93 additions and 93 deletions

View File

@ -95,8 +95,8 @@ public class KeyboardShortcutsFragment extends BasePreferenceFragment implements
protected void onClick() {
final Context context = getContext();
final Intent intent = new Intent(context, KeyboardShortcutPreferenceCompatActivity.class);
intent.putExtra(KeyboardShortcutPreferenceCompatActivity.Companion.getEXTRA_CONTEXT_TAG(), mContextTag);
intent.putExtra(KeyboardShortcutPreferenceCompatActivity.Companion.getEXTRA_KEY_ACTION(), mAction);
intent.putExtra(KeyboardShortcutPreferenceCompatActivity.EXTRA_CONTEXT_TAG, mContextTag);
intent.putExtra(KeyboardShortcutPreferenceCompatActivity.EXTRA_KEY_ACTION, mAction);
context.startActivity(intent);
}

View File

@ -69,7 +69,7 @@ class ColorPickerDialogActivity : BaseActivity(), Callback {
companion object {
val RESULT_CLEARED = -2
const val RESULT_CLEARED = -2
}
}

View File

@ -1924,7 +1924,7 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
}
companion object {
val ALPHA_FULL = 1.0f
const val ALPHA_FULL = 1.0f
}
}

View File

@ -134,7 +134,7 @@ class DataExportActivity : BaseActivity(), DataExportImportTypeSelectorDialogFra
}
companion object {
private val FRAGMENT_TAG = "import_settings_dialog"
private const val FRAGMENT_TAG = "import_settings_dialog"
}
}

View File

@ -140,7 +140,7 @@ class DataImportActivity : BaseActivity(), DataExportImportTypeSelectorDialogFra
}
companion object {
private val FRAGMENT_TAG = "import_settings_dialog"
private const val FRAGMENT_TAG = "import_settings_dialog"
}
}
@ -185,7 +185,7 @@ class DataImportActivity : BaseActivity(), DataExportImportTypeSelectorDialogFra
companion object {
private val FRAGMENT_TAG = "read_settings_data_dialog"
private const val FRAGMENT_TAG = "read_settings_data_dialog"
}
}

View File

@ -119,7 +119,7 @@ class KeyboardShortcutPreferenceCompatActivity : BaseActivity(), OnClickListener
companion object {
val EXTRA_CONTEXT_TAG = "context_tag"
val EXTRA_KEY_ACTION = "key_action"
const val EXTRA_CONTEXT_TAG = "context_tag"
const val EXTRA_KEY_ACTION = "key_action"
}
}

View File

@ -635,10 +635,10 @@ class MediaViewerActivity : BaseActivity(), IMediaViewerActivity, MediaSwipeClos
companion object {
private val REQUEST_SHARE_MEDIA = 201
private val REQUEST_PERMISSION_SAVE_MEDIA = 202
private val REQUEST_PERMISSION_SHARE_MEDIA = 203
private val REQUEST_SELECT_SAVE_MEDIA = 204
private const val REQUEST_SHARE_MEDIA = 201
private const val REQUEST_PERMISSION_SAVE_MEDIA = 202
private const val REQUEST_PERMISSION_SHARE_MEDIA = 203
private const val REQUEST_SELECT_SAVE_MEDIA = 204
@RequiresApi(Build.VERSION_CODES.JELLY_BEAN)
const val FLAG_SYSTEM_UI_HIDE_BARS = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or

View File

@ -538,10 +538,10 @@ class QuickSearchBarActivity : BaseActivity(), OnClickListener, LoaderCallbacks<
companion object {
internal val VIEW_TYPE_SEARCH_HISTORY = 0
internal val VIEW_TYPE_SAVED_SEARCH = 1
internal val VIEW_TYPE_USER_SUGGESTION_ITEM = 2
internal val VIEW_TYPE_USER_SCREEN_NAME = 3
internal const val VIEW_TYPE_SEARCH_HISTORY = 0
internal const val VIEW_TYPE_SAVED_SEARCH = 1
internal const val VIEW_TYPE_USER_SUGGESTION_ITEM = 2
internal const val VIEW_TYPE_USER_SCREEN_NAME = 3
}
}

View File

@ -349,8 +349,8 @@ class SettingsActivity : BaseActivity(), OnItemClickListener, OnPreferenceStartF
companion object {
val VIEW_TYPE_PREFERENCE_ENTRY = 0
val VIEW_TYPE_HEADER_ENTRY = 1
const val VIEW_TYPE_PREFERENCE_ENTRY = 0
const val VIEW_TYPE_HEADER_ENTRY = 1
}
}
@ -424,7 +424,7 @@ class SettingsActivity : BaseActivity(), OnItemClickListener, OnPreferenceStartF
companion object {
private val RESULT_SETTINGS_CHANGED = 10
private const val RESULT_SETTINGS_CHANGED = 10
fun setShouldRecreate(activity: Activity) {
if (activity !is SettingsActivity) return

View File

@ -1189,8 +1189,8 @@ class SignInActivity : BaseActivity(), OnClickListener, TextWatcher,
const val REQUEST_BROWSER_TWITTER_SIGN_IN = 101
const val REQUEST_BROWSER_MASTODON_SIGN_IN = 102
private val FRAGMENT_TAG_SIGN_IN_PROGRESS = "sign_in_progress"
private val EXTRA_API_LAST_CHANGE = "api_last_change"
private const val FRAGMENT_TAG_SIGN_IN_PROGRESS = "sign_in_progress"
private const val EXTRA_API_LAST_CHANGE = "api_last_change"
@Throws(IOException::class)
internal fun detectAccountType(twitter: MicroBlog, user: User, type: String?): Pair<String, AccountExtras?> {

View File

@ -366,7 +366,7 @@ class WebLinkHandlerActivity : Activity() {
"photo", "album", "paipai", "q", "userview", "dialogue")
private val AUTHORITY_TWITTER_COM = "twitter.com"
private const val AUTHORITY_TWITTER_COM = "twitter.com"
private fun regulateTwitterUri(data: Uri): Uri {

View File

@ -142,6 +142,6 @@ class ParcelableGroupsAdapter(
companion object {
val ITEM_VIEW_TYPE_USER_LIST = 2
const val ITEM_VIEW_TYPE_USER_LIST = 2
}
}

View File

@ -122,7 +122,7 @@ class ParcelableUserListsAdapter(
companion object {
val ITEM_VIEW_TYPE_USER_LIST = 2
const val ITEM_VIEW_TYPE_USER_LIST = 2
fun createUserListViewHolder(adapter: IUserListsAdapter<*>,
inflater: LayoutInflater,

View File

@ -162,6 +162,6 @@ class SupportTabsAdapter(
companion object {
private val EXTRA_ADAPTER_POSITION = "adapter_position"
private const val EXTRA_ADAPTER_POSITION = "adapter_position"
}
}

View File

@ -112,9 +112,9 @@ class VariousItemsAdapter(
companion object {
val VIEW_TYPE_STATUS = 1
val VIEW_TYPE_USER = 2
val VIEW_TYPE_USER_LIST = 3
val VIEW_TYPE_HASHTAG = 4
const val VIEW_TYPE_STATUS = 1
const val VIEW_TYPE_USER = 2
const val VIEW_TYPE_USER_LIST = 3
const val VIEW_TYPE_HASHTAG = 4
}
}

View File

@ -36,7 +36,7 @@ interface ILoadMoreSupportAdapter {
annotation class IndicatorPosition
companion object {
val ITEM_VIEW_TYPE_LOAD_INDICATOR = 0
const val ITEM_VIEW_TYPE_LOAD_INDICATOR = 0
const val NONE: Long = 0
const val START: Long = 1

View File

@ -329,7 +329,7 @@ class TwidereApplication : Application(), OnSharedPreferenceChangeListener {
companion object {
private val KEY_KEYBOARD_SHORTCUT_INITIALIZED = "keyboard_shortcut_initialized"
private const val KEY_KEYBOARD_SHORTCUT_INITIALIZED = "keyboard_shortcut_initialized"
var instance: TwidereApplication? = null
private set

View File

@ -241,6 +241,6 @@ class AccountsManagerFragment : BaseFragment(), LoaderManager.LoaderCallbacks<Li
companion object {
private val FRAGMENT_TAG_ACCOUNT_DELETION = "account_deletion"
private const val FRAGMENT_TAG_ACCOUNT_DELETION = "account_deletion"
}
}

View File

@ -194,7 +194,7 @@ class AddStatusFilterDialogFragment : BaseDialogFragment() {
companion object {
val FRAGMENT_TAG = "add_status_filter"
const val FRAGMENT_TAG = "add_status_filter"
private fun createFilteredUser(item: UserItem): ContentValues {
val values = ContentValues()

View File

@ -140,8 +140,8 @@ abstract class BasePreferenceFragment : PreferenceFragmentCompat(), IBaseFragmen
companion object {
private val REQUEST_PICK_RINGTONE = 301
private val EXTRA_RINGTONE_PREFERENCE_KEY = "internal:ringtone_preference_key"
private const val REQUEST_PICK_RINGTONE = 301
private const val EXTRA_RINGTONE_PREFERENCE_KEY = "internal:ringtone_preference_key"
}
}

View File

@ -48,7 +48,7 @@ class CreateUserBlockDialogFragment : AbsUserMuteBlockDialogFragment() {
companion object {
val FRAGMENT_TAG = "create_user_block"
const val FRAGMENT_TAG = "create_user_block"
fun show(fm: FragmentManager, user: ParcelableUser): CreateUserBlockDialogFragment {
val args = Bundle()

View File

@ -49,7 +49,7 @@ class CreateUserMuteDialogFragment : AbsUserMuteBlockDialogFragment() {
companion object {
val FRAGMENT_TAG = "create_user_mute"
const val FRAGMENT_TAG = "create_user_mute"
fun show(fm: FragmentManager, user: ParcelableUser): CreateUserMuteDialogFragment {
val args = Bundle()

View File

@ -90,7 +90,7 @@ class DeleteUserListMembersDialogFragment : BaseDialogFragment(), DialogInterfac
companion object {
val FRAGMENT_TAG = "destroy_user_list_member"
const val FRAGMENT_TAG = "destroy_user_list_member"
fun show(fm: FragmentManager, userList: ParcelableUserList,
vararg users: ParcelableUser): DeleteUserListMembersDialogFragment {

View File

@ -65,7 +65,7 @@ class DestroyFriendshipDialogFragment : BaseDialogFragment(), DialogInterface.On
companion object {
val FRAGMENT_TAG = "destroy_friendship"
const val FRAGMENT_TAG = "destroy_friendship"
fun show(fm: FragmentManager, user: ParcelableUser): DestroyFriendshipDialogFragment {
val f = DestroyFriendshipDialogFragment()

View File

@ -69,7 +69,7 @@ class DestroyUserListSubscriptionDialogFragment : BaseDialogFragment(), DialogIn
companion object {
val FRAGMENT_TAG = "destroy_user_list"
const val FRAGMENT_TAG = "destroy_user_list"
fun show(fm: FragmentManager,
userList: ParcelableUserList): DestroyUserListSubscriptionDialogFragment {

View File

@ -257,10 +257,10 @@ class HostMappingsListFragment : AbsContentListViewFragment<HostMappingsListFrag
companion object {
private val EXTRA_EDIT_MODE = "edit_mode"
private val EXTRA_HOST = "host"
private val EXTRA_ADDRESS = "address"
private val EXTRA_EXCLUDED = "excluded"
private const val EXTRA_EDIT_MODE = "edit_mode"
private const val EXTRA_HOST = "host"
private const val EXTRA_ADDRESS = "address"
private const val EXTRA_EXCLUDED = "excluded"
}
}

View File

@ -49,7 +49,7 @@ class ReportUserSpamDialogFragment : AbsUserMuteBlockDialogFragment() {
companion object {
val FRAGMENT_TAG = "report_user_spam"
const val FRAGMENT_TAG = "report_user_spam"
fun show(fm: FragmentManager, user: ParcelableUser): ReportUserSpamDialogFragment {
val f = ReportUserSpamDialogFragment()

View File

@ -1887,8 +1887,8 @@ class UserFragment : BaseFragment(), OnClickListener, OnLinkClickListener,
companion object {
private val sArgbEvaluator = ArgbEvaluator()
private val LOADER_ID_USER = 1
private val LOADER_ID_FRIENDSHIP = 2
private const val LOADER_ID_USER = 1
private const val LOADER_ID_FRIENDSHIP = 2
private const val TAB_POSITION_STATUSES = 0
private const val TAB_POSITION_MEDIA = 1

View File

@ -455,7 +455,7 @@ class UserProfileEditorFragment : BaseFragment(), OnSizeChangedListener,
companion object {
private val DIALOG_FRAGMENT_TAG = "updating_user_profile"
private const val DIALOG_FRAGMENT_TAG = "updating_user_profile"
}
}
@ -558,16 +558,16 @@ class UserProfileEditorFragment : BaseFragment(), OnSizeChangedListener,
companion object {
private val LOADER_ID_USER = 1
private const val LOADER_ID_USER = 1
private val REQUEST_UPLOAD_PROFILE_IMAGE = 1
private val REQUEST_UPLOAD_PROFILE_BANNER_IMAGE = 2
private val REQUEST_UPLOAD_PROFILE_BACKGROUND_IMAGE = 3
private val REQUEST_PICK_LINK_COLOR = 11
private val REQUEST_PICK_BACKGROUND_COLOR = 12
private const val REQUEST_UPLOAD_PROFILE_IMAGE = 1
private const val REQUEST_UPLOAD_PROFILE_BANNER_IMAGE = 2
private const val REQUEST_UPLOAD_PROFILE_BACKGROUND_IMAGE = 3
private const val REQUEST_PICK_LINK_COLOR = 11
private const val REQUEST_PICK_BACKGROUND_COLOR = 12
private val RESULT_REMOVE_BANNER = 101
private val UPDATE_PROFILE_DIALOG_FRAGMENT_TAG = "update_profile"
private const val RESULT_REMOVE_BANNER = 101
private const val UPDATE_PROFILE_DIALOG_FRAGMENT_TAG = "update_profile"
}
}

View File

@ -337,7 +337,7 @@ class DraftsListFragment : AbsContentListViewFragment<DraftsAdapter>(), LoaderCa
companion object {
private val FRAGMENT_TAG_DELETING_DRAFTS = "deleting_drafts"
private const val FRAGMENT_TAG_DELETING_DRAFTS = "deleting_drafts"
}
}
}

View File

@ -38,7 +38,7 @@ class DestroyStatusDialogFragment : AbsSimpleStatusOperationDialogFragment() {
companion object {
val FRAGMENT_TAG = "destroy_status"
const val FRAGMENT_TAG = "destroy_status"
fun show(fm: FragmentManager, status: ParcelableStatus): DestroyStatusDialogFragment {
val args = Bundle()

View File

@ -103,7 +103,7 @@ class FavoriteConfirmDialogFragment : AbsStatusDialogFragment() {
companion object {
val FRAGMENT_TAG = "favorite_confirm"
const val FRAGMENT_TAG = "favorite_confirm"
fun show(fm: FragmentManager, accountKey: UserKey, statusId: String,
status: ParcelableStatus? = null): FavoriteConfirmDialogFragment {

View File

@ -41,7 +41,7 @@ class PinStatusDialogFragment : AbsSimpleStatusOperationDialogFragment() {
companion object {
val FRAGMENT_TAG = "pin_status"
const val FRAGMENT_TAG = "pin_status"
fun show(fm: FragmentManager, status: ParcelableStatus): PinStatusDialogFragment {
val args = Bundle()

View File

@ -344,7 +344,7 @@ class RetweetQuoteDialogFragment : AbsStatusDialogFragment() {
companion object {
private const val FRAGMENT_TAG = "retweet_quote"
private val showProtectedConfirm = false
private const val showProtectedConfirm = false
fun show(fm: FragmentManager, accountKey: UserKey, statusId: String,
status: ParcelableStatus? = null, text: String? = null):

View File

@ -955,12 +955,12 @@ class StatusFragment : BaseFragment(), LoaderCallbacks<SingleResponse<Parcelable
companion object {
// Constants
private val LOADER_ID_DETAIL_STATUS = 1
private val LOADER_ID_STATUS_CONVERSATIONS = 2
private val LOADER_ID_STATUS_ACTIVITY = 3
private val STATE_LOADED = 1
private val STATE_LOADING = 2
private val STATE_ERROR = 3
private const val LOADER_ID_DETAIL_STATUS = 1
private const val LOADER_ID_STATUS_CONVERSATIONS = 2
private const val LOADER_ID_STATUS_ACTIVITY = 3
private const val STATE_LOADED = 1
private const val STATE_LOADING = 2
private const val STATE_ERROR = 3
fun Bundle.toPagination(): Pagination {
val maxId = getString(EXTRA_MAX_ID)

View File

@ -41,7 +41,7 @@ class UnpinStatusDialogFragment : AbsSimpleStatusOperationDialogFragment() {
companion object {
val FRAGMENT_TAG = "unpin_status"
const val FRAGMENT_TAG = "unpin_status"
fun show(fm: FragmentManager, status: ParcelableStatus): UnpinStatusDialogFragment {
val args = Bundle()

View File

@ -51,7 +51,7 @@ class AccountActionProvider(
companion object {
val MENU_GROUP = 201
const val MENU_GROUP = 201
}
}

View File

@ -400,7 +400,7 @@ class LengthyOperationsService : BaseIntentService("lengthy_operations") {
}
companion object {
private val BULK_SIZE = (128 * 1024).toLong() // 128KiB
private const val BULK_SIZE = (128 * 1024).toLong() // 128KiB
private fun updateSendDirectMessageNotification(context: Context,
builder: NotificationCompat.Builder,

View File

@ -53,6 +53,6 @@ abstract class ProgressSaveFileTask(
}
companion object {
private val PROGRESS_FRAGMENT_TAG = "progress"
private const val PROGRESS_FRAGMENT_TAG = "progress"
}
}

View File

@ -690,7 +690,7 @@ class UpdateStatusTask(
companion object {
private val BULK_SIZE = 512 * 1024// 512 Kib
private const val BULK_SIZE = 512 * 1024// 512 Kib
@Throws(UploadException::class)
fun uploadMicroBlogMediaShared(context: Context, upload: TwitterUpload,

View File

@ -81,15 +81,15 @@ class ErrorInfoStore(application: Context) {
companion object {
val KEY_DIRECT_MESSAGES = "direct_messages"
val KEY_INTERACTIONS = "interactions"
val KEY_HOME_TIMELINE = "home_timeline"
val KEY_ACTIVITIES_BY_FRIENDS = "activities_by_friends"
const val KEY_DIRECT_MESSAGES = "direct_messages"
const val KEY_INTERACTIONS = "interactions"
const val KEY_HOME_TIMELINE = "home_timeline"
const val KEY_ACTIVITIES_BY_FRIENDS = "activities_by_friends"
val CODE_NO_DM_PERMISSION = 1
val CODE_NO_ACCESS_FOR_CREDENTIALS = 2
val CODE_NETWORK_ERROR = 3
val CODE_TIMESTAMP_ERROR = 4
const val CODE_NO_DM_PERMISSION = 1
const val CODE_NO_ACCESS_FOR_CREDENTIALS = 2
const val CODE_NETWORK_ERROR = 3
const val CODE_TIMESTAMP_ERROR = 4
fun getErrorInfo(context: Context, code: Int): DisplayErrorInfo? {
when (code) {

View File

@ -34,8 +34,8 @@ import org.mariotaku.twidere.model.UserKey
*/
object LinkCreator {
private val AUTHORITY_TWITTER = "twitter.com"
private val AUTHORITY_FANFOU = "fanfou.com"
private const val AUTHORITY_TWITTER = "twitter.com"
private const val AUTHORITY_FANFOU = "fanfou.com"
fun getTwidereStatusLink(accountKey: UserKey?, statusId: String): Uri {
val builder = Uri.Builder()

View File

@ -218,7 +218,7 @@ class MultiSelectEventHandler(
companion object {
val MENU_GROUP = 201
const val MENU_GROUP = 201
}
}

View File

@ -200,7 +200,7 @@ class UserColorNameManager(context: Context) {
companion object {
private val NICKNAME_NULL = ".#NULL#"
private const val NICKNAME_NULL = ".#NULL#"
fun decideDisplayName(nickname: String?, name: String, screenName: String,
nameFirst: Boolean) = nickname ?: if (nameFirst) name else "@$screenName"

View File

@ -55,7 +55,7 @@ class SystemHosts {
companion object {
private val HOSTS_PATH = "/system/etc/hosts"
private const val HOSTS_PATH = "/system/etc/hosts"
}
}

View File

@ -236,7 +236,7 @@ class TwidereDns(val context: Context, private val preferences: SharedPreference
companion object {
private val RESOLVER_LOGTAG = "TwidereDns"
private const val RESOLVER_LOGTAG = "TwidereDns"
private fun hostMatches(host: String?, rule: String?): Boolean {

View File

@ -116,6 +116,6 @@ class SyncStatusViewController : PremiumDashboardActivity.ExtraFeatureViewContro
}
companion object {
private val REQUEST_CONNECT_NETWORK_STORAGE: Int = 201
private const val REQUEST_CONNECT_NETWORK_STORAGE: Int = 201
}
}

View File

@ -761,12 +761,12 @@ class DetailStatusViewHolder(
internal class LabeledCount(var type: Int, var count: Long)
companion object {
private val ITEM_VIEW_TYPE_USER = 1
private val ITEM_VIEW_TYPE_COUNT = 2
private const val ITEM_VIEW_TYPE_USER = 1
private const val ITEM_VIEW_TYPE_COUNT = 2
private val KEY_REPLY_COUNT = 1
private val KEY_RETWEET_COUNT = 2
private val KEY_FAVORITE_COUNT = 3
private const val KEY_REPLY_COUNT = 1
private const val KEY_RETWEET_COUNT = 2
private const val KEY_FAVORITE_COUNT = 3
}
}