Skip to content
This repository has been archived by the owner on May 30, 2019. It is now read-only.

Commit

Permalink
Added rudimentary theme support
Browse files Browse the repository at this point in the history
Theme support is NOW! Woo! The documentation is nonexistent, and some
of the details are sketchy, but IT WORKS!

Included is the Base16 Monokai theme. Later to come might include
Zenburn and others! Yay!

This required some massive restructuring of how Messages are handled,
and how their colors are managed. In this case, a new Sub-Enum is created,
the Message.MessageColor enum, which defines a bunch of possible values.

Later on, I need to document all these.
  • Loading branch information
indrora committed Feb 11, 2014
1 parent 8c16d0e commit cc1b4c8
Show file tree
Hide file tree
Showing 19 changed files with 400 additions and 75 deletions.
9 changes: 9 additions & 0 deletions application/res/values/arrays.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,13 @@
<item>20</item>
<item>30</item>
</string-array>

<string-array name="theme_labels">
<item>Default</item>
<item>Monokai</item>
</string-array>
<string-array name="theme_values">
<item>default</item>
<item>monokai</item>
</string-array>
</resources>
5 changes: 4 additions & 1 deletion application/res/values/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@

<string name="key_mirc_colors" translatable="false">mirc_colors</string>
<string name="default_mirc_colors" translatable="false">true</string>


<string name="key_colorscheme" translatable="false">colorscheme</string>
<string name="default_colorscheme" translatable="false">default</string>

<string name="key_graphical_smilies" translatable="false">graphical_smilies</string>
<string name="default_graphical_smilies" translatable="false">true</string>

Expand Down
9 changes: 9 additions & 0 deletions application/res/xml/preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ along with Yaaic. If not, see <http://www.gnu.org/licenses/>.
android:entryValues="@array/fontsize_values"
android:key="@string/key_fontsize"
android:defaultValue="@string/default_fontsize" />
<ListPreference
android:title="Color scheme"
android:summary="May not look right until restart"
android:dialogTitle="Choose color scheme"
android:entries="@array/theme_labels"
android:entryValues="@array/theme_values"
android:defaultValue="@string/default_colorscheme"
android:key="@string/key_colorscheme"
/>
<CheckBoxPreference
android:title="@string/settings_icons_title"
android:summary="@string/settings_icons_desc"
Expand Down
28 changes: 28 additions & 0 deletions application/res/xml/theme_default.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<colorscheme>
<foreground>#ffffffff</foreground>
<background>#ff000000</background>
<userevent>#ff458509</userevent>
<error>#ffcc0000</error>
<channelevent>#ff729fcf</channelevent>
<topic>#ffbe9b01</topic>
<serverevent>#ffaaaaaa</serverevent>
<highlight>#ffcc0000</highlight>
<url>#FF00007F</url>
<color>#FFFFFFFF</color>
<color>#FF000000</color>
<color>#FF00007F</color>
<color>#FF009300</color>
<color>#FFFC0000</color>
<color>#FF7F0000</color>
<color>#FF9C009C</color>
<color>#FFFC7F00</color>
<color>#FFFFFF00</color>
<color>#FF00FC00</color>
<color>#FF008080</color>
<color>#FF00FFFF</color>
<color>#FF0000FF</color>
<color>#FFFF00FF</color>
<color>#FF7F7F7F</color>
<color>#FFD2D2D2</color>
</colorscheme>
30 changes: 30 additions & 0 deletions application/res/xml/theme_monokai.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<colorscheme>

<foreground>#fff9f8f5</foreground>

<background>#ff141414</background>
<userevent>#ffa1efe4</userevent>
<error>#fff92672</error>
<channelevent>#ff66d9ef</channelevent>
<topic>#ffa6e22e</topic>
<serverevent>#fffd971f</serverevent>
<highlight>#ffae81ff</highlight>
<url>#fff4bf75</url>
<color>#ff272822</color>
<color>#ff383830</color>
<color>#ff49483e</color>
<color>#ff75715e</color>
<color>#ffa59f85</color>
<color>#fff8f8f2</color>
<color>#fff5f4f1</color>
<color>#fff9f8f5</color>
<color>#fff92672</color>
<color>#fffd971f</color>
<color>#fff4bf75</color>
<color>#ffa6e22e</color>
<color>#ffa1efe4</color>
<color>#ff66d9ef</color>
<color>#ffae81ff</color>
<color>#ffcc6633</color>
</colorscheme>
1 change: 1 addition & 0 deletions application/src/indrora/atomic/Atomic.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.util.Set;


