Skip to content

Commit

Permalink
Ref darwin-morocho#3. Made support of RUS language. Made ENG language…
Browse files Browse the repository at this point in the history
… is default.
  • Loading branch information
EhrmantrautMichael authored and Eugene Kabanov committed Jul 16, 2017
1 parent 408d983 commit d076eb9
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,12 @@ public class OneCalendarView extends LinearLayout {
private TextView textViewMY;
private TextView textViewD, textViewL, textViewM, textViewX, textViewJ, textViewV, textViewS;

public static final int SPANISH = 0, ENGLISH = 1;//si el calendario estara en español o ingles

//
// Languages of calendar
//
public static final int LANGUAGE_ENGLISH = 0;
public static final int LANGUAGE_SPANISH = 1;
public static final int LANGUAGE_RUSSIAN = 2;

private int iday, imonth, iyear, month, year;
//meses por defecto en español
Expand Down Expand Up @@ -72,7 +76,7 @@ public class OneCalendarView extends LinearLayout {
int textColorMonthAndYear = Color.parseColor("#0099cc");
int textColorSelectedDay = Color.parseColor("#000000");
int backgroundColorSelectedDay = Color.parseColor("#d2d2d2");
int calendarLanguage = 0;
int calendarLanguage = LANGUAGE_ENGLISH;

public OneCalendarView(Context context) {
super(context);
Expand Down Expand Up @@ -135,6 +139,7 @@ public OneCalendarView(Context context, AttributeSet attrs) throws RuntimeExcept
} catch (NullPointerException e) {
}

// Default language is English
calendarLanguage = a.getInt(R.styleable.OneCalendarView_calendarLanguage, 0);

a.recycle();
Expand Down Expand Up @@ -294,20 +299,26 @@ public void dayOnLongClik(Day day, int position) {
* este metodo configura el calendar a un mes y un año especifico
*
* @param month mes para el calendar
* @param year año del mes
* @param year año del mes
*/
public void setMonthYear(int month, int year) {
showMonth(month, year);
}


/**
* permite cambiar el lenguaje de como se visualizan los meses y dias del calendario
* TODO: Made strings resources: ES, RU, EN
*
* [EN] Change calendar's language (months, days)
* [ES] Permite cambiar el lenguaje de como se visualizan los meses y dias del calendario
*
* @param language SPANISH=0, ENGLISH=1;
* @param language new language of calendar
* @see OneCalendarView#LANGUAGE_ENGLISH
* @see OneCalendarView#LANGUAGE_RUSSIAN
* @see OneCalendarView#LANGUAGE_SPANISH
*/
public void setLanguage(int language) {
if (language == 1) {//si el idioma es el ingles
if (language == LANGUAGE_ENGLISH) {//si el idioma es el ingles
textViewL.setText("M");
textViewM.setText("T");
textViewX.setText("W");
Expand All @@ -328,9 +339,28 @@ public void setLanguage(int language) {
octubre = "October";
noviembre = "November";
diciembre = "December";

} else {

} else if (language == LANGUAGE_RUSSIAN) {
textViewL.setText("П");
textViewM.setText("В");
textViewX.setText("С");
textViewJ.setText("Ч");
textViewV.setText("П");
textViewS.setText("С");
textViewD.setText("В");

enero = "Январь";
febrero = "Февраль";
marzo = "Март";
abril = "Апрель";
mayo = "Май";
junio = "Июнь";
julio = "Июль";
agosto = "Август";
septiembre = "Сентябрь";
octubre = "Октябрь";
noviembre = "Ноябрь";
diciembre = "Декабрь";
} else if (language == LANGUAGE_SPANISH) {
textViewL.setText("L");
textViewM.setText("M");
textViewX.setText("X");
Expand All @@ -354,8 +384,6 @@ public void setLanguage(int language) {
}

textViewMY.setText(getStringMonth(month) + " " + year);


}

/**
Expand Down Expand Up @@ -507,15 +535,15 @@ public interface OneCalendarClickListener {
/**
* cuando se da click en un dia en el calendario mostrado
*
* @param day un Objeto de tipo Day del cual podemos llara a su metodo getDate() para recuperar una fecha
* @param day un Objeto de tipo Day del cual podemos llara a su metodo getDate() para recuperar una fecha
* @param position posicion desde 0-41, que ocupa en el calendario actual
*/
void dateOnClick(Day day, int position);

/**
* cuando se da click prolongado en un dia en el calendario mostrado
*
* @param day un Objeto de tipo Day del cual podemos llara a su metodo getDate() para recuperar una fecha
* @param day un Objeto de tipo Day del cual podemos llara a su metodo getDate() para recuperar una fecha
* @param position posicion desde 0-41, que ocupa en el calendario actual
*/
void dateOnLongClick(Day day, int position);
Expand All @@ -529,6 +557,7 @@ public void setOneCalendarClickListener(OneCalendarClickListener oneCalendarClic

/**
* retorna el mes visible en el calendario
*
* @return
*/
public int getMonth() {
Expand All @@ -537,6 +566,7 @@ public int getMonth() {

/**
* retorna el año del mes visible en el calendario
*
* @return
*/
public int getYear() {
Expand Down
35 changes: 17 additions & 18 deletions onecalendar/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="OneCalendarView">
<attr name="mainBackgroundColor" format="color" />
<attr name="calendarBackgroundColor" format="color" />
<attr name="currentDayBackgroundColor" format="color" />
<attr name="backgroundColorDaysOfMonth" format="color" />
<attr name="backgroundColorDaysOfAnotherMonth" format="color" />
<attr name="textColorDaysOfMonth" format="color" />
<attr name="textColorDaysOfAnotherMonth" format="color" />
<attr name="textColorMonthAndYear" format="color" />
<attr name="textColorSelectedDay" format="color" />
<attr name="backgroundColorSelectedDay" format="color" />
<attr name="calendarLanguage" format="enum">
<enum name="ES" value="0" />
<enum name="EN" value="1" />
</attr>


</declare-styleable>
<declare-styleable name="OneCalendarView">
<attr name="mainBackgroundColor" format="color"/>
<attr name="calendarBackgroundColor" format="color"/>
<attr name="currentDayBackgroundColor" format="color"/>
<attr name="backgroundColorDaysOfMonth" format="color"/>
<attr name="backgroundColorDaysOfAnotherMonth" format="color"/>
<attr name="textColorDaysOfMonth" format="color"/>
<attr name="textColorDaysOfAnotherMonth" format="color"/>
<attr name="textColorMonthAndYear" format="color"/>
<attr name="textColorSelectedDay" format="color"/>
<attr name="backgroundColorSelectedDay" format="color"/>
<attr name="calendarLanguage" format="enum">
<enum name="EN" value="0"/>
<enum name="ES" value="1"/>
<enum name="RU" value="2"/>
</attr>
</declare-styleable>
</resources>

0 comments on commit d076eb9

Please sign in to comment.