FirebaseUI登录方向 [英] FirebaseUI login orientation

查看:83
本文介绍了FirebaseUI登录方向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用FirebaseUI进行登录. 无论我如何尝试,都无法使登录屏幕保持纵向模式.我在这里做错了什么?我怀疑这是清单中的东西.

I'm using FirebaseUI for login. I can't make the login screen remain in portrait mode no matter what I try. What am I doing wrong here? I suspect it's something in the Manifest.

有趣的是,启动画面保持竖屏显示,此后立即进入横向模式.我找不到错误,请帮忙.

Interestingly, the Splash Screen remains in portrait, and goes to landscape mode straight after that. I can't find the mistake, please help.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.r3dm4n.abc">

<uses-permission android:name="android.permission.INTERNET" />

<application
    android:name=".app.AppController"
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:configChanges="keyboardHidden|orientation"
    android:screenOrientation="portrait"
    android:theme="@style/AppTheme">
    <activity android:name=".activities.MainActivity">
        <intent-filter>
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <activity
        android:name=".activities.SignInActivity"
        android:configChanges="keyboardHidden|orientation"
        android:screenOrientation="portrait"
        android:theme="@style/FirebaseLoginTheme">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>

    </activity>

    <meta-data
        android:name="com.facebook.sdk.ApplicationId"

        android:value="@string/facebook_app_id" />
    <meta-data
        android:name="com.google.android.geo.API_KEY"
        android:value="@string/google_maps_key" />


    <service android:name=".app.MyFirebaseMessagingService">
        <intent-filter>
            <action android:name="com.google.firebase.MESSAGING_EVENT" />
        </intent-filter>

        <meta-data
            android:name="com.google.firebase.messaging.default_notification_icon"
            android:resource="@drawable/launch_logo" />
        <meta-data
            android:name="com.google.firebase.messaging.default_notification_color"
            android:resource="@color/colorPrimaryDark" />
    </service>
</application>
</manifest>

FirebaseLoginTheme

FirebaseLoginTheme

   <style name="FirebaseLoginTheme" parent="FirebaseUI">
    <item name="android:screenOrientation">portrait</item>
    <item name="windowNoTitle">true</item>
    <item name="windowActionBar">false</item>
    <item name="android:windowFullscreen">true</item>
    <item name="android:windowContentOverlay">@null</item>
    <item name="android:windowBackground">@drawable/login</item>
    <item name="colorControlNormal">@color/colorWhite</item>
    <item name="colorControlActivated">@color/colorWhite</item>
    <item name="colorControlHighlight">@color/colorWhite</item>
    <item name="android:textColor">@color/colorWhite</item>

</style>

我的SignInActivty

My SignInActivty

公共类SignInActivity扩展了AppCompatActivity {

public class SignInActivity extends AppCompatActivity {

public static final int RC_SIGN_IN = 1337;
private DatabaseReference mDatabase;
private FirebaseAuth mAuth;
private FirebaseAuth.AuthStateListener mAuthStateListener;
private FirebaseUser firebaseUser;
private AccessToken accessToken;


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mDatabase = FirebaseDatabase.getInstance().getReference();
    mDatabase.keepSynced(true);

    mAuth = FirebaseAuth.getInstance();
    mAuthStateListener = new FirebaseAuth.AuthStateListener() {
        @Override
        public void onAuthStateChanged(@NonNull FirebaseAuth mAuth) {
            firebaseUser = mAuth.getCurrentUser();
            if (firebaseUser != null) {
                //signed in
                Intent intent = new Intent(SignInActivity.this, MainActivity.class);
                startActivity(intent);

            } else {
                //signed out
                startActivityForResult(
                        AuthUI.getInstance()
                                .createSignInIntentBuilder()
                                .setTheme(R.style.FirebaseLoginTheme)
                                .setLogo(R.drawable.firebaselogo)
                                .setProviders(Arrays.asList(
                                        new AuthUI.IdpConfig.Builder(AuthUI.GOOGLE_PROVIDER).build(),
                                        new AuthUI.IdpConfig.Builder(AuthUI.FACEBOOK_PROVIDER).build(),
                                        new AuthUI.IdpConfig.Builder(AuthUI.EMAIL_PROVIDER).build()))
                                .setIsSmartLockEnabled(false)
                                .build(),
                        RC_SIGN_IN);
            }
        }
    };
}


protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == RC_SIGN_IN) {
        if (resultCode == RESULT_OK) {
            startActivity(new Intent(this, MainActivity.class));
            firebaseUser = FirebaseAuth.getInstance().getCurrentUser();
            accessToken = AccessToken.getCurrentAccessToken();
            addToDatabase();
            finish();
            return;
        }

        // Sign in canceled
        if (resultCode == RESULT_CANCELED) {
            showSnackbar("Sign in is required to use this app.");
            return;
        }

        // No network
        if (resultCode == ResultCodes.RESULT_NO_NETWORK) {
            showSnackbar("Conexiune internet inactiva");
            return;
        }
    }
}


@Override
protected void onPause() {
    super.onPause();
    mAuth.removeAuthStateListener(mAuthStateListener);
}

@Override
protected void onResume() {
    super.onResume();
    mAuth.addAuthStateListener(mAuthStateListener);
}
}

推荐答案

根据 Github帖子和一个,在FirebaseUI上设置方向不是可能的.

According to this Github post and this one, setting orientation on FirebaseUI is not possible.

这篇关于FirebaseUI登录方向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