diff --git a/application/AndroidManifest.xml b/application/AndroidManifest.xml
index 22da244..b9457c4 100644
--- a/application/AndroidManifest.xml
+++ b/application/AndroidManifest.xml
@@ -26,7 +26,8 @@ along with Yaaic. If not, see .
+ android:label="Yaaic"
+ android:theme="@style/Theme.Sherlock">
.
-->
-
-
-
-
-
-
\ No newline at end of file
+ android:layout_gravity="center_vertical"
+ android:drawableLeft="@drawable/actionbar_add"
+ android:drawablePadding="5dip"
+ android:padding="10dip"
+ android:gravity="center_vertical"
+ android:text="@string/add_server_list"
+ android:textSize="18sp" />
diff --git a/application/res/layout/border.xml b/application/res/layout/conversation_background.xml
similarity index 93%
rename from application/res/layout/border.xml
rename to application/res/layout/conversation_background.xml
index 0a18b00..5473b3f 100644
--- a/application/res/layout/border.xml
+++ b/application/res/layout/conversation_background.xml
@@ -24,12 +24,12 @@ along with Yaaic. If not, see .
android:shape="rectangle">
+ android:color="#FF181818" />
+ android:color="#FF000000" />
\ No newline at end of file
diff --git a/application/res/layout/serveradd.xml b/application/res/layout/serveradd.xml
index f1159d7..e49b2d9 100644
--- a/application/res/layout/serveradd.xml
+++ b/application/res/layout/serveradd.xml
@@ -27,16 +27,13 @@ along with Yaaic. If not, see .
+ android:layout_height="wrap_content">
+ android:layout_marginBottom="3dip"
+ style="?android:attr/listSeparatorTextViewStyle" />
.
android:text="@string/user"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
- android:background="#ff333333"
- android:textSize="16sp"
- android:gravity="center_horizontal"
- android:padding="3dp"
- android:layout_margin="2dp" />
+ android:layout_marginBottom="3dip"
+ style="?android:attr/listSeparatorTextViewStyle" />
.
android:singleLine="true" />
+ android:text="@string/on_connect"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="3dip"
+ style="?android:attr/listSeparatorTextViewStyle" />
.
android:text="@string/commands" />
+ android:text="@string/preferences"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="3dip"
+ style="?android:attr/listSeparatorTextViewStyle" />
+
+
\ No newline at end of file
diff --git a/application/res/menu/conversations.xml b/application/res/menu/conversations.xml
index bf91ae8..9cb0116 100644
--- a/application/res/menu/conversations.xml
+++ b/application/res/menu/conversations.xml
@@ -23,17 +23,21 @@ along with Yaaic. If not, see .
+ android:icon="@drawable/actionbar_add"
+ android:showAsAction="ifRoom|withText" />
+ android:icon="@drawable/actionbar_users"
+ android:showAsAction="ifRoom|withText" />
+ android:icon="@android:drawable/ic_menu_close_clear_cancel"
+ android:showAsAction="never" />
+ android:icon="@android:drawable/ic_menu_revert"
+ android:showAsAction="never" />
\ No newline at end of file
diff --git a/application/res/menu/servers.xml b/application/res/menu/servers.xml
index bf687c3..d01d03e 100644
--- a/application/res/menu/servers.xml
+++ b/application/res/menu/servers.xml
@@ -23,11 +23,13 @@ along with Yaaic. If not, see .
+ android:icon="@drawable/actionbar_add"
+ android:showAsAction="ifRoom|withText" />
+ android:icon="@drawable/actionbar_settings"
+ android:showAsAction="ifRoom" />
- Users
Channels
Add new server
+ Edit server
Title
Host
diff --git a/application/src/org/yaaic/activity/AddServerActivity.java b/application/src/org/yaaic/activity/AddServerActivity.java
index d862674..c13db50 100644
--- a/application/src/org/yaaic/activity/AddServerActivity.java
+++ b/application/src/org/yaaic/activity/AddServerActivity.java
@@ -34,7 +34,6 @@ import org.yaaic.model.Identity;
import org.yaaic.model.Server;
import org.yaaic.model.Status;
-import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
@@ -47,12 +46,17 @@ import android.widget.EditText;
import android.widget.Spinner;
import android.widget.Toast;
+import com.actionbarsherlock.app.SherlockActivity;
+import com.actionbarsherlock.view.Menu;
+import com.actionbarsherlock.view.MenuInflater;
+import com.actionbarsherlock.view.MenuItem;
+
/**
* Add a new server to the list
*
* @author Sebastian Kaspari
*/
-public class AddServerActivity extends Activity implements OnClickListener
+public class AddServerActivity extends SherlockActivity implements OnClickListener
{
private static final int REQUEST_CODE_CHANNELS = 1;
private static final int REQUEST_CODE_COMMANDS = 2;
@@ -95,6 +99,8 @@ public class AddServerActivity extends Activity implements OnClickListener
Bundle extras = getIntent().getExtras();
if (extras != null && extras.containsKey(Extra.SERVER)) {
+ setTitle(R.string.edit_server_label);
+
// Request to edit an existing server
Database db = new Database(this);
this.server = db.getServerById(extras.getInt(Extra.SERVER));
@@ -149,6 +155,35 @@ public class AddServerActivity extends Activity implements OnClickListener
}
}
+ /**
+ * On options menu requested
+ */
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu)
+ {
+ super.onCreateOptionsMenu(menu);
+
+ MenuInflater inflater = new MenuInflater(this);
+ inflater.inflate(R.menu.addserver, menu);
+
+ return true;
+ }
+
+ /**
+ * On menu item selected
+ */
+ @Override
+ public boolean onMenuItemSelected(int featureId, MenuItem item)
+ {
+ switch (item.getItemId()) {
+ case R.id.save:
+ save();
+ return true;
+ }
+
+ return super.onMenuItemSelected(featureId, item);
+ }
+
/**
* On activity result
*/
@@ -215,19 +250,7 @@ public class AddServerActivity extends Activity implements OnClickListener
break;
case R.id.add:
- try {
- validateServer();
- validateIdentity();
- if (server == null) {
- addServer();
- } else {
- updateServer();
- }
- setResult(RESULT_OK);
- finish();
- } catch(ValidationException e) {
- Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show();
- }
+ save();
break;
case R.id.cancel:
@@ -237,6 +260,25 @@ public class AddServerActivity extends Activity implements OnClickListener
}
}
+ /**
+ * Try to save server.
+ */
+ private void save() {
+ try {
+ validateServer();
+ validateIdentity();
+ if (server == null) {
+ addServer();
+ } else {
+ updateServer();
+ }
+ setResult(RESULT_OK);
+ finish();
+ } catch(ValidationException e) {
+ Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show();
+ }
+ }
+
/**
* Add server to database
*/
diff --git a/application/src/org/yaaic/activity/ConversationActivity.java b/application/src/org/yaaic/activity/ConversationActivity.java
index 4520cd8..8cc4fdd 100644
--- a/application/src/org/yaaic/activity/ConversationActivity.java
+++ b/application/src/org/yaaic/activity/ConversationActivity.java
@@ -49,7 +49,6 @@ import org.yaaic.model.User;
import org.yaaic.receiver.ConversationReceiver;
import org.yaaic.receiver.ServerReceiver;
-import android.app.Activity;
import android.app.AlertDialog;
import android.content.ComponentName;
import android.content.DialogInterface;
@@ -66,14 +65,9 @@ import android.os.IBinder;
import android.speech.RecognizerIntent;
import android.support.v4.view.ViewPager;
import android.text.InputType;
-import android.util.DisplayMetrics;
import android.view.KeyEvent;
-import android.view.Menu;
-import android.view.MenuInflater;
-import android.view.MenuItem;
import android.view.View;
import android.view.View.OnKeyListener;
-import android.view.Window;
import android.view.WindowManager;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager;
@@ -81,14 +75,20 @@ import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
+import com.actionbarsherlock.app.ActionBar;
+import com.actionbarsherlock.app.SherlockActivity;
+import com.actionbarsherlock.view.Menu;
+import com.actionbarsherlock.view.MenuInflater;
+import com.actionbarsherlock.view.MenuItem;
import com.viewpagerindicator.TitlePageIndicator;
+import com.viewpagerindicator.TitlePageIndicator.IndicatorStyle;
/**
* The server view with a scrollable list of all channels
*
* @author Sebastian Kaspari
*/
-public class ConversationActivity extends Activity implements ServiceConnection, ServerListener, ConversationListener
+public class ConversationActivity extends SherlockActivity implements ServiceConnection, ServerListener, ConversationListener
{
public static final int REQUEST_CODE_SPEECH = 99;
@@ -171,7 +171,6 @@ public class ConversationActivity extends Activity implements ServiceConnection,
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
- requestWindowFeature(Window.FEATURE_NO_TITLE);
serverId = getIntent().getExtras().getInt("serverId");
server = Yaaic.getInstance().getServerById(serverId);
@@ -182,13 +181,17 @@ public class ConversationActivity extends Activity implements ServiceConnection,
this.finish();
}
- setTitle("Yaaic - " + server.getTitle());
+ ActionBar actionBar = getSupportActionBar();
+ actionBar.setDisplayHomeAsUpEnabled(true);
- setContentView(R.layout.conversations);
- if (settings.fullscreenConversations()){
+ setTitle(server.getTitle());
+
+ if (settings.fullscreenConversations()) {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
+ setContentView(R.layout.conversations);
+
boolean isLandscape = (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE);
EditText input = (EditText) findViewById(R.id.input);
@@ -199,10 +202,21 @@ public class ConversationActivity extends Activity implements ServiceConnection,
pagerAdapter = new ConversationPagerAdapter(server);
pager.setAdapter(pagerAdapter);
+ final float density = getResources().getDisplayMetrics().density;
+
TitlePageIndicator indicator = (TitlePageIndicator) findViewById(R.id.titleIndicator);
indicator.setTypeface(Typeface.MONOSPACE);
indicator.setViewPager(pager);
+ indicator.setFooterColor(0xFF31B6E7);
+ indicator.setFooterLineHeight(1 * density);
+ indicator.setFooterIndicatorHeight(3 * density);
+ indicator.setFooterIndicatorStyle(IndicatorStyle.Underline);
+ indicator.setTextColor(0xFFDDDDDD);
+ indicator.setSelectedColor(0xFFFFFFFF);
+ indicator.setSelectedBold(true);
+ indicator.setBackgroundColor(0xFF181818);
+
historySize = settings.getHistorySize();
if (server.getStatus() == Status.PRE_CONNECTING) {
@@ -211,12 +225,12 @@ public class ConversationActivity extends Activity implements ServiceConnection,
server.getConversation(ServerInfo.DEFAULT_NAME).setHistorySize(historySize);
}
- DisplayMetrics dm = new DisplayMetrics();
- getWindowManager().getDefaultDisplay().getMetrics(dm);
- float fontSize = settings.getFontSize() * dm.scaledDensity;
+ final float scaledDensity = getResources().getDisplayMetrics().density;
+
+ float fontSize = settings.getFontSize() * scaledDensity;
indicator.setTextSize(fontSize);
- int padding = (int) (5 * dm.scaledDensity);
+ int padding = (int) (5 * scaledDensity);
input.setPadding(padding, padding, padding, padding);
indicator.setTypeface(Typeface.MONOSPACE);
@@ -410,7 +424,7 @@ public class ConversationActivity extends Activity implements ServiceConnection,
super.onCreateOptionsMenu(menu);
// inflate from xml
- MenuInflater inflater = getMenuInflater();
+ MenuInflater inflater = new MenuInflater(this);
inflater.inflate(R.menu.conversations, menu);
return true;
@@ -436,6 +450,10 @@ public class ConversationActivity extends Activity implements ServiceConnection,
public boolean onMenuItemSelected(int featureId, MenuItem item)
{
switch (item.getItemId()) {
+ case android.R.id.home:
+ finish();
+ break;
+
case R.id.disconnect:
server.setStatus(Status.DISCONNECTED);
server.setMayReconnect(false);
diff --git a/application/src/org/yaaic/activity/ServersActivity.java b/application/src/org/yaaic/activity/ServersActivity.java
index aa3e83d..7f23c15 100644
--- a/application/src/org/yaaic/activity/ServersActivity.java
+++ b/application/src/org/yaaic/activity/ServersActivity.java
@@ -28,7 +28,6 @@ import org.yaaic.adapter.ServerListAdapter;
import org.yaaic.db.Database;
import org.yaaic.irc.IRCBinder;
import org.yaaic.irc.IRCService;
-import org.yaaic.layout.NonScalingBackgroundDrawable;
import org.yaaic.listener.ServerListener;
import org.yaaic.model.Broadcast;
import org.yaaic.model.Extra;
@@ -37,7 +36,6 @@ import org.yaaic.model.Status;
import org.yaaic.receiver.ServerReceiver;
import android.app.AlertDialog;
-import android.app.ListActivity;
import android.content.ComponentName;
import android.content.DialogInterface;
import android.content.Intent;
@@ -45,21 +43,24 @@ import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.IBinder;
-import android.view.Menu;
-import android.view.MenuInflater;
-import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
+import android.widget.AdapterView.OnItemClickListener;
+import android.widget.AdapterView.OnItemLongClickListener;
import android.widget.ListView;
import android.widget.Toast;
-import android.widget.AdapterView.OnItemLongClickListener;
+
+import com.actionbarsherlock.app.SherlockActivity;
+import com.actionbarsherlock.view.Menu;
+import com.actionbarsherlock.view.MenuInflater;
+import com.actionbarsherlock.view.MenuItem;
/**
* List of servers
- *
+ *
* @author Sebastian Kaspari
*/
-public class ServersActivity extends ListActivity implements ServiceConnection, ServerListener, OnItemLongClickListener {
+public class ServersActivity extends SherlockActivity implements ServiceConnection, ServerListener, OnItemClickListener, OnItemLongClickListener {
private IRCBinder binder;
private ServerReceiver receiver;
private ServerListAdapter adapter;
@@ -78,7 +79,7 @@ public class ServersActivity extends ListActivity implements ServiceConnection,
* depending on the task the app was started in. In order to avoid
* stacking up of this duplicated activities we keep a count of this
* root activity and let it finish if it already exists
- *
+ *
* Launching the app via the notification icon creates a new task,
* and there doesn't seem to be a way around this so this is needed
*/
@@ -89,11 +90,11 @@ public class ServersActivity extends ListActivity implements ServiceConnection,
setContentView(R.layout.servers);
adapter = new ServerListAdapter();
- setListAdapter(adapter);
- list = getListView();
+ list = (ListView) findViewById(android.R.id.list);
+ list.setAdapter(adapter);
+ list.setOnItemClickListener(this);
list.setOnItemLongClickListener(this);
- list.setBackgroundDrawable(new NonScalingBackgroundDrawable(this, list, R.drawable.background));
}
/**
@@ -164,7 +165,7 @@ public class ServersActivity extends ListActivity implements ServiceConnection,
* On server selected
*/
@Override
- protected void onListItemClick(ListView l, View v, int position, long id) {
+ public void onItemClick(AdapterView> parent, View view, int position, long id) {
Server server = adapter.getItem(position);
if (server == null) {
@@ -240,7 +241,7 @@ public class ServersActivity extends ListActivity implements ServiceConnection,
/**
* Start activity to edit server with given id
- *
+ *
* @param serverId The id of the server
*/
private void editServer(int serverId)
@@ -266,7 +267,7 @@ public class ServersActivity extends ListActivity implements ServiceConnection,
super.onCreateOptionsMenu(menu);
// inflate from xml
- MenuInflater inflater = getMenuInflater();
+ MenuInflater inflater = new MenuInflater(this);
inflater.inflate(R.menu.servers, menu);
return true;
@@ -319,7 +320,7 @@ public class ServersActivity extends ListActivity implements ServiceConnection,
/**
* Delete server
- *
+ *
* @param serverId
*/
public void deleteServer(int serverId)
@@ -345,5 +346,4 @@ public class ServersActivity extends ListActivity implements ServiceConnection,
list.setBackgroundDrawable(null);
}
}
-
}
diff --git a/application/src/org/yaaic/activity/SettingsActivity.java b/application/src/org/yaaic/activity/SettingsActivity.java
index 61f61bb..dc6a0ff 100644
--- a/application/src/org/yaaic/activity/SettingsActivity.java
+++ b/application/src/org/yaaic/activity/SettingsActivity.java
@@ -23,14 +23,15 @@ package org.yaaic.activity;
import org.yaaic.R;
import android.os.Bundle;
-import android.preference.PreferenceActivity;
+
+import com.actionbarsherlock.app.SherlockPreferenceActivity;
/**
* Settings
- *
+ *
* @author Sebastian Kaspari
*/
-public class SettingsActivity extends PreferenceActivity
+public class SettingsActivity extends SherlockPreferenceActivity
{
/**
* On create
diff --git a/application/src/org/yaaic/adapter/ConversationPagerAdapter.java b/application/src/org/yaaic/adapter/ConversationPagerAdapter.java
index b5e7bdf..b3233fc 100644
--- a/application/src/org/yaaic/adapter/ConversationPagerAdapter.java
+++ b/application/src/org/yaaic/adapter/ConversationPagerAdapter.java
@@ -247,6 +247,7 @@ public class ConversationPagerAdapter extends PagerAdapter implements TitleProvi
convInfo.adapter = adapter;
}
+
list.setAdapter(adapter);
list.setSelection(adapter.getCount() - 1); // scroll to bottom
diff --git a/application/src/org/yaaic/irc/IRCService.java b/application/src/org/yaaic/irc/IRCService.java
index d7182ad..ed03f9d 100644
--- a/application/src/org/yaaic/irc/IRCService.java
+++ b/application/src/org/yaaic/irc/IRCService.java
@@ -564,6 +564,7 @@ public class IRCService extends Service
}
synchronized(alarmIntentsLock) {
+ // XXX: alarmIntents can be null
PendingIntent pendingRIntent = alarmIntents.get(serverId);
if (pendingRIntent != null) {
AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE);
diff --git a/application/src/org/yaaic/layout/NonScalingBackgroundDrawable.java b/application/src/org/yaaic/layout/NonScalingBackgroundDrawable.java
deleted file mode 100644
index 4620671..0000000
--- a/application/src/org/yaaic/layout/NonScalingBackgroundDrawable.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
-Yaaic - Yet Another Android IRC Client
-
-Copyright 2009-2011 Sebastian Kaspari
-
-This file is part of Yaaic.
-
-Yaaic is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-Yaaic is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with Yaaic. If not, see .
- */
-package org.yaaic.layout;
-
-import android.content.Context;
-import android.graphics.Canvas;
-import android.graphics.ColorFilter;
-import android.graphics.drawable.Drawable;
-import android.view.View;
-
-/**
- * Wrapper for background drawables that should not be scaled
- *
- * @author Sebastian Kaspari
- */
-public class NonScalingBackgroundDrawable extends Drawable
-{
- private final View view;
- private final Drawable drawable;
-
- /**
- * Create a new non scaling background drawable
- *
- * @param context
- * @param view
- * @param resource
- */
- public NonScalingBackgroundDrawable(Context context, View view, int resource)
- {
- this.view = view;
- this.drawable = context.getResources().getDrawable(resource);
- }
-
- /**
- * Draw the background drawable
- */
- @Override
- public void draw(Canvas canvas)
- {
- int left = (view.getWidth() / 2) - (drawable.getIntrinsicWidth() / 2);
- int top = (view.getHeight() / 2) - (drawable.getIntrinsicHeight() / 2);
- int right = left + drawable.getIntrinsicWidth();
- int bottom = top + drawable.getIntrinsicHeight();
-
- drawable.setBounds(left, top, right, bottom);
-
- drawable.draw(canvas);
- }
-
- /**
- * Get the opacity
- */
- @Override
- public int getOpacity()
- {
- return drawable.getOpacity();
- }
-
- /**
- * Set the alpha
- */
- @Override
- public void setAlpha(int alpha)
- {
- drawable.setAlpha(alpha);
- }
-
- /**
- * Set the color filter
- */
- @Override
- public void setColorFilter(ColorFilter cf)
- {
- drawable.setColorFilter(cf);
- }
-}
diff --git a/application/src/org/yaaic/view/MessageListView.java b/application/src/org/yaaic/view/MessageListView.java
index 744d480..d39d468 100644
--- a/application/src/org/yaaic/view/MessageListView.java
+++ b/application/src/org/yaaic/view/MessageListView.java
@@ -47,16 +47,16 @@ public class MessageListView extends ListView
setDivider(null);
- setBackgroundResource(R.layout.border);
- setCacheColorHint(0xFF181818);
+ setCacheColorHint(0x000000);
setVerticalFadingEdgeEnabled(false);
+ setBackgroundResource(R.layout.conversation_background);
setScrollBarStyle(SCROLLBARS_OUTSIDE_INSET);
setTranscriptMode(TRANSCRIPT_MODE_ALWAYS_SCROLL);
// Scale padding by screen density
float density = context.getResources().getDisplayMetrics().density;
int padding = (int) (5 * density);
- setPadding(padding, padding, padding, 0);
+ setPadding(padding, padding, padding, padding);
// XXX: This should be dynamically
setTranscriptMode(TRANSCRIPT_MODE_ALWAYS_SCROLL);