Skip to content
Snippets Groups Projects
Commit b0689157 authored by Janne Mareike Koschinski's avatar Janne Mareike Koschinski
Browse files

Fixed bugs in heartbeat and other things

parent 703ddffe
No related branches found
No related tags found
No related merge requests found
Showing
with 245 additions and 186 deletions
package de.kuschku.libquassel; package de.kuschku.libquassel;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.util.Log;
import java.util.UUID; import java.util.UUID;
import de.greenrobot.event.EventBus; import de.greenrobot.event.EventBus;
import de.greenrobot.event.NoSubscriberEvent;
public class BusProvider { public class BusProvider {
@NonNull @NonNull
...@@ -16,11 +18,18 @@ public class BusProvider { ...@@ -16,11 +18,18 @@ public class BusProvider {
@NonNull @NonNull
private final String id; private final String id;
private final BusHandler handleHandler = new BusHandler("QHANDLE");
private final BusHandler dispatchHandler = new BusHandler("QDISPATCH");
private final BusHandler eventHandler = new BusHandler("QEVENT");
public BusProvider() { public BusProvider() {
this.id = UUID.randomUUID().toString(); this.id = UUID.randomUUID().toString();
this.handle = new EventBus(); this.handle = new EventBus();
this.handle.register(handleHandler);
this.dispatch = new EventBus(); this.dispatch = new EventBus();
this.dispatch.register(dispatchHandler);
this.event = new EventBus(); this.event = new EventBus();
this.event.register(eventHandler);
} }
public void handle(Object o) { public void handle(Object o) {
...@@ -41,4 +50,16 @@ public class BusProvider { ...@@ -41,4 +50,16 @@ public class BusProvider {
"id='" + id + '\'' + "id='" + id + '\'' +
'}'; '}';
} }
public static class BusHandler {
private final String identifier;
public BusHandler(String identifier) {
this.identifier = identifier;
}
public void onEvent(NoSubscriberEvent event) {
Log.e(identifier, String.valueOf(event));
}
}
} }
...@@ -181,7 +181,6 @@ public class CoreConnection { ...@@ -181,7 +181,6 @@ public class CoreConnection {
inputThread = new ReadThread(); inputThread = new ReadThread();
heartbeatThread = new HeartbeatThread(); heartbeatThread = new HeartbeatThread();
inputThread.start(); inputThread.start();
heartbeatThread.start();
} }
public void onEventAsync(HandshakeFailedEvent event) { public void onEventAsync(HandshakeFailedEvent event) {
...@@ -261,6 +260,7 @@ public class CoreConnection { ...@@ -261,6 +260,7 @@ public class CoreConnection {
// Mark prehandshake as read // Mark prehandshake as read
hasReadPreHandshake = true; hasReadPreHandshake = true;
heartbeatThread.start();
// Send client data to core // Send client data to core
String clientDate = new SimpleDateFormat("MMM dd yyyy HH:mm:ss", Locale.US).format(new Date()); String clientDate = new SimpleDateFormat("MMM dd yyyy HH:mm:ss", Locale.US).format(new Date());
...@@ -304,7 +304,6 @@ public class CoreConnection { ...@@ -304,7 +304,6 @@ public class CoreConnection {
while (running) { while (running) {
Heartbeat heartbeat = new Heartbeat(DateTime.now()); Heartbeat heartbeat = new Heartbeat(DateTime.now());
Log.e("heartbeat", String.valueOf(heartbeat));
busProvider.dispatch(heartbeat); busProvider.dispatch(heartbeat);
Thread.sleep(30 * 1000); Thread.sleep(30 * 1000);
......
...@@ -121,6 +121,8 @@ public class ProtocolHandler implements IProtocolHandler { ...@@ -121,6 +121,8 @@ public class ProtocolHandler implements IProtocolHandler {
} }
public void onEvent(@NonNull SessionInit message) { public void onEvent(@NonNull SessionInit message) {
busProvider.dispatch(new Heartbeat(DateTime.now()));
client.setState(message.SessionState); client.setState(message.SessionState);
client.setConnectionStatus(ConnectionChangeEvent.Status.INITIALIZING_DATA); client.setConnectionStatus(ConnectionChangeEvent.Status.INITIALIZING_DATA);
...@@ -148,8 +150,6 @@ public class ProtocolHandler implements IProtocolHandler { ...@@ -148,8 +150,6 @@ public class ProtocolHandler implements IProtocolHandler {
} }
public void onEventMainThread(@NonNull HeartbeatReply heartbeat) { public void onEventMainThread(@NonNull HeartbeatReply heartbeat) {
Log.e("heartbeatreply", String.valueOf(heartbeat));
long roundtrip = DateTime.now().getMillis() - heartbeat.dateTime.getMillis(); long roundtrip = DateTime.now().getMillis() - heartbeat.dateTime.getMillis();
long lag = (long) (roundtrip * 0.5); long lag = (long) (roundtrip * 0.5);
......
...@@ -29,7 +29,7 @@ public class HeartbeatReplySerializer implements FunctionSerializer<HeartbeatRep ...@@ -29,7 +29,7 @@ public class HeartbeatReplySerializer implements FunctionSerializer<HeartbeatRep
@Override @Override
public List serialize(@NonNull HeartbeatReply data) { public List serialize(@NonNull HeartbeatReply data) {
return Arrays.asList( return Arrays.asList(
FunctionType.HEARTBEATREPLY.id, new QVariant<>(FunctionType.HEARTBEATREPLY.id),
new QVariant<>(data.dateTime) new QVariant<>(data.dateTime)
); );
} }
......
...@@ -9,7 +9,6 @@ import java.util.List; ...@@ -9,7 +9,6 @@ import java.util.List;
import de.kuschku.libquassel.functions.FunctionType; import de.kuschku.libquassel.functions.FunctionType;
import de.kuschku.libquassel.functions.types.Heartbeat; import de.kuschku.libquassel.functions.types.Heartbeat;
import de.kuschku.libquassel.primitives.QMetaType;
import de.kuschku.libquassel.primitives.types.QVariant; import de.kuschku.libquassel.primitives.types.QVariant;
import static de.kuschku.util.AndroidAssert.assertTrue; import static de.kuschku.util.AndroidAssert.assertTrue;
...@@ -30,8 +29,8 @@ public class HeartbeatSerializer implements FunctionSerializer<Heartbeat> { ...@@ -30,8 +29,8 @@ public class HeartbeatSerializer implements FunctionSerializer<Heartbeat> {
@Override @Override
public List serialize(@NonNull Heartbeat data) { public List serialize(@NonNull Heartbeat data) {
return Arrays.asList( return Arrays.asList(
FunctionType.HEARTBEAT.id, new QVariant<>(FunctionType.HEARTBEAT.id),
new QVariant<>(QMetaType.Type.QDateTime, data.dateTime) new QVariant<>(data.dateTime)
); );
} }
......
...@@ -66,7 +66,7 @@ public class BacklogFilter implements UICallback { ...@@ -66,7 +66,7 @@ public class BacklogFilter implements UICallback {
} }
private boolean filterItem(Message message) { private boolean filterItem(Message message) {
return client.getIgnoreListManager().matches(message) || filteredTypes.contains(message.type); return (client.getIgnoreListManager() != null && client.getIgnoreListManager().matches(message)) || filteredTypes.contains(message.type);
} }
public void addFilter(Message.Type type) { public void addFilter(Message.Type type) {
......
...@@ -202,10 +202,10 @@ public class LegacyPeer implements RemotePeer { ...@@ -202,10 +202,10 @@ public class LegacyPeer implements RemotePeer {
busProvider.handle(UnpackedInitDataFunctionSerializer.get().deserialize((List<QVariant>) data.data)); busProvider.handle(UnpackedInitDataFunctionSerializer.get().deserialize((List<QVariant>) data.data));
break; break;
case HEARTBEAT: case HEARTBEAT:
busProvider.handle(HeartbeatSerializer.get().deserialize((List<QVariant>) data)); busProvider.handle(HeartbeatSerializer.get().deserialize((List<QVariant>) data.data));
break; break;
case HEARTBEATREPLY: case HEARTBEATREPLY:
busProvider.handle(HeartbeatReplySerializer.get().deserialize((List<QVariant>) data)); busProvider.handle(HeartbeatReplySerializer.get().deserialize((List<QVariant>) data.data));
break; break;
default: default:
busProvider.sendEvent(new GeneralErrorEvent("Unknown package received: " + data)); busProvider.sendEvent(new GeneralErrorEvent("Unknown package received: " + data));
......
package de.kuschku.libquassel.ssl; package de.kuschku.libquassel.ssl;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.util.Log;
import java.security.GeneralSecurityException; import java.security.GeneralSecurityException;
import java.security.KeyStore; import java.security.KeyStore;
......
...@@ -20,7 +20,7 @@ public class ClientBackgroundThread implements Runnable { ...@@ -20,7 +20,7 @@ public class ClientBackgroundThread implements Runnable {
@NonNull @NonNull
private static final ClientData CLIENT_DATA = new ClientData( private static final ClientData CLIENT_DATA = new ClientData(
new ClientData.FeatureFlags(true, true), new ClientData.FeatureFlags(true, true),
new byte[]{RemotePeer.DATASTREAM, RemotePeer.LEGACY}, new byte[]{RemotePeer.DATASTREAM},
"QuasselDroid-ng 0.1 | libquassel 0.2", "QuasselDroid-ng 0.1 | libquassel 0.2",
RemotePeer.PROTOCOL_VERSION_LEGACY RemotePeer.PROTOCOL_VERSION_LEGACY
); );
......
...@@ -42,6 +42,8 @@ import com.mikepenz.materialdrawer.model.ProfileDrawerItem; ...@@ -42,6 +42,8 @@ import com.mikepenz.materialdrawer.model.ProfileDrawerItem;
import com.mikepenz.materialdrawer.model.SecondaryDrawerItem; import com.mikepenz.materialdrawer.model.SecondaryDrawerItem;
import com.sothree.slidinguppanel.SlidingUpPanelLayout; import com.sothree.slidinguppanel.SlidingUpPanelLayout;
import org.joda.time.DateTime;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
...@@ -59,6 +61,7 @@ import de.kuschku.libquassel.events.ConnectionChangeEvent; ...@@ -59,6 +61,7 @@ import de.kuschku.libquassel.events.ConnectionChangeEvent;
import de.kuschku.libquassel.events.GeneralErrorEvent; import de.kuschku.libquassel.events.GeneralErrorEvent;
import de.kuschku.libquassel.events.LagChangedEvent; import de.kuschku.libquassel.events.LagChangedEvent;
import de.kuschku.libquassel.events.UnknownCertificateEvent; import de.kuschku.libquassel.events.UnknownCertificateEvent;
import de.kuschku.libquassel.functions.types.Heartbeat;
import de.kuschku.libquassel.localtypes.Buffer; import de.kuschku.libquassel.localtypes.Buffer;
import de.kuschku.libquassel.localtypes.ChannelBuffer; import de.kuschku.libquassel.localtypes.ChannelBuffer;
import de.kuschku.libquassel.localtypes.backlogmanagers.BacklogFilter; import de.kuschku.libquassel.localtypes.backlogmanagers.BacklogFilter;
...@@ -88,38 +91,76 @@ import static de.kuschku.util.AndroidAssert.assertNotNull; ...@@ -88,38 +91,76 @@ import static de.kuschku.util.AndroidAssert.assertNotNull;
@UiThread @UiThread
public class ChatActivity extends AppCompatActivity { public class ChatActivity extends AppCompatActivity {
@NonNull // Main layout
private final Status status = new Status();
@Bind(R.id.toolbar) @Bind(R.id.toolbar)
Toolbar toolbar; Toolbar toolbar;
@Bind(R.id.sliding_layout) @Bind(R.id.sliding_layout)
SlidingUpPanelLayout slidingLayout; SlidingUpPanelLayout slidingLayout;
@Bind(R.id.sliding_layout_history)
SlidingUpPanelLayout slidingLayoutHistory; // Input Line
@Bind(R.id.chatline_scroller) @Bind(R.id.chatline_scroller)
ScrollView chatlineScroller; ScrollView chatlineScroller;
@Bind(R.id.chatline) @Bind(R.id.chatline)
AppCompatEditText chatline; AppCompatEditText chatline;
@Bind(R.id.send) @Bind(R.id.send)
AppCompatImageButton send; AppCompatImageButton send;
// Input History
@Bind(R.id.sliding_layout_history)
SlidingUpPanelLayout slidingLayoutHistory;
@Bind(R.id.msg_history) @Bind(R.id.msg_history)
RecyclerView msgHistory; RecyclerView msgHistory;
@Bind(R.id.swipe_view)
SwipeRefreshLayout swipeView; // Advanced Formatter
@Bind(R.id.messages)
RecyclerView messages;
@Bind(R.id.formatting_menu) @Bind(R.id.formatting_menu)
ActionMenuView formattingMenu; ActionMenuView formattingMenu;
@Bind(R.id.formatting_toolbar) @Bind(R.id.formatting_toolbar)
Toolbar formattingToolbar; Toolbar formattingToolbar;
private AppContext context = new AppContext();
private ServiceInterface serviceInterface = new ServiceInterface(); // Content view
private QuasselService.LocalBinder binder; @Bind(R.id.swipe_view)
SwipeRefreshLayout swipeView;
@Bind(R.id.messages)
RecyclerView messages;
private MessageAdapter messageAdapter; private MessageAdapter messageAdapter;
private AccountHeader accountHeader; private AccountHeader accountHeader;
private Drawer drawerLeft; private Drawer drawerLeft;
private BufferViewConfigWrapper wrapper;
private AdvancedEditor editor; private AdvancedEditor editor;
private BufferViewConfigWrapper wrapper;
@NonNull
private final Status status = new Status();
private static class Status extends Storable {
@Store
int bufferId = -1;
@Store
int bufferViewConfigId = -1;
}
private ServiceInterface serviceInterface = new ServiceInterface();
private class ServiceInterface {
private void connect(@NonNull ServerAddress address) {
assertNotNull(binder);
disconnect();
context.setProvider(new BusProvider());
context.getProvider().event.register(ChatActivity.this);
binder.startBackgroundThread(context.getProvider(), address);
onConnectionEstablished();
context.getProvider().handle(new Heartbeat(DateTime.parse("1980-01-01T00:00")));
}
private void disconnect() {
if (context.getProvider() != null) {
context.getProvider().event.unregister(ChatActivity.this);
}
context.setProvider(null);
context.setClient(null);
}
}
private ServiceConnection serviceConnection = new ServiceConnection() { private ServiceConnection serviceConnection = new ServiceConnection() {
@UiThread @UiThread
public void onServiceConnected(@NonNull ComponentName cn, @NonNull IBinder service) { public void onServiceConnected(@NonNull ComponentName cn, @NonNull IBinder service) {
...@@ -131,9 +172,9 @@ public class ChatActivity extends AppCompatActivity { ...@@ -131,9 +172,9 @@ public class ChatActivity extends AppCompatActivity {
serviceInterface.disconnect(); serviceInterface.disconnect();
backgroundThread.provider.event.register(ChatActivity.this);
context.setClient(backgroundThread.handler.client);
context.setProvider(backgroundThread.provider); context.setProvider(backgroundThread.provider);
context.setClient(backgroundThread.handler.client);
context.getProvider().event.register(ChatActivity.this);
updateBufferViewConfigs(); updateBufferViewConfigs();
updateSubTitle(); updateSubTitle();
} }
...@@ -147,20 +188,30 @@ public class ChatActivity extends AppCompatActivity { ...@@ -147,20 +188,30 @@ public class ChatActivity extends AppCompatActivity {
} }
}; };
private static void updateNoColor(Buffer buffer, Menu menu) { @PreferenceWrapper(BuildConfig.APPLICATION_ID)
boolean isNoColor = isNoColor(buffer); public static abstract class Settings {
menu.findItem(R.id.format_bold).setEnabled(!isNoColor); @StringPreference("QUASSEL_LIGHT")
menu.findItem(R.id.format_italic).setEnabled(!isNoColor); String theme;
menu.findItem(R.id.format_underline).setEnabled(!isNoColor); @BooleanPreference(false)
menu.findItem(R.id.format_paint).setEnabled(!isNoColor); boolean fullHostmask;
menu.findItem(R.id.format_fill).setEnabled(!isNoColor); @IntPreference(2)
} int textSize;
@BooleanPreference(true)
boolean mircColors;
public static boolean isNoColor(Buffer buffer) { @StringPreference("")
return buffer instanceof ChannelBuffer && ((ChannelBuffer) buffer).getChannel() != null && String lastHost;
((ChannelBuffer) buffer).getChannel().getD_ChanModes().contains("c"); @IntPreference(4242)
int lastPort;
@StringPreference("")
String lastUsername;
@StringPreference("")
String lastPassword;
} }
private AppContext context = new AppContext();
private QuasselService.LocalBinder binder;
@Override @Override
protected void onCreate(@Nullable Bundle savedInstanceState) { protected void onCreate(@Nullable Bundle savedInstanceState) {
setupContext(); setupContext();
...@@ -186,6 +237,141 @@ public class ChatActivity extends AppCompatActivity { ...@@ -186,6 +237,141 @@ public class ChatActivity extends AppCompatActivity {
initLoader(); initLoader();
} }
@Override
protected void onPause() {
serviceInterface.disconnect();
unbindService(serviceConnection);
super.onPause();
}
@Override
protected void onResume() {
super.onResume();
Intent intent = new Intent(this, QuasselService.class);
bindService(intent, serviceConnection, Context.BIND_IMPORTANT);
}
@Override
protected void onStart() {
super.onStart();
}
@Override
protected void onStop() {
super.onStop();
}
@Override
protected void onRestart() {
super.onRestart();
}
@Override
protected void onDestroy() {
super.onDestroy();
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
}
@Override
protected void onSaveInstanceState(@NonNull Bundle outState) {
assertNotNull(outState);
super.onSaveInstanceState(outState);
status.onSaveInstanceState(outState);
}
@Override
protected void onRestoreInstanceState(@NonNull Bundle savedInstanceState) {
assertNotNull(savedInstanceState);
super.onRestoreInstanceState(savedInstanceState);
status.onRestoreInstanceState(savedInstanceState);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.chat, menu);
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
List<Integer> filterSettings = Arrays.asList(
Message.Type.Join.value,
Message.Type.Part.value,
Message.Type.Quit.value,
Message.Type.Nick.value,
Message.Type.Mode.value,
Message.Type.Topic.value
);
int[] filterSettingsInts = new int[filterSettings.size()];
for (int i = 0; i < filterSettingsInts.length; i++) {
filterSettingsInts[i] = filterSettings.get(i);
}
switch (item.getItemId()) {
case R.id.action_hide_events: {
if (context.getClient() != null) {
BacklogFilter backlogFilter = context.getClient().getBacklogManager().getFilter(status.bufferId);
if (backlogFilter != null) {
int oldFilters = backlogFilter.getFilters();
List<Integer> oldFiltersList = new ArrayList<>();
for (int type : filterSettings) {
if ((type & oldFilters) != 0)
oldFiltersList.add(filterSettings.indexOf(type));
}
Integer[] selectedIndices = oldFiltersList.toArray(new Integer[oldFiltersList.size()]);
new MaterialDialog.Builder(this)
.items(
"Joins",
"Parts",
"Quits",
"Nick Changes",
"Mode Changes",
"Topic Changes"
)
.itemsIds(filterSettingsInts)
.itemsCallbackMultiChoice(
selectedIndices,
(dialog, which, text) -> false
)
.positiveText("Select")
.negativeText("Cancel")
.onPositive((dialog, which) -> {
int filters = 0x00000000;
if (dialog.getSelectedIndices() != null)
for (int i : dialog.getSelectedIndices()) {
filters |= filterSettings.get(i);
}
backlogFilter.setFilters(filters);
})
.build()
.show();
}
}
}
}
return super.onOptionsItemSelected(item);
}
private static void updateNoColor(Buffer buffer, Menu menu) {
boolean isNoColor = isNoColor(buffer);
menu.findItem(R.id.format_bold).setEnabled(!isNoColor);
menu.findItem(R.id.format_italic).setEnabled(!isNoColor);
menu.findItem(R.id.format_underline).setEnabled(!isNoColor);
menu.findItem(R.id.format_paint).setEnabled(!isNoColor);
menu.findItem(R.id.format_fill).setEnabled(!isNoColor);
}
public static boolean isNoColor(Buffer buffer) {
return buffer instanceof ChannelBuffer && ((ChannelBuffer) buffer).getChannel() != null &&
((ChannelBuffer) buffer).getChannel().getD_ChanModes().contains("c");
}
private void setupContext() { private void setupContext() {
context.setSettings(new WrappedSettings(this)); context.setSettings(new WrappedSettings(this));
AppTheme theme = AppTheme.themeFromString(context.getSettings().theme.get()); AppTheme theme = AppTheme.themeFromString(context.getSettings().theme.get());
...@@ -331,102 +517,20 @@ public class ChatActivity extends AppCompatActivity { ...@@ -331,102 +517,20 @@ public class ChatActivity extends AppCompatActivity {
.withSavedInstance(savedInstanceState) .withSavedInstance(savedInstanceState)
.withProfileImagesVisible(false) .withProfileImagesVisible(false)
.withOnAccountHeaderListener((view, profile, current) -> { .withOnAccountHeaderListener((view, profile, current) -> {
if (!current) {
selectBufferViewConfig((int) profile.getIdentifier()); selectBufferViewConfig((int) profile.getIdentifier());
}
return true; return true;
}) })
.build(); .build();
} }
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.chat, menu);
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
List<Integer> filterSettings = Arrays.asList(
Message.Type.Join.value,
Message.Type.Part.value,
Message.Type.Quit.value,
Message.Type.Nick.value,
Message.Type.Mode.value,
Message.Type.Topic.value
);
int[] filterSettingsInts = new int[filterSettings.size()];
for (int i = 0; i < filterSettingsInts.length; i++) {
filterSettingsInts[i] = filterSettings.get(i);
}
switch (item.getItemId()) {
case R.id.action_hide_events: {
if (context.getClient() != null) {
BacklogFilter backlogFilter = context.getClient().getBacklogManager().getFilter(status.bufferId);
if (backlogFilter != null) {
int oldFilters = backlogFilter.getFilters();
List<Integer> oldFiltersList = new ArrayList<>();
for (int type : filterSettings) {
if ((type & oldFilters) != 0)
oldFiltersList.add(filterSettings.indexOf(type));
}
Integer[] selectedIndices = oldFiltersList.toArray(new Integer[oldFiltersList.size()]);
new MaterialDialog.Builder(this)
.items(
"Joins",
"Parts",
"Quits",
"Nick Changes",
"Mode Changes",
"Topic Changes"
)
.itemsIds(filterSettingsInts)
.itemsCallbackMultiChoice(
selectedIndices,
(dialog, which, text) -> false
)
.positiveText("Select")
.negativeText("Cancel")
.onPositive((dialog, which) -> {
int filters = 0x00000000;
if (dialog.getSelectedIndices() != null)
for (int i : dialog.getSelectedIndices()) {
filters |= filterSettings.get(i);
}
backlogFilter.setFilters(filters);
})
.build()
.show();
}
}
}
}
return super.onOptionsItemSelected(item);
}
@Override
protected void onPause() {
super.onPause();
serviceInterface.disconnect();
unbindService(serviceConnection);
}
@Override
protected void onResume() {
super.onResume();
Intent intent = new Intent(this, QuasselService.class);
bindService(intent, serviceConnection, Context.BIND_IMPORTANT);
}
public void setChatlineExpanded(boolean expanded) { public void setChatlineExpanded(boolean expanded) {
int selectionStart = chatline.getSelectionStart(); int selectionStart = chatline.getSelectionStart();
int selectionEnd = chatline.getSelectionEnd(); int selectionEnd = chatline.getSelectionEnd();
if (expanded) { if (expanded) {
chatlineScroller.getLayoutParams().height = ViewGroup.LayoutParams.MATCH_PARENT; chatline.getLayoutParams().height = ViewGroup.LayoutParams.WRAP_CONTENT;
} else { } else {
chatlineScroller.getLayoutParams().height = context.getThemeUtil().res.actionBarSize; chatline.getLayoutParams().height = context.getThemeUtil().res.actionBarSize;
} }
chatline.setSingleLine(!expanded); chatline.setSingleLine(!expanded);
...@@ -456,22 +560,6 @@ public class ChatActivity extends AppCompatActivity { ...@@ -456,22 +560,6 @@ public class ChatActivity extends AppCompatActivity {
.show(); .show();
} }
@Override
protected void onRestoreInstanceState(@NonNull Bundle savedInstanceState) {
assertNotNull(savedInstanceState);
super.onRestoreInstanceState(savedInstanceState);
status.onRestoreInstanceState(savedInstanceState);
}
@Override
protected void onSaveInstanceState(@NonNull Bundle outState) {
assertNotNull(outState);
super.onSaveInstanceState(outState);
status.onSaveInstanceState(outState);
}
private void selectBufferViewConfig(@IntRange(from = -1) int bufferViewConfigId) { private void selectBufferViewConfig(@IntRange(from = -1) int bufferViewConfigId) {
status.bufferViewConfigId = bufferViewConfigId; status.bufferViewConfigId = bufferViewConfigId;
accountHeader.setActiveProfile(bufferViewConfigId, false); accountHeader.setActiveProfile(bufferViewConfigId, false);
...@@ -671,51 +759,4 @@ public class ChatActivity extends AppCompatActivity { ...@@ -671,51 +759,4 @@ public class ChatActivity extends AppCompatActivity {
toolbar.setSubtitle(""); toolbar.setSubtitle("");
} }
} }
@PreferenceWrapper(BuildConfig.APPLICATION_ID)
public static abstract class Settings {
@StringPreference("QUASSEL_LIGHT")
String theme;
@BooleanPreference(false)
boolean fullHostmask;
@IntPreference(2)
int textSize;
@BooleanPreference(true)
boolean mircColors;
@StringPreference("")
String lastHost;
@IntPreference(4242)
int lastPort;
@StringPreference("")
String lastUsername;
@StringPreference("")
String lastPassword;
}
private static class Status extends Storable {
@Store
int bufferId = -1;
@Store
int bufferViewConfigId = -1;
}
private class ServiceInterface {
private void connect(@NonNull ServerAddress address) {
assertNotNull(binder);
disconnect();
BusProvider provider = new BusProvider();
provider.event.register(ChatActivity.this);
binder.startBackgroundThread(provider, address);
onConnectionEstablished();
}
private void disconnect() {
if (context.getProvider() != null)
context.getProvider().event.unregister(this);
context.setProvider(null);
context.setClient(null);
}
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment