mirror of https://github.com/iSoron/uhabits.git
parent
7de69c1c10
commit
103c0b57f8
@ -1,56 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2016 Álinson Santos Xavier <isoron@gmail.com>
|
|
||||||
*
|
|
||||||
* This file is part of Loop Habit Tracker.
|
|
||||||
*
|
|
||||||
* Loop Habit Tracker 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.
|
|
||||||
*
|
|
||||||
* Loop Habit Tracker 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.activities.habits.edit;
|
|
||||||
|
|
||||||
import com.google.auto.factory.*;
|
|
||||||
|
|
||||||
import org.isoron.uhabits.*;
|
|
||||||
import org.isoron.uhabits.commands.*;
|
|
||||||
import org.isoron.uhabits.models.*;
|
|
||||||
|
|
||||||
@AutoFactory(allowSubclasses = true)
|
|
||||||
public class CreateNumericalHabitDialog extends NumericalHabitDialog
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
protected int getTitle()
|
|
||||||
{
|
|
||||||
return R.string.create_habit;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void initializeHabits()
|
|
||||||
{
|
|
||||||
modifiedHabit = modelFactory.buildHabit();
|
|
||||||
modifiedHabit.setFrequency(Frequency.DAILY);
|
|
||||||
modifiedHabit.setColor(
|
|
||||||
prefs.getDefaultHabitColor(modifiedHabit.getColor()));
|
|
||||||
modifiedHabit.setType(Habit.NUMBER_HABIT);
|
|
||||||
modifiedHabit.setTargetValue(100);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void saveHabit()
|
|
||||||
{
|
|
||||||
Command command = appComponent
|
|
||||||
.getCreateHabitCommandFactory()
|
|
||||||
.create(habitList, modifiedHabit);
|
|
||||||
commandRunner.execute(command, null);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,55 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2016 Álinson Santos Xavier <isoron@gmail.com>
|
|
||||||
*
|
|
||||||
* This file is part of Loop Habit Tracker.
|
|
||||||
*
|
|
||||||
* Loop Habit Tracker 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.
|
|
||||||
*
|
|
||||||
* Loop Habit Tracker 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.activities.habits.edit;
|
|
||||||
|
|
||||||
import org.isoron.uhabits.*;
|
|
||||||
import org.isoron.uhabits.commands.*;
|
|
||||||
|
|
||||||
public class EditNumericalHabitDialog extends NumericalHabitDialog
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
protected int getTitle()
|
|
||||||
{
|
|
||||||
return R.string.edit_habit;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void initializeHabits()
|
|
||||||
{
|
|
||||||
Long habitId = (Long) getArguments().get("habitId");
|
|
||||||
if (habitId == null)
|
|
||||||
throw new IllegalArgumentException("habitId must be specified");
|
|
||||||
|
|
||||||
originalHabit = habitList.getById(habitId);
|
|
||||||
if (originalHabit == null)
|
|
||||||
throw new IllegalStateException("habit is null");
|
|
||||||
|
|
||||||
modifiedHabit = modelFactory.buildHabit();
|
|
||||||
modifiedHabit.copyFrom(originalHabit);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void saveHabit()
|
|
||||||
{
|
|
||||||
Command command = appComponent.getEditHabitCommandFactory().
|
|
||||||
create(habitList, originalHabit, modifiedHabit);
|
|
||||||
commandRunner.execute(command, originalHabit.getId());
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,47 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2016 Álinson Santos Xavier <isoron@gmail.com>
|
|
||||||
*
|
|
||||||
* This file is part of Loop Habit Tracker.
|
|
||||||
*
|
|
||||||
* Loop Habit Tracker 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.
|
|
||||||
*
|
|
||||||
* Loop Habit Tracker 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.activities.habits.edit;
|
|
||||||
|
|
||||||
import android.os.*;
|
|
||||||
import android.support.annotation.*;
|
|
||||||
|
|
||||||
import org.isoron.uhabits.models.*;
|
|
||||||
|
|
||||||
import javax.inject.*;
|
|
||||||
|
|
||||||
public class EditNumericalHabitDialogFactory
|
|
||||||
{
|
|
||||||
@Inject
|
|
||||||
public EditNumericalHabitDialogFactory()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public EditNumericalHabitDialog create(@NonNull Habit habit)
|
|
||||||
{
|
|
||||||
if (habit.getId() == null)
|
|
||||||
throw new IllegalArgumentException("habit not saved");
|
|
||||||
|
|
||||||
EditNumericalHabitDialog dialog = new EditNumericalHabitDialog();
|
|
||||||
Bundle args = new Bundle();
|
|
||||||
args.putLong("habitId", habit.getId());
|
|
||||||
dialog.setArguments(args);
|
|
||||||
return dialog;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,158 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2016 Álinson Santos Xavier <isoron@gmail.com>
|
|
||||||
*
|
|
||||||
* This file is part of Loop Habit Tracker.
|
|
||||||
*
|
|
||||||
* Loop Habit Tracker 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.
|
|
||||||
*
|
|
||||||
* Loop Habit Tracker 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.activities.habits.edit;
|
|
||||||
|
|
||||||
import android.os.*;
|
|
||||||
import android.support.annotation.*;
|
|
||||||
import android.support.v7.app.*;
|
|
||||||
import android.view.*;
|
|
||||||
|
|
||||||
import org.isoron.uhabits.*;
|
|
||||||
import org.isoron.uhabits.R;
|
|
||||||
import org.isoron.uhabits.activities.*;
|
|
||||||
import org.isoron.uhabits.activities.common.dialogs.*;
|
|
||||||
import org.isoron.uhabits.commands.*;
|
|
||||||
import org.isoron.uhabits.models.*;
|
|
||||||
import org.isoron.uhabits.preferences.*;
|
|
||||||
|
|
||||||
import butterknife.*;
|
|
||||||
|
|
||||||
public abstract class NumericalHabitDialog extends AppCompatDialogFragment
|
|
||||||
{
|
|
||||||
@Nullable
|
|
||||||
protected Habit originalHabit;
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
protected Habit modifiedHabit;
|
|
||||||
|
|
||||||
protected Preferences prefs;
|
|
||||||
|
|
||||||
protected CommandRunner commandRunner;
|
|
||||||
|
|
||||||
protected HabitList habitList;
|
|
||||||
|
|
||||||
protected AppComponent appComponent;
|
|
||||||
|
|
||||||
protected ModelFactory modelFactory;
|
|
||||||
|
|
||||||
private ColorPickerDialogFactory colorPickerDialogFactory;
|
|
||||||
|
|
||||||
private NumericalHabitDialogHelper helper;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getTheme()
|
|
||||||
{
|
|
||||||
return R.style.DialogWithTitle;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onActivityCreated(Bundle savedInstanceState)
|
|
||||||
{
|
|
||||||
super.onActivityCreated(savedInstanceState);
|
|
||||||
BaseActivity activity = (BaseActivity) getActivity();
|
|
||||||
ActivityComponent component = activity.getComponent();
|
|
||||||
colorPickerDialogFactory = component.getColorPickerDialogFactory();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View onCreateView(LayoutInflater inflater,
|
|
||||||
ViewGroup container,
|
|
||||||
Bundle savedInstanceState)
|
|
||||||
{
|
|
||||||
View view =
|
|
||||||
inflater.inflate(R.layout.edit_numerical_habit, container, false);
|
|
||||||
|
|
||||||
HabitsApplication app =
|
|
||||||
(HabitsApplication) getContext().getApplicationContext();
|
|
||||||
|
|
||||||
appComponent = app.getComponent();
|
|
||||||
prefs = appComponent.getPreferences();
|
|
||||||
habitList = appComponent.getHabitList();
|
|
||||||
commandRunner = appComponent.getCommandRunner();
|
|
||||||
modelFactory = appComponent.getModelFactory();
|
|
||||||
|
|
||||||
ButterKnife.bind(this, view);
|
|
||||||
|
|
||||||
helper = new NumericalHabitDialogHelper(this, view);
|
|
||||||
getDialog().setTitle(getTitle());
|
|
||||||
initializeHabits();
|
|
||||||
restoreSavedInstance(savedInstanceState);
|
|
||||||
helper.populateForm(modifiedHabit);
|
|
||||||
return view;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSaveInstanceState(Bundle outState)
|
|
||||||
{
|
|
||||||
super.onSaveInstanceState(outState);
|
|
||||||
outState.putInt("color", modifiedHabit.getColor());
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract int getTitle();
|
|
||||||
|
|
||||||
protected abstract void initializeHabits();
|
|
||||||
|
|
||||||
protected void restoreSavedInstance(@Nullable Bundle bundle)
|
|
||||||
{
|
|
||||||
if (bundle == null) return;
|
|
||||||
if (modifiedHabit == null) return;
|
|
||||||
|
|
||||||
int color = bundle.getInt("color", modifiedHabit.getColor());
|
|
||||||
|
|
||||||
modifiedHabit.setColor(color);
|
|
||||||
modifiedHabit.setReminder(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract void saveHabit();
|
|
||||||
|
|
||||||
|
|
||||||
@OnClick(R.id.buttonDiscard)
|
|
||||||
void onButtonDiscardClick()
|
|
||||||
{
|
|
||||||
dismiss();
|
|
||||||
}
|
|
||||||
|
|
||||||
@OnClick(R.id.buttonSave)
|
|
||||||
void onSaveButtonClick()
|
|
||||||
{
|
|
||||||
helper.parseForm(modifiedHabit);
|
|
||||||
if (!helper.validate(modifiedHabit)) return;
|
|
||||||
saveHabit();
|
|
||||||
dismiss();
|
|
||||||
}
|
|
||||||
|
|
||||||
@OnClick(R.id.buttonPickColor)
|
|
||||||
void showColorPicker()
|
|
||||||
{
|
|
||||||
if (modifiedHabit == null) return;
|
|
||||||
|
|
||||||
int color = modifiedHabit.getColor();
|
|
||||||
ColorPickerDialog picker = colorPickerDialogFactory.create(color);
|
|
||||||
|
|
||||||
picker.setListener(c ->
|
|
||||||
{
|
|
||||||
prefs.setDefaultHabitColor(c);
|
|
||||||
modifiedHabit.setColor(c);
|
|
||||||
helper.populateColor(c);
|
|
||||||
});
|
|
||||||
|
|
||||||
picker.show(getFragmentManager(), "picker");
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,121 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2016 Álinson Santos Xavier <isoron@gmail.com>
|
|
||||||
*
|
|
||||||
* This file is part of Loop Habit Tracker.
|
|
||||||
*
|
|
||||||
* Loop Habit Tracker 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.
|
|
||||||
*
|
|
||||||
* Loop Habit Tracker 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.activities.habits.edit;
|
|
||||||
|
|
||||||
import android.icu.text.*;
|
|
||||||
import android.support.v4.app.*;
|
|
||||||
import android.view.*;
|
|
||||||
import android.widget.*;
|
|
||||||
|
|
||||||
import org.isoron.uhabits.R;
|
|
||||||
import org.isoron.uhabits.activities.habits.edit.views.*;
|
|
||||||
import org.isoron.uhabits.models.*;
|
|
||||||
import org.isoron.uhabits.utils.*;
|
|
||||||
|
|
||||||
import butterknife.*;
|
|
||||||
|
|
||||||
public class NumericalHabitDialogHelper
|
|
||||||
{
|
|
||||||
private DialogFragment frag;
|
|
||||||
|
|
||||||
private DecimalFormat valueFormatter = new DecimalFormat("#.##");
|
|
||||||
|
|
||||||
@BindView(R.id.tvName)
|
|
||||||
TextView tvName;
|
|
||||||
|
|
||||||
@BindView(R.id.tvDescription)
|
|
||||||
ExampleEditText tvDescription;
|
|
||||||
|
|
||||||
@BindView(R.id.tvUnit)
|
|
||||||
ExampleEditText tvUnit;
|
|
||||||
|
|
||||||
@BindView(R.id.tvTargetCount)
|
|
||||||
TextView tvTargetValue;
|
|
||||||
|
|
||||||
@BindView(R.id.tvTargetType)
|
|
||||||
Spinner tvTargetType;
|
|
||||||
|
|
||||||
public NumericalHabitDialogHelper(DialogFragment frag, View view)
|
|
||||||
{
|
|
||||||
this.frag = frag;
|
|
||||||
ButterKnife.bind(this, view);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void parseForm(Habit habit)
|
|
||||||
{
|
|
||||||
habit.setName(tvName.getText().toString().trim());
|
|
||||||
habit.setDescription(tvDescription.getRealText().trim());
|
|
||||||
habit.setTargetType(tvTargetType.getSelectedItemPosition());
|
|
||||||
habit.setTargetValue(
|
|
||||||
Double.parseDouble(tvTargetValue.getText().toString()));
|
|
||||||
habit.setUnit(tvUnit.getRealText().trim());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void populateColor(int paletteColor)
|
|
||||||
{
|
|
||||||
tvName.setTextColor(
|
|
||||||
ColorUtils.getColor(frag.getContext(), paletteColor));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void populateForm(final Habit habit)
|
|
||||||
{
|
|
||||||
tvName.setText(habit.getName());
|
|
||||||
|
|
||||||
if(!habit.getDescription().isEmpty())
|
|
||||||
tvDescription.setRealText(habit.getDescription());
|
|
||||||
|
|
||||||
if(!habit.getUnit().isEmpty())
|
|
||||||
tvUnit.setRealText(habit.getUnit());
|
|
||||||
|
|
||||||
tvTargetType.setSelection(habit.getTargetType());
|
|
||||||
tvTargetValue.setText(valueFormatter.format(habit.getTargetValue()));
|
|
||||||
populateColor(habit.getColor());
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean validate(Habit habit)
|
|
||||||
{
|
|
||||||
Boolean valid = true;
|
|
||||||
if (!validateName(habit)) valid = false;
|
|
||||||
if (!validateTargetValue()) valid = false;
|
|
||||||
return valid;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean validateTargetValue()
|
|
||||||
{
|
|
||||||
double value = Double.parseDouble(tvTargetValue.getText().toString());
|
|
||||||
if(value <= 0)
|
|
||||||
{
|
|
||||||
tvTargetValue.setError(frag.getString(R.string.validation_number_should_be_positive));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Boolean validateName(Habit habit)
|
|
||||||
{
|
|
||||||
if (habit.getName().isEmpty())
|
|
||||||
{
|
|
||||||
tvName.setError(frag.getString(R.string.validation_name_should_not_be_blank));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,90 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2016 Álinson Santos Xavier <isoron@gmail.com>
|
||||||
|
*
|
||||||
|
* This file is part of Loop Habit Tracker.
|
||||||
|
*
|
||||||
|
* Loop Habit Tracker 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.
|
||||||
|
*
|
||||||
|
* Loop Habit Tracker 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.activities.habits.edit.views;
|
||||||
|
|
||||||
|
import android.content.*;
|
||||||
|
import android.content.res.*;
|
||||||
|
import android.icu.text.*;
|
||||||
|
import android.support.annotation.*;
|
||||||
|
import android.util.*;
|
||||||
|
import android.view.*;
|
||||||
|
import android.widget.*;
|
||||||
|
|
||||||
|
import org.isoron.uhabits.R;
|
||||||
|
|
||||||
|
import butterknife.*;
|
||||||
|
|
||||||
|
|
||||||
|
public class TargetPanel extends FrameLayout
|
||||||
|
{
|
||||||
|
private DecimalFormat valueFormatter = new DecimalFormat("#.##");
|
||||||
|
|
||||||
|
@BindView(R.id.tvUnit)
|
||||||
|
ExampleEditText tvUnit;
|
||||||
|
|
||||||
|
@BindView(R.id.tvTargetCount)
|
||||||
|
TextView tvTargetValue;
|
||||||
|
|
||||||
|
public TargetPanel(@NonNull Context context, @Nullable AttributeSet attrs)
|
||||||
|
{
|
||||||
|
super(context, attrs);
|
||||||
|
|
||||||
|
View view = inflate(context, R.layout.edit_habit_target, null);
|
||||||
|
ButterKnife.bind(this, view);
|
||||||
|
addView(view);
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getTargetValue()
|
||||||
|
{
|
||||||
|
String sValue = tvTargetValue.getText().toString();
|
||||||
|
return Double.parseDouble(sValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTargetValue(double targetValue)
|
||||||
|
{
|
||||||
|
tvTargetValue.setText(valueFormatter.format(targetValue));
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUnit()
|
||||||
|
{
|
||||||
|
return tvUnit.getRealText();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUnit(String unit)
|
||||||
|
{
|
||||||
|
tvUnit.setRealText(unit);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean validate()
|
||||||
|
{
|
||||||
|
Resources res = getResources();
|
||||||
|
String sValue = tvTargetValue.getText().toString();
|
||||||
|
double value = Double.parseDouble(sValue);
|
||||||
|
|
||||||
|
if (value <= 0)
|
||||||
|
{
|
||||||
|
tvTargetValue.setError(
|
||||||
|
res.getString(R.string.validation_number_should_be_positive));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,62 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
~ Copyright (C) 2016 Álinson Santos Xavier <isoron@gmail.com>
|
||||||
|
~
|
||||||
|
~ This file is part of Loop Habit Tracker.
|
||||||
|
~
|
||||||
|
~ Loop Habit Tracker 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.
|
||||||
|
~
|
||||||
|
~ Loop Habit Tracker 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/>.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<LinearLayout style="@style/dialogFormRow"
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://isoron.org/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
style="@style/dialogFormLabel"
|
||||||
|
android:text="@string/target"/>
|
||||||
|
|
||||||
|
<android.support.design.widget.TextInputLayout
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="2">
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/tvTargetCount"
|
||||||
|
style="@style/dialogFormInput"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:hint="@string/count"
|
||||||
|
android:inputType="numberDecimal"
|
||||||
|
android:text="@string/default_count"
|
||||||
|
/>
|
||||||
|
</android.support.design.widget.TextInputLayout>
|
||||||
|
|
||||||
|
<android.support.design.widget.TextInputLayout
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="2">
|
||||||
|
|
||||||
|
<org.isoron.uhabits.activities.habits.edit.views.ExampleEditText
|
||||||
|
android:id="@+id/tvUnit"
|
||||||
|
style="@style/dialogFormInput"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:hint="@string/unit"
|
||||||
|
android:inputType="text"
|
||||||
|
app:example="@string/example_units"/>
|
||||||
|
</android.support.design.widget.TextInputLayout>
|
||||||
|
</LinearLayout>
|
@ -1,137 +0,0 @@
|
|||||||
<!--
|
|
||||||
~ Copyright (C) 2016 Álinson Santos Xavier <isoron@gmail.com>
|
|
||||||
~
|
|
||||||
~ This file is part of Loop Habit Tracker.
|
|
||||||
~
|
|
||||||
~ Loop Habit Tracker 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.
|
|
||||||
~
|
|
||||||
~ Loop Habit Tracker 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/>.
|
|
||||||
-->
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/container"
|
|
||||||
style="@style/dialogForm"
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
tools:context=".activities.habits.edit.BooleanHabitDialog"
|
|
||||||
tools:ignore="MergeRootFrame"
|
|
||||||
xmlns:app="http://isoron.org/android">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/formPanel"
|
|
||||||
style="@style/dialogFormPanel">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
style="@style/dialogFormRow">
|
|
||||||
|
|
||||||
<android.support.design.widget.TextInputLayout
|
|
||||||
android:id="@+id/tilName"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="6">
|
|
||||||
|
|
||||||
<EditText
|
|
||||||
android:id="@+id/tvName"
|
|
||||||
style="@style/dialogFormInput"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:hint="@string/name">
|
|
||||||
<requestFocus/>
|
|
||||||
</EditText>
|
|
||||||
</android.support.design.widget.TextInputLayout>
|
|
||||||
|
|
||||||
<ImageButton
|
|
||||||
android:id="@+id/buttonPickColor"
|
|
||||||
style="@style/dialogFormInputColor"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:contentDescription="@string/color_picker_default_title"
|
|
||||||
android:src="?dialogIconChangeColor"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<android.support.design.widget.TextInputLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content">
|
|
||||||
|
|
||||||
<org.isoron.uhabits.activities.habits.edit.views.ExampleEditText
|
|
||||||
android:id="@+id/tvDescription"
|
|
||||||
style="@style/dialogFormInputMultiline"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:hint="Question"
|
|
||||||
app:example="e.g. How many steps did you walk today?"/>
|
|
||||||
</android.support.design.widget.TextInputLayout>
|
|
||||||
|
|
||||||
<LinearLayout style="@style/dialogFormRow">
|
|
||||||
|
|
||||||
<Spinner
|
|
||||||
android:id="@+id/tvTargetType"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="3"
|
|
||||||
android:entries="@array/targetValues"/>
|
|
||||||
|
|
||||||
<android.support.design.widget.TextInputLayout
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="2">
|
|
||||||
|
|
||||||
<EditText
|
|
||||||
android:id="@+id/tvTargetCount"
|
|
||||||
style="@style/dialogFormInput"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:hint="@string/count"
|
|
||||||
android:inputType="numberDecimal"
|
|
||||||
android:text="@string/default_count"
|
|
||||||
/>
|
|
||||||
</android.support.design.widget.TextInputLayout>
|
|
||||||
|
|
||||||
<android.support.design.widget.TextInputLayout
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="2">
|
|
||||||
|
|
||||||
<org.isoron.uhabits.activities.habits.edit.views.ExampleEditText
|
|
||||||
android:id="@+id/tvUnit"
|
|
||||||
style="@style/dialogFormInput"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:hint="@string/unit"
|
|
||||||
app:example="e.g. steps"
|
|
||||||
android:inputType="text"/>
|
|
||||||
</android.support.design.widget.TextInputLayout>
|
|
||||||
</LinearLayout>
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
style="?android:attr/buttonBarStyle"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:gravity="end">
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/buttonDiscard"
|
|
||||||
style="?android:attr/buttonBarButtonStyle"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_margin="8dp"
|
|
||||||
android:text="@string/discard"/>
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/buttonSave"
|
|
||||||
style="?android:attr/buttonBarButtonStyle"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_margin="8dp"
|
|
||||||
android:text="@string/save"/>
|
|
||||||
</LinearLayout>
|
|
||||||
</LinearLayout>
|
|
Loading…
Reference in new issue