mirror of
https://github.com/TwidereProject/Twidere-Android
synced 2025-02-17 04:00:48 +01:00
changes to tab now applies correctly
This commit is contained in:
parent
173fe2d462
commit
e8baaee3ea
@ -198,9 +198,10 @@ public interface IntentConstants {
|
||||
String EXTRA_HIDE_QUOTES = "hide_quotes";
|
||||
String EXTRA_HIDE_REPLIES = "hide_replies";
|
||||
String EXTRA_MENTIONS_ONLY = "mentions_only";
|
||||
String EXTRA_CHANGED = "changed";
|
||||
String EXTRA_NOTIFY_CHANGE = "notify_change";
|
||||
String EXTRA_RESTART_ACTIVITY = "restart_activity";
|
||||
String EXTRA_RECREATE_ACTIVITY = "recreate_activity";
|
||||
String EXTRA_SHOULD_RECREATE = "should_recreate";
|
||||
String EXTRA_SHOULD_RESTART = "should_restart";
|
||||
String EXTRA_FROM_USER = "from_user";
|
||||
String EXTRA_SHOW_MEDIA_PREVIEW = "show_media_preview";
|
||||
String EXTRA_SHOW_EXTRA_TYPE = "show_extra_type";
|
||||
|
@ -55,7 +55,8 @@ class SettingsActivity : BaseActivity(), OnItemClickListener, OnPreferenceStartF
|
||||
private var mEntriesListView: ListView? = null
|
||||
private var mSlidingPaneLayout: SlidingPaneLayout? = null
|
||||
|
||||
var shouldNotifyChange: Boolean = false
|
||||
var shouldRecreate: Boolean = false
|
||||
var shouldRestart: Boolean = false
|
||||
private var mEntriesAdapter: EntriesAdapter? = null
|
||||
private var mDetailFragmentContainer: View? = null
|
||||
|
||||
@ -150,8 +151,9 @@ class SettingsActivity : BaseActivity(), OnItemClickListener, OnPreferenceStartF
|
||||
}
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
if (resultCode == RESULT_SETTINGS_CHANGED && data != null && data.getBooleanExtra(EXTRA_CHANGED, false)) {
|
||||
shouldNotifyChange = true
|
||||
if (resultCode == RESULT_SETTINGS_CHANGED && data != null) {
|
||||
shouldRecreate = data.getBooleanExtra(EXTRA_SHOULD_RECREATE, false)
|
||||
shouldRestart = data.getBooleanExtra(EXTRA_SHOULD_RESTART, false)
|
||||
}
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
}
|
||||
@ -162,9 +164,10 @@ class SettingsActivity : BaseActivity(), OnItemClickListener, OnPreferenceStartF
|
||||
|
||||
|
||||
override fun finish() {
|
||||
if (shouldNotifyChange) {
|
||||
if (shouldRecreate || shouldRestart) {
|
||||
val data = Intent()
|
||||
data.putExtra(EXTRA_CHANGED, true)
|
||||
data.putExtra(EXTRA_SHOULD_RECREATE, shouldRecreate)
|
||||
data.putExtra(EXTRA_SHOULD_RESTART, shouldRestart)
|
||||
setResult(RESULT_SETTINGS_CHANGED, data)
|
||||
}
|
||||
super.finish()
|
||||
@ -241,8 +244,12 @@ class SettingsActivity : BaseActivity(), OnItemClickListener, OnPreferenceStartF
|
||||
}
|
||||
|
||||
private fun notifyUnsavedChange(): Boolean {
|
||||
if (isTopSettings && shouldNotifyChange) {
|
||||
if (isTopSettings && (shouldRecreate || shouldRestart)) {
|
||||
val df = RestartConfirmDialogFragment()
|
||||
val args = Bundle()
|
||||
args.putBoolean(EXTRA_SHOULD_RECREATE, shouldRecreate)
|
||||
args.putBoolean(EXTRA_SHOULD_RESTART, shouldRestart)
|
||||
df.arguments = args
|
||||
df.show(supportFragmentManager, "restart_confirm")
|
||||
return true
|
||||
}
|
||||
@ -391,9 +398,14 @@ class SettingsActivity : BaseActivity(), OnItemClickListener, OnPreferenceStartF
|
||||
|
||||
private val RESULT_SETTINGS_CHANGED = 10
|
||||
|
||||
fun setShouldNotifyChange(activity: Activity) {
|
||||
fun setShouldRecreate(activity: Activity) {
|
||||
if (activity !is SettingsActivity) return
|
||||
activity.shouldNotifyChange = true
|
||||
activity.shouldRecreate = true
|
||||
}
|
||||
|
||||
fun setShouldRestart(activity: Activity) {
|
||||
if (activity !is SettingsActivity) return
|
||||
activity.shouldRestart = true
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -60,6 +60,7 @@ import org.mariotaku.twidere.TwidereConstants.*
|
||||
import org.mariotaku.twidere.activity.*
|
||||
import org.mariotaku.twidere.annotation.CustomTabType
|
||||
import org.mariotaku.twidere.annotation.Referral
|
||||
import org.mariotaku.twidere.constant.IntentConstants
|
||||
import org.mariotaku.twidere.constant.KeyboardShortcutConstants.*
|
||||
import org.mariotaku.twidere.fragment.AccountsDashboardFragment.AccountsInfo
|
||||
import org.mariotaku.twidere.menu.AccountToggleProvider
|
||||
@ -160,8 +161,9 @@ class AccountsDashboardFragment : BaseSupportFragment(), LoaderCallbacks<Account
|
||||
when (requestCode) {
|
||||
REQUEST_SETTINGS -> {
|
||||
if (data == null) return
|
||||
val activity = activity
|
||||
if (data.getBooleanExtra(EXTRA_CHANGED, false)) {
|
||||
if (data.getBooleanExtra(EXTRA_SHOULD_RESTART, false)) {
|
||||
Utils.restartActivity(activity)
|
||||
} else if (data.getBooleanExtra(EXTRA_SHOULD_RECREATE, false)) {
|
||||
activity.recreate()
|
||||
}
|
||||
return
|
||||
|
@ -68,7 +68,7 @@ class CustomTabsFragment : BaseSupportFragment(), LoaderCallbacks<Cursor?>, Mult
|
||||
val itemIds = listView.checkedItemIds
|
||||
val where = Expression.`in`(Column(Tabs._ID), RawItemArray(itemIds))
|
||||
contentResolver.delete(Tabs.CONTENT_URI, where.sql, null)
|
||||
SettingsActivity.setShouldNotifyChange(activity)
|
||||
SettingsActivity.setShouldRestart(activity)
|
||||
}
|
||||
}
|
||||
mode.finish()
|
||||
@ -127,7 +127,7 @@ class CustomTabsFragment : BaseSupportFragment(), LoaderCallbacks<Cursor?>, Mult
|
||||
values.put(Tabs.EXTRAS, data.getStringExtra(EXTRA_EXTRAS))
|
||||
values.put(Tabs.POSITION, adapter!!.count)
|
||||
contentResolver.insert(Tabs.CONTENT_URI, values)
|
||||
SettingsActivity.setShouldNotifyChange(activity)
|
||||
SettingsActivity.setShouldRestart(activity)
|
||||
}
|
||||
}
|
||||
REQUEST_EDIT_TAB -> {
|
||||
@ -138,7 +138,7 @@ class CustomTabsFragment : BaseSupportFragment(), LoaderCallbacks<Cursor?>, Mult
|
||||
values.put(Tabs.EXTRAS, data.getStringExtra(EXTRA_EXTRAS))
|
||||
val where = Expression.equals(Tabs._ID, data.getLongExtra(EXTRA_ID, -1)).sql
|
||||
contentResolver.update(Tabs.CONTENT_URI, values, where, null)
|
||||
SettingsActivity.setShouldNotifyChange(activity)
|
||||
SettingsActivity.setShouldRestart(activity)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -251,7 +251,7 @@ class CustomTabsFragment : BaseSupportFragment(), LoaderCallbacks<Cursor?>, Mult
|
||||
i++
|
||||
}
|
||||
}
|
||||
SettingsActivity.setShouldNotifyChange(activity)
|
||||
SettingsActivity.setShouldRestart(activity)
|
||||
}
|
||||
|
||||
private fun updateTitle(mode: ActionMode?) {
|
||||
|
@ -76,10 +76,12 @@ class SettingsDetailsFragment : BasePreferenceFragment(), OnSharedPreferenceChan
|
||||
val extras = preference.extras
|
||||
if (extras != null) {
|
||||
val activity = activity
|
||||
if (extras.containsKey(EXTRA_NOTIFY_CHANGE)) {
|
||||
SettingsActivity.setShouldNotifyChange(activity)
|
||||
if (extras.containsKey(EXTRA_SHOULD_RESTART)) {
|
||||
SettingsActivity.setShouldRestart(activity)
|
||||
} else if (extras.containsKey(EXTRA_SHOULD_RECREATE)) {
|
||||
SettingsActivity.setShouldRecreate(activity)
|
||||
}
|
||||
if (extras.containsKey(EXTRA_RESTART_ACTIVITY)) {
|
||||
if (extras.containsKey(EXTRA_RECREATE_ACTIVITY)) {
|
||||
activity.recreate()
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,7 @@
|
||||
app:min="12"
|
||||
app:progressTextSuffix="sp">
|
||||
<extra
|
||||
android:name="notify_change"
|
||||
android:name="should_recreate"
|
||||
android:value="true"/>
|
||||
</org.mariotaku.twidere.preference.SeekBarDialogPreference>
|
||||
|
||||
@ -33,7 +33,7 @@
|
||||
android:order="23"
|
||||
android:title="@string/profile_image">
|
||||
<extra
|
||||
android:name="notify_change"
|
||||
android:name="should_recreate"
|
||||
android:value="true"/>
|
||||
</SwitchPreferenceCompat>
|
||||
|
||||
@ -45,7 +45,7 @@
|
||||
android:order="24"
|
||||
android:title="@string/profile_image_style">
|
||||
<extra
|
||||
android:name="notify_change"
|
||||
android:name="should_recreate"
|
||||
android:value="true"/>
|
||||
</org.mariotaku.twidere.preference.EntrySummaryListPreference>
|
||||
|
||||
@ -55,7 +55,7 @@
|
||||
android:order="25"
|
||||
android:title="@string/media_preview">
|
||||
<extra
|
||||
android:name="notify_change"
|
||||
android:name="should_recreate"
|
||||
android:value="true"/>
|
||||
</SwitchPreferenceCompat>
|
||||
|
||||
@ -65,7 +65,7 @@
|
||||
android:order="27"
|
||||
android:title="@string/link_highlight_option">
|
||||
<extra
|
||||
android:name="notify_change"
|
||||
android:name="should_recreate"
|
||||
android:value="true"/>
|
||||
</org.mariotaku.twidere.preference.LinkHighlightPreference>
|
||||
|
||||
@ -75,7 +75,7 @@
|
||||
android:order="33"
|
||||
android:title="@string/hide_card_actions">
|
||||
<extra
|
||||
android:name="notify_change"
|
||||
android:name="should_recreate"
|
||||
android:value="true"/>
|
||||
</SwitchPreferenceCompat>
|
||||
|
||||
@ -86,7 +86,7 @@
|
||||
android:summary="@string/i_want_my_stars_back_summary"
|
||||
android:title="@string/i_want_my_stars_back">
|
||||
<extra
|
||||
android:name="notify_change"
|
||||
android:name="should_recreate"
|
||||
android:value="true"/>
|
||||
</SwitchPreferenceCompat>
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
android:summaryOn="@string/name_first_summary_on"
|
||||
android:title="@string/name_first">
|
||||
<extra
|
||||
android:name="notify_change"
|
||||
android:name="should_recreate"
|
||||
android:value="true"/>
|
||||
</SwitchPreferenceCompat>
|
||||
|
||||
|
@ -29,7 +29,7 @@
|
||||
android:key="drawer_toggle"
|
||||
android:title="@string/drawer_toggle">
|
||||
<extra
|
||||
android:name="notify_change"
|
||||
android:name="should_recreate"
|
||||
android:value="true"/>
|
||||
</SwitchPreferenceCompat>
|
||||
|
||||
|
@ -28,7 +28,7 @@
|
||||
android:key="media_preview_style"
|
||||
android:title="@string/media_preview_style">
|
||||
<extra
|
||||
android:name="notify_change"
|
||||
android:name="should_recreate"
|
||||
android:value="true"/>
|
||||
</org.mariotaku.twidere.preference.EntrySummaryListPreference>
|
||||
<SwitchPreferenceCompat
|
||||
@ -37,7 +37,7 @@
|
||||
android:summary="@string/show_absolute_time_summary"
|
||||
android:title="@string/show_absolute_time">
|
||||
<extra
|
||||
android:name="notify_change"
|
||||
android:name="should_recreate"
|
||||
android:value="true"/>
|
||||
</SwitchPreferenceCompat>
|
||||
<SwitchPreferenceCompat
|
||||
@ -45,7 +45,7 @@
|
||||
android:key="unread_count"
|
||||
android:title="@string/unread_count">
|
||||
<extra
|
||||
android:name="notify_change"
|
||||
android:name="should_recreate"
|
||||
android:value="true"/>
|
||||
</SwitchPreferenceCompat>
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
android:order="21"
|
||||
android:title="@string/theme">
|
||||
<extra
|
||||
android:name="restart_activity"
|
||||
android:name="recreate_activity"
|
||||
android:value="true"/>
|
||||
</org.mariotaku.twidere.preference.EntrySummaryListPreference>
|
||||
|
||||
@ -22,10 +22,10 @@
|
||||
android:order="22"
|
||||
android:title="@string/background">
|
||||
<extra
|
||||
android:name="notify_change"
|
||||
android:name="should_recreate"
|
||||
android:value="true"/>
|
||||
<extra
|
||||
android:name="restart_activity"
|
||||
android:name="recreate_activity"
|
||||
android:value="true"/>
|
||||
</org.mariotaku.twidere.preference.ThemeBackgroundPreference>
|
||||
|
||||
@ -35,10 +35,10 @@
|
||||
android:title="@string/color"
|
||||
app:defaultColor="@color/branding_color">
|
||||
<extra
|
||||
android:name="notify_change"
|
||||
android:name="should_recreate"
|
||||
android:value="true"/>
|
||||
<extra
|
||||
android:name="restart_activity"
|
||||
android:name="recreate_activity"
|
||||
android:value="true"/>
|
||||
</org.mariotaku.twidere.preference.ColorPickerPreference>
|
||||
|
||||
@ -49,10 +49,10 @@
|
||||
android:order="24"
|
||||
android:title="@string/font_family">
|
||||
<extra
|
||||
android:name="notify_change"
|
||||
android:name="should_recreate"
|
||||
android:value="true"/>
|
||||
<extra
|
||||
android:name="restart_activity"
|
||||
android:name="recreate_activity"
|
||||
android:value="true"/>
|
||||
</org.mariotaku.twidere.preference.ThemeFontFamilyPreference>
|
||||
|
||||
@ -61,7 +61,7 @@
|
||||
android:order="25"
|
||||
android:title="@string/emoji_support">
|
||||
<extra
|
||||
android:name="notify_change"
|
||||
android:name="should_recreate"
|
||||
android:value="true"/>
|
||||
</org.mariotaku.twidere.preference.EmojiSupportPreference>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user