FirebaseUI 登录方向



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

有趣的是,初始屏幕保持纵向,之后直接进入横向模式。我找不到错误,请帮忙。

<?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

   <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>

我的登录激活

公共类 SignInActivity 扩展了 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上设置方向是不可能的。

相关内容

  • 没有找到相关文章

最新更新