Improve hide long toots
This commit is contained in:
parent
df3f870c7d
commit
cfa6a1108e
|
@ -717,23 +717,36 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
});
|
||||
}
|
||||
holder.status_content.setText(status.getContentSpan(), TextView.BufferType.SPANNABLE);
|
||||
boolean truncate_toots = sharedpreferences.getBoolean(Helper.SET_TRUNCATE_TOOTS, false);
|
||||
if( truncate_toots) {
|
||||
int truncate_toots_size = sharedpreferences.getInt(Helper.SET_TRUNCATE_TOOTS_SIZE, 0);
|
||||
if( truncate_toots_size > 0) {
|
||||
holder.status_content.setMaxLines(truncate_toots_size);
|
||||
if (status.getNumberLines() == -1) {
|
||||
status.setNumberLines(holder.status_content.getLineCount());
|
||||
status.setNumberLines(-2);
|
||||
holder.status_show_more_content.setVisibility(View.GONE);
|
||||
holder.status_content.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
status.setNumberLines(holder.status_content.getLineCount());
|
||||
if( status.getNumberLines() > truncate_toots_size) {
|
||||
notifyStatusChanged(status);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
if (status.getNumberLines() > 10) {
|
||||
else if (status.getNumberLines() > truncate_toots_size) {
|
||||
holder.status_show_more_content.setVisibility(View.VISIBLE);
|
||||
if (status.isExpanded()) {
|
||||
holder.status_content.setMaxLines(Integer.MAX_VALUE);
|
||||
holder.status_show_more_content.setText(R.string.load_attachment_spoiler_less);
|
||||
holder.status_show_more_content.setText(R.string.hide_toot_truncate);
|
||||
} else {
|
||||
holder.status_content.setMaxLines(10);
|
||||
holder.status_show_more_content.setText(R.string.load_attachment_spoiler);
|
||||
holder.status_content.setMaxLines(truncate_toots_size);
|
||||
holder.status_show_more_content.setText(R.string.display_toot_truncate);
|
||||
}
|
||||
} else {
|
||||
holder.status_show_more_content.setVisibility(View.GONE);
|
||||
}
|
||||
}else{
|
||||
holder.status_show_more_content.setVisibility(View.GONE);
|
||||
}
|
||||
holder.status_show_more_content.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
|
|
@ -262,15 +262,22 @@ public class SettingsFragment extends Fragment {
|
|||
}
|
||||
});
|
||||
|
||||
boolean truncate_toots = sharedpreferences.getBoolean(Helper.SET_TRUNCATE_TOOTS, false);
|
||||
final CheckBox set_truncate_toots = rootView.findViewById(R.id.set_truncate_toots);
|
||||
set_truncate_toots.setChecked(truncate_toots);
|
||||
|
||||
set_truncate_toots.setOnClickListener(new View.OnClickListener() {
|
||||
int truncate_toots_size = sharedpreferences.getInt(Helper.SET_TRUNCATE_TOOTS_SIZE, 0);
|
||||
SeekBar set_truncate_size = rootView.findViewById(R.id.set_truncate_size);
|
||||
set_truncate_size.setMax(20);
|
||||
set_truncate_size.setProgress(truncate_toots_size);
|
||||
TextView set_truncate_toots = rootView.findViewById(R.id.set_truncate_toots);
|
||||
set_truncate_toots.setText(String.valueOf(truncate_toots_size));
|
||||
set_truncate_size.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {}
|
||||
@Override
|
||||
public void onStartTrackingTouch(SeekBar seekBar) {}
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||
set_truncate_toots.setText(String.valueOf(progress));
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
editor.putBoolean(Helper.SET_TRUNCATE_TOOTS, set_truncate_toots.isChecked());
|
||||
editor.putInt(Helper.SET_TRUNCATE_TOOTS_SIZE, progress);
|
||||
editor.apply();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -338,7 +338,7 @@ public class Helper {
|
|||
public static final String SET_DISPLAY_GLOBAL = "set_display_global";
|
||||
public static final String SET_AUTOMATICALLY_SPLIT_TOOTS = "set_automatically_split_toots";
|
||||
public static final String SET_AUTOMATICALLY_SPLIT_TOOTS_SIZE = "set_automatically_split_toots_size";
|
||||
public static final String SET_TRUNCATE_TOOTS = "set_truncate_toots";
|
||||
public static final String SET_TRUNCATE_TOOTS_SIZE = "set_truncate_toots_size";
|
||||
//End points
|
||||
public static final String EP_AUTHORIZE = "/oauth/authorize";
|
||||
|
||||
|
|
|
@ -187,11 +187,32 @@
|
|||
android:layout_height="wrap_content" />
|
||||
|
||||
<!-- TRUNCATE LONG TOOTS -->
|
||||
<CheckBox
|
||||
android:id="@+id/set_truncate_toots"
|
||||
<TextView
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:text="@string/truncate_long_toots"
|
||||
android:layout_height="wrap_content" />
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:text="@string/set_truncate_toot"/>
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_height="wrap_content">
|
||||
<TextView
|
||||
android:id="@+id/set_truncate_toots"
|
||||
android:gravity="end"
|
||||
android:layout_width="30dp"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:layout_height="wrap_content" />
|
||||
<SeekBar
|
||||
android:layout_gravity="center_vertical"
|
||||
android:id="@+id/set_truncate_size"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
</SeekBar>
|
||||
</LinearLayout>
|
||||
|
||||
<!-- Resize pictures -->
|
||||
<LinearLayout
|
||||
|
|
|
@ -266,6 +266,9 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
<Button
|
||||
android:layout_marginTop="-10dp"
|
||||
android:paddingTop="2dp"
|
||||
android:paddingBottom="2dp"
|
||||
android:id="@+id/status_show_more_content"
|
||||
android:visibility="gone"
|
||||
android:textAllCaps="false"
|
||||
|
@ -273,13 +276,11 @@
|
|||
android:drawableStart="@drawable/ic_more_toot_content"
|
||||
android:gravity="center_vertical"
|
||||
android:drawablePadding="5dp"
|
||||
android:paddingTop="5dp"
|
||||
android:paddingBottom="5dp"
|
||||
android:maxLines="1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
style="?attr/borderless"
|
||||
android:text="@string/load_attachment_spoiler" />
|
||||
android:text="@string/display_toot_truncate" />
|
||||
<TextView
|
||||
android:visibility="gone"
|
||||
android:layout_marginEnd="10dp"
|
||||
|
|
|
@ -242,13 +242,13 @@
|
|||
android:drawableStart="@drawable/ic_more_toot_content"
|
||||
android:gravity="center_vertical"
|
||||
android:drawablePadding="5dp"
|
||||
android:paddingTop="5dp"
|
||||
android:paddingBottom="5dp"
|
||||
android:paddingTop="2dp"
|
||||
android:paddingBottom="2dp"
|
||||
android:maxLines="1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
style="?attr/borderless"
|
||||
android:text="@string/load_attachment_spoiler" />
|
||||
android:text="@string/display_toot_truncate" />
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
|
@ -169,13 +169,14 @@
|
|||
android:drawableStart="@drawable/ic_more_toot_content"
|
||||
android:gravity="center_vertical"
|
||||
android:drawablePadding="5dp"
|
||||
android:paddingTop="5dp"
|
||||
android:paddingBottom="5dp"
|
||||
android:layout_marginTop="-10dp"
|
||||
android:paddingTop="2dp"
|
||||
android:paddingBottom="2dp"
|
||||
android:maxLines="1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
style="?attr/borderless"
|
||||
android:text="@string/load_attachment_spoiler" />
|
||||
android:text="@string/display_toot_truncate" />
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
|
@ -186,11 +186,32 @@
|
|||
android:layout_height="wrap_content" />
|
||||
|
||||
<!-- TRUNCATE LONG TOOTS -->
|
||||
<CheckBox
|
||||
android:id="@+id/set_truncate_toots"
|
||||
<TextView
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:text="@string/truncate_long_toots"
|
||||
android:layout_height="wrap_content" />
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:text="@string/set_truncate_toot"/>
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_height="wrap_content">
|
||||
<TextView
|
||||
android:id="@+id/set_truncate_toots"
|
||||
android:gravity="end"
|
||||
android:layout_width="30dp"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:layout_height="wrap_content" />
|
||||
<SeekBar
|
||||
android:layout_gravity="center_vertical"
|
||||
android:id="@+id/set_truncate_size"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
</SeekBar>
|
||||
</LinearLayout>
|
||||
|
||||
<!-- Resize pictures -->
|
||||
<LinearLayout
|
||||
|
|
|
@ -677,6 +677,9 @@
|
|||
<string name="set_change_locale">Change the language</string>
|
||||
<string name="default_language">Default language</string>
|
||||
<string name="truncate_long_toots">Truncate long toots</string>
|
||||
<string name="set_truncate_toot">Truncate toots over \'x\' lines. Zero means disabled.</string>
|
||||
<string name="display_toot_truncate">Display more</string>
|
||||
<string name="hide_toot_truncate">Display less</string>
|
||||
|
||||
<string-array name="filter_expire">
|
||||
<item>Never</item>
|
||||
|
|
Loading…
Reference in New Issue