Permalink
Browse files

Added subjuntivo checkbox and scrollview, implemented Preterite

  • Loading branch information...
F1iX committed Nov 19, 2017
1 parent 79c77e1 commit 2a84d6a9dc367e1f2aec37951f7d14e432981bef
@@ -1,19 +1,23 @@
package me.keppler.conjugator;

import android.content.SharedPreferences;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.Editable;
import android.text.Html;
import android.text.TextWatcher;
import android.view.KeyEvent;
import android.view.inputmethod.EditorInfo;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.SeekBar;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {
int tenseId = 4;
String verb = "";
int tenseId;
String verb;
Boolean subjuntivo;

@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -51,6 +55,37 @@ public void onTextChanged(final CharSequence s, int start, int before, int count
public void afterTextChanged(final Editable s) {
}
});

final CheckBox sub = (CheckBox) findViewById(R.id.checkBox);
sub.setOnCheckedChangeListener(new CheckBox.OnCheckedChangeListener(){
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked){
subjuntivo = isChecked;
conjugate();
}
});

/* Get recent entries from shared preferences */
SharedPreferences prefs = getApplicationContext().getSharedPreferences("me.keppler.conjugator", android.content.Context.MODE_PRIVATE);
verb = prefs.getString("recentVerb", "");
tenseId = prefs.getInt("recentTenseId", 4);
subjuntivo = prefs.getBoolean("recentSubjuntivoCheckbox", false);

input.setText(verb); // Populate recent value
seek.setProgress(tenseId); // populate recent value
sub.setChecked(subjuntivo); // Populate recent value
}

@Override
protected void onPause() {
super.onPause();
/* Persist data by writing values to shared preferences*/
SharedPreferences prefs = getApplicationContext().getSharedPreferences("me.keppler.conjugator", android.content.Context.MODE_PRIVATE);
SharedPreferences.Editor editor = prefs.edit();
editor.putString("recentVerb", verb);
editor.putInt("recentTenseId", tenseId);
editor.putBoolean("recentSubjuntivoCheckbox", subjuntivo);
editor.apply();
}

