Add ActionBarSherlock to all activities. Restructure menu items. Fixes #96.
This commit is contained in:
parent
3e9735760a
commit
fbdebc2ca5
|
@ -26,7 +26,8 @@ along with Yaaic. If not, see <http://www.gnu.org/licenses/>.
|
||||||
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="15" />
|
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="15" />
|
||||||
<application
|
<application
|
||||||
android:icon="@drawable/icon"
|
android:icon="@drawable/icon"
|
||||||
android:label="Yaaic">
|
android:label="Yaaic"
|
||||||
|
android:theme="@style/Theme.Sherlock">
|
||||||
<activity
|
<activity
|
||||||
android:name=".activity.ServersActivity"
|
android:name=".activity.ServersActivity"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
|
|
|
@ -19,27 +19,14 @@ GNU General Public License for more details.
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with Yaaic. If not, see <http://www.gnu.org/licenses/>.
|
along with Yaaic. If not, see <http://www.gnu.org/licenses/>.
|
||||||
-->
|
-->
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<TextView
|
||||||
android:orientation="horizontal"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:padding="5dp">
|
android:layout_gravity="center_vertical"
|
||||||
<LinearLayout
|
android:drawableLeft="@drawable/actionbar_add"
|
||||||
android:layout_width="fill_parent"
|
android:drawablePadding="5dip"
|
||||||
android:layout_height="wrap_content"
|
android:padding="10dip"
|
||||||
android:orientation="horizontal">
|
android:gravity="center_vertical"
|
||||||
<ImageView
|
android:text="@string/add_server_list"
|
||||||
android:id="@+id/status"
|
android:textSize="18sp" />
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:src="@android:drawable/ic_menu_add"
|
|
||||||
android:layout_gravity="center_vertical"
|
|
||||||
android:paddingRight="5dp" />
|
|
||||||
<TextView
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center_vertical"
|
|
||||||
android:text="@string/add_server_list"
|
|
||||||
android:textSize="18sp" />
|
|
||||||
</LinearLayout>
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
|
@ -24,12 +24,12 @@ along with Yaaic. If not, see <http://www.gnu.org/licenses/>.
|
||||||
android:shape="rectangle">
|
android:shape="rectangle">
|
||||||
<stroke
|
<stroke
|
||||||
android:width="1dp"
|
android:width="1dp"
|
||||||
android:color="#3f5d9b" />
|
android:color="#FF181818" />
|
||||||
<padding
|
<padding
|
||||||
android:left="3dp"
|
android:left="3dp"
|
||||||
android:top="3dp"
|
android:top="3dp"
|
||||||
android:right="3dp"
|
android:right="3dp"
|
||||||
android:bottom="3dp" />
|
android:bottom="3dp" />
|
||||||
<solid
|
<solid
|
||||||
android:color="#ff181818" />
|
android:color="#FF000000" />
|
||||||
</shape>
|
</shape>
|
|
@ -27,16 +27,13 @@ along with Yaaic. If not, see <http://www.gnu.org/licenses/>.
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="fill_parent">
|
android:layout_height="wrap_content">
|
||||||
<TextView
|
<TextView
|
||||||
android:text="@string/server"
|
android:text="@string/server"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="#ff333333"
|
android:layout_marginBottom="3dip"
|
||||||
android:textSize="16sp"
|
style="?android:attr/listSeparatorTextViewStyle" />
|
||||||
android:gravity="center_horizontal"
|
|
||||||
android:padding="3dp"
|
|
||||||
android:layout_margin="2dp" />
|
|
||||||
<TextView
|
<TextView
|
||||||
android:text="@string/server_title"
|
android:text="@string/server_title"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
|
@ -100,11 +97,8 @@ along with Yaaic. If not, see <http://www.gnu.org/licenses/>.
|
||||||
android:text="@string/user"
|
android:text="@string/user"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="#ff333333"
|
android:layout_marginBottom="3dip"
|
||||||
android:textSize="16sp"
|
style="?android:attr/listSeparatorTextViewStyle" />
|
||||||
android:gravity="center_horizontal"
|
|
||||||
android:padding="3dp"
|
|
||||||
android:layout_margin="2dp" />
|
|
||||||
<TextView
|
<TextView
|
||||||
android:text="@string/nickname"
|
android:text="@string/nickname"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
|
@ -144,14 +138,11 @@ along with Yaaic. If not, see <http://www.gnu.org/licenses/>.
|
||||||
android:singleLine="true" />
|
android:singleLine="true" />
|
||||||
<!-- ############################################################################ -->
|
<!-- ############################################################################ -->
|
||||||
<TextView
|
<TextView
|
||||||
android:text="@string/on_connect"
|
android:text="@string/on_connect"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="#ff333333"
|
android:layout_marginBottom="3dip"
|
||||||
android:textSize="16sp"
|
style="?android:attr/listSeparatorTextViewStyle" />
|
||||||
android:gravity="center_horizontal"
|
|
||||||
android:padding="3dp"
|
|
||||||
android:layout_margin="2dp" />
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/authentication"
|
android:id="@+id/authentication"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
|
@ -169,14 +160,11 @@ along with Yaaic. If not, see <http://www.gnu.org/licenses/>.
|
||||||
android:text="@string/commands" />
|
android:text="@string/commands" />
|
||||||
<!-- ############################################################################ -->
|
<!-- ############################################################################ -->
|
||||||
<TextView
|
<TextView
|
||||||
android:text="@string/preferences"
|
android:text="@string/preferences"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="#ff333333"
|
android:layout_marginBottom="3dip"
|
||||||
android:textSize="16sp"
|
style="?android:attr/listSeparatorTextViewStyle" />
|
||||||
android:gravity="center_horizontal"
|
|
||||||
android:padding="3dp"
|
|
||||||
android:layout_margin="2dp" />
|
|
||||||
<TextView
|
<TextView
|
||||||
android:text="@string/charset"
|
android:text="@string/charset"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
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 <http://www.gnu.org/licenses/>.
|
||||||
|
-->
|
||||||
|
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item
|
||||||
|
android:id="@+id/save"
|
||||||
|
android:title="@string/server_save"
|
||||||
|
android:icon="@drawable/actionbar_save"
|
||||||
|
android:showAsAction="ifRoom|withText" />
|
||||||
|
</menu>
|
|
@ -23,17 +23,21 @@ along with Yaaic. If not, see <http://www.gnu.org/licenses/>.
|
||||||
<item
|
<item
|
||||||
android:id="@+id/join"
|
android:id="@+id/join"
|
||||||
android:title="@string/join_channel"
|
android:title="@string/join_channel"
|
||||||
android:icon="@android:drawable/ic_menu_add" />
|
android:icon="@drawable/actionbar_add"
|
||||||
|
android:showAsAction="ifRoom|withText" />
|
||||||
<item
|
<item
|
||||||
android:id="@+id/users"
|
android:id="@+id/users"
|
||||||
android:title="@string/users"
|
android:title="@string/users"
|
||||||
android:icon="@drawable/menu_users" />
|
android:icon="@drawable/actionbar_users"
|
||||||
|
android:showAsAction="ifRoom|withText" />
|
||||||
<item
|
<item
|
||||||
android:id="@+id/close"
|
android:id="@+id/close"
|
||||||
android:title="@string/close"
|
android:title="@string/close"
|
||||||
android:icon="@android:drawable/ic_menu_close_clear_cancel" />
|
android:icon="@android:drawable/ic_menu_close_clear_cancel"
|
||||||
|
android:showAsAction="never" />
|
||||||
<item
|
<item
|
||||||
android:id="@+id/disconnect"
|
android:id="@+id/disconnect"
|
||||||
android:title="@string/disconnect"
|
android:title="@string/disconnect"
|
||||||
android:icon="@android:drawable/ic_menu_revert" />
|
android:icon="@android:drawable/ic_menu_revert"
|
||||||
|
android:showAsAction="never" />
|
||||||
</menu>
|
</menu>
|
|
@ -23,11 +23,13 @@ along with Yaaic. If not, see <http://www.gnu.org/licenses/>.
|
||||||
<item
|
<item
|
||||||
android:id="@+id/add"
|
android:id="@+id/add"
|
||||||
android:title="@string/add_server_menu"
|
android:title="@string/add_server_menu"
|
||||||
android:icon="@android:drawable/ic_menu_add" />
|
android:icon="@drawable/actionbar_add"
|
||||||
|
android:showAsAction="ifRoom|withText" />
|
||||||
<item
|
<item
|
||||||
android:id="@+id/settings"
|
android:id="@+id/settings"
|
||||||
android:title="@string/settings_menu"
|
android:title="@string/settings_menu"
|
||||||
android:icon="@android:drawable/ic_menu_preferences" />
|
android:icon="@drawable/actionbar_settings"
|
||||||
|
android:showAsAction="ifRoom" />
|
||||||
<item
|
<item
|
||||||
android:id="@+id/about"
|
android:id="@+id/about"
|
||||||
android:title="@string/about_menu"
|
android:title="@string/about_menu"
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
<string name="users_label">Users</string>
|
<string name="users_label">Users</string>
|
||||||
<string name="channels_label">Channels</string>
|
<string name="channels_label">Channels</string>
|
||||||
<string name="add_server_label">Add new server</string>
|
<string name="add_server_label">Add new server</string>
|
||||||
|
<string name="edit_server_label">Edit server</string>
|
||||||
|
|
||||||
<string name="server_title">Title</string>
|
<string name="server_title">Title</string>
|
||||||
<string name="server_host">Host</string>
|
<string name="server_host">Host</string>
|
||||||
|
|
|
@ -34,7 +34,6 @@ import org.yaaic.model.Identity;
|
||||||
import org.yaaic.model.Server;
|
import org.yaaic.model.Server;
|
||||||
import org.yaaic.model.Status;
|
import org.yaaic.model.Status;
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
@ -47,12 +46,17 @@ import android.widget.EditText;
|
||||||
import android.widget.Spinner;
|
import android.widget.Spinner;
|
||||||
import android.widget.Toast;
|
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
|
* Add a new server to the list
|
||||||
*
|
*
|
||||||
* @author Sebastian Kaspari <sebastian@yaaic.org>
|
* @author Sebastian Kaspari <sebastian@yaaic.org>
|
||||||
*/
|
*/
|
||||||
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_CHANNELS = 1;
|
||||||
private static final int REQUEST_CODE_COMMANDS = 2;
|
private static final int REQUEST_CODE_COMMANDS = 2;
|
||||||
|
@ -95,6 +99,8 @@ public class AddServerActivity extends Activity implements OnClickListener
|
||||||
|
|
||||||
Bundle extras = getIntent().getExtras();
|
Bundle extras = getIntent().getExtras();
|
||||||
if (extras != null && extras.containsKey(Extra.SERVER)) {
|
if (extras != null && extras.containsKey(Extra.SERVER)) {
|
||||||
|
setTitle(R.string.edit_server_label);
|
||||||
|
|
||||||
// Request to edit an existing server
|
// Request to edit an existing server
|
||||||
Database db = new Database(this);
|
Database db = new Database(this);
|
||||||
this.server = db.getServerById(extras.getInt(Extra.SERVER));
|
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
|
* On activity result
|
||||||
*/
|
*/
|
||||||
|
@ -215,19 +250,7 @@ public class AddServerActivity extends Activity implements OnClickListener
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case R.id.add:
|
case R.id.add:
|
||||||
try {
|
save();
|
||||||
validateServer();
|
|
||||||
validateIdentity();
|
|
||||||
if (server == null) {
|
|
||||||
addServer();
|
|
||||||
} else {
|
|
||||||
updateServer();
|
|
||||||
}
|
|
||||||
setResult(RESULT_OK);
|
|
||||||
finish();
|
|
||||||
} catch(ValidationException e) {
|
|
||||||
Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case R.id.cancel:
|
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
|
* Add server to database
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -49,7 +49,6 @@ import org.yaaic.model.User;
|
||||||
import org.yaaic.receiver.ConversationReceiver;
|
import org.yaaic.receiver.ConversationReceiver;
|
||||||
import org.yaaic.receiver.ServerReceiver;
|
import org.yaaic.receiver.ServerReceiver;
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
|
@ -66,14 +65,9 @@ import android.os.IBinder;
|
||||||
import android.speech.RecognizerIntent;
|
import android.speech.RecognizerIntent;
|
||||||
import android.support.v4.view.ViewPager;
|
import android.support.v4.view.ViewPager;
|
||||||
import android.text.InputType;
|
import android.text.InputType;
|
||||||
import android.util.DisplayMetrics;
|
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.Menu;
|
|
||||||
import android.view.MenuInflater;
|
|
||||||
import android.view.MenuItem;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnKeyListener;
|
import android.view.View.OnKeyListener;
|
||||||
import android.view.Window;
|
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.view.inputmethod.EditorInfo;
|
import android.view.inputmethod.EditorInfo;
|
||||||
import android.view.inputmethod.InputMethodManager;
|
import android.view.inputmethod.InputMethodManager;
|
||||||
|
@ -81,14 +75,20 @@ import android.widget.Button;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.Toast;
|
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;
|
||||||
|
import com.viewpagerindicator.TitlePageIndicator.IndicatorStyle;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The server view with a scrollable list of all channels
|
* The server view with a scrollable list of all channels
|
||||||
*
|
*
|
||||||
* @author Sebastian Kaspari <sebastian@yaaic.org>
|
* @author Sebastian Kaspari <sebastian@yaaic.org>
|
||||||
*/
|
*/
|
||||||
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;
|
public static final int REQUEST_CODE_SPEECH = 99;
|
||||||
|
|
||||||
|
@ -171,7 +171,6 @@ public class ConversationActivity extends Activity implements ServiceConnection,
|
||||||
protected void onCreate(Bundle savedInstanceState)
|
protected void onCreate(Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
|
||||||
|
|
||||||
serverId = getIntent().getExtras().getInt("serverId");
|
serverId = getIntent().getExtras().getInt("serverId");
|
||||||
server = Yaaic.getInstance().getServerById(serverId);
|
server = Yaaic.getInstance().getServerById(serverId);
|
||||||
|
@ -182,13 +181,17 @@ public class ConversationActivity extends Activity implements ServiceConnection,
|
||||||
this.finish();
|
this.finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
setTitle("Yaaic - " + server.getTitle());
|
ActionBar actionBar = getSupportActionBar();
|
||||||
|
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||||
|
|
||||||
setContentView(R.layout.conversations);
|
setTitle(server.getTitle());
|
||||||
if (settings.fullscreenConversations()){
|
|
||||||
|
if (settings.fullscreenConversations()) {
|
||||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setContentView(R.layout.conversations);
|
||||||
|
|
||||||
boolean isLandscape = (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE);
|
boolean isLandscape = (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE);
|
||||||
|
|
||||||
EditText input = (EditText) findViewById(R.id.input);
|
EditText input = (EditText) findViewById(R.id.input);
|
||||||
|
@ -199,10 +202,21 @@ public class ConversationActivity extends Activity implements ServiceConnection,
|
||||||
pagerAdapter = new ConversationPagerAdapter(server);
|
pagerAdapter = new ConversationPagerAdapter(server);
|
||||||
pager.setAdapter(pagerAdapter);
|
pager.setAdapter(pagerAdapter);
|
||||||
|
|
||||||
|
final float density = getResources().getDisplayMetrics().density;
|
||||||
|
|
||||||
TitlePageIndicator indicator = (TitlePageIndicator) findViewById(R.id.titleIndicator);
|
TitlePageIndicator indicator = (TitlePageIndicator) findViewById(R.id.titleIndicator);
|
||||||
indicator.setTypeface(Typeface.MONOSPACE);
|
indicator.setTypeface(Typeface.MONOSPACE);
|
||||||
indicator.setViewPager(pager);
|
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();
|
historySize = settings.getHistorySize();
|
||||||
|
|
||||||
if (server.getStatus() == Status.PRE_CONNECTING) {
|
if (server.getStatus() == Status.PRE_CONNECTING) {
|
||||||
|
@ -211,12 +225,12 @@ public class ConversationActivity extends Activity implements ServiceConnection,
|
||||||
server.getConversation(ServerInfo.DEFAULT_NAME).setHistorySize(historySize);
|
server.getConversation(ServerInfo.DEFAULT_NAME).setHistorySize(historySize);
|
||||||
}
|
}
|
||||||
|
|
||||||
DisplayMetrics dm = new DisplayMetrics();
|
final float scaledDensity = getResources().getDisplayMetrics().density;
|
||||||
getWindowManager().getDefaultDisplay().getMetrics(dm);
|
|
||||||
float fontSize = settings.getFontSize() * dm.scaledDensity;
|
float fontSize = settings.getFontSize() * scaledDensity;
|
||||||
indicator.setTextSize(fontSize);
|
indicator.setTextSize(fontSize);
|
||||||
|
|
||||||
int padding = (int) (5 * dm.scaledDensity);
|
int padding = (int) (5 * scaledDensity);
|
||||||
input.setPadding(padding, padding, padding, padding);
|
input.setPadding(padding, padding, padding, padding);
|
||||||
indicator.setTypeface(Typeface.MONOSPACE);
|
indicator.setTypeface(Typeface.MONOSPACE);
|
||||||
|
|
||||||
|
@ -410,7 +424,7 @@ public class ConversationActivity extends Activity implements ServiceConnection,
|
||||||
super.onCreateOptionsMenu(menu);
|
super.onCreateOptionsMenu(menu);
|
||||||
|
|
||||||
// inflate from xml
|
// inflate from xml
|
||||||
MenuInflater inflater = getMenuInflater();
|
MenuInflater inflater = new MenuInflater(this);
|
||||||
inflater.inflate(R.menu.conversations, menu);
|
inflater.inflate(R.menu.conversations, menu);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -436,6 +450,10 @@ public class ConversationActivity extends Activity implements ServiceConnection,
|
||||||
public boolean onMenuItemSelected(int featureId, MenuItem item)
|
public boolean onMenuItemSelected(int featureId, MenuItem item)
|
||||||
{
|
{
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
|
case android.R.id.home:
|
||||||
|
finish();
|
||||||
|
break;
|
||||||
|
|
||||||
case R.id.disconnect:
|
case R.id.disconnect:
|
||||||
server.setStatus(Status.DISCONNECTED);
|
server.setStatus(Status.DISCONNECTED);
|
||||||
server.setMayReconnect(false);
|
server.setMayReconnect(false);
|
||||||
|
|
|
@ -28,7 +28,6 @@ import org.yaaic.adapter.ServerListAdapter;
|
||||||
import org.yaaic.db.Database;
|
import org.yaaic.db.Database;
|
||||||
import org.yaaic.irc.IRCBinder;
|
import org.yaaic.irc.IRCBinder;
|
||||||
import org.yaaic.irc.IRCService;
|
import org.yaaic.irc.IRCService;
|
||||||
import org.yaaic.layout.NonScalingBackgroundDrawable;
|
|
||||||
import org.yaaic.listener.ServerListener;
|
import org.yaaic.listener.ServerListener;
|
||||||
import org.yaaic.model.Broadcast;
|
import org.yaaic.model.Broadcast;
|
||||||
import org.yaaic.model.Extra;
|
import org.yaaic.model.Extra;
|
||||||
|
@ -37,7 +36,6 @@ import org.yaaic.model.Status;
|
||||||
import org.yaaic.receiver.ServerReceiver;
|
import org.yaaic.receiver.ServerReceiver;
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.ListActivity;
|
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
@ -45,21 +43,24 @@ import android.content.IntentFilter;
|
||||||
import android.content.ServiceConnection;
|
import android.content.ServiceConnection;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.view.Menu;
|
|
||||||
import android.view.MenuInflater;
|
|
||||||
import android.view.MenuItem;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
|
import android.widget.AdapterView.OnItemClickListener;
|
||||||
|
import android.widget.AdapterView.OnItemLongClickListener;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.Toast;
|
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
|
* List of servers
|
||||||
*
|
*
|
||||||
* @author Sebastian Kaspari <sebastian@yaaic.org>
|
* @author Sebastian Kaspari <sebastian@yaaic.org>
|
||||||
*/
|
*/
|
||||||
public class ServersActivity extends ListActivity implements ServiceConnection, ServerListener, OnItemLongClickListener {
|
public class ServersActivity extends SherlockActivity implements ServiceConnection, ServerListener, OnItemClickListener, OnItemLongClickListener {
|
||||||
private IRCBinder binder;
|
private IRCBinder binder;
|
||||||
private ServerReceiver receiver;
|
private ServerReceiver receiver;
|
||||||
private ServerListAdapter adapter;
|
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
|
* 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
|
* stacking up of this duplicated activities we keep a count of this
|
||||||
* root activity and let it finish if it already exists
|
* root activity and let it finish if it already exists
|
||||||
*
|
*
|
||||||
* Launching the app via the notification icon creates a new task,
|
* 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
|
* 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);
|
setContentView(R.layout.servers);
|
||||||
|
|
||||||
adapter = new ServerListAdapter();
|
adapter = new ServerListAdapter();
|
||||||
setListAdapter(adapter);
|
|
||||||
|
|
||||||
list = getListView();
|
list = (ListView) findViewById(android.R.id.list);
|
||||||
|
list.setAdapter(adapter);
|
||||||
|
list.setOnItemClickListener(this);
|
||||||
list.setOnItemLongClickListener(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
|
* On server selected
|
||||||
*/
|
*/
|
||||||
@Override
|
@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);
|
Server server = adapter.getItem(position);
|
||||||
|
|
||||||
if (server == null) {
|
if (server == null) {
|
||||||
|
@ -240,7 +241,7 @@ public class ServersActivity extends ListActivity implements ServiceConnection,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start activity to edit server with given id
|
* Start activity to edit server with given id
|
||||||
*
|
*
|
||||||
* @param serverId The id of the server
|
* @param serverId The id of the server
|
||||||
*/
|
*/
|
||||||
private void editServer(int serverId)
|
private void editServer(int serverId)
|
||||||
|
@ -266,7 +267,7 @@ public class ServersActivity extends ListActivity implements ServiceConnection,
|
||||||
super.onCreateOptionsMenu(menu);
|
super.onCreateOptionsMenu(menu);
|
||||||
|
|
||||||
// inflate from xml
|
// inflate from xml
|
||||||
MenuInflater inflater = getMenuInflater();
|
MenuInflater inflater = new MenuInflater(this);
|
||||||
inflater.inflate(R.menu.servers, menu);
|
inflater.inflate(R.menu.servers, menu);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -319,7 +320,7 @@ public class ServersActivity extends ListActivity implements ServiceConnection,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete server
|
* Delete server
|
||||||
*
|
*
|
||||||
* @param serverId
|
* @param serverId
|
||||||
*/
|
*/
|
||||||
public void deleteServer(int serverId)
|
public void deleteServer(int serverId)
|
||||||
|
@ -345,5 +346,4 @@ public class ServersActivity extends ListActivity implements ServiceConnection,
|
||||||
list.setBackgroundDrawable(null);
|
list.setBackgroundDrawable(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,14 +23,15 @@ package org.yaaic.activity;
|
||||||
import org.yaaic.R;
|
import org.yaaic.R;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.PreferenceActivity;
|
|
||||||
|
import com.actionbarsherlock.app.SherlockPreferenceActivity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Settings
|
* Settings
|
||||||
*
|
*
|
||||||
* @author Sebastian Kaspari <sebastian@yaaic.org>
|
* @author Sebastian Kaspari <sebastian@yaaic.org>
|
||||||
*/
|
*/
|
||||||
public class SettingsActivity extends PreferenceActivity
|
public class SettingsActivity extends SherlockPreferenceActivity
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* On create
|
* On create
|
||||||
|
|
|
@ -247,6 +247,7 @@ public class ConversationPagerAdapter extends PagerAdapter implements TitleProvi
|
||||||
convInfo.adapter = adapter;
|
convInfo.adapter = adapter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
list.setAdapter(adapter);
|
list.setAdapter(adapter);
|
||||||
list.setSelection(adapter.getCount() - 1); // scroll to bottom
|
list.setSelection(adapter.getCount() - 1); // scroll to bottom
|
||||||
|
|
||||||
|
|
|
@ -564,6 +564,7 @@ public class IRCService extends Service
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized(alarmIntentsLock) {
|
synchronized(alarmIntentsLock) {
|
||||||
|
// XXX: alarmIntents can be null
|
||||||
PendingIntent pendingRIntent = alarmIntents.get(serverId);
|
PendingIntent pendingRIntent = alarmIntents.get(serverId);
|
||||||
if (pendingRIntent != null) {
|
if (pendingRIntent != null) {
|
||||||
AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE);
|
AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE);
|
||||||
|
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
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 <sebastian@yaaic.org>
|
|
||||||
*/
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -47,16 +47,16 @@ public class MessageListView extends ListView
|
||||||
|
|
||||||
setDivider(null);
|
setDivider(null);
|
||||||
|
|
||||||
setBackgroundResource(R.layout.border);
|
setCacheColorHint(0x000000);
|
||||||
setCacheColorHint(0xFF181818);
|
|
||||||
setVerticalFadingEdgeEnabled(false);
|
setVerticalFadingEdgeEnabled(false);
|
||||||
|
setBackgroundResource(R.layout.conversation_background);
|
||||||
setScrollBarStyle(SCROLLBARS_OUTSIDE_INSET);
|
setScrollBarStyle(SCROLLBARS_OUTSIDE_INSET);
|
||||||
setTranscriptMode(TRANSCRIPT_MODE_ALWAYS_SCROLL);
|
setTranscriptMode(TRANSCRIPT_MODE_ALWAYS_SCROLL);
|
||||||
|
|
||||||
// Scale padding by screen density
|
// Scale padding by screen density
|
||||||
float density = context.getResources().getDisplayMetrics().density;
|
float density = context.getResources().getDisplayMetrics().density;
|
||||||
int padding = (int) (5 * density);
|
int padding = (int) (5 * density);
|
||||||
setPadding(padding, padding, padding, 0);
|
setPadding(padding, padding, padding, padding);
|
||||||
|
|
||||||
// XXX: This should be dynamically
|
// XXX: This should be dynamically
|
||||||
setTranscriptMode(TRANSCRIPT_MODE_ALWAYS_SCROLL);
|
setTranscriptMode(TRANSCRIPT_MODE_ALWAYS_SCROLL);
|
||||||
|
|
Loading…
Reference in New Issue