mirror of
https://github.com/M66B/FairEmail.git
synced 2025-03-15 08:29:24 +00:00
Sign in with Google (2)
This commit is contained in:
parent
320ab884bf
commit
4d1fd57546
4 changed files with 31 additions and 18 deletions
|
@ -29,7 +29,9 @@ import android.content.Intent;
|
|||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.net.Uri;
|
||||
|
@ -191,6 +193,21 @@ public class FragmentOAuth extends FragmentBase {
|
|||
}
|
||||
});
|
||||
|
||||
if ("gmail".equals(id)) {
|
||||
final Context context = getContext();
|
||||
int dp6 = Helper.dp2pixels(context, 6);
|
||||
int dp12 = Helper.dp2pixels(context, 12);
|
||||
int dp24 = Helper.dp2pixels(context, 24);
|
||||
Drawable g = context.getDrawable(R.drawable.btn_google_light_normal);
|
||||
g.setBounds(0, 0, dp24, dp24);
|
||||
btnOAuth.setCompoundDrawablesRelative(g, null, null, null);
|
||||
btnOAuth.setText(R.string.title_setup_google_sign_in);
|
||||
btnOAuth.setCompoundDrawablePadding(dp6);
|
||||
btnOAuth.setPaddingRelative(dp12, 0, dp12, 0);
|
||||
btnOAuth.setTextColor(Color.DKGRAY);
|
||||
btnOAuth.setBackground(context.getDrawable(R.drawable.btn_google_background));
|
||||
}
|
||||
|
||||
btnOAuth.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
|
|
@ -302,8 +302,7 @@ public class FragmentSetup extends FragmentBase {
|
|||
if (provider.oauth != null &&
|
||||
(provider.oauth.enabled || BuildConfig.DEBUG) &&
|
||||
!TextUtils.isEmpty(provider.oauth.clientId)) {
|
||||
String title = getString(R.string.title_setup_oauth, "gmail".equals(provider.id)
|
||||
? getString(R.string.title_setup_google_sign_in) : provider.description);
|
||||
String title = getString(R.string.title_setup_oauth, provider.description);
|
||||
item = menu
|
||||
.add(Menu.FIRST, -1, order++, title)
|
||||
.setIntent(new Intent(ActivitySetup.ACTION_QUICK_OAUTH)
|
||||
|
@ -314,9 +313,7 @@ public class FragmentSetup extends FragmentBase {
|
|||
.putExtra("askTenant", provider.oauth.askTenant())
|
||||
.putExtra("pop", provider.pop != null));
|
||||
// https://developers.google.com/identity/branding-guidelines
|
||||
resid = ("gmail".equals(provider.id)
|
||||
? R.drawable.btn_google_light_normal
|
||||
: res.getIdentifier("provider_" + provider.id, "drawable", pkg));
|
||||
resid = res.getIdentifier("provider_" + provider.id, "drawable", pkg);
|
||||
if (resid != 0)
|
||||
item.setIcon(resid);
|
||||
}
|
||||
|
|
|
@ -122,19 +122,11 @@ public class PopupMenuLifecycle extends PopupMenu {
|
|||
if (icon == null)
|
||||
icon = new ColorDrawable(Color.TRANSPARENT);
|
||||
else {
|
||||
Intent intent = menuItem.getIntent();
|
||||
boolean gmail = (intent != null &&
|
||||
ActivitySetup.ACTION_QUICK_OAUTH.equals(intent.getAction()) &&
|
||||
"gmail".equals(intent.getStringExtra("id")));
|
||||
if (gmail)
|
||||
icon.setState(new int[]{android.R.attr.state_enabled, android.R.attr.state_focused});
|
||||
else {
|
||||
icon = icon.getConstantState().newDrawable().mutate();
|
||||
int color = Helper.resolveColor(context, R.attr.colorAccent);
|
||||
icon.setTint(color);
|
||||
if (!menuItem.isEnabled())
|
||||
icon.setAlpha(Math.round(Helper.LOW_LIGHT * 255));
|
||||
}
|
||||
icon = icon.getConstantState().newDrawable().mutate();
|
||||
int color = Helper.resolveColor(context, R.attr.colorAccent);
|
||||
icon.setTint(color);
|
||||
if (!menuItem.isEnabled())
|
||||
icon.setAlpha(Math.round(Helper.LOW_LIGHT * 255));
|
||||
}
|
||||
|
||||
int iconSize = context.getResources().getDimensionPixelSize(R.dimen.menu_item_icon_size);
|
||||
|
|
7
app/src/main/res/drawable/btn_google_background.xml
Normal file
7
app/src/main/res/drawable/btn_google_background.xml
Normal file
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid android:color="#FFFFFF" />
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="#C0C0C0" />
|
||||
</shape>
|
Loading…
Add table
Reference in a new issue