Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c7a4aa7d authored by Roman Birg's avatar Roman Birg
Browse files

SystemUI: make clock and time clickable in statusbar



Clicking clock opens alarms, clicking the date will open the calendar.

Change-Id: I622527c1f144a8867aa543348b70a4fefe3f6403
Signed-off-by: default avatarRoman Birg <roman@cyngn.com>
parent 00c2018e
Loading
Loading
Loading
Loading
+13 −7
Original line number Diff line number Diff line
@@ -107,6 +107,7 @@
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="@dimen/clock_collapsed_bottom_margin"
        android:background="@drawable/ripple_drawable"
        android:layout_alignParentBottom="true">
        <com.android.systemui.statusbar.policy.DateView android:id="@+id/date_collapsed"
            android:layout_width="wrap_content"
@@ -129,13 +130,18 @@
            />
    </FrameLayout>

    <FrameLayout
            android:id="@+id/clock"
            android:layout_marginStart="16dp"
            android:layout_above="@id/date_group"
            android:background="@drawable/ripple_drawable"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content">
        <include layout="@layout/split_clock_view"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
        android:layout_marginStart="16dp"
        android:layout_above="@id/date_group"
        android:id="@+id/clock"
                />
    </FrameLayout>

    <Button android:id="@+id/alarm_status"
        android:layout_width="wrap_content"
+23 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.systemui.statusbar.phone;

import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.ContentUris;
import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
@@ -27,6 +28,9 @@ import android.graphics.Rect;
import android.graphics.drawable.Animatable;
import android.graphics.drawable.Drawable;
import android.telephony.TelephonyManager;
import android.net.Uri;
import android.provider.AlarmClock;
import android.provider.CalendarContract;
import android.util.AttributeSet;
import android.util.MathUtils;
import android.util.TypedValue;
@@ -133,7 +137,9 @@ public class StatusBarHeaderView extends RelativeLayout implements View.OnClickL
        mSystemIconsContainer = (ViewGroup) findViewById(R.id.system_icons_container);
        mSystemIconsSuperContainer.setOnClickListener(this);
        mDateGroup = findViewById(R.id.date_group);
        mDateGroup.setOnClickListener(this);
        mClock = findViewById(R.id.clock);
        mClock.setOnClickListener(this);
        mTime = (TextView) findViewById(R.id.time_view);
        mAmPm = (TextView) findViewById(R.id.am_pm_view);
        mMultiUserSwitch = (MultiUserSwitch) findViewById(R.id.multi_user_switch);
@@ -511,6 +517,10 @@ public class StatusBarHeaderView extends RelativeLayout implements View.OnClickL
            if (showIntent != null && showIntent.isActivity()) {
                mActivityStarter.startActivity(showIntent.getIntent(), true /* dismissShade */);
            }
        } else if (v == mClock) {
            startClockActivity();
        } else if (v == mDateGroup) {
            startDateActivity();
        }
    }

@@ -524,6 +534,19 @@ public class StatusBarHeaderView extends RelativeLayout implements View.OnClickL
                true /* dismissShade */);
    }

    private void startClockActivity() {
        mActivityStarter.startActivity(new Intent(AlarmClock.ACTION_SHOW_ALARMS),
                true /* dismissShade */);
    }

    private void startDateActivity() {
        Uri.Builder builder = CalendarContract.CONTENT_URI.buildUpon();
        builder.appendPath("time");
        ContentUris.appendId(builder, System.currentTimeMillis());
        Intent intent = new Intent(Intent.ACTION_VIEW).setData(builder.build());
        mActivityStarter.startActivity(intent, true /* dismissShade */);
    }

    public void setQSPanel(QSPanel qsp) {
        mQSPanel = qsp;
        if (mQSPanel != null) {