void conjugate(){
@@ -62,63 +97,118 @@ void conjugate(){
, getString(R.string.p2)
, getString(R.string.p3)};

switch (tenseId) {
case 0:
tense = "Pretérito pluscuamperfecto";
example = "Yo había hablando = I had spoken";
if(verb.length() > 1) {
//forms = Pluperfect.get(verb);
}
break;
case 1:
tense = "Pretérito indefinido";
example = "Yo hablé = I spoke";
if(verb.length() > 1) {
//forms = PreteriteIndefinido.get(verb);
}
break;
case 2:
tense = "Pretérito imperfecto";
example = "Yo hablaba = I spoke";
if(verb.length() > 1) {
forms = Imperfect.get(verb);
}
break;
case 3:
tense = "Pretérito perfecto";
example = "Yo he hablando = I have spoken";
if(verb.length() > 1) {
forms = PresentPerfect.get(verb);
}
break;
case 4:
tense = "Presente";
example = "Yo hablo = I speak";
if(verb.length() > 1) {
forms = Present.get(verb);
}
break;
case 5:
tense = "Futuro proximo";
example = "Yo voy a hablar = I am going to speak";
if(verb.length() > 1) {
forms = GoingToFuture.get(verb);
}
break;
case 6:
tense = "Futuro simple";
example = "Yo hablaré = I will speak";
if(verb.length() > 1) {
forms = Future.get(verb);
}
break;
case 7:
tense = "Futuro perfecto";
example = "Yo habré hablando = I will have spoken";
if(verb.length() > 1) {
//forms = FuturePerfect.get(verb);
}
break;
if(subjuntivo){
// TODO: Subjuntivo forms
switch (tenseId) {
case 0:
tense = "Subjuntivo del pretérito pluscuamperfecto";
example = "...que yo hubiera hablado = ...that I had spoken";
if (verb.length() > 1) {
//forms = Pluperfect.get(verb);
}
break;
case 1:
tense = "Subjuntivo del pretérito pluscuamperfecto II";
example = "...que yo hubiese hablando = ...that I had spoken";
if (verb.length() > 1) {
//forms = PreteriteIndefinido.get(verb);
}
break;
case 2:
tense = "Subjuntivo del pretérito imperfecto";
example = "...que yo hablara = ...that I spoke";
if (verb.length() > 1) {
//forms = Imperfect.get(verb);
}
break;
case 3:
tense = "Subjuntivo del pretérito perfecto";
example = "...que yo haya hablado = ...that I have spoken";
if (verb.length() > 1) {
//forms = PresentPerfect.get(verb);
}
break;
case 4:
tense = "Subjuntivo del presente";
example = "...que yo hablo = ...that I speak";
if (verb.length() > 1) {
//forms = Present.get(verb);
}
break;
case 5:
tense = "Conditional";
example = "Yo hablaría = I would speak";
if (verb.length() > 1) {
//forms = GoingToFuture.get(verb);
}
break;
case 6:
tense = "Conditional perfect";
example = "Yo habría hablado = I would have spoken";
if (verb.length() > 1) {
//forms = Future.get(verb);
}
break;
}
} else {
switch (tenseId) {
case 0:
tense = "Pretérito pluscuamperfecto";
example = "Yo había hablando = I had spoken";
if (verb.length() > 1) {
//forms = Pluperfect.get(verb);
}
break;
case 1:
tense = "Pretérito indefinido";
example = "Yo hablé = I spoke (at a definite point of time)";
if (verb.length() > 1) {
forms = Preterite.get(verb);
}
break;
case 2:
tense = "Pretérito imperfecto";
example = "Yo hablaba = I spoke (without defined end)";
if (verb.length() > 1) {
forms = Imperfect.get(verb);
}
break;
case 3:
tense = "Pretérito perfecto";
example = "Yo he hablando = I have spoken";
if (verb.length() > 1) {
forms = PresentPerfect.get(verb);
}
break;
case 4:
tense = "Presente";
example = "Yo hablo = I speak";
if (verb.length() > 1) {
forms = Present.get(verb);
}
break;
case 5:
tense = "Futuro proximo";
example = "Yo voy a hablar = I am going to speak";
if (verb.length() > 1) {
forms = GoingToFuture.get(verb);
}
break;
case 6:
tense = "Futuro simple";
example = "Yo hablaré = I will speak";
if (verb.length() > 1) {
forms = Future.get(verb);
}
break;
case 7:
tense = "Futuro perfecto";
example = "Yo habré hablando = I will have spoken";
if (verb.length() > 1) {
//forms = FuturePerfect.get(verb);
}
break;
}
}

((TextView) findViewById(R.id.textViewTense)).setText(tense);
@@ -0,0 +1,114 @@
package me.keppler.conjugator;

/**
* Created by felix on 18/11/17.
*/

public class Preterite {
public static String[] get(String verb) {
String[] forms = new String[6];

// comer = to eat, compartir = to share
forms[0] = verb.substring(0, verb.length() - 2) + "í"; // Yo comí = I ate, Yo compartí = I shared
forms[1] = verb.substring(0, verb.length() - 2) + "iste"; // Tu comiste = You ate, Tu compartiste = You shared
forms[2] = verb.substring(0, verb.length() - 2) + ""; // Ella comió = She ate, El compartió = He shared
forms[3] = verb.substring(0, verb.length() - 2) + "imos"; // Nosotros comimos = We ate, Nosotros compartimos = We shared
forms[4] = verb.substring(0, verb.length() - 2) + "isteis"; // Vosotros comisteis = You ate, Vosotros compartisteis = You shared
forms[5] = verb.substring(0, verb.length() - 2) + "ieron"; // Ellos comieron = They ate, Ellas compartieron = They shared

if (verb.endsWith("ar")) { // hablar = to speak
forms[0] = verb.substring(0, verb.length() - 2) + "é"; // Yo hablé = I spoke
forms[1] = verb.substring(0, verb.length() - 2) + "aste"; // Tu hablaste = You spoke
forms[2] = verb.substring(0, verb.length() - 2) + "ó"; // El habló = He spoke
forms[3] = verb.substring(0, verb.length() - 2) + "amos"; // Nosotros hablamos = We spoke
forms[4] = verb.substring(0, verb.length() - 2) + "asteis"; // Vosotros hablasteis = You spoke
forms[5] = verb.substring(0, verb.length() - 2) + "aron"; // Ellos hablaron = They spoke
}

switch(verb){
case "andar": // to go
forms[0] = "anduve";
forms[1] = "anduviste";
forms[2] = "anduvo";
forms[3] = "anduvimos";
forms[4] = "anduvisteis";
forms[5] = "anduvieron";
break;
case "ir": // to go
case "ser": // to be
forms[0] = "fui"; // Yo fui allí ayer = I was there yesterday
forms[1] = "fuiste"; // Fuiste anoche = You were last night
forms[2] = "fue"; // El fue una vez = He was once
forms[3] = "fuimos"; // Nosotros fuimos hace dos meses = We were two months ago
forms[4] = "fuisteis"; // Vosotros fuisteis la semana pasada = You were last week
forms[5] = "fueron"; // Ellos fueron anoche = They were last night
break;
case "conducir": // to drive
forms[0] = "conduje"; // Yo conduje ayer = I drove yesterday
forms[1] = "condujiste"; // Condujiste una vez = You drove one time
forms[2] = "condujo"; // El condujo anoche = He drove last night
forms[3] = "condujimos"; // Nosotros condujimos esta tarde = We drove this afternoon
forms[4] = "condujisteis"; // Vosotros condujisteis el lunes pasado = You drove last monday
forms[5] = "condujeron"; // Ellos condujeron hace dos dias = They drove two days ago
break;
case "dar": // to give
forms[0] = "di"; // Yo di anteayer = I gave the day before yesterday
forms[1] = "diste"; // Diste hoy por la mañana = You gave this morning
forms[2] = "dio"; // El dio el otro día = He gave the other day
forms[3] = "dimos"; // Nosotros dimos entonces = We gave then
forms[4] = "disteis"; // Vosotros disteis el año pasado = They gave last year
forms[5] = "dieron"; // Ellos dieron desde el primer momento = They gave from the first moment
break;
case "decir": // to say/tell
forms[0] = "dije"; // Yo dije en ese momento = I said that moment
forms[1] = "dijiste"; // Dijiste ayer = You said yesterday
forms[2] = "dijo"; // El dijo anteanoche = He said the night before last night
forms[3] = "dijimos"; // Nosotros dijimos ayer al mediodía = We said yesterday at noon
forms[4] = "dijisteis"; // Vosotros dijisteis hace dos días = You said two days ago
forms[5] = "dijeron"; // Ellos dijeron anteayer = They said the day before yesterday
break;
case "estar": // to be (feeling)
forms[0] = "estuve"; // Yo estuve una vez = I was once
forms[1] = "estuviste"; // Estuviste anoche = You were last night
forms[2] = "estuvo"; // El estuvo esta tarde = He was this afternoon
forms[3] = "estuvimos"; // Nosotros estuvimos ayer por la noche = We were last night
forms[4] = "estuvisteis"; // Vosotros estuvisteis = You were
forms[5] = "estuvieron"; // Ellos estuvieron = They were
break;
case "hacer": // to do
forms[0] = "hice";
forms[1] = "hiciste";
forms[2] = "hizo";
forms[3] = "hicimos";
forms[4] = "hicisteis";
forms[5] = "hicieron";
break;
case "poner": // to put
forms[0] = "puse";
forms[1] = "pusiste";
forms[2] = "puso";
forms[3] = "pusimos";
forms[4] = "pusisteis";
forms[5] = "pusieron";
break;
case "poder": // to be able to
forms[0] = "pude";
forms[1] = "pudiste";
forms[2] = "pudo";
forms[3] = "pudimos";
forms[4] = "pudisteis";
forms[5] = "pudieron";
break;
case "querer": // to want/love
forms[0] = "quise";
forms[1] = "quisiste";
forms[2] = "quiso";
forms[3] = "quisimos";
forms[4] = "quisisteis";
forms[5] = "quisieron";
break;
// TODO: Further irregularities
}
return forms;
}
}
Oops, something went wrong.

0 comments on commit 2a84d6a

Please sign in to comment.