Alternative design for header bar

pull/84/merge
Alinson S. Xavier 10 years ago
parent 44ed74a693
commit 30ef75bb45

@ -133,7 +133,7 @@ abstract public class BaseActivity extends AppCompatActivity implements Thread.U
if(toolbar == null) return; if(toolbar == null) return;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
toolbar.setElevation(UIHelper.dpToPixels(this, 3)); toolbar.setElevation(UIHelper.dpToPixels(this, 2));
setSupportActionBar(toolbar); setSupportActionBar(toolbar);

@ -42,6 +42,7 @@ import org.isoron.uhabits.commands.Command;
import org.isoron.uhabits.dialogs.EditHabitDialogFragment; import org.isoron.uhabits.dialogs.EditHabitDialogFragment;
import org.isoron.uhabits.dialogs.HistoryEditorDialog; import org.isoron.uhabits.dialogs.HistoryEditorDialog;
import org.isoron.uhabits.helpers.ColorHelper; import org.isoron.uhabits.helpers.ColorHelper;
import org.isoron.uhabits.helpers.DateHelper;
import org.isoron.uhabits.helpers.ReminderHelper; import org.isoron.uhabits.helpers.ReminderHelper;
import org.isoron.uhabits.helpers.UIHelper; import org.isoron.uhabits.helpers.UIHelper;
import org.isoron.uhabits.models.Habit; import org.isoron.uhabits.models.Habit;
@ -92,6 +93,8 @@ public class ShowHabitFragment extends Fragment
activity = (ShowHabitActivity) getActivity(); activity = (ShowHabitActivity) getActivity();
habit = activity.getHabit(); habit = activity.getHabit();
updateHeader(view);
dataViews = new LinkedList<>(); dataViews = new LinkedList<>();
Button btEditHistory = (Button) view.findViewById(R.id.btEditHistory); Button btEditHistory = (Button) view.findViewById(R.id.btEditHistory);
@ -105,7 +108,6 @@ public class ShowHabitFragment extends Fragment
previousScoreInterval = defaultScoreInterval; previousScoreInterval = defaultScoreInterval;
setScoreBucketSize(defaultScoreInterval); setScoreBucketSize(defaultScoreInterval);
sStrengthInterval.setSelection(defaultScoreInterval); sStrengthInterval.setSelection(defaultScoreInterval);
sStrengthInterval.setOnItemSelectedListener(this); sStrengthInterval.setOnItemSelectedListener(this);
@ -147,6 +149,48 @@ public class ShowHabitFragment extends Fragment
return view; 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 @Override
public void onResume() public void onResume()
{ {

@ -107,7 +107,7 @@ public abstract class HabitWidgetView extends FrameLayout implements HabitDataV
backgroundPaint.setAlpha(backgroundAlpha); backgroundPaint.setAlpha(backgroundAlpha);
frame = (ViewGroup) findViewById(R.id.frame); frame = (ViewGroup) findViewById(R.id.frame);
frame.setBackgroundDrawable(background); if(frame != null) frame.setBackgroundDrawable(background);
} }
@Override @Override

Binary file not shown.

After

Width:  |  Height:  |  Size: 610 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 610 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 183 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 198 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 388 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 403 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 122 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 133 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 798 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 821 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 168 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 185 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 214 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 234 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 243 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 257 B

