wrap the calendar layout in a Coordinator layout in app

This commit is contained in:
tibbi
2016-07-05 13:12:06 +02:00
parent be0126dcb6
commit 6b5d965ac0
5 changed files with 400 additions and 391 deletions

View File

@@ -60,7 +60,7 @@ public class MyWidgetProvider extends AppWidgetProvider implements Calendar {
mTodayTextSize = mRes.getDimension(R.dimen.today_text_size) / mRes.getDisplayMetrics().density; mTodayTextSize = mRes.getDimension(R.dimen.today_text_size) / mRes.getDisplayMetrics().density;
mWidgetManager = AppWidgetManager.getInstance(mContext); mWidgetManager = AppWidgetManager.getInstance(mContext);
mRemoteViews = new RemoteViews(mContext.getPackageName(), R.layout.activity_main); mRemoteViews = new RemoteViews(mContext.getPackageName(), R.layout.calendar_layout);
mIntent = new Intent(mContext, MyWidgetProvider.class); mIntent = new Intent(mContext, MyWidgetProvider.class);
setupButtons(); setupButtons();
updateLabelColor(); updateLabelColor();

View File

@@ -6,13 +6,13 @@ import android.content.res.Resources;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.PorterDuff; import android.graphics.PorterDuff;
import android.os.Bundle; import android.os.Bundle;
import android.support.design.widget.CoordinatorLayout;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatActivity;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.widget.DatePicker; import android.widget.DatePicker;
import android.widget.FrameLayout;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
@@ -74,7 +74,7 @@ public class MainActivity extends AppCompatActivity implements Calendar {
mTodayTextSize /= mRes.getDisplayMetrics().density; mTodayTextSize /= mRes.getDisplayMetrics().density;
setupLabels(); setupLabels();
final FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) mCalendarHolder.getLayoutParams(); final CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) mCalendarHolder.getLayoutParams();
params.setMargins(mActivityMargin, mActivityMargin, mActivityMargin, mActivityMargin); params.setMargins(mActivityMargin, mActivityMargin, mActivityMargin, mActivityMargin);
mCalendar = new CalendarImpl(this, getApplicationContext()); mCalendar = new CalendarImpl(this, getApplicationContext());

View File

@@ -1,391 +1,10 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout <android.support.design.widget.CoordinatorLayout
android:id="@+id/calendar_holder" android:id="@+id/calendar_coordinator"
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<ImageView <include layout="@layout/calendar_layout"/>
android:id="@+id/left_arrow"
style="@style/ArrowStyle"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignBottom="@+id/table_month"
android:layout_alignTop="@+id/table_month"
android:padding="@dimen/activity_margin"
android:src="@mipmap/arrow_left"/>
<TextView </android.support.design.widget.CoordinatorLayout>
android:id="@+id/table_month"
style="@style/MonthStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toLeftOf="@+id/right_arrow"
android:layout_toRightOf="@+id/left_arrow"
android:gravity="center_horizontal"
android:paddingBottom="@dimen/activity_margin"
android:paddingTop="@dimen/top_padding"
android:textSize="@dimen/month_text_size"/>
<ImageView
android:id="@+id/right_arrow"
style="@style/ArrowStyle"
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:padding="@dimen/activity_margin"
android:src="@mipmap/arrow_right"/>
<LinearLayout
android:id="@+id/table_holder"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/table_month"
android:gravity="center"
android:orientation="vertical">
<include
layout="@layout/first_row"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal">
<TextView
android:id="@+id/day_0"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
android:id="@+id/day_1"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
android:id="@+id/day_2"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
android:id="@+id/day_3"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
android:id="@+id/day_4"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
android:id="@+id/day_5"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
android:id="@+id/day_6"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal">
<TextView
android:id="@+id/day_7"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
android:id="@+id/day_8"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
android:id="@+id/day_9"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
android:id="@+id/day_10"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
android:id="@+id/day_11"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
android:id="@+id/day_12"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
android:id="@+id/day_13"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal">
<TextView
android:id="@+id/day_14"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
android:id="@+id/day_15"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
android:id="@+id/day_16"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
android:id="@+id/day_17"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
android:id="@+id/day_18"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
android:id="@+id/day_19"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
android:id="@+id/day_20"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal">
<TextView
android:id="@+id/day_21"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
android:id="@+id/day_22"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
android:id="@+id/day_23"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
android:id="@+id/day_24"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
android:id="@+id/day_25"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
android:id="@+id/day_26"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
android:id="@+id/day_27"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal">
<TextView
android:id="@+id/day_28"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
android:id="@+id/day_29"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
android:id="@+id/day_30"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
android:id="@+id/day_31"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
android:id="@+id/day_32"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
android:id="@+id/day_33"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
android:id="@+id/day_34"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal">
<TextView
android:id="@+id/day_35"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
android:id="@+id/day_36"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
android:id="@+id/day_37"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
android:id="@+id/day_38"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
android:id="@+id/day_39"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
android:id="@+id/day_40"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
android:id="@+id/day_41"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
</LinearLayout>
</LinearLayout>
</RelativeLayout>

