Skip to content

Commit

Permalink
bugfixes and performance improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
pY4x3g committed Mar 28, 2015
1 parent 184aaf8 commit 503fdff
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 16 deletions.
4 changes: 2 additions & 2 deletions AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.redPanda"
android:versionCode="515"
android:versionName="0.1.515 beta">
android:versionCode="520"
android:versionName="0.1.520 beta">

<uses-sdk android:minSdkVersion="14"
android:targetSdkVersion="11" />
Expand Down
Binary file modified libs/bitchatj.jar
Binary file not shown.
9 changes: 7 additions & 2 deletions src/org/redPanda/BS.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import java.util.logging.Logger;
import org.redPanda.ChannelList.ChanPref;
import org.redPanda.ChannelList.Preferences;
import org.redPandaLib.ImageTooLargeException;
import org.redPandaLib.Main;
import org.redPandaLib.NewMessageListener;
import org.redPandaLib.core.Channel;
Expand Down Expand Up @@ -79,7 +80,7 @@ public class BS extends Service {
* service. The Message's replyTo field must be a Messenger of the client
* where callbacks should be sent.
*/
public static final int VERSION = 514;
public static final int VERSION = 520;
public static boolean updateAbleViaWeb = false;
public static final int SEND_MSG = 1;
public static final int MSG_REGISTER_CLIENT = 2;
Expand Down Expand Up @@ -344,7 +345,11 @@ public void run() {
}

setPriority(Thread.MIN_PRIORITY);
Main.sendImageToChannel(spchan, path, lowPriority);
try {
Main.sendImageToChannel(spchan, path, lowPriority);
} catch (ImageTooLargeException ex) {
//Toast.makeText(BS.this, "Image too large.", Toast.LENGTH_SHORT).show();
}
}
}.start();
break;
Expand Down
12 changes: 7 additions & 5 deletions src/org/redPanda/ChannelList/FlActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -990,10 +990,9 @@ public void run() {
final ArrayList<Peer> list = (ArrayList<Peer>) Test.peerList.clone();

for (Peer peer : list) {
if (peer.isConnected()) {
if (peer.isConnected() && peer.isAuthed() && peer.isCryptedConnection()) {
actCons++;
}
if (peer.isConnecting) {
} else if (peer.isConnecting || peer.isConnected() || peer.isAuthed()) {
connectingCons++;
}
}
Expand All @@ -1012,10 +1011,13 @@ public void run() {
if (isFinishing()) {
return;
}

final int messageCount = Test.messageStore.getMessageCount();

infotext.post(new Runnable() {

public void run() {
infotext.setText("Nodes: " + activeConnections + "/" + connectingConnections + "/" + list.size() + " - " + clonedTrusts.size() + " - " + trustedIpsFinal + ". Msgs: " + Test.messageStore.getMessageCount());
infotext.setText("Nodes: " + activeConnections + "/" + connectingConnections + "/" + list.size() + " - " + clonedTrusts.size() + " - " + trustedIpsFinal + ". Msgs: " + messageCount);
}
});
} else {
Expand All @@ -1034,7 +1036,7 @@ public void run() {
});
}
try {
sleep(100);
sleep(1000);
} catch (InterruptedException ex) {
}
}
Expand Down
14 changes: 13 additions & 1 deletion src/org/redPanda/ChatActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,22 @@ protected void onCreate(Bundle savedInstanceState) {
intent = new Intent(ChatActivity.this, FlActivity.class);
startActivity(intent);
finish();
return;
}

Intent in = getIntent();
this.setTitle(in.getExtras().getString("title"));
String string = in.getExtras().getString("title");

if (string == null) {
Toast.makeText(ChatActivity.this, "oops, no channel defined...", Toast.LENGTH_LONG).show();
Intent intent;
intent = new Intent(ChatActivity.this, FlActivity.class);
startActivity(intent);
finish();
return;
}

this.setTitle(string);
chan = (Channel) in.getExtras().get("Channel");
setContentView(R.layout.chatlayout);

Expand Down
26 changes: 20 additions & 6 deletions src/org/redPanda/ConnectivityChanged.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@
*/
public class ConnectivityChanged extends BroadcastReceiver {

private int lastConnectionType = -1; //-1: unknown, 1: mobile, 2: wlan

@Override
public void onReceive(Context context, Intent intent) {

// //Check if backend started successful
// if (Test.localSettings == null) {
// return;
// }

new ExceptionLogger(context);

final ConnectivityManager connMgr = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
Expand All @@ -43,9 +44,13 @@ public void onReceive(Context context, Intent intent) {
final android.net.NetworkInfo mobile = connMgr.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);

if (wifi.isConnected()) {


if (lastConnectionType == 1) {
Main.internetConnectionInterrupted();
}

Settings.REDUCE_TRAFFIC = false;

Settings.connectToNewClientsTill = Long.MAX_VALUE;

IntentFilter ifilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
Expand All @@ -64,16 +69,21 @@ public void onReceive(Context context, Intent intent) {
Settings.MIN_CONNECTIONS = 3;
}
} else {

Main.sendBroadCastMsg("batteryStatus was null...");//ToDo: remove

}

lastConnectionType = 2;

} else if (mobile != null && mobile.isConnected()) {

Settings.REDUCE_TRAFFIC = true;

Settings.MIN_CONNECTIONS = 2;

if (lastConnectionType == 2) {
Main.internetConnectionInterrupted();
}

SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(context);
boolean saveInternet = sharedPref.getBoolean(Preferences.KEY_SAVE_MOBILE_INTERNET, false);

Expand All @@ -96,8 +106,12 @@ public void onReceive(Context context, Intent intent) {
} else {
Settings.connectToNewClientsTill = Long.MAX_VALUE;
}

lastConnectionType = 1;

} else {
Settings.connectToNewClientsTill = Long.MIN_VALUE;
//lastConnectionType = -1;
}

}
Expand Down

0 comments on commit 503fdff

Please sign in to comment.