forked from organicmaps/organicmaps
[android] Phone auth review fixes + server integration fixes
This commit is contained in:
parent
cd8c347fd5
commit
4a13f0624f
6 changed files with 15 additions and 16 deletions
|
@ -392,7 +392,6 @@
|
|||
android:value="com.mapswithme.maps.MwmActivity"/>
|
||||
</activity>
|
||||
|
||||
<!-- facebook -->
|
||||
<activity
|
||||
android:name="com.facebook.FacebookActivity"
|
||||
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
|
||||
|
@ -409,11 +408,10 @@
|
|||
<data android:scheme="@string/fb_login_protocol_scheme"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<!-- authorisation by phone number-->
|
||||
|
||||
<activity
|
||||
android:name="com.mapswithme.maps.auth.PhoneAuthActivity"
|
||||
android:configChanges="orientation|screenLayout|screenSize|keyboardHidden"
|
||||
android:windowSoftInputMode="adjustResize"
|
||||
android:label="@string/authorization_button_sign_in"/>
|
||||
|
||||
<activity android:name="com.mopub.common.MoPubBrowser" android:configChanges="keyboardHidden|orientation|screenSize"/>
|
||||
|
|
|
@ -40,7 +40,8 @@
|
|||
<TextView
|
||||
android:id="@+id/phone_button"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/height_primary_button"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="@dimen/height_primary_button"
|
||||
android:layout_marginTop="@dimen/margin_base"
|
||||
android:textAppearance="@style/MwmTextAppearance.Button"
|
||||
android:textColor="?accentButtonTextColor"
|
||||
|
|
|
@ -11,7 +11,7 @@ import com.mapswithme.maps.base.OnBackPressListener;
|
|||
|
||||
public class PhoneAuthActivity extends BaseMwmExtraTitleActivity
|
||||
{
|
||||
public static void start(@NonNull Fragment fragment)
|
||||
public static void startForResult(@NonNull Fragment fragment)
|
||||
{
|
||||
final Intent i = new Intent(fragment.getContext(), PhoneAuthActivity.class);
|
||||
i.putExtra(EXTRA_TITLE, fragment.getString(R.string.authorization_button_sign_in));
|
||||
|
|
|
@ -6,6 +6,7 @@ import android.content.Intent;
|
|||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -20,7 +21,7 @@ import com.mapswithme.util.UiUtils;
|
|||
|
||||
public class PhoneAuthFragment extends BaseMwmFragment implements OnBackPressListener
|
||||
{
|
||||
private static final String REDIRECT_URL = "https://localhost/";
|
||||
private static final String REDIRECT_URL = "http://localhost";
|
||||
|
||||
@SuppressWarnings("NullableProblems")
|
||||
@NonNull
|
||||
|
@ -43,9 +44,6 @@ public class PhoneAuthFragment extends BaseMwmFragment implements OnBackPressLis
|
|||
{
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
if (savedInstanceState != null)
|
||||
return;
|
||||
|
||||
mWebView = view.findViewById(R.id.webview);
|
||||
mProgress = view.findViewById(R.id.progress);
|
||||
mWebView.setWebViewClient(new WebViewClient()
|
||||
|
@ -60,11 +58,11 @@ public class PhoneAuthFragment extends BaseMwmFragment implements OnBackPressLis
|
|||
@Override
|
||||
public boolean shouldOverrideUrlLoading(WebView view, String url)
|
||||
{
|
||||
if (url.contains(REDIRECT_URL + "?code="))
|
||||
if (!TextUtils.isEmpty(url) && url.contains(REDIRECT_URL + "/?code="))
|
||||
{
|
||||
Intent returnIntent = new Intent();
|
||||
returnIntent.putExtra(Constants.EXTRA_PHONE_AUTH_TOKEN,
|
||||
url.substring((REDIRECT_URL + "?code=").length()));
|
||||
url.substring((REDIRECT_URL + "/?code=").length()));
|
||||
|
||||
getActivity().setResult(Activity.RESULT_OK, returnIntent);
|
||||
getActivity().finish();
|
||||
|
|
|
@ -43,7 +43,7 @@ public class SocialAuthDialogFragment extends BaseMwmDialogFragment
|
|||
@NonNull
|
||||
private final View.OnClickListener mPhoneClickListener = (View v) ->
|
||||
{
|
||||
PhoneAuthActivity.start(this);
|
||||
PhoneAuthActivity.startForResult(this);
|
||||
};
|
||||
|
||||
@NonNull
|
||||
|
@ -126,9 +126,11 @@ public class SocialAuthDialogFragment extends BaseMwmDialogFragment
|
|||
String token = mPhoneAuthToken;
|
||||
|
||||
@Framework.AuthTokenType
|
||||
int tokenType = token != null ? Framework.SOCIAL_TOKEN_PHONE : Framework.SOCIAL_TOKEN_FACEBOOK;
|
||||
int tokenType = !TextUtils.isEmpty(token) ?
|
||||
Framework.SOCIAL_TOKEN_PHONE :
|
||||
Framework.SOCIAL_TOKEN_FACEBOOK;
|
||||
|
||||
if (token == null)
|
||||
if (TextUtils.isEmpty(token))
|
||||
{
|
||||
AccessToken facebookToken = AccessToken.getCurrentAccessToken();
|
||||
token = facebookToken != null ? facebookToken.getToken() : null;
|
||||
|
|
|
@ -138,7 +138,7 @@ struct PhoneAuthRequestData
|
|||
std::string m_code;
|
||||
|
||||
explicit PhoneAuthRequestData(std::string const & code)
|
||||
: m_cliendId("phone_device_app")
|
||||
: m_cliendId(kAppName)
|
||||
, m_code(code)
|
||||
{}
|
||||
|
||||
|
@ -405,7 +405,7 @@ std::string User::GetPhoneAuthUrl(std::string const & redirectUri)
|
|||
{
|
||||
std::ostringstream os;
|
||||
os << kPassportServerUrl << "/oauth/authorize/?mode=phone_device&response_type=code"
|
||||
<< "&locale=" << languages::GetCurrentNorm() << "&redirect_uri=" << UrlEncode(redirectUri)
|
||||
<< "&locale=" << languages::GetCurrentOrig() << "&redirect_uri=" << UrlEncode(redirectUri)
|
||||
<< "&client_id=" << kAppName;
|
||||
|
||||
return os.str();
|
||||
|
|
Loading…
Add table
Reference in a new issue