Commit 5cb535fb authored by Grigory Fedorov's avatar Grigory Fedorov

Chat "show background" preference option. #438 Disabling this option should avoid crash #417

parent e98e36ec
......@@ -323,6 +323,10 @@ public class SettingsManager implements OnInitializedListener,
throw new IllegalStateException();
}
public static boolean chatsShowBackground() {
return getBoolean(R.string.chats_show_background_key, R.bool.chats_show_background_default);
}
public static int chatsAppearanceStyle() {
String value = getString(R.string.chats_font_size_key,
R.string.chats_font_size_default);
......
......@@ -27,6 +27,7 @@ import android.widget.LinearLayout;
import com.xabber.android.R;
import com.xabber.android.data.ActivityManager;
import com.xabber.android.data.Application;
import com.xabber.android.data.SettingsManager;
import com.xabber.android.data.account.OnAccountChangedListener;
import com.xabber.android.data.entity.BaseEntity;
import com.xabber.android.data.extension.archive.MessageArchiveManager;
......@@ -167,7 +168,7 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
return;
}
setContentView(R.layout.activity_chat_viewer);
setContentView(R.layout.chat_viewer);
statusBarPainter = new StatusBarPainter(this);
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
......@@ -187,7 +188,11 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
viewPager = (ViewPager) findViewById(R.id.pager);
viewPager.setAdapter(chatViewerAdapter);
viewPager.setOnPageChangeListener(this);
viewPager.getBackground().setAlpha(30);
if (SettingsManager.chatsShowBackground()) {
viewPager.setBackgroundDrawable(getResources().getDrawable(R.drawable.chat_background_repeat));
viewPager.getBackground().setAlpha(30);
}
chatScrollIndicatorAdapter = new ChatScrollIndicatorAdapter(this,
(LinearLayout)findViewById(R.id.chat_scroll_indicator));
......
......@@ -112,7 +112,7 @@ public class ChatViewerFragment extends Fragment implements PopupMenu.OnMenuItem
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
View view = inflater.inflate(R.layout.chat_fragment, container, false);
View view = inflater.inflate(R.layout.chat_viewer_fragment, container, false);
contactTitleView = view.findViewById(R.id.contact_title);
......
......@@ -5,22 +5,19 @@
android:layout_height="match_parent"
>
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/chat_background_repeat"
/>
<LinearLayout
android:id="@+id/chat_scroll_indicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_centerHorizontal="true"
android:layout_marginTop="62dp"
android:id="@+id/chat_scroll_indicator"
android:orientation="horizontal"
>
</LinearLayout>
......
......@@ -22,13 +22,13 @@
android:layout_width="32dip"
android:layout_height="32dip"
android:layout_marginTop="3dp"
android:layout_marginLeft="6dp"
android:layout_alignTop="@+id/message_text"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignTop="@+id/message_text"
android:layout_marginLeft="6dp"
android:layout_marginTop="3dp"
android:src="@drawable/ic_avatar_1"
/>
......@@ -37,29 +37,29 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/avatar"
android:layout_toEndOf="@id/avatar"
android:minWidth="142dp"
android:layout_marginEnd="48dp"
android:layout_marginLeft="6dp"
android:paddingLeft="16dp"
android:paddingRight="10dp"
android:paddingEnd="6dp"
android:layout_marginRight="48dp"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:layout_marginStart="6dp"
android:layout_toEndOf="@id/avatar"
android:layout_toRightOf="@id/avatar"
android:autoLink="all"
android:background="@drawable/message_incoming"
android:layout_marginLeft="6dp"
android:layout_marginStart="6dp"
android:minWidth="142dp"
android:layout_marginRight="48dp"
android:layout_marginEnd="48dp"
android:paddingBottom="8dp"
android:paddingEnd="6dp"
android:paddingLeft="16dp"
android:paddingRight="10dp"
android:background="@drawable/message_incoming">
android:paddingTop="8dp">
<include layout="@layout/chat_message"/>
<include layout="@layout/chat_viewer_message" />
</FrameLayout>
......@@ -68,14 +68,14 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/avatar"
android:layout_toEndOf="@+id/avatar"
android:layout_below="@+id/message_balloon"
android:layout_toEndOf="@+id/avatar"
android:layout_toRightOf="@+id/avatar"
android:paddingLeft="16dp"
android:textSize="10sp"
android:text="Feb 19, 2015 4:39 PM"
android:textSize="10sp"
/>
</RelativeLayout>
......@@ -24,26 +24,26 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginEnd="6dp"
android:layout_marginLeft="48dp"
android:layout_marginStart="48dp"
android:layout_marginRight="6dp"
android:layout_marginEnd="6dp"
android:layout_marginStart="48dp"
android:paddingLeft="12dp"
android:paddingTop="8dp"
android:background="@drawable/message_outgoing_states"
android:paddingBottom="8dp"
android:paddingRight="16dp"
android:paddingEnd="16dp"
android:paddingLeft="12dp"
android:paddingRight="16dp"
android:background="@drawable/message_outgoing_states"
android:paddingTop="8dp"
>
<include layout="@layout/chat_message"/>
<include layout="@layout/chat_viewer_message" />
</FrameLayout>
......@@ -51,16 +51,16 @@
android:id="@+id/message_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/message_balloon"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/message_balloon"
android:paddingRight="16dp"
android:paddingEnd="16dp"
android:textSize="10sp"
android:paddingRight="16dp"
android:text="Feb 19, 2015 4:39 PM"
android:textSize="10sp"
/>
<ImageView
......
......@@ -72,6 +72,9 @@
<string name="chats_divide">Сообщение с новой строки\nОтображать сообщение с новой строки</string>
<!-- http://dl.dropbox.com/u/1029995/com.xabber.android/preference_editor_chat_viewer_new_line.png -->
<string name="chats_divide_portrait">В портретном режиме</string>
<string name="chats_show_background">Отображать фон\nОтключение может увеличить производительность</string>
<!-- http://dl.dropbox.com/u/1029995/com.xabber.android/preference_editor_chat_viewer.png -->
<string name="chats_font_size">Размер шрифта\nРазмер текста сообщения</string>
<!-- http://dl.dropbox.com/u/1029995/com.xabber.android/preference_editor_chat_viewer_font_size.png -->
......
......@@ -72,6 +72,9 @@
<string name="chats_divide">Message on the new line\nDisplay a message on a new line</string>
<!-- http://dl.dropbox.com/u/1029995/com.xabber.android/preference_editor_chat_viewer_new_line.png -->
<string name="chats_divide_portrait">In portrait mode</string>
<string name="chats_show_background">Show background\nDisabling may increase performance</string>
<!-- http://dl.dropbox.com/u/1029995/com.xabber.android/preference_editor_chat_viewer.png -->
<string name="chats_font_size">Font size\nSize of text in the message</string>
<!-- http://dl.dropbox.com/u/1029995/com.xabber.android/preference_editor_chat_viewer_font_size.png -->
......
......@@ -246,6 +246,9 @@
</string-array>
<string name="chats_hide_keyboard_default">@string/chats_hide_keyboard_landscape_value</string>
<string name="chats_show_background_key">chats_show_background</string>
<bool name="chats_show_background_default">true</bool>
<string name="chats_font_size_key">chats_font_size</string>
<string name="chats_font_size_small_value">small</string>
<string name="chats_font_size_normal_value">normal</string>
......
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<CheckBoxPreference
android:title="@string/chats_show_avatars"
android:key="@string/chats_show_avatars_key"
android:defaultValue="@bool/chats_show_avatars_default"
android:key="@string/chats_show_avatars_key"
android:title="@string/chats_show_avatars"
/>
<CheckBoxPreference
android:title="@string/chats_send_by_enter"
android:key="@string/chats_send_by_enter_key"
android:defaultValue="@bool/chats_send_by_enter_default"
android:key="@string/chats_send_by_enter_key"
android:title="@string/chats_send_by_enter"
/>
<ListPreference
android:title="@string/chats_show_status_change"
android:summary="@string/chats_show_status_change"
android:key="@string/chats_show_status_change_key"
android:defaultValue="@string/chats_show_status_change_default"
android:entries="@array/chats_show_status_change_entries"
android:entryValues="@array/chats_show_status_change_entryvalues"
android:defaultValue="@string/chats_show_status_change_default"
android:key="@string/chats_show_status_change_key"
android:summary="@string/chats_show_status_change"
android:title="@string/chats_show_status_change"
/>
<ListPreference
android:title="@string/chats_hide_keyboard"
android:key="@string/chats_hide_keyboard_key"
android:defaultValue="@string/chats_hide_keyboard_default"
android:entries="@array/chats_hide_keyboard_entries"
android:entryValues="@array/chats_hide_keyboard_entryvalues"
android:defaultValue="@string/chats_hide_keyboard_default"
android:key="@string/chats_hide_keyboard_key"
android:title="@string/chats_hide_keyboard"
/>
<CheckBoxPreference
android:defaultValue="@bool/chats_show_background_default"
android:key="@string/chats_show_background_key"
android:title="@string/chats_show_background"
/>
<ListPreference
android:title="@string/chats_font_size"
android:key="@string/chats_font_size_key"
android:defaultValue="@string/chats_font_size_default"
android:entries="@array/chats_font_size_entries"
android:entryValues="@array/chats_font_size_entryvalues"
android:defaultValue="@string/chats_font_size_default"
android:key="@string/chats_font_size_key"
android:title="@string/chats_font_size"
/>
<ListPreference
android:title="@string/chats_divide"
android:key="@string/chats_divide_key"
android:defaultValue="@string/chats_divide_default"
android:entries="@array/chats_divide_entries"
android:entryValues="@array/chats_divide_entryvalues"
android:defaultValue="@string/chats_divide_default"
android:key="@string/chats_divide_key"
android:title="@string/chats_divide"
/>
<CheckBoxPreference
android:title="@string/chats_state_notification"
android:key="@string/chats_state_notification_key"
android:defaultValue="@bool/chats_state_notification_default"
android:key="@string/chats_state_notification_key"
android:title="@string/chats_state_notification"
/>
<CheckBoxPreference
android:title="@string/chats_attention"
android:key="@string/chats_attention_key"
android:defaultValue="@bool/chats_attention_default"
android:key="@string/chats_attention_key"
android:title="@string/chats_attention"
/>
<RingtonePreference
android:title="@string/chats_attention_sound"
android:key="@string/chats_attention_sound_key"
android:defaultValue="@string/chats_attention_sound_default"
android:ringtoneType="ringtone"
android:dependency="@string/chats_attention_key"
android:showSilent="true"
android:key="@string/chats_attention_sound_key"
android:ringtoneType="ringtone"
android:showDefault="true"
android:showSilent="true"
android:title="@string/chats_attention_sound"
/>
</PreferenceScreen>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment