mirror of https://github.com/M66B/FairEmail.git
Added image view hints
This commit is contained in:
parent
d4857d7101
commit
34589b5930
|
@ -0,0 +1,60 @@
|
||||||
|
package eu.faircode.email;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.view.Gravity;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.appcompat.widget.AppCompatImageView;
|
||||||
|
|
||||||
|
public class ViewImageHint extends AppCompatImageView implements View.OnLongClickListener {
|
||||||
|
private OnLongClickListener listener;
|
||||||
|
|
||||||
|
public ViewImageHint(@NonNull Context context) {
|
||||||
|
super(context);
|
||||||
|
setOnLongClickListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ViewImageHint(@NonNull Context context, @Nullable AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
setOnLongClickListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ViewImageHint(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
||||||
|
super(context, attrs, defStyleAttr);
|
||||||
|
setOnLongClickListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setOnLongClickListener(OnLongClickListener listener) {
|
||||||
|
if (listener == this) {
|
||||||
|
super.setOnLongClickListener(listener);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.listener = listener;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onLongClick(View v) {
|
||||||
|
if (listener == null || !listener.onLongClick(v)) {
|
||||||
|
String title = getContentDescription().toString();
|
||||||
|
if (!TextUtils.isEmpty(title)) {
|
||||||
|
int[] pos = new int[2];
|
||||||
|
getLocationInWindow(pos);
|
||||||
|
|
||||||
|
Toast toast = ToastEx.makeText(getContext(), title, Toast.LENGTH_LONG);
|
||||||
|
toast.setGravity(Gravity.TOP | Gravity.START, pos[0], pos[1]);
|
||||||
|
toast.show();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
|
@ -13,7 +13,7 @@
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
<ImageView
|
<eu.faircode.email.ViewImageHint
|
||||||
android:id="@+id/ivPlain"
|
android:id="@+id/ivPlain"
|
||||||
android:layout_width="21dp"
|
android:layout_width="21dp"
|
||||||
android:layout_height="21dp"
|
android:layout_height="21dp"
|
||||||
|
@ -23,7 +23,7 @@
|
||||||
app:layout_constraintTop_toBottomOf="@id/ibExpanderAddress"
|
app:layout_constraintTop_toBottomOf="@id/ibExpanderAddress"
|
||||||
app:srcCompat="@drawable/baseline_notes_24" />
|
app:srcCompat="@drawable/baseline_notes_24" />
|
||||||
|
|
||||||
<ImageView
|
<eu.faircode.email.ViewImageHint
|
||||||
android:id="@+id/ivReceipt"
|
android:id="@+id/ivReceipt"
|
||||||
android:layout_width="21dp"
|
android:layout_width="21dp"
|
||||||
android:layout_height="21dp"
|
android:layout_height="21dp"
|
||||||
|
@ -33,7 +33,7 @@
|
||||||
app:layout_constraintTop_toBottomOf="@id/ibExpanderAddress"
|
app:layout_constraintTop_toBottomOf="@id/ibExpanderAddress"
|
||||||
app:srcCompat="@drawable/baseline_playlist_add_check_24" />
|
app:srcCompat="@drawable/baseline_playlist_add_check_24" />
|
||||||
|
|
||||||
<ImageView
|
<eu.faircode.email.ViewImageHint
|
||||||
android:id="@+id/ivBrowsed"
|
android:id="@+id/ivBrowsed"
|
||||||
android:layout_width="21dp"
|
android:layout_width="21dp"
|
||||||
android:layout_height="21dp"
|
android:layout_height="21dp"
|
||||||
|
|
Loading…
Reference in New Issue