Fix up preference screen a little

1) Remove phantom padding on left margin for all fragments

2) Move preferences around slightly

3) Add some card separators and style led list pref

// FREEBIE
This commit is contained in:
Moxie Marlinspike 2017-04-14 20:39:38 -07:00
parent 4fd41080ac
commit 13d785894a
16 changed files with 309 additions and 163 deletions

View file

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape>
<padding android:top="1dp" android:right="0dp" android:bottom="0dp" android:left="0dp" />
<solid android:color="#d4d4d4" />
</shape>
</item>
<item>
<shape>
<padding android:top="1dp" android:right="0dp" android:bottom="0dp" android:left="0dp" />
<solid android:color="#dddddd" />
<size android:height="20dp"/>
</shape>
</item>
</layer-list>

View file

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="3dp">
<ImageView
android:id="@+id/color_view"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_gravity="center"
android:scaleType="fitXY" />
</FrameLayout>

View file

@ -0,0 +1,14 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_margin="0dp"
android:background="@color/amber_50"
android:padding="0dp">
<View
android:layout_width="match_parent"
android:layout_height="10dp"
android:background="@drawable/preference_divider"/>
</LinearLayout>

View file

@ -1187,6 +1187,11 @@
<string name="preferences_advanced__enable_support_for_next_generation_video_and_voice_calls">Support for next-generation video and voice calls when enabled by both parties. This feature is in beta.</string>
<string name="preferences_advanced__relay_all_calls_through_the_signal_server_to_avoid_revealing_your_ip_address">Relay all calls through the Signal server to avoid revealing your IP address to your contact. Enabling will reduce call quality.</string>
<string name="preferences_advanced__always_relay_calls">Always relay calls</string>
<string name="preferences_app_protection__app_access">App access</string>
<string name="preferences_app_protection__communication">Communication</string>
<string name="preferences_chats__chats">Chats</string>
<string name="preferences_notifications__message_notifications">Message notifications</string>
<string name="preferences_notifications__events">Events</string>

View file

@ -7,24 +7,6 @@
android:title="@string/preferences__signal_messages_and_calls"
android:summary="@string/preferences__free_private_messages_and_calls"/>
<org.thoughtcrime.securesms.components.SwitchPreferenceCompat
android:defaultValue="false"
android:key="pref_enter_sends"
android:summary="@string/preferences__pressing_the_enter_key_will_send_text_messages"
android:title="@string/preferences__pref_enter_sends_title"/>
<org.thoughtcrime.securesms.components.SwitchPreferenceCompat
android:defaultValue="false"
android:key="pref_system_emoji"
android:title="@string/preferences_advanced__use_system_emoji"
android:summary="@string/preferences_advanced__disable_signal_built_in_emoji_support" />
<org.thoughtcrime.securesms.components.SwitchPreferenceCompat
android:defaultValue="false"
android:key="pref_turn_only"
android:title="@string/preferences_advanced__always_relay_calls"
android:summary="@string/preferences_advanced__relay_all_calls_through_the_signal_server_to_avoid_revealing_your_ip_address"/>
<Preference android:key="pref_choose_identity"
android:title="@string/preferences__choose_identity"
android:summary="@string/preferences__choose_your_contact_entry_from_the_contacts_list"/>

View file

