Commit 3671697f authored by Tiago Cunha's avatar Tiago Cunha

Some work on interfaces

parent 349f73a3
...@@ -5,11 +5,12 @@ import android.support.annotation.Nullable; ...@@ -5,11 +5,12 @@ import android.support.annotation.Nullable;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import chat.rocket.android.R; import chat.rocket.android.R;
import chat.rocket.android.activity.LoginActivity;
import chat.rocket.android.fragment.AbstractFragment; import chat.rocket.android.fragment.AbstractFragment;
import chat.rocket.android.helper.TextUtils; import chat.rocket.android.helper.TextUtils;
abstract class AbstractServerConfigFragment extends AbstractFragment { abstract class AbstractServerConfigFragment extends AbstractFragment {
public static final String KEY_HOSTNAME = "hostname";
protected String hostname; protected String hostname;
@Override @Override
...@@ -22,7 +23,7 @@ abstract class AbstractServerConfigFragment extends AbstractFragment { ...@@ -22,7 +23,7 @@ abstract class AbstractServerConfigFragment extends AbstractFragment {
return; return;
} }
hostname = args.getString(LoginActivity.KEY_HOSTNAME); hostname = args.getString(KEY_HOSTNAME);
if (TextUtils.isEmpty(hostname)) { if (TextUtils.isEmpty(hostname)) {
finish(); finish();
} }
......
...@@ -55,7 +55,7 @@ public class LoginFragment extends AbstractServerConfigFragment implements Login ...@@ -55,7 +55,7 @@ public class LoginFragment extends AbstractServerConfigFragment implements Login
final View btnUserRegistration = rootView.findViewById(R.id.btn_user_registration); final View btnUserRegistration = rootView.findViewById(R.id.btn_user_registration);
btnUserRegistration.setOnClickListener(view -> UserRegistrationDialogFragment.create(hostname, btnUserRegistration.setOnClickListener(view -> UserRegistrationDialogFragment.create(hostname,
txtUsername.getText().toString(), txtPasswd.getText().toString()) txtUsername.getText().toString(), txtPasswd.getText().toString())
.show(getFragmentManager(), UserRegistrationDialogFragment.class.getSimpleName())); .show(getFragmentManager(), "UserRegistrationDialogFragment"));
} }
@Override @Override
...@@ -117,7 +117,7 @@ public class LoginFragment extends AbstractServerConfigFragment implements Login ...@@ -117,7 +117,7 @@ public class LoginFragment extends AbstractServerConfigFragment implements Login
@Override @Override
public void showTwoStepAuth() { public void showTwoStepAuth() {
// showFragmentWithBackStack(TwoStepAuthFragment.create(hostname));
} }
@Override @Override
......
package chat.rocket.android.fragment.server_config;
import chat.rocket.android.shared.BaseContract;
public interface TwoStepAuthContract {
interface View extends BaseContract.View {
void showLoading();
void hideLoading();
void showError(String message);
}
interface Presenter extends BaseContract.Presenter<View> {
void onCode(String twoStepAuthCode);
}
}
package chat.rocket.android.fragment.server_config;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import chat.rocket.android.R;
public class TwoStepAuthFragment extends AbstractServerConfigFragment
implements TwoStepAuthContract.View {
private View waitingView;
private TwoStepAuthContract.Presenter presenter;
public static TwoStepAuthFragment create(String hostname) {
Bundle args = new Bundle();
args.putString(AbstractServerConfigFragment.KEY_HOSTNAME, hostname);
TwoStepAuthFragment fragment = new TwoStepAuthFragment();
fragment.setArguments(args);
return fragment;
}
@Override
public void showLoading() {
}
@Override
public void hideLoading() {
}
@Override
public void showError(String message) {
}
@Override
protected int getLayout() {
return R.layout.fragment_two_step_auth;
}
@Override
protected void onSetupView() {
waitingView = rootView.findViewById(R.id.waiting);
final TextView twoStepCodeTextView = (TextView) rootView.findViewById(R.id.two_step_code);
final View submit = rootView.findViewById(R.id.btn_two_step_login);
submit.setOnClickListener(view -> {});
}
}
package chat.rocket.android.fragment.server_config;
import chat.rocket.android.shared.BasePresenter;
public class TwoStepAuthPresenter extends BasePresenter<TwoStepAuthContract.View>
implements TwoStepAuthContract.Presenter {
@Override
public void onCode(String twoStepAuthCode) {
}
}
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/colorPrimaryDark">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@color/white"
android:minWidth="288dp"
android:orientation="vertical"
android:padding="@dimen/margin_24">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
style="@style/Base.TextAppearance.AppCompat.Large"
android:text="@string/two_factor_authentication_title" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/Base.TextAppearance.AppCompat.Body1"
android:text="@string/open_your_authentication_app_and_enter_the_code" />
<android.support.design.widget.TextInputLayout
android:id="@+id/text_input_two_step_code"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.TextInputEditText
android:id="@+id/two_step_code"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/two_factor_code"
android:imeOptions="actionNext"
android:inputType="textWebEmailAddress"
android:maxLines="1" />
</android.support.design.widget.TextInputLayout>
<Space
android:layout_width="wrap_content"
android:layout_height="@dimen/margin_16" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/btn_two_step_login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
app:elevation="2dp"
app:fabSize="normal"
app:srcCompat="@drawable/ic_arrow_forward_white_24dp" />
<chat.rocket.android.widget.WaitingView
android:id="@+id/waiting"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:visibility="gone" />
</LinearLayout>
</FrameLayout>
\ No newline at end of file
...@@ -47,4 +47,7 @@ ...@@ -47,4 +47,7 @@
<string name="connection_error_try_later">There\'s a connection error. Please try later.</string> <string name="connection_error_try_later">There\'s a connection error. Please try later.</string>
<string name="version_info_text">Version: %s</string> <string name="version_info_text">Version: %s</string>
<string name="two_factor_authentication_title">Two-factor authentication</string>
<string name="open_your_authentication_app_and_enter_the_code">Open your authentication app and enter the code</string>
<string name="two_factor_code">Two-factor code</string>
</resources> </resources>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment