Skip to content

Commit

Permalink
Include current time on lockscreen
Browse files Browse the repository at this point in the history
  • Loading branch information
Yoni Samlan committed Jul 6, 2014
1 parent 2fd91fb commit 1be3af5
Show file tree
Hide file tree
Showing 10 changed files with 59 additions and 7 deletions.
Binary file modified artwork/screenshots/babytime_denied.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified artwork/screenshots/babytime_main_screen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified artwork/screenshots/framed/babytime_denied_framed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified artwork/screenshots/framed/babytime_main_screen_framed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions mobile/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
applicationId "com.yonisamlan.wearbabytime"
minSdkVersion 18
targetSdkVersion 20
versionCode 1
versionName "1.0"
versionCode 2
versionName "1.0.1"
}
buildTypes {
release {
Expand Down
4 changes: 2 additions & 2 deletions wear/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ android {
applicationId "com.yonisamlan.wearbabytime"
minSdkVersion 20
targetSdkVersion 20
versionCode 1
versionName "1.0"
versionCode 2
versionName "1.0.1"
}
buildTypes {
release {
Expand Down
2 changes: 1 addition & 1 deletion wear/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@android:style/Theme.DeviceDefault" >
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_name"
Expand Down
27 changes: 27 additions & 0 deletions wear/src/main/java/com/yonisamlan/wearbabytime/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,37 @@

import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.os.SystemClock;
import android.support.annotation.StringRes;
import android.text.format.Time;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.TextView;
import android.widget.Toast;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.concurrent.TimeUnit;

public class MainActivity extends Activity implements GestureDetector.OnGestureListener {
private static final String TAG = "babytime";
private static final long TOAST_RATE_LIMIT_MILLIS = 3500; // AOSP's Toast.LENGTH_LONG
private static final long MAX_UNLOCK_GESTURE_TIME_MILLIS = TimeUnit.SECONDS.toMillis(5);
private static final String TIME_FORMAT = "%H:%M";
private static final Time TIME = new Time();

private Handler mClockHandler;
private GestureDetector mGestureDetector;
private long mLastNotificationTimeMillis;
private long mUnlockGestureStartedMillis;
private int mUnlockStepCount;


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand All @@ -44,6 +54,23 @@ public boolean onTouch(View v, MotionEvent event) {
return true;
}
});

// Update the clock every minute
final TextView timeView = (TextView) findViewById(R.id.time);

mClockHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
if (!isFinishing() && timeView != null) {
TIME.setToNow();
long millisUntilNextMinute = (60 - TIME.second) * 1000;
mClockHandler.sendEmptyMessageDelayed(0, millisUntilNextMinute);
((TextView) timeView).setText(TIME.format(TIME_FORMAT));
}
}
};

mClockHandler.sendEmptyMessage(0);
}

@Override
Expand Down
14 changes: 12 additions & 2 deletions wear/src/main/res/layout/activity_wear_baby_time.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
android:orientation="vertical"
android:padding="8dip">


<TextView
android:layout_width="wrap_content"
android:layout_gravity="center_horizontal"
Expand All @@ -27,10 +26,21 @@
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="@string/title" />

<TextView
android:id="@+id/time"
android:layout_width="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="48sp"
android:fontFamily="sans-serif-light"
android:padding="8dip"
tools:text="23:37" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="8dip"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/directions" />
</LinearLayout>
Expand Down
15 changes: 15 additions & 0 deletions wear/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme" parent="@android:style/Theme.DeviceDefault">
<item name="android:textAppearanceLarge">@style/AppTextAppearanceLarge</item>
<item name="android:textAppearanceMedium">@style/AppTextAppearanceMedium</item>
</style>

<style name="AppTextAppearanceLarge" parent="@android:style/TextAppearance.Large">
<item name="android:textColor">@android:color/secondary_text_dark</item>
</style>

<style name="AppTextAppearanceMedium" parent="@android:style/TextAppearance.Medium">
<item name="android:textColor">@android:color/secondary_text_dark</item>
</style>
</resources>

0 comments on commit 1be3af5

Please sign in to comment.