mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
Allow for settings titles to expand across multiple lines instead of being truncated (#1671)
* Added preference classes that allow for titles with multiple lines for settings with long titles * Added null checks to ensure the title TextView isn't null
This commit is contained in:
parent
5cfe709281
commit
1bf5dda4b2
6 changed files with 190 additions and 13 deletions
|
|
@ -0,0 +1,37 @@
|
||||||
|
package fr.free.nrw.commons.ui.LongTitlePreferences;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.preference.EditTextPreference;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by seannemann on 6/27/2018.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class LongTitleEditTextPreference extends EditTextPreference {
|
||||||
|
public LongTitleEditTextPreference(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||||
|
super(context, attrs, defStyleAttr);
|
||||||
|
}
|
||||||
|
|
||||||
|
public LongTitleEditTextPreference(Context context, AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public LongTitleEditTextPreference(Context context) {
|
||||||
|
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onBindView(View view)
|
||||||
|
{
|
||||||
|
super.onBindView(view);
|
||||||
|
|
||||||
|
TextView title= view.findViewById(android.R.id.title);
|
||||||
|
if (title != null) {
|
||||||
|
title.setSingleLine(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
package fr.free.nrw.commons.ui.LongTitlePreferences;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.preference.ListPreference;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by seannemann on 6/27/2018.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class LongTitleListPreference extends ListPreference {
|
||||||
|
public LongTitleListPreference(Context context, AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public LongTitleListPreference(Context context) {
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onBindView(View view)
|
||||||
|
{
|
||||||
|
super.onBindView(view);
|
||||||
|
|
||||||
|
TextView title= view.findViewById(android.R.id.title);
|
||||||
|
if (title != null) {
|
||||||
|
title.setSingleLine(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,36 @@
|
||||||
|
package fr.free.nrw.commons.ui.LongTitlePreferences;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.preference.Preference;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by seannemann on 6/27/2018.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class LongTitlePreference extends Preference {
|
||||||
|
public LongTitlePreference(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||||
|
super(context, attrs, defStyleAttr);
|
||||||
|
}
|
||||||
|
|
||||||
|
public LongTitlePreference(Context context, AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public LongTitlePreference(Context context) {
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onBindView(View view)
|
||||||
|
{
|
||||||
|
super.onBindView(view);
|
||||||
|
|
||||||
|
TextView title= view.findViewById(android.R.id.title);
|
||||||
|
if (title != null) {
|
||||||
|
title.setSingleLine(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,36 @@
|
||||||
|
package fr.free.nrw.commons.ui.LongTitlePreferences;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.preference.PreferenceCategory;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by seannemann on 6/27/2018.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class LongTitlePreferenceCategory extends PreferenceCategory {
|
||||||
|
public LongTitlePreferenceCategory(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||||
|
super(context, attrs, defStyleAttr);
|
||||||
|
}
|
||||||
|
|
||||||
|
public LongTitlePreferenceCategory(Context context, AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public LongTitlePreferenceCategory(Context context) {
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onBindView(View view)
|
||||||
|
{
|
||||||
|
super.onBindView(view);
|
||||||
|
|
||||||
|
TextView title= view.findViewById(android.R.id.title);
|
||||||
|
if (title != null) {
|
||||||
|
title.setSingleLine(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,36 @@
|
||||||
|
package fr.free.nrw.commons.ui.LongTitlePreferences;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.preference.SwitchPreference;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by seannemann on 6/27/2018.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class LongTitleSwitchPreference extends SwitchPreference {
|
||||||
|
public LongTitleSwitchPreference(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||||
|
super(context, attrs, defStyleAttr);
|
||||||
|
}
|
||||||
|
|
||||||
|
public LongTitleSwitchPreference(Context context, AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public LongTitleSwitchPreference(Context context) {
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onBindView(View view)
|
||||||
|
{
|
||||||
|
super.onBindView(view);
|
||||||
|
|
||||||
|
TextView title= view.findViewById(android.R.id.title);
|
||||||
|
if (title != null) {
|
||||||
|
title.setSingleLine(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -2,58 +2,58 @@
|
||||||
<PreferenceScreen
|
<PreferenceScreen
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
<PreferenceCategory
|
<fr.free.nrw.commons.ui.LongTitlePreferences.LongTitlePreferenceCategory
|
||||||
android:title="@string/preference_category_appearance">
|
android:title="@string/preference_category_appearance">
|
||||||
|
|
||||||
<SwitchPreference
|
<fr.free.nrw.commons.ui.LongTitlePreferences.LongTitleSwitchPreference
|
||||||
android:title="@string/preference_theme"
|
android:title="@string/preference_theme"
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
android:summary="@string/preference_theme_summary"
|
android:summary="@string/preference_theme_summary"
|
||||||
android:key="theme" />
|
android:key="theme" />
|
||||||
|
|
||||||
</PreferenceCategory>
|
</fr.free.nrw.commons.ui.LongTitlePreferences.LongTitlePreferenceCategory>
|
||||||
|
|
||||||
<PreferenceCategory
|
<fr.free.nrw.commons.ui.LongTitlePreferences.LongTitlePreferenceCategory
|
||||||
android:title="@string/preference_category_general">
|
android:title="@string/preference_category_general">
|
||||||
|
|
||||||
<ListPreference
|
<fr.free.nrw.commons.ui.LongTitlePreferences.LongTitleListPreference
|
||||||
android:key="defaultLicense"
|
android:key="defaultLicense"
|
||||||
android:title="@string/preference_license"
|
android:title="@string/preference_license"
|
||||||
android:entries="@array/pref_defaultLicense_entries"
|
android:entries="@array/pref_defaultLicense_entries"
|
||||||
android:entryValues="@array/pref_defaultLicense_values"
|
android:entryValues="@array/pref_defaultLicense_values"
|
||||||
android:defaultValue="@string/license_pref_cc_by_sa_4_0" />
|
android:defaultValue="@string/license_pref_cc_by_sa_4_0" />
|
||||||
|
|
||||||
<SwitchPreference
|
<fr.free.nrw.commons.ui.LongTitlePreferences.LongTitleSwitchPreference
|
||||||
android:key="useExternalStorage"
|
android:key="useExternalStorage"
|
||||||
android:title="@string/use_external_storage"
|
android:title="@string/use_external_storage"
|
||||||
android:defaultValue="true"
|
android:defaultValue="true"
|
||||||
android:summary="@string/use_external_storage_summary" />
|
android:summary="@string/use_external_storage_summary" />
|
||||||
|
|
||||||
<EditTextPreference
|
<fr.free.nrw.commons.ui.LongTitlePreferences.LongTitleEditTextPreference
|
||||||
android:key="uploads"
|
android:key="uploads"
|
||||||
android:defaultValue="100"
|
android:defaultValue="100"
|
||||||
android:title= "@string/set_limit"
|
android:title= "@string/set_limit"
|
||||||
android:inputType="numberDecimal"
|
android:inputType="numberDecimal"
|
||||||
android:maxLength="3" />
|
android:maxLength="3" />
|
||||||
|
|
||||||
</PreferenceCategory>
|
</fr.free.nrw.commons.ui.LongTitlePreferences.LongTitlePreferenceCategory>
|
||||||
|
|
||||||
<!-- The key 'allowGps' was used before and has since been removed based on the discussion at #1599.
|
<!-- The key 'allowGps' was used before and has since been removed based on the discussion at #1599.
|
||||||
Do not reuse this key unless you revive the same feature with the changes mentioned at #1599.-->
|
Do not reuse this key unless you revive the same feature with the changes mentioned at #1599.-->
|
||||||
|
|
||||||
<PreferenceCategory
|
<fr.free.nrw.commons.ui.LongTitlePreferences.LongTitlePreferenceCategory
|
||||||
android:title="@string/preference_category_feedback">
|
android:title="@string/preference_category_feedback">
|
||||||
|
|
||||||
<Preference
|
<fr.free.nrw.commons.ui.LongTitlePreferences.LongTitlePreference
|
||||||
android:key="becomeBetaTester"
|
android:key="becomeBetaTester"
|
||||||
android:title="@string/become_a_tester_title"
|
android:title="@string/become_a_tester_title"
|
||||||
android:summary="@string/become_a_tester_description">
|
android:summary="@string/become_a_tester_description">
|
||||||
</Preference>
|
</fr.free.nrw.commons.ui.LongTitlePreferences.LongTitlePreference>
|
||||||
|
|
||||||
<Preference
|
<fr.free.nrw.commons.ui.LongTitlePreferences.LongTitlePreference
|
||||||
android:key="sendLogFile"
|
android:key="sendLogFile"
|
||||||
android:title="@string/send_log_file"
|
android:title="@string/send_log_file"
|
||||||
android:summary="@string/send_log_file_description"/>
|
android:summary="@string/send_log_file_description"/>
|
||||||
|
|
||||||
</PreferenceCategory>
|
</fr.free.nrw.commons.ui.LongTitlePreferences.LongTitlePreferenceCategory>
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue