Skip to content

Commit

Permalink
Merge commit '7b2dce472fe28d445f4691e07b7a84b62a6fd728'
Browse files Browse the repository at this point in the history
  • Loading branch information
aziraphale committed Mar 21, 2012
2 parents c22dd92 + 7b2dce4 commit f51ce56
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 12 deletions.
Binary file added res/drawable/connecting.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 7 additions & 3 deletions res/layout/login.xml
Expand Up @@ -8,9 +8,13 @@
<LinearLayout android:layout_height="wrap_content"
android:layout_width="wrap_content" android:id="@+id/logo_layout"
android:layout_centerHorizontal="true" android:layout_marginTop="10dip" android:layout_marginBottom="20dip">
<ImageView android:layout_height="wrap_content"
android:layout_width="wrap_content" android:id="@+id/logo_img"
android:src="@drawable/icon"/>

<ImageView
android:id="@+id/logo_img"
android:layout_width="70dp"
android:layout_height="70dp"
android:src="@drawable/icon" />

<TextView android:layout_width="wrap_content" android:id="@+id/introText"
android:textSize="40dip" android:text="uasseldroid"
android:textColor="@color/logo_text_color" android:layout_height="wrap_content" android:layout_gravity="center" android:layout_marginTop="10dp"/>
Expand Down
2 changes: 1 addition & 1 deletion res/values/ids.xml
Expand Up @@ -41,7 +41,6 @@
<item type="id" name="BUFFERUPDATE_NEWMESSAGE"></item>
<item type="id" name="BUFFERUPDATE_USERSCHANGED"></item>
<item type="id" name="DISCONNECTED"></item>
<item type="id" name="CONNECTED"></item>
<item type="id" name="SET_BUFFER_PERM_HIDDEN"></item>
<item type="id" name="SET_BUFFER_TEMP_HIDDEN"></item>
<item name="INVALID_CERTIFICATE" type="id"></item>
Expand All @@ -53,5 +52,6 @@
<item type="id" name="LAST_SEEN_CHANGED"></item>
<item type="id" name="INIT_PROGRESS"></item>
<item type="id" name="INIT_DONE"></item>
<item type="id" name="CONNECTING"/>

</resources>
1 change: 1 addition & 0 deletions res/values/strings.xml
Expand Up @@ -36,4 +36,5 @@
<string name="preference_wake_lock">wakelock</string>
<string name="preference_keep_screen_on">keepscreenon</string>
<string name="nick_list_header">Nicks</string>
<string name="notification_connecting">Connecting to core</string>
</resources>
Expand Up @@ -62,6 +62,29 @@ public void notifyConnected() {
// Send the notification.
notifyManager.notify(R.id.NOTIFICATION, notification);
}

public void notifyConnecting() {
CharSequence text = context.getText(R.string.notification_connecting);
int icon = R.drawable.connecting;
int temp_flags = Notification.FLAG_ONGOING_EVENT;

// Set the icon, scrolling text and timestamp
Notification notification = new Notification(icon, text, System.currentTimeMillis());
notification.flags |= temp_flags;
// The PendingIntent to launch our activity if the user selects this notification
PendingIntent contentIntent;

Intent launch = new Intent(context, BufferActivity.class);
launch.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
contentIntent = PendingIntent.getActivity(context, 0, launch, 0);

// Set the info for the views that show in the notification panel.
notification.setLatestEventInfo(context, context.getText(R.string.app_name), text,
contentIntent);

// Send the notification.
notifyManager.notify(R.id.NOTIFICATION, notification);
}

public void notifyHighlight(Integer bufferId) {
if(bufferId != null && !highlightedBuffers.contains(bufferId)) {
Expand Down
2 changes: 1 addition & 1 deletion src/com/iskrembilen/quasseldroid/gui/LoginActivity.java
Expand Up @@ -151,7 +151,7 @@ public void onCreate(Bundle savedInstanceState) {

@Override
protected void onReceiveResult(int resultCode, Bundle resultData) {
if (resultCode==CoreConnService.CONNECTION_CONNECTED) {
if (resultCode==CoreConnService.CONNECTION_CONNECTING) {
removeDialog(R.id.DIALOG_CONNECTING);
Intent bufferIntent = new Intent(LoginActivity.this, BufferActivity.class);
if (sharedString != null && sharedString.length() > 0) {
Expand Down
4 changes: 2 additions & 2 deletions src/com/iskrembilen/quasseldroid/io/CoreConnection.java
Expand Up @@ -306,7 +306,7 @@ public void connect() throws UnknownHostException, IOException, GeneralSecurityE
connecting = true;

// Notify the UI we have an open socket
Message msg = service.getHandler().obtainMessage(R.id.CONNECTED);
Message msg = service.getHandler().obtainMessage(R.id.CONNECTING);
msg.sendToTarget();


Expand Down Expand Up @@ -353,7 +353,7 @@ public void connect() throws UnknownHostException, IOException, GeneralSecurityE
version = Integer.parseInt(matcher.group(1));
release = Integer.parseInt(matcher.group(2));
} else {
throw new IOException("Can't match core version, illegal version?");
throw new UnsupportedProtocolException("Can't match core version: " + coreInfo.getCoreVersion());
}

//Check that the protocol version is atleast 10 and the version is above 0.6.0
Expand Down
16 changes: 11 additions & 5 deletions src/com/iskrembilen/quasseldroid/service/CoreConnService.java
Expand Up @@ -89,6 +89,7 @@ public class CoreConnService extends Service {
public static final int UNSUPPORTED_PROTOCOL = 3;
public static final int INIT_PROGRESS = 4;
public static final int INIT_DONE = 5;
public static final int CONNECTION_CONNECTING = 6;

public static final String STATUS_KEY = "status";
public static final String CERT_KEY = "certificate";
Expand Down Expand Up @@ -814,9 +815,8 @@ public void handleMessage(Message msg) {
*/
buffer = networks.getBufferById(msg.arg1);
if (buffer != null) {
Boolean hasHighlights = buffer.hasUnseenHighlight();
buffer.setLastSeenMessage(msg.arg2);
if(hasHighlights)
if(buffer.hasUnseenHighlight())
notificationManager.notifyHighlightsRead(buffer.getInfo().id);
} else {
Log.e(TAG, "Getting set last seen message on unknown buffer: " + msg.arg1);
Expand All @@ -834,14 +834,16 @@ public void handleMessage(Message msg) {
}
break;

case R.id.CONNECTED:

case R.id.CONNECTING:
/**
* CoreConn has connected to a core
*/
notificationManager.notifyConnected();
sendStatusMessage(CoreConnService.CONNECTION_CONNECTED, null);
notificationManager.notifyConnecting();
sendStatusMessage(CoreConnService.CONNECTION_CONNECTING, null);
break;


case R.id.LOST_CONNECTION:
/**
* Lost connection with core, update notification
Expand Down Expand Up @@ -936,6 +938,10 @@ public void handleMessage(Message msg) {
sendStatusMessage(CoreConnService.INIT_PROGRESS, bundle);
break;
case R.id.INIT_DONE:
/**
* CoreConn has connected to a core
*/
notificationManager.notifyConnected();
sendStatusMessage(CoreConnService.INIT_DONE, null);
break;
case R.id.USER_PARTED:
Expand Down

0 comments on commit f51ce56

Please sign in to comment.