Skip to content

Commit

Permalink
Revert "Feature/material theme and Dark Theme support (#11469)" (#11486)
Browse files Browse the repository at this point in the history
  • Loading branch information
khaykov authored Mar 20, 2020
1 parent 76aea7f commit 7244b9e
Show file tree
Hide file tree
Showing 31 changed files with 588 additions and 504 deletions.
2 changes: 1 addition & 1 deletion WordPressLoginFlow/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ dependencies {
implementation 'androidx.media:media:1.0.1'
implementation 'androidx.legacy:legacy-support-v13:1.0.0'
implementation 'androidx.gridlayout:gridlayout:1.0.0'
implementation 'com.google.android.material:material:1.1.0'
implementation 'com.google.android.material:material:1.0.0'

api 'com.google.android.gms:play-services-auth:15.0.1'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import android.text.TextUtils;
import android.text.TextWatcher;
import android.text.method.DigitsKeyListener;
import android.view.ContextThemeWrapper;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
Expand All @@ -20,8 +21,6 @@
import androidx.annotation.StringRes;
import androidx.appcompat.app.AlertDialog;

import com.google.android.material.dialog.MaterialAlertDialogBuilder;

import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import org.wordpress.android.fluxc.generated.AccountActionBuilder;
Expand All @@ -45,10 +44,10 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import static android.content.Context.CLIPBOARD_SERVICE;

import dagger.android.support.AndroidSupportInjection;

import static android.content.Context.CLIPBOARD_SERVICE;

public class Login2FaFragment extends LoginBaseFormFragment<LoginListener> implements TextWatcher,
OnEditorCommitListener {
private static final String KEY_2FA_TYPE = "KEY_2FA_TYPE";
Expand Down Expand Up @@ -397,7 +396,7 @@ private void handleAuthError(AuthenticationErrorType error, String errorMessage)
}

private void showErrorDialog(String message) {
AlertDialog dialog = new MaterialAlertDialogBuilder(getActivity())
AlertDialog dialog = new AlertDialog.Builder(new ContextThemeWrapper(getActivity(), R.style.LoginTheme))
.setMessage(message)
.setPositiveButton(R.string.login_error_button, null)
.create();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import android.text.Html;
import android.text.TextWatcher;
import android.util.Patterns;
import android.view.ContextThemeWrapper;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
Expand All @@ -32,7 +33,6 @@
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.common.api.GoogleApiClient.ConnectionCallbacks;
import com.google.android.gms.common.api.GoogleApiClient.OnConnectionFailedListener;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;

import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
Expand Down Expand Up @@ -383,7 +383,7 @@ private void showEmailError(int messageId) {
}

private void showErrorDialog(String message) {
AlertDialog dialog = new MaterialAlertDialogBuilder(getActivity())
AlertDialog dialog = new AlertDialog.Builder(new ContextThemeWrapper(getActivity(), R.style.LoginTheme))
.setMessage(message)
.setPositiveButton(R.string.login_error_button, null)
.create();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.ContextThemeWrapper;
import android.view.KeyEvent;
import android.view.View;
import android.widget.EditText;
Expand All @@ -17,8 +18,6 @@
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.DialogFragment;

import com.google.android.material.dialog.MaterialAlertDialogBuilder;

import org.wordpress.android.util.EditTextUtils;

public class LoginHttpAuthDialogFragment extends DialogFragment {
Expand Down Expand Up @@ -50,7 +49,7 @@ public void onCreate(@Nullable Bundle savedInstanceState) {
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder alert = new MaterialAlertDialogBuilder(getActivity());
AlertDialog.Builder alert = new AlertDialog.Builder(new ContextThemeWrapper(getActivity(), R.style.LoginTheme));
alert.setTitle(R.string.http_authorization_required);

//noinspection InflateParams
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public class LoginMagicLinkRequestFragment extends Fragment {
public static final String TAG = "login_magic_link_request_fragment_tag";

private static final String KEY_IN_PROGRESS = "KEY_IN_PROGRESS";
private static final String KEY_GRAVATAR_IN_PROGRESS = "KEY_GRAVATAR_IN_PROGRESS";
private static final String ARG_EMAIL_ADDRESS = "ARG_EMAIL_ADDRESS";
private static final String ARG_MAGIC_LINK_SCHEME = "ARG_MAGIC_LINK_SCHEME";
private static final String ARG_IS_JETPACK_CONNECT = "ARG_IS_JETPACK_CONNECT";
Expand Down Expand Up @@ -223,6 +224,9 @@ public void onActivityCreated(@Nullable Bundle savedInstanceState) {
if (mInProgress) {
showMagicLinkRequestProgressDialog();
}

boolean gravatarInProgress = savedInstanceState.getBoolean(KEY_GRAVATAR_IN_PROGRESS);
mAvatarProgressBar.setVisibility(gravatarInProgress ? View.VISIBLE : View.GONE);
}
// important for accessibility - talkback
getActivity().setTitle(R.string.magic_link_login_title);
Expand All @@ -239,6 +243,7 @@ public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);

outState.putBoolean(KEY_IN_PROGRESS, mInProgress);
outState.putBoolean(KEY_GRAVATAR_IN_PROGRESS, mAvatarProgressBar.getVisibility() == View.VISIBLE);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.ContextThemeWrapper;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.DialogFragment;

import com.google.android.material.dialog.MaterialAlertDialogBuilder;

import org.wordpress.android.fluxc.store.AccountStore;
import org.wordpress.android.fluxc.store.SiteStore;

Expand Down Expand Up @@ -47,7 +46,7 @@ public void onAttach(Context context) {
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder alert = new MaterialAlertDialogBuilder(getActivity());
AlertDialog.Builder alert = new AlertDialog.Builder(new ContextThemeWrapper(getActivity(), R.style.LoginTheme));
alert.setTitle(R.string.login_site_address_help_title);

//noinspection InflateParams
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Patterns;
import android.view.ContextThemeWrapper;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
Expand All @@ -28,7 +29,6 @@
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.common.api.GoogleApiClient.ConnectionCallbacks;
import com.google.android.gms.common.api.GoogleApiClient.OnConnectionFailedListener;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;

import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
Expand Down Expand Up @@ -232,7 +232,7 @@ public void onTextChanged(CharSequence s, int start, int before, int count) {
}

protected void showErrorDialog(String message) {
AlertDialog dialog = new MaterialAlertDialogBuilder(getActivity())
AlertDialog dialog = new AlertDialog.Builder(new ContextThemeWrapper(getActivity(), R.style.LoginTheme))
.setMessage(message)
.setPositiveButton(R.string.login_error_button, null)
.create();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
Expand All @@ -19,8 +20,6 @@
import androidx.appcompat.widget.Toolbar;
import androidx.fragment.app.Fragment;

import com.google.android.material.dialog.MaterialAlertDialogBuilder;

import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import org.wordpress.android.fluxc.Dispatcher;
Expand Down Expand Up @@ -232,7 +231,7 @@ public void onClick(DialogInterface dialog, int which) {
}
};

AlertDialog dialog = new MaterialAlertDialogBuilder(getActivity())
AlertDialog dialog = new AlertDialog.Builder(new ContextThemeWrapper(getActivity(), R.style.LoginTheme))
.setMessage(message)
.setNegativeButton(R.string.signup_magic_link_error_button_negative, dialogListener)
.setPositiveButton(R.string.signup_magic_link_error_button_positive, dialogListener)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
import org.wordpress.android.login.R;

public class WPBottomSheetDialogFragment extends BottomSheetDialogFragment {
@Override
public int getTheme() {
return R.style.LoginTheme_BottomSheetDialogStyle;
}

@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package org.wordpress.android.login.widgets;

import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.TypedArray;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
import android.os.Parcel;
Expand All @@ -10,12 +13,16 @@
import android.util.AttributeSet;
import android.util.SparseArray;
import android.view.KeyEvent;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import androidx.core.graphics.drawable.DrawableCompat;

import com.google.android.material.textfield.TextInputLayout;

Expand All @@ -31,9 +38,14 @@ public interface OnEditorCommitListener {
void onEditorCommit();
}

private ImageView mIcon;
private TextInputLayout mTextInputLayout;
private EditText mEditText;

public ImageView getIcon() {
return mIcon;
}

public EditText getEditText() {
return mEditText;
}
Expand All @@ -56,13 +68,35 @@ public WPLoginInputRow(Context context, AttributeSet attrs, int defStyle) {
private void init(Context context, AttributeSet attrs) {
inflate(context, R.layout.login_input_row, this);

mIcon = findViewById(R.id.icon);
mTextInputLayout = findViewById(R.id.input_layout);
mEditText = findViewById(R.id.input);

if (attrs != null) {
TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.wpLoginInputRow, 0, 0);

try {
if (a.hasValue(R.styleable.wpLoginInputRow_wpIconDrawable)) {
int iconResId = a.getResourceId(R.styleable.wpLoginInputRow_wpIconDrawable,
R.drawable.ic_user_grey_24dp);
int tintResId = a.getResourceId(R.styleable.wpLoginInputRow_wpIconDrawableTint,
R.color.login_input_icon_color);

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
mIcon.setImageTintList(ColorStateList.valueOf(ContextCompat.getColor(context, tintResId)));
mIcon.setImageResource(iconResId);
} else {
Drawable drawable = context.getResources().getDrawable(iconResId);
DrawableCompat.setTint(drawable, context.getResources().getColor(tintResId));
DrawableCompat.setTintMode(drawable, PorterDuff.Mode.SRC_IN);
mIcon.setImageDrawable(drawable);
}

mIcon.setVisibility(View.VISIBLE);
} else {
mIcon.setVisibility(View.GONE);
}

if (a.hasValue(R.styleable.wpLoginInputRow_android_inputType)) {
mEditText.setInputType(a.getInteger(R.styleable.wpLoginInputRow_android_inputType, 0));
}
Expand All @@ -78,11 +112,16 @@ private void init(Context context, AttributeSet attrs) {
// Makes the hint transparent, so the TalkBack can read it, when the field is prefilled
mEditText.setHintTextColor(getResources().getColor(android.R.color.transparent));
}

if (a.hasValue(R.styleable.wpLoginInputRow_passwordToggleEnabled)) {
mTextInputLayout.setPasswordVisibilityToggleEnabled(
a.getBoolean(R.styleable.wpLoginInputRow_passwordToggleEnabled, false));
}

if (a.hasValue(R.styleable.wpLoginInputRow_passwordToggleTint)) {
mTextInputLayout.setPasswordVisibilityToggleTintList(
a.getColorStateList(R.styleable.wpLoginInputRow_passwordToggleTint));
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
if (a.hasValue(R.styleable.wpLoginInputRow_android_textAlignment)) {
mEditText.setTextAlignment(
Expand Down Expand Up @@ -145,8 +184,8 @@ public void setOnEditorCommitListener(final OnEditorCommitListener listener) {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_DONE
|| actionId == EditorInfo.IME_ACTION_NEXT
|| (event != null
|| actionId == EditorInfo.IME_ACTION_NEXT
|| (event != null
&& event.getAction() == KeyEvent.ACTION_UP
&& event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) {
listener.onEditorCommit();
Expand Down
Loading

0 comments on commit 7244b9e

Please sign in to comment.