1
0
mirror of https://github.com/KokaKiwi/BarInsta synced 2024-11-22 14:47:29 +00:00

convert some more classes to kotlin

This commit is contained in:
Austin Huang 2021-05-22 16:22:16 -04:00
parent 1ad2b3e72b
commit c003cf5900
No known key found for this signature in database
GPG Key ID: 84C23AA04587A91F
3 changed files with 137 additions and 141 deletions

View File

@ -1,40 +1,43 @@
package awais.instagrabber.fragments.settings;
package awais.instagrabber.fragments.settings
public final class PreferenceKeys {
object PreferenceKeys {
// new boolean prefs
public static final String PREF_ENABLE_DM_NOTIFICATIONS = "enable_dm_notifications";
public static final String PREF_ENABLE_DM_AUTO_REFRESH = "enable_dm_auto_refresh";
public static final String PREF_ENABLE_DM_AUTO_REFRESH_FREQ_UNIT = "enable_dm_auto_refresh_freq_unit";
public static final String PREF_ENABLE_DM_AUTO_REFRESH_FREQ_NUMBER = "enable_dm_auto_refresh_freq_number";
public static final String PREF_ENABLE_SENTRY = "enable_sentry";
public static final String PREF_TAB_ORDER = "tab_order";
public static final String PREF_SHOWN_COUNT_TOOLTIP = "shown_count_tooltip";
public static final String PREF_SEARCH_FOCUS_KEYBOARD = "search_focus_keyboard";
const val PREF_ENABLE_DM_NOTIFICATIONS = "enable_dm_notifications"
const val PREF_ENABLE_DM_AUTO_REFRESH = "enable_dm_auto_refresh"
const val PREF_ENABLE_DM_AUTO_REFRESH_FREQ_UNIT = "enable_dm_auto_refresh_freq_unit"
const val PREF_ENABLE_DM_AUTO_REFRESH_FREQ_NUMBER = "enable_dm_auto_refresh_freq_number"
const val PREF_ENABLE_SENTRY = "enable_sentry"
const val PREF_TAB_ORDER = "tab_order"
const val PREF_SHOWN_COUNT_TOOLTIP = "shown_count_tooltip"
const val PREF_SEARCH_FOCUS_KEYBOARD = "search_focus_keyboard"
// string prefs
public static final String FOLDER_PATH = "custom_path";
public static final String DATE_TIME_FORMAT = "date_time_format";
public static final String DATE_TIME_SELECTION = "date_time_selection";
public static final String CUSTOM_DATE_TIME_FORMAT = "date_time_custom_format";
public static final String APP_THEME = "app_theme_v19";
public static final String APP_LANGUAGE = "app_language_v19";
public static final String STORY_SORT = "story_sort";
const val FOLDER_PATH = "custom_path"
const val DATE_TIME_FORMAT = "date_time_format"
const val DATE_TIME_SELECTION = "date_time_selection"
const val CUSTOM_DATE_TIME_FORMAT = "date_time_custom_format"
const val APP_THEME = "app_theme_v19"
const val APP_LANGUAGE = "app_language_v19"
const val STORY_SORT = "story_sort"
// set string prefs
public static final String KEYWORD_FILTERS = "keyword_filters";
const val KEYWORD_FILTERS = "keyword_filters"
// old boolean prefs
public static final String DOWNLOAD_USER_FOLDER = "download_user_folder";
public static final String TOGGLE_KEYWORD_FILTER = "toggle_keyword_filter";
public static final String DOWNLOAD_PREPEND_USER_NAME = "download_user_name";
public static final String PLAY_IN_BACKGROUND = "play_in_background";
public static final String FOLDER_SAVE_TO = "saved_to";
public static final String AUTOPLAY_VIDEOS = "autoplay_videos";
public static final String MUTED_VIDEOS = "muted_videos";
public static final String SHOW_CAPTIONS = "show_captions";
public static final String CUSTOM_DATE_TIME_FORMAT_ENABLED = "data_time_custom_enabled";
public static final String SWAP_DATE_TIME_FORMAT_ENABLED = "swap_date_time_enabled";
public static final String MARK_AS_SEEN = "mark_as_seen";
public static final String HIDE_MUTED_REELS = "hide_muted_reels";
public static final String DM_MARK_AS_SEEN = "dm_mark_as_seen";
public static final String CHECK_ACTIVITY = "check_activity";
public static final String CHECK_UPDATES = "check_updates";
public static final String FLAG_SECURE = "flag_secure";
}
const val DOWNLOAD_USER_FOLDER = "download_user_folder"
const val TOGGLE_KEYWORD_FILTER = "toggle_keyword_filter"
const val DOWNLOAD_PREPEND_USER_NAME = "download_user_name"
const val PLAY_IN_BACKGROUND = "play_in_background"
const val FOLDER_SAVE_TO = "saved_to"
const val AUTOPLAY_VIDEOS = "autoplay_videos"
const val MUTED_VIDEOS = "muted_videos"
const val SHOW_CAPTIONS = "show_captions"
const val CUSTOM_DATE_TIME_FORMAT_ENABLED = "data_time_custom_enabled"
const val SWAP_DATE_TIME_FORMAT_ENABLED = "swap_date_time_enabled"
const val MARK_AS_SEEN = "mark_as_seen"
const val HIDE_MUTED_REELS = "hide_muted_reels"
const val DM_MARK_AS_SEEN = "dm_mark_as_seen"
const val CHECK_ACTIVITY = "check_activity"
const val CHECK_UPDATES = "check_updates"
const val FLAG_SECURE = "flag_secure"
}

