Pinch zoom text size

pull/162/head
M66B 5 years ago
parent ed29c0776c
commit 6e1dd04502

@ -54,12 +54,12 @@ For authorizing:
* ~~Pinch zoom~~ (not reliably possible in a scrolling list; the full message view can be zoomed instead)
* ~~More compact folder view~~
* ~~Compose lists and tables~~ (this requires a rich text editor, see [this FAQ](#user-content-faq99))
* ~~Pinch zoom text size~~
* Send as attachment
* Themes
* Search for settings
* Select any day for time conditions
* Widget for selected account
* Pinch zoom
Anything on this list is in random order and *might* be added in the near future.

@ -66,6 +66,7 @@ import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.ScaleGestureDetector;
import android.view.TouchDelegate;
import android.view.View;
import android.view.ViewAnimationUtils;
@ -227,7 +228,11 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
));
public class ViewHolder extends RecyclerView.ViewHolder implements
View.OnClickListener, View.OnLongClickListener, BottomNavigationView.OnNavigationItemSelectedListener, View.OnKeyListener {
View.OnKeyListener,
View.OnClickListener,
View.OnLongClickListener,
View.OnTouchListener,
BottomNavigationView.OnNavigationItemSelectedListener {
private View card;
private View view;
@ -331,6 +336,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
private boolean hasJunk;
private boolean delete;
private ScaleGestureDetector gestureDetector;
ViewHolder(final View itemView) {
super(itemView);
@ -508,9 +515,25 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ibImages.setOnClickListener(this);
ibDecrypt.setOnClickListener(this);
tvBody.setOnTouchListener(this);
btnCalendarAccept.setOnClickListener(this);
btnCalendarDecline.setOnClickListener(this);
btnCalendarMaybe.setOnClickListener(this);
gestureDetector = new ScaleGestureDetector(context, new ScaleGestureDetector.SimpleOnScaleGestureListener() {
@Override
public boolean onScale(ScaleGestureDetector detector) {
TupleMessageEx message = getMessage();
if (message != null) {
float factor = detector.getScaleFactor();
float size = tvBody.getTextSize() * factor;
properties.setSize(message.id, size);
tvBody.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
}
return true;
}
});
}
}
@ -540,6 +563,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ibImages.setOnClickListener(null);
ibDecrypt.setOnClickListener(null);
tvBody.setOnTouchListener(null);
btnCalendarAccept.setOnClickListener(null);
btnCalendarDecline.setOnClickListener(null);
btnCalendarMaybe.setOnClickListener(null);
@ -950,8 +975,10 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ibFull.setVisibility(View.GONE);
ibImages.setVisibility(View.GONE);
if (textSize != 0)
tvBody.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
if (textSize != 0) {
float size = properties.getSize(message.id, textSize);
tvBody.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
}
tvBody.setTextColor(contrast ? textColorPrimary : textColorSecondary);
tvBody.setTypeface(monospaced ? Typeface.MONOSPACE : Typeface.DEFAULT);
@ -1417,6 +1444,27 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
private boolean firstClick = false;
@Override
public boolean onTouch(View view, MotionEvent ev) {
if (ev.getPointerCount() > 1 &&
textSize != 0 && gestureDetector != null) {
switch (ev.getAction()) {
case MotionEvent.ACTION_DOWN:
case MotionEvent.ACTION_MOVE:
view.getParent().requestDisallowInterceptTouchEvent(true);
gestureDetector.onTouchEvent(ev);
break;
case MotionEvent.ACTION_UP:
view.getParent().requestDisallowInterceptTouchEvent(false);
gestureDetector.onTouchEvent(ev);
break;
}
return true;
}
return false;
}
@Override
public void onClick(View view) {
final TupleMessageEx message = getMessage();
@ -3477,6 +3525,10 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
boolean getValue(String name, long id);
void setSize(long id, float size);
float getSize(long id, float defaultSize);
void setBody(long id, Spanned body);
Spanned getBody(long id);

@ -232,6 +232,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
private int autoCloseCount = 0;
private boolean autoExpanded = true;
private Map<String, List<Long>> values = new HashMap<>();
private LongSparseArray<Float> sizes = new LongSparseArray<>();
private LongSparseArray<Spanned> bodies = new LongSparseArray<>();
private LongSparseArray<List<EntityAttachment>> attachments = new LongSparseArray<>();
private LongSparseArray<TupleAccountSwipes> accountSwipes = new LongSparseArray<>();
@ -1179,6 +1180,16 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
return false;
}
@Override
public void setSize(long id, float size) {
sizes.put(id, size);
}
@Override
public float getSize(long id, float defaultSize) {
return sizes.get(id, defaultSize);
}
@Override
public void setBody(long id, Spanned value) {
if (value == null)

Loading…
Cancel
Save