mirror of https://github.com/iSoron/uhabits.git
parent
b8cacaffa9
commit
ae7869d3a2
@ -0,0 +1,69 @@
|
|||||||
|
/* Copyright (C) 2016 Alinson Santos Xavier
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by the Free
|
||||||
|
* Software Foundation, either version 3 of the License, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
* more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package org.isoron.uhabits.widgets;
|
||||||
|
|
||||||
|
import android.app.PendingIntent;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
|
import org.isoron.uhabits.HabitBroadcastReceiver;
|
||||||
|
import org.isoron.uhabits.R;
|
||||||
|
import org.isoron.uhabits.models.Habit;
|
||||||
|
import org.isoron.uhabits.views.CheckmarkView;
|
||||||
|
|
||||||
|
public class CheckmarkWidgetProvider extends BaseWidgetProvider
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
protected View buildCustomView(Context context, int maxHeight, int maxWidth, Habit habit)
|
||||||
|
{
|
||||||
|
CheckmarkView widgetView = new CheckmarkView(context);
|
||||||
|
|
||||||
|
widgetView.setHabit(habit);
|
||||||
|
widgetView.measure(maxWidth, maxHeight);
|
||||||
|
widgetView.layout(0, 0, maxWidth, maxHeight);
|
||||||
|
|
||||||
|
int width = widgetView.getMeasuredWidth();
|
||||||
|
int height = widgetView.getMeasuredHeight();
|
||||||
|
widgetView.measure(width, height);
|
||||||
|
widgetView.layout(0, 0, width, height);
|
||||||
|
|
||||||
|
return widgetView;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected PendingIntent getOnClickPendingIntent(Context context, Habit habit)
|
||||||
|
{
|
||||||
|
return HabitBroadcastReceiver.buildCheckIntent(context, habit, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getDefaultHeight()
|
||||||
|
{
|
||||||
|
return 200;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getDefaultWidth()
|
||||||
|
{
|
||||||
|
return 160;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getLayoutId()
|
||||||
|
{
|
||||||
|
return R.layout.widget_checkmark;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,69 @@
|
|||||||
|
/* Copyright (C) 2016 Alinson Santos Xavier
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by the Free
|
||||||
|
* Software Foundation, either version 3 of the License, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
* more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package org.isoron.uhabits.widgets;
|
||||||
|
|
||||||
|
import android.app.PendingIntent;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
|
import org.isoron.helpers.DialogHelper;
|
||||||
|
import org.isoron.uhabits.R;
|
||||||
|
import org.isoron.uhabits.models.Habit;
|
||||||
|
import org.isoron.uhabits.views.HabitHistoryView;
|
||||||
|
|
||||||
|
public class HistoryWidgetProvider extends BaseWidgetProvider
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
protected View buildCustomView(Context context, int maxHeight, int maxWidth, Habit habit)
|
||||||
|
{
|
||||||
|
HabitHistoryView view = new HabitHistoryView(context, null);
|
||||||
|
view.setHabit(habit);
|
||||||
|
view.measure(maxWidth, maxHeight);
|
||||||
|
view.layout(0, 0, maxWidth, maxHeight);
|
||||||
|
|
||||||
|
int width = view.getMeasuredWidth();
|
||||||
|
int height = view.getMeasuredHeight();
|
||||||
|
height -= DialogHelper.dpToPixels(context, 12);
|
||||||
|
view.measure(width, height);
|
||||||
|
view.layout(0, 0, width, height);
|
||||||
|
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected PendingIntent getOnClickPendingIntent(Context context, Habit habit)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getDefaultHeight()
|
||||||
|
{
|
||||||
|
return 200;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getDefaultWidth()
|
||||||
|
{
|
||||||
|
return 200;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getLayoutId()
|
||||||
|
{
|
||||||
|
return R.layout.widget_graph;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,70 @@
|
|||||||
|
/* Copyright (C) 2016 Alinson Santos Xavier
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by the Free
|
||||||
|
* Software Foundation, either version 3 of the License, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
* more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package org.isoron.uhabits.widgets;
|
||||||
|
|
||||||
|
import android.app.PendingIntent;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
|
import org.isoron.helpers.DialogHelper;
|
||||||
|
import org.isoron.uhabits.R;
|
||||||
|
import org.isoron.uhabits.models.Habit;
|
||||||
|
import org.isoron.uhabits.views.HabitScoreView;
|
||||||
|
|
||||||
|
public class ScoreWidgetProvider extends BaseWidgetProvider
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
protected View buildCustomView(Context context, int maxHeight, int maxWidth, Habit habit)
|
||||||
|
{
|
||||||
|
HabitScoreView view = new HabitScoreView(context, null);
|
||||||
|
view.setIsBackgroundTransparent(true);
|
||||||
|
view.setHabit(habit);
|
||||||
|
view.measure(maxWidth, maxHeight);
|
||||||
|
view.layout(0, 0, maxWidth, maxHeight);
|
||||||
|
|
||||||
|
int width = view.getMeasuredWidth();
|
||||||
|
int height = view.getMeasuredHeight();
|
||||||
|
height -= DialogHelper.dpToPixels(context, 12);
|
||||||
|
view.measure(width, height);
|
||||||
|
view.layout(0, 0, width, height);
|
||||||
|
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected PendingIntent getOnClickPendingIntent(Context context, Habit habit)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getDefaultHeight()
|
||||||
|
{
|
||||||
|
return 200;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getDefaultWidth()
|
||||||
|
{
|
||||||
|
return 200;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getLayoutId()
|
||||||
|
{
|
||||||
|
return R.layout.widget_graph;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,70 @@
|
|||||||
|
/* Copyright (C) 2016 Alinson Santos Xavier
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by the Free
|
||||||
|
* Software Foundation, either version 3 of the License, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
* more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package org.isoron.uhabits.widgets;
|
||||||
|
|
||||||
|
import android.app.PendingIntent;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
|
import org.isoron.helpers.DialogHelper;
|
||||||
|
import org.isoron.uhabits.R;
|
||||||
|
import org.isoron.uhabits.models.Habit;
|
||||||
|
import org.isoron.uhabits.views.HabitScoreView;
|
||||||
|
import org.isoron.uhabits.views.HabitStreakView;
|
||||||
|
|
||||||
|
public class StreakWidgetProvider extends BaseWidgetProvider
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
protected View buildCustomView(Context context, int maxHeight, int maxWidth, Habit habit)
|
||||||
|
{
|
||||||
|
HabitStreakView view = new HabitStreakView(context, null);
|
||||||
|
view.setHabit(habit);
|
||||||
|
view.measure(maxWidth, maxHeight);
|
||||||
|
view.layout(0, 0, maxWidth, maxHeight);
|
||||||
|
|
||||||
|
int width = view.getMeasuredWidth();
|
||||||
|
int height = view.getMeasuredHeight();
|
||||||
|
height -= DialogHelper.dpToPixels(context, 12);
|
||||||
|
view.measure(width, height);
|
||||||
|
view.layout(0, 0, width, height);
|
||||||
|
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected PendingIntent getOnClickPendingIntent(Context context, Habit habit)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getDefaultHeight()
|
||||||
|
{
|
||||||
|
return 200;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getDefaultWidth()
|
||||||
|
{
|
||||||
|
return 200;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getLayoutId()
|
||||||
|
{
|
||||||
|
return R.layout.widget_graph;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:gravity="center"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:padding="4dp">
|
||||||
|
|
||||||
|
<org.isoron.uhabits.views.CheckmarkView
|
||||||
|
android:id="@+id/imageView"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:adjustViewBounds="true"
|
||||||
|
/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:minHeight="80dp"
|
||||||
|
android:minWidth="80dp"
|
||||||
|
android:minResizeWidth="40dp"
|
||||||
|
android:minResizeHeight="40dp"
|
||||||
|
android:initialLayout="@layout/widget_graph"
|
||||||
|
android:previewImage="@mipmap/ic_small_widget_preview"
|
||||||
|
android:resizeMode="vertical|horizontal"
|
||||||
|
android:updatePeriodMillis="3600000"
|
||||||
|
android:configure="org.isoron.uhabits.widgets.HabitPickerDialog"
|
||||||
|
android:widgetCategory="home_screen">
|
||||||
|
|
||||||
|
|
||||||
|
</appwidget-provider>
|
@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:minHeight="80dp"
|
||||||
|
android:minWidth="80dp"
|
||||||
|
android:minResizeWidth="40dp"
|
||||||
|
android:minResizeHeight="40dp"
|
||||||
|
android:initialLayout="@layout/widget_graph"
|
||||||
|
android:previewImage="@mipmap/ic_small_widget_preview"
|
||||||
|
android:resizeMode="vertical|horizontal"
|
||||||
|
android:updatePeriodMillis="3600000"
|
||||||
|
android:configure="org.isoron.uhabits.widgets.HabitPickerDialog"
|
||||||
|
android:widgetCategory="home_screen">
|
||||||
|
|
||||||
|
|
||||||
|
</appwidget-provider>
|
@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:minHeight="80dp"
|
||||||
|
android:minWidth="80dp"
|
||||||
|
android:minResizeWidth="40dp"
|
||||||
|
android:minResizeHeight="40dp"
|
||||||
|
android:initialLayout="@layout/widget_graph"
|
||||||
|
android:previewImage="@mipmap/ic_small_widget_preview"
|
||||||
|
android:resizeMode="vertical|horizontal"
|
||||||
|
android:updatePeriodMillis="3600000"
|
||||||
|
android:configure="org.isoron.uhabits.widgets.HabitPickerDialog"
|
||||||
|
android:widgetCategory="home_screen">
|
||||||
|
|
||||||
|
|
||||||
|
</appwidget-provider>
|
Loading…
Reference in new issue