@ -1,39 +1,52 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<org.thoughtcrime.securesms.components.SwitchPreferenceCompat
android:key="pref_enable_passphrase_temporary"
android:defaultValue="true"
android:title="@string/preferences__enable_passphrase"
android:summary="@string/preferences__lock_signal_and_message_notifications_with_a_passphrase"/>
<PreferenceCategory android:title="@string/preferences_app_protection__app_access">
<org.thoughtcrime.securesms.components.SwitchPreferenceCompat
android:key="pref_enable_passphrase_temporary"
android:defaultValue="true"
android:title="@string/preferences__enable_passphrase"
android:summary="@string/preferences__lock_signal_and_message_notifications_with_a_passphrase"/>
<Preference android:key="pref_change_passphrase"
android:title="@string/preferences__change_passphrase"
android:summary="@string/preferences__change_your_passphrase"
android:dependency="pref_enable_passphrase_temporary"/>
<Preference android:key="pref_change_passphrase"
android:title="@string/preferences__change_passphrase"
android:summary="@string/preferences__change_your_passphrase"
android:dependency="pref_enable_passphrase_temporary"/>
<CheckBoxPreference android:defaultValue="false"
android:key="pref_timeout_passphrase"
android:title="@string/preferences__inactivity_timeout_passphrase"
android:summary="@string/preferences__auto_lock_signal_after_a_specified_time_interval_of_inactivity"
android:dependency="pref_enable_passphrase_temporary"/>
<CheckBoxPreference android:defaultValue="false"
android:key="pref_timeout_passphrase"
android:title="@string/preferences__inactivity_timeout_passphrase"
android:summary="@string/preferences__auto_lock_signal_after_a_specified_time_interval_of_inactivity"
android:dependency="pref_enable_passphrase_temporary"/>
<Preference android:title="@string/preferences__inactivity_timeout_interval"
android:key="pref_timeout_interval"
android:dependency="pref_timeout_passphrase"/>
<Preference android:title="@string/preferences__inactivity_timeout_interval"
android:key="pref_timeout_interval"
android:dependency="pref_timeout_passphrase"/>
<org.thoughtcrime.securesms.components.SwitchPreferenceCompat
android:defaultValue="true"
android:key="pref_screen_security"
android:title="@string/preferences__screen_security"
android:summary="@string/preferences__disable_screen_security_to_allow_screen_shots" />
<org.thoughtcrime.securesms.components.SwitchPreferenceCompat
android:defaultValue="true"
android:key="pref_screen_security"
android:title="@string/preferences__screen_security"
android:summary="@string/preferences__disable_screen_security_to_allow_screen_shots" />
</PreferenceCategory>
<PreferenceCategory android:layout="@layout/preference_divider"/>
<PreferenceCategory android:title="@string/preferences_app_protection__communication">
<org.thoughtcrime.securesms.components.SwitchPreferenceCompat
android:defaultValue="true"
android:key="pref_blocking_identity_changes"
android:title="@string/preferences_app_protection__safety_numbers_approval"
android:summary="@string/preferences_app_protecting__require_approval_of_new_safety_numbers_when_they_change"/>
<org.thoughtcrime.securesms.components.SwitchPreferenceCompat
android:defaultValue="false"
android:key="pref_turn_only"
android:title="@string/preferences_advanced__always_relay_calls"
android:summary="@string/preferences_advanced__relay_all_calls_through_the_signal_server_to_avoid_revealing_your_ip_address"/>
<Preference android:key="preference_category_blocked"
android:title="@string/preferences_app_protection__blocked_contacts" />
</PreferenceCategory>
<org.thoughtcrime.securesms.components.SwitchPreferenceCompat
android:defaultValue="true"
android:key="pref_blocking_identity_changes"
android:title="@string/preferences_app_protection__safety_numbers_approval"
android:summary="@string/preferences_app_protecting__require_approval_of_new_safety_numbers_when_they_change"/>
<Preference android:key="preference_category_blocked"
android:title="@string/preferences_app_protection__blocked_contacts" />
</PreferenceScreen>

View file

@ -27,6 +27,24 @@
android:entryValues="@array/pref_media_download_entries" />
</PreferenceCategory>
<PreferenceCategory android:layout="@layout/preference_divider"/>
<PreferenceCategory android:title="@string/preferences_chats__chats">
<org.thoughtcrime.securesms.components.SwitchPreferenceCompat
android:defaultValue="false"
android:key="pref_system_emoji"
android:title="@string/preferences_advanced__use_system_emoji"
android:summary="@string/preferences_advanced__disable_signal_built_in_emoji_support" />
<org.thoughtcrime.securesms.components.SwitchPreferenceCompat
android:defaultValue="false"
android:key="pref_enter_sends"
android:summary="@string/preferences__pressing_the_enter_key_will_send_text_messages"
android:title="@string/preferences__pref_enter_sends_title"/>
</PreferenceCategory>
<PreferenceCategory android:layout="@layout/preference_divider"/>
<PreferenceCategory android:key="message_trimming" android:title="@string/preferences_chats__message_trimming">
<org.thoughtcrime.securesms.components.SwitchPreferenceCompat
android:defaultValue="false"