@ -17,18 +17,91 @@
~ with this program. If not, see <http://www.gnu.org/licenses/>. ~ with this program. If not, see <http://www.gnu.org/licenses/>.
--> -->
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" <ScrollView
xmlns:habit="http://isoron.org/android" 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"
android:layout_width="fill_parent" xmlns:habit="http://isoron.org/android"
android:layout_height="wrap_content" xmlns:tools="http://schemas.android.com/tools"
android:background="?windowBackgroundColor"
android:fillViewport="true"> android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="?windowBackgroundColor"
android:clipToPadding="false"
android:fillViewport="true">
<LinearLayout <LinearLayout
style="@style/CardList" style="@style/CardList"
android:clipToPadding="false"
tools:context="org.isoron.uhabits.ShowHabitActivity"> 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 <LinearLayout
style="@style/Card" style="@style/Card"
android:gravity="start"> android:gravity="start">
@ -49,17 +122,17 @@
android:id="@+id/scoreRing" android:id="@+id/scoreRing"
android:layout_width="75dp" android:layout_width="75dp"
android:layout_height="75dp" android:layout_height="75dp"
android:layout_margin="10dp"
habit:percentage="0" habit:percentage="0"
habit:thickness="10"
habit:textSize="12" habit:textSize="12"
android:layout_margin="10dp"/> habit:thickness="10"/>
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/habit_strength" android:text="@string/habit_strength"
android:textSize="@dimen/smallTextSize" android:textColor="?mediumContrastTextColor"
android:textColor="?mediumContrastTextColor"/> android:textSize="@dimen/smallTextSize"/>
</LinearLayout> </LinearLayout>
@ -73,20 +146,20 @@
android:id="@+id/sStrengthInterval" android:id="@+id/sStrengthInterval"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="22dp" android:layout_height="22dp"
android:entries="@array/strengthIntervalNames"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:entries="@array/strengthIntervalNames"
android:theme="@style/SmallSpinner" android:theme="@style/SmallSpinner"
/> />
<TextView <TextView
android:id="@+id/tvStrength" android:id="@+id/tvStrength"
style="@style/CardHeader" style="@style/CardHeader"
android:text="@string/habit_strength"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="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 <org.isoron.uhabits.views.HabitScoreView
android:id="@+id/scoreView" android:id="@+id/scoreView"
@ -156,4 +229,4 @@
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
</ScrollView> </ScrollView>

@ -17,30 +17,30 @@
~ with this program. If not, see <http://www.gnu.org/licenses/>. ~ with this program. If not, see <http://www.gnu.org/licenses/>.
--> -->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout
xmlns:tools="http://schemas.android.com/tools" android:id="@+id/container"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/container" xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" xmlns:tools="http://schemas.android.com/tools"
android:layout_height="match_parent" android:layout_width="match_parent"
tools:context="org.isoron.uhabits.ShowHabitActivity" android:layout_height="match_parent"
tools:ignore="MergeRootFrame" tools:context="org.isoron.uhabits.ShowHabitActivity"
tools:menu="show_habit_activity_menu,show_habit_fragment_menu"> tools:ignore="MergeRootFrame"
tools:menu="show_habit_activity_menu,show_habit_fragment_menu">
<android.support.v7.widget.Toolbar <android.support.v7.widget.Toolbar
android:id="@+id/toolbar" android:id="@+id/toolbar"
app:popupTheme="?toolbarPopupTheme" style="@style/Toolbar"
app:popupTheme="?toolbarPopupTheme"/>
style="@style/Toolbar"/>
<fragment <fragment
android:id="@+id/fragment2" android:id="@+id/fragment2"
android:name="org.isoron.uhabits.fragments.ShowHabitFragment" android:name="org.isoron.uhabits.fragments.ShowHabitFragment"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
tools:layout="@layout/show_habit" android:layout_below="@id/toolbar"
android:layout_gravity="center" android:layout_gravity="center"
android:layout_below="@id/toolbar"/> tools:layout="@layout/show_habit"/>
<View <View
android:id="@+id/toolbarShadow" android:id="@+id/toolbarShadow"

@ -156,6 +156,7 @@
<string name="bug_report_failed">Failed to generate bug report.</string> <string name="bug_report_failed">Failed to generate bug report.</string>
<string name="generate_bug_report">Generate bug report</string> <string name="generate_bug_report">Generate bug report</string>
<string name="troubleshooting">Troubleshooting</string> <string name="troubleshooting">Troubleshooting</string>
<string name="help_translate">Help translate this app</string> <string name="help_translate">Help translate this app</string>
<string name="night_mode">Night mode</string> <string name="night_mode">Night mode</string>
<string name="use_pure_black">Pure black for 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="month">Month</string>
<string name="quarter">Quarter</string> <string name="quarter">Quarter</string>
<string name="year">Year</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> </resources>
Loading…
Cancel
Save