Skip to content

Commit e1c7562

Browse files
DPigeonDPigeon
authored andcommitted
Fixing profile language
1 parent 848b433 commit e1c7562

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

app/src/main/java/com/ctext/MainActivity.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ else if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL)
288288
view.getContext().getDrawable(R.drawable.user_profile).clearColorFilter();
289289
view.invalidate();
290290
// Go to the profile activity with a nice slide animation
291-
goToActivity(ProfileActivity.class);
291+
goToProfileActivity(ProfileActivity.class, "no");
292292
}
293293

294294
return true;
@@ -653,7 +653,7 @@ protected void loadProfile() {
653653
if (outputLang != -1)
654654
setOutputLanguage(outputLang);
655655
} else {
656-
goToActivity(ProfileActivity.class);
656+
goToProfileActivity(ProfileActivity.class, "yes");
657657
Toast.makeText(getApplicationContext(), "Create your profile!", Toast.LENGTH_LONG).show();
658658
}
659659
}
@@ -682,10 +682,11 @@ public static int getScreenHeight() {
682682
return Resources.getSystem().getDisplayMetrics().heightPixels;
683683
}
684684

685-
void goToActivity(Class activity) { // Function that goes from the main activity to another one
685+
void goToProfileActivity(Class activity, String firstTime) { // Function that goes from the main activity to profile one
686686
Intent intent = new Intent(MainActivity.this, activity);
687687
intent.putExtra("lensFacing", lensFacing);
688688
intent.putExtra("mode", currentMode.ordinal());
689+
intent.putExtra("firstTime", firstTime);
689690
startActivity(intent);
690691
}
691692

app/src/main/java/com/ctext/ProfileActivity.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public boolean onCreateOptionsMenu(Menu menu) { // Creates the three dot action
5959
@Override
6060
public boolean onOptionsItemSelected(MenuItem item) {
6161
int menuId = item.getItemId();
62-
if(menuId == R.id.profile_settings) { // If we click on the ... button
62+
if (menuId == R.id.profile_settings) { // If we click on the ... button
6363
switchMode(true, View.VISIBLE); // Switch to edit mode
6464
}
6565
return super.onOptionsItemSelected(item);
@@ -99,7 +99,9 @@ protected void addRadioButtons(String languages, int i) {
9999
}
100100

101101
protected void setActivityFields() {
102-
if (sharedPreferenceHelper.getProfile().getLanguage() == -1) { // Info does not exist
102+
Intent intent = getIntent();
103+
String firstTime = intent.getStringExtra("firstTime");
104+
if (firstTime.equals("yes")) { // If first time launching app
103105
switchMode(true, View.VISIBLE); // Switch to the edit mode
104106
}
105107
else {
@@ -134,7 +136,7 @@ protected void saveProfile() {
134136
toastMessage("Your profile has been saved!");
135137
goToActivity(MainActivity.class);
136138
} else
137-
toastMessage("An error occured while saving your profile!");
139+
toastMessage("You must choose a language!");
138140
}
139141

140142
protected void toastMessage(String message) { // Shows a toast message

0 commit comments

Comments
 (0)