Sign in with Google

pull/209/head
M66B 2 years ago
parent e6a18bd322
commit f6d304cd0b

@ -277,19 +277,34 @@ public class FragmentSetup extends FragmentBase {
Resources res = context.getResources();
String pkg = context.getPackageName();
boolean google = true;
List<EmailProvider> providers = EmailProvider.loadProfiles(context);
for (EmailProvider provider : providers)
if ("gmail".equals(provider.id) &&
provider.oauth != null &&
provider.oauth.enabled) {
google = false;
break;
}
int order = 1;
if (google) {
String gmail = getString(R.string.title_setup_oauth, getString(R.string.title_setup_gmail));
MenuItem item = menu.add(Menu.FIRST, R.string.title_setup_gmail, order++, gmail);
int resid = res.getIdentifier("provider_gmail", "drawable", pkg);
if (resid != 0)
item.setIcon(resid);
}
for (EmailProvider provider : EmailProvider.loadProfiles(context))
for (EmailProvider provider : providers)
if (provider.oauth != null &&
(provider.oauth.enabled || BuildConfig.DEBUG) &&
!TextUtils.isEmpty(provider.oauth.clientId)) {
item = menu
.add(Menu.FIRST, -1, order++, getString(R.string.title_setup_oauth, provider.description))
String title = getString(R.string.title_setup_oauth, "gmail".equals(provider.id)
? getString(R.string.title_setup_google_sign_in) : provider.description);
MenuItem item = menu
.add(Menu.FIRST, -1, order++, title)
.setIntent(new Intent(ActivitySetup.ACTION_QUICK_OAUTH)
.putExtra("id", provider.id)
.putExtra("name", provider.description)
@ -297,7 +312,9 @@ public class FragmentSetup extends FragmentBase {
.putExtra("askAccount", provider.oauth.askAccount)
.putExtra("askTenant", provider.oauth.askTenant())
.putExtra("pop", provider.pop != null));
resid = res.getIdentifier("provider_" + provider.id, "drawable", pkg);
int resid = ("gmail".equals(provider.id)
? R.drawable.google_signin
: res.getIdentifier("provider_" + provider.id, "drawable", pkg));
if (resid != 0)
item.setIcon(resid);
}

@ -20,10 +20,12 @@ package eu.faircode.email;
*/
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.text.SpannableStringBuilder;
import android.text.style.BackgroundColorSpan;
import android.text.style.ImageSpan;
import android.view.Gravity;
import android.view.Menu;
@ -117,9 +119,15 @@ public class PopupMenuLifecycle extends PopupMenu {
static void insertIcon(Context context, MenuItem menuItem, boolean submenu) {
Drawable icon = menuItem.getIcon();
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);
@ -127,6 +135,7 @@ public class PopupMenuLifecycle extends PopupMenu {
if (!menuItem.isEnabled())
icon.setAlpha(Math.round(Helper.LOW_LIGHT * 255));
}
}
int iconSize = context.getResources().getDimensionPixelSize(R.dimen.menu_item_icon_size);
icon.setBounds(0, 0, iconSize, iconSize);

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 712 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_enabled="true"
android:state_pressed="false"
android:state_focused="false"
android:drawable="@drawable/btn_google_light_normal" />
<item
android:state_enabled="true"
android:state_pressed="false"
android:state_focused="true"
android:drawable="@drawable/btn_google_light_focus" />
<item
android:state_enabled="true"
android:state_pressed="true"
android:drawable="@drawable/btn_google_light_pressed" />
<item
android:state_enabled="false"
android:drawable="@drawable/btn_google_light_disabled" />
</selector>

@ -201,6 +201,7 @@
<string name="title_setup_identities">Identities</string>
<string name="title_setup_gmail" translatable="false">Gmail</string>
<string name="title_setup_oauth" translatable="false">%1$s (OAuth)</string>
<string name="title_setup_google_sign_in">Sign in with Google</string>
<string name="title_setup_other">Other provider</string>
<string name="title_setup_inbound">Incoming email only (email cannot be sent!)</string>
<string name="title_setup_pop3">POP3 account</string>

@ -23,8 +23,8 @@
<oauth
askAccount="true"
authorizationEndpoint="https://accounts.google.com/o/oauth2/auth"
clientId=""
clientSecret=""
clientId="495454862802-rkeb9fs6i6aqs99ieureo5nugc5g98lc.apps.googleusercontent.com"
clientSecret="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"
enabled="false"
privacy="https://policies.google.com/privacy"
prompt="consent"

Loading…
Cancel
Save