mirror of
https://github.com/M66B/FairEmail.git
synced 2025-02-23 22:51:02 +00:00
Added quota warning
This commit is contained in:
parent
459faa0ff2
commit
97d513954d
4 changed files with 97 additions and 37 deletions
|
@ -29,6 +29,7 @@ import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.lifecycle.LifecycleOwner;
|
import androidx.lifecycle.LifecycleOwner;
|
||||||
|
@ -59,6 +60,8 @@ public class AdapterNavAccount extends RecyclerView.Adapter<AdapterNavAccount.Vi
|
||||||
private NumberFormat NF = NumberFormat.getNumberInstance();
|
private NumberFormat NF = NumberFormat.getNumberInstance();
|
||||||
private DateFormat TF;
|
private DateFormat TF;
|
||||||
|
|
||||||
|
private static final int QUOTA_WARNING = 95; // percent
|
||||||
|
|
||||||
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener {
|
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener {
|
||||||
private View view;
|
private View view;
|
||||||
private ImageView ivItem;
|
private ImageView ivItem;
|
||||||
|
@ -81,11 +84,13 @@ public class AdapterNavAccount extends RecyclerView.Adapter<AdapterNavAccount.Vi
|
||||||
private void wire() {
|
private void wire() {
|
||||||
view.setOnClickListener(this);
|
view.setOnClickListener(this);
|
||||||
view.setOnLongClickListener(this);
|
view.setOnLongClickListener(this);
|
||||||
|
ivWarning.setOnClickListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void unwire() {
|
private void unwire() {
|
||||||
view.setOnClickListener(null);
|
view.setOnClickListener(null);
|
||||||
view.setOnLongClickListener(null);
|
view.setOnLongClickListener(null);
|
||||||
|
ivWarning.setOnClickListener(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void bindTo(TupleAccountEx account) {
|
private void bindTo(TupleAccountEx account) {
|
||||||
|
@ -115,11 +120,27 @@ public class AdapterNavAccount extends RecyclerView.Adapter<AdapterNavAccount.Vi
|
||||||
tvItemExtra.setText(account.last_connected == null ? null : TF.format(account.last_connected));
|
tvItemExtra.setText(account.last_connected == null ? null : TF.format(account.last_connected));
|
||||||
|
|
||||||
ivExternal.setVisibility(View.GONE);
|
ivExternal.setVisibility(View.GONE);
|
||||||
ivWarning.setVisibility(account.error == null ? View.GONE : View.VISIBLE);
|
|
||||||
|
int percent = Math.round(account.quota_usage * 100f / account.quota_limit);
|
||||||
|
if (account.error != null) {
|
||||||
|
ivWarning.setEnabled(false);
|
||||||
|
ivWarning.setImageResource(R.drawable.twotone_warning_24);
|
||||||
|
ivWarning.setVisibility(View.VISIBLE);
|
||||||
|
} else if (percent > QUOTA_WARNING) {
|
||||||
|
ivWarning.setEnabled(true);
|
||||||
|
ivWarning.setImageResource(R.drawable.twotone_disc_full_24);
|
||||||
|
ivWarning.setVisibility(View.VISIBLE);
|
||||||
|
} else
|
||||||
|
ivWarning.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
if (v.getId() == R.id.ivWarning) {
|
||||||
|
ToastEx.makeText(context, R.string.title_legend_quota, Toast.LENGTH_LONG).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int pos = getAdapterPosition();
|
int pos = getAdapterPosition();
|
||||||
if (pos == RecyclerView.NO_POSITION)
|
if (pos == RecyclerView.NO_POSITION)
|
||||||
return;
|
return;
|
||||||
|
|
15
app/src/main/res/drawable/twotone_disc_full_24.xml
Normal file
15
app/src/main/res/drawable/twotone_disc_full_24.xml
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24"
|
||||||
|
android:tint="?attr/colorControlNormal">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M10,6c-3.31,0 -6,2.69 -6,6s2.69,6 6,6 6,-2.69 6,-6 -2.69,-6 -6,-6zM10,14c-1.1,0 -2,-0.9 -2,-2s0.9,-2 2,-2 2,0.9 2,2 -0.9,2 -2,2z"
|
||||||
|
android:strokeAlpha="0.3"
|
||||||
|
android:fillAlpha="0.3"/>
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M20,14h2v2h-2zM10,4c-4.42,0 -8,3.58 -8,8s3.58,8 8,8 8,-3.58 8,-8 -3.58,-8 -8,-8zM10,18c-3.31,0 -6,-2.69 -6,-6s2.69,-6 6,-6 6,2.69 6,6 -2.69,6 -6,6zM20,7h2v5h-2zM10,10c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2z"/>
|
||||||
|
</vector>
|
|
@ -210,39 +210,6 @@
|
||||||
app:layout_constraintStart_toEndOf="@id/ivDisconnected"
|
app:layout_constraintStart_toEndOf="@id/ivDisconnected"
|
||||||
app:layout_constraintTop_toTopOf="@id/ivDisconnected" />
|
app:layout_constraintTop_toTopOf="@id/ivDisconnected" />
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/ivBackoff"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:contentDescription="@string/title_legend_backoff"
|
|
||||||
android:padding="12dp"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toBottomOf="@id/ivDisconnected"
|
|
||||||
app:srcCompat="@drawable/twotone_update_24" />
|
|
||||||
|
|
||||||
<eu.faircode.email.FixedTextView
|
|
||||||
android:id="@+id/tvBackoff"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="0dp"
|
|
||||||
android:gravity="center_vertical"
|
|
||||||
android:text="@string/title_legend_backoff"
|
|
||||||
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
|
|
||||||
app:layout_constraintBottom_toBottomOf="@id/ivBackoff"
|
|
||||||
app:layout_constraintEnd_toStartOf="@id/ibInfoBackoff"
|
|
||||||
app:layout_constraintStart_toEndOf="@id/ivBackoff"
|
|
||||||
app:layout_constraintTop_toTopOf="@id/ivBackoff" />
|
|
||||||
|
|
||||||
<ImageButton
|
|
||||||
android:id="@+id/ibInfoBackoff"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:contentDescription="@string/title_info"
|
|
||||||
android:tooltipText="@string/title_info"
|
|
||||||
app:layout_constraintBottom_toBottomOf="@id/ivBackoff"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="@id/ivBackoff"
|
|
||||||
app:srcCompat="@drawable/twotone_info_24" />
|
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/ivConnecting"
|
android:id="@+id/ivConnecting"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
@ -250,7 +217,7 @@
|
||||||
android:contentDescription="@string/title_legend_connecting"
|
android:contentDescription="@string/title_legend_connecting"
|
||||||
android:padding="12dp"
|
android:padding="12dp"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/ivBackoff"
|
app:layout_constraintTop_toBottomOf="@id/ivDisconnected"
|
||||||
app:srcCompat="@drawable/twotone_cloud_queue_24" />
|
app:srcCompat="@drawable/twotone_cloud_queue_24" />
|
||||||
|
|
||||||
<eu.faircode.email.FixedTextView
|
<eu.faircode.email.FixedTextView
|
||||||
|
@ -287,6 +254,62 @@
|
||||||
app:layout_constraintStart_toEndOf="@id/ivConnected"
|
app:layout_constraintStart_toEndOf="@id/ivConnected"
|
||||||
app:layout_constraintTop_toTopOf="@id/ivConnected" />
|
app:layout_constraintTop_toTopOf="@id/ivConnected" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/ivBackoff"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:contentDescription="@string/title_legend_backoff"
|
||||||
|
android:padding="12dp"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/ivConnected"
|
||||||
|
app:srcCompat="@drawable/twotone_update_24" />
|
||||||
|
|
||||||
|
<eu.faircode.email.FixedTextView
|
||||||
|
android:id="@+id/tvBackoff"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:text="@string/title_legend_backoff"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
|
||||||
|
app:layout_constraintBottom_toBottomOf="@id/ivBackoff"
|
||||||
|
app:layout_constraintEnd_toStartOf="@id/ibInfoBackoff"
|
||||||
|
app:layout_constraintStart_toEndOf="@id/ivBackoff"
|
||||||
|
app:layout_constraintTop_toTopOf="@id/ivBackoff" />
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/ibInfoBackoff"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:contentDescription="@string/title_info"
|
||||||
|
android:tooltipText="@string/title_info"
|
||||||
|
app:layout_constraintBottom_toBottomOf="@id/ivBackoff"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="@id/ivBackoff"
|
||||||
|
app:srcCompat="@drawable/twotone_info_24" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/ivQuota"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:contentDescription="@string/title_legend_backoff"
|
||||||
|
android:padding="12dp"
|
||||||
|
android:tint="?attr/colorWarning"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/ivBackoff"
|
||||||
|
app:srcCompat="@drawable/twotone_disc_full_24" />
|
||||||
|
|
||||||
|
<eu.faircode.email.FixedTextView
|
||||||
|
android:id="@+id/tvQuota"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:text="@string/title_legend_quota"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
|
||||||
|
app:layout_constraintBottom_toBottomOf="@id/ivQuota"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toEndOf="@id/ivQuota"
|
||||||
|
app:layout_constraintTop_toTopOf="@id/ivQuota" />
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/ivExecuting"
|
android:id="@+id/ivExecuting"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
@ -294,7 +317,7 @@
|
||||||
android:contentDescription="@string/title_legend_executing"
|
android:contentDescription="@string/title_legend_executing"
|
||||||
android:padding="12dp"
|
android:padding="12dp"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/ivConnected"
|
app:layout_constraintTop_toBottomOf="@id/ivQuota"
|
||||||
app:srcCompat="@drawable/twotone_dns_24" />
|
app:srcCompat="@drawable/twotone_dns_24" />
|
||||||
|
|
||||||
<eu.faircode.email.FixedTextView
|
<eu.faircode.email.FixedTextView
|
||||||
|
|
|
@ -1350,9 +1350,10 @@
|
||||||
<string name="title_legend_synchronize_off">Synchronize off</string>
|
<string name="title_legend_synchronize_off">Synchronize off</string>
|
||||||
<string name="title_legend_synchronize_poll">Synchronize periodically</string>
|
<string name="title_legend_synchronize_poll">Synchronize periodically</string>
|
||||||
<string name="title_legend_disconnected">Disconnected</string>
|
<string name="title_legend_disconnected">Disconnected</string>
|
||||||
<string name="title_legend_backoff">Waiting after failure</string>
|
|
||||||
<string name="title_legend_connecting">Connecting</string>
|
<string name="title_legend_connecting">Connecting</string>
|
||||||
<string name="title_legend_connected">Connected</string>
|
<string name="title_legend_connected">Connected</string>
|
||||||
|
<string name="title_legend_backoff">Waiting after failure</string>
|
||||||
|
<string name="title_legend_quota">Mailbox almost full</string>
|
||||||
<string name="title_legend_executing">Executing operations</string>
|
<string name="title_legend_executing">Executing operations</string>
|
||||||
<string name="title_legend_synchronizing">Synchronizing</string>
|
<string name="title_legend_synchronizing">Synchronizing</string>
|
||||||
<string name="title_legend_downloading">Downloading</string>
|
<string name="title_legend_downloading">Downloading</string>
|
||||||
|
|
Loading…
Reference in a new issue