diff --git a/source-code/app/src/main/java/org/buildmlearn/toolkit/activity/FirstRunActivity.java b/source-code/app/src/main/java/org/buildmlearn/toolkit/activity/FirstRunActivity.java index eeb49d34..150f6058 100644 --- a/source-code/app/src/main/java/org/buildmlearn/toolkit/activity/FirstRunActivity.java +++ b/source-code/app/src/main/java/org/buildmlearn/toolkit/activity/FirstRunActivity.java @@ -10,7 +10,7 @@ import android.view.animation.Animation; import android.view.animation.AnimationUtils; import android.widget.EditText; - +import android.widget.Button; import com.crashlytics.android.Crashlytics; @@ -44,11 +44,37 @@ protected void onCreate(Bundle savedInstanceState) { } setContentView(R.layout.activity_first_run); - findViewById(R.id.focus_thief).clearFocus(); - Animation animBounceinup=AnimationUtils.loadAnimation(getBaseContext(),R.anim.bounceinup); + Animation anim_bounceinup=AnimationUtils.loadAnimation(getBaseContext(),R.anim.bounceinup); name = (EditText) findViewById(R.id.first_name); - name.startAnimation(animBounceinup); + Button button = (Button) findViewById(R.id.ok_button); + name.startAnimation(anim_bounceinup); + button.startAnimation(anim_bounceinup); + button.setOnClickListener(new View.OnClickListener() { + public void onClick(View v) { + + if (name.getText().toString().equals("")) { + name.setError(getApplicationContext().getResources().getString(R.string.enter_name)); + } + else if(!Character.isLetterOrDigit(name.getText().toString().charAt(0))) + { + name.setError(getApplicationContext().getResources().getString(R.string.valid_msg)); + } + + + SharedPreferences.Editor editor = prefs.edit(); + + editor.putString(getString(R.string.key_user_name), name.getText().toString()); + editor.putBoolean(FIRST_RUN, true); + editor.apply(); + Intent intent = new Intent(getApplicationContext(), TutorialActivity.class); + intent.putExtra(Constants.START_ACTIVITY, true); + startActivity(intent); + finish(); + + } + }); + name.setOnKeyListener(new View.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { diff --git a/source-code/app/src/main/res/layout/activity_first_run.xml b/source-code/app/src/main/res/layout/activity_first_run.xml index 884e9564..2025e549 100644 --- a/source-code/app/src/main/res/layout/activity_first_run.xml +++ b/source-code/app/src/main/res/layout/activity_first_run.xml @@ -18,7 +18,8 @@ android:layout_height="wrap_content" android:layout_centerInParent="true" android:gravity="center" - android:orientation="vertical"> + android:orientation="vertical" + android:weightSum="1"> +