Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion samples/notifications/default.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@

# Project target.
target=android-5
android.library.reference.1=../cicada/cicadalib
android.library.reference.1=../../cicadalib
9 changes: 9 additions & 0 deletions samples/phonestatus/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="src" path="CicadaLib_src"/>
<classpathentry kind="src" path="ApolloLib_src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
45 changes: 45 additions & 0 deletions samples/phonestatus/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>PhoneStatus</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
<linkedResources>
<link>
<name>ApolloLib_src</name>
<type>2</type>
<locationURI>_android_ApolloLib_c6286f16/src</locationURI>
</link>
<link>
<name>CicadaLib_src</name>
<type>2</type>
<locationURI>_android_CicadaLib_8981e3e4/src</locationURI>
</link>
</linkedResources>
</projectDescription>
16 changes: 16 additions & 0 deletions samples/phonestatus/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.hydraproductions.cicada.phonestatus"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="8" />

<application android:icon="@drawable/icon" android:label="@string/app_name">
<service android:name=".PhoneStatus"
android:label="@string/app_name"
android:exported="true">
<meta-data android:name="org.cicadasong.cicada.apptype"
android:value="WIDGET_AND_APP" />
</service>
</application>
</manifest>
12 changes: 12 additions & 0 deletions samples/phonestatus/default.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system use,
# "build.properties", and override values to adapt the script to your
# project structure.

# Project target.
target=android-8
android.library.reference.1=../../cicadalib
40 changes: 40 additions & 0 deletions samples/phonestatus/proguard.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*

-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
-keep public class com.android.vending.licensing.ILicensingService

-keepclasseswithmembernames class * {
native <methods>;
}

-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet);
}

-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}

-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
}

-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}

-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
Binary file added samples/phonestatus/res/drawable-hdpi/icon.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 added samples/phonestatus/res/drawable-ldpi/icon.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 added samples/phonestatus/res/drawable-mdpi/icon.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: 4 additions & 0 deletions samples/phonestatus/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Phone Status</string>
</resources>
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
package com.hydraproductions.cicada.phonestatus;

import org.cicadasong.cicadalib.CicadaApp;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Typeface;

import android.telephony.PhoneStateListener;
import android.telephony.TelephonyManager;
import android.telephony.SignalStrength; // API Level 7+
import android.util.Log;

/**
* @See http://developer.android.com/reference/android/telephony/SignalStrength.html#getGsmSignalStrength%28%29
* @See 3GPP TS 27.007 v6.3.0 (2003-06) - Section 8.5 - Signal Quality +CSQ
* @author Dominic Clifton <me@dominicclifton.name>
*/
public class PhoneStatus extends CicadaApp {

public static final String TAG = PhoneStatus.class.getSimpleName();

private Paint paint;
private TelephonyManager telephonyManager;
private StatusPhoneStateListener phoneStateListener;
float signalStrengthPercentage;

final static short GSM_STRENGTH_MIN = 0;
final static short GSM_STRENGTH_MAX = 31;
final static short GSM_STRENGTH_UNKNOWN = 99;

protected float calculateSignalStrengthPercentage(SignalStrength signalStrength) {
// TODO add CDMA signal strength calculations
int gsmSignalStrength = signalStrength.getGsmSignalStrength();
Log.i(TAG, String.format("GSM Signal Strength: %d", gsmSignalStrength));
if (gsmSignalStrength == GSM_STRENGTH_MAX) {
return 0;
}
return (float)(gsmSignalStrength * 100) / GSM_STRENGTH_UNKNOWN;
}

protected void updateSignalStrength(SignalStrength signalStrength) {
signalStrengthPercentage = calculateSignalStrengthPercentage(signalStrength);

if (!PhoneStatus.this.isActive()) {
return;
}
invalidate();
}


private class StatusPhoneStateListener extends PhoneStateListener {
@Override
public void onSignalStrengthsChanged(SignalStrength signalStrength) {
updateSignalStrength(signalStrength);
}
};

@Override
public void onCreate() {
super.onCreate();
phoneStateListener = new StatusPhoneStateListener();
telephonyManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
}

@Override
public String getAppName() {
return getString(R.string.app_name);
}

@Override
protected void onResume() {
paint = new Paint();
paint.setTextAlign(Paint.Align.CENTER);
paint.setTypeface(Typeface.DEFAULT_BOLD);
paint.setAntiAlias(false);
paint.setTextSize(16);

telephonyManager.listen(phoneStateListener, PhoneStateListener.LISTEN_SIGNAL_STRENGTHS);

invalidate();
}

@Override
protected void onPause() {
telephonyManager.listen(phoneStateListener, PhoneStateListener.LISTEN_NONE);
}

@Override
protected void onDraw(Canvas canvas) {
int x = canvas.getWidth() / 2;
int y = (int) (canvas.getHeight() - paint.ascent()) / 2;
String readout = String.format("%3.2f%%", signalStrengthPercentage);
canvas.drawText(readout, x, y, paint);
}

@Override
protected void onButtonPress(WatchButton button) {
// TODO Auto-generated method stub
}
}
2 changes: 1 addition & 1 deletion samples/stopwatch/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.hydraproductions.cicada"
package="com.hydraproductions.cicada.stopwatch"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="8" />
Expand Down
2 changes: 1 addition & 1 deletion samples/stopwatch/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">StopWatch</string>
<string name="app_name">Stopwatch</string>
</resources>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.hydraproductions.cicada;
package com.hydraproductions.cicada.stopwatch;

/**
* Stopwatch example
Expand Down