add arrow icons for switching the month
|
@ -1,8 +1,10 @@
|
||||||
package calendar.simplemobiletools.com;
|
package calendar.simplemobiletools.com;
|
||||||
|
|
||||||
|
import android.graphics.PorterDuff;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
import android.widget.ImageView;
|
||||||
import android.widget.TableLayout;
|
import android.widget.TableLayout;
|
||||||
import android.widget.TableRow;
|
import android.widget.TableRow;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
@ -12,19 +14,30 @@ import org.joda.time.DateTime;
|
||||||
import java.text.DateFormatSymbols;
|
import java.text.DateFormatSymbols;
|
||||||
|
|
||||||
public class MainActivity extends AppCompatActivity {
|
public class MainActivity extends AppCompatActivity {
|
||||||
|
private DateTime targetDate;
|
||||||
|
private int grey;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
|
|
||||||
|
grey = getResources().getColor(R.color.darkGrey);
|
||||||
|
|
||||||
|
final ImageView leftArrow = (ImageView) findViewById(R.id.left_arrow);
|
||||||
|
leftArrow.getDrawable().mutate().setColorFilter(grey, PorterDuff.Mode.SRC_ATOP);
|
||||||
|
|
||||||
|
final ImageView rightArrow = (ImageView) findViewById(R.id.right_arrow);
|
||||||
|
rightArrow.getDrawable().mutate().setColorFilter(grey, PorterDuff.Mode.SRC_ATOP);
|
||||||
|
|
||||||
final TextView monthTV = (TextView) findViewById(R.id.table_month);
|
final TextView monthTV = (TextView) findViewById(R.id.table_month);
|
||||||
|
|
||||||
final TableLayout tableHolder = (TableLayout) findViewById(R.id.table_holder);
|
final TableLayout tableHolder = (TableLayout) findViewById(R.id.table_holder);
|
||||||
final LayoutInflater inflater = getLayoutInflater();
|
final LayoutInflater inflater = getLayoutInflater();
|
||||||
|
|
||||||
final DateTime now = new DateTime();
|
final DateTime now = new DateTime();
|
||||||
monthTV.setText(getMonthName(now));
|
targetDate = now;
|
||||||
|
monthTV.setText(getMonthName());
|
||||||
final int currMonthDays = now.dayOfMonth().getMaximumValue();
|
final int currMonthDays = now.dayOfMonth().getMaximumValue();
|
||||||
|
|
||||||
final int firstDayIndex = now.withDayOfMonth(1).getDayOfWeek() - 1;
|
final int firstDayIndex = now.withDayOfMonth(1).getDayOfWeek() - 1;
|
||||||
|
@ -44,7 +57,7 @@ public class MainActivity extends AppCompatActivity {
|
||||||
currDate = prevMonthStart + cur;
|
currDate = prevMonthStart + cur;
|
||||||
} else if (currDate <= currMonthDays) {
|
} else if (currDate <= currMonthDays) {
|
||||||
thisMonthDays++;
|
thisMonthDays++;
|
||||||
day.setTextColor(getResources().getColor(R.color.darkGrey));
|
day.setTextColor(grey);
|
||||||
} else {
|
} else {
|
||||||
currDate = nextMonthsDay++;
|
currDate = nextMonthsDay++;
|
||||||
}
|
}
|
||||||
|
@ -58,8 +71,8 @@ public class MainActivity extends AppCompatActivity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getMonthName(DateTime dateTime) {
|
private String getMonthName() {
|
||||||
final String[] months = new DateFormatSymbols().getMonths();
|
final String[] months = new DateFormatSymbols().getMonths();
|
||||||
return months[dateTime.getMonthOfYear() - 1];
|
return months[targetDate.getMonthOfYear() - 1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,22 +4,44 @@
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
android:layout_margin="@dimen/activity_margin"
|
||||||
tools:context="calendar.simplemobiletools.com.MainActivity">
|
tools:context="calendar.simplemobiletools.com.MainActivity">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/left_arrow"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_alignBottom="@+id/table_month"
|
||||||
|
android:layout_alignTop="@+id/table_month"
|
||||||
|
android:paddingRight="@dimen/activity_margin"
|
||||||
|
android:src="@mipmap/arrow_left"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/table_month"
|
android:id="@+id/table_month"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="@dimen/activity_margin"
|
|
||||||
android:gravity="center_horizontal"
|
android:gravity="center_horizontal"
|
||||||
|
android:paddingBottom="@dimen/activity_margin"
|
||||||
|
android:paddingTop="@dimen/activity_margin"
|
||||||
android:textColor="@color/darkGrey"
|
android:textColor="@color/darkGrey"
|
||||||
android:textSize="24sp"/>
|
android:textSize="24sp"/>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/right_arrow"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_alignBottom="@+id/table_month"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
android:layout_alignTop="@+id/table_month"
|
||||||
|
android:paddingLeft="@dimen/activity_margin"
|
||||||
|
android:src="@mipmap/arrow_right"/>
|
||||||
|
|
||||||
<TableLayout
|
<TableLayout
|
||||||
android:id="@+id/table_holder"
|
android:id="@+id/table_holder"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_below="@+id/table_month"
|
android:layout_below="@+id/table_month"
|
||||||
|
android:layout_marginBottom="@dimen/activity_margin"
|
||||||
android:gravity="center">
|
android:gravity="center">
|
||||||
|
|
||||||
</TableLayout>
|
</TableLayout>
|
||||||
|
|
After Width: | Height: | Size: 820 B |
After Width: | Height: | Size: 828 B |
After Width: | Height: | Size: 498 B |
After Width: | Height: | Size: 500 B |
After Width: | Height: | Size: 884 B |
After Width: | Height: | Size: 897 B |
After Width: | Height: | Size: 884 B |
After Width: | Height: | Size: 897 B |
After Width: | Height: | Size: 884 B |
After Width: | Height: | Size: 897 B |