mirror of
https://github.com/tateisu/SubwayTooter
synced 2025-01-29 18:19:22 +01:00
アプリ設定に「アプリ名を可能なら表示する」を追加。
This commit is contained in:
parent
bd94fcc075
commit
ec6ae97060
@ -12,8 +12,8 @@ android {
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 27
|
||||
|
||||
versionCode 204
|
||||
versionName "2.0.4"
|
||||
versionCode 205
|
||||
versionName "2.0.5"
|
||||
|
||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
|
||||
|
@ -459,8 +459,8 @@ class ActAccountSetting : AppCompatActivity(), View.OnClickListener, CompoundBut
|
||||
account.delete()
|
||||
|
||||
val pref = Pref.pref(this@ActAccountSetting)
|
||||
if(account.db_id == pref.getLong(Pref.KEY_TABLET_TOOT_DEFAULT_ACCOUNT, - 1L)) {
|
||||
pref.edit().putLong(Pref.KEY_TABLET_TOOT_DEFAULT_ACCOUNT, - 1L).apply()
|
||||
if(account.db_id == Pref.lpTabletTootDefaultAccount(pref) ) {
|
||||
pref.edit().put(Pref.lpTabletTootDefaultAccount, - 1L).apply()
|
||||
}
|
||||
|
||||
finish()
|
||||
@ -528,7 +528,7 @@ class ActAccountSetting : AppCompatActivity(), View.OnClickListener, CompoundBut
|
||||
|
||||
TootTaskRunner(this@ActAccountSetting).run(account, object : TootTask {
|
||||
override fun background(client : TootApiClient) : TootApiResult? {
|
||||
return client.authentication1(Pref.pref(this@ActAccountSetting).getString(Pref.KEY_CLIENT_NAME, ""))
|
||||
return client.authentication1(Pref.spClientName(this@ActAccountSetting))
|
||||
}
|
||||
|
||||
override fun handleResult(result : TootApiResult?) {
|
||||
|
@ -21,12 +21,10 @@ import android.view.ViewGroup
|
||||
import android.widget.AdapterView
|
||||
import android.widget.ArrayAdapter
|
||||
import android.widget.BaseAdapter
|
||||
import android.widget.CheckBox
|
||||
import android.widget.CompoundButton
|
||||
import android.widget.EditText
|
||||
import android.widget.ImageView
|
||||
import android.widget.Spinner
|
||||
import android.widget.Switch
|
||||
import android.widget.TextView
|
||||
|
||||
import com.jrummyapps.android.colorpicker.ColorPickerDialog
|
||||
@ -86,30 +84,14 @@ class ActAppSetting : AppCompatActivity()
|
||||
|
||||
internal lateinit var pref : SharedPreferences
|
||||
|
||||
private lateinit var swDontConfirmBeforeCloseColumn : Switch
|
||||
private lateinit var swPriorLocalURL : Switch
|
||||
private lateinit var swDisableFastScroller : Switch
|
||||
private lateinit var swSimpleList : Switch
|
||||
private lateinit var swExitAppWhenCloseProtectedColumn : Switch
|
||||
private lateinit var swShowFollowButtonInButtonBar : Switch
|
||||
private lateinit var swDontRound : Switch
|
||||
private lateinit var swDontUseStreaming : Switch
|
||||
private lateinit var swDontRefreshOnResume : Switch
|
||||
private lateinit var swDontScreenOff : Switch
|
||||
private lateinit var swDisableTabletMode : Switch
|
||||
private lateinit var swDontCropMediaThumb : Switch
|
||||
private lateinit var swPriorChrome : Switch
|
||||
private lateinit var swPostButtonBarTop : Switch
|
||||
private lateinit var swDontDuplicationCheck : Switch
|
||||
private lateinit var swQuickTootBar : Switch
|
||||
private lateinit var swEnableGifAnimation : Switch
|
||||
private lateinit var swMentionFullAcct : Switch
|
||||
private lateinit var swRelativeTimestamp : Switch
|
||||
private lateinit var swDontUseActionButtonWithQuickTootBar : Switch
|
||||
private lateinit var swShortAcctLocalUser : Switch
|
||||
private lateinit var swDisableEmojiAnimation : Switch
|
||||
private lateinit var swAllowNonSpaceBeforeEmojiShortcode : Switch
|
||||
private lateinit var swUseInternalMediaViewer : Switch
|
||||
class BooleanViewInfo(
|
||||
val info : Pref.BooleanPref,
|
||||
val view : CompoundButton
|
||||
)
|
||||
|
||||
private val booleanViewList = ArrayList<BooleanViewInfo>()
|
||||
|
||||
|
||||
|
||||
private lateinit var spBackButtonAction : Spinner
|
||||
private lateinit var spUITheme : Spinner
|
||||
@ -117,10 +99,6 @@ class ActAppSetting : AppCompatActivity()
|
||||
private lateinit var spRefreshAfterToot : Spinner
|
||||
private lateinit var spDefaultAccount : Spinner
|
||||
|
||||
private lateinit var cbNotificationSound : CheckBox
|
||||
private lateinit var cbNotificationVibration : CheckBox
|
||||
private lateinit var cbNotificationLED : CheckBox
|
||||
|
||||
private var footer_button_bg_color : Int = 0
|
||||
private var footer_button_fg_color : Int = 0
|
||||
private var footer_tab_bg_color : Int = 0
|
||||
@ -174,90 +152,24 @@ class ActAppSetting : AppCompatActivity()
|
||||
setContentView(R.layout.act_app_setting)
|
||||
|
||||
Styler.fixHorizontalPadding(findViewById(R.id.svContent))
|
||||
|
||||
swDontConfirmBeforeCloseColumn = findViewById(R.id.swDontConfirmBeforeCloseColumn)
|
||||
swDontConfirmBeforeCloseColumn.setOnCheckedChangeListener(this)
|
||||
|
||||
swPriorLocalURL = findViewById(R.id.swPriorLocalURL)
|
||||
swPriorLocalURL.setOnCheckedChangeListener(this)
|
||||
|
||||
swDisableFastScroller = findViewById(R.id.swDisableFastScroller)
|
||||
swDisableFastScroller.setOnCheckedChangeListener(this)
|
||||
|
||||
swSimpleList = findViewById(R.id.swSimpleList)
|
||||
swSimpleList.setOnCheckedChangeListener(this)
|
||||
|
||||
swExitAppWhenCloseProtectedColumn = findViewById(R.id.swExitAppWhenCloseProtectedColumn)
|
||||
swExitAppWhenCloseProtectedColumn.setOnCheckedChangeListener(this)
|
||||
|
||||
swShowFollowButtonInButtonBar = findViewById(R.id.swShowFollowButtonInButtonBar)
|
||||
swShowFollowButtonInButtonBar.setOnCheckedChangeListener(this)
|
||||
|
||||
swDontRound = findViewById(R.id.swDontRound)
|
||||
swDontRound.setOnCheckedChangeListener(this)
|
||||
|
||||
swDontUseStreaming = findViewById(R.id.swDontUseStreaming)
|
||||
swDontUseStreaming.setOnCheckedChangeListener(this)
|
||||
|
||||
swDontRefreshOnResume = findViewById(R.id.swDontRefreshOnResume)
|
||||
swDontRefreshOnResume.setOnCheckedChangeListener(this)
|
||||
|
||||
swDontScreenOff = findViewById(R.id.swDontScreenOff)
|
||||
swDontScreenOff.setOnCheckedChangeListener(this)
|
||||
|
||||
swDisableTabletMode = findViewById(R.id.swDisableTabletMode)
|
||||
swDisableTabletMode.setOnCheckedChangeListener(this)
|
||||
|
||||
swDontCropMediaThumb = findViewById(R.id.swDontCropMediaThumb)
|
||||
swDontCropMediaThumb.setOnCheckedChangeListener(this)
|
||||
|
||||
swPriorChrome = findViewById(R.id.swPriorChrome)
|
||||
swPriorChrome.setOnCheckedChangeListener(this)
|
||||
|
||||
swPostButtonBarTop = findViewById(R.id.swPostButtonBarTop)
|
||||
swPostButtonBarTop.setOnCheckedChangeListener(this)
|
||||
|
||||
swDontDuplicationCheck = findViewById(R.id.swDontDuplicationCheck)
|
||||
swDontDuplicationCheck.setOnCheckedChangeListener(this)
|
||||
|
||||
swQuickTootBar = findViewById(R.id.swQuickTootBar)
|
||||
swQuickTootBar.setOnCheckedChangeListener(this)
|
||||
|
||||
swEnableGifAnimation = findViewById(R.id.swEnableGifAnimation)
|
||||
swEnableGifAnimation.setOnCheckedChangeListener(this)
|
||||
|
||||
swMentionFullAcct = findViewById(R.id.swMentionFullAcct)
|
||||
swMentionFullAcct.setOnCheckedChangeListener(this)
|
||||
|
||||
swRelativeTimestamp = findViewById(R.id.swRelativeTimestamp)
|
||||
swRelativeTimestamp.setOnCheckedChangeListener(this)
|
||||
|
||||
swDontUseActionButtonWithQuickTootBar = findViewById(R.id.swDontUseActionButtonWithQuickTootBar)
|
||||
swDontUseActionButtonWithQuickTootBar.setOnCheckedChangeListener(this)
|
||||
|
||||
swShortAcctLocalUser = findViewById(R.id.swShortAcctLocalUser)
|
||||
swShortAcctLocalUser.setOnCheckedChangeListener(this)
|
||||
|
||||
swDisableEmojiAnimation = findViewById(R.id.swDisableEmojiAnimation)
|
||||
swDisableEmojiAnimation.setOnCheckedChangeListener(this)
|
||||
|
||||
swAllowNonSpaceBeforeEmojiShortcode = findViewById(R.id.swAllowNonSpaceBeforeEmojiShortcode)
|
||||
swAllowNonSpaceBeforeEmojiShortcode.setOnCheckedChangeListener(this)
|
||||
|
||||
swUseInternalMediaViewer = findViewById(R.id.swUseInternalMediaViewer)
|
||||
swUseInternalMediaViewer.setOnCheckedChangeListener(this)
|
||||
|
||||
cbNotificationSound = findViewById(R.id.cbNotificationSound)
|
||||
cbNotificationVibration = findViewById(R.id.cbNotificationVibration)
|
||||
cbNotificationLED = findViewById(R.id.cbNotificationLED)
|
||||
cbNotificationSound.setOnCheckedChangeListener(this)
|
||||
cbNotificationVibration.setOnCheckedChangeListener(this)
|
||||
cbNotificationLED.setOnCheckedChangeListener(this)
|
||||
|
||||
// initialize Switch and CheckBox
|
||||
for(info in Pref.map.values) {
|
||||
if( info is Pref.BooleanPref) {
|
||||
val view = findViewById<CompoundButton>(info.id)
|
||||
view.setOnCheckedChangeListener(this)
|
||||
booleanViewList.add(BooleanViewInfo(info, view))
|
||||
}
|
||||
}
|
||||
|
||||
val bBefore8 = Build.VERSION.SDK_INT < 26
|
||||
cbNotificationSound.isEnabled = bBefore8
|
||||
cbNotificationVibration.isEnabled = bBefore8
|
||||
cbNotificationLED.isEnabled = bBefore8
|
||||
for(si in booleanViewList) {
|
||||
when(si.info) {
|
||||
Pref.bpNotificationLED,
|
||||
Pref.bpNotificationVibration,
|
||||
Pref.bpNotificationSound -> si.view.isEnabled = bBefore8
|
||||
}
|
||||
}
|
||||
|
||||
run {
|
||||
val caption_list = arrayOf(getString(R.string.ask_always), getString(R.string.close_column), getString(R.string.open_column_list), getString(R.string.app_exit))
|
||||
@ -368,65 +280,40 @@ class ActAppSetting : AppCompatActivity()
|
||||
private fun loadUIFromData() {
|
||||
load_busy = true
|
||||
|
||||
swDontConfirmBeforeCloseColumn.isChecked = pref.getBoolean(Pref.KEY_DONT_CONFIRM_BEFORE_CLOSE_COLUMN, false)
|
||||
swPriorLocalURL.isChecked = pref.getBoolean(Pref.KEY_PRIOR_LOCAL_URL, false)
|
||||
swSimpleList.isChecked = pref.getBoolean(Pref.KEY_SIMPLE_LIST, true)
|
||||
swExitAppWhenCloseProtectedColumn.isChecked = pref.getBoolean(Pref.KEY_EXIT_APP_WHEN_CLOSE_PROTECTED_COLUMN, false)
|
||||
swShowFollowButtonInButtonBar.isChecked = pref.getBoolean(Pref.KEY_SHOW_FOLLOW_BUTTON_IN_BUTTON_BAR, false)
|
||||
swDontRound.isChecked = pref.getBoolean(Pref.KEY_DONT_ROUND, false)
|
||||
swDontUseStreaming.isChecked = pref.getBoolean(Pref.KEY_DONT_USE_STREAMING, false)
|
||||
swDontRefreshOnResume.isChecked = pref.getBoolean(Pref.KEY_DONT_REFRESH_ON_RESUME, false)
|
||||
swDontScreenOff.isChecked = pref.getBoolean(Pref.KEY_DONT_SCREEN_OFF, false)
|
||||
swDisableTabletMode.isChecked = pref.getBoolean(Pref.KEY_DISABLE_TABLET_MODE, false)
|
||||
swDontCropMediaThumb.isChecked = pref.getBoolean(Pref.KEY_DONT_CROP_MEDIA_THUMBNAIL, false)
|
||||
swPostButtonBarTop.isChecked = pref.getBoolean(Pref.KEY_POST_BUTTON_BAR_AT_TOP, false)
|
||||
swDontDuplicationCheck.isChecked = pref.getBoolean(Pref.KEY_DONT_DUPLICATION_CHECK, false)
|
||||
swQuickTootBar.isChecked = pref.getBoolean(Pref.KEY_QUICK_TOOT_BAR, false)
|
||||
swEnableGifAnimation.isChecked = pref.getBoolean(Pref.KEY_ENABLE_GIF_ANIMATION, false)
|
||||
swMentionFullAcct.isChecked = pref.getBoolean(Pref.KEY_MENTION_FULL_ACCT, false)
|
||||
swRelativeTimestamp.isChecked = pref.getBoolean(Pref.KEY_RELATIVE_TIMESTAMP, false)
|
||||
swDontUseActionButtonWithQuickTootBar.isChecked = pref.getBoolean(Pref.KEY_DONT_USE_ACTION_BUTTON, false)
|
||||
swShortAcctLocalUser.isChecked = pref.getBoolean(Pref.KEY_SHORT_ACCT_LOCAL_USER, false)
|
||||
swDisableEmojiAnimation.isChecked = pref.getBoolean(Pref.KEY_DISABLE_EMOJI_ANIMATION, false)
|
||||
swAllowNonSpaceBeforeEmojiShortcode.isChecked = pref.getBoolean(Pref.KEY_ALLOW_NON_SPACE_BEFORE_EMOJI_SHORTCODE, false)
|
||||
swUseInternalMediaViewer.isChecked = pref.getBoolean(Pref.KEY_USE_INTERNAL_MEDIA_VIEWER, true)
|
||||
// Switch with default true
|
||||
swDisableFastScroller.isChecked = pref.getBoolean(Pref.KEY_DISABLE_FAST_SCROLLER, true)
|
||||
swPriorChrome.isChecked = pref.getBoolean(Pref.KEY_PRIOR_CHROME, true)
|
||||
for(si in booleanViewList) {
|
||||
si.view.isChecked = si.info(pref)
|
||||
}
|
||||
|
||||
cbNotificationSound.isChecked = pref.getBoolean(Pref.KEY_NOTIFICATION_SOUND, true)
|
||||
cbNotificationVibration.isChecked = pref.getBoolean(Pref.KEY_NOTIFICATION_VIBRATION, true)
|
||||
cbNotificationLED.isChecked = pref.getBoolean(Pref.KEY_NOTIFICATION_LED, true)
|
||||
|
||||
spBackButtonAction.setSelection(pref.getInt(Pref.KEY_BACK_BUTTON_ACTION, 0))
|
||||
spUITheme.setSelection(pref.getInt(Pref.KEY_UI_THEME, 0))
|
||||
spResizeImage.setSelection(pref.getInt(Pref.KEY_RESIZE_IMAGE, 4))
|
||||
spRefreshAfterToot.setSelection(pref.getInt(Pref.KEY_REFRESH_AFTER_TOOT, 0))
|
||||
spBackButtonAction.setSelection(Pref.ipBackButtonAction(pref))
|
||||
spUITheme.setSelection(Pref.ipUiTheme(pref))
|
||||
spResizeImage.setSelection(Pref.ipResizeImage(pref))
|
||||
spRefreshAfterToot.setSelection(Pref.ipRefreshAfterToot(pref))
|
||||
|
||||
spDefaultAccount.setSelection(
|
||||
(spDefaultAccount.adapter as AccountAdapter).getIndexFromId(pref.getLong(Pref.KEY_TABLET_TOOT_DEFAULT_ACCOUNT, - 1L))
|
||||
(spDefaultAccount.adapter as AccountAdapter).getIndexFromId( Pref.lpTabletTootDefaultAccount(pref))
|
||||
)
|
||||
|
||||
footer_button_bg_color = pref.getInt(Pref.KEY_FOOTER_BUTTON_BG_COLOR, 0)
|
||||
footer_button_fg_color = pref.getInt(Pref.KEY_FOOTER_BUTTON_FG_COLOR, 0)
|
||||
footer_tab_bg_color = pref.getInt(Pref.KEY_FOOTER_TAB_BG_COLOR, 0)
|
||||
footer_tab_divider_color = pref.getInt(Pref.KEY_FOOTER_TAB_DIVIDER_COLOR, 0)
|
||||
footer_tab_indicator_color = pref.getInt(Pref.KEY_FOOTER_TAB_INDICATOR_COLOR, 0)
|
||||
footer_button_bg_color = Pref.ipFooterButtonBgColor(pref)
|
||||
footer_button_fg_color = Pref.ipFooterButtonFgColor(pref)
|
||||
footer_tab_bg_color = Pref.ipFooterTabBgColor(pref)
|
||||
footer_tab_divider_color = Pref.ipFooterTabDividerColor(pref)
|
||||
footer_tab_indicator_color = Pref.ipFooterTabIndicatorColor(pref)
|
||||
|
||||
etColumnWidth.setText(pref.getString(Pref.KEY_COLUMN_WIDTH, ""))
|
||||
etMediaThumbHeight.setText(pref.getString(Pref.KEY_MEDIA_THUMB_HEIGHT, ""))
|
||||
etClientName.setText(pref.getString(Pref.KEY_CLIENT_NAME, ""))
|
||||
etQuoteNameFormat.setText(pref.getString(Pref.KEY_QUOTE_NAME_FORMAT, ""))
|
||||
etAutoCWLines.setText(pref.getString(Pref.KEY_AUTO_CW_LINES, "0"))
|
||||
etAvatarIconSize.setText(pref.getString(Pref.KEY_AVATAR_ICON_SIZE, "48"))
|
||||
etColumnWidth.setText(Pref.spColumnWidth(pref))
|
||||
etMediaThumbHeight.setText(Pref.spMediaThumbHeight(pref))
|
||||
etClientName.setText(Pref.spClientName(pref))
|
||||
etQuoteNameFormat.setText(Pref.spQuoteNameFormat(pref))
|
||||
etAutoCWLines.setText(Pref.spAutoCWLines(pref))
|
||||
etAvatarIconSize.setText(Pref.spAvatarIconSize(pref))
|
||||
|
||||
etMediaSizeMax.setText(pref.getString(Pref.KEY_MEDIA_SIZE_MAX, "8"))
|
||||
etMediaSizeMax.setText(Pref.spMediaSizeMax(pref))
|
||||
|
||||
etTimelineFontSize.setText(formatFontSize(pref.getFloat(Pref.KEY_TIMELINE_FONT_SIZE, Float.NaN)))
|
||||
etAcctFontSize.setText(formatFontSize(pref.getFloat(Pref.KEY_ACCT_FONT_SIZE, Float.NaN)))
|
||||
timeline_font = Pref.spTimelineFont(pref)
|
||||
timeline_font_bold = Pref.spTimelineFontBold(pref)
|
||||
|
||||
etTimelineFontSize.setText(formatFontSize(Pref.fpTimelineFontSize(pref)))
|
||||
etAcctFontSize.setText(formatFontSize(Pref.fpAcctFontSize(pref)))
|
||||
|
||||
timeline_font = pref.getString(Pref.KEY_TIMELINE_FONT, "")
|
||||
timeline_font_bold = pref.getString(Pref.KEY_TIMELINE_FONT_BOLD, "")
|
||||
|
||||
load_busy = false
|
||||
|
||||
@ -440,65 +327,43 @@ class ActAppSetting : AppCompatActivity()
|
||||
|
||||
private fun saveUIToData() {
|
||||
if(load_busy) return
|
||||
pref.edit()
|
||||
.putBoolean(Pref.KEY_DONT_CONFIRM_BEFORE_CLOSE_COLUMN, swDontConfirmBeforeCloseColumn.isChecked)
|
||||
.putBoolean(Pref.KEY_PRIOR_LOCAL_URL, swPriorLocalURL.isChecked)
|
||||
.putBoolean(Pref.KEY_DISABLE_FAST_SCROLLER, swDisableFastScroller.isChecked)
|
||||
.putBoolean(Pref.KEY_SIMPLE_LIST, swSimpleList.isChecked)
|
||||
.putBoolean(Pref.KEY_EXIT_APP_WHEN_CLOSE_PROTECTED_COLUMN, swExitAppWhenCloseProtectedColumn.isChecked)
|
||||
.putBoolean(Pref.KEY_SHOW_FOLLOW_BUTTON_IN_BUTTON_BAR, swShowFollowButtonInButtonBar.isChecked)
|
||||
.putBoolean(Pref.KEY_DONT_ROUND, swDontRound.isChecked)
|
||||
.putBoolean(Pref.KEY_DONT_USE_STREAMING, swDontUseStreaming.isChecked)
|
||||
.putBoolean(Pref.KEY_DONT_REFRESH_ON_RESUME, swDontRefreshOnResume.isChecked)
|
||||
.putBoolean(Pref.KEY_DONT_SCREEN_OFF, swDontScreenOff.isChecked)
|
||||
.putBoolean(Pref.KEY_DISABLE_TABLET_MODE, swDisableTabletMode.isChecked)
|
||||
.putBoolean(Pref.KEY_DONT_CROP_MEDIA_THUMBNAIL, swDontCropMediaThumb.isChecked)
|
||||
.putBoolean(Pref.KEY_PRIOR_CHROME, swPriorChrome.isChecked)
|
||||
.putBoolean(Pref.KEY_POST_BUTTON_BAR_AT_TOP, swPostButtonBarTop.isChecked)
|
||||
.putBoolean(Pref.KEY_DONT_DUPLICATION_CHECK, swDontDuplicationCheck.isChecked)
|
||||
.putBoolean(Pref.KEY_QUICK_TOOT_BAR, swQuickTootBar.isChecked)
|
||||
.putBoolean(Pref.KEY_ENABLE_GIF_ANIMATION, swEnableGifAnimation.isChecked)
|
||||
.putBoolean(Pref.KEY_MENTION_FULL_ACCT, swMentionFullAcct.isChecked)
|
||||
.putBoolean(Pref.KEY_RELATIVE_TIMESTAMP, swRelativeTimestamp.isChecked)
|
||||
.putBoolean(Pref.KEY_DONT_USE_ACTION_BUTTON, swDontUseActionButtonWithQuickTootBar.isChecked)
|
||||
.putBoolean(Pref.KEY_SHORT_ACCT_LOCAL_USER, swShortAcctLocalUser.isChecked)
|
||||
.putBoolean(Pref.KEY_DISABLE_EMOJI_ANIMATION, swDisableEmojiAnimation.isChecked)
|
||||
.putBoolean(Pref.KEY_ALLOW_NON_SPACE_BEFORE_EMOJI_SHORTCODE, swAllowNonSpaceBeforeEmojiShortcode.isChecked)
|
||||
.putBoolean(Pref.KEY_USE_INTERNAL_MEDIA_VIEWER, swUseInternalMediaViewer.isChecked)
|
||||
|
||||
val e = pref.edit()
|
||||
|
||||
for(si in booleanViewList) {
|
||||
e.putBoolean(si.info.key, si.view.isChecked)
|
||||
}
|
||||
|
||||
e
|
||||
.put(Pref.lpTabletTootDefaultAccount,
|
||||
(spDefaultAccount.adapter as AccountAdapter)
|
||||
.getIdFromIndex(spDefaultAccount.selectedItemPosition)
|
||||
)
|
||||
|
||||
.putBoolean(Pref.KEY_NOTIFICATION_SOUND, cbNotificationSound.isChecked)
|
||||
.putBoolean(Pref.KEY_NOTIFICATION_VIBRATION, cbNotificationVibration.isChecked)
|
||||
.putBoolean(Pref.KEY_NOTIFICATION_LED, cbNotificationLED.isChecked)
|
||||
.put(Pref.fpTimelineFontSize, parseFontSize(etTimelineFontSize.text.toString().trim { it <= ' ' }))
|
||||
.put(Pref.fpAcctFontSize, parseFontSize(etAcctFontSize.text.toString().trim { it <= ' ' }))
|
||||
|
||||
.putInt(Pref.KEY_BACK_BUTTON_ACTION, spBackButtonAction.selectedItemPosition)
|
||||
.putInt(Pref.KEY_UI_THEME, spUITheme.selectedItemPosition)
|
||||
.putInt(Pref.KEY_RESIZE_IMAGE, spResizeImage.selectedItemPosition)
|
||||
.putInt(Pref.KEY_REFRESH_AFTER_TOOT, spRefreshAfterToot.selectedItemPosition)
|
||||
.put(Pref.spColumnWidth, etColumnWidth.text.toString().trim { it <= ' ' })
|
||||
.put(Pref.spMediaThumbHeight, etMediaThumbHeight.text.toString().trim { it <= ' ' })
|
||||
.put(Pref.spClientName, etClientName.text.toString().trim { it <= ' ' })
|
||||
.put(Pref.spQuoteNameFormat, etQuoteNameFormat.text.toString()) // not trimmed
|
||||
.put(Pref.spAutoCWLines, etAutoCWLines.text.toString().trim { it <= ' ' })
|
||||
.put(Pref.spAvatarIconSize, etAvatarIconSize.text.toString().trim { it <= ' ' })
|
||||
.put(Pref.spMediaSizeMax, etMediaSizeMax.text.toString().trim { it <= ' ' })
|
||||
.put(Pref.spTimelineFont, timeline_font ?:"")
|
||||
.put(Pref.spTimelineFontBold, timeline_font_bold?:"")
|
||||
|
||||
.putInt(Pref.KEY_FOOTER_BUTTON_BG_COLOR, footer_button_bg_color)
|
||||
.putInt(Pref.KEY_FOOTER_BUTTON_FG_COLOR, footer_button_fg_color)
|
||||
.putInt(Pref.KEY_FOOTER_TAB_BG_COLOR, footer_tab_bg_color)
|
||||
.putInt(Pref.KEY_FOOTER_TAB_DIVIDER_COLOR, footer_tab_divider_color)
|
||||
.putInt(Pref.KEY_FOOTER_TAB_INDICATOR_COLOR, footer_tab_indicator_color)
|
||||
|
||||
.putLong(Pref.KEY_TABLET_TOOT_DEFAULT_ACCOUNT, (spDefaultAccount.adapter as AccountAdapter)
|
||||
.getIdFromIndex(spDefaultAccount.selectedItemPosition))
|
||||
|
||||
.putString(Pref.KEY_TIMELINE_FONT, timeline_font)
|
||||
.putString(Pref.KEY_TIMELINE_FONT_BOLD, timeline_font_bold)
|
||||
.putString(Pref.KEY_COLUMN_WIDTH, etColumnWidth.text.toString().trim { it <= ' ' })
|
||||
.putString(Pref.KEY_MEDIA_THUMB_HEIGHT, etMediaThumbHeight.text.toString().trim { it <= ' ' })
|
||||
.putString(Pref.KEY_CLIENT_NAME, etClientName.text.toString().trim { it <= ' ' })
|
||||
.putString(Pref.KEY_QUOTE_NAME_FORMAT, etQuoteNameFormat.text.toString()) // not trimmed
|
||||
.putString(Pref.KEY_AUTO_CW_LINES, etAutoCWLines.text.toString()) // not trimmed
|
||||
.putString(Pref.KEY_AVATAR_ICON_SIZE, etAvatarIconSize.text.toString().trim { it <= ' ' })
|
||||
.putString(Pref.KEY_MEDIA_SIZE_MAX, etMediaSizeMax.text.toString()) // not trimmed
|
||||
|
||||
.putFloat(Pref.KEY_TIMELINE_FONT_SIZE, parseFontSize(etTimelineFontSize.text.toString().trim { it <= ' ' }))
|
||||
.putFloat(Pref.KEY_ACCT_FONT_SIZE, parseFontSize(etAcctFontSize.text.toString().trim { it <= ' ' }))
|
||||
.put(Pref.ipBackButtonAction, spBackButtonAction.selectedItemPosition)
|
||||
.put(Pref.ipUiTheme, spUITheme.selectedItemPosition)
|
||||
.put(Pref.ipResizeImage, spResizeImage.selectedItemPosition)
|
||||
.put(Pref.ipRefreshAfterToot, spRefreshAfterToot.selectedItemPosition)
|
||||
.put(Pref.ipFooterButtonBgColor, footer_button_bg_color)
|
||||
.put(Pref.ipFooterButtonFgColor, footer_button_fg_color)
|
||||
.put(Pref.ipFooterTabBgColor, footer_tab_bg_color)
|
||||
.put(Pref.ipFooterTabDividerColor, footer_tab_divider_color)
|
||||
.put(Pref.ipFooterTabIndicatorColor, footer_tab_indicator_color)
|
||||
|
||||
.apply()
|
||||
|
||||
}
|
||||
|
||||
override fun onCheckedChanged(buttonView : CompoundButton, isChecked : Boolean) {
|
||||
@ -591,11 +456,10 @@ class ActAppSetting : AppCompatActivity()
|
||||
R.id.btnCustomStreamListenerEdit -> ActCustomStreamListener.open(this)
|
||||
|
||||
R.id.btnCustomStreamListenerReset -> {
|
||||
pref
|
||||
.edit()
|
||||
.remove(Pref.KEY_STREAM_LISTENER_CONFIG_URL)
|
||||
.remove(Pref.KEY_STREAM_LISTENER_SECRET)
|
||||
.remove(Pref.KEY_STREAM_LISTENER_CONFIG_DATA)
|
||||
pref.edit()
|
||||
.remove(Pref.spStreamListenerConfigUrl)
|
||||
.remove(Pref.spStreamListenerSecret)
|
||||
.remove(Pref.spStreamListenerConfigData)
|
||||
.apply()
|
||||
SavedAccount.clearRegistrationCache()
|
||||
PollingWorker.queueUpdateListener(this)
|
||||
@ -764,7 +628,7 @@ class ActAppSetting : AppCompatActivity()
|
||||
|
||||
private fun parseFontSize(src : String) : Float {
|
||||
try {
|
||||
if( src.isNotEmpty() ) {
|
||||
if(src.isNotEmpty()) {
|
||||
val f = NumberFormat.getInstance(Locale.getDefault()).parse(src).toFloat()
|
||||
return when {
|
||||
f.isNaN() -> Float.NaN
|
||||
@ -782,7 +646,7 @@ class ActAppSetting : AppCompatActivity()
|
||||
|
||||
private fun showFontSize(sample : TextView, et : EditText, default_sp : Float) {
|
||||
var fv = parseFontSize(et.text.toString().trim { it <= ' ' })
|
||||
if(fv.isNaN() ) {
|
||||
if(fv.isNaN()) {
|
||||
sample.textSize = default_sp
|
||||
} else {
|
||||
if(fv < 1f) fv = 1f
|
||||
@ -794,7 +658,7 @@ class ActAppSetting : AppCompatActivity()
|
||||
tvFontUrl : TextView, font_url : String?
|
||||
) {
|
||||
try {
|
||||
if(font_url?.isNotEmpty() == true ) {
|
||||
if(font_url?.isNotEmpty() == true) {
|
||||
|
||||
tvFontUrl.typeface = Typeface.DEFAULT
|
||||
val face = Typeface.createFromFile(font_url)
|
||||
@ -983,7 +847,7 @@ class ActAppSetting : AppCompatActivity()
|
||||
|
||||
override fun getView(position : Int, viewOld : View?, parent : ViewGroup) : View {
|
||||
val view = viewOld ?: layoutInflater.inflate(android.R.layout.simple_spinner_item, parent, false)
|
||||
view.findViewById<TextView>(android.R.id.text1) .text =
|
||||
view.findViewById<TextView>(android.R.id.text1).text =
|
||||
if(position == 0)
|
||||
getString(R.string.ask_always)
|
||||
else
|
||||
|
@ -90,8 +90,8 @@ class ActCustomStreamListener : AppCompatActivity(), View.OnClickListener, TextW
|
||||
|
||||
val pref = Pref.pref(this)
|
||||
|
||||
etStreamListenerConfigurationUrl.setText(pref.getString(Pref.KEY_STREAM_LISTENER_CONFIG_URL, ""))
|
||||
etStreamListenerSecret.setText(pref.getString(Pref.KEY_STREAM_LISTENER_SECRET, ""))
|
||||
etStreamListenerConfigurationUrl.setText(Pref.spStreamListenerConfigUrl(pref))
|
||||
etStreamListenerSecret.setText(Pref.spStreamListenerSecret(pref))
|
||||
stream_config_json = null
|
||||
tvLog.text = getString(R.string.input_url_and_secret_then_test)
|
||||
|
||||
@ -123,10 +123,12 @@ class ActCustomStreamListener : AppCompatActivity(), View.OnClickListener, TextW
|
||||
Utils.hideKeyboard(this, etStreamListenerConfigurationUrl)
|
||||
finish()
|
||||
}
|
||||
|
||||
R.id.btnTest -> {
|
||||
Utils.hideKeyboard(this, etStreamListenerConfigurationUrl)
|
||||
startTest()
|
||||
}
|
||||
|
||||
R.id.btnSave -> {
|
||||
Utils.hideKeyboard(this, etStreamListenerConfigurationUrl)
|
||||
if(save()) {
|
||||
@ -145,15 +147,15 @@ class ActCustomStreamListener : AppCompatActivity(), View.OnClickListener, TextW
|
||||
}
|
||||
|
||||
Pref.pref(this).edit()
|
||||
.putString(Pref.KEY_STREAM_LISTENER_CONFIG_URL, etStreamListenerConfigurationUrl.text.toString().trim { it <= ' ' })
|
||||
.putString(Pref.KEY_STREAM_LISTENER_SECRET, etStreamListenerSecret.text.toString().trim { it <= ' ' })
|
||||
.putString(Pref.KEY_STREAM_LISTENER_CONFIG_DATA, stream_config_json)
|
||||
.put(Pref.spStreamListenerConfigUrl, etStreamListenerConfigurationUrl.text.toString().trim { it <= ' ' })
|
||||
.put(Pref.spStreamListenerSecret, etStreamListenerSecret.text.toString().trim { it <= ' ' })
|
||||
.put(Pref.spStreamListenerConfigData, stream_config_json ?: "")
|
||||
.apply()
|
||||
return true
|
||||
}
|
||||
|
||||
internal fun addLog(line : String) {
|
||||
Utils.runOnMainThread{
|
||||
Utils.runOnMainThread {
|
||||
val old = tvLog.text.toString()
|
||||
tvLog.text = if(old.isEmpty()) line else old + "\n" + line
|
||||
}
|
||||
@ -171,10 +173,10 @@ class ActCustomStreamListener : AppCompatActivity(), View.OnClickListener, TextW
|
||||
try {
|
||||
|
||||
while(true) {
|
||||
if( strSecret.isEmpty() ) {
|
||||
if(strSecret.isEmpty()) {
|
||||
addLog("Secret is empty. Custom Listener is not used.")
|
||||
break
|
||||
} else if(strUrl.isEmpty() ) {
|
||||
} else if(strUrl.isEmpty()) {
|
||||
addLog("Configuration URL is empty. Custom Listener is not used.")
|
||||
break
|
||||
}
|
||||
@ -193,9 +195,9 @@ class ActCustomStreamListener : AppCompatActivity(), View.OnClickListener, TextW
|
||||
log.trace(ex)
|
||||
null
|
||||
}
|
||||
|
||||
if(! response.isSuccessful || bodyString?.isEmpty() != false ){
|
||||
addLog(TootApiClient.formatResponse(response, "Can't get configuration from URL.",bodyString))
|
||||
|
||||
if(! response.isSuccessful || bodyString?.isEmpty() != false) {
|
||||
addLog(TootApiClient.formatResponse(response, "Can't get configuration from URL.", bodyString))
|
||||
break
|
||||
}
|
||||
|
||||
|
@ -162,27 +162,29 @@ class ActMain : AppCompatActivity()
|
||||
internal lateinit var pager : ViewPager
|
||||
internal lateinit var pager_adapter : ColumnPagerAdapter
|
||||
}
|
||||
|
||||
class TabletEnv {
|
||||
internal lateinit var tablet_pager : RecyclerView
|
||||
internal lateinit var tablet_pager_adapter : TabletColumnPagerAdapter
|
||||
internal lateinit var tablet_layout_manager : LinearLayoutManager
|
||||
internal lateinit var tablet_snap_helper : GravitySnapHelper
|
||||
}
|
||||
|
||||
private var phoneEnv : PhoneEnv? = null
|
||||
private var tabletEnv : TabletEnv? = null
|
||||
|
||||
// スマホモードとタブレットモードでコードを切り替える
|
||||
private inline fun <R> phoneTab(lambdaPhone : (PhoneEnv) -> R, lambdaTablet : (TabletEnv) -> R) : R {
|
||||
|
||||
|
||||
val pe = phoneEnv
|
||||
if(pe != null) return lambdaPhone(pe)
|
||||
|
||||
|
||||
val te = tabletEnv
|
||||
if(te != null) return lambdaTablet(te)
|
||||
|
||||
|
||||
throw RuntimeException("missing phoneEnv or tabletEnv")
|
||||
}
|
||||
|
||||
|
||||
// スマホモードならラムダを実行する。タブレットモードならnullを返す
|
||||
private inline fun <R> phoneOnly(lambdaPhone : (PhoneEnv) -> R) : R? {
|
||||
val pe = phoneEnv
|
||||
@ -279,7 +281,6 @@ class ActMain : AppCompatActivity()
|
||||
Utils.showToast(this@ActMain, false, R.string.unboost_succeeded)
|
||||
}
|
||||
|
||||
|
||||
private var nScreenColumn : Int = 0
|
||||
private var nColumnWidth : Int = 0
|
||||
|
||||
@ -291,7 +292,7 @@ class ActMain : AppCompatActivity()
|
||||
for(c in app_state.column_list) {
|
||||
c.fireShowContent()
|
||||
}
|
||||
if(pref.getBoolean(Pref.KEY_RELATIVE_TIMESTAMP, false)) {
|
||||
if(Pref.bpRelativeTimestamp(pref)) {
|
||||
handler.postDelayed(this, 10000L)
|
||||
}
|
||||
}
|
||||
@ -315,7 +316,7 @@ class ActMain : AppCompatActivity()
|
||||
return - 1L
|
||||
},
|
||||
{ _ ->
|
||||
val db_id = App1.pref.getLong(Pref.KEY_TABLET_TOOT_DEFAULT_ACCOUNT, - 1L)
|
||||
val db_id = Pref.lpTabletTootDefaultAccount(App1.pref)
|
||||
val a = SavedAccount.loadAccount(this@ActMain, db_id)
|
||||
return a?.db_id ?: - 1L
|
||||
}
|
||||
@ -353,8 +354,8 @@ class ActMain : AppCompatActivity()
|
||||
this.density = app_state.density
|
||||
this.acct_pad_lr = (0.5f + 4f * density).toInt()
|
||||
|
||||
timeline_font_size_sp = validateFloat(pref.getFloat(Pref.KEY_TIMELINE_FONT_SIZE, Float.NaN))
|
||||
acct_font_size_sp = validateFloat(pref.getFloat(Pref.KEY_ACCT_FONT_SIZE, Float.NaN))
|
||||
timeline_font_size_sp = validateFloat( Pref.fpTimelineFontSize(pref))
|
||||
acct_font_size_sp = validateFloat( Pref.fpAcctFontSize(pref))
|
||||
|
||||
initUI()
|
||||
|
||||
@ -363,7 +364,7 @@ class ActMain : AppCompatActivity()
|
||||
if(! app_state.column_list.isEmpty()) {
|
||||
|
||||
// 前回最後に表示していたカラムの位置にスクロールする
|
||||
val column_pos = pref.getInt(Pref.KEY_LAST_COLUMN_POS, - 1)
|
||||
val column_pos = Pref.ipLastColumnPos(pref)
|
||||
if(column_pos >= 0 && column_pos < app_state.column_list.size) {
|
||||
scrollToColumn(column_pos, true)
|
||||
}
|
||||
@ -399,7 +400,7 @@ class ActMain : AppCompatActivity()
|
||||
outState ?: return
|
||||
|
||||
phoneTab(
|
||||
{ env -> outState.putInt(STATE_CURRENT_PAGE, env.pager.currentItem)},
|
||||
{ env -> outState.putInt(STATE_CURRENT_PAGE, env.pager.currentItem) },
|
||||
{ env ->
|
||||
val ve = env.tablet_layout_manager.findLastVisibleItemPosition()
|
||||
if(ve != RecyclerView.NO_POSITION) {
|
||||
@ -415,8 +416,10 @@ class ActMain : AppCompatActivity()
|
||||
if(pos > 0 && pos < app_state.column_list.size) {
|
||||
phoneTab(
|
||||
{ env -> env.pager.currentItem = pos },
|
||||
{ env -> env.tablet_layout_manager
|
||||
.smoothScrollToPosition(env.tablet_pager, null, pos) }
|
||||
{ env ->
|
||||
env.tablet_layout_manager
|
||||
.smoothScrollToPosition(env.tablet_pager, null, pos)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -498,7 +501,7 @@ class ActMain : AppCompatActivity()
|
||||
|
||||
MyClickableSpan.link_callback = WeakReference(link_click_listener)
|
||||
|
||||
if(pref.getBoolean(Pref.KEY_DONT_SCREEN_OFF, false)) {
|
||||
if(Pref.bpDontScreenOff(pref)) {
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||
} else {
|
||||
window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||
@ -526,14 +529,14 @@ class ActMain : AppCompatActivity()
|
||||
{ env -> env.pager.currentItem },
|
||||
{ env -> env.tablet_layout_manager.findFirstVisibleItemPosition() })
|
||||
|
||||
pref.edit().putInt(Pref.KEY_LAST_COLUMN_POS, last_pos).apply()
|
||||
pref.edit().put(Pref.ipLastColumnPos,last_pos).apply()
|
||||
|
||||
super.onPause()
|
||||
}
|
||||
|
||||
private fun refreshAfterPost() {
|
||||
if(posted_acct?.isNotEmpty() == true) {
|
||||
val refresh_after_toot = pref.getInt(Pref.KEY_REFRESH_AFTER_TOOT, 0)
|
||||
val refresh_after_toot = Pref.ipRefreshAfterToot(pref)
|
||||
if(refresh_after_toot != Pref.RAT_DONT_REFRESH) {
|
||||
for(column in app_state.column_list) {
|
||||
val a = column.access_info
|
||||
@ -553,8 +556,8 @@ class ActMain : AppCompatActivity()
|
||||
bAllowPseudo = false,
|
||||
bAuto = true,
|
||||
message = getString(R.string.account_picker_toot)
|
||||
,dismiss_callback ={ sent_intent2 = null }
|
||||
){ ai ->
|
||||
, dismiss_callback = { sent_intent2 = null }
|
||||
) { ai ->
|
||||
sent_intent2 = null
|
||||
ActPost.open(this@ActMain, REQUEST_CODE_POST, ai.db_id, intent)
|
||||
}
|
||||
@ -570,8 +573,8 @@ class ActMain : AppCompatActivity()
|
||||
|
||||
override fun onClick(v : View) {
|
||||
when(v.id) {
|
||||
R.id.btnMenu -> if(! drawer .isDrawerOpen(Gravity.START)) {
|
||||
drawer .openDrawer(Gravity.START)
|
||||
R.id.btnMenu -> if(! drawer.isDrawerOpen(Gravity.START)) {
|
||||
drawer.openDrawer(Gravity.START)
|
||||
}
|
||||
|
||||
R.id.btnToot -> Action_Account.openPost(this@ActMain)
|
||||
@ -602,8 +605,8 @@ class ActMain : AppCompatActivity()
|
||||
AccountPicker.pick(
|
||||
this,
|
||||
bAllowPseudo = false,
|
||||
bAuto =true,
|
||||
message =getString(R.string.account_picker_toot)
|
||||
bAuto = true,
|
||||
message = getString(R.string.account_picker_toot)
|
||||
) { ai -> performQuickPost(ai) }
|
||||
})
|
||||
return
|
||||
@ -740,11 +743,11 @@ class ActMain : AppCompatActivity()
|
||||
|
||||
} else if(requestCode == REQUEST_CODE_TEXT) {
|
||||
if(resultCode == ActText.RESULT_SEARCH_MSP) {
|
||||
val text = data ?.getStringExtra(Intent.EXTRA_TEXT)
|
||||
addColumn(defaultInsertPosition, SavedAccount.na, Column.TYPE_SEARCH_MSP, text ?:"")
|
||||
val text = data?.getStringExtra(Intent.EXTRA_TEXT)
|
||||
addColumn(defaultInsertPosition, SavedAccount.na, Column.TYPE_SEARCH_MSP, text ?: "")
|
||||
} else if(resultCode == ActText.RESULT_SEARCH_TS) {
|
||||
val text = data ?.getStringExtra(Intent.EXTRA_TEXT)
|
||||
addColumn(defaultInsertPosition, SavedAccount.na, Column.TYPE_SEARCH_TS, text?:"")
|
||||
val text = data?.getStringExtra(Intent.EXTRA_TEXT)
|
||||
addColumn(defaultInsertPosition, SavedAccount.na, Column.TYPE_SEARCH_TS, text ?: "")
|
||||
}
|
||||
}
|
||||
|
||||
@ -772,7 +775,7 @@ class ActMain : AppCompatActivity()
|
||||
}
|
||||
|
||||
// カラムが1個以上ある場合は設定に合わせて挙動を変える
|
||||
when(pref.getInt(Pref.KEY_BACK_BUTTON_ACTION, 0)) {
|
||||
when( Pref.ipBackButtonAction(pref)) {
|
||||
ActAppSetting.BACK_ASK_ALWAYS -> {
|
||||
val dialog = ActionsDialog()
|
||||
|
||||
@ -802,8 +805,8 @@ class ActMain : AppCompatActivity()
|
||||
|
||||
val closer = { column : Column ->
|
||||
if(column.dont_close
|
||||
&& pref.getBoolean(Pref.KEY_EXIT_APP_WHEN_CLOSE_PROTECTED_COLUMN, false)
|
||||
&& pref.getBoolean(Pref.KEY_DONT_CONFIRM_BEFORE_CLOSE_COLUMN, false)
|
||||
&& Pref.bpExitAppWhenCloseProtectedColumn(pref)
|
||||
&& Pref.bpDontConfirmBeforeCloseColumn(pref)
|
||||
) {
|
||||
this@ActMain.finish()
|
||||
} else {
|
||||
@ -917,10 +920,10 @@ class ActMain : AppCompatActivity()
|
||||
internal fun initUI() {
|
||||
setContentView(R.layout.act_main)
|
||||
|
||||
dont_crop_media_thumbnail = pref.getBoolean(Pref.KEY_DONT_CROP_MEDIA_THUMBNAIL, false)
|
||||
dont_crop_media_thumbnail = Pref.bpDontCropMediaThumb(pref)
|
||||
|
||||
var sv = pref.getString(Pref.KEY_TIMELINE_FONT, null)
|
||||
if(sv?.isNotEmpty() == true) {
|
||||
var sv = Pref.spTimelineFont(pref)
|
||||
if( sv.isNotEmpty() ) {
|
||||
try {
|
||||
timeline_font = Typeface.createFromFile(sv)
|
||||
} catch(ex : Throwable) {
|
||||
@ -929,8 +932,8 @@ class ActMain : AppCompatActivity()
|
||||
|
||||
}
|
||||
|
||||
sv = pref.getString(Pref.KEY_TIMELINE_FONT_BOLD, null)
|
||||
if(sv?.isNotEmpty() == true) {
|
||||
sv = Pref.spTimelineFontBold(pref)
|
||||
if(sv.isNotEmpty() ) {
|
||||
try {
|
||||
timeline_font_bold = Typeface.createFromFile(sv)
|
||||
} catch(ex : Throwable) {
|
||||
@ -946,13 +949,13 @@ class ActMain : AppCompatActivity()
|
||||
|
||||
}
|
||||
|
||||
shortAcctLocalUser = pref.getBoolean(Pref.KEY_SHORT_ACCT_LOCAL_USER, false)
|
||||
shortAcctLocalUser = Pref.bpShortAcctLocalUser(pref)
|
||||
|
||||
run {
|
||||
var icon_size_dp = 48f
|
||||
try {
|
||||
sv = pref.getString(Pref.KEY_AVATAR_ICON_SIZE, null)
|
||||
val fv = if(sv == null || sv.isEmpty()) Float.NaN else sv.toFloat()
|
||||
sv = Pref.spAvatarIconSize(pref)
|
||||
val fv = if( sv.isEmpty()) Float.NaN else sv.toFloat()
|
||||
if(fv.isNaN() || fv.isInfinite() || fv < 1f) {
|
||||
// error or bad range
|
||||
} else {
|
||||
@ -975,7 +978,7 @@ class ActMain : AppCompatActivity()
|
||||
drawer = findViewById(R.id.drawer_layout)
|
||||
// ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
|
||||
// this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close );
|
||||
drawer .addDrawerListener(this)
|
||||
drawer.addDrawerListener(this)
|
||||
// toggle.syncState();
|
||||
|
||||
val navigationView = findViewById<NavigationView>(R.id.nav_view)
|
||||
@ -991,7 +994,7 @@ class ActMain : AppCompatActivity()
|
||||
etQuickToot = findViewById(R.id.etQuickToot)
|
||||
btnQuickToot = findViewById(R.id.btnQuickToot)
|
||||
|
||||
if(! pref.getBoolean(Pref.KEY_QUICK_TOOT_BAR, false)) {
|
||||
if(! Pref.bpQuickTootBar(pref)) {
|
||||
llQuickTootBar.visibility = View.GONE
|
||||
}
|
||||
|
||||
@ -999,7 +1002,7 @@ class ActMain : AppCompatActivity()
|
||||
btnMenu.setOnClickListener(this)
|
||||
btnQuickToot.setOnClickListener(this)
|
||||
|
||||
if(pref.getBoolean(Pref.KEY_DONT_USE_ACTION_BUTTON, false)) {
|
||||
if(Pref.bpDontUseActionButtonWithQuickTootBar(pref)) {
|
||||
etQuickToot.inputType = InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_FLAG_MULTI_LINE
|
||||
etQuickToot.imeOptions = EditorInfo.IME_ACTION_NONE
|
||||
// 最後に指定する必要がある?
|
||||
@ -1029,7 +1032,7 @@ class ActMain : AppCompatActivity()
|
||||
val density = dm.density
|
||||
|
||||
var media_thumb_height = 64
|
||||
sv = pref.getString(Pref.KEY_MEDIA_THUMB_HEIGHT, "")
|
||||
sv = Pref.spMediaThumbHeight(pref)
|
||||
if(sv?.isNotEmpty() == true) {
|
||||
try {
|
||||
val iv = Integer.parseInt(sv)
|
||||
@ -1044,8 +1047,8 @@ class ActMain : AppCompatActivity()
|
||||
app_state.media_thumb_height = (0.5f + media_thumb_height * density).toInt()
|
||||
|
||||
var column_w_min_dp = COLUMN_WIDTH_MIN_DP
|
||||
sv = pref.getString(Pref.KEY_COLUMN_WIDTH, "")
|
||||
if(sv?.isNotEmpty() == true) {
|
||||
sv = Pref.spColumnWidth(pref)
|
||||
if(sv.isNotEmpty()) {
|
||||
try {
|
||||
val iv = Integer.parseInt(sv)
|
||||
if(iv >= 100) {
|
||||
@ -1060,7 +1063,7 @@ class ActMain : AppCompatActivity()
|
||||
|
||||
val sw = dm.widthPixels
|
||||
|
||||
if(pref.getBoolean(Pref.KEY_DISABLE_TABLET_MODE, false) || sw < column_w_min * 2) {
|
||||
if(Pref.bpDisableTabletMode(pref) || sw < column_w_min * 2) {
|
||||
// SmartPhone mode
|
||||
findViewById<View>(R.id.rvPager).visibility = View.GONE
|
||||
phoneEnv = PhoneEnv()
|
||||
@ -1125,7 +1128,7 @@ class ActMain : AppCompatActivity()
|
||||
llEmpty.visibility = if(app_state.column_list.isEmpty()) View.VISIBLE else View.GONE
|
||||
|
||||
llColumnStrip.removeAllViews()
|
||||
for( i in 0 until app_state.column_list.size){
|
||||
for(i in 0 until app_state.column_list.size) {
|
||||
|
||||
val column = app_state.column_list[i]
|
||||
|
||||
@ -1415,7 +1418,7 @@ class ActMain : AppCompatActivity()
|
||||
|
||||
} else if(sv.startsWith("host:")) {
|
||||
val host = sv.substring(5)
|
||||
client.instance =host
|
||||
client.instance = host
|
||||
}
|
||||
|
||||
if(client.instance == null) {
|
||||
@ -1423,7 +1426,7 @@ class ActMain : AppCompatActivity()
|
||||
}
|
||||
|
||||
this.host = client.instance
|
||||
val client_name = Pref.pref(this@ActMain).getString(Pref.KEY_CLIENT_NAME, "")
|
||||
val client_name = Pref.spClientName(this@ActMain)
|
||||
|
||||
val result = client.authentication2(client_name, code)
|
||||
val obj = result?.jsonObject
|
||||
@ -1628,7 +1631,7 @@ class ActMain : AppCompatActivity()
|
||||
return
|
||||
}
|
||||
|
||||
if(! bConfirm && ! pref.getBoolean(Pref.KEY_DONT_CONFIRM_BEFORE_CLOSE_COLUMN, false)) {
|
||||
if(! bConfirm && ! Pref.bpDontConfirmBeforeCloseColumn(pref)) {
|
||||
AlertDialog.Builder(this)
|
||||
.setMessage(R.string.confirm_close_column)
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
@ -1762,11 +1765,11 @@ class ActMain : AppCompatActivity()
|
||||
}
|
||||
|
||||
private fun showFooterColor() {
|
||||
val footer_button_bg_color = pref.getInt(Pref.KEY_FOOTER_BUTTON_BG_COLOR, 0)
|
||||
val footer_button_fg_color = pref.getInt(Pref.KEY_FOOTER_BUTTON_FG_COLOR, 0)
|
||||
val footer_tab_bg_color = pref.getInt(Pref.KEY_FOOTER_TAB_BG_COLOR, 0)
|
||||
val footer_tab_divider_color = pref.getInt(Pref.KEY_FOOTER_TAB_DIVIDER_COLOR, 0)
|
||||
val footer_tab_indicator_color = pref.getInt(Pref.KEY_FOOTER_TAB_INDICATOR_COLOR, 0)
|
||||
val footer_button_bg_color = Pref.ipFooterButtonBgColor(pref)
|
||||
val footer_button_fg_color = Pref.ipFooterButtonFgColor(pref)
|
||||
val footer_tab_bg_color = Pref.ipFooterTabBgColor(pref)
|
||||
val footer_tab_divider_color = Pref.ipFooterTabDividerColor(pref)
|
||||
val footer_tab_indicator_color = Pref.ipFooterTabIndicatorColor(pref)
|
||||
var c = footer_button_bg_color
|
||||
if(c == 0) {
|
||||
btnMenu.setBackgroundResource(R.drawable.btn_bg_ddd)
|
||||
@ -1850,10 +1853,10 @@ class ActMain : AppCompatActivity()
|
||||
val size = app_state.column_list.size
|
||||
if(index > size) index = size
|
||||
|
||||
phoneOnly { env-> env.pager.adapter = null}
|
||||
|
||||
phoneOnly { env -> env.pager.adapter = null }
|
||||
|
||||
app_state.column_list.add(index, column)
|
||||
|
||||
|
||||
phoneTab(
|
||||
{ env -> env.pager.adapter = env.pager_adapter },
|
||||
{ env -> resizeColumnWidth(env) }
|
||||
@ -1869,12 +1872,12 @@ class ActMain : AppCompatActivity()
|
||||
val idx_column = app_state.column_list.indexOf(column)
|
||||
if(idx_column == - 1) return
|
||||
|
||||
phoneOnly{env->env.pager.adapter = null}
|
||||
phoneOnly { env -> env.pager.adapter = null }
|
||||
|
||||
app_state.column_list.removeAt(idx_column).dispose()
|
||||
|
||||
phoneTab(
|
||||
{ env -> env.pager.adapter = env.pager_adapter},
|
||||
{ env -> env.pager.adapter = env.pager_adapter },
|
||||
{ env -> resizeColumnWidth(env) }
|
||||
)
|
||||
|
||||
@ -1883,7 +1886,7 @@ class ActMain : AppCompatActivity()
|
||||
}
|
||||
|
||||
private fun setOrder(new_order : ArrayList<Int>) {
|
||||
|
||||
|
||||
phoneOnly { env -> env.pager.adapter = null }
|
||||
|
||||
val tmp_list = ArrayList<Column>()
|
||||
@ -1919,8 +1922,8 @@ class ActMain : AppCompatActivity()
|
||||
private fun resizeColumnWidth(env : TabletEnv) {
|
||||
|
||||
var column_w_min_dp = COLUMN_WIDTH_MIN_DP
|
||||
val sv = pref.getString(Pref.KEY_COLUMN_WIDTH, "")
|
||||
if(sv?.isNotEmpty() == true) {
|
||||
val sv = Pref.spColumnWidth(pref)
|
||||
if(sv.isNotEmpty() ) {
|
||||
try {
|
||||
val iv = Integer.parseInt(sv)
|
||||
if(iv >= 100) {
|
||||
@ -2104,7 +2107,7 @@ class ActMain : AppCompatActivity()
|
||||
)
|
||||
updateColumnStrip()
|
||||
}
|
||||
}finally{
|
||||
} finally {
|
||||
// 通知サービスをリスタート
|
||||
PollingWorker.queueAppDataImportAfter(this@ActMain)
|
||||
}
|
||||
@ -2140,7 +2143,7 @@ class ActMain : AppCompatActivity()
|
||||
}
|
||||
|
||||
private fun resizeAutoCW(column_w : Int) {
|
||||
val sv = pref.getString(Pref.KEY_AUTO_CW_LINES, "")
|
||||
val sv = Pref.spAutoCWLines(pref)
|
||||
nAutoCwLines = Utils.parse_int(sv, - 1)
|
||||
if(nAutoCwLines > 0) {
|
||||
val lv_pad = (0.5f + 12 * density).toInt()
|
||||
|
@ -698,7 +698,7 @@ class ActPost : AppCompatActivity(), View.OnClickListener, PostAttachment.Callba
|
||||
|
||||
setContentView(R.layout.act_post)
|
||||
|
||||
if(Pref.pref(this).getBoolean(Pref.KEY_POST_BUTTON_BAR_AT_TOP, false)) {
|
||||
if(Pref.bpPostButtonBarTop(this)) {
|
||||
val bar = findViewById<View>(R.id.llFooterBar)
|
||||
val parent = bar.parent as ViewGroup
|
||||
parent.removeView(bar)
|
||||
@ -1189,7 +1189,7 @@ class ActPost : AppCompatActivity(), View.OnClickListener, PostAttachment.Callba
|
||||
}
|
||||
|
||||
// 設定からリサイズ指定を読む
|
||||
val resize_to = list_resize_max[pref.getInt(Pref.KEY_RESIZE_IMAGE, 4)]
|
||||
val resize_to = list_resize_max[Pref.ipResizeImage(pref)]
|
||||
|
||||
val bitmap = Utils.createResizedBitmap(log, this, uri, true, resize_to)
|
||||
if(bitmap != null) {
|
||||
@ -1292,7 +1292,7 @@ class ActPost : AppCompatActivity(), View.OnClickListener, PostAttachment.Callba
|
||||
try {
|
||||
val opener = createOpener(uri, mime_type)
|
||||
|
||||
val sv = pref.getString(Pref.KEY_MEDIA_SIZE_MAX, "8")
|
||||
val sv = Pref.spMediaSizeMax(pref)
|
||||
var media_size_max = 1000000 * Utils.parse_int(sv, 8)
|
||||
if(media_size_max < 1000000) media_size_max = 1000000
|
||||
|
||||
|
@ -238,7 +238,7 @@ class App1 : Application() {
|
||||
|
||||
fun prepare(app_context : Context) : AppState {
|
||||
var state = appStateX
|
||||
if(state != null ) return state
|
||||
if(state != null) return state
|
||||
|
||||
CalligraphyConfig.initDefault(CalligraphyConfig.Builder()
|
||||
.setFontAttrId(R.attr.fontPath)
|
||||
@ -424,7 +424,7 @@ class App1 : Application() {
|
||||
|
||||
prepare(activity.applicationContext)
|
||||
|
||||
var theme_idx = pref.getInt(Pref.KEY_UI_THEME, 0)
|
||||
var theme_idx = Pref.ipUiTheme(pref)
|
||||
|
||||
if(forceDark) theme_idx = 1
|
||||
|
||||
@ -508,14 +508,14 @@ class App1 : Application() {
|
||||
var allow_non_space_before_emoji_shortcode : Boolean = false
|
||||
|
||||
private fun reloadConfig() {
|
||||
disable_emoji_animation = pref.getBoolean(Pref.KEY_DISABLE_EMOJI_ANIMATION, false)
|
||||
allow_non_space_before_emoji_shortcode = pref.getBoolean(Pref.KEY_ALLOW_NON_SPACE_BEFORE_EMOJI_SHORTCODE, false)
|
||||
disable_emoji_animation = Pref.bpDisableEmojiAnimation(pref)
|
||||
allow_non_space_before_emoji_shortcode = Pref.bpAllowNonSpaceBeforeEmojiShortcode(pref)
|
||||
}
|
||||
|
||||
// Chrome Custom Tab を開く
|
||||
fun openCustomTab(activity : Activity, url : String) {
|
||||
try {
|
||||
if(pref.getBoolean(Pref.KEY_PRIOR_CHROME, true)) {
|
||||
if( Pref.bpPriorChrome(pref)) {
|
||||
try {
|
||||
// 初回はChrome指定で試す
|
||||
val builder = CustomTabsIntent.Builder()
|
||||
|
@ -263,111 +263,34 @@ object AppDataExporter {
|
||||
reader.beginObject()
|
||||
while(reader.hasNext()) {
|
||||
val k = reader.nextName() ?: throw RuntimeException("importPref: name is null")
|
||||
|
||||
val token = reader.peek()
|
||||
if(token == JsonToken.NULL) {
|
||||
reader.nextNull()
|
||||
e.remove(k)
|
||||
continue
|
||||
}
|
||||
when(k) {
|
||||
// boolean
|
||||
Pref.KEY_DONT_CONFIRM_BEFORE_CLOSE_COLUMN,
|
||||
Pref.KEY_PRIOR_LOCAL_URL,
|
||||
Pref.KEY_DISABLE_FAST_SCROLLER,
|
||||
Pref.KEY_SIMPLE_LIST,
|
||||
Pref.KEY_NOTIFICATION_SOUND,
|
||||
Pref.KEY_NOTIFICATION_VIBRATION,
|
||||
Pref.KEY_NOTIFICATION_LED,
|
||||
Pref.KEY_EXIT_APP_WHEN_CLOSE_PROTECTED_COLUMN,
|
||||
Pref.KEY_SHOW_FOLLOW_BUTTON_IN_BUTTON_BAR,
|
||||
Pref.KEY_DONT_ROUND,
|
||||
Pref.KEY_DONT_USE_STREAMING,
|
||||
Pref.KEY_DONT_REFRESH_ON_RESUME,
|
||||
Pref.KEY_DONT_SCREEN_OFF,
|
||||
Pref.KEY_DISABLE_TABLET_MODE,
|
||||
Pref.KEY_DONT_CROP_MEDIA_THUMBNAIL,
|
||||
Pref.KEY_PRIOR_CHROME,
|
||||
Pref.KEY_POST_BUTTON_BAR_AT_TOP,
|
||||
Pref.KEY_DONT_DUPLICATION_CHECK,
|
||||
Pref.KEY_QUICK_TOOT_BAR,
|
||||
Pref.KEY_ENABLE_GIF_ANIMATION,
|
||||
Pref.KEY_MENTION_FULL_ACCT,
|
||||
Pref.KEY_RELATIVE_TIMESTAMP,
|
||||
Pref.KEY_DONT_USE_ACTION_BUTTON,
|
||||
Pref.KEY_SHORT_ACCT_LOCAL_USER,
|
||||
Pref.KEY_DISABLE_EMOJI_ANIMATION,
|
||||
Pref.KEY_ALLOW_NON_SPACE_BEFORE_EMOJI_SHORTCODE,
|
||||
Pref.KEY_USE_INTERNAL_MEDIA_VIEWER -> {
|
||||
val bv = reader.nextBoolean()
|
||||
e.putBoolean(k, bv)
|
||||
}
|
||||
|
||||
// int
|
||||
Pref.KEY_BACK_BUTTON_ACTION,
|
||||
Pref.KEY_UI_THEME,
|
||||
Pref.KEY_RESIZE_IMAGE,
|
||||
Pref.KEY_REFRESH_AFTER_TOOT,
|
||||
Pref.KEY_FOOTER_BUTTON_BG_COLOR,
|
||||
Pref.KEY_FOOTER_BUTTON_FG_COLOR,
|
||||
Pref.KEY_FOOTER_TAB_BG_COLOR,
|
||||
Pref.KEY_FOOTER_TAB_DIVIDER_COLOR,
|
||||
Pref.KEY_FOOTER_TAB_INDICATOR_COLOR,
|
||||
Pref.KEY_LAST_COLUMN_POS -> {
|
||||
val iv = reader.nextInt()
|
||||
e.putInt(k, iv)
|
||||
}
|
||||
|
||||
// long
|
||||
Pref.KEY_TABLET_TOOT_DEFAULT_ACCOUNT -> {
|
||||
val lv = reader.nextLong()
|
||||
e.putLong(k, lv)
|
||||
}
|
||||
|
||||
// string
|
||||
Pref.KEY_COLUMN_WIDTH,
|
||||
Pref.KEY_MEDIA_THUMB_HEIGHT,
|
||||
Pref.KEY_STREAM_LISTENER_CONFIG_URL,
|
||||
Pref.KEY_STREAM_LISTENER_SECRET,
|
||||
Pref.KEY_STREAM_LISTENER_CONFIG_DATA,
|
||||
Pref.KEY_CLIENT_NAME,
|
||||
Pref.KEY_MASTODON_SEARCH_PORTAL_USER_TOKEN,
|
||||
Pref.KEY_QUOTE_NAME_FORMAT,
|
||||
Pref.KEY_AUTO_CW_LINES,
|
||||
Pref.KEY_AVATAR_ICON_SIZE,
|
||||
Pref.KEY_EMOJI_PICKER_RECENT,
|
||||
Pref.KEY_MEDIA_SIZE_MAX -> {
|
||||
|
||||
val sv = reader.nextString()
|
||||
e.putString(k, sv)
|
||||
}
|
||||
|
||||
// double
|
||||
Pref.KEY_TIMELINE_FONT_SIZE,
|
||||
Pref.KEY_ACCT_FONT_SIZE -> {
|
||||
val dv = reader.nextDouble()
|
||||
if(dv <= MAGIC_NAN) {
|
||||
e.putFloat(k, Float.NaN)
|
||||
} else {
|
||||
e.putFloat(k, dv.toFloat())
|
||||
}
|
||||
val prefItem = Pref.map.get(k)
|
||||
when(prefItem) {
|
||||
is Pref.BooleanPref -> e.putBoolean(k, reader.nextBoolean())
|
||||
is Pref.IntPref -> e.putInt(k, reader.nextInt())
|
||||
is Pref.LongPref -> e.putLong(k, reader.nextLong())
|
||||
|
||||
is Pref.StringPref -> if(prefItem.skipImport) {
|
||||
reader.skipValue()
|
||||
e.remove(k)
|
||||
} else {
|
||||
e.putString(k, reader.nextString())
|
||||
}
|
||||
|
||||
Pref.KEY_TIMELINE_FONT,
|
||||
Pref.KEY_TIMELINE_FONT_BOLD -> {
|
||||
reader.skipValue()
|
||||
e.remove(k)
|
||||
is Pref.FloatPref -> {
|
||||
val dv = reader.nextDouble()
|
||||
e.putFloat(k, if(dv <= MAGIC_NAN) Float.NaN else dv.toFloat())
|
||||
}
|
||||
|
||||
// just ignore
|
||||
"device_token",
|
||||
"install_id",
|
||||
"disable_gif_animation" -> {
|
||||
reader.skipValue()
|
||||
e.remove(k)
|
||||
}
|
||||
|
||||
// force reset
|
||||
|
||||
else -> {
|
||||
// ignore or force reset
|
||||
reader.skipValue()
|
||||
e.remove(k)
|
||||
}
|
||||
@ -457,28 +380,28 @@ object AppDataExporter {
|
||||
while(reader.hasNext()) {
|
||||
val name = reader.nextName()
|
||||
|
||||
when (name){
|
||||
KEY_PREF -> importPref(reader, app_state.pref)
|
||||
KEY_ACCOUNT -> importTable(reader, SavedAccount.table, account_id_map)
|
||||
when(name) {
|
||||
KEY_PREF -> importPref(reader, app_state.pref)
|
||||
KEY_ACCOUNT -> importTable(reader, SavedAccount.table, account_id_map)
|
||||
|
||||
KEY_ACCT_COLOR -> {
|
||||
KEY_ACCT_COLOR -> {
|
||||
importTable(reader, AcctColor.table, null)
|
||||
AcctColor.clearMemoryCache()
|
||||
}
|
||||
|
||||
KEY_MUTED_APP -> importTable(reader, MutedApp.table, null)
|
||||
KEY_MUTED_WORD -> importTable(reader, MutedWord.table, null)
|
||||
KEY_MUTED_APP -> importTable(reader, MutedApp.table, null)
|
||||
KEY_MUTED_WORD -> importTable(reader, MutedWord.table, null)
|
||||
KEY_HIGHLIGHT_WORD -> importTable(reader, HighlightWord.table, null)
|
||||
KEY_CLIENT_INFO -> importTable(reader, ClientInfo.table, null)
|
||||
KEY_COLUMN -> result = readColumn(app_state, reader, account_id_map)
|
||||
KEY_CLIENT_INFO -> importTable(reader, ClientInfo.table, null)
|
||||
KEY_COLUMN -> result = readColumn(app_state, reader, account_id_map)
|
||||
}
|
||||
}
|
||||
|
||||
run {
|
||||
val old_id = app_state.pref.getLong(Pref.KEY_TABLET_TOOT_DEFAULT_ACCOUNT, - 1L)
|
||||
val old_id = Pref.lpTabletTootDefaultAccount(app_state.pref)
|
||||
if(old_id != - 1L) {
|
||||
val new_id = account_id_map[old_id]
|
||||
app_state.pref.edit().putLong(Pref.KEY_TABLET_TOOT_DEFAULT_ACCOUNT, new_id ?: - 1L).apply()
|
||||
app_state.pref.edit().put(Pref.lpTabletTootDefaultAccount, new_id ?: - 1L).apply()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1218,7 +1218,7 @@ class Column(
|
||||
|
||||
val task = @SuppressLint("StaticFieldLeak")
|
||||
object : AsyncTask<Void, Void, TootApiResult?>() {
|
||||
internal var parser = TootParser(context, access_info,highlightTrie = highlight_trie)
|
||||
internal var parser = TootParser(context, access_info, highlightTrie = highlight_trie)
|
||||
|
||||
internal var instance_tmp : TootInstance? = null
|
||||
|
||||
@ -1227,10 +1227,10 @@ class Column(
|
||||
internal var list_tmp : ArrayList<Any>? = null
|
||||
|
||||
internal fun getInstanceInformation(client : TootApiClient, instance_name : String?) : TootApiResult? {
|
||||
if( instance_name != null ){
|
||||
if(instance_name != null) {
|
||||
// 「インスタンス情報」カラムをNAアカウントで開く場合
|
||||
client.instance = instance_name
|
||||
}else{
|
||||
} else {
|
||||
// カラムに紐付けられたアカウントのタンスのインスタンス情報
|
||||
}
|
||||
val result = client.request("/api/v1/instance")
|
||||
@ -1420,7 +1420,7 @@ class Column(
|
||||
}
|
||||
|
||||
override fun doInBackground(vararg params : Void) : TootApiResult? {
|
||||
val client = TootApiClient(context, callback=object : TootApiCallback {
|
||||
val client = TootApiClient(context, callback = object : TootApiCallback {
|
||||
override val isApiCancelled : Boolean
|
||||
get() = isCancelled || is_dispose.get()
|
||||
|
||||
@ -1433,7 +1433,7 @@ class Column(
|
||||
}
|
||||
})
|
||||
|
||||
client.account =access_info
|
||||
client.account = access_info
|
||||
|
||||
try {
|
||||
var result : TootApiResult?
|
||||
@ -1463,7 +1463,7 @@ class Column(
|
||||
var instance = access_info.instance
|
||||
// まだ取得してない
|
||||
// 疑似アカウントの場合は過去のデータが別タンスかもしれない?
|
||||
if( instance == null || access_info.isPseudo ) {
|
||||
if(instance == null || access_info.isPseudo) {
|
||||
val r2 = getInstanceInformation(client, null)
|
||||
if(instance_tmp != null) {
|
||||
instance = instance_tmp
|
||||
@ -1531,7 +1531,7 @@ class Column(
|
||||
result = client.request(
|
||||
String.format(Locale.JAPAN, PATH_STATUSES_CONTEXT, status_id))
|
||||
jsonObject = result?.jsonObject ?: return result
|
||||
val conversation_context = parseItem(::TootContext,parser, jsonObject)
|
||||
val conversation_context = parseItem(::TootContext, parser, jsonObject)
|
||||
|
||||
// 一つのリストにまとめる
|
||||
target_status.conversation_main = true
|
||||
@ -1596,7 +1596,7 @@ class Column(
|
||||
list_tmp = ArrayList()
|
||||
result = TootApiResult()
|
||||
} else {
|
||||
result = client.searchMsp( search_query, max_id )
|
||||
result = client.searchMsp(search_query, max_id)
|
||||
val jsonArray = result?.jsonArray
|
||||
if(jsonArray != null) {
|
||||
// max_id の更新
|
||||
@ -1616,7 +1616,7 @@ class Column(
|
||||
list_tmp = ArrayList()
|
||||
result = TootApiResult()
|
||||
} else {
|
||||
result = client.searchTootsearch( search_query, max_id)
|
||||
result = client.searchTootsearch(search_query, max_id)
|
||||
val jsonObject = result?.jsonObject
|
||||
if(jsonObject != null) {
|
||||
// max_id の更新
|
||||
@ -1793,7 +1793,7 @@ class Column(
|
||||
|
||||
val task = @SuppressLint("StaticFieldLeak")
|
||||
object : AsyncTask<Void, Void, TootApiResult?>() {
|
||||
internal var parser = TootParser(context, access_info,highlightTrie = highlight_trie)
|
||||
internal var parser = TootParser(context, access_info, highlightTrie = highlight_trie)
|
||||
|
||||
internal var list_tmp : ArrayList<Any>? = null
|
||||
|
||||
@ -2242,7 +2242,7 @@ class Column(
|
||||
}
|
||||
|
||||
override fun doInBackground(vararg params : Void) : TootApiResult? {
|
||||
val client = TootApiClient(context, callback=object : TootApiCallback {
|
||||
val client = TootApiClient(context, callback = object : TootApiCallback {
|
||||
override val isApiCancelled : Boolean
|
||||
get() = isCancelled || is_dispose.get()
|
||||
|
||||
@ -2255,7 +2255,7 @@ class Column(
|
||||
}
|
||||
})
|
||||
|
||||
client.account =access_info
|
||||
client.account = access_info
|
||||
try {
|
||||
|
||||
return when(column_type) {
|
||||
@ -2328,7 +2328,7 @@ class Column(
|
||||
list_tmp = ArrayList()
|
||||
result = TootApiResult(context.getString(R.string.end_of_list))
|
||||
} else {
|
||||
result = client.searchMsp( search_query, max_id)
|
||||
result = client.searchMsp(search_query, max_id)
|
||||
val jsonArray = result?.jsonArray
|
||||
if(jsonArray != null) {
|
||||
// max_id の更新
|
||||
@ -2350,7 +2350,7 @@ class Column(
|
||||
list_tmp = ArrayList()
|
||||
result = TootApiResult(context.getString(R.string.end_of_list))
|
||||
} else {
|
||||
result = client.searchTootsearch( search_query, max_id)
|
||||
result = client.searchTootsearch(search_query, max_id)
|
||||
val jsonObject = result?.jsonObject
|
||||
if(jsonObject != null) {
|
||||
// max_id の更新
|
||||
@ -2506,7 +2506,7 @@ class Column(
|
||||
internal val since_id = gap.since_id
|
||||
internal var list_tmp : ArrayList<Any>? = null
|
||||
|
||||
internal var parser = TootParser(context, access_info,highlightTrie = highlight_trie)
|
||||
internal var parser = TootParser(context, access_info, highlightTrie = highlight_trie)
|
||||
|
||||
internal fun getAccountList(client : TootApiClient, path_base : String) : TootApiResult? {
|
||||
val time_start = SystemClock.elapsedRealtime()
|
||||
@ -2710,7 +2710,7 @@ class Column(
|
||||
}
|
||||
|
||||
override fun doInBackground(vararg params : Void) : TootApiResult? {
|
||||
val client = TootApiClient(context, callback=object : TootApiCallback {
|
||||
val client = TootApiClient(context, callback = object : TootApiCallback {
|
||||
override val isApiCancelled : Boolean
|
||||
get() = isCancelled || is_dispose.get()
|
||||
|
||||
@ -2942,8 +2942,9 @@ class Column(
|
||||
|
||||
if(! bRefreshLoading
|
||||
&& canAutoRefresh()
|
||||
&& ! App1.getAppState(context).pref.getBoolean(Pref.KEY_DONT_REFRESH_ON_RESUME, false)
|
||||
&& ! dont_auto_refresh) {
|
||||
&& ! Pref.bpDontRefreshOnResume(App1.getAppState(context).pref)
|
||||
&& ! dont_auto_refresh
|
||||
) {
|
||||
|
||||
// リフレッシュしてからストリーミング開始
|
||||
log.d("onStart: start auto refresh.")
|
||||
@ -3042,7 +3043,7 @@ class Column(
|
||||
return
|
||||
}
|
||||
|
||||
if(App1.getAppState(context).pref.getBoolean(Pref.KEY_DONT_USE_STREAMING, false)) {
|
||||
if( Pref.bpDontUseStreaming(context) ) {
|
||||
log.d("resumeStreaming: disabled in app setting.")
|
||||
return
|
||||
}
|
||||
|
@ -29,7 +29,6 @@ import jp.juggler.subwaytooter.util.LogCategory
|
||||
import jp.juggler.subwaytooter.view.MyListView
|
||||
import jp.juggler.subwaytooter.util.ScrollPosition
|
||||
import jp.juggler.subwaytooter.util.Utils
|
||||
import java.util.regex.Matcher
|
||||
|
||||
internal class ColumnViewHolder(val activity : ActMain, root : View) : View.OnClickListener, SwipyRefreshLayout.OnRefreshListener, CompoundButton.OnCheckedChangeListener {
|
||||
|
||||
@ -345,7 +344,7 @@ internal class ColumnViewHolder(val activity : ActMain, root : View) : View.OnCl
|
||||
|
||||
log.d("onPageCreate [%d] %s", page_idx, column.getColumnName(true))
|
||||
|
||||
val bSimpleList = column.column_type != Column.TYPE_CONVERSATION && activity.pref.getBoolean(Pref.KEY_SIMPLE_LIST, true)
|
||||
val bSimpleList = column.column_type != Column.TYPE_CONVERSATION && Pref.bpSimpleList(activity.pref)
|
||||
|
||||
tvColumnIndex.text = activity.getString(R.string.column_index, page_idx + 1, page_count)
|
||||
|
||||
@ -427,7 +426,7 @@ internal class ColumnViewHolder(val activity : ActMain, root : View) : View.OnCl
|
||||
|
||||
//
|
||||
listView.adapter = status_adapter
|
||||
listView.isFastScrollEnabled = ! Pref.pref(activity).getBoolean(Pref.KEY_DISABLE_FAST_SCROLLER, true)
|
||||
listView.isFastScrollEnabled = ! Pref.bpDisableFastScroller(Pref.pref(activity))
|
||||
listView.onItemClickListener = status_adapter
|
||||
|
||||
column.addColumnViewHolder(this)
|
||||
|
@ -537,8 +537,8 @@ internal class DlgContextMenu(
|
||||
R.id.btnQuoteName -> who?.let { who ->
|
||||
var sv = who.display_name
|
||||
try {
|
||||
val fmt = activity.pref.getString(Pref.KEY_QUOTE_NAME_FORMAT, null)
|
||||
if(fmt != null && fmt.contains("%1\$s")) {
|
||||
val fmt = Pref.spQuoteNameFormat( activity.pref)
|
||||
if( fmt.contains("%1\$s")) {
|
||||
sv = String.format(fmt, sv)
|
||||
}
|
||||
} catch(ex : Throwable) {
|
||||
|
@ -543,15 +543,13 @@ internal class ItemViewHolder(
|
||||
buttons_for_status?.bind(status, (item as? TootNotification))
|
||||
|
||||
val application = status.application
|
||||
when(column.column_type) {
|
||||
|
||||
Column.TYPE_CONVERSATION -> if(application == null) {
|
||||
tvApplication.visibility = View.GONE
|
||||
} else {
|
||||
tvApplication.visibility = View.VISIBLE
|
||||
tvApplication.text = activity.getString(R.string.application_is, application.name ?: "")
|
||||
}
|
||||
else -> tvApplication.visibility = View.GONE
|
||||
if(application != null
|
||||
&&( column.column_type == Column.TYPE_CONVERSATION || Pref.bpShowAppName(activity.pref) )
|
||||
) {
|
||||
tvApplication.visibility = View.VISIBLE
|
||||
tvApplication.text = activity.getString(R.string.application_is, application?.name ?: "")
|
||||
}else{
|
||||
tvApplication.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
@ -852,7 +850,7 @@ internal class ItemViewHolder(
|
||||
}
|
||||
|
||||
is TootAttachment -> {
|
||||
if(App1.pref.getBoolean(Pref.KEY_USE_INTERNAL_MEDIA_VIEWER, true)) {
|
||||
if(Pref.bpUseInternalMediaViewer(App1.pref)) {
|
||||
// 内蔵メディアビューア
|
||||
ActMediaViewer.open(activity, media_attachments, i)
|
||||
|
||||
|
@ -972,12 +972,12 @@ class PollingWorker private constructor(c : Context) {
|
||||
private fun loadCustomStreamListenerSetting() {
|
||||
mCustomStreamListenerSetting = null
|
||||
mCustomStreamListenerSecret = null
|
||||
val jsonString = pref.getString(Pref.KEY_STREAM_LISTENER_CONFIG_DATA, null)
|
||||
val jsonString = Pref.spStreamListenerConfigData(pref)
|
||||
mCustomStreamListenerSettingString = jsonString
|
||||
if(jsonString != null && jsonString.isNotEmpty()) {
|
||||
if(jsonString.isNotEmpty() ){
|
||||
try {
|
||||
mCustomStreamListenerSetting = JsonValue.readHjson(jsonString).asObject()
|
||||
mCustomStreamListenerSecret = pref.getString(Pref.KEY_STREAM_LISTENER_SECRET, null)
|
||||
mCustomStreamListenerSecret = Pref.spStreamListenerSecret(pref)
|
||||
} catch(ex : Throwable) {
|
||||
log.trace(ex)
|
||||
}
|
||||
@ -1448,7 +1448,7 @@ class PollingWorker private constructor(c : Context) {
|
||||
|
||||
var iv = 0
|
||||
|
||||
if(pref.getBoolean(Pref.KEY_NOTIFICATION_SOUND, true)) {
|
||||
if( Pref.bpNotificationSound(pref) ) {
|
||||
|
||||
var sound_uri : Uri? = null
|
||||
|
||||
@ -1487,13 +1487,13 @@ class PollingWorker private constructor(c : Context) {
|
||||
|
||||
log.d("showNotification[%s] creating notification(4)", account.acct)
|
||||
|
||||
if(pref.getBoolean(Pref.KEY_NOTIFICATION_VIBRATION, true)) {
|
||||
if(Pref.bpNotificationVibration(pref)) {
|
||||
iv = iv or NotificationCompat.DEFAULT_VIBRATE
|
||||
}
|
||||
|
||||
log.d("showNotification[%s] creating notification(5)", account.acct)
|
||||
|
||||
if(pref.getBoolean(Pref.KEY_NOTIFICATION_LED, true)) {
|
||||
if(Pref.bpNotificationLED(pref)) {
|
||||
iv = iv or NotificationCompat.DEFAULT_LIGHTS
|
||||
}
|
||||
|
||||
|
@ -5,97 +5,215 @@ import android.content.SharedPreferences
|
||||
import android.preference.PreferenceManager
|
||||
|
||||
object Pref {
|
||||
|
||||
fun pref(context : Context) : SharedPreferences {
|
||||
return PreferenceManager.getDefaultSharedPreferences(context)
|
||||
}
|
||||
|
||||
const val KEY_BACK_TO_COLUMN_LIST = "BackToColumnList" // 使わなくなった
|
||||
@Suppress("EqualsOrHashCode")
|
||||
abstract class BasePref<in T>(val key : String) {
|
||||
|
||||
override fun equals(other : Any?) : Boolean {
|
||||
return this === other
|
||||
}
|
||||
|
||||
fun remove(e : SharedPreferences.Editor) {
|
||||
e.remove(key)
|
||||
}
|
||||
|
||||
abstract fun put(editor : SharedPreferences.Editor, v : T)
|
||||
}
|
||||
|
||||
class BooleanPref(
|
||||
key : String,
|
||||
private val defVal : Boolean,
|
||||
val id : Int
|
||||
) : BasePref<Boolean>(key) {
|
||||
|
||||
operator fun invoke(pref : SharedPreferences) : Boolean {
|
||||
return pref.getBoolean(key, defVal)
|
||||
}
|
||||
|
||||
operator fun invoke(context : Context) : Boolean {
|
||||
return pref(context).getBoolean(key, defVal)
|
||||
}
|
||||
|
||||
override fun put(editor : SharedPreferences.Editor, v : Boolean) {
|
||||
editor.putBoolean(key, v)
|
||||
}
|
||||
}
|
||||
|
||||
class IntPref(
|
||||
key : String,
|
||||
private val defVal : Int
|
||||
) : BasePref<Int>(key) {
|
||||
|
||||
operator fun invoke(pref : SharedPreferences) : Int {
|
||||
return pref.getInt(key, defVal)
|
||||
}
|
||||
|
||||
operator fun invoke(context : Context) : Int {
|
||||
return pref(context).getInt(key, defVal)
|
||||
}
|
||||
|
||||
override fun put(editor : SharedPreferences.Editor, v : Int) {
|
||||
editor.putInt(key, v)
|
||||
}
|
||||
}
|
||||
|
||||
class LongPref(
|
||||
key : String,
|
||||
private val defVal : Long
|
||||
) : BasePref<Long>(key) {
|
||||
|
||||
operator fun invoke(pref : SharedPreferences) : Long {
|
||||
return pref.getLong(key, defVal)
|
||||
}
|
||||
|
||||
operator fun invoke(context : Context) : Long {
|
||||
return pref(context).getLong(key, defVal)
|
||||
}
|
||||
|
||||
override fun put(editor : SharedPreferences.Editor, v : Long) {
|
||||
editor.putLong(key, v)
|
||||
}
|
||||
}
|
||||
|
||||
class FloatPref(
|
||||
key : String,
|
||||
private val defVal : Float
|
||||
) : BasePref<Float>(key) {
|
||||
|
||||
operator fun invoke(pref : SharedPreferences) : Float {
|
||||
return pref.getFloat(key, defVal)
|
||||
}
|
||||
|
||||
operator fun invoke(context : Context) : Float {
|
||||
return pref(context).getFloat(key, defVal)
|
||||
}
|
||||
|
||||
override fun put(editor : SharedPreferences.Editor, v : Float) {
|
||||
editor.putFloat(key, v)
|
||||
}
|
||||
}
|
||||
|
||||
class StringPref(
|
||||
key : String,
|
||||
private val defVal : String,
|
||||
val skipImport : Boolean = false
|
||||
) : BasePref<String>(key) {
|
||||
|
||||
operator fun invoke(pref : SharedPreferences) : String {
|
||||
return pref.getString(key, defVal)
|
||||
}
|
||||
|
||||
operator fun invoke(context : Context) : String {
|
||||
return pref(context).getString(key, defVal)
|
||||
}
|
||||
|
||||
override fun put(editor : SharedPreferences.Editor, v : String) {
|
||||
editor.putString(key, v)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// インポート時に使う。キー名に対応した設定項目を返す
|
||||
val map = HashMap<String, BasePref<*>>()
|
||||
|
||||
private fun <T : BasePref<*>> register(item : T) : T {
|
||||
map.put(item.key, item)
|
||||
return item
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// boolean
|
||||
|
||||
val bpAllowNonSpaceBeforeEmojiShortcode = register(BooleanPref("allow_non_space_before_emoji_shortcode", false, R.id.swAllowNonSpaceBeforeEmojiShortcode))
|
||||
val bpDisableEmojiAnimation = register(BooleanPref("disable_emoji_animation", false, R.id.swDisableEmojiAnimation))
|
||||
val bpDisableFastScroller = register(BooleanPref("disable_fast_scroller", true, R.id.swDisableFastScroller))
|
||||
val bpDisableTabletMode = register(BooleanPref("disable_tablet_mode", false, R.id.swDisableTabletMode))
|
||||
val bpDontConfirmBeforeCloseColumn = register(BooleanPref("DontConfirmBeforeCloseColumn", false, R.id.swDontConfirmBeforeCloseColumn))
|
||||
val bpDontCropMediaThumb = register(BooleanPref("DontCropMediaThumb", false, R.id.swDontCropMediaThumb))
|
||||
val bpDontDuplicationCheck = register(BooleanPref("dont_duplication_check", false, R.id.swDontDuplicationCheck))
|
||||
val bpDontRefreshOnResume = register(BooleanPref("dont_refresh_on_resume", false, R.id.swDontRefreshOnResume))
|
||||
val bpDontRound = register(BooleanPref("dont_round", false, R.id.swDontRound))
|
||||
val bpDontScreenOff = register(BooleanPref("dont_screen_off", false, R.id.swDontScreenOff))
|
||||
val bpDontUseActionButtonWithQuickTootBar = register(BooleanPref("dont_use_action_button", false, R.id.swDontUseActionButtonWithQuickTootBar))
|
||||
val bpDontUseStreaming = register(BooleanPref("dont_use_streaming", false, R.id.swDontUseStreaming))
|
||||
val bpEnableGifAnimation = register(BooleanPref("enable_gif_animation", false, R.id.swEnableGifAnimation))
|
||||
val bpExitAppWhenCloseProtectedColumn = register(BooleanPref("ExitAppWhenCloseProtectedColumn", false, R.id.swExitAppWhenCloseProtectedColumn))
|
||||
val bpMentionFullAcct = register(BooleanPref("mention_full_acct", false, R.id.swMentionFullAcct))
|
||||
val bpPostButtonBarTop = register(BooleanPref("post_button_bar_at_top", false, R.id.swPostButtonBarTop))
|
||||
val bpPriorChrome = register(BooleanPref("prior_chrome", true, R.id.swPriorChrome))
|
||||
val bpPriorLocalURL = register(BooleanPref("prior_local_url", false, R.id.swPriorLocalURL))
|
||||
val bpQuickTootBar = register(BooleanPref("quick_toot_bar", false, R.id.swQuickTootBar))
|
||||
val bpRelativeTimestamp = register(BooleanPref("relative_timestamp", true, R.id.swRelativeTimestamp))
|
||||
val bpShortAcctLocalUser = register(BooleanPref("short_acct_local_user", true, R.id.swShortAcctLocalUser))
|
||||
val bpShowFollowButtonInButtonBar = register(BooleanPref("ShowFollowButtonInButtonBar", false, R.id.swShowFollowButtonInButtonBar))
|
||||
val bpSimpleList = register(BooleanPref("simple_list", true, R.id.swSimpleList))
|
||||
val bpUseInternalMediaViewer = register(BooleanPref("use_internal_media_viewer", true, R.id.swUseInternalMediaViewer))
|
||||
val bpShowAppName = register(BooleanPref("show_app_name", false, R.id.swShowAppName))
|
||||
val bpNotificationSound = register(BooleanPref("notification_sound", true, R.id.cbNotificationSound))
|
||||
val bpNotificationVibration = register(BooleanPref("notification_vibration", true, R.id.cbNotificationVibration))
|
||||
val bpNotificationLED = register(BooleanPref("notification_led", true, R.id.cbNotificationLED))
|
||||
|
||||
// int
|
||||
|
||||
val ipBackButtonAction = register(IntPref("back_button_action", 0))
|
||||
val ipUiTheme = register(IntPref("ui_theme", 0))
|
||||
val ipResizeImage = register(IntPref("resize_image", 4))
|
||||
|
||||
val ipRefreshAfterToot = register(IntPref("refresh_after_toot", 0))
|
||||
|
||||
val ipFooterButtonBgColor = register(IntPref("footer_button_bg_color", 0))
|
||||
val ipFooterButtonFgColor = register(IntPref("footer_button_fg_color", 0))
|
||||
val ipFooterTabBgColor = register(IntPref("footer_tab_bg_color", 0))
|
||||
val ipFooterTabDividerColor = register(IntPref("footer_tab_divider_color", 0))
|
||||
val ipFooterTabIndicatorColor = register(IntPref("footer_tab_indicator_color", 0))
|
||||
val ipLastColumnPos = register(IntPref("last_column_pos", - 1))
|
||||
|
||||
// ipRefreshAfterToot の値
|
||||
const val RAT_REFRESH_SCROLL = 0
|
||||
const val RAT_REFRESH_DONT_SCROLL = 1
|
||||
const val RAT_DONT_REFRESH = 2
|
||||
|
||||
const val KEY_DONT_CONFIRM_BEFORE_CLOSE_COLUMN = "DontConfirmBeforeCloseColumn"
|
||||
// string
|
||||
|
||||
const val KEY_BACK_BUTTON_ACTION = "back_button_action"
|
||||
const val KEY_PRIOR_LOCAL_URL = "prior_local_url"
|
||||
const val KEY_DISABLE_FAST_SCROLLER = "disable_fast_scroller"
|
||||
const val KEY_UI_THEME = "ui_theme"
|
||||
const val KEY_SIMPLE_LIST = "simple_list"
|
||||
const val KEY_NOTIFICATION_SOUND = "notification_sound"
|
||||
const val KEY_NOTIFICATION_VIBRATION = "notification_vibration"
|
||||
const val KEY_NOTIFICATION_LED = "notification_led"
|
||||
const val KEY_EXIT_APP_WHEN_CLOSE_PROTECTED_COLUMN = "ExitAppWhenCloseProtectedColumn"
|
||||
const val KEY_RESIZE_IMAGE = "resize_image"
|
||||
const val KEY_SHOW_FOLLOW_BUTTON_IN_BUTTON_BAR = "ShowFollowButtonInButtonBar"
|
||||
const val KEY_REFRESH_AFTER_TOOT = "refresh_after_toot"
|
||||
const val KEY_DONT_ROUND = "dont_round"
|
||||
val spColumnWidth = register(StringPref("ColumnWidth", ""))
|
||||
val spMediaThumbHeight = register(StringPref("MediaThumbHeight", ""))
|
||||
val spClientName = register(StringPref("client_name", ""))
|
||||
val spQuoteNameFormat = register(StringPref("quote_name_format", ""))
|
||||
val spAutoCWLines = register(StringPref("auto_cw_lines", "0"))
|
||||
val spAvatarIconSize = register(StringPref("avatar_icon_size", "48"))
|
||||
val spMediaSizeMax = register(StringPref("max_media_size", "8"))
|
||||
val spTimelineFont = register(StringPref("timeline_font", "", skipImport = true))
|
||||
val spTimelineFontBold = register(StringPref("timeline_font_bold", "", skipImport = true))
|
||||
val spStreamListenerSecret = register(StringPref("stream_listener_secret", ""))
|
||||
val spStreamListenerConfigUrl = register(StringPref("stream_listener_config_url", ""))
|
||||
val spStreamListenerConfigData = register(StringPref("stream_listener_config_data", ""))
|
||||
val spMspUserToken = register(StringPref("mastodon_search_portal_user_token", ""))
|
||||
val spEmojiPickerRecent = register(StringPref("emoji_picker_recent", ""))
|
||||
|
||||
const val KEY_FOOTER_BUTTON_BG_COLOR = "footer_button_bg_color"
|
||||
const val KEY_FOOTER_BUTTON_FG_COLOR = "footer_button_fg_color"
|
||||
const val KEY_FOOTER_TAB_BG_COLOR = "footer_tab_bg_color"
|
||||
const val KEY_FOOTER_TAB_DIVIDER_COLOR = "footer_tab_divider_color"
|
||||
const val KEY_FOOTER_TAB_INDICATOR_COLOR = "footer_tab_indicator_color"
|
||||
// long
|
||||
|
||||
const val KEY_DONT_USE_STREAMING = "dont_use_streaming"
|
||||
const val KEY_DONT_REFRESH_ON_RESUME = "dont_refresh_on_resume"
|
||||
const val KEY_DONT_SCREEN_OFF = "dont_screen_off"
|
||||
const val KEY_DISABLE_TABLET_MODE = "disable_tablet_mode"
|
||||
val lpTabletTootDefaultAccount = register(LongPref("tablet_toot_default_account", - 1L))
|
||||
|
||||
const val KEY_COLUMN_WIDTH = "ColumnWidth"
|
||||
const val KEY_MEDIA_THUMB_HEIGHT = "MediaThumbHeight"
|
||||
const val KEY_TIMELINE_FONT = "timeline_font"
|
||||
const val KEY_TIMELINE_FONT_BOLD = "timeline_font_bold"
|
||||
// float
|
||||
|
||||
const val KEY_DONT_CROP_MEDIA_THUMBNAIL = "DontCropMediaThumb"
|
||||
|
||||
const val KEY_STREAM_LISTENER_SECRET = "stream_listener_secret"
|
||||
const val KEY_STREAM_LISTENER_CONFIG_URL = "stream_listener_config_url"
|
||||
const val KEY_STREAM_LISTENER_CONFIG_DATA = "stream_listener_config_data"
|
||||
const val KEY_TABLET_TOOT_DEFAULT_ACCOUNT = "tablet_toot_default_account"
|
||||
|
||||
const val KEY_PRIOR_CHROME = "prior_chrome"
|
||||
|
||||
internal const val KEY_POST_BUTTON_BAR_AT_TOP = "post_button_bar_at_top"
|
||||
|
||||
const val KEY_CLIENT_NAME = "client_name"
|
||||
|
||||
const val KEY_MASTODON_SEARCH_PORTAL_USER_TOKEN = "mastodon_search_portal_user_token"
|
||||
|
||||
const val KEY_LAST_COLUMN_POS = "last_column_pos"
|
||||
|
||||
const val KEY_TIMELINE_FONT_SIZE = "timeline_font_size"
|
||||
const val KEY_ACCT_FONT_SIZE = "acct_font_size"
|
||||
|
||||
const val KEY_DONT_DUPLICATION_CHECK = "dont_duplication_check"
|
||||
const val KEY_QUICK_TOOT_BAR = "quick_toot_bar"
|
||||
|
||||
const val KEY_QUOTE_NAME_FORMAT = "quote_name_format"
|
||||
|
||||
const val KEY_ENABLE_GIF_ANIMATION = "enable_gif_animation"
|
||||
|
||||
const val KEY_MENTION_FULL_ACCT = "mention_full_acct"
|
||||
|
||||
const val KEY_RELATIVE_TIMESTAMP = "relative_timestamp"
|
||||
|
||||
const val KEY_DONT_USE_ACTION_BUTTON = "dont_use_action_button"
|
||||
|
||||
const val KEY_AUTO_CW_LINES = "auto_cw_lines"
|
||||
|
||||
const val KEY_SHORT_ACCT_LOCAL_USER = "short_acct_local_user"
|
||||
|
||||
const val KEY_AVATAR_ICON_SIZE = "avatar_icon_size"
|
||||
|
||||
const val KEY_EMOJI_PICKER_RECENT = "emoji_picker_recent"
|
||||
|
||||
const val KEY_DISABLE_EMOJI_ANIMATION = "disable_emoji_animation"
|
||||
|
||||
const val KEY_ALLOW_NON_SPACE_BEFORE_EMOJI_SHORTCODE = "allow_non_space_before_emoji_shortcode"
|
||||
|
||||
const val KEY_MEDIA_SIZE_MAX = "max_media_size"
|
||||
|
||||
const val KEY_USE_INTERNAL_MEDIA_VIEWER = "use_internal_media_viewer"
|
||||
|
||||
// 項目を追加したらAppDataExporter#importPref のswitch文も更新すること
|
||||
val fpTimelineFontSize = register(FloatPref("timeline_font_size", Float.NaN))
|
||||
val fpAcctFontSize = register(FloatPref("acct_font_size", Float.NaN))
|
||||
|
||||
}
|
||||
|
||||
fun <T> SharedPreferences.Editor.put(item : Pref.BasePref<T>, v : T) : SharedPreferences.Editor {
|
||||
item.put(this, v)
|
||||
return this
|
||||
}
|
||||
|
||||
fun SharedPreferences.Editor.remove(item : Pref.BasePref<*>) : SharedPreferences.Editor {
|
||||
item.remove(this)
|
||||
return this
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ internal class StatusButtons(
|
||||
|
||||
val account = status.account
|
||||
|
||||
this.relation = if( ! activity.pref.getBoolean(Pref.KEY_SHOW_FOLLOW_BUTTON_IN_BUTTON_BAR, false)) {
|
||||
this.relation = if( ! Pref.bpShowFollowButtonInButtonBar(activity.pref)) {
|
||||
llFollow2.visibility = View.GONE
|
||||
null
|
||||
} else {
|
||||
|
@ -39,7 +39,7 @@ object Action_Account {
|
||||
return if(bPseudoAccount || bInputAccessToken) {
|
||||
client.getInstanceInformation()
|
||||
} else {
|
||||
val client_name = Pref.pref(activity).getString(Pref.KEY_CLIENT_NAME, "")
|
||||
val client_name = Pref.spClientName(activity)
|
||||
client.authentication1(client_name)
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ import jp.juggler.subwaytooter.Pref
|
||||
import jp.juggler.subwaytooter.table.ClientInfo
|
||||
import jp.juggler.subwaytooter.table.SavedAccount
|
||||
import jp.juggler.subwaytooter.R
|
||||
import jp.juggler.subwaytooter.put
|
||||
import jp.juggler.subwaytooter.util.*
|
||||
import okhttp3.*
|
||||
import org.json.JSONArray
|
||||
@ -558,13 +559,13 @@ class TootApiClient(
|
||||
fun searchMsp(query : String, max_id : String) : TootApiResult? {
|
||||
|
||||
// ユーザトークンを読む
|
||||
var user_token = pref.getString(Pref.KEY_MASTODON_SEARCH_PORTAL_USER_TOKEN, null)
|
||||
var user_token :String? = Pref.spMspUserToken(pref)
|
||||
|
||||
for(nTry in 0 until 3) {
|
||||
if(callback.isApiCancelled) return null
|
||||
|
||||
// ユーザトークンがなければ取得する
|
||||
if(user_token == null || user_token.isEmpty()) {
|
||||
if( user_token == null || user_token.isEmpty() ){
|
||||
|
||||
callback.publishApiProgress("get MSP user token...")
|
||||
|
||||
@ -590,9 +591,10 @@ class TootApiClient(
|
||||
user_token = jsonObject.optJSONObject("result")?.optString("token")
|
||||
if(user_token?.isEmpty() != false) {
|
||||
return result.setError("Can't get MSP user token. response=${result.bodyString}")
|
||||
}else{
|
||||
pref.edit().put( Pref.spMspUserToken,user_token).apply()
|
||||
}
|
||||
|
||||
pref.edit().putString(Pref.KEY_MASTODON_SEARCH_PORTAL_USER_TOKEN, user_token).apply()
|
||||
}
|
||||
|
||||
// ユーザトークンを使って検索APIを呼び出す
|
||||
|
@ -57,7 +57,7 @@ class TootAttachment(src : JSONObject) : TootAttachmentLike {
|
||||
}
|
||||
|
||||
fun getLargeUrl(pref : SharedPreferences) : String? {
|
||||
return if( pref.getBoolean(Pref.KEY_PRIOR_LOCAL_URL, false) ){
|
||||
return if( Pref.bpPriorLocalURL(pref) ){
|
||||
if( url?.isNotEmpty() ==true) url else remote_url
|
||||
} else {
|
||||
if( remote_url?.isNotEmpty() == true ) remote_url else url
|
||||
@ -65,7 +65,7 @@ class TootAttachment(src : JSONObject) : TootAttachmentLike {
|
||||
}
|
||||
fun getLargeUrlList(pref : SharedPreferences) : ArrayList<String> {
|
||||
val result = ArrayList<String>()
|
||||
if( pref.getBoolean(Pref.KEY_PRIOR_LOCAL_URL, false) ){
|
||||
if( Pref.bpPriorLocalURL(pref) ){
|
||||
if( url?.isNotEmpty() ==true) result.add(url)
|
||||
if( remote_url?.isNotEmpty()==true) result.add( remote_url)
|
||||
} else {
|
||||
|
@ -474,7 +474,7 @@ class TootStatus(parser : TootParser, src : JSONObject, serviceType : ServiceTyp
|
||||
private val date_format = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault())
|
||||
|
||||
fun formatTime(context : Context, t : Long, bAllowRelative : Boolean) : String {
|
||||
if(bAllowRelative && App1.pref.getBoolean(Pref.KEY_RELATIVE_TIMESTAMP, false)) {
|
||||
if(bAllowRelative && Pref.bpRelativeTimestamp(App1.pref)) {
|
||||
val now = System.currentTimeMillis()
|
||||
var delta = now - t
|
||||
val sign = context.getString(if(delta > 0) R.string.ago else R.string.later)
|
||||
|
@ -25,6 +25,7 @@ import jp.juggler.subwaytooter.App1
|
||||
import jp.juggler.subwaytooter.Pref
|
||||
import jp.juggler.subwaytooter.R
|
||||
import jp.juggler.subwaytooter.api.entity.CustomEmoji
|
||||
import jp.juggler.subwaytooter.put
|
||||
import jp.juggler.subwaytooter.util.*
|
||||
import jp.juggler.subwaytooter.view.NetworkEmojiView
|
||||
|
||||
@ -92,8 +93,8 @@ class EmojiPicker(
|
||||
|
||||
// recentをロードする
|
||||
val pref = App1.pref
|
||||
val sv = pref.getString(Pref.KEY_EMOJI_PICKER_RECENT, null)
|
||||
if( sv != null && sv.isNotEmpty() ) {
|
||||
val sv = Pref.spEmojiPickerRecent(pref)
|
||||
if( sv.isNotEmpty() ) {
|
||||
try {
|
||||
val array = JSONArray(sv)
|
||||
for( i in 0 until array.length() ){
|
||||
@ -353,8 +354,8 @@ class EmojiPicker(
|
||||
// Recentをロード(他インスタンスの絵文字を含む)
|
||||
val pref = App1.pref
|
||||
val list = ArrayList<JSONObject>()
|
||||
val sv = pref.getString(Pref.KEY_EMOJI_PICKER_RECENT, null)
|
||||
if( sv != null && sv.isNotEmpty() ) {
|
||||
val sv = Pref.spEmojiPickerRecent(pref)
|
||||
if( sv.isNotEmpty() ) {
|
||||
try {
|
||||
val array = JSONArray(sv)
|
||||
var i = 0
|
||||
@ -401,7 +402,7 @@ class EmojiPicker(
|
||||
for(item in list) {
|
||||
array.put(item)
|
||||
}
|
||||
App1.pref.edit().putString(Pref.KEY_EMOJI_PICKER_RECENT, array.toString()).apply()
|
||||
App1.pref.edit().put(Pref.spEmojiPickerRecent, array.toString()).apply()
|
||||
} catch(ignored : Throwable) {
|
||||
|
||||
}
|
||||
|
@ -363,7 +363,7 @@ object HTMLDecoder {
|
||||
bShort : Boolean, context : Context, display_url : String, href : String?, list_attachment :ArrayList<TootAttachmentLike>?
|
||||
) : CharSequence {
|
||||
if(! display_url.startsWith("http")) {
|
||||
if(display_url.startsWith("@") && href != null && App1.pref.getBoolean(Pref.KEY_MENTION_FULL_ACCT, false)) {
|
||||
if(display_url.startsWith("@") && href != null && Pref.bpMentionFullAcct(App1.pref)) {
|
||||
// メンションをfull acct にする
|
||||
val m = TootAccount.reAccountUrl.matcher(href)
|
||||
if(m.find()) {
|
||||
@ -452,7 +452,7 @@ object HTMLDecoder {
|
||||
if(sb.isNotEmpty()) sb.append(" ")
|
||||
val start = sb.length
|
||||
sb.append('@')
|
||||
if(App1.pref.getBoolean(Pref.KEY_MENTION_FULL_ACCT, false)) {
|
||||
if( Pref.bpMentionFullAcct(App1.pref)) {
|
||||
sb.append(access_info.getFullAcct(item.acct))
|
||||
} else {
|
||||
sb.append(item.acct)
|
||||
|
@ -277,7 +277,7 @@ class PostHelper(
|
||||
.post(request_body)
|
||||
val digest = Utils.digestSHA256(body_string + account.acct)
|
||||
|
||||
if(digest != null && ! pref.getBoolean(Pref.KEY_DONT_DUPLICATION_CHECK, false)) {
|
||||
if(digest != null && ! Pref.bpDontDuplicationCheck(pref) ) {
|
||||
request_builder.header("Idempotency-Key", digest)
|
||||
}
|
||||
|
||||
|
@ -38,15 +38,14 @@ class MyNetworkImageView @JvmOverloads constructor(
|
||||
) : AppCompatImageView(context, attrs, defStyle) {
|
||||
|
||||
|
||||
|
||||
companion object {
|
||||
|
||||
internal val log = LogCategory("MyNetworkImageView")
|
||||
|
||||
@SuppressLint("StaticFieldLeak") internal var app_context : Context? = null
|
||||
|
||||
// private const val SQUARE_RATIO_MARGIN = 0.05f
|
||||
// private const val maxLoopCount = GifDrawable.LOOP_FOREVER
|
||||
// private const val SQUARE_RATIO_MARGIN = 0.05f
|
||||
// private const val maxLoopCount = GifDrawable.LOOP_FOREVER
|
||||
}
|
||||
|
||||
// ロード中などに表示するDrawableのリソースID
|
||||
@ -92,9 +91,9 @@ class MyNetworkImageView @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
|
||||
mCornerRadius = if(pref.getBoolean(Pref.KEY_DONT_ROUND, false)) 0f else r
|
||||
mCornerRadius = if(Pref.bpDontRound(pref)) 0f else r
|
||||
|
||||
val gif_url = if(! pref.getBoolean(Pref.KEY_ENABLE_GIF_ANIMATION, false)) null else gifUrlArg
|
||||
val gif_url = if(Pref.bpEnableGifAnimation(pref)) gifUrlArg else null
|
||||
|
||||
if(gif_url != null && gif_url.isNotEmpty()) {
|
||||
mUrl = gif_url
|
||||
@ -106,17 +105,17 @@ class MyNetworkImageView @JvmOverloads constructor(
|
||||
loadImageIfNecessary()
|
||||
}
|
||||
|
||||
private fun getGLide() :RequestManager? {
|
||||
try{
|
||||
private fun getGLide() : RequestManager? {
|
||||
try {
|
||||
return Glide.with(context)
|
||||
}catch(ex:IllegalArgumentException){
|
||||
if( ex.message?.contains("destroyed activity") == true ){
|
||||
} catch(ex : IllegalArgumentException) {
|
||||
if(ex.message?.contains("destroyed activity") == true) {
|
||||
// ignore it
|
||||
}else{
|
||||
log.e(ex,"Glide.with() failed.")
|
||||
} else {
|
||||
log.e(ex, "Glide.with() failed.")
|
||||
}
|
||||
}catch(ex:Throwable){
|
||||
log.e(ex,"Glide.with() failed.")
|
||||
} catch(ex : Throwable) {
|
||||
log.e(ex, "Glide.with() failed.")
|
||||
}
|
||||
return null
|
||||
}
|
||||
@ -134,8 +133,8 @@ class MyNetworkImageView @JvmOverloads constructor(
|
||||
setImageDrawable(null)
|
||||
try {
|
||||
getGLide()?.clear(target)
|
||||
}catch(ex:Throwable){
|
||||
log.e(ex,"Glide.clear() failed.")
|
||||
} catch(ex : Throwable) {
|
||||
log.e(ex, "Glide.clear() failed.")
|
||||
}
|
||||
|
||||
mTarget = null
|
||||
@ -165,7 +164,7 @@ class MyNetworkImageView @JvmOverloads constructor(
|
||||
private fun loadImageIfNecessary() {
|
||||
try {
|
||||
val url = mUrl
|
||||
if(url?.isEmpty() != false ) {
|
||||
if(url?.isEmpty() != false) {
|
||||
// if the URL to be loaded in this view is empty,
|
||||
// cancel any old requests and clear the currently loaded image.
|
||||
cancelLoading()
|
||||
@ -298,16 +297,16 @@ class MyNetworkImageView @JvmOverloads constructor(
|
||||
// 角丸でないならそのまま使う
|
||||
resource
|
||||
}
|
||||
|
||||
// GidDrawableを置き換える
|
||||
|
||||
// GidDrawableを置き換える
|
||||
resource is GifDrawable -> replaceGifDrawable(resource)
|
||||
|
||||
// Glide 4.xから、静止画はBitmapDrawableになった
|
||||
resource is BitmapDrawable ->{
|
||||
|
||||
// Glide 4.xから、静止画はBitmapDrawableになった
|
||||
resource is BitmapDrawable -> {
|
||||
val bitmap = resource.bitmap
|
||||
if( bitmap ==null ){
|
||||
if(bitmap == null) {
|
||||
resource
|
||||
}else{
|
||||
} else {
|
||||
val d = RoundedBitmapDrawableFactory.create(resources, bitmap)
|
||||
d.cornerRadius = mCornerRadius
|
||||
d
|
||||
@ -324,19 +323,19 @@ class MyNetworkImageView @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun replaceGifDrawable( resource:GifDrawable) : Drawable {
|
||||
// ディスクキャッシュから読んだ画像は角丸が正しく扱われない
|
||||
// MyGifDrawable に差し替えて描画させる
|
||||
if(app_context != null) {
|
||||
try {
|
||||
return MyGifDrawable(resource, mCornerRadius)
|
||||
} catch(ex : Throwable) {
|
||||
log.trace(ex)
|
||||
|
||||
private fun replaceGifDrawable(resource : GifDrawable) : Drawable {
|
||||
// ディスクキャッシュから読んだ画像は角丸が正しく扱われない
|
||||
// MyGifDrawable に差し替えて描画させる
|
||||
if(app_context != null) {
|
||||
try {
|
||||
return MyGifDrawable(resource, mCornerRadius)
|
||||
} catch(ex : Throwable) {
|
||||
log.trace(ex)
|
||||
}
|
||||
}
|
||||
return resource
|
||||
}
|
||||
return resource
|
||||
}
|
||||
|
||||
private fun afterResourceReady(resource : Drawable, transition : Transition<in Drawable>?) {
|
||||
super.onResourceReady(resource, transition)
|
||||
|
@ -712,6 +712,23 @@
|
||||
|
||||
<View style="@style/setting_divider"/>
|
||||
|
||||
<TextView
|
||||
style="@style/setting_row_label"
|
||||
android:text="@string/always_show_application"
|
||||
/>
|
||||
|
||||
<LinearLayout style="@style/setting_row_form">
|
||||
|
||||
<Switch
|
||||
android:id="@+id/swShowAppName"
|
||||
style="@style/setting_horizontal_stretch"
|
||||
android:gravity="center"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<View style="@style/setting_divider"/>
|
||||
|
||||
|
||||
<TextView
|
||||
style="@style/setting_row_label"
|
||||
|
@ -599,6 +599,7 @@
|
||||
<string name="keyword">Keyword</string>
|
||||
<string name="domain_block_from_pseudo">Can\'t use domain block from pseudo account.</string>
|
||||
<string name="domain_block_from_local">Can\'t use domain block for local instance.</string>
|
||||
<string name="always_show_application">Show (via) application name if possible</string>
|
||||
|
||||
<!--<string name="abc_action_bar_home_description">Revenir à l\'accueil</string>-->
|
||||
<!--<string name="abc_action_bar_home_description_format">%1$s, %2$s</string>-->
|
||||
|
@ -883,5 +883,6 @@
|
||||
<string name="keyword">キーワード</string>
|
||||
<string name="domain_block_from_pseudo">疑似アカウントではドメインブロックできません</string>
|
||||
<string name="domain_block_from_local">自分のタンスにはドメインブロックできません</string>
|
||||
<string name="always_show_application">アプリ名(via)を可能なら表示する</string>
|
||||
|
||||
</resources>
|
||||
|
@ -588,5 +588,6 @@
|
||||
<string name="keyword">Keyword</string>
|
||||
<string name="domain_block_from_pseudo">Can\'t use domain block from pseudo account.</string>
|
||||
<string name="domain_block_from_local">Can\'t use domain block for local instance.</string>
|
||||
<string name="always_show_application">Show (via) application name if possible</string>
|
||||
|
||||
</resources>
|
||||
|
Loading…
x
Reference in New Issue
Block a user