Alternative design for header bar
@@ -133,7 +133,7 @@ abstract public class BaseActivity extends AppCompatActivity implements Thread.U
|
||||
if(toolbar == null) return;
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
|
||||
toolbar.setElevation(UIHelper.dpToPixels(this, 3));
|
||||
toolbar.setElevation(UIHelper.dpToPixels(this, 2));
|
||||
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@ import org.isoron.uhabits.commands.Command;
|
||||
import org.isoron.uhabits.dialogs.EditHabitDialogFragment;
|
||||
import org.isoron.uhabits.dialogs.HistoryEditorDialog;
|
||||
import org.isoron.uhabits.helpers.ColorHelper;
|
||||
import org.isoron.uhabits.helpers.DateHelper;
|
||||
import org.isoron.uhabits.helpers.ReminderHelper;
|
||||
import org.isoron.uhabits.helpers.UIHelper;
|
||||
import org.isoron.uhabits.models.Habit;
|
||||
@@ -92,6 +93,8 @@ public class ShowHabitFragment extends Fragment
|
||||
activity = (ShowHabitActivity) getActivity();
|
||||
habit = activity.getHabit();
|
||||
|
||||
updateHeader(view);
|
||||
|
||||
dataViews = new LinkedList<>();
|
||||
|
||||
Button btEditHistory = (Button) view.findViewById(R.id.btEditHistory);
|
||||
@@ -105,7 +108,6 @@ public class ShowHabitFragment extends Fragment
|
||||
previousScoreInterval = defaultScoreInterval;
|
||||
setScoreBucketSize(defaultScoreInterval);
|
||||
|
||||
|
||||
sStrengthInterval.setSelection(defaultScoreInterval);
|
||||
sStrengthInterval.setOnItemSelectedListener(this);
|
||||
|
||||
@@ -147,6 +149,48 @@ public class ShowHabitFragment extends Fragment
|
||||
return view;
|
||||
}
|
||||
|
||||
private void updateHeader(View view)
|
||||
{
|
||||
if(habit == null) return;
|
||||
|
||||
int activeColor = ColorHelper.getColor(getContext(), habit.color);
|
||||
|
||||
TextView questionLabel = (TextView) view.findViewById(R.id.questionLabel);
|
||||
questionLabel.setTextColor(activeColor);
|
||||
questionLabel.setText(habit.description);
|
||||
|
||||
TextView reminderLabel = (TextView) view.findViewById(R.id.reminderLabel);
|
||||
if(habit.hasReminder())
|
||||
reminderLabel.setText(DateHelper.formatTime(getActivity(), habit.reminderHour,
|
||||
habit.reminderMin));
|
||||
else
|
||||
reminderLabel.setText(getResources().getString(R.string.reminder_off));
|
||||
|
||||
TextView frequencyLabel = (TextView) view.findViewById(R.id.frequencyLabel);
|
||||
String freqText;
|
||||
|
||||
if(habit.freqNum.equals(habit.freqDen))
|
||||
freqText = getResources().getString(R.string.every_day);
|
||||
else if(habit.freqNum == 1 && habit.freqDen == 7)
|
||||
freqText = getResources().getString(R.string.every_week);
|
||||
else
|
||||
{
|
||||
String times_every;
|
||||
if(habit.freqNum == 1)
|
||||
times_every = getResources().getString(R.string.time_every);
|
||||
else
|
||||
times_every = getResources().getString(R.string.times_every);
|
||||
|
||||
freqText = String.format("%d %s %d %s", habit.freqNum, times_every, habit.freqDen,
|
||||
getResources().getString(R.string.days));
|
||||
}
|
||||
|
||||
frequencyLabel.setText(freqText);
|
||||
|
||||
if(habit.description.isEmpty())
|
||||
questionLabel.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume()
|
||||
{
|
||||
|
||||
@@ -107,7 +107,7 @@ public abstract class HabitWidgetView extends FrameLayout implements HabitDataV
|
||||
backgroundPaint.setAlpha(backgroundAlpha);
|
||||
|
||||
frame = (ViewGroup) findViewById(R.id.frame);
|
||||
frame.setBackgroundDrawable(background);
|
||||
if(frame != null) frame.setBackgroundDrawable(background);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
BIN
app/src/main/res/drawable-hdpi/ic_alarm_black.png
Normal file
|
After Width: | Height: | Size: 610 B |
BIN
app/src/main/res/drawable-hdpi/ic_alarm_white.png
Normal file
|
After Width: | Height: | Size: 610 B |
BIN
app/src/main/res/drawable-hdpi/ic_repeat_black.png
Normal file
|
After Width: | Height: | Size: 183 B |
BIN
app/src/main/res/drawable-hdpi/ic_repeat_white.png
Normal file
|
After Width: | Height: | Size: 198 B |
BIN
app/src/main/res/drawable-mdpi/ic_alarm_black.png
Normal file
|
After Width: | Height: | Size: 388 B |
BIN
app/src/main/res/drawable-mdpi/ic_alarm_white.png
Normal file
|
After Width: | Height: | Size: 403 B |
BIN
app/src/main/res/drawable-mdpi/ic_repeat_black.png
Normal file
|
After Width: | Height: | Size: 122 B |
BIN
app/src/main/res/drawable-mdpi/ic_repeat_white.png
Normal file
|
After Width: | Height: | Size: 133 B |
BIN
app/src/main/res/drawable-xhdpi/ic_alarm_black.png
Normal file
|
After Width: | Height: | Size: 798 B |
BIN
app/src/main/res/drawable-xhdpi/ic_alarm_white.png
Normal file
|
After Width: | Height: | Size: 821 B |
BIN
app/src/main/res/drawable-xhdpi/ic_repeat_black.png
Normal file
|
After Width: | Height: | Size: 168 B |
BIN
app/src/main/res/drawable-xhdpi/ic_repeat_white.png
Normal file
|
After Width: | Height: | Size: 185 B |
BIN
app/src/main/res/drawable-xxhdpi/ic_alarm_black.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
app/src/main/res/drawable-xxhdpi/ic_alarm_white.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
app/src/main/res/drawable-xxhdpi/ic_repeat_black.png
Normal file
|
After Width: | Height: | Size: 214 B |
BIN
app/src/main/res/drawable-xxhdpi/ic_repeat_white.png
Normal file
|
After Width: | Height: | Size: 234 B |
BIN
app/src/main/res/drawable-xxxhdpi/ic_alarm_black.png
Normal file
|
After Width: | Height: | Size: 1.6 KiB |
BIN
app/src/main/res/drawable-xxxhdpi/ic_alarm_white.png
Normal file
|
After Width: | Height: | Size: 1.6 KiB |
BIN
app/src/main/res/drawable-xxxhdpi/ic_repeat_black.png
Normal file
|
After Width: | Height: | Size: 243 B |
BIN
app/src/main/res/drawable-xxxhdpi/ic_repeat_white.png
Normal file
|
After Width: | Height: | Size: 257 B |
@@ -17,18 +17,91 @@
|
||||
~ with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<ScrollView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:habit="http://isoron.org/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?windowBackgroundColor"
|
||||
android:clipToPadding="false"
|
||||
android:fillViewport="true">
|
||||
|
||||
<LinearLayout
|
||||
style="@style/CardList"
|
||||
android:clipToPadding="false"
|
||||
tools:context="org.isoron.uhabits.ShowHabitActivity">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/subtitle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?headerBackgroundColor"
|
||||
android:elevation="2dp"
|
||||
android:paddingTop="15dp"
|
||||
android:paddingBottom="10dp"
|
||||
android:paddingLeft="60dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/questionLabel"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="?mediumContrastTextColor"
|
||||
android:textSize="@dimen/regularTextSize"
|
||||
android:layout_marginBottom="8dp"
|
||||
/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:layout_marginBottom="5dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/frequencyIcon"
|
||||
android:layout_width="18dp"
|
||||
android:layout_height="18dp"
|
||||
android:src="@drawable/ic_repeat_black"
|
||||
android:alpha="0.3"
|
||||
android:layout_marginRight="5dp"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/frequencyLabel"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Every day"
|
||||
android:textColor="?mediumContrastTextColor"
|
||||
android:textSize="@dimen/smallTextSize"
|
||||
/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/reminderIcon"
|
||||
android:layout_width="18dp"
|
||||
android:layout_height="18dp"
|
||||
android:src="@drawable/ic_alarm_black"
|
||||
android:alpha="0.3"
|
||||
android:layout_marginRight="5dp"
|
||||
android:layout_marginLeft="10dp"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/reminderLabel"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="1dp"
|
||||
android:text="7:30"
|
||||
android:textColor="?mediumContrastTextColor"
|
||||
android:textSize="@dimen/smallTextSize"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
style="@style/Card"
|
||||
android:gravity="start">
|
||||
@@ -49,17 +122,17 @@
|
||||
android:id="@+id/scoreRing"
|
||||
android:layout_width="75dp"
|
||||
android:layout_height="75dp"
|
||||
android:layout_margin="10dp"
|
||||
habit:percentage="0"
|
||||
habit:thickness="10"
|
||||
habit:textSize="12"
|
||||
android:layout_margin="10dp"/>
|
||||
habit:thickness="10"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/habit_strength"
|
||||
android:textSize="@dimen/smallTextSize"
|
||||
android:textColor="?mediumContrastTextColor"/>
|
||||
android:textColor="?mediumContrastTextColor"
|
||||
android:textSize="@dimen/smallTextSize"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
@@ -73,20 +146,20 @@
|
||||
android:id="@+id/sStrengthInterval"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="22dp"
|
||||
android:entries="@array/strengthIntervalNames"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:entries="@array/strengthIntervalNames"
|
||||
android:theme="@style/SmallSpinner"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvStrength"
|
||||
style="@style/CardHeader"
|
||||
android:text="@string/habit_strength"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentStart="true"/>
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:text="@string/habit_strength"/>
|
||||
|
||||
<org.isoron.uhabits.views.HabitScoreView
|
||||
android:id="@+id/scoreView"
|
||||
|
||||
@@ -17,10 +17,11 @@
|
||||
~ with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
<RelativeLayout
|
||||
android:id="@+id/container"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context="org.isoron.uhabits.ShowHabitActivity"
|
||||
@@ -29,18 +30,17 @@
|
||||
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
app:popupTheme="?toolbarPopupTheme"
|
||||
|
||||
style="@style/Toolbar"/>
|
||||
style="@style/Toolbar"
|
||||
app:popupTheme="?toolbarPopupTheme"/>
|
||||
|
||||
<fragment
|
||||
android:id="@+id/fragment2"
|
||||
android:name="org.isoron.uhabits.fragments.ShowHabitFragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:layout="@layout/show_habit"
|
||||
android:layout_below="@id/toolbar"
|
||||
android:layout_gravity="center"
|
||||
android:layout_below="@id/toolbar"/>
|
||||
tools:layout="@layout/show_habit"/>
|
||||
|
||||
<View
|
||||
android:id="@+id/toolbarShadow"
|
||||
|
||||
@@ -156,6 +156,7 @@
|
||||
<string name="bug_report_failed">Failed to generate bug report.</string>
|
||||
<string name="generate_bug_report">Generate bug report</string>
|
||||
<string name="troubleshooting">Troubleshooting</string>
|
||||
|
||||
<string name="help_translate">Help translate this app</string>
|
||||
<string name="night_mode">Night mode</string>
|
||||
<string name="use_pure_black">Pure black for night mode</string>
|
||||
@@ -167,4 +168,12 @@
|
||||
<string name="month">Month</string>
|
||||
<string name="quarter">Quarter</string>
|
||||
<string name="year">Year</string>
|
||||
|
||||
<!-- Middle part of the sentence '1 time in xx days' -->
|
||||
<string name="time_every">time in</string>
|
||||
|
||||
<string name="every_x_days">Every %d days</string>
|
||||
<string name="every_x_weeks">Every %d weeks</string>
|
||||
<string name="every_x_months">Every %d months</string>
|
||||
<string name="score">Score</string>
|
||||
</resources>
|
||||