View File

@ -1,95 +1,92 @@
package awais.instagrabber.utils;
package awais.instagrabber.utils
public final class Constants {
public static final String CRASH_REPORT_EMAIL = "barinsta@austinhuang.me";
object Constants {
const val CRASH_REPORT_EMAIL = "barinsta@austinhuang.me"
// int prefs, do not export
public static final String PREV_INSTALL_VERSION = "prevVersion";
public static final String BROWSER_UA_CODE = "browser_ua_code";
public static final String APP_UA_CODE = "app_ua_code";
const val PREV_INSTALL_VERSION = "prevVersion"
const val BROWSER_UA_CODE = "browser_ua_code"
const val APP_UA_CODE = "app_ua_code"
// never Export
public static final String COOKIE = "cookie";
const val COOKIE = "cookie"
// deprecated: public static final String SHOW_QUICK_ACCESS_DIALOG = "show_quick_dlg";
public static final String DEVICE_UUID = "device_uuid";
public static final String BROWSER_UA = "browser_ua";
public static final String APP_UA = "app_ua";
const val DEVICE_UUID = "device_uuid"
const val BROWSER_UA = "browser_ua"
const val APP_UA = "app_ua"
//////////////////////// EXTRAS ////////////////////////
public static final String EXTRAS_USER = "user";
public static final String EXTRAS_HASHTAG = "hashtag";
public static final String EXTRAS_LOCATION = "location";
public static final String EXTRAS_USERNAME = "username";
public static final String EXTRAS_ID = "id";
public static final String EXTRAS_POST = "post";
public static final String EXTRAS_PROFILE = "profile";
public static final String EXTRAS_TYPE = "type";
public static final String EXTRAS_NAME = "name";
public static final String EXTRAS_STORIES = "stories";
public static final String EXTRAS_HIGHLIGHT = "highlight";
public static final String EXTRAS_INDEX = "index";
public static final String EXTRAS_THREAD_MODEL = "threadModel";
public static final String EXTRAS_FOLLOWERS = "followers";
public static final String EXTRAS_SHORTCODE = "shortcode";
public static final String EXTRAS_END_CURSOR = "endCursor";
public static final String FEED = "feed";
public static final String FEED_ORDER = "feedOrder";
const val EXTRAS_USER = "user"
const val EXTRAS_HASHTAG = "hashtag"
const val EXTRAS_LOCATION = "location"
const val EXTRAS_USERNAME = "username"
const val EXTRAS_ID = "id"
const val EXTRAS_POST = "post"
const val EXTRAS_PROFILE = "profile"
const val EXTRAS_TYPE = "type"
const val EXTRAS_NAME = "name"
const val EXTRAS_STORIES = "stories"
const val EXTRAS_HIGHLIGHT = "highlight"
const val EXTRAS_INDEX = "index"
const val EXTRAS_THREAD_MODEL = "threadModel"
const val EXTRAS_FOLLOWERS = "followers"
const val EXTRAS_SHORTCODE = "shortcode"
const val EXTRAS_END_CURSOR = "endCursor"
const val FEED = "feed"
const val FEED_ORDER = "feedOrder"
// Notification ids
public static final int ACTIVITY_NOTIFICATION_ID = 10;
public static final int DM_UNREAD_PARENT_NOTIFICATION_ID = 20;
public static final int DM_CHECK_NOTIFICATION_ID = 11;
const val ACTIVITY_NOTIFICATION_ID = 10
const val DM_UNREAD_PARENT_NOTIFICATION_ID = 20
const val DM_CHECK_NOTIFICATION_ID = 11
// see https://github.com/dilame/instagram-private-api/blob/master/src/core/constants.ts
// public static final String SUPPORTED_CAPABILITIES = "[ { \"name\": \"SUPPORTED_SDK_VERSIONS\", \"value\":" +
// " \"13.0,14.0,15.0,16.0,17.0,18.0,19.0,20.0,21.0,22.0,23.0,24.0,25.0,26.0,27.0,28.0,29.0,30.0,31.0," +
// "32.0,33.0,34.0,35.0,36.0,37.0,38.0,39.0,40.0,41.0,42.0,43.0,44.0,45.0,46.0,47.0,48.0,49.0,50.0,51.0," +
// "52.0,53.0,54.0,55.0,56.0,57.0,58.0,59.0,60.0,61.0,62.0,63.0,64.0,65.0,66.0\" }, { \"name\": \"FACE_TRACKER_VERSION\", " +
// "\"value\": 12 }, { \"name\": \"segmentation\", \"value\": \"segmentation_enabled\" }, { \"name\": \"COMPRESSION\", " +
// "\"value\": \"ETC2_COMPRESSION\" }, { \"name\": \"world_tracker\", \"value\": \"world_tracker_enabled\" }, { \"name\": " +
// "\"gyroscope\", \"value\": \"gyroscope_enabled\" } ]";
// public static final String SIGNATURE_VERSION = "4";
// public static final String SIGNATURE_KEY = "9193488027538fd3450b83b7d05286d4ca9599a0f7eeed90d8c85925698a05dc";
public static final String BREADCRUMB_KEY = "iN4$aGr0m";
public static final int LOGIN_RESULT_CODE = 5000;
public static final String SKIPPED_VERSION = "skipped_version";
public static final String DEFAULT_TAB = "default_tab";
public static final String PREF_DARK_THEME = "dark_theme";
public static final String PREF_LIGHT_THEME = "light_theme";
public static final String DEFAULT_HASH_TAG_PIC = "https://www.instagram.com/static/images/hashtag/search-hashtag-default-avatar.png/1d8417c9a4f5.png";
public static final String SHARED_PREFERENCES_NAME = "settings";
public static final String PREF_POSTS_LAYOUT = "posts_layout";
public static final String PREF_PROFILE_POSTS_LAYOUT = "profile_posts_layout";
public static final String PREF_TOPIC_POSTS_LAYOUT = "topic_posts_layout";
public static final String PREF_HASHTAG_POSTS_LAYOUT = "hashtag_posts_layout";
public static final String PREF_LOCATION_POSTS_LAYOUT = "location_posts_layout";
public static final String PREF_LIKED_POSTS_LAYOUT = "liked_posts_layout";
public static final String PREF_TAGGED_POSTS_LAYOUT = "tagged_posts_layout";
public static final String PREF_SAVED_POSTS_LAYOUT = "saved_posts_layout";
public static final String PREF_EMOJI_VARIANTS = "emoji_variants";
public static final String PREF_REACTIONS = "reactions";
public static final String ACTIVITY_CHANNEL_ID = "activity";
public static final String ACTIVITY_CHANNEL_NAME = "Activity";
public static final String DOWNLOAD_CHANNEL_ID = "download";
public static final String DOWNLOAD_CHANNEL_NAME = "Downloads";
public static final String DM_UNREAD_CHANNEL_ID = "dmUnread";
public static final String DM_UNREAD_CHANNEL_NAME = "Messages";
public static final String SILENT_NOTIFICATIONS_CHANNEL_ID = "silentNotifications";
public static final String SILENT_NOTIFICATIONS_CHANNEL_NAME = "Silent notifications";
public static final String NOTIF_GROUP_NAME = "awais.instagrabber.InstaNotif";
public static final String GROUP_KEY_DM = "awais.instagrabber.MESSAGES";
public static final String GROUP_KEY_SILENT_NOTIFICATIONS = "awais.instagrabber.SILENT_NOTIFICATIONS";
public static final int SHOW_ACTIVITY_REQUEST_CODE = 1738;
public static final int SHOW_DM_THREAD = 2000;
public static final int DM_SYNC_SERVICE_REQUEST_CODE = 3000;
public static final int GLOBAL_NETWORK_ERROR_DIALOG_REQUEST_CODE = 7777;
public static final String ACTION_SHOW_ACTIVITY = "show_activity";
public static final String ACTION_SHOW_DM_THREAD = "show_dm_thread";
public static final String DM_THREAD_ACTION_EXTRA_THREAD_ID = "thread_id";
public static final String DM_THREAD_ACTION_EXTRA_THREAD_TITLE = "thread_title";
public static final String X_IG_APP_ID = "936619743392459";
// public static final String SUPPORTED_CAPABILITIES = "[ { \"name\": \"SUPPORTED_SDK_VERSIONS\", \"value\":" +
// " \"13.0,14.0,15.0,16.0,17.0,18.0,19.0,20.0,21.0,22.0,23.0,24.0,25.0,26.0,27.0,28.0,29.0,30.0,31.0," +
// "32.0,33.0,34.0,35.0,36.0,37.0,38.0,39.0,40.0,41.0,42.0,43.0,44.0,45.0,46.0,47.0,48.0,49.0,50.0,51.0," +
// "52.0,53.0,54.0,55.0,56.0,57.0,58.0,59.0,60.0,61.0,62.0,63.0,64.0,65.0,66.0\" }, { \"name\": \"FACE_TRACKER_VERSION\", " +
// "\"value\": 12 }, { \"name\": \"segmentation\", \"value\": \"segmentation_enabled\" }, { \"name\": \"COMPRESSION\", " +
// "\"value\": \"ETC2_COMPRESSION\" }, { \"name\": \"world_tracker\", \"value\": \"world_tracker_enabled\" }, { \"name\": " +
// "\"gyroscope\", \"value\": \"gyroscope_enabled\" } ]";
// public static final String SIGNATURE_VERSION = "4";
// public static final String SIGNATURE_KEY = "9193488027538fd3450b83b7d05286d4ca9599a0f7eeed90d8c85925698a05dc";
const val BREADCRUMB_KEY = "iN4\$aGr0m"
const val LOGIN_RESULT_CODE = 5000
const val SKIPPED_VERSION = "skipped_version"
const val DEFAULT_TAB = "default_tab"
const val PREF_DARK_THEME = "dark_theme"
const val PREF_LIGHT_THEME = "light_theme"
const val DEFAULT_HASH_TAG_PIC = "https://www.instagram.com/static/images/hashtag/search-hashtag-default-avatar.png/1d8417c9a4f5.png"
const val SHARED_PREFERENCES_NAME = "settings"
const val PREF_POSTS_LAYOUT = "posts_layout"
const val PREF_PROFILE_POSTS_LAYOUT = "profile_posts_layout"
const val PREF_TOPIC_POSTS_LAYOUT = "topic_posts_layout"
const val PREF_HASHTAG_POSTS_LAYOUT = "hashtag_posts_layout"
const val PREF_LOCATION_POSTS_LAYOUT = "location_posts_layout"
const val PREF_LIKED_POSTS_LAYOUT = "liked_posts_layout"
const val PREF_TAGGED_POSTS_LAYOUT = "tagged_posts_layout"
const val PREF_SAVED_POSTS_LAYOUT = "saved_posts_layout"
const val PREF_EMOJI_VARIANTS = "emoji_variants"
const val PREF_REACTIONS = "reactions"
const val ACTIVITY_CHANNEL_ID = "activity"
const val ACTIVITY_CHANNEL_NAME = "Activity"
const val DOWNLOAD_CHANNEL_ID = "download"
const val DOWNLOAD_CHANNEL_NAME = "Downloads"
const val DM_UNREAD_CHANNEL_ID = "dmUnread"
const val DM_UNREAD_CHANNEL_NAME = "Messages"
const val SILENT_NOTIFICATIONS_CHANNEL_ID = "silentNotifications"
const val SILENT_NOTIFICATIONS_CHANNEL_NAME = "Silent notifications"
const val NOTIF_GROUP_NAME = "awais.instagrabber.InstaNotif"
const val GROUP_KEY_DM = "awais.instagrabber.MESSAGES"
const val GROUP_KEY_SILENT_NOTIFICATIONS = "awais.instagrabber.SILENT_NOTIFICATIONS"
const val SHOW_ACTIVITY_REQUEST_CODE = 1738
const val SHOW_DM_THREAD = 2000
const val DM_SYNC_SERVICE_REQUEST_CODE = 3000
const val GLOBAL_NETWORK_ERROR_DIALOG_REQUEST_CODE = 7777
const val ACTION_SHOW_ACTIVITY = "show_activity"
const val ACTION_SHOW_DM_THREAD = "show_dm_thread"
const val DM_THREAD_ACTION_EXTRA_THREAD_ID = "thread_id"
const val DM_THREAD_ACTION_EXTRA_THREAD_TITLE = "thread_title"
const val X_IG_APP_ID = "936619743392459"
}

View File

@ -1,26 +1,22 @@
package awais.instagrabber.utils;
package awais.instagrabber.utils
import android.content.Context;
import android.content.Context
import com.google.android.exoplayer2.database.ExoDatabaseProvider
import com.google.android.exoplayer2.source.DefaultMediaSourceFactory
import com.google.android.exoplayer2.upstream.DefaultHttpDataSourceFactory
import com.google.android.exoplayer2.upstream.cache.CacheDataSource
import com.google.android.exoplayer2.upstream.cache.LeastRecentlyUsedCacheEvictor
import com.google.android.exoplayer2.upstream.cache.SimpleCache
import androidx.annotation.NonNull;
import com.google.android.exoplayer2.database.ExoDatabaseProvider;
import com.google.android.exoplayer2.source.DefaultMediaSourceFactory;
import com.google.android.exoplayer2.upstream.DefaultHttpDataSourceFactory;
import com.google.android.exoplayer2.upstream.cache.CacheDataSource;
import com.google.android.exoplayer2.upstream.cache.LeastRecentlyUsedCacheEvictor;
import com.google.android.exoplayer2.upstream.cache.SimpleCache;
public final class ExoplayerUtils {
private static final long MAX_CACHE_BYTES = 1048576;
private static final LeastRecentlyUsedCacheEvictor cacheEvictor = new LeastRecentlyUsedCacheEvictor(MAX_CACHE_BYTES);
public static DefaultMediaSourceFactory getCachedMediaSourceFactory(@NonNull final Context context) {
final ExoDatabaseProvider exoDatabaseProvider = new ExoDatabaseProvider(context);
final SimpleCache simpleCache = new SimpleCache(context.getCacheDir(), cacheEvictor, exoDatabaseProvider);
final CacheDataSource.Factory cacheDataSourceFactory = new CacheDataSource.Factory()
object ExoplayerUtils {
private const val MAX_CACHE_BYTES: Long = 1048576
private val cacheEvictor = LeastRecentlyUsedCacheEvictor(MAX_CACHE_BYTES)
fun getCachedMediaSourceFactory(context: Context): DefaultMediaSourceFactory {
val exoDatabaseProvider = ExoDatabaseProvider(context)
val simpleCache = SimpleCache(context.cacheDir, cacheEvictor, exoDatabaseProvider)
val cacheDataSourceFactory = CacheDataSource.Factory()
.setCache(simpleCache)
.setUpstreamDataSourceFactory(new DefaultHttpDataSourceFactory());
return new DefaultMediaSourceFactory(cacheDataSourceFactory);
.setUpstreamDataSourceFactory(DefaultHttpDataSourceFactory())
return DefaultMediaSourceFactory(cacheDataSourceFactory)
}
}
}