View file

@ -1,65 +1,75 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<org.thoughtcrime.securesms.components.SwitchPreferenceCompat
android:key="pref_key_enable_notifications"
android:title="@string/preferences__notifications"
android:summary="@string/preferences__enable_message_notifications"
android:defaultValue="true" />
<RingtonePreference android:dependency="pref_key_enable_notifications"
android:key="pref_key_ringtone"
android:title="@string/preferences__sound"
android:ringtoneType="notification"
android:defaultValue="content://settings/system/notification_sound" />
<PreferenceCategory android:title="@string/preferences_notifications__message_notifications">
<CheckBoxPreference android:dependency="pref_key_enable_notifications"
android:key="pref_key_vibrate"
android:defaultValue="true"
android:title="@string/preferences__vibrate"
android:summary="@string/preferences__also_vibrate_when_notified" />
<org.thoughtcrime.securesms.components.SwitchPreferenceCompat
android:key="pref_key_enable_notifications"
android:title="@string/preferences__notifications"
android:summary="@string/preferences__enable_message_notifications"
android:defaultValue="true" />
<org.thoughtcrime.securesms.preferences.BooleanListPreference
android:key="pref_led_color"
android:defaultValue="blue"
android:title="@string/preferences__led_color"
android:dependency="pref_key_enable_notifications"
android:entries="@array/pref_led_color_entries"
android:entryValues="@array/pref_led_color_values" />
<RingtonePreference android:dependency="pref_key_enable_notifications"
android:key="pref_key_ringtone"
android:title="@string/preferences__sound"
android:ringtoneType="notification"
android:defaultValue="content://settings/system/notification_sound" />
<org.thoughtcrime.securesms.preferences.LedBlinkPatternListPreference
android:key="pref_led_blink"
android:defaultValue="500,2000"
android:title="@string/preferences__pref_led_blink_title"
android:dependency="pref_led_color"
android:entries="@array/pref_led_blink_pattern_entries"
android:entryValues="@array/pref_led_blink_pattern_values" />
<org.thoughtcrime.securesms.components.SwitchPreferenceCompat
android:dependency="pref_key_enable_notifications"
android:key="pref_key_vibrate"
android:defaultValue="true"
android:title="@string/preferences__vibrate"
android:summary="@string/preferences__also_vibrate_when_notified" />
<CheckBoxPreference android:key="pref_key_inthread_notifications"
android:title="@string/preferences__in_conversation_notifications"
android:summary="@string/preferences__play_inthread_notifications"
android:dependency="pref_key_enable_notifications"
android:defaultValue="true" />
<ListPreference
android:key="pref_repeat_alerts"
android:defaultValue="0"
android:title="@string/preferences__repeat_alerts"
<org.thoughtcrime.securesms.preferences.LEDColorListPreference
android:key="pref_led_color"
android:defaultValue="blue"
android:title="@string/preferences__led_color"
android:dependency="pref_key_enable_notifications"
android:entries="@array/pref_repeat_alerts_entries"
android:entryValues="@array/pref_repeat_alerts_values" />
android:entries="@array/pref_led_color_entries"
android:entryValues="@array/pref_led_color_values" />
<ListPreference android:key="pref_notification_privacy"
android:title="@string/preferences_notifications__display_in_notifications"
android:dependency="pref_key_enable_notifications"
android:defaultValue="all"
android:entries="@array/pref_notification_privacy_entries"
android:entryValues="@array/pref_notification_privacy_values"/>
<org.thoughtcrime.securesms.preferences.LedBlinkPatternListPreference
android:key="pref_led_blink"
android:defaultValue="500,2000"
android:title="@string/preferences__pref_led_blink_title"
android:dependency="pref_led_color"
android:entries="@array/pref_led_blink_pattern_entries"
android:entryValues="@array/pref_led_blink_pattern_values" />
<org.thoughtcrime.securesms.components.SwitchPreferenceCompat
android:key="pref_enable_new_contacts_notifications"
android:title="@string/preferences__new_contacts_notifications"
android:summary="@string/preferences__show_a_notification_for_new_signal_contacts"
android:defaultValue="true" />
<org.thoughtcrime.securesms.components.SwitchPreferenceCompat
android:key="pref_key_inthread_notifications"
android:title="@string/preferences__in_conversation_notifications"
android:summary="@string/preferences__play_inthread_notifications"
android:dependency="pref_key_enable_notifications"
android:defaultValue="true" />
<ListPreference
android:key="pref_repeat_alerts"
android:defaultValue="0"
android:title="@string/preferences__repeat_alerts"
android:dependency="pref_key_enable_notifications"
android:entries="@array/pref_repeat_alerts_entries"
android:entryValues="@array/pref_repeat_alerts_values" />
<ListPreference android:key="pref_notification_privacy"
android:title="@string/preferences_notifications__display_in_notifications"
android:dependency="pref_key_enable_notifications"
android:defaultValue="all"
android:entries="@array/pref_notification_privacy_entries"
android:entryValues="@array/pref_notification_privacy_values"/>
</PreferenceCategory>
<PreferenceCategory android:layout="@layout/preference_divider"/>
<PreferenceCategory android:title="@string/preferences_notifications__events">
<org.thoughtcrime.securesms.components.SwitchPreferenceCompat
android:key="pref_enable_new_contacts_notifications"
android:title="Contact joined Signal"
android:summary="@string/preferences__show_a_notification_for_new_signal_contacts"
android:defaultValue="true" />
</PreferenceCategory>
</PreferenceScreen>

