I have an Activity
called AuthActivity and I would like all of my authentication Fragments
to be in this Activity
. I will have 4 Fragments
: LoginFragment, RegisterFragment, ForgotPasswordFragment and RememberedLoginFragment. I currently only have the LoginFragment and I would like some feedback before I continue making the others. I would like some feedback on all of the code, Java and XML.
fragment_login.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/fragment_login"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<View
android:id="@+id/loginTopView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="@color/colorPrimary" />
<RelativeLayout
android:id="@+id/loginCenterView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="5"
android:background="@color/colorAccent">
<ImageView
android:id="@+id/loginLogo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="@drawable/ic_logo"
android:contentDescription="@string/logo" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/loginBottomView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="10"
android:padding="15dp"
android:background="@color/colorPrimary">
<EditText
android:id="@+id/loginEmail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:hint="@string/email"
android:inputType="textEmailAddress"
android:textColor="@android:color/white"
android:textColorHint="#AAFFFFFF" />
<EditText
android:id="@+id/loginPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/loginEmail"
android:hint="@string/password"
android:inputType="textPassword"
android:textColor="@android:color/white"
android:textColorHint="#AAFFFFFF" />
<CheckBox
android:id="@+id/loginRememberMe"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/loginPassword"
android:text="@string/remember_me" />
<CheckBox
android:id="@+id/loginStayLoggedIn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/loginRememberMe"
android:text="@string/stay_logged_in" />
<Button
android:id="@+id/loginButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/loginStayLoggedIn"
android:text="@string/login"
android:textAllCaps="false" />
<TextView
android:id="@+id/loginForgotPassword"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/loginButton"
android:layout_centerHorizontal="true"
android:textColor="@android:color/white"
android:text="@string/forgot_password" />
<TextView
android:id="@+id/loginRegisterLink"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:textColor="@android:color/white"
android:text="@string/register_link_text" />
</RelativeLayout>
</LinearLayout>
LoginFragment.java:
public class LoginFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_login, container, false);
}
}
activity_auth.xml:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/activity_auth"
android:layout_width="match_parent"
android:layout_height="match_parent" />
AuthActivity.java:
public class AuthActivity extends FragmentActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_auth);
if (savedInstanceState != null) {
return;
}
LoginFragment loginFragment = new LoginFragment();
loginFragment.setArguments(getIntent().getExtras());
getSupportFragmentManager().beginTransaction().add(R.id.activity_auth, loginFragment).commit();