😴 Minor code style improvements

This commit is contained in:
Christian Basler 2018-04-20 17:49:37 +02:00
parent e05d27bfbc
commit b1fd9d9ef9
4 changed files with 35 additions and 33 deletions

View File

@ -98,7 +98,8 @@ class ComposeMessageActivity : AppCompatActivity() {
val prefix: String = if (subject.length >= 3 && subject.substring(0, 3).equals( val prefix: String = if (subject.length >= 3 && subject.substring(0, 3).equals(
"RE:", "RE:",
ignoreCase = true ignoreCase = true
)) { )
) {
"" ""
} else { } else {
"RE: " "RE: "
@ -107,7 +108,7 @@ class ComposeMessageActivity : AppCompatActivity() {
} }
replyIntent.putExtra( replyIntent.putExtra(
EXTRA_CONTENT, EXTRA_CONTENT,
"\n\n------------------------------------------------------\n" + item.text!! "\n\n------------------------------------------------------\n${item.text ?: ""}"
) )
return replyIntent return replyIntent
} }

View File

@ -79,7 +79,8 @@ class MessageListFragment : Fragment(), ListHolder<Label> {
if (!isLoading && !isLastPage) { if (!isLoading && !isLastPage) {
if (visibleItemCount + firstVisibleItemPosition >= totalItemCount - 5 if (visibleItemCount + firstVisibleItemPosition >= totalItemCount - 5
&& firstVisibleItemPosition >= 0) { && firstVisibleItemPosition >= 0
) {
loadMoreItems() loadMoreItems()
} }
} }

View File

@ -20,7 +20,6 @@ import android.app.Activity
import android.content.* import android.content.*
import android.os.Bundle import android.os.Bundle
import android.os.IBinder import android.os.IBinder
import android.preference.PreferenceManager
import android.support.v4.app.Fragment import android.support.v4.app.Fragment
import android.support.v4.content.ContextCompat import android.support.v4.content.ContextCompat
import android.support.v4.content.FileProvider.getUriForFile import android.support.v4.content.FileProvider.getUriForFile
@ -173,11 +172,12 @@ class SettingsFragment : PreferenceFragmentCompat(), SharedPreferences.OnSharedP
override fun onAttach(ctx: Context?) { override fun onAttach(ctx: Context?) {
super.onAttach(ctx) super.onAttach(ctx)
(ctx as? MainActivity)?.floatingActionButton?.hide() ctx?.let {
PreferenceManager.getDefaultSharedPreferences(ctx) if (it is MainActivity) {
.registerOnSharedPreferenceChangeListener(this) it.floatingActionButton?.hide()
it.updateTitle(getString(R.string.settings))
(ctx as? MainActivity)?.updateTitle(getString(R.string.settings)) }
}
} }
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) { override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) {

View File

@ -1,105 +1,105 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<android.support.v7.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<android.support.v7.preference.PreferenceScreen <PreferenceScreen
android:key="preference_ux" android:key="preference_ux"
android:title="@string/preference_group_user_experience" android:title="@string/preference_group_user_experience"
android:summary="@string/preference_group_user_experience_summary" android:summary="@string/preference_group_user_experience_summary"
android:persistent="false"> android:persistent="false">
<android.support.v7.preference.SwitchPreferenceCompat <SwitchPreferenceCompat
android:defaultValue="true" android:defaultValue="true"
android:key="emulate_conversations" android:key="emulate_conversations"
android:summary="@string/emulate_conversations_summary" android:summary="@string/emulate_conversations_summary"
android:title="@string/emulate_conversations" /> android:title="@string/emulate_conversations" />
<android.support.v7.preference.Preference <Preference
android:defaultValue="true" android:defaultValue="true"
android:key="emulate_conversations_initialize" android:key="emulate_conversations_initialize"
android:summary="@string/emulate_conversations_summary" android:summary="@string/emulate_conversations_summary"
android:title="@string/emulate_conversations_initialize" /> android:title="@string/emulate_conversations_initialize" />
</android.support.v7.preference.PreferenceScreen> </PreferenceScreen>
<android.support.v7.preference.PreferenceScreen <PreferenceScreen
android:key="preference_network_and_performance" android:key="preference_network_and_performance"
android:title="@string/preference_group_network_and_performance" android:title="@string/preference_group_network_and_performance"
android:summary="@string/preference_group_network_and_performance_summary" android:summary="@string/preference_group_network_and_performance_summary"
android:persistent="false"> android:persistent="false">
<android.support.v7.preference.SwitchPreferenceCompat <SwitchPreferenceCompat
android:defaultValue="true" android:defaultValue="true"
android:key="wifi_only" android:key="wifi_only"
android:summary="@string/wifi_only_summary" android:summary="@string/wifi_only_summary"
android:title="@string/wifi_only" /> android:title="@string/wifi_only" />
<android.support.v7.preference.SwitchPreferenceCompat <SwitchPreferenceCompat
android:defaultValue="true" android:defaultValue="true"
android:key="request_acknowledgements" android:key="request_acknowledgements"
android:summary="@string/request_acknowledgements_summary" android:summary="@string/request_acknowledgements_summary"
android:title="@string/request_acknowledgements" /> android:title="@string/request_acknowledgements" />
</android.support.v7.preference.PreferenceScreen> </PreferenceScreen>
<android.support.v7.preference.PreferenceScreen <PreferenceScreen
android:key="preference_advanced" android:key="preference_advanced"
android:title="@string/preference_group_advanced" android:title="@string/preference_group_advanced"
android:summary="@string/preference_group_advanced_summary" android:summary="@string/preference_group_advanced_summary"
android:persistent="false"> android:persistent="false">
<android.support.v7.preference.Preference <Preference
android:key="cleanup" android:key="cleanup"
android:summary="@string/cleanup_summary" android:summary="@string/cleanup_summary"
android:title="@string/cleanup" /> android:title="@string/cleanup" />
<android.support.v7.preference.Preference <Preference
android:key="export" android:key="export"
android:summary="@string/export_data_summary" android:summary="@string/export_data_summary"
android:title="@string/export_data" /> android:title="@string/export_data" />
<android.support.v7.preference.Preference <Preference
android:key="import" android:key="import"
android:summary="@string/import_data_summary" android:summary="@string/import_data_summary"
android:title="@string/import_data" /> android:title="@string/import_data" />
<android.support.v7.preference.PreferenceScreen <PreferenceScreen
android:key="preference_experimental" android:key="preference_experimental"
android:title="@string/preference_group_experimental" android:title="@string/preference_group_experimental"
android:summary="@string/preference_group_experimental_summary" android:summary="@string/preference_group_experimental_summary"
android:persistent="false"> android:persistent="false">
<android.support.v7.preference.EditTextPreference <EditTextPreference
android:inputType="textUri" android:inputType="textUri"
android:key="trusted_node" android:key="trusted_node"
android:summary="@string/trusted_node_summary" android:summary="@string/trusted_node_summary"
android:title="@string/trusted_node" /> android:title="@string/trusted_node" />
<android.support.v7.preference.EditTextPreference <EditTextPreference
android:defaultValue="120" android:defaultValue="120"
android:inputType="number" android:inputType="number"
android:key="sync_timeout" android:key="sync_timeout"
android:summary="@string/sync_timeout_summary" android:summary="@string/sync_timeout_summary"
android:title="@string/sync_timeout" /> android:title="@string/sync_timeout" />
<android.support.v7.preference.SwitchPreferenceCompat <SwitchPreferenceCompat
android:defaultValue="false" android:defaultValue="false"
android:dependency="trusted_node" android:dependency="trusted_node"
android:key="server_pow" android:key="server_pow"
android:summary="@string/server_pow_summary" android:summary="@string/server_pow_summary"
android:title="@string/server_pow" /> android:title="@string/server_pow" />
<android.support.v7.preference.Preference <Preference
android:key="status" android:key="status"
android:summary="@string/status_summary" android:summary="@string/status_summary"
android:title="@string/status" /> android:title="@string/status" />
</android.support.v7.preference.PreferenceScreen> </PreferenceScreen>
</android.support.v7.preference.PreferenceScreen> </PreferenceScreen>
<android.support.v7.preference.Preference <Preference
android:key="about" android:key="about"
android:summary="@string/about_summary" android:summary="@string/about_summary"
android:title="@string/about" /> android:title="@string/about" />
<android.support.v7.preference.Preference <Preference
android:key="help_out" android:key="help_out"
android:summary="@string/help_out_summary" android:summary="@string/help_out_summary"
android:title="@string/help_out"> android:title="@string/help_out">
<intent <intent
android:action="android.intent.action.VIEW" android:action="android.intent.action.VIEW"
android:data="@string/help_out_link" /> android:data="@string/help_out_link" />
</android.support.v7.preference.Preference> </Preference>
</android.support.v7.preference.PreferenceScreen> </PreferenceScreen>