View file

@ -26,11 +26,13 @@ import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.preference.PreferenceFragment;
import android.view.View;
import org.thoughtcrime.securesms.crypto.MasterSecret;
import org.thoughtcrime.securesms.preferences.AdvancedPreferenceFragment;
import org.thoughtcrime.securesms.preferences.AppProtectionPreferenceFragment;
import org.thoughtcrime.securesms.preferences.AppearancePreferenceFragment;
import org.thoughtcrime.securesms.preferences.CorrectedPreferenceFragment;
import org.thoughtcrime.securesms.preferences.NotificationsPreferenceFragment;
import org.thoughtcrime.securesms.preferences.SmsMmsPreferenceFragment;
import org.thoughtcrime.securesms.preferences.ChatsPreferenceFragment;
@ -121,7 +123,8 @@ public class ApplicationPreferencesActivity extends PassphraseRequiredActionBarA
}
}
public static class ApplicationPreferenceFragment extends PreferenceFragment {
public static class ApplicationPreferenceFragment extends CorrectedPreferenceFragment {
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);

View file

@ -27,7 +27,7 @@ import org.thoughtcrime.securesms.util.TextSecurePreferences;
import java.util.concurrent.TimeUnit;
public class AppProtectionPreferenceFragment extends PreferenceFragment {
public class AppProtectionPreferenceFragment extends CorrectedPreferenceFragment {
private static final String PREFERENCE_CATEGORY_BLOCKED = "preference_category_blocked";

View file

@ -1,58 +0,0 @@
/**
* Copyright (C) 2017 Whisper Systems
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.thoughtcrime.securesms.preferences;
import android.content.Context;
import android.preference.ListPreference;
import android.util.AttributeSet;
import org.thoughtcrime.securesms.R;
/**
* List preference that disables dependents when set to "none", similar to a CheckBoxPreference.
*
* @author Taylor Kline
*/
public class BooleanListPreference extends ListPreference {
public BooleanListPreference(Context context, AttributeSet attrs) {
super(context, attrs);
}
public BooleanListPreference(Context context) {
super(context);
}
@Override
public void setValue(String value) {
CharSequence oldEntry = getEntry();
super.setValue(value);
CharSequence newEntry = getEntry();
if (oldEntry != newEntry) {
notifyDependencyChange(shouldDisableDependents());
}
}
@Override
public boolean shouldDisableDependents() {
CharSequence newEntry = getEntry();
String noneEntry = getContext().getString(R.string.preferences__none);
boolean shouldDisable = newEntry.equals(noneEntry);
return shouldDisable || super.shouldDisableDependents();
}
}

View file

@ -10,6 +10,7 @@ import android.support.v4.preference.PreferenceFragment;
import android.support.v7.app.AlertDialog;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import org.thoughtcrime.securesms.ApplicationPreferencesActivity;
import org.thoughtcrime.securesms.R;
@ -20,7 +21,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Set;
public class ChatsPreferenceFragment extends PreferenceFragment {
public class ChatsPreferenceFragment extends CorrectedPreferenceFragment {
private static final String TAG = ChatsPreferenceFragment.class.getSimpleName();
@Override

View file

@ -0,0 +1,18 @@
package org.thoughtcrime.securesms.preferences;
import android.os.Bundle;
import android.support.v4.preference.PreferenceFragment;
import android.view.View;
public class CorrectedPreferenceFragment extends PreferenceFragment {
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
View lv = getView().findViewById(android.R.id.list);
if (lv != null) lv.setPadding(0, 0, 0, 0);
}
}

View file

@ -0,0 +1,108 @@
/**
* Copyright (C) 2017 Whisper Systems
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.thoughtcrime.securesms.preferences;
import android.content.Context;
import android.graphics.drawable.GradientDrawable;
import android.preference.ListPreference;
import android.support.annotation.NonNull;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import org.thoughtcrime.securesms.R;
/**
* List preference that disables dependents when set to "none", similar to a CheckBoxPreference.
*
* @author Taylor Kline
*/
public class LEDColorListPreference extends ListPreference {
private static final String TAG = LEDColorListPreference.class.getSimpleName();
private ImageView colorImageView;
public LEDColorListPreference(Context context, AttributeSet attrs) {
super(context, attrs);
setWidgetLayoutResource(R.layout.led_color_preference_widget);
}
public LEDColorListPreference(Context context) {
super(context);
setWidgetLayoutResource(R.layout.led_color_preference_widget);
}
@Override
public void setValue(String value) {
CharSequence oldEntry = getEntry();
super.setValue(value);
CharSequence newEntry = getEntry();
if (oldEntry != newEntry) {
notifyDependencyChange(shouldDisableDependents());
}
if (value != null) setPreviewColor(value);
}
@Override
public boolean shouldDisableDependents() {
CharSequence newEntry = getValue();
boolean shouldDisable = newEntry.equals("none");
return shouldDisable || super.shouldDisableDependents();
}
@Override
protected void onBindView(View view) {
super.onBindView(view);
this.colorImageView = (ImageView)view.findViewById(R.id.color_view);
setPreviewColor(getValue());
}
@Override
public void setSummary(CharSequence summary) {
super.setSummary(null);
}
private void setPreviewColor(@NonNull String value) {
int color;
switch (value) {
case "green": color = getContext().getResources().getColor(R.color.green_500); break;
case "red": color = getContext().getResources().getColor(R.color.red_500); break;
case "blue": color = getContext().getResources().getColor(R.color.blue_500); break;
case "yellow": color = getContext().getResources().getColor(R.color.yellow_500); break;
case "cyan": color = getContext().getResources().getColor(R.color.cyan_500); break;
case "magenta": color = getContext().getResources().getColor(R.color.pink_500); break;
case "white": color = getContext().getResources().getColor(R.color.white); break;
default: color = getContext().getResources().getColor(R.color.transparent); break;
}
if (colorImageView != null) {
GradientDrawable drawable = new GradientDrawable();
drawable.setShape(GradientDrawable.OVAL);
drawable.setColor(color);
colorImageView.setImageDrawable(drawable);
}
}
}

View file

@ -8,7 +8,7 @@ import org.thoughtcrime.securesms.R;
import java.util.Arrays;
public abstract class ListSummaryPreferenceFragment extends PreferenceFragment {
public abstract class ListSummaryPreferenceFragment extends CorrectedPreferenceFragment {
protected class ListSummaryListener implements Preference.OnPreferenceChangeListener {
@Override

View file

@ -20,7 +20,7 @@ import org.thoughtcrime.securesms.R;
import org.thoughtcrime.securesms.util.TextSecurePreferences;
import org.thoughtcrime.securesms.util.Util;
public class SmsMmsPreferenceFragment extends PreferenceFragment {
public class SmsMmsPreferenceFragment extends CorrectedPreferenceFragment {
private static final String KITKAT_DEFAULT_PREF = "pref_set_default";
private static final String MMS_PREF = "pref_mms_preferences";