import android.app.Application;
import android.content.Context;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import indrora.atomic.listener.ServerListener;
import indrora.atomic.listener.SpeechClickListener;
import indrora.atomic.model.Broadcast;
import indrora.atomic.model.ColorScheme;
import indrora.atomic.model.Conversation;
import indrora.atomic.model.Extra;
import indrora.atomic.model.Message;
Expand Down Expand Up @@ -98,6 +99,9 @@ public class ConversationActivity extends SherlockActivity implements ServiceCon
private static final int REQUEST_CODE_USER = 3;
private static final int REQUEST_CODE_NICK_COMPLETION= 4;

private static ColorScheme _scheme;
public static ColorScheme getScheme() { return _scheme; }

private int serverId;
private Server server;
private IRCBinder binder;
Expand Down Expand Up @@ -183,6 +187,8 @@ protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);

_scheme = new ColorScheme(this);

serverId = getIntent().getExtras().getInt("serverId");
server = Atomic.getInstance().getServerById(serverId);
Settings settings = new Settings(this);
Expand Down Expand Up @@ -764,7 +770,7 @@ private void sendMessage(String text) {

if (!server.isConnected()) {
Message message = new Message(getString(R.string.message_not_connected));
message.setColor(Message.COLOR_RED);
message.setColor(Message.MessageColor.ERROR);
message.setIcon(R.drawable.error);
server.getConversation(server.getSelectedConversation()).addMessage(message);
onConversationMessage(server.getSelectedConversation());
Expand All @@ -783,7 +789,7 @@ private void sendMessage(String text) {
binder.getService().getConnection(serverId).sendMessage(conversation.getName(), text);
} else {
Message message = new Message(getString(R.string.chat_only_form_channel));
message.setColor(Message.COLOR_YELLOW);
message.setColor(Message.MessageColor.TOPIC);
message.setIcon(R.drawable.warning);
conversation.addMessage(message);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public MessageListAdapter(Conversation conversation, Context context)
// Render channel name as first message in channel
if (conversation.getType() != Conversation.TYPE_SERVER) {
Message header = new Message(conversation.getName());
header.setColor(Message.COLOR_RED);
header.setColor(Message.MessageColor.ERROR);
messages.add(header.renderTextView(context));
}

Expand Down
2 changes: 1 addition & 1 deletion application/src/indrora/atomic/command/CommandParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public void handleClientCommand(String type, String[] params, Server server, Con
// Command could not be executed
if (conversation != null) {
Message errorMessage = new Message(type + ": " + e.getMessage());
errorMessage.setColor(Message.COLOR_RED);
errorMessage.setColor(Message.MessageColor.ERROR);
conversation.addMessage(errorMessage);

// XXX:I18N - How to get a context here? (command_syntax)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public void execute(String[] params, Server server, Conversation conversation, I
service.getConnection(server.getId()).dccSendFile(file, params[2], 60000);

Message message = new Message(service.getString(R.string.dcc_waiting_accept, params[2]));
message.setColor(Message.COLOR_GREY);
message.setColor(Message.MessageColor.SERVER_EVENT);
conversation.addMessage(message);

service.sendBroadcast(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ private void showAllCommands(IRCService service, Server server, Conversation con
}

Message message = new Message(commandList.toString());
message.setColor(Message.COLOR_YELLOW);
message.setColor(Message.MessageColor.TOPIC);
conversation.addMessage(message);

Intent intent = Broadcast.createConversationIntent(
Expand Down Expand Up @@ -121,7 +121,7 @@ private void showCommandDetails(IRCService service, Server server, Conversation
if (commands.containsKey(command)) {
// XXX:I18N - String building salad :)
Message message = new Message("Help of /" + command + "\n" + commands.get(command).getUsage() + "\n" + commands.get(command).getDescription(service) + "\n");
message.setColor(Message.COLOR_YELLOW);
message.setColor(Message.MessageColor.TOPIC);
conversation.addMessage(message);

Intent intent = Broadcast.createConversationIntent(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public void execute(String[] params, Server server, Conversation conversation, I
}

Message message = new Message(userList.toString());
message.setColor(Message.COLOR_YELLOW);
message.setColor(Message.MessageColor.TOPIC);
conversation.addMessage(message);

Intent intent = Broadcast.createConversationIntent(
Expand Down
Loading

0 comments on commit cc1b4c8

Please sign in to comment.