Skip to content

Commit

Permalink
Improve Stop/Snooze activity appearance
Browse files Browse the repository at this point in the history
- Created Footer
- Stop button is octagon
  • Loading branch information
shauleiz committed Jun 10, 2024
1 parent 794a712 commit 65a85c4
Show file tree
Hide file tree
Showing 4 changed files with 137 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.util.AttributeSet;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
Expand All @@ -24,6 +25,8 @@
import android.view.WindowInsets;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.PopupMenu;
Expand All @@ -46,6 +49,8 @@ public class StopSnoozeActivity extends AppCompatActivity {
BroadcastReceiver broadcastReceiver;
private SimpleDateFormat dateFormat;

private TextView footer;

/**
* If {@link #AUTO_HIDE} is set, the number of milliseconds to wait after
* user interaction before hiding the system UI.
Expand Down Expand Up @@ -242,6 +247,17 @@ public boolean onTouch(View view, MotionEvent motionEvent) {
};
private ActivityStopSnoozeBinding binding;


@Nullable
@Override
public View onCreateView(@Nullable View parent, @NonNull String name, @NonNull Context context, @NonNull AttributeSet attrs) {
View view = super.onCreateView(parent, name, context, attrs);



return view;
}

@SuppressLint("ClickableViewAccessibility")
@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -254,7 +270,7 @@ protected void onCreate(Bundle savedInstanceState) {
mControlsView = binding.fullscreenContentControls;
mContentView = binding.fullscreenContent;


footer = findViewById(R.id.footnote);

// Allow this activity on a locked screen
allowOnLockScreen();
Expand Down Expand Up @@ -425,7 +441,9 @@ private void DisplayScreenText()
if (!label.isEmpty())
label+=" - ";

String displayText = String.format(Locale.US,"%s\n%s%s", appName, label, strCurrentTime);
String displayText = String.format(Locale.US,"%s%s", label, strCurrentTime);
((TextView)mContentView).setText(displayText);

footer.setText(appName);
}
}
3 changes: 3 additions & 0 deletions app/src/main/res/drawable/iconmonstr_octagon_1.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:alpha="1.0" android:height="24dp" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">
<path android:fillColor="#FFFF0000" android:pathData="M24,16.971l-7.029,7.029h-9.942l-7.029,-7.029v-9.942l7.029,-7.029h9.942l7.029,7.029z"/>
</vector>
67 changes: 54 additions & 13 deletions app/src/main/res/layout-land/activity_stop_snooze.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<!-- The primary full-screen view. This can be replaced with whatever view
is needed to present your content, e.g. VideoView, SurfaceView,
TextureView, etc. -->

<TextView
android:id="@+id/fullscreen_content"
android:layout_width="0dp"
Expand Down Expand Up @@ -49,39 +50,79 @@
app:layout_constraintVertical_bias="1.0"
tools:ignore="UselessParent">

<Button
android:id="@+id/stop_button"
<FrameLayout
android:layout_width="200dp"
android:layout_height="200dp"
android:autoSizeMinTextSize="14sp"
android:backgroundTint="@android:color/holo_red_light"
android:gravity="center_horizontal|center_vertical"
android:text="@string/stop_button"
android:textAlignment="center"
android:textAppearance="@style/TextAppearance.AppCompat.Body2"
android:textSize="30sp"
android:layout_gravity="center"
android:layout_marginEnd="32dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/snooze_button"
app:layout_constraintTop_toTopOf="@+id/snooze_button" />
app:layout_constraintTop_toTopOf="@+id/snooze_button">

<Button
android:id="@+id/stop_button"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:autoSizeMinTextSize="14sp"
android:background="@drawable/iconmonstr_octagon_1"
android:foreground="@drawable/iconmonstr_octagon_1"
android:gravity="center_horizontal|center_vertical"
android:text="@string/stop_button"
android:textAlignment="center"
android:textAppearance="@style/TextAppearance.AppCompat.Body2"
android:textSize="30sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/stoptext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:text="@string/stop_button"
android:textAlignment="center"
android:textAppearance="@style/TextAppearance.AppCompat.Body2"
android:textColor="@color/white"
android:textSize="30sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />

</FrameLayout>


<Button
android:id="@+id/snooze_button"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_marginStart="32dp"
android:autoSizeMinTextSize="14sp"
android:backgroundTint="@android:color/holo_orange_dark"
android:text="@string/snooze_button"
android:textAppearance="@style/TextAppearance.AppCompat.Body2"
android:textSize="30sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/stop_button"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintHorizontal_chainStyle="spread"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

<TextView
android:id="@+id/footnote"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center_horizontal|bottom"
android:keepScreenOn="true"
android:maxLines="10"
android:paddingTop="24dp"
android:text="@string/dummy_content"
android:textColor="@color/design_default_color_surface"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />


</androidx.constraintlayout.widget.ConstraintLayout>
79 changes: 60 additions & 19 deletions app/src/main/res/layout/activity_stop_snooze.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<!-- The primary full-screen view. This can be replaced with whatever view
is needed to present your content, e.g. VideoView, SurfaceView,
TextureView, etc. -->

<TextView
android:id="@+id/fullscreen_content"
android:layout_width="0dp"
Expand All @@ -38,51 +39,91 @@
android:layout_height="0dp"
android:layout_marginTop="128dp"

android:layout_marginBottom="16dp"
android:backgroundTint="@color/light_blue_600"
android:layout_marginBottom="32dp"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/fullscreen_content"
app:layout_constraintVertical_bias="1.0"
app:layout_constraintVertical_bias="0.0"
tools:ignore="UselessParent">

<Button
android:id="@+id/stop_button"

<FrameLayout
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_marginTop="64dp"
android:autoSizeMinTextSize="14sp"
android:backgroundTint="@android:color/holo_red_light"
android:gravity="center_horizontal|center_vertical"
android:text="@string/stop_button"
android:textAlignment="center"
android:textAppearance="@style/TextAppearance.AppCompat.Body2"
android:textSize="30sp"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_gravity="center"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/snooze_button" />
app:layout_constraintTop_toTopOf="parent">

<Button
android:id="@+id/stop_button"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:autoSizeMinTextSize="14sp"
android:background="@drawable/iconmonstr_octagon_1"
android:foreground="@drawable/iconmonstr_octagon_1"
android:gravity="center_horizontal|center_vertical"
android:text="@string/stop_button"
android:textAlignment="center"
android:textAppearance="@style/TextAppearance.AppCompat.Body2"
android:textSize="30sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/stoptext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:text="@string/stop_button"
android:textAlignment="center"
android:textAppearance="@style/TextAppearance.AppCompat.Body2"
android:textColor="@color/white"
android:textSize="30sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />


</FrameLayout>


<Button
android:id="@+id/snooze_button"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_marginBottom="64dp"
android:autoSizeMinTextSize="14sp"
android:backgroundTint="@android:color/holo_orange_dark"
android:text="@string/snooze_button"
android:textAppearance="@style/TextAppearance.AppCompat.Body2"
android:textSize="30sp"
app:layout_constraintBottom_toTopOf="@+id/stop_button"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintStart_toStartOf="parent" />


</androidx.constraintlayout.widget.ConstraintLayout>

<TextView
android:id="@+id/footnote"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center_horizontal|bottom"
android:keepScreenOn="true"
android:maxLines="10"
android:paddingTop="24dp"
android:text="@string/dummy_content"
android:textColor="@color/design_default_color_surface"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />


</androidx.constraintlayout.widget.ConstraintLayout>

0 comments on commit 65a85c4

Please sign in to comment.