mirror of https://github.com/M66B/FairEmail.git
Added button to disable Gmail
This commit is contained in:
parent
edb7ab16ac
commit
3bcac5b0ed
|
@ -24,7 +24,9 @@ import android.content.Context;
|
|||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
|
@ -40,6 +42,7 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import static android.app.Activity.RESULT_OK;
|
||||
import static eu.faircode.email.ServiceAuthenticator.AUTH_TYPE_GMAIL;
|
||||
|
||||
public class FragmentDialogAccount extends FragmentDialogBase {
|
||||
@NonNull
|
||||
|
@ -59,6 +62,7 @@ public class FragmentDialogAccount extends FragmentDialogBase {
|
|||
final TextView tvLeft = dview.findViewById(R.id.tvLeft);
|
||||
final TextView tvRight = dview.findViewById(R.id.tvRight);
|
||||
final Button btnAccount = dview.findViewById(R.id.btnAccount);
|
||||
final Button btnGmail = dview.findViewById(R.id.btnGmail);
|
||||
|
||||
final Drawable check = context.getDrawable(R.drawable.twotone_check_24);
|
||||
final Drawable close = context.getDrawable(R.drawable.twotone_close_24);
|
||||
|
@ -78,6 +82,7 @@ public class FragmentDialogAccount extends FragmentDialogBase {
|
|||
tvRight.setText(null);
|
||||
|
||||
tvSentWarning.setVisibility(View.GONE);
|
||||
btnGmail.setVisibility(View.GONE);
|
||||
|
||||
Bundle args = getArguments();
|
||||
final long account = args.getLong("account");
|
||||
|
@ -94,12 +99,26 @@ public class FragmentDialogAccount extends FragmentDialogBase {
|
|||
}
|
||||
});
|
||||
|
||||
Intent gmail = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
|
||||
gmail.setData(Uri.parse("package:com.google.android.gm"));
|
||||
boolean hasGmail = (gmail.resolveActivity(context.getPackageManager()) != null);
|
||||
|
||||
btnGmail.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
v.getContext().startActivity(gmail);
|
||||
}
|
||||
});
|
||||
|
||||
DB db = DB.getInstance(context);
|
||||
|
||||
db.account().liveAccount(account).observe(this, new Observer<EntityAccount>() {
|
||||
@Override
|
||||
public void onChanged(EntityAccount account) {
|
||||
tvName.setText(account.name);
|
||||
btnGmail.setVisibility(
|
||||
hasGmail && account.auth_type == AUTH_TYPE_GMAIL
|
||||
? View.VISIBLE : View.GONE);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -197,5 +197,18 @@
|
|||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/btnAccount" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnGmail"
|
||||
style="?android:attr/buttonStyleSmall"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:drawableEnd="@drawable/twotone_close_24"
|
||||
android:drawablePadding="6dp"
|
||||
android:tag="disable"
|
||||
android:text="@string/title_disable_gmail"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvAccount" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</eu.faircode.email.ScrollViewEx>
|
|
@ -156,6 +156,7 @@
|
|||
<string name="title_edit_account">Edit account</string>
|
||||
<string name="title_edit_identity">Edit identity</string>
|
||||
<string name="title_edit_folder">Edit folder</string>
|
||||
<string name="title_disable_gmail">Disable Gmail</string>
|
||||
|
||||
<string name="title_setup">Settings</string>
|
||||
<string name="title_setup_help">Help</string>
|
||||
|
|
Loading…
Reference in New Issue