View File

@@ -0,0 +1,391 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:id="@+id/calendar_holder"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/left_arrow"
style="@style/ArrowStyle"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignBottom="@+id/table_month"
android:layout_alignTop="@+id/table_month"
android:padding="@dimen/activity_margin"
android:src="@mipmap/arrow_left"/>
<TextView
android:id="@+id/table_month"
style="@style/MonthStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toLeftOf="@+id/right_arrow"
android:layout_toRightOf="@+id/left_arrow"
android:gravity="center_horizontal"
android:paddingBottom="@dimen/activity_margin"
android:paddingTop="@dimen/top_padding"
android:textSize="@dimen/month_text_size"/>
<ImageView
android:id="@+id/right_arrow"
style="@style/ArrowStyle"
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:padding="@dimen/activity_margin"
android:src="@mipmap/arrow_right"/>
<LinearLayout
android:id="@+id/table_holder"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/table_month"
android:gravity="center"
android:orientation="vertical">
<include
layout="@layout/first_row"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal">
<TextView
android:id="@+id/day_0"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
android:id="@+id/day_1"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
android:id="@+id/day_2"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
android:id="@+id/day_3"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
android:id="@+id/day_4"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
android:id="@+id/day_5"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
android:id="@+id/day_6"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal">
<TextView
android:id="@+id/day_7"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
android:id="@+id/day_8"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
android:id="@+id/day_9"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
android:id="@+id/day_10"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
android:id="@+id/day_11"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
android:id="@+id/day_12"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
android:id="@+id/day_13"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal">
<TextView
android:id="@+id/day_14"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
android:id="@+id/day_15"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
android:id="@+id/day_16"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
android:id="@+id/day_17"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
android:id="@+id/day_18"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
android:id="@+id/day_19"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
android:id="@+id/day_20"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal">
<TextView
android:id="@+id/day_21"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
android:id="@+id/day_22"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
android:id="@+id/day_23"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
android:id="@+id/day_24"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
android:id="@+id/day_25"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
android:id="@+id/day_26"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
android:id="@+id/day_27"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal">
<TextView
android:id="@+id/day_28"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
android:id="@+id/day_29"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
android:id="@+id/day_30"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
android:id="@+id/day_31"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
android:id="@+id/day_32"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
android:id="@+id/day_33"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
android:id="@+id/day_34"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal">
<TextView
android:id="@+id/day_35"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
android:id="@+id/day_36"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
android:id="@+id/day_37"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
android:id="@+id/day_38"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
android:id="@+id/day_39"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
android:id="@+id/day_40"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
android:id="@+id/day_41"
style="@style/DayView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
</LinearLayout>
</LinearLayout>
</RelativeLayout>

View File

@@ -1,9 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android" <appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:configure="com.simplemobiletools.calendar.activities.WidgetConfigureActivity" android:configure="com.simplemobiletools.calendar.activities.WidgetConfigureActivity"
android:initialLayout="@layout/activity_main" android:initialLayout="@layout/calendar_layout"
android:minHeight="@dimen/min_widget_height" android:minHeight="@dimen/min_widget_height"
android:minWidth="@dimen/min_widget_width" android:minWidth="@dimen/min_widget_width"
android:resizeMode="horizontal|vertical" android:resizeMode="horizontal|vertical"
android:updatePeriodMillis="18000000"> android:updatePeriodMillis="18000000"/>
</appwidget-provider>