Skip to content

Commit

Permalink
Resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
Florian Ravasi committed Nov 16, 2018
2 parents e2fbce5 + 82f1cc9 commit 6c3fbc9
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 14 deletions.
@@ -1,5 +1,7 @@
package ch.epfl.sweng.studyup;

import android.app.AlertDialog;
import android.support.design.widget.BottomNavigationView;
import android.support.test.espresso.intent.Intents;
import android.support.test.rule.ActivityTestRule;
import android.support.test.rule.GrantPermissionRule;
Expand All @@ -18,9 +20,13 @@

import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.intent.Intents.intended;
import static android.support.test.espresso.intent.matcher.IntentMatchers.hasComponent;
import static android.support.test.espresso.matcher.RootMatchers.isDialog;
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;
import static ch.epfl.sweng.studyup.utils.Constants.PERSIST_LOGIN_FILENAME;
import static org.junit.Assert.assertTrue;

Expand Down Expand Up @@ -65,4 +71,16 @@ public void closeButtonTest() {
onView(withId(R.id.back_button)).perform(click());
TestCase.assertTrue(mActivityRule.getActivity().isFinishing());
}

@Test
public void testLanguageChoosingPopup() {
onView(withId(R.id.languageChoiceButton)).perform(click());
onView(withText(R.string.cancel))
.inRoot(isDialog())
.check(matches(isDisplayed()))
.perform(click());

//If all worked, we could close the settings
onView(withId(R.id.back_button)).perform(click());
}
}
21 changes: 21 additions & 0 deletions app/src/main/java/ch/epfl/sweng/studyup/SettingsActivity.java
@@ -1,15 +1,19 @@
package ch.epfl.sweng.studyup;

import android.app.AlertDialog;
import android.app.job.JobScheduler;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.Toast;

import ch.epfl.sweng.studyup.map.BackgroundLocation;
import ch.epfl.sweng.studyup.utils.Constants;
import ch.epfl.sweng.studyup.utils.RefreshContext;

import static ch.epfl.sweng.studyup.MainActivity.clearCacheToLogOut;
Expand All @@ -29,6 +33,23 @@ public void onLogoutClick(View view) {
startActivity(intent);
}

public void onLanguageChoiceClick(View view) {
AlertDialog.Builder languageChoiceBuilder = new AlertDialog.Builder(this);
languageChoiceBuilder.setTitle(R.string.language_title_alert_dialog);
languageChoiceBuilder.setItems(Constants.LANGUAGES, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if(which == 0) {
Toast.makeText(SettingsActivity.this, "Damn you're english !", Toast.LENGTH_SHORT).show();
} else if(which == 1) {
Toast.makeText(SettingsActivity.this, "Omelette du fromage", Toast.LENGTH_SHORT).show();
}
}
});
languageChoiceBuilder.setNegativeButton(R.string.cancel, null);
languageChoiceBuilder.create().show();
}

public void onBackButton(View view) {
finish();
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/ch/epfl/sweng/studyup/utils/Constants.java
Expand Up @@ -88,6 +88,8 @@ public class Constants {
public static final int MAIN_INDEX=0, QUESTS_INDEX_STUDENT =1, SHOP_INDEX=2, MAP_INDEX=3, INVENTORY_INDEX =4, DEFAULT_INDEX_STUDENT=MAIN_INDEX;
public static final int ADD_QUESTION_INDEX=0, QUESTS_INDEX_TEACHER=1, DEFAULT_INDEX_TEACHER=ADD_QUESTION_INDEX;

//Settings constants
public static final String[] LANGUAGES = {"English", "Français"};
// Enums for Role, Course
public enum Role {
student,
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
61 changes: 48 additions & 13 deletions app/src/main/res/layout/activity_settings.xml
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
Expand All @@ -11,9 +10,9 @@
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:ignore="MissingConstraints"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="0dp"
tools:ignore="MissingConstraints">
tools:layout_editor_absoluteY="0dp">


<!--TOP TOOL BAR-->
Expand Down Expand Up @@ -53,10 +52,10 @@
android:id="@+id/textSettings"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:text="@string/textViewSettings"
android:textColor="@color/colorGreyBlack"
android:textSize="28sp"
Expand Down Expand Up @@ -100,31 +99,30 @@
android:id="@+id/logoutbutton"
android:layout_width="match_parent"
android:layout_height="26dp"
android:layout_marginBottom="8dp"
android:layout_marginEnd="12dp"
android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
android:layout_marginEnd="12dp"
android:layout_marginBottom="12dp"
android:background="@color/colorWhite"
android:scaleType="fitStart"
android:onClick="onLogoutClick"
app:layout_constraintBottom_toBottomOf="parent"
android:scaleType="fitStart"
app:layout_constraintBottom_toTopOf="@+id/languageChoiceButton"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="1.0"
app:srcCompat="@drawable/ic_logout_black_24dp"
tools:ignore="ContentDescription" />

<TextView
android:id="@+id/textLogoutButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:text="@string/log_out"
android:textColor="@color/colorGreyBlack"
android:textSize="18sp"
android:textSize="22sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="@+id/logoutbutton"
app:layout_constraintEnd_toEndOf="@+id/logoutbutton"
Expand All @@ -133,6 +131,43 @@
app:layout_constraintTop_toTopOf="@+id/logoutbutton"
app:layout_constraintVertical_bias="0.0" />

<ImageButton
android:id="@+id/languageChoiceButton"
android:layout_width="match_parent"
android:layout_height="32dp"
android:layout_marginBottom="8dp"
android:layout_marginEnd="12dp"
android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
android:background="@color/colorWhite"
android:onClick="onLanguageChoiceClick"
android:scaleType="fitStart"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/logoutbutton"
app:srcCompat="@drawable/settings_language_choice_icon"
tools:ignore="ContentDescription" />

<TextView
android:id="@+id/textLanguageButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="28dp"
android:text="@string/language_choice_settings_button"
android:textColor="@color/colorGreyBlack"
android:textSize="22sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="@+id/languageChoiceButton"
app:layout_constraintEnd_toEndOf="@+id/languageChoiceButton"
app:layout_constraintHorizontal_bias="0.159"
app:layout_constraintStart_toStartOf="@+id/languageChoiceButton"
app:layout_constraintTop_toTopOf="@+id/languageChoiceButton"
app:layout_constraintVertical_bias="0.0" />

</android.support.constraint.ConstraintLayout>


Expand Down
4 changes: 3 additions & 1 deletion app/src/main/res/values/strings.xml
Expand Up @@ -65,6 +65,8 @@
<string name="title_activity_settings">Settings</string>
<string name="textViewSettings">Settings</string>
<string name="toast_text_infos_are_coming">Infos are coming soon</string>
<string name="language_default">English</string>
<string name="language_choice_settings_button">Choose your language</string>
<string name="language_title_alert_dialog">Languages</string>
<string name="cancel">Cancel</string>

</resources>

0 comments on commit 6c3fbc9

Please sign in to comment.